KiCad PCB EDA Suite
DRC_ENGINE Class Reference

Design Rule Checker object that performs all the DRC tests. More...

#include <drc_engine.h>

Inheritance diagram for DRC_ENGINE:
UNITS_PROVIDER

Classes

struct  DRC_ENGINE_CONSTRAINT
 

Public Member Functions

 DRC_ENGINE (BOARD *aBoard=nullptr, BOARD_DESIGN_SETTINGS *aSettings=nullptr)
 
 ~DRC_ENGINE ()
 
void SetBoard (BOARD *aBoard)
 
BOARDGetBoard () const
 
void SetDesignSettings (BOARD_DESIGN_SETTINGS *aSettings)
 
BOARD_DESIGN_SETTINGSGetDesignSettings () const
 
void SetSchematicNetlist (NETLIST *aNetlist)
 
NETLISTGetSchematicNetlist () const
 
void SetDrawingSheet (DS_PROXY_VIEW_ITEM *aDrawingSheet)
 
DS_PROXY_VIEW_ITEMGetDrawingSheet () const
 
void SetDebugOverlay (std::shared_ptr< KIGFX::VIEW_OVERLAY > aOverlay)
 
std::shared_ptr< KIGFX::VIEW_OVERLAYGetDebugOverlay () const
 
void SetViolationHandler (DRC_VIOLATION_HANDLER aHandler)
 Set an optional DRC violation handler (receives DRC_ITEMs and positions). More...
 
void ClearViolationHandler ()
 
void SetProgressReporter (PROGRESS_REPORTER *aProgRep)
 Set an optional reporter for user-level progress info. More...
 
PROGRESS_REPORTERGetProgressReporter () const
 
void SetLogReporter (REPORTER *aReporter)
 
void InitEngine (const wxFileName &aRulePath)
 Initialize the DRC engine. More...
 
void RunTests (EDA_UNITS aUnits, bool aReportAllTrackErrors, bool aTestFootprints)
 Run the DRC tests. More...
 
bool IsErrorLimitExceeded (int error_code)
 
DRC_CONSTRAINT EvalRules (DRC_CONSTRAINT_T aConstraintType, const BOARD_ITEM *a, const BOARD_ITEM *b, PCB_LAYER_ID aLayer, REPORTER *aReporter=nullptr)
 
DRC_CONSTRAINT EvalZoneConnection (const BOARD_ITEM *a, const BOARD_ITEM *b, PCB_LAYER_ID aLayer, REPORTER *aReporter=nullptr)
 
void ProcessAssertions (const BOARD_ITEM *a, std::function< void(const DRC_CONSTRAINT *)> aFailureHandler, REPORTER *aReporter=nullptr)
 
bool HasRulesForConstraintType (DRC_CONSTRAINT_T constraintID)
 
bool GetReportAllTrackErrors () const
 
bool GetTestFootprints () const
 
bool RulesValid ()
 
void ReportViolation (const std::shared_ptr< DRC_ITEM > &aItem, const VECTOR2I &aPos, int aMarkerLayer)
 
bool KeepRefreshing (bool aWait=false)
 
void AdvanceProgress ()
 
void SetMaxProgress (int aSize)
 
bool ReportProgress (double aProgress)
 
bool ReportPhase (const wxString &aMessage)
 
void ReportAux (const wxString &aStr)
 
bool IsCancelled () const
 
bool QueryWorstConstraint (DRC_CONSTRAINT_T aRuleId, DRC_CONSTRAINT &aConstraint)
 
std::set< int > QueryDistinctConstraints (DRC_CONSTRAINT_T aConstraintId)
 
std::vector< DRC_TEST_PROVIDER * > GetTestProviders () const
 
DRC_TEST_PROVIDERGetTestProvider (const wxString &name) const
 
EDA_UNITS GetUserUnits () const
 
void SetUserUnits (EDA_UNITS aUnits)
 
const EDA_IU_SCALEGetIuScale () const
 
