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
SimulationOptionsDialog Class Reference

Edit OPTIONS for the active SWMM project. More...

#include <simulationoptionsdialog.h>

Inheritance diagram for SimulationOptionsDialog:
Collaboration diagram for SimulationOptionsDialog:

Public Member Functions

 SimulationOptionsDialog (SWMM_Engine engine, SWMMModelLayer *layer=nullptr, const QString &engineVersion=QStringLiteral("6.0.0"), SWMMVisProjectWindow *projectWindow=nullptr, QWidget *parent=nullptr)
 
 ~SimulationOptionsDialog () override=default
 
bool wroteAnyChanges () const
 True after a successful Apply / OK that wrote at least one key.
 
QStringList lastWriteKeys () const
 Every option key offered to writeIfChanged during the last write pass — whether or not the value actually changed.
 

Static Public Member Functions

static int parseEngineBool (const QString &s)
 Map an engine boolean string ("YES"/"NO"/"TRUE"/"FALSE"/"1"/"0") to a Qt::CheckState. Unknown values → Qt::PartiallyChecked.
 
static QString engineBoolString (bool on)
 Render a checkbox state as the canonical engine string.
 
static void fastPresetValues (int &out_threads, double &out_min_step_sec)
 Canonical "fast preset" recipe for 1D/2D-coupled runs: all worker threads on, and the adaptive routing step floored so the 2D coupling can't collapse it. Benchmarked ~4x faster with a ~4–5% peak-depth trade on the Bellinge model (see FAST_RUN_RECIPE.md). Kept as a static so the recipe values are locked by a unit test.
 
static int fastPresetThreads ()
 THREADS the fast preset uses: the machine's performance-core count (macOS), else its logical-CPU count, else 8.
 
static QString threadLimitsSummary (const SWMM_ThreadInfo &ti)
 Human-readable summary of the machine / OpenMP thread limits (from swmm_get_thread_info) for tooltips.
 
static void formatEngineDateTime (const QDateTime &dt, QString &out_date, QString &out_time)
 Format a Qt date+time as the engine's expected MM/DD/YYYY + HH:MM:SS pair (returned as out_date and out_time).
 
static QDateTime parseEngineDateTime (const QString &date, const QString &time)
 Inverse of formatEngineDateTime. Returns an invalid QDateTime if either string is malformed.
 
static double oaDateFromQDateTime (const QDateTime &dt)
 Convert a QDateTime to SWMM's OLE Automation Date (decimal days since 1899-12-30 00:00). Used by the [EVENTS] section editor to round-trip through the swmm_events_* C API which speaks OADate directly. Returns 0.0 for invalid input.
 
static QDateTime qDateTimeFromOaDate (double oa)
 Inverse of oaDateFromQDateTime.
 
static qint64 parseStepSeconds (const QString &s, qint64 fallback)
 Parse a step value as returned by swmm_options_get() into whole seconds. The engine round-trip is loose: a step comes back as plain seconds ("900"), decimal seconds ("900.000000" — the std::to_string(double) form used for REPORT_STEP / ROUTING_STEP) or as HH:MM:SS ("00:15:00", "48:00:00"). Returns fallback when s matches none of those.
 
static bool optionValueEquals (const QString &a, const QString &b)
 Compare an option value from swmm_options_get() against a freshly formatted one, tolerating formatting differences. The engine renders numerics as std::to_string(double) ("0.000000") while the dialog formats with 'f'/'g' variants ("0.00"), so a plain string compare treats every unchanged numeric as an edit. Exact string equality → true; else if both sides parse as doubles they compare with a relative tolerance; else false.
 
static QList< int > selectedRowsDescending (const QTableWidget *table)
 Distinct selected row indices of table, sorted descending (safe order for removeRow()). Reads the selection MODEL first — the [EVENTS] table populates cells exclusively with setCellWidget() editors, so item-based queries like selectedItems() see an always-empty selection — then falls back to selectedItems() for plain cell selections.
 

Detailed Description

Edit OPTIONS for the active SWMM project.

Round-trip layout:

  • On construction: read every option from the engine via swmm_options_get and populate the controls.
  • On Apply / OK: diff against the last-read snapshot and write only changed keys via swmm_options_set. Marks the project dirty if any key was written.
  • On Cancel: discard pending edits.

Constructor & Destructor Documentation

◆ SimulationOptionsDialog()

SimulationOptionsDialog::SimulationOptionsDialog ( SWMM_Engine  engine,
SWMMModelLayer layer = nullptr,
const QString &  engineVersion = QStringLiteral("6.0.0"),
SWMMVisProjectWindow projectWindow = nullptr,
QWidget *  parent = nullptr 
)
explicit
Parameters
engineOpen SWMM engine handle (required).
layerOptional model layer — gives Tab 5 access to the layer CRS + extent for the Detect from coordinates helper and the read-only extent summary.
engineVersionVersion string of the engine that will run the simulation (e.g. "6.0.0" or "5.2.4"). Controls which tabs and controls are enabled — options that the selected engine does not support are disabled with an explanatory tooltip.
projectWindowOptional MDI window — provides .oswp-persisted rich HTML notes for the new "Title/Notes" tab. When omitted, the tab still works but only round-trips plain text through the engine.
parentQt parent.
Here is the call graph for this function:

◆ ~SimulationOptionsDialog()

SimulationOptionsDialog::~SimulationOptionsDialog ( )
overridedefault

Member Function Documentation

◆ engineBoolString()

QString SimulationOptionsDialog::engineBoolString ( bool  on)
static

Render a checkbox state as the canonical engine string.

Here is the caller graph for this function:

◆ fastPresetThreads()

int SimulationOptionsDialog::fastPresetThreads ( )
static

THREADS the fast preset uses: the machine's performance-core count (macOS), else its logical-CPU count, else 8.

Here is the caller graph for this function:

◆ fastPresetValues()

void SimulationOptionsDialog::fastPresetValues ( int &  out_threads,
double out_min_step_sec 
)
static

Canonical "fast preset" recipe for 1D/2D-coupled runs: all worker threads on, and the adaptive routing step floored so the 2D coupling can't collapse it. Benchmarked ~4x faster with a ~4–5% peak-depth trade on the Bellinge model (see FAST_RUN_RECIPE.md). Kept as a static so the recipe values are locked by a unit test.

Here is the call graph for this function:

◆ formatEngineDateTime()

void SimulationOptionsDialog::formatEngineDateTime ( const QDateTime &  dt,
QString &  out_date,
QString &  out_time 
)
static

Format a Qt date+time as the engine's expected MM/DD/YYYY + HH:MM:SS pair (returned as out_date and out_time).

◆ lastWriteKeys()

QStringList SimulationOptionsDialog::lastWriteKeys ( ) const

Every option key offered to writeIfChanged during the last write pass — whether or not the value actually changed.

The reachability seam for the dialog restructure (OPTIONS_DIALOG_TABBED_RESTRUCTURE_PLAN_2026-09-07.md §6 test 6): a key recorded here with no widget carrying a matching optionKey property means some editor was orphaned by a page move. Every page writes through the shared context, so the record lives in one place.

◆ oaDateFromQDateTime()

double SimulationOptionsDialog::oaDateFromQDateTime ( const QDateTime &  dt)
static

Convert a QDateTime to SWMM's OLE Automation Date (decimal days since 1899-12-30 00:00). Used by the [EVENTS] section editor to round-trip through the swmm_events_* C API which speaks OADate directly. Returns 0.0 for invalid input.

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

◆ optionValueEquals()

bool SimulationOptionsDialog::optionValueEquals ( const QString &  a,
const QString &  b 
)
static

Compare an option value from swmm_options_get() against a freshly formatted one, tolerating formatting differences. The engine renders numerics as std::to_string(double) ("0.000000") while the dialog formats with 'f'/'g' variants ("0.00"), so a plain string compare treats every unchanged numeric as an edit. Exact string equality → true; else if both sides parse as doubles they compare with a relative tolerance; else false.

Here is the caller graph for this function:

◆ parseEngineBool()

int SimulationOptionsDialog::parseEngineBool ( const QString &  s)
static

Map an engine boolean string ("YES"/"NO"/"TRUE"/"FALSE"/"1"/"0") to a Qt::CheckState. Unknown values → Qt::PartiallyChecked.

Here is the caller graph for this function:

◆ parseEngineDateTime()

QDateTime SimulationOptionsDialog::parseEngineDateTime ( const QString &  date,
const QString &  time 
)
static

Inverse of formatEngineDateTime. Returns an invalid QDateTime if either string is malformed.

Here is the caller graph for this function:

◆ parseStepSeconds()

qint64 SimulationOptionsDialog::parseStepSeconds ( const QString &  s,
qint64  fallback 
)
static

Parse a step value as returned by swmm_options_get() into whole seconds. The engine round-trip is loose: a step comes back as plain seconds ("900"), decimal seconds ("900.000000" — the std::to_string(double) form used for REPORT_STEP / ROUTING_STEP) or as HH:MM:SS ("00:15:00", "48:00:00"). Returns fallback when s matches none of those.

◆ qDateTimeFromOaDate()

QDateTime SimulationOptionsDialog::qDateTimeFromOaDate ( double  oa)
static

Inverse of oaDateFromQDateTime.

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

◆ selectedRowsDescending()

QList< int > SimulationOptionsDialog::selectedRowsDescending ( const QTableWidget *  table)
static

Distinct selected row indices of table, sorted descending (safe order for removeRow()). Reads the selection MODEL first — the [EVENTS] table populates cells exclusively with setCellWidget() editors, so item-based queries like selectedItems() see an always-empty selection — then falls back to selectedItems() for plain cell selections.

◆ threadLimitsSummary()

QString SimulationOptionsDialog::threadLimitsSummary ( const SWMM_ThreadInfo &  ti)
static

Human-readable summary of the machine / OpenMP thread limits (from swmm_get_thread_info) for tooltips.

◆ wroteAnyChanges()

bool SimulationOptionsDialog::wroteAnyChanges ( ) const
inline

True after a successful Apply / OK that wrote at least one key.


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