mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-10-06 03:04:13 +02:00
Add a wires-per-terminal limit, with an application master switch
Discussion #1158: a real terminal takes one or two wires (four with double ferrules), a folio report is a virtual point that carries one, but QElectroTech lets any number of wires be connected anywhere. Project properties > General gets a "Conducteurs par borne" group: - the most wires a terminal may take (0, the default, is no limit); - "one wire per folio report". When set, a new wire that would go past the limit is refused: the terminal shows red while dragging, as for any refused link, and a tooltip says why on release. Auto-connect on placing, moving or multi-pasting a symbol skips full terminals, and qet.addConductor() refuses with its own message. Wires already drawn, opening, pasting and undo are never refused. Settings > General gets a master switch, on by default, that turns every rule of this feature off in every project; the project group is greyed with a note while it is off. The rules live in wiringrules.cpp. The project setting is saved as <wiring_rules .../> only when a rule is on, so a project that never used it saves exactly as before; an older version drops it, which means "off". tst_wiringrules covers the rules, the save round trip and, through the real binary, that a wire past the limit is refused unless the master switch is off (checked to fail with the limit check removed). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015FPuYPS4T7QuEwjNu22rXD
This commit is contained in:
@@ -1257,6 +1257,26 @@ void QETProject::setWireHops(WireHops::Mode mode)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@brief QETProject::wiringRules
|
||||
@return how many wires a terminal of this project may take
|
||||
(discussion #1158); the default when the project sets no rule.
|
||||
*/
|
||||
WiringRules::Settings QETProject::wiringRules() const {
|
||||
return m_wiring_rules;
|
||||
}
|
||||
|
||||
/**
|
||||
@brief QETProject::setWiringRules
|
||||
Set how many wires a terminal of this project may take. Only wires
|
||||
drawn from now on are affected: none already drawn is removed.
|
||||
@param rules
|
||||
*/
|
||||
void QETProject::setWiringRules(const WiringRules::Settings &rules)
|
||||
{
|
||||
m_wiring_rules = rules;
|
||||
}
|
||||
|
||||
/**
|
||||
@brief QETProject::autoBreakConductor
|
||||
@return true if use of auto break conductor is authorized.
|
||||
@@ -1367,6 +1387,7 @@ QDomDocument QETProject::toXml()
|
||||
// local, non-transmitted usage tracking (time spent on this project)
|
||||
writeUsageXml(project_root);
|
||||
writeWireHopsXml(project_root);
|
||||
writeWiringRulesXml(project_root);
|
||||
|
||||
// Properties for news diagrams
|
||||
QDomElement new_diagrams_properties = xml_doc.createElement("newdiagrams");
|
||||
@@ -1877,6 +1898,7 @@ void QETProject::readProjectXml(QDomDocument &xml_project)
|
||||
//Load the local, non-transmitted usage tracking
|
||||
readUsageXml(xml_project);
|
||||
readWireHopsXml(xml_project);
|
||||
readWiringRulesXml(xml_project);
|
||||
|
||||
//Load the default properties for the new diagrams
|
||||
readDefaultPropertiesXml(xml_project);
|
||||
@@ -2070,6 +2092,17 @@ void QETProject::readWireHopsXml(QDomDocument &xml_project)
|
||||
: WireHops::fromString(crossings.attribute(QStringLiteral("hop")));
|
||||
}
|
||||
|
||||
/**
|
||||
@brief QETProject::readWiringRulesXml
|
||||
Read the <wiring_rules> element of the project, if any.
|
||||
A project without it sets no rule.
|
||||
@param xml_project : the xml description of the project
|
||||
*/
|
||||
void QETProject::readWiringRulesXml(QDomDocument &xml_project)
|
||||
{
|
||||
m_wiring_rules = WiringRules::fromXml(xml_project.documentElement());
|
||||
}
|
||||
|
||||
/**
|
||||
@brief QETProject::readDefaultPropertiesXml
|
||||
load default properties for new diagram, found in the xml of this project
|
||||
@@ -2232,6 +2265,16 @@ void QETProject::writeWireHopsXml(QDomElement &xml_element)
|
||||
xml_element.appendChild(crossings);
|
||||
}
|
||||
|
||||
/**
|
||||
@brief QETProject::writeWiringRulesXml
|
||||
Export the project's wiring rules as a <wiring_rules> child of
|
||||
\a xml_element, only when one is set.
|
||||
*/
|
||||
void QETProject::writeWiringRulesXml(QDomElement &xml_element)
|
||||
{
|
||||
WiringRules::toXml(m_wiring_rules, xml_element);
|
||||
}
|
||||
|
||||
/**
|
||||
@brief QETProject::writeDefaultPropertiesXml
|
||||
Export all defaults properties used by a new diagram and his content
|
||||
|
||||
Reference in New Issue
Block a user