SWMMVis  6.0.0-alpha.4
Qt6/C++ GIS-based graphical user interface for the SWMMVis engine (6.0.0-alpha.4)
Loading...
Searching...
No Matches
layerstyledialog.h
Go to the documentation of this file.
1
26#ifndef OPENSWMMVIS_UI_DIALOGS_LAYERSTYLEDIALOG_H
27#define OPENSWMMVIS_UI_DIALOGS_LAYERSTYLEDIALOG_H
28
29#include <QDialog>
30#include <QFlags>
31#include <QJsonObject>
32#include <QPointer>
33#include <QString>
34
35#include <memory>
36#include <vector>
37
38class QLineEdit;
39class QLabel;
40class QToolButton;
41class QCheckBox;
42class QComboBox;
43class QGroupBox;
44class QSlider;
45class QSpinBox;
46class QPlainTextEdit;
47class QTableWidget;
48class QTabWidget;
49
51class QUndoStack; // #36 — optional app-level undo for symbology edits
52
53namespace openswmmvis::ui {
54
55class ILayerStyleSubject;
56
67enum class LayerCapability : unsigned int
68{
69 Information = 1u << 0,
70 Source = 1u << 1,
71 Symbology = 1u << 2,
72 Labels = 1u << 3,
73 Rendering = 1u << 4,
74 Metadata = 1u << 5,
75 // VS.5 — the deferred-feature tabs (Temporal / Mask / AuxStorage /
76 // Joins / Diagrams) were removed from the dialog for simplicity. Their
77 // capability bits are retired; the standalone tab widget classes are
78 // scheduled for stale-file cleanup in VS.11.
79};
80Q_DECLARE_FLAGS(LayerCapabilities, LayerCapability)
81
82
83[[nodiscard]] LayerCapabilities layerCapabilities(OpenSWMMVisLayer *layer);
84
85// ---------------------------------------------------------------------------
86
87class LayerStyleDialog : public QDialog
88{
89 Q_OBJECT
90public:
91 explicit LayerStyleDialog(OpenSWMMVisLayer *layer,
92 QString initialRoutingId = {},
93 QWidget *parent = nullptr,
94 QUndoStack *undoStack = nullptr); // #36 — optional
96
97private slots:
98 void onApply();
99 void onAccept();
100 void onCancel();
101 void onPickCRS();
102 void onOpacitySliderChanged(int v);
103 void onOpacitySpinChanged(int v);
107 void onImportStyle();
108 void onExportStyle();
109
113 void onBasemapRenderParamsChanged();
114
115private:
116 void buildTabs();
117 void buildInformationTab();
118 void buildSourceTab();
119 void buildSymbologyTab();
120 void buildLabelsTab();
121 void buildRenderingTab();
122 void buildMetadataTab();
123 void readFromLayer();
124 // Rebuild the Metadata tab's key/value table from the common block plus
125 // the active layer's extendedMetadata(). Also used by the Refresh button
126 // so a live results layer's growing counts can be re-read on demand.
127 void populateMetadata();
128 void writeGeneralRenderingToLayer();
129 void snapshotSubjects();
130 void restoreSubjectsFromSnapshot();
131 void focusInitialSubject();
132
133 QPointer<OpenSWMMVisLayer> m_layer;
134 LayerCapabilities m_caps;
135
136 // Subject wrappers are owned by the dialog; the property objects they
137 // point at are the layer's PERSISTENT adapters (adapter-ownership
138 // refactor), so every panel edits the same instances the snapshots
139 // cover. Rendered into the Symbology / Labels tabs as appropriate.
140 std::vector<std::unique_ptr<ILayerStyleSubject>> m_subjects;
141 std::vector<QJsonObject> m_subjectSnapshots;
142 // Full renderer-state baseline for Cancel (kind renderers, layer
143 // renderer, label config) via StyleFileIO::styleToJson — the part the
144 // per-subject snapshots don't cover. Refreshed on Apply / import.
145 QJsonObject m_styleSnapshot;
146
147 // #36 — app-level undo. m_undoBaseline (+ m_undoStyleBaseline) is the
148 // state at dialog open; on OK, if it changed, push an
149 // EditLayerStyleCommand(before,after) onto m_undoStack so the symbology
150 // edit is undoable after the dialog closes. Null stack → no command
151 // (back-compat for callers without one).
152 QUndoStack *m_undoStack = nullptr;
153 std::vector<QJsonObject> m_undoBaseline;
154 QJsonObject m_undoStyleBaseline;
155
156 QString m_initialRoutingId;
157
158 // Vertical sidebar (tabPosition = West).
159 QTabWidget *m_tabs = nullptr;
160
161 // Information tab widgets.
162 QLineEdit *m_nameEdit = nullptr;
163 QLabel *m_typeLabel = nullptr;
164 QPlainTextEdit *m_infoText = nullptr;
165
166 // Source tab widgets.
167 QLabel *m_sourceLabel = nullptr; // populated in readFromLayer()
168 QLabel *m_crsLabel = nullptr;
169 QToolButton *m_crsButton = nullptr;
170 QString m_pendingCRSAuthority;
171
172 // Rendering tab widgets.
173 QCheckBox *m_visibleBox = nullptr;
174 QSlider *m_opacitySlider = nullptr;
175 QSpinBox *m_opacitySpin = nullptr;
176
177 // Slice X.26 — basemap render adjustments (only created when the
178 // active layer is a basemap kind: XYZ / WMTS / WMS / WCS).
179 QGroupBox *m_basemapAdjustBox = nullptr;
180 QSlider *m_brightnessSlider = nullptr;
181 QSlider *m_contrastSlider = nullptr;
182 QSlider *m_saturationSlider = nullptr;
183 QComboBox *m_resamplingCombo = nullptr;
184
185 // Metadata tab — read-only Name/Value table (common block + the layer's
186 // type-specific extendedMetadata()).
187 QTableWidget *m_metadataTable = nullptr;
188
189 // General / Rendering snapshot for Cancel rollback.
190 QString m_snapshotName;
191 bool m_snapshotVisible = true;
192 double m_snapshotOpacity = 1.0;
193};
194
195} // namespace openswmmvis::ui
196
197Q_DECLARE_OPERATORS_FOR_FLAGS(openswmmvis::ui::LayerCapabilities)
198
199#endif // OPENSWMMVIS_UI_DIALOGS_LAYERSTYLEDIALOG_H
Abstract base class for all layers displayed in the MapCanvas.
Definition openswmmvislayer.h:116
Definition layerstyledialog.h:88
Definition openswmmvislayer.h:43
LayerCapability
Which tabs apply to a given layer type.
Definition layerstyledialog.h:68
LayerCapabilities layerCapabilities(OpenSWMMVisLayer *layer)
Definition layerstyledialog.cpp:309
QVector< int > v
pool vertex indices
Definition pslgminsize.cpp:159
QVector< int > parent
union-find
Definition pslgminsize.cpp:176