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
addbasemapdialog.h
Go to the documentation of this file.
1
26#ifndef ADDBASEMAPDIALOG_H
27#define ADDBASEMAPDIALOG_H
28
30
31#include <hydrocoupleogc/httpclient.h>
32#include <hydrocoupleogc/servicecredentials.h>
33#include <hydrocoupleogc/wfscapabilities.h>
34
35#include <QList>
36#include <QPair>
37#include <QRectF>
38#include <QString>
39
40#include <QDialog>
41
42#include <memory>
43
44class QTabWidget;
45class QComboBox;
46class QLineEdit;
47class QSpinBox;
48class QCheckBox;
49class QPushButton;
50class QLabel;
51class QListWidget;
52class QTreeWidget;
53class QTreeWidgetItem;
54class QGroupBox;
55class QDialogButtonBox;
56class QNetworkAccessManager;
57class QNetworkReply;
60class WFSLayer;
61struct WMSServiceInfo;
62struct WMTSServiceInfo;
63
64// ---------------------------------------------------------------------------
65
70class AddBasemapDialog : public QDialog
71{
72 Q_OBJECT
73
74public:
88 enum Tab {
91 Wcs = 2,
94 Wfs = 5
95 };
96
97 explicit AddBasemapDialog(QWidget *parent = nullptr);
98 ~AddBasemapDialog() override;
99
110 void setPreferredExtent(const QRectF &lonLatBounds);
111
118 void connectToWFS();
119
122 [[nodiscard]] QString wfsStatus() const;
123
135 [[nodiscard]] OpenSWMMVisLayer *createLayer(QObject *parent) const;
136
137 void setInitialTab(int index);
138
139private slots:
140 // XYZ tab
141 void onXYZConnectionSelected(const QString &name);
142 void onXYZNew();
143 void onXYZEdit();
144 void onXYZDelete();
145 void onXYZTest();
146
147 // WMS/WMTS tab
148 void onWMSConnectionSelected(const QString &name);
149 void onWMSNew();
150 void onWMSEdit();
151 void onWMSDelete();
152 void onWMSConnect();
153 void onWMSCapabilitiesFetched();
154 void onWMSCapabilitiesError(const QString &error);
155 void onWMSLayerSelectionChanged();
156
157 // WCS tab
158 void onWCSConnectionSelected(const QString &name);
159 void onWCSNew();
160 void onWCSDelete();
161 void onWCSConnect();
162 void onWCSCapabilitiesFetched(const struct WCSServiceInfo &info);
163 void onWCSCapabilitiesError(const QString &error);
164 void onWCSCoverageSelectionChanged();
165
166 // WFS tab
167 void onWFSConnectionSelected(const QString &name);
168 void onWFSNew();
169 void onWFSDelete();
170 void onWFSConnect();
171
172 // ArcGIS tab
173 void onArcGISConnectionSelected(const QString &name);
174 void onArcGISNew();
175 void onArcGISEdit();
176 void onArcGISDelete();
177 void onArcGISConnect();
178 void onArcGISMetadataFetched();
179 void onArcGISMetadataError(const QString &error);
180
181 // Local file tab
182 void onLocalConnectionSelected(const QString &name);
183 void onLocalNew();
184 void onLocalDelete();
185 void onLocalBrowseFile();
186 void onLocalBrowseWorldFile();
187 void onLocalSelectCrs();
188
189private:
190 void setupUiXYZ(QWidget *page);
191 void setupUiWMS(QWidget *page);
192 void setupUiWCS(QWidget *page);
193 void setupUiArcGIS(QWidget *page);
194 void setupUiLocal(QWidget *page);
195 void buildConnectionBar(QWidget *parent, QComboBox *&combo,
196 QPushButton *&newBtn, QPushButton *&editBtn,
197 QPushButton *&delBtn);
198 void buildAuthGroup(QWidget *parent, QGroupBox *&box,
199 QLineEdit *&user, QLineEdit *&pass,
200 QPushButton *&eyeBtn);
201 void togglePasswordVisibility(QLineEdit *passEdit, QPushButton *eyeBtn);
202
203 void refreshXYZCombo();
204 void refreshWMSCombo();
205 void refreshWCSCombo();
206 void refreshArcGISCombo();
207 void refreshLocalCombo();
208
209 void populateXYZ(const XYZConnection &conn, const BasemapAuth &auth);
210 void populateWMS(const WMSConnection &conn, const BasemapAuth &auth);
211 void populateWCS(const struct WCSConnection &conn, const BasemapAuth &auth);
212 void populateArcGIS(const ArcGISRestConnection &conn, const BasemapAuth &auth);
213 void populateLocal(const LocalRasterConnection &conn);
214 void updateLocalGeorefStatus();
215
216 void populateWMSTree(const struct WMSServiceInfo &info);
217 void populateWMTSTree(const struct WMTSServiceInfo &info);
218 void populateWCSTree(const struct WCSServiceInfo &info);
219
220 // Helpers for createLayer()
221 [[nodiscard]] OpenSWMMVisLayer *buildXYZLayer(QObject *parent) const;
222 [[nodiscard]] OpenSWMMVisLayer *buildWMSLayer(QObject *parent) const;
223 [[nodiscard]] OpenSWMMVisLayer *buildWMTSLayer(QObject *parent) const;
224 [[nodiscard]] OpenSWMMVisLayer *buildWCSLayer(QObject *parent) const;
225 [[nodiscard]] OpenSWMMVisLayer *buildArcGISLayer(QObject *parent) const;
226 [[nodiscard]] OpenSWMMVisLayer *buildLocalRasterLayer(QObject *parent) const;
227
228 // ---------- Widgets ----------------------------------------------------
229
230 QTabWidget *m_tabs = nullptr;
231 QDialogButtonBox *m_buttonBox = nullptr;
232
233 // XYZ
234 QComboBox *m_xyzCombo = nullptr;
235 QPushButton *m_xyzNew = nullptr;
236 QPushButton *m_xyzEdit = nullptr;
237 QPushButton *m_xyzDel = nullptr;
238 QLineEdit *m_xyzName = nullptr;
239 QLineEdit *m_xyzUrl = nullptr;
240 QSpinBox *m_xyzZMin = nullptr;
241 QSpinBox *m_xyzZMax = nullptr;
242 QComboBox *m_xyzPixRatio = nullptr; // 0/1/2
243 QComboBox *m_xyzAxis = nullptr; // ZXY / ZYX
244 QGroupBox *m_xyzAuthBox = nullptr;
245 QLineEdit *m_xyzUser = nullptr;
246 QLineEdit *m_xyzPass = nullptr;
247 QPushButton *m_xyzEye = nullptr;
248 BasemapHttpHeadersWidget *m_xyzHeaders = nullptr;
249 QPushButton *m_xyzTestBtn = nullptr;
250 QLabel *m_xyzTestLabel = nullptr;
251
252 // WMS / WMTS
253 QComboBox *m_wmsCombo = nullptr;
254 QPushButton *m_wmsNew = nullptr;
255 QPushButton *m_wmsEdit = nullptr;
256 QPushButton *m_wmsDel = nullptr;
257 QLineEdit *m_wmsUrl = nullptr;
258 QPushButton *m_wmsConnect = nullptr;
259 QLabel *m_wmsProtocol = nullptr; // shows "WMS" or "WMTS"
260 QGroupBox *m_wmsAuthBox = nullptr;
261 QLineEdit *m_wmsUser = nullptr;
262 QLineEdit *m_wmsPass = nullptr;
263 QPushButton *m_wmsEye = nullptr;
264 QTreeWidget *m_wmsTree = nullptr;
265 QComboBox *m_wmsStyle = nullptr;
266 QComboBox *m_wmsFmt = nullptr;
267 QComboBox *m_wmsCrs = nullptr;
268 QComboBox *m_wmsTms = nullptr; // tile matrix set (WMTS only)
269 QLabel *m_wmsTmsLabel = nullptr;
270 // Advanced
271 QComboBox *m_wmsDpiMode = nullptr;
272 QComboBox *m_wmsRatio = nullptr;
273 QCheckBox *m_wmsIgnoreUri = nullptr;
274 QCheckBox *m_wmsIgnoreAxis = nullptr;
275 QCheckBox *m_wmsInvertAxis = nullptr;
276 QCheckBox *m_wmsSmooth = nullptr;
277 BasemapHttpHeadersWidget *m_wmsHeaders = nullptr;
278 QLabel *m_wmsStatus = nullptr;
279
280 // WCS
281 QComboBox *m_wcsCombo = nullptr;
282 QPushButton *m_wcsNew = nullptr;
283 QPushButton *m_wcsDel = nullptr;
284 QLineEdit *m_wcsUrl = nullptr;
285 QPushButton *m_wcsConnect = nullptr;
286 QLabel *m_wcsStatus = nullptr;
287 QTreeWidget *m_wcsCovTree = nullptr;
288 QComboBox *m_wcsFmt = nullptr;
289 QComboBox *m_wcsCrs = nullptr;
290 QLineEdit *m_wcsRange = nullptr;
291 QComboBox *m_wcsInterp = nullptr;
292 QGroupBox *m_wcsAuthBox = nullptr;
293 QLineEdit *m_wcsUser = nullptr;
294 QLineEdit *m_wcsPass = nullptr;
295 QPushButton *m_wcsEye = nullptr;
296 BasemapHttpHeadersWidget *m_wcsHeaders = nullptr;
297
298 // ------ WFS tab ---------------------------------------------------
299 QComboBox *m_wfsCombo = nullptr;
300 QPushButton *m_wfsNew = nullptr;
301 QPushButton *m_wfsDel = nullptr;
302 QLineEdit *m_wfsUrl = nullptr;
303 QPushButton *m_wfsConnect = nullptr;
304 QLabel *m_wfsStatus = nullptr;
305 QListWidget *m_wfsTypes = nullptr;
306 QGroupBox *m_wfsAuthBox = nullptr;
307 QLineEdit *m_wfsUser = nullptr;
308 QLineEdit *m_wfsPass = nullptr;
309 QPushButton *m_wfsEye = nullptr;
310 BasemapHttpHeadersWidget *m_wfsHeaders = nullptr;
311
312 // ArcGIS
313 QComboBox *m_arcCombo = nullptr;
314 QPushButton *m_arcNew = nullptr;
315 QPushButton *m_arcEdit = nullptr;
316 QPushButton *m_arcDel = nullptr;
317 QLineEdit *m_arcUrl = nullptr;
318 QLineEdit *m_arcPrefix = nullptr;
319 QLineEdit *m_arcContent = nullptr;
320 QLineEdit *m_arcCommunity = nullptr;
321 QGroupBox *m_arcAuthBox = nullptr;
322 QLineEdit *m_arcUser = nullptr;
323 QLineEdit *m_arcPass = nullptr;
324 QPushButton *m_arcEye = nullptr;
325 BasemapHttpHeadersWidget *m_arcHeaders = nullptr;
326 QPushButton *m_arcConnect = nullptr;
327 QLabel *m_arcInfoLabel = nullptr;
328
329 // Local file
330 QComboBox *m_localCombo = nullptr;
331 QPushButton *m_localNew = nullptr;
332 QPushButton *m_localDel = nullptr;
333 QLineEdit *m_localName = nullptr;
334 QLineEdit *m_localFile = nullptr;
335 QPushButton *m_localFileBrowse = nullptr;
336 QLineEdit *m_localWorld = nullptr;
337 QPushButton *m_localWorldBrowse = nullptr;
338 QLineEdit *m_localCrs = nullptr; // read-only; set via CRS dialog
339 QPushButton *m_localCrsBtn = nullptr;
340 QLabel *m_localStatus = nullptr;
341
342 // ---------- Runtime state ----------------------------------------------
343
344 QNetworkAccessManager *m_nam = nullptr;
345
346 // WMS runtime
347 bool m_isWMTS = false;
348 std::unique_ptr<WMSServiceInfo> m_wmsInfo;
349 std::unique_ptr<WMTSServiceInfo> m_wmtsInfo;
350
351 // WCS runtime
352 struct WCSServiceInfo *m_wcsInfo = nullptr;
353
354 // ------ WFS state -------------------------------------------------
355 void setupUiWFS(QWidget *page);
356 void refreshWFSCombo();
357 void populateWFS(const WFSConnection &conn, const BasemapAuth &auth);
358 void showWFSCollections(const QByteArray &body);
359
371 void fetchWFSThenAccept();
372
382 void updateOkEnabled();
383
384 [[nodiscard]] OpenSWMMVisLayer *buildWFSLayer(QObject *parent) const;
385
386 [[nodiscard]] HydroCouple::Ogc::ServiceCredentials wfsCredentials() const;
387
388 HydroCouple::Ogc::HttpClient *m_wfsClient = nullptr;
389 HydroCouple::Ogc::WfsCapabilities m_wfsCaps;
390
392 QList<QPair<QString, QString>> m_wfsChoices;
393
394 QRectF m_preferredExtent;
395 QString m_wfsStatusText;
396
404 mutable WFSLayer *m_wfsLayer = nullptr;
405
406 // ArcGIS runtime — derived XYZ connection built after Connect
407 XYZConnection m_arcDerivedXYZ;
408};
409
410#endif // ADDBASEMAPDIALOG_H
Plain data structs for all supported basemap connection types.
Unified dialog for adding a layer from a web service or a file.
Definition addbasemapdialog.h:71
void setInitialTab(int index)
Definition addbasemapdialog.cpp:143
~AddBasemapDialog() override
Definition addbasemapdialog.cpp:149
Tab
The dialog's pages, in the order they appear.
Definition addbasemapdialog.h:88
@ Wfs
Definition addbasemapdialog.h:94
@ WmsWmts
Definition addbasemapdialog.h:90
@ ArcGisRest
Definition addbasemapdialog.h:92
@ LocalFile
Definition addbasemapdialog.h:93
@ Wcs
Definition addbasemapdialog.h:91
@ XyzTiles
Definition addbasemapdialog.h:89
void setPreferredExtent(const QRectF &lonLatBounds)
Limits a feature request to the ground the map is looking at.
Definition addbasemapdialog.cpp:1398
OpenSWMMVisLayer * createLayer(QObject *parent) const
Creates and returns the layer the current page describes.
Definition addbasemapdialog.cpp:1644
QString wfsStatus() const
Definition addbasemapdialog.cpp:1393
void connectToWFS()
Asks the WFS at the address now entered what it holds.
Definition addbasemapdialog.cpp:1455
Definition basemaphttpheaderswidget.h:34
Abstract base class for all layers displayed in the MapCanvas.
Definition openswmmvislayer.h:116
A vector layer whose features came from a web feature service.
Definition wfslayer.h:37
int index
Position in m_quadRegions / m_quadReports.
Definition meshgenerator.cpp:153
QVector< int > parent
union-find
Definition pslgminsize.cpp:176
QString name
Definition sectionmodelbuilders.cpp:474
Parameters for an ArcGIS REST tiled MapServer service.
Definition basemapconnection.h:246
Username + password pair. Stored encrypted in QSettings by BasemapConnectionStore; never written to p...
Definition basemapconnection.h:55
Parameters for a local raster (GeoTIFF/PNG/JPEG/...) basemap.
Definition basemapconnection.h:279
Parameters for an OGC Web Coverage Service (WCS 1.1.x / 2.0) source.
Definition basemapconnection.h:168
Top-level metadata returned by a WCS GetCapabilities request.
Definition wcslayer.h:72
Parameters for an OGC Web Feature Service (WFS 1.x / 2.0) source.
Definition basemapconnection.h:211
Parameters for an OGC WMS or WMTS service.
Definition basemapconnection.h:127
Metadata returned by a WMS GetCapabilities request.
Definition wmslayer.h:48
Metadata returned by a WMTS GetCapabilities request.
Definition wmtslayer.h:78
All parameters needed to configure an XYZ (slippy-map) tile layer.
Definition basemapconnection.h:71