29#ifndef OPENSWMMVIS_PATTERN_PATTERNPROVIDER_H
30#define OPENSWMMVIS_PATTERN_PATTERNPROVIDER_H
61 QString
name() const noexcept {
return m_name; }
80 double factor(
int i)
const {
return m_factors.at(
i); }
83 const QVector<double>&
factors() const noexcept {
return m_factors; }
93 bool setFactor(
int i,
double v, QString *reasonOut =
nullptr);
101 bool setAllFactors(QVector<
double> f, QString *reasonOut =
nullptr);
106 bool normalize(
double targetSum = 1.0, QString *reasonOut =
nullptr);
112 bool swapFactors(
int i,
int j, QString *reasonOut =
nullptr);
145 QVector<
double> m_factors;
Definition patternprovider.h:49
const QVector< double > & factors() const noexcept
All factors (const ref). Size is always factorCount().
Definition patternprovider.h:83
bool setFactorLive(int i, double v)
Live variant of setFactor for drag-edit: does NOT push undo per-frame (caller handles batching).
Definition patternprovider.cpp:90
void typeChanged(PatternType prev, PatternType now)
Pattern type changed (factors reset to 1.0).
static QString rowLabel(PatternType t, int i)
Human-readable label for a factor row index (1..factorCount-1). Returns "Jan".."Dec" / "Sun"....
Definition patternprovider.cpp:27
void nameChanged(QString prev, QString now)
Pattern was renamed; dependent-reference cascading is the registry's job (subscribers should not rewr...
int factorCount() const noexcept
Convenience: factorCountFor(type()).
Definition patternprovider.h:70
bool setFactor(int i, double v, QString *reasonOut=nullptr)
Replace one factor. Validates 0 ≤ i < factorCount() and v >= 0 (negative multipliers are nonsensical ...
Definition patternprovider.cpp:69
~PatternProvider() override
QString name() const noexcept
Pattern ID. Uniqueness within a project is owned by the registry.
Definition patternprovider.h:61
void factorsChanged()
All factors were replaced (setAllFactors / setType / normalize). Subscribers re-read the whole array.
PatternType type() const noexcept
Pattern shape (Monthly / Daily / Hourly / Weekend).
Definition patternprovider.h:64
bool setAllFactors(QVector< double > f, QString *reasonOut=nullptr)
Replace the entire factor array. Size of f must equal factorCount(); each value must be >= 0....
Definition patternprovider.cpp:100
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 ...
Definition patternprovider.cpp:122
void setType(PatternType t)
Switch pattern type. Resets all factors to 1.0 because the factor count changes — there's no meaningf...
Definition patternprovider.cpp:166
double sumOfFactors() const noexcept
Sum of all factors. Used by the UI status strip + normalize.
Definition patternprovider.cpp:64
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 (hor...
Definition patternprovider.cpp:143
double factor(int i) const
Read a single factor by index. Caller must ensure 0 ≤ i < factorCount().
Definition patternprovider.h:80
void setName(QString newName)
Rename the pattern. Uniqueness is the registry's responsibility; this just stores + notifies.
Definition patternprovider.cpp:158
void factorChanged(int i)
One factor at index i had its value changed.
void mutationRejected(QString reason)
A mutator was refused because it would have violated an invariant. Surfaced to UI so the status bar c...
static int factorCountFor(PatternType t) noexcept
How many factors does this type need? Static helper.
Definition patternprovider.cpp:16
size_t i
Definition contourjob.cpp:27
DiagramType t
Definition diagramspec.cpp:20
Definition patternprovider.h:36
PatternType
Pattern shape — fixed factor count per type. Numeric values intentionally match the engine's PatternT...
Definition patternprovider.h:41
@ Weekend
24 factors, one per hour of day (weekend).
@ Hourly
24 factors, one per hour of day (weekday).
@ Monthly
12 factors, one per calendar month.
@ Daily
7 factors, one per day of week (Sun..Sat).
QVector< int > v
pool vertex indices
Definition pslgminsize.cpp:159
QVector< int > parent
union-find
Definition pslgminsize.cpp:176