|
KiCad PCB EDA Suite
|
Loads DRC rules from .kicad_dru files and converts them to panel entries. More...
#include <drc_re_rule_loader.h>
Public Member Functions | |
| DRC_RULE_LOADER () | |
| std::vector< DRC_RE_LOADED_PANEL_ENTRY > | LoadRule (const DRC_RULE &aRule, const wxString &aOriginalText) |
| Load a single DRC_RULE and convert it to panel entries. | |
| std::vector< DRC_RE_LOADED_PANEL_ENTRY > | LoadFile (const wxString &aPath) |
| Load all rules from a .kicad_dru file. | |
| std::vector< DRC_RE_LOADED_PANEL_ENTRY > | LoadFromString (const wxString &aRulesText) |
| Load rules from a text string. | |
Private Member Functions | |
| std::shared_ptr< DRC_RE_BASE_CONSTRAINT_DATA > | createConstraintData (DRC_RULE_EDITOR_CONSTRAINT_NAME aPanel, const DRC_RULE &aRule, const std::set< DRC_CONSTRAINT_T > &aClaimedConstraints) |
| Create the appropriate constraint data object for a panel type. | |
| const DRC_CONSTRAINT * | findConstraint (const DRC_RULE &aRule, DRC_CONSTRAINT_T aType) |
| Find a constraint of a specific type in a rule. | |
| double | toMM (int aValue) |
| Convert internal units (nanometers) to millimeters. | |
| wxString | extractRuleText (const wxString &aContent, const wxString &aRuleName) |
| Extract the complete original text of a rule from file content. | |
| wxString | extractRuleBody (const wxString &aOriginalText) |
| Extract the body of a rule from its original text, stripping the (rule "name" ...) wrapper. | |
| wxString | extractRuleComment (const wxString &aOriginalText) |
| Extract comment lines from a rule. | |
| wxString | cleanStrippedCondition (const wxString &aCondition) |
| Clean up a condition string after auto-generated tokens have been removed. | |
Private Attributes | |
| DRC_PANEL_MATCHER | m_matcher |
Loads DRC rules from .kicad_dru files and converts them to panel entries.
This class handles the conversion of text-based DRC rules into the appropriate graphical panel representations. Rules with multiple constraints may be split across multiple panel entries, with the condition and severity duplicated to each.
Definition at line 47 of file drc_re_rule_loader.h.
| DRC_RULE_LOADER::DRC_RULE_LOADER | ( | ) |
Definition at line 48 of file drc_re_rule_loader.cpp.
|
private |
Clean up a condition string after auto-generated tokens have been removed.
Strips empty parentheses, collapsed operators, and dangling leading/trailing operators.
Definition at line 118 of file drc_re_rule_loader.cpp.
Referenced by createConstraintData(), and LoadRule().
|
private |
Create the appropriate constraint data object for a panel type.
| aPanel | The target panel type. |
| aRule | The source rule. |
| aClaimedConstraints | The constraints this panel should handle. |
Definition at line 147 of file drc_re_rule_loader.cpp.
References ABSOLUTE_LENGTH, ALLOWED_ORIENTATION, ASSERTION_CONSTRAINT, BLIND, BURIED, cleanStrippedCondition(), DRC_RULE_EDITOR_UTILS::CreateNumericConstraintData(), CUSTOM_RULE, DIFF_PAIR_GAP_CONSTRAINT, DISALLOW_CONSTRAINT, DRC_DISALLOW_BLIND_VIAS, DRC_DISALLOW_BURIED_VIAS, DRC_DISALLOW_MICRO_VIAS, DRC_DISALLOW_THROUGH_VIAS, findConstraint(), DRC_RULE_EDITOR_UTILS::GetConstraintCode(), DRC_RULE_CONDITION::GetExpression(), DRC_CONSTRAINT::GetOption(), DRC_CONSTRAINT::GetValue(), HOLE_SIZE_CONSTRAINT, DRC_RULE_EDITOR_UTILS::IsNumericInputType(), LENGTH_CONSTRAINT, DRC_RULE::m_Condition, DRC_CONSTRAINT::m_DisallowFlags, DRC_RULE::m_Name, DRC_CONSTRAINT::m_Test, MATCHED_LENGTH_DIFF_PAIR, MINOPTMAX< T >::Max(), MAX_UNCOUPLED_CONSTRAINT, MICRO, MINOPTMAX< T >::Min(), MIN_RESOLVED_SPOKES_CONSTRAINT, MINIMUM_TEXT_HEIGHT_AND_THICKNESS, MINOPTMAX< T >::Opt(), PERMITTED_LAYERS, ROUTING_DIFF_PAIR, ROUTING_WIDTH, SKEW_CONSTRAINT, DRC_CONSTRAINT::SKEW_WITHIN_DIFF_PAIRS, TEXT_HEIGHT_CONSTRAINT, TEXT_THICKNESS_CONSTRAINT, THROUGH, toMM(), TRACK_WIDTH_CONSTRAINT, VIA_COUNT_CONSTRAINT, VIA_DIAMETER_CONSTRAINT, VIA_STYLE, and VIAS_UNDER_SMD.
Referenced by LoadRule().
|
private |
Extract the body of a rule from its original text, stripping the (rule "name" ...) wrapper.
Handles both quoted and unquoted rule names.
| aOriginalText | The full original text of a single rule. |
Definition at line 71 of file drc_re_rule_loader.cpp.
Referenced by LoadRule().
|
private |
Extract comment lines from a rule.
Comments are lines starting with # inside the rule block.
| aOriginalText | Rule text. |
Definition at line 92 of file drc_re_rule_loader.cpp.
Referenced by LoadRule().
|
private |
Extract the complete original text of a rule from file content.
| aContent | The full file content. |
| aRuleName | The name of the rule to extract. |
Definition at line 682 of file drc_re_rule_loader.cpp.
Referenced by LoadFromString().
|
private |
Find a constraint of a specific type in a rule.
| aRule | The rule to search. |
| aType | The constraint type to find. |
Definition at line 59 of file drc_re_rule_loader.cpp.
References DRC_RULE::m_Constraints, and DRC_CONSTRAINT::m_Type.
Referenced by createConstraintData(), and LoadRule().
| std::vector< DRC_RE_LOADED_PANEL_ENTRY > DRC_RULE_LOADER::LoadFile | ( | const wxString & | aPath | ) |
Load all rules from a .kicad_dru file.
| aPath | Path to the rules file. |
Definition at line 773 of file drc_re_rule_loader.cpp.
References LoadFromString().
Referenced by DIALOG_DRC_RULE_EDITOR::LoadExistingRules().
| std::vector< DRC_RE_LOADED_PANEL_ENTRY > DRC_RULE_LOADER::LoadFromString | ( | const wxString & | aRulesText | ) |
Load rules from a text string.
| aRulesText | The text content of the rules. |
Definition at line 647 of file drc_re_rule_loader.cpp.
References extractRuleText(), LoadRule(), and DRC_RULES_PARSER::Parse().
Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and LoadFile().
| std::vector< DRC_RE_LOADED_PANEL_ENTRY > DRC_RULE_LOADER::LoadRule | ( | const DRC_RULE & | aRule, |
| const wxString & | aOriginalText ) |
Load a single DRC_RULE and convert it to panel entries.
If the rule contains more constraints than a single panel can handle, it will be split into multiple entries, preserving order.
| aRule | The parsed DRC rule to convert. |
| aOriginalText | The original text of the rule for round-trip fidelity. |
Definition at line 469 of file drc_re_rule_loader.cpp.
References ALLOWED_ORIENTATION, ASSERTION_CONSTRAINT, B_SilkS, cleanStrippedCondition(), createConstraintData(), CUSTOM_RULE, extractRuleBody(), extractRuleComment(), F_SilkS, findConstraint(), DRC_RULE_CONDITION::GetExpression(), DRC_RE_LOADED_PANEL_ENTRY::layerSource, DRC_RULE::m_Condition, DRC_RULE::m_LayerCondition, DRC_RULE::m_LayerSource, m_matcher, DRC_RULE::m_Name, DRC_RULE::m_Severity, DRC_CONSTRAINT::m_Test, DRC_RE_LOADED_PANEL_ENTRY::originalRuleText, PERMITTED_LAYERS, SILK_CLEARANCE_CONSTRAINT, SILK_TO_SILK_CLEARANCE, SILK_TO_SOLDERMASK_CLEARANCE, VIA_STYLE, and VIAS_UNDER_SMD.
Referenced by LoadFromString().
|
private |
Convert internal units (nanometers) to millimeters.
Definition at line 53 of file drc_re_rule_loader.cpp.
Referenced by createConstraintData().
|
private |
Definition at line 142 of file drc_re_rule_loader.h.
Referenced by LoadRule().