![]() |
SWMMVis
6.0.0-alpha.4
Qt6/C++ GIS-based graphical user interface for the SWMMVis engine (6.0.0-alpha.4)
|
#include <timeseriesprovider.h>
Public Types | |
| enum class | SourceMode { Inline , ExternalFile , GeopackageObserved } |
| Where the data lives. More... | |
| enum class | TimeMode { Absolute , Relative , Mixed } |
How the series' times were authored in the .inp. More... | |
Signals | |
| void | timeModeChanged () |
| The derived timeMode() flipped, or the relative anchor moved. Payload-free; subscribers re-read (metadataChanged style). | |
| void | pointsChanged (int firstIndex, int count) |
| Points in [firstIndex, firstIndex+count) had their value changed in place. | |
| void | pointsInserted (int at, int count) |
count points were inserted starting at at. | |
| void | pointsRemoved (int at, int count) |
count points were removed starting at at. | |
| void | metadataChanged () |
| Identity / units / description changed (signal carries no payload; subscribers re-read). | |
| void | sourceModeChanged (SourceMode prev, SourceMode now) |
| Source mode flipped. | |
| void | nameChanged (QString prev, QString now) |
| Tseries was renamed; dependent-reference cascading is the registry's job (subscribers should not rewrite refs from this signal). | |
| void | mutationRejected (QString reason) |
| A mutator was refused because it would have violated an invariant. Surfaced to UI so the drag-edit status bar can show the offending state. | |
| void | pointCacheDisposed () |
Step F — ExternalFile mode: the lazy point cache was dropped via disposePointCache. Distinguishes "freed to save memory" from "legitimately empty" so views can render a placeholder instead of treating it as a parse failure. | |
Public Member Functions | |
| TimeseriesProvider (QString name, QObject *parent=nullptr) | |
| ~TimeseriesProvider () override | |
| QString | name () const noexcept |
| Tseries ID. Uniqueness within a project is owned by the registry. | |
| QString | unitsLabel () const noexcept |
| Units label inferred from column suffix or set explicitly (e.g. "m", "ft³/s"). UI hint only — no unit conversion happens here. | |
| QString | description () const noexcept |
| Optional free-text description; surfaced by the editor's header context menu. | |
| SourceMode | sourceMode () const noexcept |
| QString | filePath () const noexcept |
| External file path (meaningful only when sourceMode == ExternalFile). | |
| QString | columnSelector () const noexcept |
| Column selector inside the external file ("" = first / name-match). | |
| QDateTime | fileMTime () const noexcept |
| Last-known file mtime for staleness detection. | |
| int | pointCount () const noexcept |
| Number of stored points. ExternalFile mode reports 0 until the read-through cache is implemented in its dedicated sub-phase. | |
| bool | isPointCacheLoaded () const noexcept |
True iff the in-memory point vector is populated. Inline / GeopackageObserved modes always return true (their points ARE the authoritative storage). ExternalFile mode returns true between a load and a disposePointCache call. | |
| void | disposePointCache () |
Drop the in-memory point vector for ExternalFile-mode providers to reclaim memory when the editor switches to a different series. The file path / column selector / mtime stay so a later Reload can re-read from disk. No-op for Inline / GeopackageObserved — those caches are authoritative storage and disposing would lose data. Emits pointsChanged(0, prevCount) so the table / chart views drop to an empty-state render (and pointCacheDisposed() for callers that need to distinguish "disposed" from "naturally empty"). | |
| const TimeseriesPoint & | pointAt (int i) const |
Read a single point by index. Caller must ensure 0 ≤ i < pointCount(). | |
| const QVector< TimeseriesPoint > & | points () const noexcept |
| All points (const ref). | |
| bool | setAllPoints (QVector< TimeseriesPoint > newPoints, QString *reasonOut=nullptr) |
| Replace the entire point list. Validates strict-monotone time before applying. Atomic: either all replaced or none. | |
| bool | setValueAt (int i, double newValue, QString *reasonOut=nullptr) |
| Change only the value at index i. Time stays put so monotonicity is preserved by construction. | |
| bool | setValueLive (int i, double newValue) |
| Live variant of setValueAt for drag-edit: does NOT push undo per-frame (caller handles batching). Same monotonicity guarantee. | |
| bool | setPointAt (int i, QDateTime newTime, double newValue, QString *reasonOut=nullptr) |
| Change both time + value at index i. Validates that the new time still slots between neighbours strictly. | |
| int | insertPoint (QDateTime time, double value, QString *reasonOut=nullptr) |
| Insert one point. Returns the new index on success. | |
| void | removePointsAt (QVector< int > indices) |
| Remove points by index. Indices are deduplicated + sorted descending internally so the loop is safe. | |
| void | setName (QString newName) |
| Rename the Tseries. Uniqueness is the registry's responsibility; this just stores + notifies. | |
| void | setUnitsLabel (QString units) |
| void | setDescription (QString d) |
| void | setSourceMode (SourceMode mode) |
| void | setFileSource (QString path, QString columnSelector, QDateTime mtime) |
| TimeMode | timeMode () const noexcept |
| Derived mode: Relative when every point is in the relative prefix (or an empty series carries relative intent), Absolute when the prefix is empty, Mixed otherwise. | |
| int | relativeCount () const noexcept |
| Leading points authored as elapsed-time-from-start. | |
| QDateTime | relativeAnchor () const noexcept |
| Simulation start the relative points' absolute times are anchored to (invalid when the series has no relative rows). | |
| void | setRelativeInfo (int count, QDateTime anchor, int allRelativeIntent=-1) |
| Raw restore used by registry load and undo: sets the prefix count (clamped to [0, pointCount()]), the anchor, and — when allRelativeIntent is 0/1 — the sticky "author every new row as
relative" flag (-1 derives it as count > 0 && count == pointCount(), which for an EMPTY series means count > 0 requests relative intent). Emits timeModeChanged() when the derived mode or anchor changes. | |
| void | setTimeMode (TimeMode mode, QDateTime anchorForRelative={}) |
| User-facing mode switch. Relative marks every current point relative and records anchorForRelative (when valid) as the anchor; Absolute clears the prefix. Mixed is a loaded state, not a target — requesting it is a no-op. | |
|
strong |
|
strong |
How the series' times were authored in the .inp.
SWMM [TIMESERIES] rows come in two forms: rows with an explicit date (the date carries forward to date-less continuation rows until the next dated row), and rows with only a time — elapsed since the simulation start. Both may mix in one series: date-less HEAD rows are relative to the start, the dated tail is absolute. The engine tracks this per table (swmm_timeseries_get/set_relative_info); the provider mirrors it so the editor can badge/author the format and the registry can round-trip it. Points are ALWAYS stored as absolute QDateTimes here — the mode only records how the leading rows are (re)emitted.
| Enumerator | |
|---|---|
| Absolute | Every row carries (or inherits) an explicit date. |
| Relative | Every row is elapsed time from the simulation start. |
| Mixed | Elapsed head rows + dated tail (loaded, not authored). |
|
explicit |
|
overridedefault |
|
inlinenoexcept |
Column selector inside the external file ("" = first / name-match).
|
inlinenoexcept |
Optional free-text description; surfaced by the editor's header context menu.
| void openswmmvis::timeseries::TimeseriesProvider::disposePointCache | ( | ) |
Drop the in-memory point vector for ExternalFile-mode providers to reclaim memory when the editor switches to a different series. The file path / column selector / mtime stay so a later Reload can re-read from disk. No-op for Inline / GeopackageObserved — those caches are authoritative storage and disposing would lose data. Emits pointsChanged(0, prevCount) so the table / chart views drop to an empty-state render (and pointCacheDisposed() for callers that need to distinguish "disposed" from "naturally empty").
|
inlinenoexcept |
Last-known file mtime for staleness detection.
|
inlinenoexcept |
External file path (meaningful only when sourceMode == ExternalFile).
| int openswmmvis::timeseries::TimeseriesProvider::insertPoint | ( | QDateTime | time, |
| double | value, | ||
| QString * | reasonOut = nullptr |
||
| ) |
Insert one point. Returns the new index on success.
| reasonOut | On failure, populated with a human-readable reason. |
|
noexcept |
True iff the in-memory point vector is populated. Inline / GeopackageObserved modes always return true (their points ARE the authoritative storage). ExternalFile mode returns true between a load and a disposePointCache call.
|
signal |
Identity / units / description changed (signal carries no payload; subscribers re-read).
|
signal |
A mutator was refused because it would have violated an invariant. Surfaced to UI so the drag-edit status bar can show the offending state.
|
inlinenoexcept |
Tseries ID. Uniqueness within a project is owned by the registry.
|
signal |
Tseries was renamed; dependent-reference cascading is the registry's job (subscribers should not rewrite refs from this signal).
|
inline |
Read a single point by index. Caller must ensure 0 ≤ i < pointCount().
|
signal |
Step F — ExternalFile mode: the lazy point cache was dropped via disposePointCache. Distinguishes "freed to save memory" from "legitimately empty" so views can render a placeholder instead of treating it as a parse failure.
|
inlinenoexcept |
Number of stored points. ExternalFile mode reports 0 until the read-through cache is implemented in its dedicated sub-phase.
|
inlinenoexcept |
All points (const ref).
|
signal |
Points in [firstIndex, firstIndex+count) had their value changed in place.
|
signal |
count points were inserted starting at at.
|
signal |
count points were removed starting at at.
|
inlinenoexcept |
Simulation start the relative points' absolute times are anchored to (invalid when the series has no relative rows).
|
inlinenoexcept |
Leading points authored as elapsed-time-from-start.
| void openswmmvis::timeseries::TimeseriesProvider::removePointsAt | ( | QVector< int > | indices | ) |
Remove points by index. Indices are deduplicated + sorted descending internally so the loop is safe.
| bool openswmmvis::timeseries::TimeseriesProvider::setAllPoints | ( | QVector< TimeseriesPoint > | newPoints, |
| QString * | reasonOut = nullptr |
||
| ) |
Replace the entire point list. Validates strict-monotone time before applying. Atomic: either all replaced or none.
| void openswmmvis::timeseries::TimeseriesProvider::setDescription | ( | QString | d | ) |
| void openswmmvis::timeseries::TimeseriesProvider::setFileSource | ( | QString | path, |
| QString | columnSelector, | ||
| QDateTime | mtime | ||
| ) |
| void openswmmvis::timeseries::TimeseriesProvider::setName | ( | QString | newName | ) |
Rename the Tseries. Uniqueness is the registry's responsibility; this just stores + notifies.
| bool openswmmvis::timeseries::TimeseriesProvider::setPointAt | ( | int | i, |
| QDateTime | newTime, | ||
| double | newValue, | ||
| QString * | reasonOut = nullptr |
||
| ) |
Change both time + value at index i. Validates that the new time still slots between neighbours strictly.
| void openswmmvis::timeseries::TimeseriesProvider::setRelativeInfo | ( | int | count, |
| QDateTime | anchor, | ||
| int | allRelativeIntent = -1 |
||
| ) |
Raw restore used by registry load and undo: sets the prefix count (clamped to [0, pointCount()]), the anchor, and — when allRelativeIntent is 0/1 — the sticky "author every new row as relative" flag (-1 derives it as count > 0 && count == pointCount(), which for an EMPTY series means count > 0 requests relative intent). Emits timeModeChanged() when the derived mode or anchor changes.
| void openswmmvis::timeseries::TimeseriesProvider::setSourceMode | ( | SourceMode | mode | ) |
| void openswmmvis::timeseries::TimeseriesProvider::setTimeMode | ( | TimeMode | mode, |
| QDateTime | anchorForRelative = {} |
||
| ) |
User-facing mode switch. Relative marks every current point relative and records anchorForRelative (when valid) as the anchor; Absolute clears the prefix. Mixed is a loaded state, not a target — requesting it is a no-op.
| void openswmmvis::timeseries::TimeseriesProvider::setUnitsLabel | ( | QString | units | ) |
| bool openswmmvis::timeseries::TimeseriesProvider::setValueAt | ( | int | i, |
| double | newValue, | ||
| QString * | reasonOut = nullptr |
||
| ) |
Change only the value at index i. Time stays put so monotonicity is preserved by construction.
| bool openswmmvis::timeseries::TimeseriesProvider::setValueLive | ( | int | i, |
| double | newValue | ||
| ) |
Live variant of setValueAt for drag-edit: does NOT push undo per-frame (caller handles batching). Same monotonicity guarantee.
|
inlinenoexcept |
|
signal |
Source mode flipped.
|
noexcept |
Derived mode: Relative when every point is in the relative prefix (or an empty series carries relative intent), Absolute when the prefix is empty, Mixed otherwise.
|
signal |
The derived timeMode() flipped, or the relative anchor moved. Payload-free; subscribers re-read (metadataChanged style).
|
inlinenoexcept |
Units label inferred from column suffix or set explicitly (e.g. "m", "ft³/s"). UI hint only — no unit conversion happens here.