mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-10-14 17:44:13 +02:00
Terminal: pass the voltage across a separation only when it was edited
The three code paths that copied the voltage / protocol to the far side of a function separated terminal -- the conductor properties dialog, search/replace and the script API -- compared it against the far wire's own properties instead of against the edit itself. The two sides differ on that field just as often as not, so the comparison held no matter what was edited and every change overwrote the far side's voltage: setting a colour on a 24 V side dragged the 0 V one along, where master left it alone. Compare the edit -- what the dialog was filled with against what the user made of it -- so that a change of the voltage / protocol is what crosses, which is what the selection panel multi-edit already did. The values are read before the undo commands are pushed, since QPropertyUndoCommand applies on push. An explicitly selected wire is never the far side of anything: picking one wire on each side of a separation and editing them edits them both, in full, however the selection happens to be walked. Nor is a wire that belongs to a potential on any path, so reaching it once normally and once across a separation gives it the full edit.
This commit is contained in:
@@ -1211,13 +1211,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;
|
||||
@@ -1232,11 +1236,15 @@ bool QetScriptApi::setConductorProperty(int folioIndex, const QString &elementUu
|
||||
}
|
||||
//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.
|
||||
//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(c->properties(), properties);
|
||||
separated_properties.applyTensionProtocolChange(before, properties);
|
||||
if (separated_properties == c->properties())
|
||||
continue;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user