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
comparisonplotmodel.h
Go to the documentation of this file.
1
23#ifndef OPENSWMMVIS_PLOT_COMPARISONPLOTMODEL_H
24#define OPENSWMMVIS_PLOT_COMPARISONPLOTMODEL_H
25
26#include "plot/irunlayer.h"
27#include "plot/plotattribute.h"
28#include "plot/seriesstyle.h"
29
30#include <QObject>
31#include <QString>
32#include <QVector>
33
34#include <memory>
35
36namespace openswmmvis::plot {
37
39struct RunSource {
40 std::shared_ptr<IRunLayer> layer;
41 QString label;
42 bool isBaseline = false;
43 bool isTransient = false;
45
46 int cycleSeed = 0;
47};
48
78
93
100 int xSeriesIndex = -1;
101 int ySeriesIndex = -1;
102
103 bool operator==(const ComparisonPair& o) const noexcept
104 { return xSeriesIndex == o.xSeriesIndex && ySeriesIndex == o.ySeriesIndex; }
105};
106
117class ComparisonPlotModel : public QObject
118{
119 Q_OBJECT
120public:
121 explicit ComparisonPlotModel(QObject *parent = nullptr);
123
124 // ----- RunSource list -------------------------------------------------
125
128
132 void removeRunSource(int runIndex);
133
134 int runSourceCount() const noexcept { return m_runs.size(); }
135 const RunSource& runSource(int i) const { return m_runs.at(i); }
136 RunSource& runSource(int i) { return m_runs[i]; }
137
139 int findRunByLayer(const IRunLayer* layer) const;
140
142 void setBaseline(int runIndex);
143 int baselineRunIndex() const noexcept { return m_baselineIdx; }
144
145 // ----- SeriesSpec list ------------------------------------------------
146
150
152 void removeSeries(int seriesIndex);
153
155 void updateStyle(int seriesIndex, const SeriesStyle& style);
156
160 void updateLegendOverride(int seriesIndex, const QString& legendOverride);
161
162 int seriesCount() const noexcept { return m_specs.size(); }
163 const SeriesSpec& spec(int i) const { return m_specs.at(i); }
164 SeriesSpec& spec(int i) { return m_specs[i]; }
165 const QVector<SeriesSpec>& specs() const noexcept { return m_specs; }
166
167 // ----- 1v1 comparison pairs (Phase 5) ----------------------------------
168 // Empty list = auto mode (baseline vs every other run by objectRef).
169
173 int addPair(ComparisonPair pair);
174
176 void removePair(int pairIndex);
177
180 void clearPairs();
181
182 const QVector<ComparisonPair>& pairs() const noexcept { return m_pairs; }
183
184 // ----- Derived row layout --------------------------------------------
185
188 const QVector<AttributeRow>& rows() const noexcept { return m_rows; }
189
193 void rebuildRows();
194
195 // ----- Series resolution ---------------------------------------------
196
199 void resolveSeries(int seriesIndex, SeriesData& out) const;
200
201 // ----- Animation cursor ----------------------------------------------
202
204 QDateTime animationTime() const noexcept { return m_animTime; }
205
208 void setAnimationTime(QDateTime t);
209
210signals:
211 void runSourceAdded(int runIndex);
212 void runSourceRemoved(int runIndex);
213 void baselineChanged(int runIndex);
214 void seriesAdded(int seriesIndex);
215 void seriesRemoved(int seriesIndex);
216 void styleChanged(int seriesIndex);
218 void animationTimeChanged(QDateTime t);
219
223
224private:
225 QVector<RunSource> m_runs;
226 QVector<SeriesSpec> m_specs;
227 QVector<AttributeRow> m_rows;
228 QVector<ComparisonPair> m_pairs;
229 int m_baselineIdx = -1;
230 QDateTime m_animTime;
231
233 void deriveRows_();
234
237 bool fixupPairsAfterSeriesRemoval_(int seriesIndex);
238};
239
240} // namespace openswmmvis::plot
241
242#endif // OPENSWMMVIS_PLOT_COMPARISONPLOTMODEL_H
Per-project flow-units state + label helpers.
Definition unitsystem.h:28
Model layer for the Comparison Plot Dialog.
Definition comparisonplotmodel.h:118
void pairsChanged()
Phase 5 — the 1v1 pair list changed (add/remove/clear or reindex after a series removal).
void resolveSeries(int seriesIndex, SeriesData &out) const
Resolve a single series. Convenience wrapper over the RunSource layer's IRunLayer::getSeriesAt.
Definition comparisonplotmodel.cpp:265
SeriesSpec & spec(int i)
Definition comparisonplotmodel.h:164
int addSeries(SeriesSpec spec)
Append a series spec. Auto-assigns a default style cycle if spec.style is the default-constructed sty...
Definition comparisonplotmodel.cpp:100
const QVector< ComparisonPair > & pairs() const noexcept
Definition comparisonplotmodel.h:182
const SeriesSpec & spec(int i) const
Definition comparisonplotmodel.h:163
void removeSeries(int seriesIndex)
Remove a series.
Definition comparisonplotmodel.cpp:119
void updateStyle(int seriesIndex, const SeriesStyle &style)
Update a series' style. Emits styleChanged.
Definition comparisonplotmodel.cpp:190
void clearPairs()
Drop all pairs (back to auto mode). Emits pairsChanged when the list was non-empty.
Definition comparisonplotmodel.cpp:166
int addPair(ComparisonPair pair)
Append a pair. Rejects (returns -1) invalid/duplicate pairs, self-pairs, and pairs whose series targe...
Definition comparisonplotmodel.cpp:136
QDateTime animationTime() const noexcept
Current animation time. Invalid when nothing is playing.
Definition comparisonplotmodel.h:204
int addRunSource(RunSource src)
Append a run. Returns the new run's index.
Definition comparisonplotmodel.cpp:25
int runSourceCount() const noexcept
Definition comparisonplotmodel.h:134
const QVector< AttributeRow > & rows() const noexcept
Distinct attributes present in the spec list, ordered by the order each attribute was first added.
Definition comparisonplotmodel.h:188
void updateLegendOverride(int seriesIndex, const QString &legendOverride)
Update a series' legend override (spec-level — wins over the auto-generated "run — object (attr)" lab...
Definition comparisonplotmodel.cpp:198
void removeRunSource(int runIndex)
Remove a run by index. All SeriesSpec entries referencing the removed run are dropped first; remainin...
Definition comparisonplotmodel.cpp:46
void removePair(int pairIndex)
Remove a pair by index. Emits pairsChanged.
Definition comparisonplotmodel.cpp:158
const RunSource & runSource(int i) const
Definition comparisonplotmodel.h:135
void rebuildRows()
Force re-derivation of rows(). Called automatically after add/remove; exposed so views can refresh af...
Definition comparisonplotmodel.cpp:210
int findRunByLayer(const IRunLayer *layer) const
Find run by IRunLayer pointer; -1 if not found.
Definition comparisonplotmodel.cpp:79
RunSource & runSource(int i)
Definition comparisonplotmodel.h:136
const QVector< SeriesSpec > & specs() const noexcept
Definition comparisonplotmodel.h:165
int baselineRunIndex() const noexcept
Definition comparisonplotmodel.h:143
void setBaseline(int runIndex)
Mark a run as baseline. -1 clears the baseline.
Definition comparisonplotmodel.cpp:90
void setAnimationTime(QDateTime t)
Slot for AnimationController::currentTimeChanged. Emits animationTimeChanged for views to update the ...
Definition comparisonplotmodel.cpp:296
int seriesCount() const noexcept
Definition comparisonplotmodel.h:162
Abstract source backing one comparison-plot run.
Definition irunlayer.h:171
size_t i
Definition contourjob.cpp:27
DiagramType t
Definition diagramspec.cpp:20
Slice BL — abstract "data-source" that the ComparisonPlotModel reads timeseries from.
Definition chartproperties.h:34
PlotAttribute
What a series plots. One row per attribute in the Nx2 grid.
Definition plotattribute.h:38
@ US
ft, ft/s, ft³/s, ft³
Slice BL — canonical enumeration of plottable result attributes.
int src
index into the caller's vector; -1 = new
Definition pslgminsize.cpp:152
QVector< int > parent
union-find
Definition pslgminsize.cpp:176
Per-series rendering style for chart plots (comprehensive schema).
Derived aggregation for one chart row. The model recomputes these whenever the spec list changes; vie...
Definition comparisonplotmodel.h:81
QString unitsLabel
e.g. "ft", "m/s".
Definition comparisonplotmodel.h:91
double ymax
Definition comparisonplotmodel.h:89
PlotAttribute attribute
Definition comparisonplotmodel.h:82
double ymin
Definition comparisonplotmodel.h:88
QString species
Definition comparisonplotmodel.h:86
QVector< int > seriesIndices
Indices into ComparisonPlotModel::specs() that target this attr.
Definition comparisonplotmodel.h:87
UnitSystem unitSystem
Definition comparisonplotmodel.h:90
One user-configured 1v1 comparison: X-series vs Y-series (COMPARISON_PLOT_1V1_AND_TREE_PLAN Phase 5)....
Definition comparisonplotmodel.h:99
int xSeriesIndex
Index into specs() — scatter X values.
Definition comparisonplotmodel.h:100
bool operator==(const ComparisonPair &o) const noexcept
Definition comparisonplotmodel.h:103
int ySeriesIndex
Index into specs() — scatter Y values.
Definition comparisonplotmodel.h:101
Identifies what object a series is about. Kind is the discriminator; the active union member is impli...
Definition irunlayer.h:38
bool isValid() const noexcept
Definition irunlayer.h:69
One plottable result: a fixed attribute OR a species by name.
Definition resultdescriptor.h:39
static ResultDescriptor forAttribute(PlotAttribute a)
Definition resultdescriptor.h:65
static ResultDescriptor forSpecies(const QString &name)
Definition resultdescriptor.h:68
One loaded run in the plot — a 1D .out, an observed CSV, or a 2D mesh layer.
Definition comparisonplotmodel.h:39
SeriesStyle defaultStyle
Cycle position for series in this run.
Definition comparisonplotmodel.h:44
bool isTransient
True when owned by the dialog (loaded ad hoc).
Definition comparisonplotmodel.h:43
int cycleSeed
Internal: used to spread colours within the run.
Definition comparisonplotmodel.h:46
bool isBaseline
Anchor for the 1v1 scatter column.
Definition comparisonplotmodel.h:42
std::shared_ptr< IRunLayer > layer
The actual data source. May be owned by the dialog.
Definition comparisonplotmodel.h:40
QString label
Display label; defaults to layer->scenarioName().
Definition comparisonplotmodel.h:41
Result of one series resolution. Times are SWMM DateTime doubles (OLE-Automation epoch,...
Definition irunlayer.h:151
One chart series — points at a RunSource via index and identifies what to read from it.
Definition comparisonplotmodel.h:51
ResultDescriptor descriptor() const
Definition comparisonplotmodel.h:66
QString legendOverride
Empty = auto-generate from (run, ref, attr).
Definition comparisonplotmodel.h:62
SeriesStyle style
Definition comparisonplotmodel.h:61
PlotAttribute attribute
Definition comparisonplotmodel.h:54
ObjectRef objectRef
Definition comparisonplotmodel.h:53
int runIndex
Definition comparisonplotmodel.h:52
bool isValid() const noexcept
Definition comparisonplotmodel.h:72
QString species
Definition comparisonplotmodel.h:60
Aggregated rendering parameters for one chart series.
Definition seriesstyle.h:48