wxString StringFromValue (double aValue, bool aAddUnitLabel=false, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
 Converts aValue in internal units into a united string. More...
 
wxString StringFromValue (const EDA_ANGLE &aValue, bool aAddUnitLabel=false)
 
wxString MessageTextFromValue (double aValue, bool aAddUnitLabel=true, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
 A lower-precision version of StringFromValue(). More...
 
wxString MessageTextFromValue (const EDA_ANGLE &aValue, bool aAddUnitLabel=true)
 
long long int ValueFromString (const wxString &aTextValue, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
 Converts aTextValue in aUnits to internal units used by the frame. More...
 

Static Public Member Functions

static bool IsNetADiffPair (BOARD *aBoard, NETINFO_ITEM *aNet, int &aNetP, int &aNetN)
 
static int MatchDpSuffix (const wxString &aNetName, wxString &aComplementNet, wxString &aBaseDpName)
 Check if the given net is a diff pair, returning its polarity and complement if so. More...
 
static bool IsNetTieExclusion (int aTrackNetCode, PCB_LAYER_ID aTrackLayer, const VECTOR2I &aCollisionPos, BOARD_ITEM *aCollidingItem)
 Check if the given collision between a track and another item occurs during the track's entry into a net-tie pad. More...
 

Protected Attributes

BOARD_DESIGN_SETTINGSm_designSettings
 
BOARDm_board
 
DS_PROXY_VIEW_ITEMm_drawingSheet
 
NETLISTm_schematicNetlist
 
std::vector< std::shared_ptr< DRC_RULE > > m_rules
 
bool m_rulesValid
 
std::vector< DRC_TEST_PROVIDER * > m_testProviders
 
std::vector< int > m_errorLimits
 
bool m_reportAllTrackErrors
 
bool m_testFootprints
 
std::map< DRC_CONSTRAINT_T, std::vector< DRC_ENGINE_CONSTRAINT * > * > m_constraintMap
 
DRC_VIOLATION_HANDLER m_violationHandler
 
REPORTERm_reporter
 
PROGRESS_REPORTERm_progressReporter
 
std::shared_ptr< KIGFX::VIEW_OVERLAYm_debugOverlay
 

Private Member Functions

void addRule (std::shared_ptr< DRC_RULE > &rule)
 
void loadRules (const wxFileName &aPath)
 Load and parse a rule set from an sexpr text file. More...
 
void compileRules ()
 
void loadImplicitRules ()
 
std::shared_ptr< DRC_RULEcreateImplicitRule (const wxString &name)
 

Private Attributes

const EDA_IU_SCALEm_iuScale
 
EDA_UNITS m_userUnits
 

Detailed Description

Design Rule Checker object that performs all the DRC tests.

Optionally reports violations via a DRC_VIOLATION_HANDLER, user-level progress via a PROGRESS_REPORTER and rule parse errors via a REPORTER, all set through various setter calls.

Note that EvalRules() has yet another optional REPORTER for reporting resolution info to the user.

Definition at line 82 of file drc_engine.h.

Constructor & Destructor Documentation

◆ DRC_ENGINE()

DRC_ENGINE::DRC_ENGINE ( BOARD aBoard = nullptr,
BOARD_DESIGN_SETTINGS aSettings = nullptr 
)

Definition at line 66 of file drc_engine.cpp.

66 :
68 m_designSettings ( aSettings ),
69 m_board( aBoard ),
70 m_drawingSheet( nullptr ),
71 m_schematicNetlist( nullptr ),
72 m_rulesValid( false ),
74 m_testFootprints( false ),
75 m_reporter( nullptr ),
76 m_progressReporter( nullptr )
77{
78 m_errorLimits.resize( DRCE_LAST + 1 );
79
80 for( int ii = DRCE_FIRST; ii <= DRCE_LAST; ++ii )
82}
constexpr EDA_IU_SCALE pcbIUScale
Definition: base_units.h:109
REPORTER * m_reporter
Definition: drc_engine.h:248
bool m_testFootprints
Definition: drc_engine.h:242
PROGRESS_REPORTER * m_progressReporter
Definition: drc_engine.h:249
DS_PROXY_VIEW_ITEM * m_drawingSheet
Definition: drc_engine.h:233
NETLIST * m_schematicNetlist
Definition: drc_engine.h:234
BOARD * m_board
Definition: drc_engine.h:232
bool m_reportAllTrackErrors
Definition: drc_engine.h:241
std::vector< int > m_errorLimits
Definition: drc_engine.h:240
bool m_rulesValid
Definition: drc_engine.h:237
BOARD_DESIGN_SETTINGS * m_designSettings
Definition: drc_engine.h:231
UNITS_PROVIDER(const EDA_IU_SCALE &aIuScale, EDA_UNITS aUnits)
#define ERROR_LIMIT
Definition: drc_engine.cpp:48
@ DRCE_FIRST
Definition: drc_item.h:38
@ DRCE_LAST
Definition: drc_item.h:101

References DRCE_FIRST, DRCE_LAST, ERROR_LIMIT, m_errorLimits, and MILLIMETRES.

◆ ~DRC_ENGINE()

DRC_ENGINE::~DRC_ENGINE ( )

Definition at line 85 of file drc_engine.cpp.

86{
87 m_rules.clear();
88
89 for( std::pair<DRC_CONSTRAINT_T, std::vector<DRC_ENGINE_CONSTRAINT*>*> pair : m_constraintMap )
90 {
91 for( DRC_ENGINE_CONSTRAINT* constraint : *pair.second )
92 delete constraint;
93
94 delete pair.second;
95 }
96}
std::map< DRC_CONSTRAINT_T, std::vector< DRC_ENGINE_CONSTRAINT * > * > m_constraintMap
Definition: drc_engine.h:245
std::vector< std::shared_ptr< DRC_RULE > > m_rules
Definition: drc_engine.h:236
DRC_CONSTRAINT_T
Definition: drc_rule.h:44

References m_constraintMap, and m_rules.

Member Function Documentation

◆ addRule()

void DRC_ENGINE::addRule ( std::shared_ptr< DRC_RULE > &  rule)
inlineprivate

Definition at line 205 of file drc_engine.h.

206 {
207 m_rules.push_back(rule);
208 }

References m_rules.

Referenced by createImplicitRule(), and loadImplicitRules().

◆ AdvanceProgress()

void DRC_ENGINE::AdvanceProgress ( )

Definition at line 1593 of file drc_engine.cpp.

1594{
1595 if( m_progressReporter )
1597}
virtual void AdvanceProgress()=0
Increment the progress bar length (inside the current virtual zone).

References PROGRESS_REPORTER::AdvanceProgress(), and m_progressReporter.

◆ ClearViolationHandler()

void DRC_ENGINE::ClearViolationHandler ( )
inline

Definition at line 115 of file drc_engine.h.

116 {
118 }
DRC_VIOLATION_HANDLER m_violationHandler
Definition: drc_engine.h:247
std::function< void(const std::shared_ptr< DRC_ITEM > &aItem, const VECTOR2I &aPos, int aLayer)> DRC_VIOLATION_HANDLER
Definition: drc_engine.h:69

References m_violationHandler.

◆ compileRules()

void DRC_ENGINE::compileRules ( )
private

Definition at line 481 of file drc_engine.cpp.

482{
483 ReportAux( wxString::Format( wxT( "Compiling Rules (%d rules): " ), (int) m_rules.size() ) );
484
485 for( std::shared_ptr<DRC_RULE>& rule : m_rules )
486 {
487 DRC_RULE_CONDITION* condition = nullptr;
488
489 if( rule->m_Condition && !rule->m_Condition->GetExpression().IsEmpty() )
490 {
491 condition = rule->m_Condition;
492 condition->Compile( nullptr );
493 }
494
495 for( const DRC_CONSTRAINT& constraint : rule->m_Constraints )
496 {
497 if( !m_constraintMap.count( constraint.m_Type ) )
498 m_constraintMap[ constraint.m_Type ] = new std::vector<DRC_ENGINE_CONSTRAINT*>();
499
500 DRC_ENGINE_CONSTRAINT* engineConstraint = new DRC_ENGINE_CONSTRAINT;
501
502 engineConstraint->layerTest = rule->m_LayerCondition;
503 engineConstraint->condition = condition;
504 engineConstraint->constraint = constraint;
505 engineConstraint->parentRule = rule;
506 m_constraintMap[ constraint.m_Type ]->push_back( engineConstraint );
507 }
508 }
509}
DRC_CONSTRAINT_T m_Type
Definition: drc_rule.h:169
void ReportAux(const wxString &aStr)
bool Compile(REPORTER *aReporter, int aSourceLine=0, int aSourceOffset=0)
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200

References DRC_RULE_CONDITION::Compile(), DRC_ENGINE::DRC_ENGINE_CONSTRAINT::condition, DRC_ENGINE::DRC_ENGINE_CONSTRAINT::constraint, Format(), DRC_ENGINE::DRC_ENGINE_CONSTRAINT::layerTest, m_constraintMap, m_rules, DRC_CONSTRAINT::m_Type, DRC_ENGINE::DRC_ENGINE_CONSTRAINT::parentRule, and ReportAux().

Referenced by InitEngine().

◆ createImplicitRule()

std::shared_ptr< DRC_RULE > DRC_ENGINE::createImplicitRule ( const wxString &  name)
private

Definition at line 128 of file drc_engine.cpp.

129{
130 std::shared_ptr<DRC_RULE> rule = std::make_shared<DRC_RULE>();
131
132 rule->m_Name = name;
133 rule->m_Implicit = true;
134
135 addRule( rule );
136
137 return rule;
138}
const char * name
Definition: DXF_plotter.cpp:56
void addRule(std::shared_ptr< DRC_RULE > &rule)
Definition: drc_engine.h:205

References addRule(), and name.

Referenced by loadImplicitRules().

◆ EvalRules()

DRC_CONSTRAINT DRC_ENGINE::EvalRules ( DRC_CONSTRAINT_T  aConstraintType,
const BOARD_ITEM a,
const BOARD_ITEM b,
PCB_LAYER_ID  aLayer,
REPORTER aReporter = nullptr 
)

Definition at line 671 of file drc_engine.cpp.

674{
675 /*
676 * NOTE: all string manipulation MUST BE KEPT INSIDE the REPORT macro. It absolutely
677 * kills performance when running bulk DRC tests (where aReporter is nullptr).
678 */
679
680 const BOARD_CONNECTED_ITEM* ac = a && a->IsConnected() ?
681 static_cast<const BOARD_CONNECTED_ITEM*>( a ) : nullptr;
682 const BOARD_CONNECTED_ITEM* bc = b && b->IsConnected() ?
683 static_cast<const BOARD_CONNECTED_ITEM*>( b ) : nullptr;
684
685 bool a_is_non_copper = a && ( !a->IsOnCopperLayer() || isKeepoutZone( a, false ) );
686 bool b_is_non_copper = b && ( !b->IsOnCopperLayer() || isKeepoutZone( b, false ) );
687
688 const PAD* pad = nullptr;
689 const ZONE* zone = nullptr;
690 const FOOTPRINT* parentFootprint = nullptr;
691
692 if( aConstraintType == ZONE_CONNECTION_CONSTRAINT
693 || aConstraintType == THERMAL_RELIEF_GAP_CONSTRAINT
694 || aConstraintType == THERMAL_SPOKE_WIDTH_CONSTRAINT )
695 {
696 if( a && a->Type() == PCB_PAD_T )
697 pad = static_cast<const PAD*>( a );
698 else if( a && ( a->Type() == PCB_ZONE_T || a->Type() == PCB_FP_ZONE_T ) )
699 zone = static_cast<const ZONE*>( a );
700
701 if( b && b->Type() == PCB_PAD_T )
702 pad = static_cast<const PAD*>( b );
703 else if( b && ( b->Type() == PCB_ZONE_T || b->Type() == PCB_FP_ZONE_T ) )
704 zone = static_cast<const ZONE*>( b );
705
706 if( pad )
707 parentFootprint = static_cast<FOOTPRINT*>( pad->GetParentFootprint() );
708 }
709
710 DRC_CONSTRAINT constraint;
711 constraint.m_Type = aConstraintType;
712
713 // Local overrides take precedence over everything *except* board min clearance
714 if( aConstraintType == CLEARANCE_CONSTRAINT || aConstraintType == HOLE_CLEARANCE_CONSTRAINT )
715 {
716 int override_val = 0;
717 int overrideA = 0;
718 int overrideB = 0;
719
720 if( ac && !b_is_non_copper )
721 overrideA = ac->GetLocalClearanceOverrides( nullptr );
722
723 if( bc && !a_is_non_copper )
724 overrideB = bc->GetLocalClearanceOverrides( nullptr );
725
726 if( overrideA > 0 || overrideB > 0 )
727 {
728 wxString msg;
729
730 if( overrideA > 0 )
731 {
732 REPORT( "" )
733 REPORT( wxString::Format( _( "Local override on %s; clearance: %s." ),
734 EscapeHTML( a->GetSelectMenuText( this ) ),
735 MessageTextFromValue( overrideA ) ) )
736
737 override_val = ac->GetLocalClearanceOverrides( &msg );
738 }
739
740 if( overrideB > 0 )
741 {
742 REPORT( "" )
743 REPORT( wxString::Format( _( "Local override on %s; clearance: %s." ),
744 EscapeHTML( b->GetSelectMenuText( this ) ),
745 EscapeHTML( MessageTextFromValue( overrideB ) ) ) )
746
747 if( overrideB > override_val )
748 override_val = bc->GetLocalClearanceOverrides( &msg );
749 }
750
751 if( override_val )
752 {
753 if( aConstraintType == CLEARANCE_CONSTRAINT )
754 {
755 if( override_val < m_designSettings->m_MinClearance )
756 {
757 override_val = m_designSettings->m_MinClearance;
758 msg = _( "board minimum" );
759
760 REPORT( "" )
761 REPORT( wxString::Format( _( "Board minimum clearance: %s." ),
762 MessageTextFromValue( override_val ) ) )
763 }
764 }
765 else
766 {
767 if( override_val < m_designSettings->m_HoleClearance )
768 {
769 override_val = m_designSettings->m_HoleClearance;
770 msg = _( "board minimum hole" );
771
772 REPORT( "" )
773 REPORT( wxString::Format( _( "Board minimum hole clearance: %s." ),
774 MessageTextFromValue( override_val ) ) )
775 }
776 }
777
778 constraint.SetName( msg );
779 constraint.m_Value.SetMin( override_val );
780 return constraint;
781 }
782 }
783 }
784 else if( aConstraintType == ZONE_CONNECTION_CONSTRAINT )
785 {
786 if( pad && pad->GetLocalZoneConnectionOverride( nullptr ) != ZONE_CONNECTION::INHERITED )
787 {
788 wxString msg;
789 ZONE_CONNECTION override = pad->GetLocalZoneConnectionOverride( &msg );
790
791 REPORT( "" )
792 REPORT( wxString::Format( _( "Local override on %s; zone connection: %s." ),
793 EscapeHTML( pad->GetSelectMenuText( this ) ),
794 EscapeHTML( PrintZoneConnection( override ) ) ) )
795
796 constraint.SetName( msg );
797 constraint.m_ZoneConnection = override;
798 return constraint;
799 }
800 }
801 else if( aConstraintType == THERMAL_RELIEF_GAP_CONSTRAINT )
802 {
803 if( pad && pad->GetLocalThermalGapOverride( nullptr ) > 0 )
804 {
805 wxString msg;
806 int gap_override = pad->GetLocalThermalGapOverride( &msg );
807
808 REPORT( "" )
809 REPORT( wxString::Format( _( "Local override on %s; thermal relief gap: %s." ),
810 EscapeHTML( pad->GetSelectMenuText( this ) ),
811 EscapeHTML( MessageTextFromValue( gap_override ) ) ) )
812
813 constraint.SetName( msg );
814 constraint.m_Value.SetMin( gap_override );
815 return constraint;
816 }
817 }
818 else if( aConstraintType == THERMAL_SPOKE_WIDTH_CONSTRAINT )
819 {
820 if( pad && pad->GetLocalSpokeWidthOverride( nullptr ) > 0 )
821 {
822 wxString msg;
823 int spoke_override = pad->GetLocalSpokeWidthOverride( &msg );
824
825 REPORT( "" )
826 REPORT( wxString::Format( _( "Local override on %s; thermal spoke width: %s." ),
827 EscapeHTML( pad->GetSelectMenuText( this ) ),
828 EscapeHTML( MessageTextFromValue( spoke_override ) ) ) )
829
830 if( zone && zone->GetMinThickness() > spoke_override )
831 {
832 spoke_override = zone->GetMinThickness();
833
834 REPORT( "" )
835 REPORT( wxString::Format( _( "%s min thickness: %s." ),
836 EscapeHTML( zone->GetSelectMenuText( this ) ),
837 EscapeHTML( MessageTextFromValue( spoke_override ) ) ) )
838 }
839
840 constraint.SetName( msg );
841 constraint.m_Value.SetMin( spoke_override );
842 return constraint;
843 }
844 }
845
846 auto testAssertion =
847 [&]( const DRC_ENGINE_CONSTRAINT* c )
848 {
849 REPORT( wxString::Format( _( "Checking assertion \"%s\"." ),
850 EscapeHTML( c->constraint.m_Test->GetExpression() ) ) )
851
852 if( c->constraint.m_Test->EvaluateFor( a, b, c->constraint.m_Type, aLayer,
853 aReporter ) )
854 {
855 REPORT( _( "Assertion passed." ) )
856 }
857 else
858 {
859 REPORT( EscapeHTML( _( "--> Assertion failed. <--" ) ) )
860 }
861 };
862
863 auto processConstraint =
864 [&]( const DRC_ENGINE_CONSTRAINT* c ) -> bool
865 {
866 bool implicit = c->parentRule && c->parentRule->m_Implicit;
867
868 REPORT( "" )
869
870 switch( c->constraint.m_Type )
871 {
879 REPORT( wxString::Format( _( "Checking %s clearance: %s." ),
880 EscapeHTML( c->constraint.GetName() ),
881 MessageTextFromValue( c->constraint.m_Value.Min() ) ) )
882 break;
883
885 REPORT( wxString::Format( _( "Checking %s max uncoupled length: %s." ),
886 EscapeHTML( c->constraint.GetName() ),
887 MessageTextFromValue( c->constraint.m_Value.Max() ) ) )
888 break;
889
890 case SKEW_CONSTRAINT:
891 REPORT( wxString::Format( _( "Checking %s max skew: %s." ),
892 EscapeHTML( c->constraint.GetName() ),
893 MessageTextFromValue( c->constraint.m_Value.Max() ) ) )
894 break;
895
897 REPORT( wxString::Format( _( "Checking %s gap: %s." ),
898 EscapeHTML( c->constraint.GetName() ),
899 MessageTextFromValue( c->constraint.m_Value.Min() ) ) )
900 break;
901
903 REPORT( wxString::Format( _( "Checking %s thermal spoke width: %s." ),
904 EscapeHTML( c->constraint.GetName() ),
905 MessageTextFromValue( c->constraint.m_Value.Opt() ) ) )
906 break;
907
909 REPORT( wxString::Format( _( "Checking %s min spoke count: %s." ),
910 EscapeHTML( c->constraint.GetName() ),
912 c->constraint.m_Value.Min() ) ) )
913 break;
914
916 REPORT( wxString::Format( _( "Checking %s zone connection: %s." ),
917 EscapeHTML( c->constraint.GetName() ),
918 EscapeHTML( PrintZoneConnection( c->constraint.m_ZoneConnection ) ) ) )
919 break;
920
931 {
932 if( aReporter )
933 {
934 wxString min = wxT( "<i>" ) + _( "undefined" ) + wxT( "</i>" );
935 wxString opt = wxT( "<i>" ) + _( "undefined" ) + wxT( "</i>" );
936 wxString max = wxT( "<i>" ) + _( "undefined" ) + wxT( "</i>" );
937
938 if( implicit )
939 {
940 min = MessageTextFromValue( c->constraint.m_Value.Min() );
941 opt = MessageTextFromValue( c->constraint.m_Value.Opt() );
942
943 switch( c->constraint.m_Type )
944 {
946 if( c->constraint.m_Value.HasOpt() )
947 {
948 REPORT( wxString::Format( _( "Checking %s track width: opt %s." ),
949 EscapeHTML( c->constraint.GetName() ),
950 opt ) )
951 }
952 else if( c->constraint.m_Value.HasMin() )
953 {
954 REPORT( wxString::Format( _( "Checking board setup constraints "
955 "track width: min %s." ),
956 min ) )
957 }
958
959 break;
960
962 REPORT( wxString::Format( _( "Checking %s annular width: min %s." ),
963 EscapeHTML( c->constraint.GetName() ),
964 opt ) )
965 break;
966
968 if( c->constraint.m_Value.HasOpt() )
969 {
970 REPORT( wxString::Format( _( "Checking %s via diameter: opt %s." ),
971 EscapeHTML( c->constraint.GetName() ),
972 opt ) )
973 }
974 else if( c->constraint.m_Value.HasMin() )
975 {
976 REPORT( wxString::Format( _( "Checking board setup constraints "
977 "via diameter: min %s." ),
978 min ) )
979 }
980 break;
981
983 if( c->constraint.m_Value.HasOpt() )
984 {
985 REPORT( wxString::Format( _( "Checking %s hole size: opt %s." ),
986 EscapeHTML( c->constraint.GetName() ),
987 opt ) )
988 }
989 else if( c->constraint.m_Value.HasMin() )
990 {
991 REPORT( wxString::Format( _( "Checking board setup constraints "
992 "hole size: min %s." ),
993 min ) )
994 }
995
996 break;
997
1001 REPORT( wxString::Format( _( "Checking %s: min %s." ),
1002 EscapeHTML( c->constraint.GetName() ),
1003 min ) )
1004 break;
1005
1007 if( c->constraint.m_Value.HasOpt() )
1008 {
1009 REPORT( wxString::Format( _( "Checking %s diff pair gap: "
1010 "opt %s." ),
1011 EscapeHTML( c->constraint.GetName() ),
1012 opt ) )
1013 }
1014 else if( c->constraint.m_Value.HasMin() )
1015 {
1016 REPORT( wxString::Format( _( "Checking board setup constraints "
1017 "clearance: min %s." ),
1018 min ) )
1019 }
1020
1021 break;
1022
1024 REPORT( wxString::Format( _( "Checking board setup constraints "
1025 "hole to hole: min %s." ),
1026 min ) )
1027 break;
1028
1029 default:
1030 REPORT( wxString::Format( _( "Checking %s." ),
1031 EscapeHTML( c->constraint.GetName() ) ) )
1032 }
1033 }
1034 else
1035 {
1036 if( c->constraint.m_Value.HasMin() )
1037 min = MessageTextFromValue( c->constraint.m_Value.Min() );
1038
1039 if( c->constraint.m_Value.HasOpt() )
1040 opt = MessageTextFromValue( c->constraint.m_Value.Opt() );
1041
1042 if( c->constraint.m_Value.HasMax() )
1043 max = MessageTextFromValue( c->constraint.m_Value.Max() );
1044
1045 REPORT( wxString::Format( _( "Checking %s: min %s; opt %s; max %s." ),
1046 EscapeHTML( c->constraint.GetName() ),
1047 min,
1048 opt,
1049 max ) )
1050 }
1051 }
1052 break;
1053 }
1054
1055 default:
1056 REPORT( wxString::Format( _( "Checking %s." ),
1057 EscapeHTML( c->constraint.GetName() ) ) )
1058 }
1059
1060 if( c->constraint.m_Type == CLEARANCE_CONSTRAINT )
1061 {
1062 if( implicit && ( a_is_non_copper || b_is_non_copper ) )
1063 {
1064 REPORT( _( "Board and netclass clearances apply only between copper "
1065 "items." ) );
1066 return true;
1067 }
1068 }
1069 else if( c->constraint.m_Type == DISALLOW_CONSTRAINT )
1070 {
1071 int mask;
1072
1073 if( a->GetFlags() & HOLE_PROXY )
1074 {
1075 mask = DRC_DISALLOW_HOLES;
1076 }
1077 else if( a->Type() == PCB_VIA_T )
1078 {
1079 mask = DRC_DISALLOW_VIAS;
1080
1081 switch( static_cast<const PCB_VIA*>( a )->GetViaType() )
1082 {
1083 case VIATYPE::BLIND_BURIED: mask |= DRC_DISALLOW_BB_VIAS; break;
1084 case VIATYPE::MICROVIA: mask |= DRC_DISALLOW_MICRO_VIAS; break;
1085 default: break;
1086 }
1087 }
1088 else
1089 {
1090 switch( a->Type() )
1091 {
1092 case PCB_TRACE_T: mask = DRC_DISALLOW_TRACKS; break;
1093 case PCB_ARC_T: mask = DRC_DISALLOW_TRACKS; break;
1094 case PCB_PAD_T: mask = DRC_DISALLOW_PADS; break;
1095 case PCB_FOOTPRINT_T: mask = DRC_DISALLOW_FOOTPRINTS; break;
1096 case PCB_SHAPE_T: mask = DRC_DISALLOW_GRAPHICS; break;
1097 case PCB_FP_SHAPE_T: mask = DRC_DISALLOW_GRAPHICS; break;
1098 case PCB_TEXT_T: mask = DRC_DISALLOW_TEXTS; break;
1099 case PCB_TEXTBOX_T: mask = DRC_DISALLOW_TEXTS; break;
1100 case PCB_FP_TEXT_T: mask = DRC_DISALLOW_TEXTS; break;
1101 case PCB_FP_TEXTBOX_T: mask = DRC_DISALLOW_TEXTS; break;
1102 case PCB_ZONE_T: mask = DRC_DISALLOW_ZONES; break;
1103 case PCB_FP_ZONE_T: mask = DRC_DISALLOW_ZONES; break;
1104 case PCB_LOCATE_HOLE_T: mask = DRC_DISALLOW_HOLES; break;
1105 default: mask = 0; break;
1106 }
1107 }
1108
1109 if( ( c->constraint.m_DisallowFlags & mask ) == 0 )
1110 {
1111 if( implicit )
1112 REPORT( _( "Keepout constraint not met." ) )
1113 else
1114 REPORT( _( "Disallow constraint not met." ) )
1115
1116 return false;
1117 }
1118
1119 LSET itemLayers = a->GetLayerSet();
1120
1121 if( a->Type() == PCB_FOOTPRINT_T )
1122 {
1123 const FOOTPRINT* footprint = static_cast<const FOOTPRINT*>( a );
1124
1125 if( !footprint->GetCourtyard( F_CrtYd ).IsEmpty() )
1126 itemLayers |= LSET::FrontMask();
1127
1128 if( !footprint->GetCourtyard( B_CrtYd ).IsEmpty() )
1129 itemLayers |= LSET::BackMask();
1130 }
1131
1132 if( !( c->layerTest & itemLayers ).any() )
1133 {
1134 if( implicit )
1135 {
1136 REPORT( _( "Keepout layer(s) not matched." ) )
1137 }
1138 else if( c->parentRule )
1139 {
1140 REPORT( wxString::Format( _( "Rule layer '%s' not matched; rule ignored." ),
1141 EscapeHTML( c->parentRule->m_LayerSource ) ) )
1142 }
1143 else
1144 {
1145 REPORT( _( "Rule layer not matched; rule ignored." ) )
1146 }
1147
1148 return false;
1149 }
1150 }
1151
1152 if( ( aLayer != UNDEFINED_LAYER && !c->layerTest.test( aLayer ) )
1153 || ( m_board->GetEnabledLayers() & c->layerTest ).count() == 0 )
1154 {
1155 if( implicit )
1156 {
1157 REPORT( "Constraint layer not matched." )
1158 }
1159 else if( c->parentRule )
1160 {
1161 REPORT( wxString::Format( _( "Rule layer '%s' not matched; rule ignored." ),
1162 EscapeHTML( c->parentRule->m_LayerSource ) ) )
1163 }
1164 else
1165 {
1166 REPORT( _( "Rule layer not matched; rule ignored." ) )
1167 }
1168
1169 return false;
1170 }
1171
1172 if( c->constraint.m_Type == HOLE_TO_HOLE_CONSTRAINT
1173 && ( !hasDrilledHole( a ) || !hasDrilledHole( b ) ) )
1174 {
1175 // Report non-drilled-holes as an implicit condition
1176 if( aReporter )
1177 {
1178 const BOARD_ITEM* x = !hasDrilledHole( a ) ? a : b;
1179
1180 REPORT( wxString::Format( _( "%s is not a drilled hole; rule ignored." ),
1181 x->GetSelectMenuText( this ) ) )
1182 }
1183
1184 return false;
1185 }
1186 else if( !c->condition || c->condition->GetExpression().IsEmpty() )
1187 {
1188 if( aReporter )
1189 {
1190 if( implicit )
1191 {
1192 REPORT( _( "Unconditional constraint applied." ) )
1193 }
1194 else if( constraint.m_Type == ASSERTION_CONSTRAINT )
1195 {
1196 REPORT( _( "Unconditional rule applied." ) )
1197 testAssertion( c );
1198 }
1199 else
1200 {
1201 REPORT( _( "Unconditional rule applied; overrides previous constraints." ) )
1202 }
1203 }
1204
1205 constraint = c->constraint;
1206 return true;
1207 }
1208 else
1209 {
1210 if( implicit )
1211 {
1212 // Don't report on implicit rule conditions; they're synthetic.
1213 }
1214 else
1215 {
1216 REPORT( wxString::Format( _( "Checking rule condition \"%s\"." ),
1217 EscapeHTML( c->condition->GetExpression() ) ) )
1218 }
1219
1220 if( c->condition->EvaluateFor( a, b, c->constraint.m_Type, aLayer, aReporter ) )
1221 {
1222 if( aReporter )
1223 {
1224 if( implicit )
1225 {
1226 REPORT( _( "Constraint applied." ) )
1227 }
1228 else if( constraint.m_Type == ASSERTION_CONSTRAINT )
1229 {
1230 REPORT( _( "Rule applied." ) )
1231 testAssertion( c );
1232 }
1233 else
1234 {
1235 REPORT( _( "Rule applied; overrides previous constraints." ) )
1236 }
1237 }
1238
1239 if( c->constraint.m_Value.HasMin() )
1240 constraint.m_Value.SetMin( c->constraint.m_Value.Min() );
1241
1242 if( c->constraint.m_Value.HasOpt() )
1243 constraint.m_Value.SetOpt( c->constraint.m_Value.Opt() );
1244
1245 if( c->constraint.m_Value.HasMax() )
1246 constraint .m_Value.SetMax( c->constraint.m_Value.Max() );
1247
1248 // While the expectation would be to OR the disallow flags, we've already
1249 // masked them down to aItem's type -- so we're really only looking for a
1250 // boolean here.
1251 constraint.m_DisallowFlags = c->constraint.m_DisallowFlags;
1252
1253 constraint.m_ZoneConnection = c->constraint.m_ZoneConnection;
1254
1255 constraint.SetParentRule( c->constraint.GetParentRule() );
1256
1257 return true;
1258 }
1259 else
1260 {
1261 REPORT( implicit ? _( "Membership not satisfied; constraint ignored." )
1262 : _( "Condition not satisfied; rule ignored." ) )
1263
1264 return false;
1265 }
1266 }
1267 };
1268
1269 if( m_constraintMap.count( aConstraintType ) )
1270 {
1271 std::vector<DRC_ENGINE_CONSTRAINT*>* ruleset = m_constraintMap[ aConstraintType ];
1272
1273 for( int ii = 0; ii < (int) ruleset->size(); ++ii )
1274 processConstraint( ruleset->at( ii ) );
1275 }
1276
1277 if( constraint.GetParentRule() && !constraint.GetParentRule()->m_Implicit )
1278 return constraint;
1279
1280 // Special case for pad zone connections which can iherit from their parent footprints.
1281 // We've already checked for local overrides, and there were no rules targetting the pad
1282 // itself, so we know we're inheriting and need to see if there are any rules targetting
1283 // the parent footprint.
1284 if( pad && parentFootprint && ( aConstraintType == ZONE_CONNECTION_CONSTRAINT
1285 || aConstraintType == THERMAL_RELIEF_GAP_CONSTRAINT
1286 || aConstraintType == THERMAL_SPOKE_WIDTH_CONSTRAINT ) )
1287 {
1288 if( a == pad )
1289 a = parentFootprint;
1290 else
1291 b = parentFootprint;
1292
1293 if( m_constraintMap.count( aConstraintType ) )
1294 {
1295 std::vector<DRC_ENGINE_CONSTRAINT*>* ruleset = m_constraintMap[ aConstraintType ];
1296
1297 for( int ii = 0; ii < (int) ruleset->size(); ++ii )
1298 processConstraint( ruleset->at( ii ) );
1299
1300 if( constraint.GetParentRule() && !constraint.GetParentRule()->m_Implicit )
1301 return constraint;
1302 }
1303 }
1304
1305 // Unfortunately implicit rules don't work for local clearances (such as zones) because
1306 // they have to be max'ed with netclass values (which are already implicit rules), and our
1307 // rule selection paradigm is "winner takes all".
1308 if( aConstraintType == CLEARANCE_CONSTRAINT )
1309 {
1310 int global = constraint.m_Value.Min();
1311 int localA = ac ? ac->GetLocalClearance( nullptr ) : 0;
1312 int localB = bc ? bc->GetLocalClearance( nullptr ) : 0;
1313 int clearance = global;
1314
1315 if( localA > 0 )
1316 {
1317 REPORT( "" )
1318 REPORT( wxString::Format( _( "Local clearance on %s; clearance: %s." ),
1319 EscapeHTML( a->GetSelectMenuText( this ) ),
1320 MessageTextFromValue( localA ) ) )
1321
1322 if( localA > clearance )
1323 {
1324 wxString msg;
1325 clearance = ac->GetLocalClearance( &msg );
1326 constraint.SetParentRule( nullptr );
1327 constraint.SetName( msg );
1328 constraint.m_Value.SetMin( clearance );
1329 }
1330 }
1331
1332 if( localB > 0 )
1333 {
1334 REPORT( "" )
1335 REPORT( wxString::Format( _( "Local clearance on %s; clearance: %s." ),
1336 EscapeHTML( b->GetSelectMenuText( this ) ),
1337 MessageTextFromValue( localB ) ) )
1338
1339 if( localB > clearance )
1340 {
1341 wxString msg;
1342 clearance = bc->GetLocalClearance( &msg );
1343 constraint.SetParentRule( nullptr );
1344 constraint.SetName( msg );
1345 constraint.m_Value.SetMin( clearance );
1346 }
1347 }
1348
1349 REPORT( "" )
1350 REPORT( wxString::Format( _( "Board minimum clearance: %s." ),
1351 MessageTextFromValue( m_designSettings->m_MinClearance ) ) )
1352
1353 if( clearance < m_designSettings->m_MinClearance )
1354 {
1355 constraint.SetParentRule( nullptr );
1356 constraint.SetName( _( "board minimum" ) );
1357 constraint.m_Value.SetMin( m_designSettings->m_MinClearance );
1358 }
1359
1360 return constraint;
1361 }
1362 else if( aConstraintType == DIFF_PAIR_GAP_CONSTRAINT )
1363 {
1364 REPORT( "" )
1365 REPORT( wxString::Format( _( "Board minimum clearance: %s." ),
1366 MessageTextFromValue( m_designSettings->m_MinClearance ) ) )
1367
1368 if( constraint.m_Value.Min() < m_designSettings->m_MinClearance )
1369 {
1370 constraint.SetParentRule( nullptr );
1371 constraint.SetName( _( "board minimum" ) );
1372 constraint.m_Value.SetMin( m_designSettings->m_MinClearance );
1373 }
1374
1375 return constraint;
1376 }
1377 else if( aConstraintType == ZONE_CONNECTION_CONSTRAINT )
1378 {
1379 if( pad && parentFootprint )
1380 {
1381 ZONE_CONNECTION local = parentFootprint->GetZoneConnection();
1382
1383 if( local != ZONE_CONNECTION::INHERITED )
1384 {
1385 REPORT( "" )
1386 REPORT( wxString::Format( _( "%s zone connection: %s." ),
1387 EscapeHTML( parentFootprint->GetSelectMenuText( this ) ),
1388 EscapeHTML( PrintZoneConnection( local ) ) ) )
1389
1390 constraint.SetParentRule( nullptr );
1391 constraint.SetName( _( "footprint" ) );
1392 constraint.m_ZoneConnection = local;
1393 return constraint;
1394 }
1395 }
1396
1397 if( zone )
1398 {
1399 ZONE_CONNECTION local = zone->GetPadConnection();
1400
1401 REPORT( "" )
1402 REPORT( wxString::Format( _( "%s pad connection: %s." ),
1403 EscapeHTML( zone->GetSelectMenuText( this ) ),
1404 EscapeHTML( PrintZoneConnection( local ) ) ) )
1405
1406 constraint.SetParentRule( nullptr );
1407 constraint.SetName( _( "zone" ) );
1408 constraint.m_ZoneConnection = local;
1409 return constraint;
1410 }
1411 }
1412 else if( aConstraintType == THERMAL_RELIEF_GAP_CONSTRAINT )
1413 {
1414 if( zone )
1415 {
1416 int local = zone->GetThermalReliefGap();
1417
1418 REPORT( "" )
1419 REPORT( wxString::Format( _( "%s thermal relief gap: %s." ),
1420 EscapeHTML( zone->GetSelectMenuText( this ) ),
1421 EscapeHTML( MessageTextFromValue( local ) ) ) )
1422
1423 constraint.SetParentRule( nullptr );
1424 constraint.SetName( _( "zone" ) );
1425 constraint.m_Value.SetMin( local );
1426 return constraint;
1427 }
1428 }
1429 else if( aConstraintType == THERMAL_SPOKE_WIDTH_CONSTRAINT )
1430 {
1431 if( zone )
1432 {
1433 int local = zone->GetThermalReliefSpokeWidth();
1434
1435 REPORT( "" )
1436 REPORT( wxString::Format( _( "%s thermal spoke width: %s." ),
1437 EscapeHTML( zone->GetSelectMenuText( this ) ),
1438 EscapeHTML( MessageTextFromValue( local ) ) ) )
1439
1440 constraint.SetParentRule( nullptr );
1441 constraint.SetName( _( "zone" ) );
1442 constraint.m_Value.SetMin( local );
1443 return constraint;
1444 }
1445 }
1446
1447 if( !constraint.GetParentRule() )
1448 {
1449 constraint.m_Type = NULL_CONSTRAINT;
1450 constraint.m_DisallowFlags = 0;
1451 }
1452
1453 return constraint;
1454}
constexpr EDA_IU_SCALE unityScale
Definition: base_units.h:112
A base class derived from BOARD_ITEM for items that can be connected and have a net,...
virtual int GetLocalClearanceOverrides(wxString *aSource) const
Return any local clearance overrides set in the "classic" (ie: pre-rule) system.
virtual int GetLocalClearance(wxString *aSource) const
Return any local clearances set in the "classic" (ie: pre-rule) system.
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:50
virtual bool IsConnected() const
Returns information if the object is derived from BOARD_CONNECTED_ITEM.
Definition: board_item.h:105
virtual bool IsOnCopperLayer() const
Definition: board_item.h:113
LSET GetEnabledLayers() const
A proxy function that calls the corresponding function in m_BoardSettings.
Definition: board.cpp:501
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:97
virtual wxString GetSelectMenuText(UNITS_PROVIDER *aUnitsProvider) const
Return the text to display to be used in the selection clarification context menu when multiple items...
Definition: eda_item.cpp:108
ZONE_CONNECTION GetZoneConnection() const
Definition: footprint.h:243
const SHAPE_POLY_SET & GetCourtyard(PCB_LAYER_ID aLayer) const
Used in DRC to test the courtyard area (a complex polygon).
Definition: footprint.cpp:2183
LSET is a set of PCB_LAYER_IDs.
Definition: layer_ids.h:530
static LSET FrontMask()
Return a mask holding all technical layers and the external CU layer on front side.
Definition: lset.cpp:895
static LSET BackMask()
Return a mask holding all technical layers and the external CU layer on back side.
Definition: lset.cpp:902
Definition: pad.h:58
bool IsEmpty() const
wxString MessageTextFromValue(double aValue, bool aAddUnitLabel=true, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
A lower-precision version of StringFromValue().
Handle a list of polygons defining a copper zone.
Definition: zone.h:57
int GetMinThickness() const
Definition: zone.h:244
static bool isKeepoutZone(const BOARD_ITEM *aItem, bool aCheckFlags)
Definition: drc_engine.cpp:99
bool hasDrilledHole(const BOARD_ITEM *aItem)
Definition: drc_engine.cpp:644
@ DRC_DISALLOW_PADS
Definition: drc_rule.h:82
@ DRC_DISALLOW_VIAS
Definition: drc_rule.h:78
@ DRC_DISALLOW_TEXTS
Definition: drc_rule.h:84
@ DRC_DISALLOW_ZONES
Definition: drc_rule.h:83
@ DRC_DISALLOW_HOLES
Definition: drc_rule.h:86
@ DRC_DISALLOW_GRAPHICS
Definition: drc_rule.h:85
@ DRC_DISALLOW_FOOTPRINTS
Definition: drc_rule.h:87
@ DRC_DISALLOW_TRACKS
Definition: drc_rule.h:81
@ DRC_DISALLOW_MICRO_VIAS
Definition: drc_rule.h:79
@ DRC_DISALLOW_BB_VIAS
Definition: drc_rule.h:80
@ ANNULAR_WIDTH_CONSTRAINT
Definition: drc_rule.h:56
@ COURTYARD_CLEARANCE_CONSTRAINT
Definition: drc_rule.h:51
@ VIA_DIAMETER_CONSTRAINT
Definition: drc_rule.h:62
@ ZONE_CONNECTION_CONSTRAINT
Definition: drc_rule.h:57
@ DIFF_PAIR_MAX_UNCOUPLED_CONSTRAINT
Definition: drc_rule.h:66
@ DIFF_PAIR_GAP_CONSTRAINT
Definition: drc_rule.h:65
@ DISALLOW_CONSTRAINT
Definition: drc_rule.h:61
@ TRACK_WIDTH_CONSTRAINT
Definition: drc_rule.h:55
@ SILK_CLEARANCE_CONSTRAINT
Definition: drc_rule.h:52
@ EDGE_CLEARANCE_CONSTRAINT
Definition: drc_rule.h:49
@ MIN_RESOLVED_SPOKES_CONSTRAINT
Definition: drc_rule.h:60
@ TEXT_THICKNESS_CONSTRAINT
Definition: drc_rule.h:54
@ LENGTH_CONSTRAINT
Definition: drc_rule.h:63
@ PHYSICAL_HOLE_CLEARANCE_CONSTRAINT
Definition: drc_rule.h:70
@ CLEARANCE_CONSTRAINT
Definition: drc_rule.h:46
@ NULL_CONSTRAINT
Definition: drc_rule.h:45
@ THERMAL_SPOKE_WIDTH_CONSTRAINT
Definition: drc_rule.h:59
@ CONNECTION_WIDTH_CONSTRAINT
Definition: drc_rule.h:72
@ THERMAL_RELIEF_GAP_CONSTRAINT
Definition: drc_rule.h:58
@ ASSERTION_CONSTRAINT
Definition: drc_rule.h:71
@ SKEW_CONSTRAINT
Definition: drc_rule.h:64
@ HOLE_CLEARANCE_CONSTRAINT
Definition: drc_rule.h:47
@ HOLE_SIZE_CONSTRAINT
Definition: drc_rule.h:50
@ TEXT_HEIGHT_CONSTRAINT
Definition: drc_rule.h:53
@ PHYSICAL_CLEARANCE_CONSTRAINT
Definition: drc_rule.h:69
@ HOLE_TO_HOLE_CONSTRAINT
Definition: drc_rule.h:48
#define _(s)
#define HOLE_PROXY
Indicates the BOARD_ITEM is a proxy for its hole.
EDA_UNITS
Definition: eda_units.h:43
@ F_CrtYd
Definition: layer_ids.h:117
@ B_CrtYd
Definition: layer_ids.h:116
@ UNDEFINED_LAYER
Definition: layer_ids.h:60
@ BLIND_BURIED
wxString EscapeHTML(const wxString &aString)
Return a new wxString escaped for embedding in HTML.
@ PCB_SHAPE_T
class PCB_SHAPE, a segment not on copper layers
Definition: typeinfo.h:88
@ PCB_FP_SHAPE_T
class FP_SHAPE, a footprint edge
Definition: typeinfo.h:94
@ PCB_VIA_T
class PCB_VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:102
@ PCB_FP_TEXTBOX_T
class FP_TEXTBOX, wrapped text in a footprint
Definition: typeinfo.h:93
@ PCB_TEXTBOX_T
class PCB_TEXTBOX, wrapped text on a layer
Definition: typeinfo.h:91
@ PCB_ZONE_T
class ZONE, a copper pour area
Definition: typeinfo.h:112
@ PCB_TEXT_T
class PCB_TEXT, text on a layer
Definition: typeinfo.h:90
@ PCB_FOOTPRINT_T
class FOOTPRINT, a footprint
Definition: typeinfo.h:86
@ PCB_FP_ZONE_T
class ZONE, managed by a footprint
Definition: typeinfo.h:100
@ PCB_PAD_T
class PAD, a pad in a footprint
Definition: typeinfo.h:87
@ PCB_FP_TEXT_T
class FP_TEXT, text in a footprint
Definition: typeinfo.h:92
@ PCB_ARC_T
class PCB_ARC, an arc track segment on a copper layer
Definition: typeinfo.h:103
@ PCB_LOCATE_HOLE_T
Definition: typeinfo.h:125
@ PCB_TRACE_T
class PCB_TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:101
wxString PrintZoneConnection(ZONE_CONNECTION aConnection)
Definition: zones.h:59
ZONE_CONNECTION
How pads are covered by copper in zone.
Definition: zones.h:50

References _, ANNULAR_WIDTH_CONSTRAINT, ASSERTION_CONSTRAINT, B_CrtYd, LSET::BackMask(), BLIND_BURIED, CLEARANCE_CONSTRAINT, CONNECTION_WIDTH_CONSTRAINT, COURTYARD_CLEARANCE_CONSTRAINT, DIFF_PAIR_GAP_CONSTRAINT, DIFF_PAIR_MAX_UNCOUPLED_CONSTRAINT, DISALLOW_CONSTRAINT, DRC_DISALLOW_BB_VIAS, DRC_DISALLOW_FOOTPRINTS, DRC_DISALLOW_GRAPHICS, DRC_DISALLOW_HOLES, DRC_DISALLOW_MICRO_VIAS, DRC_DISALLOW_PADS, DRC_DISALLOW_TEXTS, DRC_DISALLOW_TRACKS, DRC_DISALLOW_VIAS, DRC_DISALLOW_ZONES, EDGE_CLEARANCE_CONSTRAINT, EscapeHTML(), F_CrtYd, Format(), LSET::FrontMask(), FOOTPRINT::GetCourtyard(), BOARD::GetEnabledLayers(), EDA_ITEM::GetFlags(), BOARD_ITEM::GetLayerSet(), BOARD_CONNECTED_ITEM::GetLocalClearance(), BOARD_CONNECTED_ITEM::GetLocalClearanceOverrides(), ZONE::GetMinThickness(), ZONE::GetPadConnection(), DRC_CONSTRAINT::GetParentRule(), EDA_ITEM::GetSelectMenuText(), FOOTPRINT::GetSelectMenuText(), ZONE::GetSelectMenuText(), ZONE::GetThermalReliefGap(), ZONE::GetThermalReliefSpokeWidth(), FOOTPRINT::GetZoneConnection(), hasDrilledHole(), HOLE_CLEARANCE_CONSTRAINT, HOLE_PROXY, HOLE_SIZE_CONSTRAINT, HOLE_TO_HOLE_CONSTRAINT, INHERITED, BOARD_ITEM::IsConnected(), SHAPE_POLY_SET::IsEmpty(), isKeepoutZone(), BOARD_ITEM::IsOnCopperLayer(), LENGTH_CONSTRAINT, m_board, m_constraintMap, m_designSettings, DRC_CONSTRAINT::m_DisallowFlags, BOARD_DESIGN_SETTINGS::m_HoleClearance, DRC_RULE::m_Implicit, BOARD_DESIGN_SETTINGS::m_MinClearance, DRC_CONSTRAINT::m_Type, DRC_CONSTRAINT::m_Value, DRC_CONSTRAINT::m_ZoneConnection, EDA_UNIT_UTILS::UI::MessageTextFromValue(), UNITS_PROVIDER::MessageTextFromValue(), MICROVIA, MINOPTMAX< T >::Min(), MIN_RESOLVED_SPOKES_CONSTRAINT, NULL_CONSTRAINT, pad, PCB_ARC_T, PCB_FOOTPRINT_T, PCB_FP_SHAPE_T, PCB_FP_TEXT_T, PCB_FP_TEXTBOX_T, PCB_FP_ZONE_T, PCB_LOCATE_HOLE_T, PCB_PAD_T, PCB_SHAPE_T, PCB_TEXT_T, PCB_TEXTBOX_T, PCB_TRACE_T, PCB_VIA_T, PCB_ZONE_T, PHYSICAL_CLEARANCE_CONSTRAINT, PHYSICAL_HOLE_CLEARANCE_CONSTRAINT, PrintZoneConnection(), REPORT, MINOPTMAX< T >::SetMax(), MINOPTMAX< T >::SetMin(), DRC_CONSTRAINT::SetName(), MINOPTMAX< T >::SetOpt(), DRC_CONSTRAINT::SetParentRule(), SILK_CLEARANCE_CONSTRAINT, SKEW_CONSTRAINT, TEXT_HEIGHT_CONSTRAINT, TEXT_THICKNESS_CONSTRAINT, THERMAL_RELIEF_GAP_CONSTRAINT, THERMAL_SPOKE_WIDTH_CONSTRAINT, TRACK_WIDTH_CONSTRAINT, EDA_ITEM::Type(), UNDEFINED_LAYER, unityScale, UNSCALED, VIA_DIAMETER_CONSTRAINT, and ZONE_CONNECTION_CONSTRAINT.

Referenced by DRC_TEST_PROVIDER_HOLE_SIZE::checkPadHole(), DRC_TEST_PROVIDER_HOLE_SIZE::checkViaHole(), EvalZoneConnection(), BOARD_INSPECTION_TOOL::InspectClearance(), BOARD_INSPECTION_TOOL::InspectDRCError(), DRC_TEST_PROVIDER_ANNULAR_WIDTH::Run(), DRC_TEST_PROVIDER_CONNECTION_WIDTH::Run(), test::DRC_TEST_PROVIDER_DIFF_PAIR_COUPLING::Run(), DRC_TEST_PROVIDER_DISALLOW::Run(), DRC_TEST_PROVIDER_SILK_CLEARANCE::Run(), DRC_TEST_PROVIDER_TEXT_DIMS::Run(), DRC_TEST_PROVIDER_TRACK_WIDTH::Run(), DRC_TEST_PROVIDER_VIA_DIAMETER::Run(), DRC_TEST_PROVIDER_MATCHED_LENGTH::runInternal(), DRC_TEST_PROVIDER_EDGE_CLEARANCE::testAgainstEdge(), DRC_TEST_PROVIDER_COURTYARD_CLEARANCE::testCourtyardClearances(), DRC_TEST_PROVIDER_HOLE_TO_HOLE::testHoleAgainstHole(), DRC_TEST_PROVIDER_PHYSICAL_CLEARANCE::testItemAgainstItem(), DRC_TEST_PROVIDER_COPPER_CLEARANCE::testItemAgainstZone(), DRC_TEST_PROVIDER_PHYSICAL_CLEARANCE::testItemAgainstZones(), DRC_TEST_PROVIDER_COPPER_CLEARANCE::testPadAgainstItem(), DRC_TEST_PROVIDER_COPPER_CLEARANCE::testTrackAgainstItem(), and DRC_TEST_PROVIDER_COPPER_CLEARANCE::testZonesToZones().

◆ EvalZoneConnection()

DRC_CONSTRAINT DRC_ENGINE::EvalZoneConnection ( const BOARD_ITEM a,
const BOARD_ITEM b,
PCB_LAYER_ID  aLayer,
REPORTER aReporter = nullptr 
)

Definition at line 610 of file drc_engine.cpp.

612{
613 DRC_CONSTRAINT constraint = EvalRules( ZONE_CONNECTION_CONSTRAINT, a, b, aLayer, aReporter );
614
615 REPORT( "" )
616 REPORT( wxString::Format( _( "Resolved zone connection type: %s." ),
617 EscapeHTML( PrintZoneConnection( constraint.m_ZoneConnection ) ) ) )
618
619 if( constraint.m_ZoneConnection == ZONE_CONNECTION::THT_THERMAL )
620 {
621 const PAD* pad = nullptr;
622
623 if( a->Type() == PCB_PAD_T )
624 pad = static_cast<const PAD*>( a );
625 else if( b->Type() == PCB_PAD_T )
626 pad = static_cast<const PAD*>( b );
627
628 if( pad && pad->GetAttribute() == PAD_ATTRIB::PTH )
629 {
631 }
632 else
633 {
634 REPORT( wxString::Format( _( "Pad is not a through hole pad; connection will be: %s." ),
637 }
638 }
639
640 return constraint;
641}
ZONE_CONNECTION m_ZoneConnection
Definition: drc_rule.h:172
DRC_CONSTRAINT EvalRules(DRC_CONSTRAINT_T aConstraintType, const BOARD_ITEM *a, const BOARD_ITEM *b, PCB_LAYER_ID aLayer, REPORTER *aReporter=nullptr)
Definition: drc_engine.cpp:671
@ PTH
Plated through hole pad.
@ THERMAL
Use thermal relief for pads.
@ THT_THERMAL
Thermal relief only for THT pads.
@ FULL
pads are covered by copper

References _, EscapeHTML(), EvalRules(), Format(), FULL, DRC_CONSTRAINT::m_ZoneConnection, pad, PCB_PAD_T, PrintZoneConnection(), PTH, REPORT, THERMAL, THT_THERMAL, EDA_ITEM::Type(), and ZONE_CONNECTION_CONSTRAINT.

Referenced by BOARD_INSPECTION_TOOL::InspectClearance().

◆ GetBoard()

◆ GetDebugOverlay()

std::shared_ptr< KIGFX::VIEW_OVERLAY > DRC_ENGINE::GetDebugOverlay ( ) const
inline

Definition at line 105 of file drc_engine.h.

105{ return m_debugOverlay; }
std::shared_ptr< KIGFX::VIEW_OVERLAY > m_debugOverlay
Definition: drc_engine.h:251

References m_debugOverlay.

Referenced by test::DRC_TEST_PROVIDER_DIFF_PAIR_COUPLING::Run().

◆ GetDesignSettings()

BOARD_DESIGN_SETTINGS * DRC_ENGINE::GetDesignSettings ( ) const
inline

Definition at line 92 of file drc_engine.h.

92{ return m_designSettings; }

References m_designSettings.

Referenced by DRC_TEST_PROVIDER_CONNECTION_WIDTH::Run().

◆ GetDrawingSheet()

DS_PROXY_VIEW_ITEM * DRC_ENGINE::GetDrawingSheet ( ) const
inline

Definition at line 98 of file drc_engine.h.

98{ return m_drawingSheet; }

References m_drawingSheet.

Referenced by DRC_TEST_PROVIDER_MISC::testTextVars().

◆ GetIuScale()

const EDA_IU_SCALE & UNITS_PROVIDER::GetIuScale ( ) const
inlineinherited

◆ GetProgressReporter()

PROGRESS_REPORTER * DRC_ENGINE::GetProgressReporter ( ) const
inline

◆ GetReportAllTrackErrors()

bool DRC_ENGINE::GetReportAllTrackErrors ( ) const
inline

◆ GetSchematicNetlist()

NETLIST * DRC_ENGINE::GetSchematicNetlist ( ) const
inline

Definition at line 95 of file drc_engine.h.

95{ return m_schematicNetlist; }

References m_schematicNetlist.

Referenced by DRC_TEST_PROVIDER_SCHEMATIC_PARITY::Run().

◆ GetTestFootprints()

bool DRC_ENGINE::GetTestFootprints ( ) const
inline

Definition at line 163 of file drc_engine.h.

163{ return m_testFootprints; }

References m_testFootprints.

Referenced by DRC_TEST_PROVIDER_SCHEMATIC_PARITY::Run().

◆ GetTestProvider()

DRC_TEST_PROVIDER * DRC_ENGINE::GetTestProvider ( const wxString &  name) const

Definition at line 1787 of file drc_engine.cpp.

1788{
1789 for( DRC_TEST_PROVIDER* prov : m_testProviders )
1790 {
1791 if( name == prov->GetName() )
1792 return prov;
1793 }
1794
1795 return nullptr;
1796}
std::vector< DRC_TEST_PROVIDER * > m_testProviders
Definition: drc_engine.h:238
Represent a DRC "provider" which runs some DRC functions over a BOARD and spits out #DRC_ITEMs and po...

References m_testProviders, and name.

◆ GetTestProviders()

std::vector< DRC_TEST_PROVIDER * > DRC_ENGINE::GetTestProviders ( ) const
inline

Definition at line 181 of file drc_engine.h.

181{ return m_testProviders; };

References m_testProviders.

◆ GetUserUnits()

EDA_UNITS UNITS_PROVIDER::GetUserUnits ( ) const
inlineinherited

Definition at line 37 of file units_provider.h.

37{ return m_userUnits; }
EDA_UNITS m_userUnits

References UNITS_PROVIDER::m_userUnits.

Referenced by DIALOG_CONSTRAINTS_REPORTER::AddPage(), DIALOG_SHIM::DIALOG_SHIM(), DIALOG_TRACK_VIA_PROPERTIES::DIALOG_TRACK_VIA_PROPERTIES(), PL_EDITOR_FRAME::DisplayGridMsg(), EDA_DRAW_FRAME::DisplayUnitsMsg(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), DRAWING_TOOL::drawShape(), DRAWING_TOOL::DrawSpecificationStackup(), EVT_GRID_CMD_CELL_CHANGED(), PCB_EDIT_FRAME::GenFootprintsReport(), PANEL_SETUP_TEXT_AND_GRAPHICS::getGridValue(), GERBER_DRAW_ITEM::GetMsgPanelInfo(), EDA_DRAW_FRAME::GetUnitPair(), GetUserUnits(), GERBVIEW_INSPECTION_TOOL::MeasureTool(), PCB_VIEWER_TOOLS::MeasureTool(), UNITS_PROVIDER::MessageTextFromValue(), PANEL_SETUP_BOARD_STACKUP::onAdjustDielectricThickness(), PANEL_SETUP_BOARD_STACKUP::onExportToClipboard(), PANEL_SETUP_TRACKS_AND_VIAS::OnSortDiffPairsClick(), PANEL_SETUP_TRACKS_AND_VIAS::OnSortTrackWidthsClick(), PANEL_SETUP_TRACKS_AND_VIAS::OnSortViaSizesClick(), PANEL_SETUP_BOARD_STACKUP::onThicknessChange(), UNIT_BINDER::onUnitsChanged(), DIALOG_TRACK_VIA_PROPERTIES::onUnitsChanged(), DIALOG_NET_INSPECTOR::onUnitsChanged(), PANEL_FP_EDITOR_DEFAULTS::PANEL_FP_EDITOR_DEFAULTS(), PANEL_PREVIEW_3D_MODEL::PANEL_PREVIEW_3D_MODEL(), PCB_CONTROL::placeBoardItems(), POSITION_RELATIVE_TOOL::PositionRelative(), DRC_TOOL::RunTests(), SCH_EDIT_FRAME::SaveSettings(), EDA_DRAW_FRAME::SaveSettings(), PIN_TABLE_DATA_MODEL::SetValue(), FP_TEXT_GRID_TABLE::SetValue(), GERBVIEW_INSPECTION_TOOL::ShowDCodes(), UNITS_PROVIDER::StringFromValue(), COMMON_TOOLS::ToggleUnits(), EDA_DRAW_FRAME::ToggleUserUnits(), PANEL_SETUP_BOARD_STACKUP::transferDataFromUIToStackup(), PANEL_SETUP_TRACKS_AND_VIAS::TransferDataFromWindow(), UNIT_BINDER::UNIT_BINDER(), PCB_BASE_EDIT_FRAME::unitsChangeRefresh(), EDITOR_CONDITIONS::unitsFunc(), PROPERTIES_PANEL::update(), GERBVIEW_FRAME::updateDCodeSelectBox(), DIALOG_DIMENSION_PROPERTIES::updateDimensionFromDialog(), PNS_TUNE_STATUS_POPUP::UpdateStatus(), PL_EDITOR_FRAME::UpdateStatusBar(), PCB_EDIT_FRAME::UpdateViaSizeSelectBox(), DRC_TOOL::userUnits(), and UNITS_PROVIDER::ValueFromString().

◆ HasRulesForConstraintType()

bool DRC_ENGINE::HasRulesForConstraintType ( DRC_CONSTRAINT_T  constraintID)

Definition at line 1633 of file drc_engine.cpp.

1634{
1635 //drc_dbg(10,"hascorrect id %d size %d\n", ruleID, m_ruleMap[ruleID]->sortedRules.size( ) );
1636 if( m_constraintMap.count( constraintID ) )
1637 return m_constraintMap[ constraintID ]->size() > 0;
1638
1639 return false;
1640}

References m_constraintMap.

Referenced by BOARD_INSPECTION_TOOL::InspectClearance(), BOARD_INSPECTION_TOOL::InspectDRCError(), DRC_TEST_PROVIDER_ANNULAR_WIDTH::Run(), DRC_TEST_PROVIDER_TEXT_DIMS::Run(), DRC_TEST_PROVIDER_TRACK_WIDTH::Run(), and DRC_TEST_PROVIDER_VIA_DIAMETER::Run().

◆ InitEngine()

void DRC_ENGINE::InitEngine ( const wxFileName &  aRulePath)

Initialize the DRC engine.

Exceptions
PARSE_ERRORif the rules file contains errors

Definition at line 512 of file drc_engine.cpp.

513{
515
516 for( DRC_TEST_PROVIDER* provider : m_testProviders )
517 {
518 ReportAux( wxString::Format( wxT( "Create DRC provider: '%s'" ), provider->GetName() ) );
519 provider->SetDRCEngine( this );
520 }
521
522 m_rules.clear();
523 m_rulesValid = false;
524
525 for( std::pair<DRC_CONSTRAINT_T, std::vector<DRC_ENGINE_CONSTRAINT*>*> pair : m_constraintMap )
526 {
527 for( DRC_ENGINE_CONSTRAINT* constraint : *pair.second )
528 delete constraint;
529
530 delete pair.second;
531 }
532
533 m_constraintMap.clear();
534
535 m_board->IncrementTimeStamp(); // Clear board-level caches
536
537 try // attempt to load full set of rules (implicit + user rules)
538 {
540 loadRules( aRulePath );
541 compileRules();
542 }
543 catch( PARSE_ERROR& original_parse_error )
544 {
545 try // try again with just our implicit rules
546 {
548 compileRules();
549 }
550 catch( PARSE_ERROR& )
551 {
552 wxFAIL_MSG( wxT( "Compiling implicit rules failed." ) );
553 }
554
555 throw original_parse_error;
556 }
557
558 for( int ii = DRCE_FIRST; ii < DRCE_LAST; ++ii )
560
561 m_rulesValid = true;
562}
void IncrementTimeStamp()
Definition: board.cpp:216
void loadRules(const wxFileName &aPath)
Load and parse a rule set from an sexpr text file.
Definition: drc_engine.cpp:458
void compileRules()
Definition: drc_engine.cpp:481
void loadImplicitRules()
Definition: drc_engine.cpp:141
std::vector< DRC_TEST_PROVIDER * > GetTestProviders() const
static DRC_TEST_PROVIDER_REGISTRY & Instance()
A filename or source description, a problem input line, a line number, a byte offset,...
Definition: ki_exception.h:119

References compileRules(), DRCE_FIRST, DRCE_LAST, ERROR_LIMIT, Format(), DRC_TEST_PROVIDER_REGISTRY::GetTestProviders(), BOARD::IncrementTimeStamp(), DRC_TEST_PROVIDER_REGISTRY::Instance(), loadImplicitRules(), loadRules(), m_board, m_constraintMap, m_errorLimits, m_rules, m_rulesValid, m_testProviders, and ReportAux().

Referenced by DoCourtyardInvalidTest(), DoCourtyardOverlapTest(), and BOARD_INSPECTION_TOOL::makeDRCEngine().

◆ IsCancelled()

bool DRC_ENGINE::IsCancelled ( ) const

Definition at line 1627 of file drc_engine.cpp.

1628{
1630}
virtual bool IsCancelled() const =0

References PROGRESS_REPORTER::IsCancelled(), and m_progressReporter.

Referenced by DRC_CACHE_GENERATOR::Run(), DRC_TEST_PROVIDER_ANNULAR_WIDTH::Run(), DRC_TEST_PROVIDER_CONNECTION_WIDTH::Run(), DRC_TEST_PROVIDER_CONNECTIVITY::Run(), DRC_TEST_PROVIDER_COPPER_CLEARANCE::Run(), DRC_TEST_PROVIDER_DISALLOW::Run(), DRC_TEST_PROVIDER_FOOTPRINT_CHECKS::Run(), DRC_TEST_PROVIDER_HOLE_SIZE::Run(), DRC_TEST_PROVIDER_MISC::Run(), DRC_TEST_PROVIDER_SCHEMATIC_PARITY::Run(), DRC_TEST_PROVIDER_SLIVER_CHECKER::Run(), DRC_TEST_PROVIDER_SOLDER_MASK::Run(), DRC_TEST_PROVIDER_TEXT_DIMS::Run(), DRC_TEST_PROVIDER_TRACK_WIDTH::Run(), DRC_TEST_PROVIDER_VIA_DIAMETER::Run(), DRC_TEST_PROVIDER_MATCHED_LENGTH::runInternal(), DRC_TEST_PROVIDER_COURTYARD_CLEARANCE::testCourtyardClearances(), DRC_TEST_PROVIDER_COURTYARD_CLEARANCE::testFootprintCourtyardDefinitions(), DRC_TEST_PROVIDER_HOLE_TO_HOLE::testHoleAgainstHole(), DRC_TEST_PROVIDER_PHYSICAL_CLEARANCE::testItemAgainstItem(), DRC_TEST_PROVIDER_SOLDER_MASK::testItemAgainstItems(), DRC_TEST_PROVIDER_PHYSICAL_CLEARANCE::testItemAgainstZones(), DRC_TEST_PROVIDER_SOLDER_MASK::testMaskItemAgainstZones(), DRC_TEST_PROVIDER_COPPER_CLEARANCE::testPadAgainstItem(), DRC_TEST_PROVIDER_COPPER_CLEARANCE::testPadClearances(), DRC_TEST_PROVIDER_MISC::testTextVars(), DRC_TEST_PROVIDER_COPPER_CLEARANCE::testTrackAgainstItem(), DRC_TEST_PROVIDER_COPPER_CLEARANCE::testTrackClearances(), DRC_TEST_PROVIDER_ZONE_CONNECTIONS::testZoneLayer(), DRC_TEST_PROVIDER_PHYSICAL_CLEARANCE::testZoneLayer(), and DRC_TEST_PROVIDER_COPPER_CLEARANCE::testZonesToZones().

◆ IsErrorLimitExceeded()

bool DRC_ENGINE::IsErrorLimitExceeded ( int  error_code)

Definition at line 1532 of file drc_engine.cpp.

1533{
1534 assert( error_code >= 0 && error_code <= DRCE_LAST );
1535 return m_errorLimits[ error_code ] <= 0;
1536}

References DRCE_LAST, and m_errorLimits.

Referenced by DRC_TEST_PROVIDER_ANNULAR_WIDTH::Run(), DRC_TEST_PROVIDER_CONNECTION_WIDTH::Run(), DRC_TEST_PROVIDER_CONNECTIVITY::Run(), DRC_TEST_PROVIDER_COPPER_CLEARANCE::Run(), DRC_TEST_PROVIDER_DISALLOW::Run(), DRC_TEST_PROVIDER_EDGE_CLEARANCE::Run(), DRC_TEST_PROVIDER_FOOTPRINT_CHECKS::Run(), DRC_TEST_PROVIDER_HOLE_SIZE::Run(), DRC_TEST_PROVIDER_HOLE_TO_HOLE::Run(), DRC_TEST_PROVIDER_LIBRARY_PARITY::Run(), DRC_TEST_PROVIDER_MISC::Run(), DRC_TEST_PROVIDER_PHYSICAL_CLEARANCE::Run(), DRC_TEST_PROVIDER_SILK_CLEARANCE::Run(), DRC_TEST_PROVIDER_SLIVER_CHECKER::Run(), DRC_TEST_PROVIDER_SOLDER_MASK::Run(), DRC_TEST_PROVIDER_TEXT_DIMS::Run(), DRC_TEST_PROVIDER_TRACK_WIDTH::Run(), DRC_TEST_PROVIDER_VIA_DIAMETER::Run(), DRC_TEST_PROVIDER_MISC::testAssertions(), DRC_TEST_PROVIDER_COURTYARD_CLEARANCE::testCourtyardClearances(), DRC_TEST_PROVIDER_MISC::testDisabledLayers(), DRC_TEST_PROVIDER_COURTYARD_CLEARANCE::testFootprintCourtyardDefinitions(), DRC_TEST_PROVIDER_HOLE_TO_HOLE::testHoleAgainstHole(), DRC_TEST_PROVIDER_PHYSICAL_CLEARANCE::testItemAgainstItem(), DRC_TEST_PROVIDER_COPPER_CLEARANCE::testItemAgainstZone(), DRC_TEST_PROVIDER_PHYSICAL_CLEARANCE::testItemAgainstZones(), DRC_TEST_PROVIDER_SOLDER_MASK::testMaskBridges(), DRC_TEST_PROVIDER_SCHEMATIC_PARITY::testNetlist(), DRC_TEST_PROVIDER_COPPER_CLEARANCE::testPadAgainstItem(), DRC_TEST_PROVIDER_SOLDER_MASK::testSilkToMaskClearance(), DRC_TEST_PROVIDER_MISC::testTextVars(), DRC_TEST_PROVIDER_COPPER_CLEARANCE::testTrackAgainstItem(), DRC_TEST_PROVIDER_ZONE_CONNECTIONS::testZoneLayer(), and DRC_TEST_PROVIDER_COPPER_CLEARANCE::testZonesToZones().

◆ IsNetADiffPair()

bool DRC_ENGINE::IsNetADiffPair ( BOARD aBoard,
NETINFO_ITEM aNet,
int &  aNetP,
int &  aNetN 
)
static

Definition at line 1730 of file drc_engine.cpp.

1731{
1732 wxString refName = aNet->GetNetname();
1733 wxString dummy, coupledNetName;
1734
1735 if( int polarity = MatchDpSuffix( refName, coupledNetName, dummy ) )
1736 {
1737 NETINFO_ITEM* net = aBoard->FindNet( coupledNetName );
1738
1739 if( !net )
1740 return false;
1741
1742 if( polarity > 0 )
1743 {
1744 aNetP = aNet->GetNetCode();
1745 aNetN = net->GetNetCode();
1746 }
1747 else
1748 {
1749 aNetP = net->GetNetCode();
1750 aNetN = aNet->GetNetCode();
1751 }
1752
1753 return true;
1754 }
1755
1756 return false;
1757}
NETINFO_ITEM * FindNet(int aNetcode) const
Search for a net with the given netcode.
Definition: board.cpp:1392
static int MatchDpSuffix(const wxString &aNetName, wxString &aComplementNet, wxString &aBaseDpName)
Check if the given net is a diff pair, returning its polarity and complement if so.
Handle the data for a net.
Definition: netinfo.h:66
const wxString & GetNetname() const
Definition: netinfo.h:119
int GetNetCode() const
Definition: netinfo.h:113
static LIB_SYMBOL * dummy()
Used to draw a dummy shape when a LIB_SYMBOL is not found in library.
Definition: sch_symbol.cpp:74

References dummy(), BOARD::FindNet(), NETINFO_ITEM::GetNetCode(), NETINFO_ITEM::GetNetname(), and MatchDpSuffix().

Referenced by test::DRC_TEST_PROVIDER_DIFF_PAIR_COUPLING::Run().

◆ IsNetTieExclusion()

bool DRC_ENGINE::IsNetTieExclusion ( int  aTrackNetCode,
PCB_LAYER_ID  aTrackLayer,
const VECTOR2I aCollisionPos,
BOARD_ITEM aCollidingItem 
)
static

Check if the given collision between a track and another item occurs during the track's entry into a net-tie pad.

Definition at line 1764 of file drc_engine.cpp.

1766{
1767 FOOTPRINT* parentFootprint = static_cast<FOOTPRINT*>( aCollidingItem->GetParentFootprint() );
1768
1769 if( parentFootprint && parentFootprint->IsNetTie() )
1770 {
1771 std::map<wxString, int> padToNetTieGroupMap = parentFootprint->MapPadNumbersToNetTieGroups();
1772
1773 for( PAD* pad : parentFootprint->Pads() )
1774 {
1775 if( padToNetTieGroupMap[ pad->GetNumber() ] >= 0 && aTrackNetCode == pad->GetNetCode() )
1776 {
1777 if( pad->GetEffectiveShape( aTrackLayer )->Collide( aCollisionPos, 0 ) )
1778 return true;
1779 }
1780 }
1781 }
1782
1783 return false;
1784}
BOARD_ITEM_CONTAINER * GetParentFootprint() const
Definition: board_item.cpp:217
std::map< wxString, int > MapPadNumbersToNetTieGroups() const
Definition: footprint.cpp:2252
PADS & Pads()
Definition: footprint.h:174
bool IsNetTie() const
Definition: footprint.h:252

References BOARD_ITEM::GetParentFootprint(), FOOTPRINT::IsNetTie(), FOOTPRINT::MapPadNumbersToNetTieGroups(), pad, and FOOTPRINT::Pads().

Referenced by DRC_TEST_PROVIDER_COPPER_CLEARANCE::testTrackAgainstItem().

◆ KeepRefreshing()

bool DRC_ENGINE::KeepRefreshing ( bool  aWait = false)

Definition at line 1584 of file drc_engine.cpp.

1585{
1586 if( !m_progressReporter )
1587 return true;
1588
1589 return m_progressReporter->KeepRefreshing( aWait );
1590}
virtual bool KeepRefreshing(bool aWait=false)=0
Update the UI (if any).

References PROGRESS_REPORTER::KeepRefreshing(), and m_progressReporter.

◆ loadImplicitRules()

void DRC_ENGINE::loadImplicitRules ( )
private

Definition at line 141 of file drc_engine.cpp.

142{
143 ReportAux( wxString::Format( wxT( "Building implicit rules (per-item/class overrides, etc...)" ) ) );
144
146
147 // 1) global defaults
148
149 std::shared_ptr<DRC_RULE> rule = createImplicitRule( _( "board setup constraints" ) );
150
151 DRC_CONSTRAINT widthConstraint( TRACK_WIDTH_CONSTRAINT );
152 widthConstraint.Value().SetMin( bds.m_TrackMinWidth );
153 rule->AddConstraint( widthConstraint );
154
155 DRC_CONSTRAINT connectionConstraint( CONNECTION_WIDTH_CONSTRAINT );
156 connectionConstraint.Value().SetMin( bds.m_MinConn );
157 rule->AddConstraint( connectionConstraint );
158
159 DRC_CONSTRAINT drillConstraint( HOLE_SIZE_CONSTRAINT );
160 drillConstraint.Value().SetMin( bds.m_MinThroughDrill );
161 rule->AddConstraint( drillConstraint );
162
163 DRC_CONSTRAINT annulusConstraint( ANNULAR_WIDTH_CONSTRAINT );
164 annulusConstraint.Value().SetMin( bds.m_ViasMinAnnularWidth );
165 rule->AddConstraint( annulusConstraint );
166
167 DRC_CONSTRAINT diameterConstraint( VIA_DIAMETER_CONSTRAINT );
168 diameterConstraint.Value().SetMin( bds.m_ViasMinSize );
169 rule->AddConstraint( diameterConstraint );
170
171 DRC_CONSTRAINT holeToHoleConstraint( HOLE_TO_HOLE_CONSTRAINT );
172 holeToHoleConstraint.Value().SetMin( bds.m_HoleToHoleMin );
173 rule->AddConstraint( holeToHoleConstraint );
174
175 rule = createImplicitRule( _( "board setup constraints zone fill strategy" ) );
176 DRC_CONSTRAINT thermalSpokeCountConstraint( MIN_RESOLVED_SPOKES_CONSTRAINT );
177 thermalSpokeCountConstraint.Value().SetMin( bds.m_MinResolvedSpokes );
178 rule->AddConstraint( thermalSpokeCountConstraint );
179
180 rule = createImplicitRule( _( "board setup constraints silk" ) );
181 rule->m_LayerCondition = LSET( 2, F_SilkS, B_SilkS );
182 DRC_CONSTRAINT silkClearanceConstraint( SILK_CLEARANCE_CONSTRAINT );
183 silkClearanceConstraint.Value().SetMin( bds.m_SilkClearance );
184 rule->AddConstraint( silkClearanceConstraint );
185
186 rule = createImplicitRule( _( "board setup constraints silk text height" ) );
187 rule->m_LayerCondition = LSET( 2, F_SilkS, B_SilkS );
188 DRC_CONSTRAINT silkTextHeightConstraint( TEXT_HEIGHT_CONSTRAINT );
189 silkTextHeightConstraint.Value().SetMin( bds.m_MinSilkTextHeight );
190 rule->AddConstraint( silkTextHeightConstraint );
191
192 rule = createImplicitRule( _( "board setup constraints silk text thickness" ) );
193 rule->m_LayerCondition = LSET( 2, F_SilkS, B_SilkS );
194 DRC_CONSTRAINT silkTextThicknessConstraint( TEXT_THICKNESS_CONSTRAINT );
195 silkTextThicknessConstraint.Value().SetMin( bds.m_MinSilkTextThickness );
196 rule->AddConstraint( silkTextThicknessConstraint );
197
198 rule = createImplicitRule( _( "board setup constraints hole" ) );
199 DRC_CONSTRAINT holeClearanceConstraint( HOLE_CLEARANCE_CONSTRAINT );
200 holeClearanceConstraint.Value().SetMin( bds.m_HoleClearance );
201 rule->AddConstraint( holeClearanceConstraint );
202
203 rule = createImplicitRule( _( "board setup constraints edge" ) );
204 DRC_CONSTRAINT edgeClearanceConstraint( EDGE_CLEARANCE_CONSTRAINT );
205 edgeClearanceConstraint.Value().SetMin( bds.m_CopperEdgeClearance );
206 rule->AddConstraint( edgeClearanceConstraint );
207
208 rule = createImplicitRule( _( "board setup constraints courtyard" ) );
209 DRC_CONSTRAINT courtyardClearanceConstraint( COURTYARD_CLEARANCE_CONSTRAINT );
210 holeToHoleConstraint.Value().SetMin( 0 );
211 rule->AddConstraint( courtyardClearanceConstraint );
212
213 // 2) micro-via specific defaults (new DRC doesn't treat microvias in any special way)
214
215 std::shared_ptr<DRC_RULE> uViaRule = createImplicitRule( _( "board setup micro-via constraints" ) );
216
217 uViaRule->m_Condition = new DRC_RULE_CONDITION( wxT( "A.Via_Type == 'Micro'" ) );
218
219 DRC_CONSTRAINT uViaDrillConstraint( HOLE_SIZE_CONSTRAINT );
220 uViaDrillConstraint.Value().SetMin( bds.m_MicroViasMinDrill );
221 uViaRule->AddConstraint( uViaDrillConstraint );
222
223 DRC_CONSTRAINT uViaDiameterConstraint( VIA_DIAMETER_CONSTRAINT );
224 uViaDiameterConstraint.Value().SetMin( bds.m_MicroViasMinSize );
225 uViaRule->AddConstraint( uViaDiameterConstraint );
226
227 // 3) per-netclass rules
228
229 std::vector<std::shared_ptr<DRC_RULE>> netclassClearanceRules;
230 std::vector<std::shared_ptr<DRC_RULE>> netclassItemSpecificRules;
231
232 auto makeNetclassRules =
233 [&]( const std::shared_ptr<NETCLASS>& nc, bool isDefault )
234 {
235 wxString ncName = nc->GetName();
236 wxString expr;
237
238 if( nc->GetClearance() || nc->GetTrackWidth() )
239 {
240 std::shared_ptr<DRC_RULE> netclassRule = std::make_shared<DRC_RULE>();
241 netclassRule->m_Name = wxString::Format( _( "netclass '%s'" ), ncName );
242 netclassRule->m_Implicit = true;
243
244 expr = wxString::Format( wxT( "A.NetClass == '%s'" ), ncName );
245 netclassRule->m_Condition = new DRC_RULE_CONDITION( expr );
246 netclassClearanceRules.push_back( netclassRule );
247
248 if( nc->GetClearance() )
249 {
251 constraint.Value().SetMin( nc->GetClearance() );
252 netclassRule->AddConstraint( constraint );
253 }
254
255 if( nc->GetTrackWidth() )
256 {
258 constraint.Value().SetMin( bds.m_TrackMinWidth );
259 constraint.Value().SetOpt( nc->GetTrackWidth() );
260 netclassRule->AddConstraint( constraint );
261 }
262 }
263
264 if( nc->GetDiffPairWidth() )
265 {
266 std::shared_ptr<DRC_RULE> netclassRule = std::make_shared<DRC_RULE>();
267 netclassRule->m_Name = wxString::Format( _( "netclass '%s' (diff pair)" ),
268 ncName );
269 netclassRule->m_Implicit = true;
270
271 expr = wxString::Format( wxT( "A.NetClass == '%s' && A.inDiffPair('*')" ),
272 ncName );
273 netclassRule->m_Condition = new DRC_RULE_CONDITION( expr );
274 netclassItemSpecificRules.push_back( netclassRule );
275
277 constraint.Value().SetMin( bds.m_TrackMinWidth );
278 constraint.Value().SetOpt( nc->GetDiffPairWidth() );
279 netclassRule->AddConstraint( constraint );
280 }
281
282 if( nc->GetDiffPairGap() )
283 {
284 std::shared_ptr<DRC_RULE> netclassRule = std::make_shared<DRC_RULE>();
285 netclassRule->m_Name = wxString::Format( _( "netclass '%s' (diff pair)" ),
286 ncName );
287 netclassRule->m_Implicit = true;
288
289 expr = wxString::Format( wxT( "A.NetClass == '%s'" ), ncName );
290 netclassRule->m_Condition = new DRC_RULE_CONDITION( expr );
291 netclassItemSpecificRules.push_back( netclassRule );
292
294 constraint.Value().SetMin( bds.m_MinClearance );
295 constraint.Value().SetOpt( nc->GetDiffPairGap() );
296 netclassRule->AddConstraint( constraint );
297
298 // A narrower diffpair gap overrides the netclass min clearance
299 if( nc->GetDiffPairGap() < nc->GetClearance() )
300 {
301 netclassRule = std::make_shared<DRC_RULE>();
302 netclassRule->m_Name = wxString::Format( _( "netclass '%s' (diff pair)" ),
303 ncName );
304 netclassRule->m_Implicit = true;
305
306 expr = wxString::Format( wxT( "A.NetClass == '%s' && AB.isCoupledDiffPair()" ),
307 ncName );
308 netclassRule->m_Condition = new DRC_RULE_CONDITION( expr );
309 netclassItemSpecificRules.push_back( netclassRule );
310
311 DRC_CONSTRAINT min_clearanceConstraint( CLEARANCE_CONSTRAINT );
312 min_clearanceConstraint.Value().SetMin( nc->GetDiffPairGap() );
313 netclassRule->AddConstraint( min_clearanceConstraint );
314 }
315 }
316
317 if( nc->GetViaDiameter() || nc->GetViaDrill() )
318 {
319 std::shared_ptr<DRC_RULE> netclassRule = std::make_shared<DRC_RULE>();
320 netclassRule->m_Name = wxString::Format( _( "netclass '%s'" ), ncName );
321 netclassRule->m_Implicit = true;
322
323 expr = wxString::Format( wxT( "A.NetClass == '%s' && A.Via_Type != 'Micro'" ),
324 ncName );
325 netclassRule->m_Condition = new DRC_RULE_CONDITION( expr );
326 netclassItemSpecificRules.push_back( netclassRule );
327
328 if( nc->GetViaDiameter() )
329 {
331 constraint.Value().SetMin( bds.m_ViasMinSize );
332 constraint.Value().SetOpt( nc->GetViaDiameter() );
333 netclassRule->AddConstraint( constraint );
334 }
335
336 if( nc->GetViaDrill() )
337 {
339 constraint.Value().SetMin( bds.m_MinThroughDrill );
340 constraint.Value().SetOpt( nc->GetViaDrill() );
341 netclassRule->AddConstraint( constraint );
342 }
343 }
344
345 if( nc->GetuViaDiameter() || nc->GetuViaDrill() )
346 {
347 std::shared_ptr<DRC_RULE> netclassRule = std::make_shared<DRC_RULE>();
348 netclassRule->m_Name = wxString::Format( _( "netclass '%s'" ), ncName );
349 netclassRule->m_Implicit = true;
350
351 expr = wxString::Format( wxT( "A.NetClass == '%s' && A.Via_Type == 'Micro'" ),
352 ncName );
353 netclassRule->m_Condition = new DRC_RULE_CONDITION( expr );
354 netclassItemSpecificRules.push_back( netclassRule );
355
356 if( nc->GetuViaDiameter() )
357 {
359 constraint.Value().SetMin( bds.m_MicroViasMinSize );
360 constraint.Value().SetMin( nc->GetuViaDiameter() );
361 netclassRule->AddConstraint( constraint );
362 }
363
364 if( nc->GetuViaDrill() )
365 {
367 constraint.Value().SetMin( bds.m_MicroViasMinDrill );
368 constraint.Value().SetOpt( nc->GetuViaDrill() );
369 netclassRule->AddConstraint( constraint );
370 }
371 }
372 };
373
375 makeNetclassRules( bds.m_NetSettings->m_DefaultNetClass, true );
376
377 for( const auto& [ name, netclass ] : bds.m_NetSettings->m_NetClasses )
378 makeNetclassRules( netclass, false );
379
380 // The netclass clearance rules have to be sorted by min clearance so the right one fires
381 // if 'A' and 'B' belong to two different netclasses.
382 //
383 // The item-specific netclass rules are all unary, so there's no 'A' vs 'B' issue.
384
385 std::sort( netclassClearanceRules.begin(), netclassClearanceRules.end(),
386 []( const std::shared_ptr<DRC_RULE>& lhs, const std::shared_ptr<DRC_RULE>& rhs )
387 {
388 return lhs->m_Constraints[0].m_Value.Min()
389 < rhs->m_Constraints[0].m_Value.Min();
390 } );
391
392 for( std::shared_ptr<DRC_RULE>& ncRule : netclassClearanceRules )
393 addRule( ncRule );
394
395 for( std::shared_ptr<DRC_RULE>& ncRule : netclassItemSpecificRules )
396 addRule( ncRule );
397
398 // 3) keepout area rules
399
400 std::vector<ZONE*> keepoutZones;
401
402 for( ZONE* zone : m_board->Zones() )
403 {
404 if( isKeepoutZone( zone, true ) )
405 keepoutZones.push_back( zone );
406 }
407
408 for( FOOTPRINT* footprint : m_board->Footprints() )
409 {
410 for( ZONE* zone : footprint->Zones() )
411 {
412 if( isKeepoutZone( zone, true ) )
413 keepoutZones.push_back( zone );
414 }
415 }
416
417 for( ZONE* zone : keepoutZones )
418 {
419 wxString name = zone->GetZoneName();
420
421 if( name.IsEmpty() )
422 rule = createImplicitRule( _( "keepout area" ) );
423 else
424 rule = createImplicitRule( wxString::Format( _( "keepout area '%s'" ), name ) );
425
426 rule->m_Condition = new DRC_RULE_CONDITION( wxString::Format( wxT( "A.insideArea('%s')" ),
427 zone->m_Uuid.AsString() ) );
428
429 rule->m_LayerCondition = zone->GetLayerSet();
430
431 int disallowFlags = 0;
432
433 if( zone->GetDoNotAllowTracks() )
434 disallowFlags |= DRC_DISALLOW_TRACKS;
435
436 if( zone->GetDoNotAllowVias() )
437 disallowFlags |= DRC_DISALLOW_VIAS;
438
439 if( zone->GetDoNotAllowPads() )
440 disallowFlags |= DRC_DISALLOW_PADS;
441
442 if( zone->GetDoNotAllowCopperPour() )
443 disallowFlags |= DRC_DISALLOW_ZONES;
444
445 if( zone->GetDoNotAllowFootprints() )
446 disallowFlags |= DRC_DISALLOW_FOOTPRINTS;
447
448 DRC_CONSTRAINT disallowConstraint( DISALLOW_CONSTRAINT );
449 disallowConstraint.m_DisallowFlags = disallowFlags;
450 rule->AddConstraint( disallowConstraint );
451 }
452
453 ReportAux( wxString::Format( wxT( "Building %d implicit netclass rules" ),
454 (int) netclassClearanceRules.size() ) );
455}
Container for design settings for a BOARD object.
std::shared_ptr< NET_SETTINGS > m_NetSettings
ZONES & Zones()
Definition: board.h:313
void SynchronizeNetsAndNetClasses()
Copy NETCLASS info to each NET, based on NET membership in a NETCLASS.
Definition: board.cpp:1460
FOOTPRINTS & Footprints()
Definition: board.h:307
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.cpp:618
std::shared_ptr< DRC_RULE > createImplicitRule(const wxString &name)
Definition: drc_engine.cpp:128
@ F_SilkS
Definition: layer_ids.h:104
@ B_SilkS
Definition: layer_ids.h:103

References _, addRule(), ANNULAR_WIDTH_CONSTRAINT, B_SilkS, CLEARANCE_CONSTRAINT, CONNECTION_WIDTH_CONSTRAINT, COURTYARD_CLEARANCE_CONSTRAINT, createImplicitRule(), DIFF_PAIR_GAP_CONSTRAINT, DISALLOW_CONSTRAINT, DRC_DISALLOW_FOOTPRINTS, DRC_DISALLOW_PADS, DRC_DISALLOW_TRACKS, DRC_DISALLOW_VIAS, DRC_DISALLOW_ZONES, EDGE_CLEARANCE_CONSTRAINT, F_SilkS, BOARD::Footprints(), Format(), BOARD::GetDesignSettings(), HOLE_CLEARANCE_CONSTRAINT, HOLE_SIZE_CONSTRAINT, HOLE_TO_HOLE_CONSTRAINT, isKeepoutZone(), m_board, BOARD_DESIGN_SETTINGS::m_CopperEdgeClearance, DRC_CONSTRAINT::m_DisallowFlags, BOARD_DESIGN_SETTINGS::m_HoleClearance, BOARD_DESIGN_SETTINGS::m_HoleToHoleMin, BOARD_DESIGN_SETTINGS::m_MicroViasMinDrill, BOARD_DESIGN_SETTINGS::m_MicroViasMinSize, BOARD_DESIGN_SETTINGS::m_MinClearance, BOARD_DESIGN_SETTINGS::m_MinConn, BOARD_DESIGN_SETTINGS::m_MinResolvedSpokes, BOARD_DESIGN_SETTINGS::m_MinSilkTextHeight, BOARD_DESIGN_SETTINGS::m_MinSilkTextThickness, BOARD_DESIGN_SETTINGS::m_MinThroughDrill, BOARD_DESIGN_SETTINGS::m_NetSettings, BOARD_DESIGN_SETTINGS::m_SilkClearance, BOARD_DESIGN_SETTINGS::m_TrackMinWidth, BOARD_DESIGN_SETTINGS::m_ViasMinAnnularWidth, BOARD_DESIGN_SETTINGS::m_ViasMinSize, MIN_RESOLVED_SPOKES_CONSTRAINT, name, ReportAux(), MINOPTMAX< T >::SetMin(), MINOPTMAX< T >::SetOpt(), SILK_CLEARANCE_CONSTRAINT, BOARD::SynchronizeNetsAndNetClasses(), TEXT_HEIGHT_CONSTRAINT, TEXT_THICKNESS_CONSTRAINT, TRACK_WIDTH_CONSTRAINT, DRC_CONSTRAINT::Value(), VIA_DIAMETER_CONSTRAINT, and BOARD::Zones().

Referenced by InitEngine().

◆ loadRules()

void DRC_ENGINE::loadRules ( const wxFileName &  aPath)
private

Load and parse a rule set from an sexpr text file.

Exceptions
PARSE_ERROR

Definition at line 458 of file drc_engine.cpp.

459{
460 if( aPath.FileExists() )
461 {
462 std::vector<std::shared_ptr<DRC_RULE>> rules;
463
464 FILE* fp = wxFopen( aPath.GetFullPath(), wxT( "rt" ) );
465
466 if( fp )
467 {
468 DRC_RULES_PARSER parser( fp, aPath.GetFullPath() );
469 parser.Parse( rules, m_reporter );
470 }
471
472 // Copy the rules into the member variable afterwards so that if Parse() throws then
473 // the possibly malformed rules won't contaminate the current ruleset.
474
475 for( std::shared_ptr<DRC_RULE>& rule : rules )
476 m_rules.push_back( rule );
477 }
478}

References m_reporter, m_rules, and DRC_RULES_PARSER::Parse().

Referenced by InitEngine().

◆ MatchDpSuffix()

int DRC_ENGINE::MatchDpSuffix ( const wxString &  aNetName,
wxString &  aComplementNet,
wxString &  aBaseDpName 
)
static

Check if the given net is a diff pair, returning its polarity and complement if so.

Parameters
aNetNameis the input net name, like DIFF_P
aComplementNetwill be filled with the complement, like DIFF_N
aBaseDpNamewill be filled with the base name, like DIFF
Returns
1 if aNetName is the positive half of a pair, -1 if negative, 0 if not a diff pair

Definition at line 1680 of file drc_engine.cpp.

1682{
1683 int rv = 0;
1684 int count = 0;
1685
1686 for( auto it = aNetName.rbegin(); it != aNetName.rend() && rv == 0; ++it, ++count )
1687 {
1688 int ch = *it;
1689
1690 if( ( ch >= '0' && ch <= '9' ) || ch == '_' )
1691 {
1692 continue;
1693 }
1694 else if( ch == '+' )
1695 {
1696 aComplementNet = wxT( "-" );
1697 rv = 1;
1698 }
1699 else if( ch == '-' )
1700 {
1701 aComplementNet = wxT( "+" );
1702 rv = -1;
1703 }
1704 else if( ch == 'N' )
1705 {
1706 aComplementNet = wxT( "P" );
1707 rv = -1;
1708 }
1709 else if ( ch == 'P' )
1710 {
1711 aComplementNet = wxT( "N" );
1712 rv = 1;
1713 }
1714 else
1715 {
1716 break;
1717 }
1718 }
1719
1720 if( rv != 0 && count >= 1 )
1721 {
1722 aBaseDpName = aNetName.Left( aNetName.Length() - count );
1723 aComplementNet = aBaseDpName + aComplementNet + aNetName.Right( count - 1 );
1724 }
1725
1726 return rv;
1727}

Referenced by inDiffPairFunc(), BOARD_INSPECTION_TOOL::InspectClearance(), isCoupledDiffPairFunc(), and IsNetADiffPair().

◆ MessageTextFromValue() [1/2]

wxString UNITS_PROVIDER::MessageTextFromValue ( const EDA_ANGLE aValue,
bool  aAddUnitLabel = true 
)
inlineinherited

Definition at line 82 of file units_provider.h.

83 {
85 aValue.AsDegrees(), aAddUnitLabel,
87 }
double AsDegrees() const
Definition: eda_angle.h:149
wxString MessageTextFromValue(const EDA_IU_SCALE &aIuScale, EDA_UNITS aUnits, double aValue, bool aAddUnitsText=true, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
A helper to convert the double length aValue to a string in inches, millimeters, or unscaled units.
Definition: eda_units.cpp:323

References EDA_ANGLE::AsDegrees(), DEGREES, DISTANCE, EDA_UNIT_UTILS::UI::MessageTextFromValue(), and unityScale.

◆ MessageTextFromValue() [2/2]

wxString UNITS_PROVIDER::MessageTextFromValue ( double  aValue,
bool  aAddUnitLabel = true,
EDA_DATA_TYPE  aType = EDA_DATA_TYPE::DISTANCE 
)
inlineinherited

A lower-precision version of StringFromValue().

Should ONLY be used for status text and messages. Not suitable for dialogs, files, etc. where the loss of precision matters.

Definition at line 75 of file units_provider.h.

77 {
79 aAddUnitLabel, aType );
80 }
const EDA_IU_SCALE & GetIuScale() const
EDA_UNITS GetUserUnits() const

References UNITS_PROVIDER::GetIuScale(), UNITS_PROVIDER::GetUserUnits(), and EDA_UNIT_UTILS::UI::MessageTextFromValue().

Referenced by DRC_TEST_PROVIDER_MATCHED_LENGTH::checkLengths(), CheckLibSymbol(), DRC_TEST_PROVIDER_HOLE_SIZE::checkPadHole(), DRC_TEST_PROVIDER_MATCHED_LENGTH::checkSkews(), DRC_TEST_PROVIDER_HOLE_SIZE::checkViaHole(), DIALOG_BOARD_REANNOTATE::CoordTowxString(), EDA_DRAW_FRAME::DisplayGridMsg(), GERBVIEW_FRAME::DisplayGridMsg(), PCB_BASE_FRAME::DisplayGridMsg(), GERBER_FILE_IMAGE::DisplayImageInfo(), DRAWING_TOOL::DrawBoardCharacteristics(), EvalRules(), DIALOG_NET_INSPECTOR::formatLength(), LIB_FIELD::GetMsgPanelInfo(), LIB_PIN::GetMsgPanelInfo(), LIB_TEXT::GetMsgPanelInfo(), LIB_TEXTBOX::GetMsgPanelInfo(), SCH_BITMAP::GetMsgPanelInfo(), SCH_FIELD::GetMsgPanelInfo(), SCH_LABEL_BASE::GetMsgPanelInfo(), SCH_PIN::GetMsgPanelInfo(), SCH_TEXT::GetMsgPanelInfo(), SCH_TEXTBOX::GetMsgPanelInfo(), DS_DRAW_ITEM_BASE::GetMsgPanelInfo(), FP_TEXT::GetMsgPanelInfo(), FP_TEXTBOX::GetMsgPanelInfo(), NETINFO_ITEM::GetMsgPanelInfo(), PAD::GetMsgPanelInfo(), PCB_BITMAP::GetMsgPanelInfo(), PCB_DIMENSION_BASE::GetMsgPanelInfo(), PCB_DIM_ALIGNED::GetMsgPanelInfo(), PCB_DIM_LEADER::GetMsgPanelInfo(), PCB_TARGET::GetMsgPanelInfo(), PCB_TEXT::GetMsgPanelInfo(), PCB_TEXTBOX::GetMsgPanelInfo(), PCB_TRACK::GetMsgPanelInfo(), PCB_VIA::GetMsgPanelInfo(), ZONE::GetMsgPanelInfo(), STROKE_PARAMS::GetMsgPanelInfo(), FOOTPRINT_SEARCH_HANDLER::GetResultCell(), ZONE_SEARCH_HANDLER::GetResultCell(), TEXT_SEARCH_HANDLER::GetResultCell(), LIB_SHAPE::GetSelectMenuText(), SCH_LINE::GetSelectMenuText(), SCH_SHAPE::GetSelectMenuText(), DS_DRAW_ITEM_LINE::GetSelectMenuText(), DS_DRAW_ITEM_RECT::GetSelectMenuText(), PCB_TRACK::GetSelectMenuText(), DIALOG_BOARD_REANNOTATE::MakeSampleText(), DRC_TEST_PROVIDER_ANNULAR_WIDTH::Run(), DRC_TEST_PROVIDER_CONNECTION_WIDTH::Run(), test::DRC_TEST_PROVIDER_DIFF_PAIR_COUPLING::Run(), DRC_TEST_PROVIDER_TEXT_DIMS::Run(), DRC_TEST_PROVIDER_TRACK_WIDTH::Run(), DRC_TEST_PROVIDER_VIA_DIAMETER::Run(), DRC_TEST_PROVIDER_MATCHED_LENGTH::runInternal(), DIALOG_BOARD_STATISTICS::saveReportClicked(), EDA_SHAPE::ShapeGetMsgPanelInfo(), showCoord(), DRC_TEST_PROVIDER_EDGE_CLEARANCE::testAgainstEdge(), DRC_TEST_PROVIDER_COURTYARD_CLEARANCE::testCourtyardClearances(), DRC_TEST_PROVIDER_HOLE_TO_HOLE::testHoleAgainstHole(), DRC_TEST_PROVIDER_PHYSICAL_CLEARANCE::testItemAgainstItem(), DRC_TEST_PROVIDER_COPPER_CLEARANCE::testItemAgainstZone(), DRC_TEST_PROVIDER_PHYSICAL_CLEARANCE::testItemAgainstZones(), DRC_TEST_PROVIDER_COPPER_CLEARANCE::testPadAgainstItem(), DRC_TEST_PROVIDER_PHYSICAL_CLEARANCE::testShapeLineChain(), DRC_TEST_PROVIDER_COPPER_CLEARANCE::testTrackAgainstItem(), DRC_TEST_PROVIDER_PHYSICAL_CLEARANCE::testZoneLayer(), DRC_TEST_PROVIDER_COPPER_CLEARANCE::testZonesToZones(), TRACK_WIDTH_MENU::update(), DIFF_PAIR_MENU::update(), VIA_SIZE_MENU::update(), BOARD_NETLIST_UPDATER::updateCopperZoneNets(), DIALOG_BOARD_STATISTICS::updateDrillGrid(), PCB_CONTROL::UpdateMessagePanel(), PL_EDITOR_FRAME::UpdateMsgPanelInfo(), SCH_BASE_FRAME::UpdateStatusBar(), GERBVIEW_FRAME::UpdateStatusBar(), PCB_BASE_FRAME::UpdateStatusBar(), and DIALOG_BOARD_STATISTICS::updateWidets().

◆ ProcessAssertions()

void DRC_ENGINE::ProcessAssertions ( const BOARD_ITEM a,
std::function< void(const DRC_CONSTRAINT *)>  aFailureHandler,
REPORTER aReporter = nullptr 
)

Definition at line 1457 of file drc_engine.cpp.

1460{
1461 /*
1462 * NOTE: all string manipulation MUST BE KEPT INSIDE the REPORT macro. It absolutely
1463 * kills performance when running bulk DRC tests (where aReporter is nullptr).
1464 */
1465
1466 auto testAssertion =
1467 [&]( const DRC_ENGINE_CONSTRAINT* c )
1468 {
1469 REPORT( wxString::Format( _( "Checking rule assertion \"%s\"." ),
1470 EscapeHTML( c->constraint.m_Test->GetExpression() ) ) )
1471
1472 if( c->constraint.m_Test->EvaluateFor( a, nullptr, c->constraint.m_Type,
1473 a->GetLayer(), aReporter ) )
1474 {
1475 REPORT( _( "Assertion passed." ) )
1476 }
1477 else
1478 {
1479 REPORT( EscapeHTML( _( "--> Assertion failed. <--" ) ) )
1480 aFailureHandler( &c->constraint );
1481 }
1482 };
1483
1484 auto processConstraint =
1485 [&]( const DRC_ENGINE_CONSTRAINT* c )
1486 {
1487 REPORT( "" )
1488 REPORT( wxString::Format( _( "Checking %s." ), c->constraint.GetName() ) )
1489
1490 if( !( a->GetLayerSet() & c->layerTest ).any() )
1491 {
1492 REPORT( wxString::Format( _( "Rule layer '%s' not matched; rule ignored." ),
1493 EscapeHTML( c->parentRule->m_LayerSource ) ) )
1494 }
1495
1496 if( !c->condition || c->condition->GetExpression().IsEmpty() )
1497 {
1498 REPORT( _( "Unconditional rule applied." ) )
1499 testAssertion( c );
1500 }
1501 else
1502 {
1503 REPORT( wxString::Format( _( "Checking rule condition \"%s\"." ),
1504 EscapeHTML( c->condition->GetExpression() ) ) )
1505
1506 if( c->condition->EvaluateFor( a, nullptr, c->constraint.m_Type,
1507 a->GetLayer(), aReporter ) )
1508 {
1509 REPORT( _( "Rule applied." ) )
1510 testAssertion( c );
1511 }
1512 else
1513 {
1514 REPORT( _( "Condition not satisfied; rule ignored." ) )
1515 }
1516 }
1517 };
1518
1520 {
1521 std::vector<DRC_ENGINE_CONSTRAINT*>* ruleset = m_constraintMap[ ASSERTION_CONSTRAINT ];
1522
1523 for( int ii = 0; ii < (int) ruleset->size(); ++ii )
1524 processConstraint( ruleset->at( ii ) );
1525 }
1526}

References _, ASSERTION_CONSTRAINT, EscapeHTML(), Format(), BOARD_ITEM::GetLayer(), BOARD_ITEM::GetLayerSet(), m_constraintMap, and REPORT.

Referenced by BOARD_INSPECTION_TOOL::InspectConstraints(), and DRC_TEST_PROVIDER_MISC::testAssertions().

◆ QueryDistinctConstraints()

std::set< int > DRC_ENGINE::QueryDistinctConstraints ( DRC_CONSTRAINT_T  aConstraintId)

Definition at line 1665 of file drc_engine.cpp.

1666{
1667 std::set<int> distinctMinimums;
1668
1669 if( m_constraintMap.count( aConstraintId ) )
1670 {
1671 for( DRC_ENGINE_CONSTRAINT* c : *m_constraintMap[aConstraintId] )
1672 distinctMinimums.emplace( c->constraint.GetValue().Min() );
1673 }
1674
1675 return distinctMinimums;
1676}

References m_constraintMap.

Referenced by DRC_TEST_PROVIDER_CONNECTION_WIDTH::Run().

◆ QueryWorstConstraint()

bool DRC_ENGINE::QueryWorstConstraint ( DRC_CONSTRAINT_T  aRuleId,
DRC_CONSTRAINT aConstraint 
)

Definition at line 1643 of file drc_engine.cpp.

1644{
1645 int worst = 0;
1646
1647 if( m_constraintMap.count( aConstraintId ) )
1648 {
1649 for( DRC_ENGINE_CONSTRAINT* c : *m_constraintMap[aConstraintId] )
1650 {
1651 int current = c->constraint.GetValue().Min();
1652
1653 if( current > worst )
1654 {
1655 worst = current;
1656 aConstraint = c->constraint;
1657 }
1658 }
1659 }
1660
1661 return worst > 0;
1662}

References m_constraintMap.

Referenced by DRC_CACHE_GENERATOR::Run(), DRC_TEST_PROVIDER_COURTYARD_CLEARANCE::Run(), DRC_TEST_PROVIDER_EDGE_CLEARANCE::Run(), DRC_TEST_PROVIDER_HOLE_TO_HOLE::Run(), DRC_TEST_PROVIDER_SILK_CLEARANCE::Run(), DRC_TEST_PROVIDER_SOLDER_MASK::Run(), and DRC_TEST_PROVIDER_COURTYARD_CLEARANCE_ON_MOVE::Run().

◆ ReportAux()

void DRC_ENGINE::ReportAux ( const wxString &  aStr)

Definition at line 1575 of file drc_engine.cpp.

1576{
1577 if( !m_reporter )
1578 return;
1579
1581}
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)=0
Report a string with a given severity.
@ RPT_SEVERITY_INFO

References m_reporter, REPORTER::Report(), and RPT_SEVERITY_INFO.

Referenced by compileRules(), InitEngine(), loadImplicitRules(), DRC_TEST_PROVIDER::reportAux(), DRC_TEST_PROVIDER::reportRuleStatistics(), and RunTests().

◆ ReportPhase()

bool DRC_ENGINE::ReportPhase ( const wxString &  aMessage)

Definition at line 1617 of file drc_engine.cpp.

1618{
1619 if( !m_progressReporter )
1620 return true;
1621
1622 m_progressReporter->AdvancePhase( aMessage );
1623 return m_progressReporter->KeepRefreshing( false );
1624}
virtual void AdvancePhase()=0
Use the next available virtual zone of the dialog progress bar.

References PROGRESS_REPORTER::AdvancePhase(), PROGRESS_REPORTER::KeepRefreshing(), and m_progressReporter.

Referenced by DRC_TEST_PROVIDER::reportPhase().

◆ ReportProgress()

bool DRC_ENGINE::ReportProgress ( double  aProgress)

◆ ReportViolation()

void DRC_ENGINE::ReportViolation ( const std::shared_ptr< DRC_ITEM > &  aItem,
const VECTOR2I aPos,
int  aMarkerLayer 
)

Definition at line 1539 of file drc_engine.cpp.

1541{
1542 static std::mutex globalLock;
1543
1544 m_errorLimits[ aItem->GetErrorCode() ] -= 1;
1545
1546 if( m_violationHandler )
1547 {
1548 std::lock_guard<std::mutex> guard( globalLock );
1549 m_violationHandler( aItem, aPos, aMarkerLayer );
1550 }
1551
1552 if( m_reporter )
1553 {
1554 wxString msg = wxString::Format( wxT( "Test '%s': %s (code %d)" ),
1555 aItem->GetViolatingTest()->GetName(),
1556 aItem->GetErrorMessage(),
1557 aItem->GetErrorCode() );
1558
1559 DRC_RULE* rule = aItem->GetViolatingRule();
1560
1561 if( rule )
1562 msg += wxString::Format( wxT( ", violating rule: '%s'" ), rule->m_Name );
1563
1564 m_reporter->Report( msg );
1565
1566 wxString violatingItemsStr = wxT( "Violating items: " );
1567
1568 m_reporter->Report( wxString::Format( wxT( " |- violating position (%d, %d)" ),
1569 aPos.x,
1570 aPos.y ) );
1571 }
1572}
wxString m_Name
Definition: drc_rule.h:110

References Format(), m_errorLimits, DRC_RULE::m_Name, m_reporter, m_violationHandler, REPORTER::Report(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by DRC_TEST_PROVIDER::reportViolation().

◆ RulesValid()

bool DRC_ENGINE::RulesValid ( )
inline

Definition at line 165 of file drc_engine.h.

165{ return m_rulesValid; }

References m_rulesValid.

◆ RunTests()

void DRC_ENGINE::RunTests ( EDA_UNITS  aUnits,
bool  aReportAllTrackErrors,
bool  aTestFootprints 
)

Run the DRC tests.

Definition at line 565 of file drc_engine.cpp.

566{
567 SetUserUnits( aUnits );
568
569 m_reportAllTrackErrors = aReportAllTrackErrors;
570 m_testFootprints = aTestFootprints;
571
572 for( int ii = DRCE_FIRST; ii < DRCE_LAST; ++ii )
573 {
574 if( m_designSettings->Ignore( ii ) )
575 m_errorLimits[ ii ] = 0;
576 else if( ii == DRCE_CLEARANCE || ii == DRCE_UNCONNECTED_ITEMS )
578 else
580 }
581
583
584 m_board->IncrementTimeStamp(); // Invalidate all caches...
585
586 DRC_CACHE_GENERATOR cacheGenerator;
587 cacheGenerator.SetDRCEngine( this );
588
589 if( !cacheGenerator.Run() ) // ... and regenerate them.
590 return;
591
592 int timestamp = m_board->GetTimeStamp();
593
594 for( DRC_TEST_PROVIDER* provider : m_testProviders )
595 {
596 ReportAux( wxString::Format( wxT( "Run DRC provider: '%s'" ), provider->GetName() ) );
597
598 if( !provider->RunTests( aUnits ) )
599 break;
600 }
601
602 // DRC tests are multi-threaded; anything that causes us to attempt to re-generate the
603 // caches while DRC is running is problematic.
604 wxASSERT( timestamp == m_board->GetTimeStamp() );
605}
bool Ignore(int aDRCErrorCode)
Return true if the DRC error code's severity is SEVERITY_IGNORE.
int GetTimeStamp() const
Definition: board.h:288
virtual bool Run() override
Run this provider against the given PCB with configured options (if any).
void SetDRCEngine(DRC_ENGINE *engine)
void SetUserUnits(EDA_UNITS aUnits)
#define EXTENDED_ERROR_LIMIT
Definition: drc_engine.cpp:49
@ DRCE_UNCONNECTED_ITEMS
Definition: drc_item.h:39
@ DRCE_CLEARANCE
Definition: drc_item.h:43

References DRCE_CLEARANCE, DRCE_FIRST, DRCE_LAST, DRCE_UNCONNECTED_ITEMS, ERROR_LIMIT, EXTENDED_ERROR_LIMIT, Format(), BOARD::GetTimeStamp(), BOARD_DESIGN_SETTINGS::Ignore(), BOARD::IncrementTimeStamp(), DRC_TEST_PROVIDER::Init(), m_board, m_designSettings, m_errorLimits, m_reportAllTrackErrors, m_testFootprints, m_testProviders, ReportAux(), DRC_CACHE_GENERATOR::Run(), DRC_TEST_PROVIDER::SetDRCEngine(), and UNITS_PROVIDER::SetUserUnits().

Referenced by DoCourtyardInvalidTest(), and DoCourtyardOverlapTest().

◆ SetBoard()

void DRC_ENGINE::SetBoard ( BOARD aBoard)
inline

Definition at line 88 of file drc_engine.h.

88{ m_board = aBoard; }

References m_board.

◆ SetDebugOverlay()

void DRC_ENGINE::SetDebugOverlay ( std::shared_ptr< KIGFX::VIEW_OVERLAY aOverlay)
inline

Definition at line 100 of file drc_engine.h.

101 {
102 m_debugOverlay = aOverlay;
103 }

References m_debugOverlay.

◆ SetDesignSettings()

void DRC_ENGINE::SetDesignSettings ( BOARD_DESIGN_SETTINGS aSettings)
inline

Definition at line 91 of file drc_engine.h.

91{ m_designSettings = aSettings; }

References m_designSettings.

◆ SetDrawingSheet()

void DRC_ENGINE::SetDrawingSheet ( DS_PROXY_VIEW_ITEM aDrawingSheet)
inline

Definition at line 97 of file drc_engine.h.

97{ m_drawingSheet = aDrawingSheet; }

References m_drawingSheet.

◆ SetLogReporter()

void DRC_ENGINE::SetLogReporter ( REPORTER aReporter)
inline

Definition at line 133 of file drc_engine.h.

133{ m_reporter = aReporter; }

References m_reporter.

◆ SetMaxProgress()

void DRC_ENGINE::SetMaxProgress ( int  aSize)

Definition at line 1600 of file drc_engine.cpp.

1601{
1602 if( m_progressReporter )
1604}
virtual void SetMaxProgress(int aMaxProgress)=0
Fix the value that gives the 100 percent progress bar length (inside the current virtual zone).

References m_progressReporter, and PROGRESS_REPORTER::SetMaxProgress().

◆ SetProgressReporter()

void DRC_ENGINE::SetProgressReporter ( PROGRESS_REPORTER aProgRep)
inline

Set an optional reporter for user-level progress info.

Definition at line 123 of file drc_engine.h.

123{ m_progressReporter = aProgRep; }

References m_progressReporter.

◆ SetSchematicNetlist()

void DRC_ENGINE::SetSchematicNetlist ( NETLIST aNetlist)
inline

Definition at line 94 of file drc_engine.h.

94{ m_schematicNetlist = aNetlist; }

References m_schematicNetlist.

◆ SetUserUnits()

◆ SetViolationHandler()

void DRC_ENGINE::SetViolationHandler ( DRC_VIOLATION_HANDLER  aHandler)
inline

Set an optional DRC violation handler (receives DRC_ITEMs and positions).

Definition at line 110 of file drc_engine.h.

111 {
112 m_violationHandler = std::move( aHandler );
113 }

References m_violationHandler.

Referenced by DoCourtyardInvalidTest(), and DoCourtyardOverlapTest().

◆ StringFromValue() [1/2]

wxString UNITS_PROVIDER::StringFromValue ( const EDA_ANGLE aValue,
bool  aAddUnitLabel = false 
)
inlineinherited

Definition at line 62 of file units_provider.h.

63 {
65 aValue.AsDegrees(), aAddUnitLabel,
67 }
wxString StringFromValue(const EDA_IU_SCALE &aIuScale, EDA_UNITS aUnits, double aValue, bool aAddUnitsText=false, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
Returns the string from aValue according to aUnits (inch, mm ...) for display.
Definition: eda_units.cpp:233

References EDA_ANGLE::AsDegrees(), DEGREES, DISTANCE, EDA_UNIT_UTILS::UI::StringFromValue(), and unityScale.

◆ StringFromValue() [2/2]

wxString UNITS_PROVIDER::StringFromValue ( double  aValue,
bool  aAddUnitLabel = false,
EDA_DATA_TYPE  aType = EDA_DATA_TYPE::DISTANCE 
)
inlineinherited

Converts aValue in internal units into a united string.

For readability, trailing 0s are removed if the mantissa has 3 or more digits. This function should be used to display values in dialogs because a value entered in mm (for instance 2.0 mm) could need up to 8 digits mantissa if displayed in inch to avoid truncation or rounding made just by the printf function.

Parameters
aValue= value in internal units
aAddUnitLabel= true to add symbol unit to the string value
Returns
A wxString object containing value and optionally the symbol unit (like 2.000 mm)

Definition at line 55 of file units_provider.h.

57 {
59 aAddUnitLabel, aType );
60 }

References UNITS_PROVIDER::GetIuScale(), UNITS_PROVIDER::GetUserUnits(), and EDA_UNIT_UTILS::UI::StringFromValue().

Referenced by PANEL_SETUP_TRACKS_AND_VIAS::AppendDiffPairs(), PANEL_SETUP_TRACKS_AND_VIAS::AppendTrackWidth(), PANEL_SETUP_TRACKS_AND_VIAS::AppendViaSize(), DIALOG_PLOT::applyPlotSettings(), DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::buildNetclassesGrid(), PANEL_SETUP_BOARD_STACKUP::computeBoardThickness(), MICROWAVE_TOOL::createFootprint(), MICROWAVE_TOOL::createMicrowaveInductor(), PANEL_SETUP_BOARD_STACKUP::createRowData(), DIALOG_TRACK_VIA_PROPERTIES::DIALOG_TRACK_VIA_PROPERTIES(), DRAWING_TOOL::DrawSpecificationStackup(), PIN_TABLE_DATA_MODEL::GetValue(), FP_TEXT_GRID_TABLE::GetValue(), BOARD_INSPECTION_TOOL::InspectClearance(), BOARD_INSPECTION_TOOL::InspectDRCError(), PANEL_SETUP_BOARD_STACKUP::onAdjustDielectricThickness(), DIALOG_TRACK_VIA_PROPERTIES::onUnitsChanged(), reportMax(), reportMin(), reportOpt(), PANEL_SETUP_BOARD_STACKUP::setDefaultLayerWidths(), PANEL_SETUP_BOARD_STACKUP::synchronizeWithBoard(), DIALOG_GRID_SETTINGS::TransferDataFromWindow(), PANEL_SETUP_NETCLASSES::TransferDataToWindow(), DIALOG_PAD_PRIMITIVE_POLY_PROPS::TransferDataToWindow(), and PANEL_SETUP_CONSTRAINTS::TransferDataToWindow().

◆ ValueFromString()

long long int UNITS_PROVIDER::ValueFromString ( const wxString &  aTextValue,
EDA_DATA_TYPE  aType = EDA_DATA_TYPE::DISTANCE 
)
inlineinherited

Converts aTextValue in aUnits to internal units used by the frame.

Warning
This utilizes the current locale and will break if decimal formats differ
Parameters
aTextValueA reference to a wxString object containing the string to convert.
Returns
internal units value

Definition at line 96 of file units_provider.h.

98 {
100 aType );
101 }
long long int ValueFromString(const EDA_IU_SCALE &aIuScale, EDA_UNITS aUnits, const wxString &aTextValue, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
Function ValueFromString converts aTextValue in aUnits to internal units used by the application.
Definition: eda_units.cpp:530

References UNITS_PROVIDER::GetIuScale(), UNITS_PROVIDER::GetUserUnits(), and EDA_UNIT_UTILS::UI::ValueFromString().

Referenced by PIN_TABLE_DATA_MODEL::compare(), PANEL_SETUP_BOARD_STACKUP::computeBoardThickness(), MICROWAVE_TOOL::createFootprint(), MICROWAVE_TOOL::createMicrowaveInductor(), PANEL_SETUP_BOARD_STACKUP::onAdjustDielectricThickness(), PANEL_SETUP_BOARD_STACKUP::onCopperLayersSelCount(), PANEL_SETUP_BOARD_STACKUP::setDefaultLayerWidths(), PANEL_SETUP_NETCLASSES::TransferDataFromWindow(), and DIALOG_GRID_SETTINGS::TransferDataToWindow().

Member Data Documentation

◆ m_board

BOARD* DRC_ENGINE::m_board
protected

Definition at line 232 of file drc_engine.h.

Referenced by EvalRules(), GetBoard(), InitEngine(), loadImplicitRules(), RunTests(), and SetBoard().

◆ m_constraintMap

std::map<DRC_CONSTRAINT_T, std::vector<DRC_ENGINE_CONSTRAINT*>*> DRC_ENGINE::m_constraintMap
protected

◆ m_debugOverlay

std::shared_ptr<KIGFX::VIEW_OVERLAY> DRC_ENGINE::m_debugOverlay
protected

Definition at line 251 of file drc_engine.h.

Referenced by GetDebugOverlay(), and SetDebugOverlay().

◆ m_designSettings

BOARD_DESIGN_SETTINGS* DRC_ENGINE::m_designSettings
protected

Definition at line 231 of file drc_engine.h.

Referenced by EvalRules(), GetDesignSettings(), RunTests(), and SetDesignSettings().

◆ m_drawingSheet

DS_PROXY_VIEW_ITEM* DRC_ENGINE::m_drawingSheet
protected

Definition at line 233 of file drc_engine.h.

Referenced by GetDrawingSheet(), and SetDrawingSheet().

◆ m_errorLimits

std::vector<int> DRC_ENGINE::m_errorLimits
protected

Definition at line 240 of file drc_engine.h.

Referenced by DRC_ENGINE(), InitEngine(), IsErrorLimitExceeded(), ReportViolation(), and RunTests().

◆ m_iuScale

const EDA_IU_SCALE& UNITS_PROVIDER::m_iuScale
privateinherited

Definition at line 104 of file units_provider.h.

Referenced by UNITS_PROVIDER::GetIuScale().

◆ m_progressReporter

◆ m_reportAllTrackErrors

bool DRC_ENGINE::m_reportAllTrackErrors
protected

Definition at line 241 of file drc_engine.h.

Referenced by GetReportAllTrackErrors(), and RunTests().

◆ m_reporter

REPORTER* DRC_ENGINE::m_reporter
protected

Definition at line 248 of file drc_engine.h.

Referenced by loadRules(), ReportAux(), ReportViolation(), and SetLogReporter().

◆ m_rules

std::vector<std::shared_ptr<DRC_RULE> > DRC_ENGINE::m_rules
protected

Definition at line 236 of file drc_engine.h.

Referenced by addRule(), compileRules(), InitEngine(), loadRules(), and ~DRC_ENGINE().

◆ m_rulesValid

bool DRC_ENGINE::m_rulesValid
protected

Definition at line 237 of file drc_engine.h.

Referenced by InitEngine(), and RulesValid().

◆ m_schematicNetlist

NETLIST* DRC_ENGINE::m_schematicNetlist
protected

Definition at line 234 of file drc_engine.h.

Referenced by GetSchematicNetlist(), and SetSchematicNetlist().

◆ m_testFootprints

bool DRC_ENGINE::m_testFootprints
protected

Definition at line 242 of file drc_engine.h.

Referenced by GetTestFootprints(), and RunTests().

◆ m_testProviders

std::vector<DRC_TEST_PROVIDER*> DRC_ENGINE::m_testProviders
protected

Definition at line 238 of file drc_engine.h.

Referenced by GetTestProvider(), GetTestProviders(), InitEngine(), and RunTests().

◆ m_userUnits

EDA_UNITS UNITS_PROVIDER::m_userUnits
privateinherited

Definition at line 105 of file units_provider.h.

Referenced by UNITS_PROVIDER::GetUserUnits(), and UNITS_PROVIDER::SetUserUnits().

◆ m_violationHandler

DRC_VIOLATION_HANDLER DRC_ENGINE::m_violationHandler
protected

Definition at line 247 of file drc_engine.h.

Referenced by ClearViolationHandler(), ReportViolation(), and SetViolationHandler().


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