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
qsg2ddirtystate.h
Go to the documentation of this file.
1
46#ifndef OPENSWMM_RENDER_QSG2DDIRTYSTATE_H
47#define OPENSWMM_RENDER_QSG2DDIRTYSTATE_H
48
49#include <QtGlobal>
50
51namespace OpenSWMM::Render
52{
53
55{
56public:
57 enum Domain : quint32 {
58 None = 0,
59 Geometry = 1u << 0,
60 Style = 1u << 1,
61 Data = 1u << 2,
62 Selection = 1u << 3,
63 Lod = 1u << 4,
64 Transform = 1u << 5,
65
69 };
70
71 // ── Event notes (called from signal handlers / setters) ────────────
72
76 void noteExtentChanged(bool zoomChanged)
77 {
78 m_extentChanged = true;
79 m_zoomChanged = m_zoomChanged || zoomChanged;
80 }
81
82 void noteDataChanged() { m_pending |= Data; }
83 void noteSelectionChanged() { m_pending |= Selection; }
84 void noteStyleChanged() { m_pending |= Style; }
85 void noteGeometryChanged() { m_pending |= Geometry; }
86
88 void noteLayerChanged() { m_pending |= AllContent; }
89
92 void noteExternalChanged() { m_external = true; }
93
94 // ── Pre-resolve introspection (for perf-log dirty reasons) ─────────
95
96 [[nodiscard]] bool extentChangePending() const { return m_extentChanged; }
97 [[nodiscard]] bool zoomChangePending() const { return m_zoomChanged; }
98 [[nodiscard]] bool externalChangePending() const { return m_external; }
99 [[nodiscard]] quint32 pending() const { return m_pending; }
100
101 [[nodiscard]] bool hasAnythingPending() const
102 {
103 return m_pending != None || m_external || m_extentChanged;
104 }
105
106 // ── Sync-time resolution ────────────────────────────────────────────
107
125 quint32 resolve(bool geomRevisionChanged,
126 bool selectionChanged,
127 bool timeChanged,
128 bool lodKeyChanged,
129 bool extentInsideCoverage)
130 {
131 quint32 bits = m_pending;
132
133 // Snapshot diffs always win — they are ground truth regardless of
134 // which (or whether a) signal fired.
135 if (geomRevisionChanged) bits |= Geometry;
136 if (selectionChanged) bits |= Selection;
137 if (timeChanged) bits |= Data;
138
139 // An ambiguous external change with no observable diff is treated
140 // as a style edit: the broadest safe content refresh that still
141 // leaves static geometry, selection and transform state alone.
142 if (m_external
143 && !geomRevisionChanged && !selectionChanged && !timeChanged
144 && (bits & (Geometry | Selection | Data)) == 0)
145 bits |= Style;
146
147 if (m_extentChanged) {
148 bits |= Transform;
149 if (lodKeyChanged || !extentInsideCoverage) bits |= Lod;
150 } else if (lodKeyChanged || !extentInsideCoverage) {
151 // Viewport/DPR resize (or a mesh-stat change) without an extent
152 // move still re-keys the content — and a coverage miss without
153 // an extent event (view grew past the built region) must
154 // likewise repopulate.
155 bits |= Lod;
156 }
157
158 m_pending = None;
159 m_external = false;
160 m_extentChanged = false;
161 m_zoomChanged = false;
162 return bits;
163 }
164
165 void clear()
166 {
167 m_pending = None;
168 m_external = false;
169 m_extentChanged = false;
170 m_zoomChanged = false;
171 }
172
173private:
174 quint32 m_pending = None;
175 bool m_external = false;
176 bool m_extentChanged = false;
177 bool m_zoomChanged = false;
178};
179
180} // namespace OpenSWMM::Render
181
182#endif // OPENSWMM_RENDER_QSG2DDIRTYSTATE_H
Definition qsg2ddirtystate.h:55
Domain
Definition qsg2ddirtystate.h:57
@ All
Definition qsg2ddirtystate.h:68
@ None
Definition qsg2ddirtystate.h:58
@ Transform
Definition qsg2ddirtystate.h:64
@ Selection
Definition qsg2ddirtystate.h:62
@ Style
Definition qsg2ddirtystate.h:60
@ Data
Definition qsg2ddirtystate.h:61
@ AllContent
Definition qsg2ddirtystate.h:67
@ Lod
Definition qsg2ddirtystate.h:63
@ Geometry
Definition qsg2ddirtystate.h:59
bool extentChangePending() const
Definition qsg2ddirtystate.h:96
bool hasAnythingPending() const
Definition qsg2ddirtystate.h:101
void noteGeometryChanged()
Definition qsg2ddirtystate.h:85
void noteStyleChanged()
Definition qsg2ddirtystate.h:84
bool externalChangePending() const
Definition qsg2ddirtystate.h:98
void clear()
Definition qsg2ddirtystate.h:165
void noteDataChanged()
Definition qsg2ddirtystate.h:82
quint32 pending() const
Definition qsg2ddirtystate.h:99
void noteExtentChanged(bool zoomChanged)
Definition qsg2ddirtystate.h:76
bool zoomChangePending() const
Definition qsg2ddirtystate.h:97
quint32 resolve(bool geomRevisionChanged, bool selectionChanged, bool timeChanged, bool lodKeyChanged, bool extentInsideCoverage)
Definition qsg2ddirtystate.h:125
void noteExternalChanged()
Definition qsg2ddirtystate.h:92
void noteLayerChanged()
Definition qsg2ddirtystate.h:88
void noteSelectionChanged()
Definition qsg2ddirtystate.h:83
Definition gisrasterlayer.h:40