49 return aValue / 1000000.0;
57 if( constraint.
m_Type == aType )
65std::shared_ptr<DRC_RE_BASE_CONSTRAINT_DATA>
68 const std::set<DRC_CONSTRAINT_T>& aClaimedConstraints )
74 auto data = std::make_shared<DRC_RE_VIA_STYLE_CONSTRAINT_DATA>();
75 data->SetRuleName( aRule.
m_Name );
76 data->SetConstraintCode(
"via_style" );
100 auto data = std::make_shared<DRC_RE_ROUTING_DIFF_PAIR_CONSTRAINT_DATA>();
101 data->SetRuleName( aRule.
m_Name );
102 data->SetConstraintCode(
"diff_pair_gap" );
132 auto data = std::make_shared<DRC_RE_MINIMUM_TEXT_HEIGHT_THICKNESS_CONSTRAINT_DATA>();
133 data->SetRuleName( aRule.
m_Name );
134 data->SetConstraintCode(
"text_height" );
150 auto data = std::make_shared<DRC_RE_ROUTING_WIDTH_CONSTRAINT_DATA>();
151 data->SetRuleName( aRule.
m_Name );
152 data->SetConstraintCode(
"track_width" );
159 data->SetPreferredRoutingWidth(
toMM( trackWidth->
GetValue().
Opt() ) );
168 auto data = std::make_shared<DRC_RE_ABSOLUTE_LENGTH_TWO_CONSTRAINT_DATA>();
169 data->SetRuleName( aRule.
m_Name );
170 data->SetConstraintCode(
"length" );
186 auto data = std::make_shared<DRC_RE_CUSTOM_RULE_CONSTRAINT_DATA>();
187 data->SetRuleName( aRule.
m_Name );
196 auto data = std::make_shared<DRC_RE_NUMERIC_INPUT_CONSTRAINT_DATA>();
197 data->SetRuleName( aRule.
m_Name );
200 data->SetConstraintCode( code );
223 auto data = std::make_shared<DRC_RE_CUSTOM_RULE_CONSTRAINT_DATA>();
224 data->SetRuleName( aRule.
m_Name );
232 const wxString& aOriginalText )
234 std::vector<DRC_RE_LOADED_PANEL_ENTRY> entries;
243 std::vector<DRC_PANEL_MATCH> matches =
m_matcher.MatchRule( aRule );
251 constraintData->SetRuleCondition( condition );
257 if( entries.empty() )
260 entries.push_back( std::move( entry ) );
265 if( entries.empty() )
267 auto customData = std::make_shared<DRC_RE_CUSTOM_RULE_CONSTRAINT_DATA>();
268 customData->SetRuleName( aRule.
m_Name );
269 customData->SetRuleCondition( condition );
270 customData->SetRuleText( aOriginalText );
275 entries.push_back( std::move( entry ) );
284 std::vector<DRC_RE_LOADED_PANEL_ENTRY> allEntries;
285 std::vector<std::shared_ptr<DRC_RULE>> parsedRules;
287 wxString rulesText = aRulesText;
289 if( !rulesText.Contains(
"(version" ) )
290 rulesText.Prepend(
"(version 1)\n" );
295 parser.
Parse( parsedRules,
nullptr );
302 for(
const auto& rule : parsedRules )
305 wxString originalText = wxString::Format(
"(rule \"%s\" ...)", rule->m_Name );
307 std::vector<DRC_RE_LOADED_PANEL_ENTRY> ruleEntries =
LoadRule( *rule, originalText );
309 for(
auto& entry : ruleEntries )
310 allEntries.push_back( std::move( entry ) );
319 std::vector<DRC_RE_LOADED_PANEL_ENTRY> allEntries;
321 wxFFile file( aPath,
"r" );
323 if( !file.IsOpened() )
327 file.ReadAll( &content );
const MINOPTMAX< int > & GetValue() const
void Parse(std::vector< std::shared_ptr< DRC_RULE > > &aRules, REPORTER *aReporter)
wxString GetExpression() const
static bool IsNumericInputType(const DRC_RULE_EDITOR_CONSTRAINT_NAME &aConstraintType)
static wxString GetConstraintCode(DRC_RULE_EDITOR_CONSTRAINT_NAME aConstraintType)
Translate a rule tree node type into the keyword used by the rules file for that constraint.
double toMM(int aValue)
Convert internal units (nanometers) to millimeters.
DRC_PANEL_MATCHER m_matcher
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 > LoadFromString(const wxString &aRulesText)
Load rules from a text string.
const DRC_CONSTRAINT * findConstraint(const DRC_RULE &aRule, DRC_CONSTRAINT_T aType)
Find a constraint of a specific type in a rule.
std::vector< DRC_RE_LOADED_PANEL_ENTRY > LoadFile(const wxString &aPath)
Load all rules from a .kicad_dru file.
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.
DRC_RULE_CONDITION * m_Condition
std::vector< DRC_CONSTRAINT > m_Constraints
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
@ VIA_DIAMETER_CONSTRAINT
@ DIFF_PAIR_GAP_CONSTRAINT
@ TEXT_THICKNESS_CONSTRAINT
@ MAX_UNCOUPLED_CONSTRAINT
DRC_RULE_EDITOR_CONSTRAINT_NAME
@ MINIMUM_TEXT_HEIGHT_AND_THICKNESS
Result of matching a panel to constraints.
Represents a rule loaded from a .kicad_dru file and mapped to a panel.
wxString originalRuleText