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

Maps DRC rule constraints to appropriate editor panels. More...

#include <drc_re_panel_matcher.h>

Public Member Functions

 DRC_PANEL_MATCHER ()
 Panel Claim Priority System.
 
std::vector< DRC_PANEL_MATCHMatchRule (const DRC_RULE &aRule)
 Match a DRC rule to one or more panel types.
 
bool CanPanelLoad (DRC_RULE_EDITOR_CONSTRAINT_NAME aPanel, const std::set< DRC_CONSTRAINT_T > &aConstraints)
 Check if a specific panel type can load a set of constraints.
 
DRC_RULE_EDITOR_CONSTRAINT_NAME GetPanelForConstraint (DRC_CONSTRAINT_T aConstraintType)
 Get the panel type for a single constraint.
 

Private Member Functions

void initClaims ()
 
bool matchesClaim (const DRC_PANEL_CLAIM &aClaim, const std::set< DRC_CONSTRAINT_T > &aConstraints, std::set< DRC_CONSTRAINT_T > *aClaimedOut)
 

Private Attributes

std::vector< DRC_PANEL_CLAIMm_claims
 

Detailed Description

Maps DRC rule constraints to appropriate editor panels.

When loading a .kicad_dru file, this class determines which graphical panels should be used to edit each rule. Multi-constraint panels (like VIA_STYLE which handles both via_diameter and hole_size) have higher priority and are tried first.

If a rule contains more constraints than any single panel can handle, it will be split across multiple panels. Constraints that cannot be mapped to any panel are sent to the CUSTOM_RULE fallback panel.

Definition at line 89 of file drc_re_panel_matcher.h.

Constructor & Destructor Documentation

◆ DRC_PANEL_MATCHER()

DRC_PANEL_MATCHER::DRC_PANEL_MATCHER ( )

Panel Claim Priority System.

When a DRC rule contains multiple constraints, the matcher must decide which graphical panels should edit each constraint. The priority system ensures deterministic, user-friendly matching.

Priority tiers: 100 Multi-constraint panels that combine related constraints (e.g., ROUTING_DIFF_PAIR handles track_width + diff_pair_gap together) 80-90 Two-constraint panels (VIA_STYLE, TEXT_HEIGHT_THICKNESS) 60-70 Single-constraint panels with min/opt/max semantics 20-30 Generic single-constraint panels 5-15 Boolean and fallback panels 0 CUSTOM_RULE catches all unmapped constraints

Algorithm:

  1. Extract all constraint types from the rule
  2. Iterate through claims in priority order (highest first)
  3. For each claim, check if ALL required constraints are present
  4. If match found, claim those constraints and remove them from the pool
  5. Continue until all constraints are claimed
  6. Any remaining constraints go to CUSTOM_RULE fallback

Example: A rule with track_width + diff_pair_gap + clearance becomes

  • ROUTING_DIFF_PAIR panel (claims track_width + diff_pair_gap at priority 100)
  • MINIMUM_CLEARANCE panel (claims clearance at priority 30)

Definition at line 58 of file drc_re_panel_matcher.cpp.

References initClaims().

Member Function Documentation

◆ CanPanelLoad()

bool DRC_PANEL_MATCHER::CanPanelLoad ( DRC_RULE_EDITOR_CONSTRAINT_NAME aPanel,
const std::set< DRC_CONSTRAINT_T > & aConstraints )

Check if a specific panel type can load a set of constraints.

Parameters
aPanelThe panel type to check.
aConstraintsThe constraint types to check.
Returns
True if the panel can represent all given constraints.

Definition at line 320 of file drc_re_panel_matcher.cpp.

References CUSTOM_RULE, and m_claims.

Referenced by BOOST_AUTO_TEST_CASE().

◆ GetPanelForConstraint()

DRC_RULE_EDITOR_CONSTRAINT_NAME DRC_PANEL_MATCHER::GetPanelForConstraint ( DRC_CONSTRAINT_T aConstraintType)

Get the panel type for a single constraint.

This is a convenience method for simple rules with one constraint.

Parameters
aConstraintTypeThe DRC constraint type.
Returns
The recommended panel type, or CUSTOM_RULE if no match.

Definition at line 346 of file drc_re_panel_matcher.cpp.

References CUSTOM_RULE, and m_claims.

Referenced by BOOST_AUTO_TEST_CASE().

◆ initClaims()

◆ matchesClaim()

bool DRC_PANEL_MATCHER::matchesClaim ( const DRC_PANEL_CLAIM & aClaim,
const std::set< DRC_CONSTRAINT_T > & aConstraints,
std::set< DRC_CONSTRAINT_T > * aClaimedOut )
private

◆ MatchRule()

std::vector< DRC_PANEL_MATCH > DRC_PANEL_MATCHER::MatchRule ( const DRC_RULE & aRule)

Match a DRC rule to one or more panel types.

The rule's constraints are analyzed and matched to panels using a priority-based system. Multi-constraint panels are tried first. If a rule has more constraints than one panel can handle, multiple panel matches are returned.

Parameters
aRuleThe DRC rule to analyze.
Returns
Vector of panel matches, each claiming a subset of constraints.

Definition at line 278 of file drc_re_panel_matcher.cpp.

References CUSTOM_RULE, m_claims, DRC_RULE::m_Constraints, DRC_CONSTRAINT::m_Type, matchesClaim(), and NULL_CONSTRAINT.

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(), and BOOST_AUTO_TEST_CASE().

Member Data Documentation

◆ m_claims

std::vector<DRC_PANEL_CLAIM> DRC_PANEL_MATCHER::m_claims
private

Definition at line 134 of file drc_re_panel_matcher.h.

Referenced by CanPanelLoad(), GetPanelForConstraint(), initClaims(), and MatchRule().


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