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
openswmmvis::pattern::PatternProvider Class Reference

#include <patternprovider.h>

Inheritance diagram for openswmmvis::pattern::PatternProvider:
Collaboration diagram for openswmmvis::pattern::PatternProvider:

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.
 

Constructor & Destructor Documentation

◆ PatternProvider()

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).

◆ ~PatternProvider()

openswmmvis::pattern::PatternProvider::~PatternProvider ( )
overridedefault

Member Function Documentation

◆ factor()

double openswmmvis::pattern::PatternProvider::factor ( int  i) const
inline

Read a single factor by index. Caller must ensure 0 ≤ i < factorCount().

◆ factorChanged

void openswmmvis::pattern::PatternProvider::factorChanged ( int  i)
signal

One factor at index i had its value changed.

Here is the caller graph for this function:

◆ factorCount()

int openswmmvis::pattern::PatternProvider::factorCount ( ) const
inlinenoexcept

Convenience: factorCountFor(type()).

Here is the call graph for this function:

◆ factorCountFor()

int openswmmvis::pattern::PatternProvider::factorCountFor ( PatternType  t)
staticnoexcept

How many factors does this type need? Static helper.

Here is the caller graph for this function:

◆ factors()

const QVector< double > & openswmmvis::pattern::PatternProvider::factors ( ) const
inlinenoexcept

All factors (const ref). Size is always factorCount().

Here is the caller graph for this function:

◆ factorsChanged

void openswmmvis::pattern::PatternProvider::factorsChanged ( )
signal

All factors were replaced (setAllFactors / setType / normalize). Subscribers re-read the whole array.

Here is the caller graph for this function:

◆ mutationRejected

void openswmmvis::pattern::PatternProvider::mutationRejected ( QString  reason)
signal

A mutator was refused because it would have violated an invariant. Surfaced to UI so the status bar can show the offending state.

Here is the caller graph for this function:

◆ name()

QString openswmmvis::pattern::PatternProvider::name ( ) const
inlinenoexcept

Pattern ID. Uniqueness within a project is owned by the registry.

Here is the caller graph for this function:

◆ nameChanged

void openswmmvis::pattern::PatternProvider::nameChanged ( QString  prev,
QString  now 
)
signal

Pattern was renamed; dependent-reference cascading is the registry's job (subscribers should not rewrite refs from this signal).

Here is the caller graph for this function:

◆ normalize()

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.

Here is the call graph for this function:

◆ rowLabel()

QString openswmmvis::pattern::PatternProvider::rowLabel ( PatternType  t,
int  i 
)
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.

Here is the caller graph for this function:

◆ setAllFactors()

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.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setFactor()

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.

Here is the call graph for this function:

◆ setFactorLive()

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).

Here is the call graph for this function:

◆ setName()

void openswmmvis::pattern::PatternProvider::setName ( QString  newName)

Rename the pattern. Uniqueness is the registry's responsibility; this just stores + notifies.

Here is the call graph for this function:

◆ setType()

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.

Here is the call graph for this function:

◆ sumOfFactors()

double openswmmvis::pattern::PatternProvider::sumOfFactors ( ) const
noexcept

Sum of all factors. Used by the UI status strip + normalize.

Here is the caller graph for this function:

◆ swapFactors()

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.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ type()

PatternType openswmmvis::pattern::PatternProvider::type ( ) const
inlinenoexcept

Pattern shape (Monthly / Daily / Hourly / Weekend).

◆ typeChanged

void openswmmvis::pattern::PatternProvider::typeChanged ( PatternType  prev,
PatternType  now 
)
signal

Pattern type changed (factors reset to 1.0).

Here is the caller graph for this function:

The documentation for this class was generated from the following files: