KiCad PCB EDA Suite
Loading...
Searching...
No Matches
DRC_RULE_LOADER Class Reference

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_ENTRYLoadRule (const DRC_RULE &aRule, const wxString &aOriginalText)
 Load a single DRC_RULE and convert it to panel entries.
 
std::vector< DRC_RE_LOADED_PANEL_ENTRYLoadFile (const wxString &aPath)
 Load all rules from a .kicad_dru file.
 
std::vector< DRC_RE_LOADED_PANEL_ENTRYLoadFromString (const wxString &aRulesText)
 Load rules from a text string.
 

Private Member Functions

std::shared_ptr< DRC_RE_BASE_CONSTRAINT_DATAcreateConstraintData (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_CONSTRAINTfindConstraint (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.
 

Private Attributes

DRC_PANEL_MATCHER m_matcher
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ DRC_RULE_LOADER()

DRC_RULE_LOADER::DRC_RULE_LOADER ( )

Definition at line 42 of file drc_re_rule_loader.cpp.

Member Function Documentation

◆ createConstraintData()

std::shared_ptr< DRC_RE_BASE_CONSTRAINT_DATA > DRC_RULE_LOADER::createConstraintData ( DRC_RULE_EDITOR_CONSTRAINT_NAME aPanel,
const DRC_RULE & aRule,
const std::set< DRC_CONSTRAINT_T > & aClaimedConstraints )
private

◆ findConstraint()

const DRC_CONSTRAINT * DRC_RULE_LOADER::findConstraint ( const DRC_RULE & aRule,
DRC_CONSTRAINT_T aType )
private

Find a constraint of a specific type in a rule.

Parameters
aRuleThe rule to search.
aTypeThe constraint type to find.
Returns
Pointer to the constraint, or nullptr if not found.

Definition at line 53 of file drc_re_rule_loader.cpp.

References DRC_RULE::m_Constraints, and DRC_CONSTRAINT::m_Type.

Referenced by createConstraintData().

◆ LoadFile()

std::vector< DRC_RE_LOADED_PANEL_ENTRY > DRC_RULE_LOADER::LoadFile ( const wxString & aPath)

Load all rules from a .kicad_dru file.

Parameters
aPathPath to the rules file.
Returns
Vector of panel entries for all rules in the file.

Definition at line 317 of file drc_re_rule_loader.cpp.

References LoadFromString().

Referenced by DIALOG_DRC_RULE_EDITOR::LoadExistingRules().

◆ LoadFromString()

◆ LoadRule()

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.

Parameters
aRuleThe parsed DRC rule to convert.
aOriginalTextThe original text of the rule for round-trip fidelity.
Returns
Vector of panel entries representing the rule.

Definition at line 231 of file drc_re_rule_loader.cpp.

References createConstraintData(), CUSTOM_RULE, DRC_RULE_CONDITION::GetExpression(), DRC_RULE::m_Condition, DRC_RULE::m_LayerCondition, m_matcher, DRC_RULE::m_Name, DRC_RULE::m_Severity, and DRC_RE_LOADED_PANEL_ENTRY::originalRuleText.

Referenced by LoadFromString().

◆ toMM()

double DRC_RULE_LOADER::toMM ( int aValue)
private

Convert internal units (nanometers) to millimeters.

Definition at line 47 of file drc_re_rule_loader.cpp.

Referenced by createConstraintData().

Member Data Documentation

◆ m_matcher

DRC_PANEL_MATCHER DRC_RULE_LOADER::m_matcher
private

Definition at line 109 of file drc_re_rule_loader.h.

Referenced by LoadRule().


The documentation for this class was generated from the following files: