40 if (swmm_heat_element_override_count(engine, &
count) != SWMM_OK)
46 if (swmm_heat_get_element_override(engine,
i, &
a, &
s,
id,
sizeof id, &
value) == SWMM_OK &&
47 a == attr &&
s ==
scope && QString::fromUtf8(
id) == name)
65 QUndoStack *stack,
const QString &description, QString *
error)
69 *
error = QObject::tr(
"The model was closed.");
72 const auto engine =
layer->engine();
73 QVector<HeatPropertyEdit>
changed;
74 for (
const auto &edit : edits) {
75 const QString
text = edit.value.toString().trimmed();
85 if ((
text.isEmpty() && !before.isValid()) ||
86 (!
text.isEmpty() && before.isValid() && before.toDouble() ==
value))
95 *
error = QObject::tr(
"Cannot snapshot heat settings before editing.");
101 const QVector<HeatPropertyEdit> *edits;
103 const int result = swmm_hydrothermal_edit_atomic(
106 auto &ctx = *
static_cast<Context *
>(ptr);
107 for (
const auto &edit : *ctx.edits) {
108 const auto name = edit.name.toUtf8();
109 const auto text = edit.value.toString().trimmed();
110 if (
text.isEmpty()) {
112 int rc = swmm_heat_element_override_count(ctx.engine, &
count);
115 for (
int i =
count - 1;
i >= 0; --
i) {
118 rc = swmm_heat_get_element_override(ctx.engine,
i, &
a, &
s,
id,
sizeof id,
122 if (
a == edit.attr &&
s == edit.scope &&
123 edit.name == QString::fromUtf8(
id)) {
124 rc = swmm_heat_remove_element_override(ctx.engine,
i);
130 const int rc = swmm_heat_set_element_override(
131 ctx.engine, edit.attr, edit.scope, name.constData(),
text.toDouble());
139 if (result != SWMM_OK) {
142 QObject::tr(
"Heat properties were refused (%1). Previous settings were restored.")
148 swmm_heat_snapshot_restore(engine, before.get());
150 *
error = QObject::tr(
"Cannot record the edit. Previous settings were restored.");
154 auto notify = [
model] {
157 emit
model->optionsChanged({
"HEAT_PROPERTIES"});
162 layer, engine, std::move(before), std::move(after), identity,
166 [](
const QString &why) {
167 QMessageBox::warning(
nullptr, QObject::tr(
"Heat properties"), why);
169 command->setText(description);
170 stack->push(command);
static QString configurationSignature(SWMM_Engine engine)
Serialize the saved heat configuration and selected model identities for stale-editor detection.
Definition heatconfigdialog.cpp:2352
Definition heatconfigurationundo.h:129
Renders the SWMM network elements (nodes, links, subcatchments, rain gages) for one OpenSWMMEngine mo...
Definition swmmmodellayer.h:137
size_t i
Definition contourjob.cpp:30
QPointer< QObject > context
Required provider lifetime guard.
Definition extensionattributes.cpp:31
std::function< void(bool)> changed
Guarded layer refresh callback.
Definition extensionattributes.cpp:36
ModelFacade * model
Definition extensionmodelaccess.cpp:625
Editor for the heat-transport configuration — [HEAT_SOURCES] inlet temperatures, [HEAT_FLUXES] module...
Undoable edits to heat, climate, snow, and component configuration.
Shared thermal attribute identifiers for tables and import mapping.
Persistent configuration of heat components and their owners.
bool ok
Definition importplanning.cpp:143
int scope
Definition initialbedqualitydialog.cpp:50
double s
Scene px per model length unit.
Definition inletdrawingview.cpp:95
int ensureHeatConfigurationFile(SWMM_Engine engine)
Ensure configured heat authoring has a registered persistent component asset name.
Definition hydrothermalconfiguration.h:28
Definition heatassignment.h:15
bool heatPropertyValueValid(int attr, double value)
Apply shared refuse-instead-of-clamp validation for thermal overrides.
Definition heatproperties.h:87
QString heatPropertyLabel(int attr)
Translate a thermal property's shared field caption.
Definition heatproperties.h:65
bool applyHeatPropertyEdits(SWMMModelLayer *layer, const QVector< HeatPropertyEdit > &edits, QUndoStack *stack, const QString &description, QString *error)
Validate and atomically apply explicit thermal overrides, register persistence and optionally retain ...
Definition heatpropertyedit.h:64
QVariant authoredHeatProperty(SWMM_Engine engine, int attr, int scope, const QString &name)
Find the first explicit thermal override matching attribute/scope/exact name.
Definition heatpropertyedit.h:37
std::unique_ptr< void, HeatSnapshotDeleter > HeatSnapshot
Definition heatconfigurationundo.h:30
void * SWMM_Engine
Definition objectdefaultsapplier.h:23
QString text
Definition queryparser.cpp:54
double value
Definition rasterfluxintegration.cpp:27
Definition heatpropertyedit.h:23
int attr
Definition heatpropertyedit.h:24
int scope
Definition heatpropertyedit.h:25
QVariant value
Definition heatpropertyedit.h:27
QString name
Definition heatpropertyedit.h:26
Map layer that renders an OpenSWMMEngine network (nodes, links, subcatchments, rain gages) and provid...
double a
Definition terrainerrorfield.cpp:42
double error
Definition terrainerrorfield.cpp:42
quint64 count
Definition terrainerrorfield.cpp:43
TraceAnalysisLayer * layer
Definition traceanalysislayer.cpp:162