![]() |
SWMMVis
6.0.0-alpha.4
Qt6/C++ GIS-based graphical user interface for the SWMMVis engine (6.0.0-alpha.4)
|
#include <swmm2dresultslayer.h>
Classes | |
| struct | SceneEdge |
| struct | SceneTri |
Public Types | |
| enum class | ColorRampStyle { Smooth , Graduated } |
| How depth is mapped to colour in the per-cell heatmap pass. More... | |
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... | |
Public Member Functions | |
| QVector< OpenSWMM::Render::AttributeField > | availableAttributes (OpenSWMMVis::SwmmCategory cat) const override |
| SWMM2DResultsLayer (const QString &name=QStringLiteral("2D Results"), OpenSWMMVisWorkspace *parent=nullptr) | |
| ~SWMM2DResultsLayer () override | |
| void | setSource (std::unique_ptr< IMesh2DSource > source) |
Swap the data source. Triggers a one-time mesh-geometry rebuild; the current time index is clamped to the new source's timeCount()-1. | |
| IMesh2DSource * | source () noexcept |
| const IMesh2DSource * | source () const noexcept |
| void | setFallbackCoordinateScale (double metresPerModelUnit) |
| Metres per model-CRS linear unit, for sources that declare none. | |
| int | currentTimeIndex () const noexcept |
| Current time index displayed on the canvas. -1 = no frame yet. | |
| void | setCurrentTimeIndex (int t) |
| void | refreshCurrentFrame () |
| Re-read and re-apply the current frame without moving the cursor. | |
| void | refreshTimeRange () |
Re-query source()->timeCount() and emit timeRangeChanged if it grew. Used by the runner's per-tick refresh during live mode. | |
| void | setFollowLive (bool on) noexcept |
| Follow-latest behavior for a LIVE (streaming) source. When on (the default), refreshTimeRange() advances the cursor to the newest frame as ticks arrive so the map animates the running simulation. Cleared when the user takes manual playback control (scrub / Play) so a chosen frame stays put; re-armed when they seek back to the latest frame. No effect on file sources, which already follow-latest while being appended. | |
| bool | followLive () const noexcept |
| void | setLiveRenderEnabled (bool on) |
| Master on/off gate for LIVE (streaming) rendering during a run. Distinct from followLive (which only chooses WHICH frame is shown) and from base-layer visibility (a non-live static result keeps drawing). When off, refreshTimeRange() stops ingesting/advancing streamed frames and the QSG renderer stops drawing the live layer, so a running sim costs no extra GPU/CPU for the 2D view. Re-enabling resumes work; the caller is expected to re-arm follow-live so the view jumps to the newest frame. No effect on file/static sources. | |
| bool | liveRenderEnabled () const noexcept |
| void | closeSource () |
| Release the active source — closes its underlying HDF5 handle (when the source is an HDF5Mesh2DSource) so the engine can truncate / overwrite the file on a subsequent run. Clears all per-frame caches and emits geometryChanged on both items so the canvas paints empty until a new source is attached via setSource(). | |
| double | dryDepth () const noexcept |
| Dry-cell depth threshold in metres. Cells below this draw with alpha 0. | |
| void | setDryDepth (double d) |
| 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. | |
| bool | qsgOwnsRendering () const noexcept |
| void | setQsgOwnsRendering (bool own) |
| double | maxDepth () const noexcept |
| Upper end of the colour ramp (metres). Auto-tracks the global max depth seen so far across all loaded ticks unless explicitly set. | |
| void | setMaxDepth (double d) |
| bool | velocityVectorsVisible () const |
| Whether centroid arrow glyphs are drawn over the depth fill. | |
| void | setVelocityVectorsVisible (bool v) |
| qreal | velocityOpacity () const |
| Overall alpha applied to all arrow glyphs, 0..1. Default 0.9. | |
| void | setVelocityOpacity (qreal alpha) |
| double | velocityArrowScale () const |
Per-glyph pixel scale: arrow_length_px = scale * log1p(vmag / vmagRef). Default 30 — a 1 m/s velocity renders ~21 px at any zoom. | |
| void | setVelocityArrowScale (double scale) |
| double | maxVelocity () const noexcept |
| Upper end of the velocity colour ramp (m/s). Auto-tracks the running max unless explicitly set. | |
| void | setMaxVelocity (double v) |
| bool | hasVelocityData () const noexcept |
| Whether the active source produced both edge geometry and a flux slice — i.e. whether the velocity overlay has data to render. NOTE: this reflects the CURRENTLY shown frame's reconstructed velocity magnitude; it is false on dry frames. Use hasEdgeFluxData for a frame-independent "does this run carry edge flux" capability check. | |
| bool | hasEdgeFluxData () const |
| Whether the run carries per-edge flux data at all, independent of the current frame. Probes the source once (cached) and is the correct gate for whole-series edge flow / flux / velocity plotting. | |
| ColorRampStyle | colorRampStyle () const noexcept |
| void | setColorRampStyle (ColorRampStyle s) |
| int | colorClasses () const noexcept |
| void | setColorClasses (int n) |
| bool | filledContours () const |
| Show filled-band contour polygons over the heatmap (off by default). Gap A3.1 — facades over the ContourBand sublayer (visibility / sublayer opacity / bandCount style prop). | |
| void | setFilledContours (bool on) |
| double | filledContoursOpacity () const |
| void | setFilledContoursOpacity (double a) |
| int | filledContoursLevels () const |
| void | setFilledContoursLevels (int n) |
| bool | isolines () const |
| Stroke iso-depth contour lines over the heatmap (off by default). Gap A3.1 — facades over the Isoline sublayer + style bag. | |
| void | setIsolines (bool on) |
| int | isolinesLevels () const |
| void | setIsolinesLevels (int n) |
| QColor | isolinesColor () const |
| void | setIsolinesColor (QColor c) |
| double | isolinesWidth () const |
| void | setIsolinesWidth (double px) |
| 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. | |
| std::pair< float, int > | currentPeak () const |
| Statistic on the current frame — useful for the status-bar peak readout. | |
| void | setCurrentSimTime (QDateTime t) |
| Set the current frame by nearest simulation time. Used to keep the 2D layer in step with the existing AnimationController's 1D playback — one slider drives both layers. | |
| void | setCurrentSimTimeAsOf (QDateTime cursor) |
Set the current frame causally: the latest frame whose simulation time is at or before cursor (floor), so a coupled output with a coarser report step never jumps to a frame ahead of the animation cursor. Clamps to frame 0 when cursor precedes the first frame (hold first). Peer of SWMMResultsLayer::periodIndexForDateTimeAsOf; used by the animation sync path so misaligned outputs hold their last-known frame. | |
| QVector< int > | pickCellsInRect (const QRectF &sceneRect) const |
Return CELL indices whose scene-space (area) centroid falls inside sceneRect. Linear scan over the cells — fine for meshes up to ~100k cells; bigger meshes may want spatial indexing. | |
| QVector< int > | pickCellsInPolygon (const QPolygonF &scenePoly) const |
Return CELL indices whose scene-space centroid falls inside scenePoly (odd-even fill rule). Used by lasso-select. | |
| int | pickCellAt (const QPointF &scenePt) const |
Return the CELL containing scenePt, or -1 (barycentric test on the display fan, mapped to the owning cell — a quad answers for both of its sub-triangles). Used by single-click cell pick and the canvas-right-click hit test. | |
| float | depthAtSceneNow (const QPointF &scenePt) const |
Current-frame water depth (m) at scenePt: locates the containing cell via pickCellAt and returns its cell-centre depth from the live SceneTri buffer. Returns 0 off-mesh / no-frame. Used by the mesh-profile cross-section to sample the animated depth column. | |
| double | depthToMeshUnits () const |
Factor that takes a 2D result DEPTH (engine SI metres — every depth accessor on this layer returns metres) into the mesh layer's vertical units, so bed + depth * depthToMeshUnits() is a valid water surface elevation against SWMM2DMeshLayer::sampleZAt and the 1D profile (project units). 1.0 for a metric project or an SI-tagged mesh; 1/0.3048 for a US project whose mesh is in feet. Same factor the XY coordinates use (the mesh's linear unit is shared by all three axes) — see resolveCoordinateScale_ / setFallbackCoordinateScale. | |
| float | depthAtSceneInterp (const QPointF &scenePt) const |
Current-frame water depth (m) at scenePt, barycentrically interpolated from the containing cell's per-vertex depths (dv0/dv1/dv2) — the same continuous field the marching-triangles contour passes render. Mirrors SWMM2DMeshLayer::sampleZAt's interpolation so the mesh-profile water-surface line varies smoothly across cell boundaries instead of stepping at each cell centre. Returns 0 off-mesh / no-frame. | |
| float | depthAtCellInterp (int triIdx, const QPointF &scenePt) const |
Barycentrically interpolated current-frame depth (m) at scenePt when its containing cell index is already known (e.g. the cached Sample::triIdx), skipping the cell search. Bounds-checks triIdx and returns 0 when out of range. depthAtSceneInterp is this plus a pickCellAt. | |
| bool | cellHasSurface (int triIdx) const |
True when any corner of cell triIdx carries a valid free surface η this frame (signed per-vertex depth ≠ 0 — the exact-0 value is the no-wet-incident-cell NO-DATA sentinel). False out of range. Feeds Sample::cellHasSurface so the profile painter bridges only true no-data gaps, not genuinely dry ground (see meshprofileinterp.h). | |
| bool | velocityAtScene (const QPointF &scenePt, float &outVx, float &outVy) const |
Barycentrically-interpolated scene-space velocity (m/s) at scenePt, from the per-vertex velocity field reconstructed in applyCurrentFlux_ (V1, Issue 5). Writes outVx,outVy and returns true when scenePt lies in a wet cell; returns false (and zeros) off-mesh or where the containing cell is dry. Used by the grid-sampled glyph placement so arrows are evenly spaced (independent of mesh density) and their direction varies smoothly across cell boundaries. | |
| QVector< float > | maxDepthPerVertex () const |
Per-**vertex** maximum water depth (m), the temporal max of the per-frame signed vertex reconstruction over each vertex's incident cells. Sized to vertexCount(), or empty when no source / no frames. Feeds the smooth (barycentric) max-depth envelope on the mesh profile — the peer of dv0/dv1/dv2 for the historical maximum. Build once and pass to maxDepthAtSceneInterp. | |
| float | maxDepthAtSceneInterp (const QPointF &scenePt, const QVector< float > &vertMax) const |
Barycentrically interpolated max water depth (m) at scenePt from a precomputed per-vertex max array vertMax (see maxDepthPerVertex). Mirrors depthAtSceneInterp so the envelope and the water-surface line share one interpolation basis. Returns 0 off-mesh. | |
| void | highlightCells (const QSet< int > &triIdxSet) |
| Replace the highlight set. Triggers an Overlay repaint via the layer's existing invalidate path. | |
| void | clearHighlights () |
| Add to / clear the highlight set. | |
| const QSet< int > & | highlightedCells () const noexcept |
| Current highlight set (read-only). | |
| 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. | |
| const std::vector< std::array< int, 3 > > & | triVertexIndices () const noexcept |
| const std::vector< std::array< int, 4 > > & | cellVertexIndices () const noexcept |
| const std::vector< int > & | triCellMap () const noexcept |
| const std::vector< int > & | cellTriRange () const noexcept |
| int | cellCount () const noexcept |
| quint64 | geomRevision () const noexcept |
| QList< OpenSWMM::Render::ISublayer * > | sublayers () const override |
| The ordered list of sublayers owned by this layer. | |
| bool | moveSublayer (int from, int to) override |
| QList< OpenSWMM::Render::LegendSymbolItem > | sublayerLegendItems () const |
| OpenSWMM::Render::MeshFillSublayer * | meshFillSublayer () const |
| OpenSWMM::Render::MeshEdgeSublayer * | meshEdgeSublayer () const |
| OpenSWMM::Render::MeshNodeSublayer * | meshNodeSublayer () const |
| OpenSWMM::Render::ContourBandSublayer * | contourBandSublayer () const |
| OpenSWMM::Render::CellDepthFillSublayer * | cellDepthFillSublayer () const |
| OpenSWMM::Render::SmoothDepthFillSublayer * | smoothDepthFillSublayer () const |
| OpenSWMM::Render::IsolineSublayer * | isolineSublayer () const |
| OpenSWMM::Render::VelocityVectorSublayer * | velocityVectorSublayer () const |
| std::vector< std::unique_ptr< openswmmvis::ui::ILayerStyleSubject > > | styleSubjects () override |
| OpenSWMM::Render::RuleList * | ruleList () override |
| const OpenSWMM::Render::RuleList * | ruleList () const override |
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 |
| virtual void | setLabelConfig (const OpenSWMM::Render::LabelConfig &cfg) |
| 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::ISublayerHost | |
| virtual | ~ISublayerHost ()=default |
| virtual void | dispatchAnimationTick (int period) |
| Hook invoked by AnimationController on every time-step change. | |
| virtual void | onSublayersJsonLoaded (const QJsonObject &sublayersJson) |
| Hook fired at the end of loadSublayersFromJson with the raw payload, so hosts can migrate style data that moved BETWEEN sublayers across schema versions (e.g. the BC fields that left MeshEdgeStyle for MeshBcStyle). Runs on both project load and .swmm-style.json import. Default: no-op. | |
Public Member Functions inherited from OpenSWMM::Render::IAttributeProvider | |
| virtual | ~IAttributeProvider ()=default |
Public Attributes | |
| QRectF | m_sceneBBox |
| QVector< SceneTri > | m_sceneTris |
| MeshSpatialGrid | m_triGrid |
| QVector< SceneEdge > | m_sceneEdges |
| QVector< QPointF > | m_sceneVerts |
Additional Inherited Members | |
Static Public Member Functions inherited from OpenSWMM::Render::ISublayerHost | |
| static QJsonObject | saveSublayersToJson (const ISublayerHost &host) |
| static QList< LegendSymbolItem > | aggregatedLegendSymbolItems (const ISublayerHost &host) |
Aggregates every visible sublayer's legendSymbolItems() into a single flat list (Slice S4 / §J.5 — legend-from- renderer rule, sublayer extension). | |
| static ISublayer * | findSublayer (const ISublayerHost &host, const QString &id) |
| O(N) lookup of a sublayer by its stable id. Returns nullptr when not found. Used by the legend dock's right-click handler in S4 to find the sublayer whose style dialog should open when the user clicks a sublayer-tagged swatch. | |
| static void | loadSublayersFromJson (ISublayerHost &host, const QJsonObject &j) |
Protected Member Functions inherited from OpenSWMMVisLayer | |
| bool | addChild (OpenSWMMVisLayer *child) |
| bool | removeChild (OpenSWMMVisLayer *child) |
| void | setLayerType (OpenSWMMVisLayerType type) |
Protected Attributes inherited from OpenSWMMVisLayer | |
| QByteArray | m_authHeader |
| "Basic <base64>" or empty | |
| BasemapHttpHeaders | m_httpHeaders |
| arbitrary headers (incl. "referer") | |
Properties inherited from OpenSWMMVisLayer | |
| QString | Name |
| bool | Visible |
| double | Opacity |
| QString | LayerId |
| OpenSWMMVisLayerType | LayerType |
| QVector< OpenSWMMVisLayer * > | Children |
| QString | CRS |
|
strong |
How depth is mapped to colour in the per-cell heatmap pass.
Smooth — continuous Viridis-ish gradient via inundationColorRgba. This is the default and matches behaviour prior to fix.3.a. Graduated — discretise the depth range into colorClasses bins and sample the same gradient at each bin's midpoint. Bin colours match the ones generated for the renderer's legend.
| Enumerator | |
|---|---|
| Smooth | |
| Graduated | |
|
explicit |
|
override |
|
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.
|
inlinenoexcept |
Number of cells (faces) in the current geometry.
|
inline |
| bool SWMM2DResultsLayer::cellHasSurface | ( | int | triIdx | ) | const |
True when any corner of cell triIdx carries a valid free surface η this frame (signed per-vertex depth ≠ 0 — the exact-0 value is the no-wet-incident-cell NO-DATA sentinel). False out of range. Feeds Sample::cellHasSurface so the profile painter bridges only true no-data gaps, not genuinely dry ground (see meshprofileinterp.h).
|
signal |
CF.3 — emitted on plot↔canvas hover sync.
|
inlinenoexcept |
CSR cell → display-triangle range: the fan triangles of cell c are [cellTriRange()[c], cellTriRange()[c+1]). Size cellCount()+1.
|
inlinenoexcept |
Cells (engine faces): {v0,v1,v2,v3}, v3 == -1 for a triangle. Indexed by CELL — the index every public pick/highlight/plot API uses.
| void SWMM2DResultsLayer::clearHighlights | ( | ) |
Add to / clear the highlight set.
| void SWMM2DResultsLayer::closeSource | ( | ) |
Release the active source — closes its underlying HDF5 handle (when the source is an HDF5Mesh2DSource) so the engine can truncate / overwrite the file on a subsequent run. Clears all per-frame caches and emits geometryChanged on both items so the canvas paints empty until a new source is attached via setSource().
Used by the dual-stream re-run handshake (Slice CF.MVP-fix.2) before launching a new simulation that targets the same OUTPUT_FILE.
|
inlinenoexcept |
|
inlinenoexcept |
|
inline |
|
signal |
Emitted alongside currentTimeChanged(int) with the QDateTime of the frame (or invalid if the source has no time anchor). Mirrors SWMMResultsLayer::currentDateTimeChanged so AnimationController can drive the 2D layer as a fallback when no 1D primary is loaded.
| std::pair< float, int > SWMM2DResultsLayer::currentPeak | ( | ) | const |
Statistic on the current frame — useful for the status-bar peak readout.
|
signal |
Emitted whenever the current frame changes (setCurrentTimeIndex).
|
inlinenoexcept |
Current time index displayed on the canvas. -1 = no frame yet.
|
overridevirtual |
Removes all QGraphicsItems belonging to this layer from the scene.
Reimplemented from OpenSWMMVisLayer.
| float SWMM2DResultsLayer::depthAtCellInterp | ( | int | triIdx, |
| const QPointF & | scenePt | ||
| ) | const |
Barycentrically interpolated current-frame depth (m) at scenePt when its containing cell index is already known (e.g. the cached Sample::triIdx), skipping the cell search. Bounds-checks triIdx and returns 0 when out of range. depthAtSceneInterp is this plus a pickCellAt.
| float SWMM2DResultsLayer::depthAtSceneInterp | ( | const QPointF & | scenePt | ) | const |
Current-frame water depth (m) at scenePt, barycentrically interpolated from the containing cell's per-vertex depths (dv0/dv1/dv2) — the same continuous field the marching-triangles contour passes render. Mirrors SWMM2DMeshLayer::sampleZAt's interpolation so the mesh-profile water-surface line varies smoothly across cell boundaries instead of stepping at each cell centre. Returns 0 off-mesh / no-frame.
| float SWMM2DResultsLayer::depthAtSceneNow | ( | const QPointF & | scenePt | ) | const |
Current-frame water depth (m) at scenePt: locates the containing cell via pickCellAt and returns its cell-centre depth from the live SceneTri buffer. Returns 0 off-mesh / no-frame. Used by the mesh-profile cross-section to sample the animated depth column.
|
inline |
Factor that takes a 2D result DEPTH (engine SI metres — every depth accessor on this layer returns metres) into the mesh layer's vertical units, so bed + depth * depthToMeshUnits() is a valid water surface elevation against SWMM2DMeshLayer::sampleZAt and the 1D profile (project units). 1.0 for a metric project or an SI-tagged mesh; 1/0.3048 for a US project whose mesh is in feet. Same factor the XY coordinates use (the mesh's linear unit is shared by all three axes) — see resolveCoordinateScale_ / setFallbackCoordinateScale.
|
inlinenoexcept |
Dry-cell depth threshold in metres. Cells below this draw with alpha 0.
|
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.
| bool SWMM2DResultsLayer::filledContours | ( | ) | const |
Show filled-band contour polygons over the heatmap (off by default). Gap A3.1 — facades over the ContourBand sublayer (visibility / sublayer opacity / bandCount style prop).
| int SWMM2DResultsLayer::filledContoursLevels | ( | ) | const |
| double SWMM2DResultsLayer::filledContoursOpacity | ( | ) | const |
|
inlinenoexcept |
|
inlinenoexcept |
QSG-2D-1M — bumped every rebuildSceneGeometry_. Lets the QSG renderer classify an ambiguous repaint into "geometry changed" vs "style changed" and key its static buffers / chunk index. Mirrors SWMM2DMeshLayer::geomRevision().
| bool SWMM2DResultsLayer::hasEdgeFluxData | ( | ) | const |
Whether the run carries per-edge flux data at all, independent of the current frame. Probes the source once (cached) and is the correct gate for whole-series edge flow / flux / velocity plotting.
|
inlinenoexcept |
Whether the active source produced both edge geometry and a flux slice — i.e. whether the velocity overlay has data to render. NOTE: this reflects the CURRENTLY shown frame's reconstructed velocity magnitude; it is false on dry frames. Use hasEdgeFluxData for a frame-independent "does this run carry edge flux" capability check.
| void SWMM2DResultsLayer::highlightCells | ( | const QSet< int > & | triIdxSet | ) |
Replace the highlight set. Triggers an Overlay repaint via the layer's existing invalidate path.
|
inlinenoexcept |
Current highlight set (read-only).
|
signal |
CF.3 — emitted when the highlight set changes.
| bool SWMM2DResultsLayer::isolines | ( | ) | const |
Stroke iso-depth contour lines over the heatmap (off by default). Gap A3.1 — facades over the Isoline sublayer + style bag.
| QColor SWMM2DResultsLayer::isolinesColor | ( | ) | const |
| int SWMM2DResultsLayer::isolinesLevels | ( | ) | const |
|
inline |
| double SWMM2DResultsLayer::isolinesWidth | ( | ) | const |
|
inlinenoexcept |
|
inlinenoexcept |
Upper end of the colour ramp (metres). Auto-tracks the global max depth seen so far across all loaded ticks unless explicitly set.
| float SWMM2DResultsLayer::maxDepthAtSceneInterp | ( | const QPointF & | scenePt, |
| const QVector< float > & | vertMax | ||
| ) | const |
Barycentrically interpolated max water depth (m) at scenePt from a precomputed per-vertex max array vertMax (see maxDepthPerVertex). Mirrors depthAtSceneInterp so the envelope and the water-surface line share one interpolation basis. Returns 0 off-mesh.
| QVector< float > SWMM2DResultsLayer::maxDepthPerVertex | ( | ) | const |
Per-**vertex** maximum water depth (m), the temporal max of the per-frame signed vertex reconstruction over each vertex's incident cells. Sized to vertexCount(), or empty when no source / no frames. Feeds the smooth (barycentric) max-depth envelope on the mesh profile — the peer of dv0/dv1/dv2 for the historical maximum. Build once and pass to maxDepthAtSceneInterp.
|
inlinenoexcept |
Upper end of the velocity colour ramp (m/s). Auto-tracks the running max unless explicitly set.
|
inline |
|
inline |
|
inline |
|
overridevirtual |
Reorder sublayers in paint order (bottom-up). Emits repaintRequested() on success. Returns false on out-of-range indices.
Reimplemented from OpenSWMM::Render::ISublayerHost.
|
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.
| int SWMM2DResultsLayer::pickCellAt | ( | const QPointF & | scenePt | ) | const |
Return the CELL containing scenePt, or -1 (barycentric test on the display fan, mapped to the owning cell — a quad answers for both of its sub-triangles). Used by single-click cell pick and the canvas-right-click hit test.
| QVector< int > SWMM2DResultsLayer::pickCellsInPolygon | ( | const QPolygonF & | scenePoly | ) | const |
Return CELL indices whose scene-space centroid falls inside scenePoly (odd-even fill rule). Used by lasso-select.
| QVector< int > SWMM2DResultsLayer::pickCellsInRect | ( | const QRectF & | sceneRect | ) | const |
Return CELL indices whose scene-space (area) centroid falls inside sceneRect. Linear scan over the cells — fine for meshes up to ~100k cells; bigger meshes may want spatial indexing.
|
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.
|
inlinenoexcept |
| void SWMM2DResultsLayer::refreshCurrentFrame | ( | ) |
Re-read and re-apply the current frame without moving the cursor.
Live 2D packets for a single simulation tick can arrive in phases (depths, then flux, then reconstructed vertex heads). Those late packets change velocity glyphs, smooth fills, contours, and profile samples even though the time index has not advanced.
|
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.
| void SWMM2DResultsLayer::refreshTimeRange | ( | ) |
Re-query source()->timeCount() and emit timeRangeChanged if it grew. Used by the runner's per-tick refresh during live mode.
|
virtual |
The IFeatureRenderer that will drive this layer's paint pass.
Constructed eagerly as a default GraduatedRenderer because this layer is fundamentally a continuous-attribute (depth) colour-mapped layer. Owned by the layer; never null.
Reimplemented from OpenSWMMVisLayer.
|
signal |
|
overridevirtual |
Reimplemented from OpenSWMMVisLayer.
|
overridevirtual |
Reimplemented from OpenSWMMVisLayer.
| void SWMM2DResultsLayer::setColorClasses | ( | int | n | ) |
| void SWMM2DResultsLayer::setColorRampStyle | ( | ColorRampStyle | s | ) |
| void SWMM2DResultsLayer::setCurrentSimTime | ( | QDateTime | t | ) |
Set the current frame by nearest simulation time. Used to keep the 2D layer in step with the existing AnimationController's 1D playback — one slider drives both layers.
| void SWMM2DResultsLayer::setCurrentSimTimeAsOf | ( | QDateTime | cursor | ) |
Set the current frame causally: the latest frame whose simulation time is at or before cursor (floor), so a coupled output with a coarser report step never jumps to a frame ahead of the animation cursor. Clamps to frame 0 when cursor precedes the first frame (hold first). Peer of SWMMResultsLayer::periodIndexForDateTimeAsOf; used by the animation sync path so misaligned outputs hold their last-known frame.
| void SWMM2DResultsLayer::setCurrentTimeIndex | ( | int | t | ) |
| void SWMM2DResultsLayer::setDryDepth | ( | double | d | ) |
| void SWMM2DResultsLayer::setFallbackCoordinateScale | ( | double | metresPerModelUnit | ) |
Metres per model-CRS linear unit, for sources that declare none.
The 2D solver runs in SI, so every result source hands this layer metres — which for a foot-based model CRS is not the unit the coordinates must be reprojected from (issue #155). Engine 6.0+ states the exact factor in the file's /crs variable and that always wins. A pre-6.0 .2d.h5, and the live in-process EngineMesh2DSource, carry no such statement, so the caller supplies it here.
Use the engine's own rule, not the layer CRS's linear unit: the engine scales the mesh when FLOW_UNITS is US-customary and the mesh file did not declare ;; UNITS: SI (m) — a condition the CRS cannot report, and which the engine's own InpWriter makes reachable on round-trip.
| metresPerModelUnit | 0.3048 when the engine scaled, else 1.0. Non-positive / non-finite values are ignored. The default is 1.0, i.e. leave the coordinates alone. |
| void SWMM2DResultsLayer::setFilledContours | ( | bool | on | ) |
| void SWMM2DResultsLayer::setFilledContoursLevels | ( | int | n | ) |
| void SWMM2DResultsLayer::setFilledContoursOpacity | ( | double | a | ) |
|
inlinenoexcept |
Follow-latest behavior for a LIVE (streaming) source. When on (the default), refreshTimeRange() advances the cursor to the newest frame as ticks arrive so the map animates the running simulation. Cleared when the user takes manual playback control (scrub / Play) so a chosen frame stays put; re-armed when they seek back to the latest frame. No effect on file sources, which already follow-latest while being appended.
| void SWMM2DResultsLayer::setIsolines | ( | bool | on | ) |
| void SWMM2DResultsLayer::setIsolinesColor | ( | QColor | c | ) |
| void SWMM2DResultsLayer::setIsolinesLevels | ( | int | n | ) |
| void SWMM2DResultsLayer::setIsolinesWidth | ( | double | px | ) |
| void SWMM2DResultsLayer::setLiveRenderEnabled | ( | bool | on | ) |
Master on/off gate for LIVE (streaming) rendering during a run. Distinct from followLive (which only chooses WHICH frame is shown) and from base-layer visibility (a non-live static result keeps drawing). When off, refreshTimeRange() stops ingesting/advancing streamed frames and the QSG renderer stops drawing the live layer, so a running sim costs no extra GPU/CPU for the 2D view. Re-enabling resumes work; the caller is expected to re-arm follow-live so the view jumps to the newest frame. No effect on file/static sources.
| void SWMM2DResultsLayer::setMaxDepth | ( | double | d | ) |
| void SWMM2DResultsLayer::setMaxVelocity | ( | double | v | ) |
| void SWMM2DResultsLayer::setQsgOwnsRendering | ( | bool | own | ) |
|
virtual |
Replaces the current renderer.
The layer takes ownership. Null pointers are silently rejected. Emits rendererChanged() when the pointer actually changes.
Reimplemented from OpenSWMMVisLayer.
| void SWMM2DResultsLayer::setSource | ( | std::unique_ptr< IMesh2DSource > | source | ) |
Swap the data source. Triggers a one-time mesh-geometry rebuild; the current time index is clamped to the new source's timeCount()-1.
Lifecycle: a run typically calls setSource(EngineMesh2DSource) once at twoDInitialized, then setSource(HDF5Mesh2DSource) again at finished to swap to the on-disk file for scrubbing.
| void SWMM2DResultsLayer::setVelocityArrowScale | ( | double | scale | ) |
| void SWMM2DResultsLayer::setVelocityOpacity | ( | qreal | alpha | ) |
| void SWMM2DResultsLayer::setVelocityVectorsVisible | ( | bool | v | ) |
|
inline |
|
inlinenoexcept |
|
inlinenoexcept |
|
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.
|
overridevirtual |
Slice U-6 — surface the 5 sublayer style bags as styleable subjects for the unified LayerStyleDialog.
Reimplemented from OpenSWMMVisLayer.
| QList< OpenSWMM::Render::LegendSymbolItem > SWMM2DResultsLayer::sublayerLegendItems | ( | ) | const |
Graduated ramp swatches for the legend dock. Mirrors SWMMResultsLayer::sublayerLegendItems for the 2D layer: emits one row per colour-ramp bin (depth), one per filled-contour band when enabled, plus single rows for isolines and velocity arrows. Each row carries the originating sublayerId so the legend's right-click → "Edit Sublayer Style…" path still works.
|
overridevirtual |
The ordered list of sublayers owned by this layer.
Paint order is list order (bottom-up). Callers must NOT cache the returned list across structural changes — the host may add / remove / reorder sublayers in response to user actions, and the references become stale. Returned references are non-owning; the host retains ownership of every sublayer.
Implements OpenSWMM::Render::ISublayerHost.
|
signal |
Emitted when source()->timeCount() changes (either via setSource or refreshTimeRange).
|
inlinenoexcept |
Display triangle → owning cell (parallel to m_sceneTris / triVertexIndices).
|
inlinenoexcept |
QSG-2D-1M — display triangle → vertex-id triples backing m_sceneTris (indices into m_sceneVerts). Read-only view for the renderer's static indexed-geometry path. On a mixed mesh this is the sub-triangle FAN (one entry per triangle cell, two per quad, cell order); see triCellMap / cellTriRange for the cell mapping.
| double SWMM2DResultsLayer::velocityArrowScale | ( | ) | const |
Per-glyph pixel scale: arrow_length_px = scale * log1p(vmag / vmagRef). Default 30 — a 1 m/s velocity renders ~21 px at any zoom.
| bool SWMM2DResultsLayer::velocityAtScene | ( | const QPointF & | scenePt, |
| float & | outVx, | ||
| float & | outVy | ||
| ) | const |
Barycentrically-interpolated scene-space velocity (m/s) at scenePt, from the per-vertex velocity field reconstructed in applyCurrentFlux_ (V1, Issue 5). Writes outVx,outVy and returns true when scenePt lies in a wet cell; returns false (and zeros) off-mesh or where the containing cell is dry. Used by the grid-sampled glyph placement so arrows are evenly spaced (independent of mesh density) and their direction varies smoothly across cell boundaries.
| qreal SWMM2DResultsLayer::velocityOpacity | ( | ) | const |
Overall alpha applied to all arrow glyphs, 0..1. Default 0.9.
|
inline |
| bool SWMM2DResultsLayer::velocityVectorsVisible | ( | ) | const |
Whether centroid arrow glyphs are drawn over the depth fill.
| QRectF SWMM2DResultsLayer::m_sceneBBox |
| QVector<SceneEdge> SWMM2DResultsLayer::m_sceneEdges |
| QVector<SceneTri> SWMM2DResultsLayer::m_sceneTris |
| QVector<QPointF> SWMM2DResultsLayer::m_sceneVerts |
QSG-2D-1M — shared scene-space vertex positions (parallel to the source vertex arrays). Built in rebuildSceneGeometry_; lets the QSG renderer draw one marker per UNIQUE mesh vertex (the per-corner emission repeated shared vertices ~6×) and feed the static indexed geometry buffers without expanding corners.
| MeshSpatialGrid SWMM2DResultsLayer::m_triGrid |
Point-location index over m_sceneTris bboxes (parallel indices). Built in rebuildSceneGeometry_; accelerates pickCellAt from O(n) to O(cell).