![]() |
SWMMVis
6.0.0-alpha.4
Qt6/C++ GIS-based graphical user interface for the SWMMVis engine (6.0.0-alpha.4)
|
A map layer backed by a GDAL/OGR vector dataset. More...
#include <gisvectorlayer.h>
Classes | |
| struct | OgrSublayerInfo |
| Lightweight description of one OGR layer inside a datasource, produced by enumerateSublayers() without fully loading it. More... | |
| struct | OpenResult |
Signals | |
| void | filePathChanged (const QString &path) |
| void | layerNameChanged (const QString &name) |
| void | featureCountChanged (int count) |
| void | filterExpressionChanged (const QString &expr) |
| void | symbolChanged (const GISVectorSymbol &symbol) |
| void | selectionChanged (const QSet< long long > &selectedIds) |
| void | rendererChanged () |
| Emitted when setRenderer() swaps the renderer pointer. | |
| void | openFinished (bool ok) |
| Emitted on the GUI thread when openAsync() completes. | |
| void | crsAssumed (const QString &filePath) |
| Emitted once when this layer's file declares no CRS and its coordinates are therefore assumed to already be in the canvas CRS. | |
Signals inherited from OpenSWMMVisLayer | |
| void | nameChanged (const QString &newName) |
| void | layerTypeChanged (OpenSWMMVisLayerType newType) |
| void | visibilityChanged (bool visible) |
| void | opacityChanged (double opacity) |
| void | srsChanged (SpatialReferenceSystem *newSRS) |
| void | extentChanged (const MapExtent &newExtent) |
| void | childrenChanged () |
| void | repaintRequested () |
| void | temporalSpecChanged (const OpenSWMM::Render::TemporalSpec &spec) |
| void | maskSpecChanged (const OpenSWMM::Render::MaskSpec &spec) |
| void | auxStorageSpecChanged (const OpenSWMM::Render::AuxiliaryStorageSpec &spec) |
| void | joinsChanged (const QVector< OpenSWMM::Render::JoinSpec > &joins) |
| void | diagramSpecChanged (const OpenSWMM::Render::DiagramSpec &spec) |
| void | labelConfigChanged () |
Public Member Functions | |
| GISVectorLayer (const QString &filePath, const QString &layerName={}, OpenSWMMVisWorkspace *parent=nullptr) | |
| ~GISVectorLayer () override | |
| void | openAsync (const QString &filePath, const QString &layerName={}) |
Asynchronously open filePath / layerName. GDALOpenEx + GetExtent (which forces a scan on some drivers) run on a worker thread; the layer is populated on the GUI thread and openFinished(bool) fires on completion. Construct with an empty path first; the synchronous openDataset path (tests / project restore) is unchanged. | |
| QString | filePath () const |
| Returns the file path to the OGR dataset. | |
| QString | ogrLayerName () const |
| Returns the OGR sub-layer name opened within the dataset. | |
| class OGRLayer * | ogrLayer () const |
| Read-only OGRLayer handle for callers that need to walk features directly (e.g. mesh-generator constraint pulls). Returns nullptr if the dataset is not open. | |
| void | appendScenePolygonsTo (QPainterPath &out) const |
Slice Z.14-paint — append every polygon ring this layer currently exposes (post-attribute-filter) to out in canvas-scene coords (Y-flipped, same space the canvas QGraphicsItems paint into). | |
| int | featureCount () const |
| Returns the number of features currently visible (after filtering). | |
| QStringList | fieldNames () const |
| Returns the list of field (attribute column) names. | |
| QString | sourceDescription () const override |
| Human-readable source of this layer: a file path, a service URL, or a description for in-memory / derived layers. | |
| QVector< QPair< QString, QString > > | extendedMetadata () const override |
| Ordered key→value pairs of TYPE-SPECIFIC metadata, rendered by the Metadata tab below the common block the dialog builds itself. | |
| QVector< OpenSWMM::Render::AttributeField > | availableAttributes (OpenSWMMVis::SwmmCategory cat) const override |
| QString | filterExpression () const |
| Returns the current OGR attribute filter expression. | |
| void | setFilterExpression (const QString &expr) |
| Sets an OGR SQL WHERE-clause filter on the features. | |
| GISVectorSymbol | symbol () const |
| void | setSymbol (const GISVectorSymbol &symbol) |
| void | setLabelConfig (const OpenSWMM::Render::LabelConfig &cfg) override |
| Slice X.18 — full label configuration. | |
| QStringList | ogrFieldNames () const |
| Names of the OGR fields available for label expressions. Empty when no dataset has been opened yet. Used by the Labels tab to populate the field combobox. | |
| std::vector< std::unique_ptr< openswmmvis::ui::ILayerStyleSubject > > | styleSubjects () override |
| OpenSWMM::Render::IFeatureRenderer * | renderer () const |
| The IFeatureRenderer that will drive this layer's paint pass. | |
| void | setRenderer (std::unique_ptr< OpenSWMM::Render::IFeatureRenderer > r) |
| Replaces the current renderer. | |
| OpenSWMM::Render::RuleList * | ruleList () override |
| const OpenSWMM::Render::RuleList * | ruleList () const override |
| QSet< long long > | selectedFeatureIds () const |
| Returns the set of currently selected feature IDs. | |
| void | setSelectedFeatureIds (const QSet< long long > &ids) |
| Selects the features with the given IDs (replacing any prior selection). | |
| void | clearSelection () |
| Clears all selected features. | |
| QSet< long long > | featureIdsInRect (const MapExtent &rectCanvasCrs) const |
SVBC round B — fids of every feature whose GEOMETRY intersects rectCanvasCrs (OGR bbox prefilter, then precise Intersects). The rect arrives in canvas CRS and is inverse-transformed when the layer is reprojected. Any pre-existing spatial filter is saved and restored (clone dance). | |
| QVector< QPointF > | selectedFeatureAnchors () const |
| Scene-space centres of the selected features' items — beacon anchors for MapCanvas::flashSelection. | |
| QList< QVariantMap > | identifyAt (double mapX, double mapY, const SpatialReferenceSystem *canvasSRS, double tolerance=1e-6) const |
| Returns attributes of features that intersect the given map point. | |
| QList< QVariantMap > | identifyAt (double mapX, double mapY, double tolerance=1e-6) const |
| Convenience overload — no CRS needed (uses current layer CRS). | |
| void | populateScene (QGraphicsScene *scene, const MapExtent &canvasExtent, const SpatialReferenceSystem *canvasSRS) override |
| Creates / updates QGraphicsItems representing this layer in the scene. | |
| void | depopulateScene (QGraphicsScene *scene) override |
| Removes all QGraphicsItems belonging to this layer from the scene. | |
| void | refreshScene (QGraphicsScene *scene, const MapExtent &canvasExtent, const SpatialReferenceSystem *canvasSRS) override |
| Smart scene refresh — updates existing items instead of destroying and recreating. | |
| void | onCanvasCRSChanged (const SpatialReferenceSystem *newCanvasSRS) override |
| Called when the user changes the canvas CRS so layers can pre-compute any CRS-dependent transform caches. | |
Public Member Functions inherited from OpenSWMMVisLayer | |
| OpenSWMMVisLayer (OpenSWMMVisWorkspace *parent) | |
| OpenSWMMVisLayer (const QString &name="Unlabeled Layer", OpenSWMMVisWorkspace *parent=nullptr) | |
| virtual | ~OpenSWMMVisLayer () |
| QString | layerId () const |
| Returns the layer's immutable unique identifier (UUID). | |
| QString | name () const |
| Returns the user-visible name of this layer. | |
| void | setName (const QString &name) |
| Sets the user-visible name. | |
| OpenSWMMVisLayerType | layerType () const |
| Returns the layer type discriminator. | |
| bool | isVisible () const |
| Returns true when this layer should be drawn. | |
| void | setVisible (bool visible) |
| Shows or hides this layer. | |
| double | opacity () const |
| Returns the layer opacity in the range [0.0, 1.0]. 0.0 = fully transparent; 1.0 = fully opaque. | |
| void | setOpacity (double opacity) |
| Sets the layer opacity. Values are clamped to [0.0, 1.0]. | |
| SpatialReferenceSystem * | srs () const |
| Returns the spatial reference system for this layer, or nullptr if the layer has no known CRS. | |
| void | setSRS (SpatialReferenceSystem *srs, bool ownsSRS=false) |
| Sets (or replaces) the CRS for this layer. | |
| QString | crsDescription () const |
| Returns a human-readable summary of this layer's CRS for display in the Properties window. | |
| MapExtent | extent () const |
| Returns the layer extent in the layer's own CRS. | |
| void | setExtent (const MapExtent &extent) |
| Sets the layer spatial extent (in the layer's CRS). | |
| virtual bool | isRasterLayer () const |
| Returns true for layers that render into a raster buffer (WMS, WMTS, GISRaster) rather than populating QGraphicsItems. | |
| virtual bool | isBasemapLayer () const |
| Returns true for world-spanning basemap layers (XYZ tile providers, WMS/WMTS services covering the whole world) that should NOT be included when computing the data-driven full extent. | |
| virtual void | render (QPainter *painter, const MapExtent &extent, const QSize &imageSize, const SpatialReferenceSystem *srs) |
Renders this layer's content directly into painter. | |
| virtual void | fetchCache (const MapExtent &extent, const QSize &viewportSize, const SpatialReferenceSystem *srs) |
| Triggers any asynchronous (or synchronous) tile/data fetch needed to populate this layer's internal cache for the given view state. | |
| void | setViewportSize (int w, int h) |
| Called by MapCanvas before refreshScene so layers can request the correct pixel dimensions for tile/image requests. | |
| int | viewportWidth () const |
| int | viewportHeight () const |
| QVector< OpenSWMMVisLayer * > | children () const |
| Returns the ordered list of child layers. | |
| double | layerZValue () const |
| Returns the z-value base assigned to this layer by the canvas. Items within the layer should use z-values relative to this. | |
| void | setLayerZValue (double z) |
| Called by the canvas to set this layer's z-value band. | |
| const OpenSWMM::Render::TemporalSpec & | temporalSpec () const |
| void | setTemporalSpec (const OpenSWMM::Render::TemporalSpec &spec) |
| const OpenSWMM::Render::LabelConfig & | labelConfig () const |
| const OpenSWMM::Render::MaskSpec & | maskSpec () const |
| void | setMaskSpec (const OpenSWMM::Render::MaskSpec &spec) |
| const OpenSWMM::Render::AuxiliaryStorageSpec & | auxStorageSpec () const |
| void | setAuxStorageSpec (const OpenSWMM::Render::AuxiliaryStorageSpec &spec) |
| const QVector< OpenSWMM::Render::JoinSpec > & | joins () const |
| void | setJoins (const QVector< OpenSWMM::Render::JoinSpec > &joins) |
| const OpenSWMM::Render::DiagramSpec & | diagramSpec () const |
| void | setDiagramSpec (const OpenSWMM::Render::DiagramSpec &spec) |
| OpenSWMMVisWorkspace * | workspace () const |
| void | setBasicAuth (const QString &username, const QString &password) |
| Sets HTTP Basic authentication for all subsequent network requests. | |
| void | setHttpHeaders (const BasemapHttpHeaders &headers) |
| Sets arbitrary extra HTTP headers applied to every request. | |
| BasemapHttpHeaders | httpHeaders () const |
Public Member Functions inherited from OpenSWMM::Render::IAttributeProvider | |
| virtual | ~IAttributeProvider ()=default |
Static Public Member Functions | |
| static QList< OgrSublayerInfo > | enumerateSublayers (const QString &filePath, QString *errorOut=nullptr) |
| Enumerate the layers in a vector datasource without fully loading any of them. Opens read-only, reads each OGR layer's name / geometry / feature-count / CRS, then closes. | |
Protected Member Functions | |
| void | setOpenFlags (unsigned flags) |
| GDALOpenEx flags used by openDataset and openAsync. | |
| unsigned | openFlags () const |
| GDALDataset * | dataset () const |
| The open dataset, or nullptr. Non-owning; the layer closes it. Exposed for subclasses that must reach GDAL directly (schema changes, transaction control). | |
| void | markSceneDirty () |
| Force the next populateScene() to rebuild its items. Call after mutating the underlying dataset so the scene reflects the write; refreshScene() alone short-circuits on a clean dirty flag. | |
| void | openDataset (const QString &filePath, const QString &layerName) |
Open filePath / layerName synchronously. | |
| void | closeDataset () |
| Closes whatever is open, releasing the dataset. | |
Protected Member Functions inherited from OpenSWMMVisLayer | |
| bool | addChild (OpenSWMMVisLayer *child) |
| bool | removeChild (OpenSWMMVisLayer *child) |
| void | setLayerType (OpenSWMMVisLayerType type) |
Properties | |
| QString | filePath |
| QString | layerName |
| int | featureCount |
| QString | filterExpr |
| GISVectorSymbol | symbol |
Properties inherited from OpenSWMMVisLayer | |
| QString | Name |
| bool | Visible |
| double | Opacity |
| QString | LayerId |
| OpenSWMMVisLayerType | LayerType |
| QVector< OpenSWMMVisLayer * > | Children |
| QString | CRS |
Additional Inherited Members | |
Public Types inherited from OpenSWMMVisLayer | |
| enum | OpenSWMMVisLayerType { SWMMDefaultLayer = 0 , SWMMModelLayer = 1 , SWMMResultsLayer = 2 , SWMMGISLayer = 3 , SWMMVectorLayer = 4 , SWMMRasterLayer = 5 , SWMMImageryLayer = 6 , SWMMTabularDataLayer = 7 , SWMMTabularyTimeSeriesLayer = 8 , SWMMSubProjectLayer = 9 , SWMMWMSLayer = 10 , SWMMWMTSLayer = 11 , SWMM2DMeshLayer = 12 , SWMM2DResultsLayer = 13 , SWMMAnnotationLayer = 14 , SWMMFeatureLayer = 15 } |
| Discriminator for the concrete layer class. More... | |
Protected Attributes inherited from OpenSWMMVisLayer | |
| QByteArray | m_authHeader |
| "Basic <base64>" or empty | |
| BasemapHttpHeaders | m_httpHeaders |
| arbitrary headers (incl. "referer") | |
A map layer backed by a GDAL/OGR vector dataset.
Loads any OGR-supported format (Shapefile, GeoPackage, GeoJSON, …), reads features, reprojects them to the canvas CRS on the fly using OGRCoordinateTransformation, and renders with a configurable symbol.
The layer also supports:
|
explicit |
|
override |
| void GISVectorLayer::appendScenePolygonsTo | ( | QPainterPath & | out | ) | const |
Slice Z.14-paint — append every polygon ring this layer currently exposes (post-attribute-filter) to out in canvas-scene coords (Y-flipped, same space the canvas QGraphicsItems paint into).
Multi-polygons contribute each sub-polygon's exterior + holes. Non-polygon geometries are skipped silently — callers (e.g. the mask-clip resolver) treat that as an empty result and fall back to unclipped paint.
Idempotent w.r.t. the spatial-filter rectangle the canvas has set on the underlying OGRLayer; the method clears the filter, iterates every feature, then restores the prior filter so concurrent canvas painting isn't disturbed.
|
overridevirtual |
Available themeable fields for cat. Empty list is a valid answer — means the layer doesn't surface per-feature attributes on this category (e.g. SWMMModelLayer::CatRainGages has no per- feature engine fields).
Order = preferred picker order. Callers should NOT re-sort.
Implements OpenSWMM::Render::IAttributeProvider.
| void GISVectorLayer::clearSelection | ( | ) |
Clears all selected features.
|
protected |
Closes whatever is open, releasing the dataset.
|
signal |
Emitted once when this layer's file declares no CRS and its coordinates are therefore assumed to already be in the canvas CRS.
Not an error — local-coordinate data legitimately has no CRS, and this is what the layer has always done. It is surfaced so a layer that lands in the wrong place has a stated reason.
|
inlineprotected |
The open dataset, or nullptr. Non-owning; the layer closes it. Exposed for subclasses that must reach GDAL directly (schema changes, transaction control).
|
overridevirtual |
Removes all QGraphicsItems belonging to this layer from the scene.
Reimplemented from OpenSWMMVisLayer.
|
static |
Enumerate the layers in a vector datasource without fully loading any of them. Opens read-only, reads each OGR layer's name / geometry / feature-count / CRS, then closes.
| filePath | Datasource path (GeoPackage, File GDB, GML, …). |
| errorOut | Optional; set to a human-readable message on failure. |
|
overridevirtual |
Ordered key→value pairs of TYPE-SPECIFIC metadata, rendered by the Metadata tab below the common block the dialog builds itself.
Default empty. Subclasses add only what is unique to them (e.g. a mesh: vertices / cells / edges / elevation range). QVector<QPair> preserves insertion order without a new type.
Reimplemented from OpenSWMMVisLayer.
| int GISVectorLayer::featureCount | ( | ) | const |
Returns the number of features currently visible (after filtering).
|
signal |
| QSet< long long > GISVectorLayer::featureIdsInRect | ( | const MapExtent & | rectCanvasCrs | ) | const |
SVBC round B — fids of every feature whose GEOMETRY intersects rectCanvasCrs (OGR bbox prefilter, then precise Intersects). The rect arrives in canvas CRS and is inverse-transformed when the layer is reprojected. Any pre-existing spatial filter is saved and restored (clone dance).
| QStringList GISVectorLayer::fieldNames | ( | ) | const |
Returns the list of field (attribute column) names.
| QString GISVectorLayer::filePath | ( | ) | const |
Returns the file path to the OGR dataset.
|
signal |
| QString GISVectorLayer::filterExpression | ( | ) | const |
Returns the current OGR attribute filter expression.
|
signal |
| QList< QVariantMap > GISVectorLayer::identifyAt | ( | double | mapX, |
| double | mapY, | ||
| const SpatialReferenceSystem * | canvasSRS, | ||
| double | tolerance = 1e-6 |
||
| ) | const |
Returns attributes of features that intersect the given map point.
| mapX | X coordinate in the canvas CRS. |
| mapY | Y coordinate in the canvas CRS. |
| canvasSRS | Canvas CRS used for the point coordinates (may be nullptr). |
| tolerance | Search tolerance in map units. |
| QList< QVariantMap > GISVectorLayer::identifyAt | ( | double | mapX, |
| double | mapY, | ||
| double | tolerance = 1e-6 |
||
| ) | const |
Convenience overload — no CRS needed (uses current layer CRS).
|
signal |
|
inlineprotected |
Force the next populateScene() to rebuild its items. Call after mutating the underlying dataset so the scene reflects the write; refreshScene() alone short-circuits on a clean dirty flag.
| QStringList GISVectorLayer::ogrFieldNames | ( | ) | const |
Names of the OGR fields available for label expressions. Empty when no dataset has been opened yet. Used by the Labels tab to populate the field combobox.
|
inline |
Read-only OGRLayer handle for callers that need to walk features directly (e.g. mesh-generator constraint pulls). Returns nullptr if the dataset is not open.
| QString GISVectorLayer::ogrLayerName | ( | ) | const |
Returns the OGR sub-layer name opened within the dataset.
|
overridevirtual |
Called when the user changes the canvas CRS so layers can pre-compute any CRS-dependent transform caches.
| newCanvasSRS | The new canvas CRS. |
Reimplemented from OpenSWMMVisLayer.
| void GISVectorLayer::openAsync | ( | const QString & | filePath, |
| const QString & | layerName = {} |
||
| ) |
Asynchronously open filePath / layerName. GDALOpenEx + GetExtent (which forces a scan on some drivers) run on a worker thread; the layer is populated on the GUI thread and openFinished(bool) fires on completion. Construct with an empty path first; the synchronous openDataset path (tests / project restore) is unchanged.
|
protected |
Open filePath / layerName synchronously.
Protected rather than private because a subclass may produce its own dataset — WFSLayer fetches one over the network and hands GDAL the bytes — and has to open and close it itself.
|
signal |
|
inlineprotected |
|
overridevirtual |
Creates / updates QGraphicsItems representing this layer in the scene.
Derived classes override this to add their items to the scene. Items should be created in scene coordinates (= map CRS coordinates) after reprojecting from the layer's native CRS.
Called by the MapCanvas when:
| scene | The shared OpenSWMMVisScene to add items to. |
| canvasExtent | Visible extent in canvas-CRS coordinates. |
| canvasSRS | The CRS currently used by the MapCanvas. |
Implements OpenSWMMVisLayer.
|
overridevirtual |
Smart scene refresh — updates existing items instead of destroying and recreating.
Override in subclasses to provide efficient incremental updates. The default implementation calls depopulateScene() then populateScene(), which is backward-compatible but causes flicker for raster/tile layers.
Raster/WMS layers should override to keep persistent scene items and update them in-place. Vector layers should override to skip rebuilding when only the view extent has changed (items are already in scene coords).
Reimplemented from OpenSWMMVisLayer.
|
virtual |
The IFeatureRenderer that will drive this layer's paint pass.
Constructed eagerly as a default SingleSymbolRenderer so callers never have to null-check. Owned by the layer.
Reimplemented from OpenSWMMVisLayer.
|
signal |
|
overridevirtual |
Reimplemented from OpenSWMMVisLayer.
|
overridevirtual |
Reimplemented from OpenSWMMVisLayer.
| QVector< QPointF > GISVectorLayer::selectedFeatureAnchors | ( | ) | const |
Scene-space centres of the selected features' items — beacon anchors for MapCanvas::flashSelection.
| QSet< long long > GISVectorLayer::selectedFeatureIds | ( | ) | const |
Returns the set of currently selected feature IDs.
|
signal |
| void GISVectorLayer::setFilterExpression | ( | const QString & | expr | ) |
Sets an OGR SQL WHERE-clause filter on the features.
| expr | OGR attribute filter, e.g. "population > 1000000". Pass an empty string to remove the filter. |
|
overridevirtual |
Slice X.18 — full label configuration.
Wraps the legacy `GISVectorSymbol::showLabels` / `labelField` / `labelFont` / `labelColor` fields plus halo, placement, and scale-range so the Labels tab of LayerStyleDialog has somewhere coherent to write.
Reimplemented from OpenSWMMVisLayer.
|
inlineprotected |
GDALOpenEx flags used by openDataset and openAsync.
Read-only by default — every vector source in the application is read-only except an editable feature layer. FeatureLayer sets GDAL_OF_VECTOR | GDAL_OF_UPDATE via setOpenFlags so it can write through the same handle the paint loop reads, instead of re-opening the GeoPackage after every edit.
A subclass that changes the flags MUST construct with an empty filePath (the ctor only opens when the path is non-empty) and call openDataset itself afterwards; the base ctor runs before the subclass exists.
|
virtual |
Replaces the current renderer.
The layer takes ownership. A null pointer is rejected (the method silently no-ops). Emits rendererChanged() when the renderer pointer actually changes.
Reimplemented from OpenSWMMVisLayer.
| void GISVectorLayer::setSelectedFeatureIds | ( | const QSet< long long > & | ids | ) |
Selects the features with the given IDs (replacing any prior selection).
| void GISVectorLayer::setSymbol | ( | const GISVectorSymbol & | symbol | ) |
|
overridevirtual |
Human-readable source of this layer: a file path, a service URL, or a description for in-memory / derived layers.
Default empty — the dialog shows "(none)". Concrete layers override to return their real origin (e.g. modelFilePath(), resultsFilePath(), serviceUrl(), or "(generated mesh)").
Reimplemented from OpenSWMMVisLayer.
Reimplemented in WFSLayer.
|
overridevirtual |
Slice U-7 — expose the GISVectorSymbol via a QObject adapter as the single styleable subject for the unified LayerStyleDialog.
Reimplemented from OpenSWMMVisLayer.
| GISVectorSymbol GISVectorLayer::symbol | ( | ) | const |
|
signal |
|
read |
|
read |
|
readwrite |
|
read |
|
readwrite |