Merge pull request #1456 from Kellermorph/terminal-potential

Terminal: rename potential separation to function separation
This commit is contained in:
ispyisail
2026-10-14 18:26:00 +13:00
committed by GitHub
15 changed files with 437 additions and 36 deletions
+29 -2
View File
@@ -1189,6 +1189,10 @@ QString QetScriptApi::conductorProperty(int folioIndex, const QString &elementUu
describes a potential and not one drawn segment. Setting it on one
conductor and leaving the rest of the potential disagreeing would
produce a file no GUI action could have produced.
One thing stops at a terminal element with its function separation
enabled: every property but the voltage / protocol, which still
crosses it (@see Conductor::functionSeparatedConductors).
@return true if anything was changed, or if it already held that value
*/
bool QetScriptApi::setConductorProperty(int folioIndex, const QString &elementUuid,
@@ -1209,13 +1213,17 @@ bool QetScriptApi::setConductorProperty(int folioIndex, const QString &elementUu
Conductor *conductor = findConductor(folioIndex, elementUuid, terminalIndex, caller);
if (!conductor) return false;
ConductorProperties properties = conductor->properties();
//Captured before the pushes below: QPropertyUndoCommand applies on
//push, so reading the properties afterwards would already give back
//@a properties.
const ConductorProperties before = conductor->properties();
ConductorProperties properties = before;
if (!setConductorPropertyValue(properties, property, value)) {
log(QStringLiteral("qet.%1: '%2' is not a valid value for %3")
.arg(caller, value, property));
return false;
}
if (properties == conductor->properties()) return true; // already so
if (properties == before) return true; // already so
QSet<Conductor *> potential = conductor->relatedPotentialConductors(true);
potential << conductor;
@@ -1227,6 +1235,25 @@ bool QetScriptApi::setConductorProperty(int folioIndex, const QString &elementUu
old_value.setValue(c->properties());
new_value.setValue(properties);
m_project->undoStack()->push(new QPropertyUndoCommand(c, "properties", old_value, new_value));
}
//The other side of a function separated terminal element gets the
//voltage / protocol only: it is the one property that still
//describes the electrical node rather than one side of it. And it
//only arrives when this call really changed it -- before / after
//is the edit, not the far wire's own value, which differs from it
//just as often as not and would then be overwritten by every call,
//colour included.
for (Conductor *c : conductor->functionSeparatedConductors(true))
{
ConductorProperties separated_properties = c->properties();
separated_properties.applyTensionProtocolChange(before, properties);
if (separated_properties == c->properties())
continue;
QVariant old_value, new_value;
old_value.setValue(c->properties());
new_value.setValue(separated_properties);
m_project->undoStack()->push(new QPropertyUndoCommand(c, "properties", old_value, new_value));
}
m_project->undoStack()->endMacro();
return true;