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
swmmlayerqsgrenderer.h
Go to the documentation of this file.
1
28#ifndef SWMMLAYERQSGRENDERER_H
29#define SWMMLAYERQSGRENDERER_H
30
31#include "map/mapextent.h"
32
33#include <QPointer>
34#include <QQuickItem>
35#include <QVector>
36
37#include <limits>
38
39class SWMMModelLayer;
40
41class SWMMLayerQSGRenderer : public QQuickItem
42{
43 Q_OBJECT
44
45public:
46 explicit SWMMLayerQSGRenderer(QQuickItem *parent = nullptr);
48
52 void setLayer(SWMMModelLayer *layer);
53
57 void setMapExtent(const MapExtent &extent);
58
64 void forceRebuild();
65
75 [[nodiscard]] quint64 contentRevision() const noexcept
76 { return m_contentRev; }
77
78protected:
79 QSGNode *updatePaintNode(QSGNode *oldNode,
80 UpdatePaintNodeData *) override;
81
82private:
85 void noteContentChanged() { ++m_contentRev; update(); }
86
87 QPointer<SWMMModelLayer> m_layer;
88 quint64 m_contentRev = 0;
89 MapExtent m_extent;
90 // Extent at the last full content rebuild. Used by setMapExtent()
91 // to decide pan-only (transform refresh) vs. full rebuild based on
92 // how far the viewport has drifted from the cached cull window.
93 MapExtent m_lastBuiltExtent;
94
95 // Fixed scene-space centre of the dataset bounding box, recomputed at
96 // the start of each content rebuild. Vertex coords stored as
97 // float(sceneCoord - anchor) keep float magnitudes small (UTM precision)
98 // and are stable across pans — only the matrix translate changes on pan.
99 double m_anchorX = 0.0;
100 double m_anchorY = 0.0;
101
102 // m_contentDirty — set on geometry / symbology / visibility / zoom changes.
103 // Triggers a full rebuild of all 13 geometry buffers in updatePaintNode.
104 // Pure pan does NOT set this flag.
105 bool m_contentDirty = true;
106
107 // m_selDirty — set when only the selection changes (setSelectedElementNames).
108 // Triggers a cheap rebuild of the 5 selection-overlay buffers only; the 8
109 // base-geometry buffers are left untouched.
110 // m_selectionPending absorbs the repaintRequested that always follows
111 // selectionChanged so it does not additionally set m_contentDirty.
112 bool m_selDirty = false;
113 bool m_selectionPending = false;
114
115 // Subcatchment triangulation cache (Stage 4).
116 // Ear-clipping O(n²) result cached per geomRevision; reused on every
117 // rebuild that does not change subcatchment geometry.
118 struct CatchTriCache {
119 quint64 revision = std::numeric_limits<quint64>::max();
120 QVector<QVector<int>> tris;
121 };
122 CatchTriCache m_catchTriCache;
123};
124
125#endif // SWMMLAYERQSGRENDERER_H
An axis-aligned bounding box in the coordinate space of a given CRS.
Definition mapextent.h:26
Definition swmmlayerqsgrenderer.h:42
void forceRebuild()
Definition swmmlayerqsgrenderer.cpp:742
QSGNode * updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *) override
Definition swmmlayerqsgrenderer.cpp:781
void setLayer(SWMMModelLayer *layer)
Definition swmmlayerqsgrenderer.cpp:683
quint64 contentRevision() const noexcept
Definition swmmlayerqsgrenderer.h:75
~SWMMLayerQSGRenderer() override
void setMapExtent(const MapExtent &extent)
Definition swmmlayerqsgrenderer.cpp:751
Renders the SWMM network elements (nodes, links, subcatchments, rain gages) for one OpenSWMMEngine mo...
Definition swmmmodellayer.h:133
Axis-aligned bounding box in a map coordinate system, used by MapCanvas and all layer types to define...
QVector< int > parent
union-find
Definition pslgminsize.cpp:176