![]() |
SWMMVis
6.0.0-alpha.4
Qt6/C++ GIS-based graphical user interface for the SWMMVis engine (6.0.0-alpha.4)
|
#include <patternprovider.h>
Signals | |
| void | factorChanged (int i) |
One factor at index i had its value changed. | |
| void | factorsChanged () |
| All factors were replaced (setAllFactors / setType / normalize). Subscribers re-read the whole array. | |
| void | nameChanged (QString prev, QString now) |
| Pattern was renamed; dependent-reference cascading is the registry's job (subscribers should not rewrite refs from this signal). | |
| void | typeChanged (PatternType prev, PatternType now) |
| Pattern type changed (factors reset to 1.0). | |
| void | mutationRejected (QString reason) |
| A mutator was refused because it would have violated an invariant. Surfaced to UI so the status bar can show the offending state. | |
Public Member Functions | |
| PatternProvider (QString name, PatternType type, QObject *parent=nullptr) | |
| Construct an empty pattern of the given type. All factors start at 1.0 (the SWMM "no effect" identity value). | |
| ~PatternProvider () override | |
| QString | name () const noexcept |
| Pattern ID. Uniqueness within a project is owned by the registry. | |
| PatternType | type () const noexcept |
| Pattern shape (Monthly / Daily / Hourly / Weekend). | |
| int | factorCount () const noexcept |
| Convenience: factorCountFor(type()). | |
| double | factor (int i) const |
Read a single factor by index. Caller must ensure 0 ≤ i < factorCount(). | |
| const QVector< double > & | factors () const noexcept |
| All factors (const ref). Size is always factorCount(). | |
| double | sumOfFactors () const noexcept |
| Sum of all factors. Used by the UI status strip + normalize. | |
| bool | setFactor (int i, double v, QString *reasonOut=nullptr) |
Replace one factor. Validates 0 ≤ i < factorCount() and v >= 0 (negative multipliers are nonsensical for SWMM patterns). Emits factorChanged(i) on success. | |
| bool | setFactorLive (int i, double v) |
| Live variant of setFactor for drag-edit: does NOT push undo per-frame (caller handles batching). | |
| bool | setAllFactors (QVector< double > f, QString *reasonOut=nullptr) |
Replace the entire factor array. Size of f must equal factorCount(); each value must be >= 0. Atomic: either applied or rejected. | |
| bool | normalize (double targetSum=1.0, QString *reasonOut=nullptr) |
Rescale every factor so their sum equals targetSum. No-op (returns false) if the current sum is zero (would divide by zero). Emits factorsChanged() on success. | |
| bool | swapFactors (int i, int j, QString *reasonOut=nullptr) |
Atomically swap the factor values at indices i and j. Used by the chart view's slot-reorder drag (horizontal drag of a vertex onto an adjacent slot). Emits a single factorsChanged(). Returns false (and emits mutationRejected) on out-of-range indices. | |
| void | setName (QString newName) |
| Rename the pattern. Uniqueness is the registry's responsibility; this just stores + notifies. | |
| void | setType (PatternType t) |
Switch pattern type. Resets all factors to 1.0 because the factor count changes — there's no meaningful mapping from 12 monthly factors to 24 hourly factors. Emits typeChanged + factorsChanged. | |
Static Public Member Functions | |
| static int | factorCountFor (PatternType t) noexcept |
| How many factors does this type need? Static helper. | |
| static QString | rowLabel (PatternType t, int i) |
| Human-readable label for a factor row index (1..factorCount-1). Returns "Jan".."Dec" / "Sun".."Sat" / "00:00".."23:00" / "00:00".."23:00". Static so UI code can label headers without holding a provider. | |
| openswmmvis::pattern::PatternProvider::PatternProvider | ( | QString | name, |
| PatternType | type, | ||
| QObject * | parent = nullptr |
||
| ) |
Construct an empty pattern of the given type. All factors start at 1.0 (the SWMM "no effect" identity value).
|
overridedefault |
|
inline |
Read a single factor by index. Caller must ensure 0 ≤ i < factorCount().
|
signal |
One factor at index i had its value changed.
|
inlinenoexcept |
Convenience: factorCountFor(type()).
|
staticnoexcept |
How many factors does this type need? Static helper.
|
inlinenoexcept |
|
signal |
All factors were replaced (setAllFactors / setType / normalize). Subscribers re-read the whole array.
|
signal |
A mutator was refused because it would have violated an invariant. Surfaced to UI so the status bar can show the offending state.
|
inlinenoexcept |
Pattern ID. Uniqueness within a project is owned by the registry.
|
signal |
Pattern was renamed; dependent-reference cascading is the registry's job (subscribers should not rewrite refs from this signal).
| bool openswmmvis::pattern::PatternProvider::normalize | ( | double | targetSum = 1.0, |
| QString * | reasonOut = nullptr |
||
| ) |
Rescale every factor so their sum equals targetSum. No-op (returns false) if the current sum is zero (would divide by zero). Emits factorsChanged() on success.
|
static |
Human-readable label for a factor row index (1..factorCount-1). Returns "Jan".."Dec" / "Sun".."Sat" / "00:00".."23:00" / "00:00".."23:00". Static so UI code can label headers without holding a provider.
| bool openswmmvis::pattern::PatternProvider::setAllFactors | ( | QVector< double > | f, |
| QString * | reasonOut = nullptr |
||
| ) |
Replace the entire factor array. Size of f must equal factorCount(); each value must be >= 0. Atomic: either applied or rejected.
| bool openswmmvis::pattern::PatternProvider::setFactor | ( | int | i, |
| double | v, | ||
| QString * | reasonOut = nullptr |
||
| ) |
Replace one factor. Validates 0 ≤ i < factorCount() and v >= 0 (negative multipliers are nonsensical for SWMM patterns). Emits factorChanged(i) on success.
| bool openswmmvis::pattern::PatternProvider::setFactorLive | ( | int | i, |
| double | v | ||
| ) |
Live variant of setFactor for drag-edit: does NOT push undo per-frame (caller handles batching).
| void openswmmvis::pattern::PatternProvider::setName | ( | QString | newName | ) |
Rename the pattern. Uniqueness is the registry's responsibility; this just stores + notifies.
| void openswmmvis::pattern::PatternProvider::setType | ( | PatternType | t | ) |
Switch pattern type. Resets all factors to 1.0 because the factor count changes — there's no meaningful mapping from 12 monthly factors to 24 hourly factors. Emits typeChanged + factorsChanged.
|
noexcept |
Sum of all factors. Used by the UI status strip + normalize.
| bool openswmmvis::pattern::PatternProvider::swapFactors | ( | int | i, |
| int | j, | ||
| QString * | reasonOut = nullptr |
||
| ) |
Atomically swap the factor values at indices i and j. Used by the chart view's slot-reorder drag (horizontal drag of a vertex onto an adjacent slot). Emits a single factorsChanged(). Returns false (and emits mutationRejected) on out-of-range indices.
|
inlinenoexcept |
Pattern shape (Monthly / Daily / Hourly / Weekend).
|
signal |
Pattern type changed (factors reset to 1.0).