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
meshattributeassigndialog.h
Go to the documentation of this file.
1
50#ifndef OPENSWMMVIS_UI_DIALOGS_MESHATTRIBUTEASSIGNDIALOG_H
51#define OPENSWMMVIS_UI_DIALOGS_MESHATTRIBUTEASSIGNDIALOG_H
52
53#include "mesh/meshinfil.h"
55
56#include <QByteArray>
57#include <QDialog>
58#include <QFutureWatcher>
59#include <QPointF>
60#include <QPointer>
61#include <QSet>
62#include <QString>
63#include <QStringList>
64#include <QVector>
65
66class MapCanvas;
67class QComboBox;
68class QDoubleSpinBox;
69class QGroupBox;
70class QLabel;
71class QProgressBar;
72class QPushButton;
73class QRadioButton;
74class QSpinBox;
75class QCheckBox;
76class QTableWidget;
78class SWMM2DMeshLayer;
79
80namespace openswmmvis::ui {
81
82class MeshAttributeAssignDialog : public QDialog
83{
84 Q_OBJECT
85
86public:
88 enum class Source { Raster, Vector };
89
91 enum class Mode {
95 };
96
98 enum class Sampling {
99 Centroid,
102 Majority,
104 };
105
107 enum class WriteTarget {
110 };
111
112 // -----------------------------------------------------------------------
113 // Data exchanged with the sampling worker.
114 //
115 // Both structs are plain data: no QObject, no layer pointer, no GDAL
116 // handle. collectJob() fills the Job on the GUI thread; the worker
117 // re-opens every source by path on its own thread.
118 // -----------------------------------------------------------------------
119
121 struct Job
122 {
126
131 QVector<int> triangles;
132 QVector<QPointF> centroids;
133 QVector<QPointF> triVerts;
134
135 QString meshCrsWkt;
136
137 // ---- Raster source ----
138 QString rasterPath;
139 QVector<int> bands;
140 int keyBand1 = 1;
141 int keyBand2 = 0;
142 double scale = 1.0;
143 double offset = 0.0;
144
145 // ---- Vector source ----
146 QString vectorPath;
149 QStringList fields;
150 QString keyField1;
151 QString keyField2;
152 bool filterBySelection = false;
153 QSet<long long> selectedIds;
154
155 // ---- Numeric targets ----
156 QVector<QByteArray> targetKeys;
157 QVector<double> targetMin;
158 QVector<double> targetMax;
159
160 // ---- Classified infiltration ----
162
163 // ---- Natural neighbour ----
166 };
167
170 {
171 QVector<int> triangles;
174 QVector<QVector<double>> values;
176 QVector<mesh::InfilRow> rows;
179 QStringList keys;
180
183 int skippedRange = 0;
185 int scanned = 0;
186 bool cancelled = false;
191 QString error;
192 };
193
195 MapCanvas *canvas,
196 SelectionManager *selection,
197 Source initialSource,
198 const QString &depthUnitLabel,
199 QWidget *parent = nullptr);
200
201public slots:
205 void reject() override;
206
207private slots:
208 void onSourceChanged();
209 void onTargetChanged();
210 void onModeChanged();
211 void onSamplingChanged();
212 void onPreview();
213 void onApply();
214 void onBrowseRaster();
215 void onCancelOrClose();
216 void onSampleFinished();
217
218 // Multi-target table
219 void onAddTargetRow();
220 void onRemoveTargetRow();
221
222 // Classified lookup table
223 void onAddLookupRow();
224 void onRemoveLookupRow();
225 void onLoadLookupCsv();
226 void onSaveLookupCsv();
227 void onTwoKeyToggled();
228
229private:
230 void buildUi(Source initialSource, const QString &depthUnitLabel);
231 void buildTargetGroup(const QString &depthUnitLabel);
232 void buildLookupGroup();
233 void populateLayerCombos();
234 void refreshVectorFields();
235 void updateButtons();
236 void setRunning(bool running);
237
240 void fillParamCombo(QComboBox *combo, const QString &depthUnitLabel) const;
241
242 [[nodiscard]] Mode currentMode() const;
243 [[nodiscard]] Sampling currentSampling() const;
244
246 [[nodiscard]] QVector<int> scopeTriangles() const;
247
249 [[nodiscard]] QVector<QPointF> centroidsFor(const QVector<int> &tris) const;
250
253 [[nodiscard]] bool collectJob(Job *job, QString *err) const;
254
256 void startSampling(bool apply);
257
259 [[nodiscard]] QVector<QByteArray> collectTargetKeys() const;
260
263 void setTargetRowSourceWidget(int row);
264
267 [[nodiscard]] mesh::InfilLookupTable collectLookupTable() const;
268 void applyLookupTable(const mesh::InfilLookupTable &t);
269 void rebuildLookupColumns();
272 void maskLookupRow(int row);
273
275 [[nodiscard]] QString summarise(const SampleResult &r) const;
276
278 void applyResult(const SampleResult &r);
279 void applyNumericResult(const SampleResult &r);
280 void applyInfilResult(const SampleResult &r);
285 void applyInfilDefaultsResult(const SampleResult &r);
286
287 QPointer<SWMM2DMeshLayer> m_mesh;
288 QPointer<MapCanvas> m_canvas;
289 QPointer<SelectionManager> m_selection;
290
291 QComboBox *m_modeCombo = nullptr;
292 QComboBox *m_targetCombo = nullptr; // SingleNumeric
293 QGroupBox *m_singleGroup = nullptr;
294 QGroupBox *m_multiGroup = nullptr;
295 QTableWidget *m_targetTable = nullptr; // MultiNumeric
296 QPushButton *m_addTargetBtn = nullptr;
297 QPushButton *m_delTargetBtn = nullptr;
298 QGroupBox *m_lookupGroup = nullptr; // ClassifiedInfil
299 QTableWidget *m_lookupTable = nullptr;
300 QComboBox *m_key1Combo = nullptr;
301 QComboBox *m_key2Combo = nullptr;
302 QSpinBox *m_key1BandSpin = nullptr;
303 QSpinBox *m_key2BandSpin = nullptr;
304 QCheckBox *m_twoKeyCheck = nullptr;
305 QLabel *m_key1Label = nullptr;
306 QLabel *m_key2Label = nullptr;
307
308 QRadioButton *m_srcRaster = nullptr;
309 QRadioButton *m_srcVector = nullptr;
310 QComboBox *m_rasterCombo = nullptr;
311 QPushButton *m_browseBtn = nullptr;
312 QSpinBox *m_bandSpin = nullptr;
313 QDoubleSpinBox *m_scaleSpin = nullptr;
314 QDoubleSpinBox *m_offsetSpin = nullptr;
315 QComboBox *m_vectorCombo = nullptr;
316 QComboBox *m_fieldCombo = nullptr;
317 QCheckBox *m_selectedOnly = nullptr;
318
319 QComboBox *m_samplingCombo = nullptr;
320 QComboBox *m_nnVariantCombo = nullptr;
321 QLabel *m_nnVariantLbl = nullptr;
322
323 QRadioButton *m_writeOverrides = nullptr;
324 QRadioButton *m_writeDefaults = nullptr;
325 QCheckBox *m_keepInherited = nullptr;
326 QGroupBox *m_writeGroup = nullptr;
327
328 QRadioButton *m_scopeAll = nullptr;
329 QRadioButton *m_scopeSelected = nullptr;
330 QLabel *m_statusLbl = nullptr;
331 QProgressBar *m_progress = nullptr;
332 QPushButton *m_previewBtn = nullptr;
333 QPushButton *m_applyBtn = nullptr;
334 QPushButton *m_closeBtn = nullptr;
335
337 QString m_browsedRasterPath;
340 QString m_depthUnitLabel;
341
344 QFutureWatcher<SampleResult> *m_watcher = nullptr;
348 Job m_runJob;
350 bool m_applyPending = false;
351};
352
353} // namespace openswmmvis::ui
354
355#endif // OPENSWMMVIS_UI_DIALOGS_MESHATTRIBUTEASSIGNDIALOG_H
The central map display widget — QGIS-style hybrid rendering.
Definition mapcanvas.h:63
Definition maptoolselectprofile.h:37
Definition swmm2dmeshlayer.h:64
Owner of the canonical selection set for one SWMM project.
Definition selectionmanager.h:112
Variant
Definition naturalnbinterpolator.h:49
Definition meshattributeassigndialog.h:83
Source
Which source the dialog opens on.
Definition meshattributeassigndialog.h:88
void reject() override
Esc / Close / the window button. While a sampling pass is running this cancels it instead of closing,...
Definition meshattributeassigndialog.cpp:2096
Sampling
How one cell's source value is obtained.
Definition meshattributeassigndialog.h:98
@ NaturalNeighbour
Sibson / Laplace over scattered points.
@ OverlayAuto
Majority or area-weighted mean, by source type.
@ Centroid
Point sample at the cell centroid (original).
@ AreaWeightedMean
Mean over the cell's footprint (continuous).
@ Majority
Largest covering share wins (categorical).
Mode
What the assignment writes.
Definition meshattributeassigndialog.h:91
@ ClassifiedInfil
Key (or key pair) → a whole mesh::InfilRow.
@ SingleNumeric
One source value → one numeric cell parameter.
@ MultiNumeric
N source values → N numeric cell parameters.
WriteTarget
Where the assignment lands (GUI plan §3.4 "Write as", engine D-I3).
Definition meshattributeassigndialog.h:107
@ RegionDefaults
One [2D_INFILTRATION_DEFAULTS] row per region tag.
@ CellOverrides
Per-cell [2D_INFILTRATION] override rows.
DiagramType t
Definition diagramspec.cpp:20
QString err
Definition inpmeshwriter.cpp:575
Per-cell 2D infiltration: value types, tag/override resolution and method↔parameter masks.
Definition openswmmvislayer.h:43
QVector< int > parent
union-find
Definition pslgminsize.cpp:176
An editable, reusable classified lookup table. Saved/loaded as CSV so an agency's standard table trav...
Definition meshinfil.h:238
Everything one sampling pass needs.
Definition meshattributeassigndialog.h:122
QStringList fields
Parallel to targetKeys (numeric modes).
Definition meshattributeassigndialog.h:149
QVector< int > bands
Parallel to targetKeys (numeric modes).
Definition meshattributeassigndialog.h:139
QString vectorFilterExpr
Definition meshattributeassigndialog.h:148
QVector< QPointF > triVerts
Definition meshattributeassigndialog.h:133
QString keyField2
Classified mode; "" = single key.
Definition meshattributeassigndialog.h:151
QSet< long long > selectedIds
Definition meshattributeassigndialog.h:153
double offset
Definition meshattributeassigndialog.h:143
mesh::InfilLookupTable table
Definition meshattributeassigndialog.h:161
QString rasterPath
Definition meshattributeassigndialog.h:138
QVector< int > triangles
Definition meshattributeassigndialog.h:131
Sampling sampling
Definition meshattributeassigndialog.h:125
QVector< QByteArray > targetKeys
Definition meshattributeassigndialog.h:156
Mode mode
Definition meshattributeassigndialog.h:123
double scale
Definition meshattributeassigndialog.h:142
QVector< double > targetMin
Parallel to targetKeys.
Definition meshattributeassigndialog.h:157
QString vectorLayerName
Definition meshattributeassigndialog.h:147
QString meshCrsWkt
Mesh layer CRS; "" = assume source CRS.
Definition meshattributeassigndialog.h:135
QString vectorPath
Definition meshattributeassigndialog.h:146
mesh::NaturalNeighbourInterpolator::Variant nnVariant
Definition meshattributeassigndialog.h:164
QString keyField1
Classified mode.
Definition meshattributeassigndialog.h:150
QVector< QPointF > centroids
Definition meshattributeassigndialog.h:132
Source source
Definition meshattributeassigndialog.h:124
int keyBand1
Classified mode: band supplying key 1.
Definition meshattributeassigndialog.h:140
QVector< double > targetMax
Parallel to targetKeys.
Definition meshattributeassigndialog.h:158
int keyBand2
Classified mode: 0 = single key.
Definition meshattributeassigndialog.h:141
bool filterBySelection
Definition meshattributeassigndialog.h:152
Outcome of one sampling pass over the in-scope cells.
Definition meshattributeassigndialog.h:170
QVector< int > triangles
Cells that received a value.
Definition meshattributeassigndialog.h:171
int skippedNoData
NoData / outside the source.
Definition meshattributeassigndialog.h:181
bool cancelled
Definition meshattributeassigndialog.h:186
QStringList keys
Definition meshattributeassigndialog.h:179
QVector< mesh::InfilRow > rows
Definition meshattributeassigndialog.h:176
int skippedRange
Outside the parameter's range.
Definition meshattributeassigndialog.h:183
int scanned
Cells considered.
Definition meshattributeassigndialog.h:185
QString error
Non-empty aborts the pass.
Definition meshattributeassigndialog.h:191
int skippedNonNumeric
Field value not a number.
Definition meshattributeassigndialog.h:182
QVector< QVector< double > > values
Definition meshattributeassigndialog.h:174
QString resolvedSampling
Definition meshattributeassigndialog.h:190
int unmatchedKeys
Classified: fell through to the fallback row.
Definition meshattributeassigndialog.h:184