KiCad PCB EDA Suite
DRC_TEST_PROVIDER_MATCHED_LENGTH Class Reference
Inheritance diagram for DRC_TEST_PROVIDER_MATCHED_LENGTH:
DRC_TEST_PROVIDER UNITS_PROVIDER

Public Member Functions

 DRC_TEST_PROVIDER_MATCHED_LENGTH ()
 
virtual ~DRC_TEST_PROVIDER_MATCHED_LENGTH ()
 
virtual bool Run () override
 Run this provider against the given PCB with configured options (if any). More...
 
virtual const wxString GetName () const override
 
virtual const wxString GetDescription () const override
 
DRC_LENGTH_REPORT BuildLengthReport () const
 
void SetDRCEngine (DRC_ENGINE *engine)
 
bool RunTests (EDA_UNITS aUnits)
 
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)
 
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...
 
EDA_ANGLE AngleValueFromString (const wxString &aTextValue)
 

Static Public Member Functions

static void Init ()
 

Protected Member Functions

int forEachGeometryItem (const std::vector< KICAD_T > &aTypes, LSET aLayers, const std::function< bool(BOARD_ITEM *)> &aFunc)
 
virtual void reportAux (wxString fmt,...)
 
virtual void reportViolation (std::shared_ptr< DRC_ITEM > &item, const VECTOR2I &aMarkerPos, int aMarkerLayer)
 
virtual bool reportProgress (int aCount, int aSize, int aDelta)
 
virtual bool reportPhase (const wxString &aStageName)
 
virtual void reportRuleStatistics ()
 
virtual void accountCheck (const DRC_RULE *ruleToTest)
 
virtual void accountCheck (const DRC_CONSTRAINT &constraintToTest)
 
bool isInvisibleText (const BOARD_ITEM *aItem) const
 
wxString formatMsg (const wxString &aFormatString, const wxString &aSource, int aConstraint, int aActual)
 
EDA_UNITS userUnits () const
 

Protected Attributes

DRC_ENGINEm_drcEngine
 
std::unordered_map< const DRC_RULE *, int > m_stats
 
bool m_isRuleDriven = true
 

Static Protected Attributes

static std::vector< KICAD_Ts_allBasicItems
 
static std::vector< KICAD_Ts_allBasicItemsButZones
 

Private Types

using CONNECTION = DRC_LENGTH_REPORT::ENTRY
 

Private Member Functions

bool runInternal (bool aDelayReportMode=false)
 
void checkLengths (const DRC_CONSTRAINT &aConstraint, const std::vector< CONNECTION > &aMatchedConnections)
 
void checkSkews (const DRC_CONSTRAINT &aConstraint, const std::vector< CONNECTION > &aMatchedConnections)
 
void checkViaCounts (const DRC_CONSTRAINT &aConstraint, const std::vector< CONNECTION > &aMatchedConnections)
 

Private Attributes

BOARDm_board
 
DRC_LENGTH_REPORT m_report
 
const EDA_IU_SCALEm_iuScale
 
EDA_UNITS m_userUnits
 

Detailed Description

Definition at line 45 of file drc_test_provider_matched_length.cpp.

Member Typedef Documentation

◆ CONNECTION

Constructor & Destructor Documentation

◆ DRC_TEST_PROVIDER_MATCHED_LENGTH()

DRC_TEST_PROVIDER_MATCHED_LENGTH::DRC_TEST_PROVIDER_MATCHED_LENGTH ( )
inline

Definition at line 48 of file drc_test_provider_matched_length.cpp.

48 :
49 m_board( nullptr )
50 {
51 }

◆ ~DRC_TEST_PROVIDER_MATCHED_LENGTH()

virtual DRC_TEST_PROVIDER_MATCHED_LENGTH::~DRC_TEST_PROVIDER_MATCHED_LENGTH ( )
inlinevirtual

Definition at line 53 of file drc_test_provider_matched_length.cpp.

54 {
55 }

Member Function Documentation

◆ accountCheck() [1/2]

void DRC_TEST_PROVIDER::accountCheck ( const DRC_CONSTRAINT constraintToTest)
protectedvirtualinherited

Definition at line 127 of file drc_test_provider.cpp.

128{
129 accountCheck( constraintToTest.GetParentRule() );
130}
DRC_RULE * GetParentRule() const
Definition: drc_rule.h:143
virtual void accountCheck(const DRC_RULE *ruleToTest)

References DRC_TEST_PROVIDER::accountCheck(), and DRC_CONSTRAINT::GetParentRule().

◆ accountCheck() [2/2]

void DRC_TEST_PROVIDER::accountCheck ( const DRC_RULE ruleToTest)
protectedvirtualinherited

Definition at line 116 of file drc_test_provider.cpp.

117{
118 auto it = m_stats.find( ruleToTest );
119
120 if( it == m_stats.end() )
121 m_stats[ ruleToTest ] = 1;
122 else
123 m_stats[ ruleToTest ] += 1;
124}
std::unordered_map< const DRC_RULE *, int > m_stats

References DRC_TEST_PROVIDER::m_stats.

Referenced by DRC_TEST_PROVIDER::accountCheck(), and DRC_TEST_PROVIDER::reportViolation().

◆ AngleValueFromString()

EDA_ANGLE UNITS_PROVIDER::AngleValueFromString ( const wxString &  aTextValue)
inlineinherited

Definition at line 104 of file units_provider.h.

105 {
107 aTextValue );
108
109 return EDA_ANGLE( angle, DEGREES_T );
110 }
const EDA_IU_SCALE & GetIuScale() const
@ DEGREES_T
Definition: eda_angle.h:31
double DoubleValueFromString(const EDA_IU_SCALE &aIuScale, EDA_UNITS aUnits, const wxString &aTextValue, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
Function DoubleValueFromString converts aTextValue to a double.
Definition: eda_units.cpp:449
static DIRECTION_45::AngleType angle(const VECTOR2I &a, const VECTOR2I &b)

References PNS::angle(), DEGREES, DEGREES_T, EDA_UNIT_UTILS::UI::DoubleValueFromString(), and UNITS_PROVIDER::GetIuScale().

Referenced by FP_TEXT_GRID_TABLE::SetValue().

◆ BuildLengthReport()

DRC_LENGTH_REPORT DRC_TEST_PROVIDER_MATCHED_LENGTH::BuildLengthReport ( ) const

◆ checkLengths()

void DRC_TEST_PROVIDER_MATCHED_LENGTH::checkLengths ( const DRC_CONSTRAINT aConstraint,
const std::vector< CONNECTION > &  aMatchedConnections 
)
private

Definition at line 88 of file drc_test_provider_matched_length.cpp.

90{
91 for( const DRC_LENGTH_REPORT::ENTRY& ent : aMatchedConnections )
92 {
93 bool minViolation = false;
94 bool maxViolation = false;
95 int minLen = 0;
96 int maxLen = 0;
97
98 if( aConstraint.GetValue().HasMin() && ent.total < aConstraint.GetValue().Min() )
99 {
100 minViolation = true;
101 minLen = aConstraint.GetValue().Min();
102 }
103 else if( aConstraint.GetValue().HasMax() && ent.total > aConstraint.GetValue().Max() )
104 {
105 maxViolation = true;
106 maxLen = aConstraint.GetValue().Max();
107 }
108
109 if( ( minViolation || maxViolation ) )
110 {
111 std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_LENGTH_OUT_OF_RANGE );
112 wxString msg;
113
114 if( minViolation )
115 {
116 msg = formatMsg( _( "(%s min length %s; actual %s)" ),
117 aConstraint.GetName(),
118 minLen,
119 ent.total );
120 }
121 else if( maxViolation )
122 {
123 msg = formatMsg( _( "(%s max length %s; actual %s)" ),
124 aConstraint.GetName(),
125 maxLen,
126 ent.total );
127 }
128
129 drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + msg );
130
131 for( auto offendingTrack : ent.items )
132 drcItem->AddItem( offendingTrack );
133
134 drcItem->SetViolatingRule( aConstraint.GetParentRule() );
135
136 reportViolation( drcItem, ( *ent.items.begin() )->GetPosition(),
137 ( *ent.items.begin() )->GetLayer() );
138 }
139 }
140}
wxString GetName() const
Definition: drc_rule.h:147
const MINOPTMAX< int > & GetValue() const
Definition: drc_rule.h:139
static std::shared_ptr< DRC_ITEM > Create(int aErrorCode)
Constructs a DRC_ITEM for the given error code.
Definition: drc_item.cpp:325
virtual void reportViolation(std::shared_ptr< DRC_ITEM > &item, const VECTOR2I &aMarkerPos, int aMarkerLayer)
wxString formatMsg(const wxString &aFormatString, const wxString &aSource, int aConstraint, int aActual)
T Min() const
Definition: minoptmax.h:33
bool HasMax() const
Definition: minoptmax.h:38
bool HasMin() const
Definition: minoptmax.h:37
T Max() const
Definition: minoptmax.h:34
@ DRCE_LENGTH_OUT_OF_RANGE
Definition: drc_item.h:95
#define _(s)

References _, DRC_ITEM::Create(), DRCE_LENGTH_OUT_OF_RANGE, DRC_TEST_PROVIDER::formatMsg(), DRC_CONSTRAINT::GetName(), DRC_CONSTRAINT::GetParentRule(), DRC_CONSTRAINT::GetValue(), MINOPTMAX< T >::HasMax(), MINOPTMAX< T >::HasMin(), MINOPTMAX< T >::Max(), MINOPTMAX< T >::Min(), and DRC_TEST_PROVIDER::reportViolation().

Referenced by runInternal().

◆ checkSkews()

void DRC_TEST_PROVIDER_MATCHED_LENGTH::checkSkews ( const DRC_CONSTRAINT aConstraint,
const std::vector< CONNECTION > &  aMatchedConnections 
)
private

Definition at line 142 of file drc_test_provider_matched_length.cpp.

144{
145 int avgLength = 0;
146
147 for( const DRC_LENGTH_REPORT::ENTRY& ent : aMatchedConnections )
148 avgLength += ent.total;
149
150 avgLength /= aMatchedConnections.size();
151
152 for( const auto& ent : aMatchedConnections )
153 {
154 int skew = ent.total - avgLength;
155 if( aConstraint.GetValue().HasMax() && abs( skew ) > aConstraint.GetValue().Max() )
156 {
157 std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_SKEW_OUT_OF_RANGE );
158 wxString msg;
159
160 msg.Printf( _( "(%s max skew %s; actual %s; average net length %s; actual %s)" ),
161 aConstraint.GetName(),
162 MessageTextFromValue( aConstraint.GetValue().Max() ),
163 MessageTextFromValue( skew ),
164 MessageTextFromValue( avgLength ),
165 MessageTextFromValue( ent.total ) );
166
167 drcItem->SetErrorMessage( drcItem->GetErrorText() + " " + msg );
168
169 for( BOARD_CONNECTED_ITEM* offendingTrack : ent.items )
170 drcItem->SetItems( offendingTrack );
171
172 drcItem->SetViolatingRule( aConstraint.GetParentRule() );
173
174 reportViolation( drcItem, ( *ent.items.begin() )->GetPosition(),
175 ( *ent.items.begin() )->GetLayer() );
176 }
177 }
178}
A base class derived from BOARD_ITEM for items that can be connected and have a net,...
wxString MessageTextFromValue(double aValue, bool aAddUnitLabel=true, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
A lower-precision version of StringFromValue().
@ DRCE_SKEW_OUT_OF_RANGE
Definition: drc_item.h:96
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
Definition: eda_angle.h:401

References _, std::abs(), DRC_ITEM::Create(), DRCE_SKEW_OUT_OF_RANGE, DRC_CONSTRAINT::GetName(), DRC_CONSTRAINT::GetParentRule(), DRC_CONSTRAINT::GetValue(), MINOPTMAX< T >::HasMax(), MINOPTMAX< T >::Max(), UNITS_PROVIDER::MessageTextFromValue(), and DRC_TEST_PROVIDER::reportViolation().

Referenced by runInternal().

◆ checkViaCounts()

void DRC_TEST_PROVIDER_MATCHED_LENGTH::checkViaCounts ( const DRC_CONSTRAINT aConstraint,
const std::vector< CONNECTION > &  aMatchedConnections 
)
private

Definition at line 181 of file drc_test_provider_matched_length.cpp.

183{
184 for( const auto& ent : aMatchedConnections )
185 {
186 if( aConstraint.GetValue().HasMax() && ent.viaCount > aConstraint.GetValue().Max() )
187 {
188 std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_TOO_MANY_VIAS );
189 wxString msg = wxString::Format( _( "(%s max count %d; actual %d)" ),
190 aConstraint.GetName(),
191 aConstraint.GetValue().Max(),
192 ent.viaCount );
193
194 drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + msg );
195
196 for( auto offendingTrack : ent.items )
197 drcItem->SetItems( offendingTrack );
198
199 drcItem->SetViolatingRule( aConstraint.GetParentRule() );
200
201 reportViolation( drcItem, ( *ent.items.begin() )->GetPosition(),
202 ( *ent.items.begin() )->GetLayer() );
203 }
204 }
205}
@ DRCE_TOO_MANY_VIAS
Definition: drc_item.h:97
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_ITEM::Create(), DRCE_TOO_MANY_VIAS, Format(), DRC_CONSTRAINT::GetName(), DRC_CONSTRAINT::GetParentRule(), DRC_CONSTRAINT::GetValue(), MINOPTMAX< T >::HasMax(), MINOPTMAX< T >::Max(), and DRC_TEST_PROVIDER::reportViolation().

Referenced by runInternal().

◆ forEachGeometryItem()

int DRC_TEST_PROVIDER::forEachGeometryItem ( const std::vector< KICAD_T > &  aTypes,
LSET  aLayers,
const std::function< bool(BOARD_ITEM *)> &  aFunc 
)
protectedinherited

Definition at line 152 of file drc_test_provider.cpp.

154{
155 BOARD *brd = m_drcEngine->GetBoard();
156 std::bitset<MAX_STRUCT_TYPE_ID> typeMask;
157 int n = 0;
158
159 if( aTypes.size() == 0 )
160 {
161 for( int i = 0; i < MAX_STRUCT_TYPE_ID; i++ )
162 typeMask[ i ] = true;
163 }
164 else
165 {
166 for( KICAD_T aType : aTypes )
167 typeMask[ aType ] = true;
168 }
169
170 for( PCB_TRACK* item : brd->Tracks() )
171 {
172 if( (item->GetLayerSet() & aLayers).any() )
173 {
174 if( typeMask[ PCB_TRACE_T ] && item->Type() == PCB_TRACE_T )
175 {
176 aFunc( item );
177 n++;
178 }
179 else if( typeMask[ PCB_VIA_T ] && item->Type() == PCB_VIA_T )
180 {
181 aFunc( item );
182 n++;
183 }
184 else if( typeMask[ PCB_ARC_T ] && item->Type() == PCB_ARC_T )
185 {
186 aFunc( item );
187 n++;
188 }
189 }
190 }
191
192 for( BOARD_ITEM* item : brd->Drawings() )
193 {
194 if( (item->GetLayerSet() & aLayers).any() )
195 {
196 if( typeMask[ PCB_DIMENSION_T ] && BaseType( item->Type() ) == PCB_DIMENSION_T )
197 {
198 if( !aFunc( item ) )
199 return n;
200
201 n++;
202 }
203 else if( typeMask[ PCB_SHAPE_T ] && item->Type() == PCB_SHAPE_T )
204 {
205 if( !aFunc( item ) )
206 return n;
207
208 n++;
209 }
210 else if( typeMask[ PCB_TEXT_T ] && item->Type() == PCB_TEXT_T )
211 {
212 if( !aFunc( item ) )
213 return n;
214
215 n++;
216 }
217 else if( typeMask[ PCB_TEXTBOX_T ] && item->Type() == PCB_TEXTBOX_T )
218 {
219 if( !aFunc( item ) )
220 return n;
221
222 n++;
223 }
224 else if( typeMask[ PCB_TARGET_T ] && item->Type() == PCB_TARGET_T )
225 {
226 if( !aFunc( item ) )
227 return n;
228
229 n++;
230 }
231 }
232 }
233
234 if( typeMask[ PCB_ZONE_T ] )
235 {
236 for( ZONE* item : brd->Zones() )
237 {
238 if( ( item->GetLayerSet() & aLayers ).any() )
239 {
240 if( !aFunc( item ) )
241 return n;
242
243 n++;
244 }
245 }
246 }
247
248 for( FOOTPRINT* footprint : brd->Footprints() )
249 {
250 if( typeMask[ PCB_FP_TEXT_T ] )
251 {
252 if( ( footprint->Reference().GetLayerSet() & aLayers ).any() )
253 {
254 if( !aFunc( &footprint->Reference() ) )
255 return n;
256
257 n++;
258 }
259
260 if( ( footprint->Value().GetLayerSet() & aLayers ).any() )
261 {
262 if( !aFunc( &footprint->Value() ) )
263 return n;
264
265 n++;
266 }
267 }
268
269 if( typeMask[ PCB_PAD_T ] )
270 {
271 for( PAD* pad : footprint->Pads() )
272 {
273 // Careful: if a pad has a hole then it pierces all layers
274 if( pad->HasHole() || ( pad->GetLayerSet() & aLayers ).any() )
275 {
276 if( !aFunc( pad ) )
277 return n;
278
279 n++;
280 }
281 }
282 }
283
284 for( BOARD_ITEM* dwg : footprint->GraphicalItems() )
285 {
286 if( (dwg->GetLayerSet() & aLayers).any() )
287 {
288 if( typeMask[ PCB_DIMENSION_T ] && BaseType( dwg->Type() ) == PCB_DIMENSION_T )
289 {
290 if( !aFunc( dwg ) )
291 return n;
292
293 n++;
294 }
295 else if( typeMask[ PCB_FP_TEXT_T ] && dwg->Type() == PCB_FP_TEXT_T )
296 {
297 if( !aFunc( dwg ) )
298 return n;
299
300 n++;
301 }
302 else if( typeMask[ PCB_FP_TEXTBOX_T ] && dwg->Type() == PCB_FP_TEXTBOX_T )
303 {
304 if( !aFunc( dwg ) )
305 return n;
306
307 n++;
308 }
309 else if( typeMask[ PCB_FP_SHAPE_T ] && dwg->Type() == PCB_FP_SHAPE_T )
310 {
311 if( !aFunc( dwg ) )
312 return n;
313
314 n++;
315 }
316 }
317 }
318
319 if( typeMask[ PCB_FP_ZONE_T ] )
320 {
321 for( ZONE* zone : footprint->Zones() )
322 {
323 if( (zone->GetLayerSet() & aLayers).any() )
324 {
325 if( !aFunc( zone ) )
326 return n;
327
328 n++;
329 }
330 }
331 }
332
333 if( typeMask[ PCB_FOOTPRINT_T ] )
334 {
335 if( !aFunc( footprint ) )
336 return n;
337
338 n++;
339 }
340 }
341
342 return n;
343}
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:58
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:265
ZONES & Zones()
Definition: board.h:313
FOOTPRINTS & Footprints()
Definition: board.h:307
TRACKS & Tracks()
Definition: board.h:304
DRAWINGS & Drawings()
Definition: board.h:310
BOARD * GetBoard() const
Definition: drc_engine.h:89
DRC_ENGINE * m_drcEngine
Definition: pad.h:59
Handle a list of polygons defining a copper zone.
Definition: zone.h:57
constexpr KICAD_T BaseType(const KICAD_T aType)
Return the underlying type of the given type.
Definition: typeinfo.h:253
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:78
@ 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
@ MAX_STRUCT_TYPE_ID
Definition: typeinfo.h:241
@ 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_TARGET_T
class PCB_TARGET, a target (graphic item)
Definition: typeinfo.h:111
@ 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_DIMENSION_T
class PCB_DIMENSION_BASE: abstract dimension meta-type
Definition: typeinfo.h:105
@ PCB_TRACE_T
class PCB_TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:101

References BaseType(), BOARD::Drawings(), BOARD::Footprints(), DRC_ENGINE::GetBoard(), DRC_TEST_PROVIDER::m_drcEngine, MAX_STRUCT_TYPE_ID, pad, PCB_ARC_T, PCB_DIMENSION_T, PCB_FOOTPRINT_T, PCB_FP_SHAPE_T, PCB_FP_TEXT_T, PCB_FP_TEXTBOX_T, PCB_FP_ZONE_T, PCB_PAD_T, PCB_SHAPE_T, PCB_TARGET_T, PCB_TEXT_T, PCB_TEXTBOX_T, PCB_TRACE_T, PCB_VIA_T, PCB_ZONE_T, BOARD::Tracks(), and BOARD::Zones().

Referenced by DRC_TEST_PROVIDER_SOLDER_MASK::buildRTrees(), DRC_CACHE_GENERATOR::Run(), test::DRC_TEST_PROVIDER_DIFF_PAIR_COUPLING::Run(), DRC_TEST_PROVIDER_DISALLOW::Run(), DRC_TEST_PROVIDER_EDGE_CLEARANCE::Run(), DRC_TEST_PROVIDER_HOLE_TO_HOLE::Run(), DRC_TEST_PROVIDER_PHYSICAL_CLEARANCE::Run(), DRC_TEST_PROVIDER_SILK_CLEARANCE::Run(), DRC_TEST_PROVIDER_SLIVER_CHECKER::Run(), DRC_TEST_PROVIDER_TEXT_DIMS::Run(), runInternal(), DRC_TEST_PROVIDER_MISC::testAssertions(), DRC_TEST_PROVIDER_MISC::testDisabledLayers(), DRC_TEST_PROVIDER_SOLDER_MASK::testMaskBridges(), DRC_TEST_PROVIDER_SOLDER_MASK::testSilkToMaskClearance(), and DRC_TEST_PROVIDER_MISC::testTextVars().

◆ formatMsg()

wxString DRC_TEST_PROVIDER::formatMsg ( const wxString &  aFormatString,
const wxString &  aSource,
int  aConstraint,
int  aActual 
)
protectedinherited

Definition at line 365 of file drc_test_provider.cpp.

367{
368 wxString constraint_str = MessageTextFromValue( aConstraint );
369 wxString actual_str = MessageTextFromValue( aActual );
370
371 if( constraint_str == actual_str )
372 {
373 // Use more precise formatting if the message-text strings were equal.
374 constraint_str = StringFromValue( aConstraint );
375 actual_str = StringFromValue( aActual );
376 }
377
378 return wxString::Format( aFormatString, aSource, constraint_str, actual_str );
379}
wxString StringFromValue(double aValue, bool aAddUnitLabel=false, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
Converts aValue in internal units into a united string.

References Format(), UNITS_PROVIDER::MessageTextFromValue(), and UNITS_PROVIDER::StringFromValue().

Referenced by checkLengths(), DRC_TEST_PROVIDER_HOLE_SIZE::checkPadHole(), DRC_TEST_PROVIDER_HOLE_SIZE::checkViaHole(), 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_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(), and DRC_TEST_PROVIDER_COPPER_CLEARANCE::testZonesToZones().

◆ GetDescription()

virtual const wxString DRC_TEST_PROVIDER_MATCHED_LENGTH::GetDescription ( ) const
inlineoverridevirtual

Reimplemented from DRC_TEST_PROVIDER.

Definition at line 64 of file drc_test_provider_matched_length.cpp.

65 {
66 return wxT( "Tests matched track lengths." );
67 }

◆ GetIuScale()

◆ GetName()

virtual const wxString DRC_TEST_PROVIDER_MATCHED_LENGTH::GetName ( void  ) const
inlineoverridevirtual

Reimplemented from DRC_TEST_PROVIDER.

Definition at line 59 of file drc_test_provider_matched_length.cpp.

60 {
61 return wxT( "length" );
62 };

◆ 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(), FP_TEXT_GRID_TABLE::FP_TEXT_GRID_TABLE(), PCB_EDIT_FRAME::GenFootprintsReport(), GERBER_DRAW_ITEM::GetMsgPanelInfo(), EDA_DRAW_FRAME::GetUnitPair(), WX_GRID::GetUnitValue(), GetUserUnits(), UNIT_BINDER::init(), GERBVIEW_INSPECTION_TOOL::MeasureTool(), PCB_VIEWER_TOOLS::MeasureTool(), UNITS_PROVIDER::MessageTextFromValue(), PANEL_SETUP_BOARD_STACKUP::onAdjustDielectricThickness(), WX_GRID::onCellEditorHidden(), PANEL_SETUP_BOARD_STACKUP::onExportToClipboard(), PANEL_SETUP_NETCLASSES::onUnitsChanged(), UNIT_BINDER::onUnitsChanged(), DIALOG_TRACK_VIA_PROPERTIES::onUnitsChanged(), DIALOG_NET_INSPECTOR::onUnitsChanged(), PANEL_PREVIEW_3D_MODEL::PANEL_PREVIEW_3D_MODEL(), PANEL_SETUP_NETCLASSES::PANEL_SETUP_NETCLASSES(), PG_UNIT_EDITOR::PG_UNIT_EDITOR(), PIN_TABLE_DATA_MODEL::PIN_TABLE_DATA_MODEL(), PCB_CONTROL::placeBoardItems(), POSITION_RELATIVE_TOOL::PositionRelative(), DRC_TOOL::RunTests(), SCH_EDIT_FRAME::SaveSettings(), EDA_DRAW_FRAME::SaveSettings(), WX_GRID::SetUnitsProvider(), PIN_TABLE_DATA_MODEL::SetValue(), FP_TEXT_GRID_TABLE::SetValue(), GERBVIEW_INSPECTION_TOOL::ShowDCodes(), UNITS_PROVIDER::StringFromValue(), COMMON_TOOLS::ToggleUnits(), EDA_DRAW_FRAME::ToggleUserUnits(), PCB_BASE_EDIT_FRAME::unitsChangeRefresh(), EDITOR_CONDITIONS::unitsFunc(), PROPERTIES_PANEL::update(), GERBVIEW_FRAME::updateDCodeSelectBox(), DIALOG_DIMENSION_PROPERTIES::updateDimensionFromDialog(), PG_UNIT_EDITOR::UpdateFrame(), PNS_TUNE_STATUS_POPUP::UpdateStatus(), PL_EDITOR_FRAME::UpdateStatusBar(), PCB_EDIT_FRAME::UpdateViaSizeSelectBox(), DRC_TOOL::userUnits(), and UNITS_PROVIDER::ValueFromString().

◆ Init()

void DRC_TEST_PROVIDER::Init ( )
staticinherited

Definition at line 53 of file drc_test_provider.cpp.

54{
55 if( s_allBasicItems.size() == 0 )
56 {
57 for( int i = 0; i < MAX_STRUCT_TYPE_ID; i++ )
58 {
59 if( i != PCB_FOOTPRINT_T && i != PCB_GROUP_T )
60 {
61 s_allBasicItems.push_back( (KICAD_T) i );
62
63 if( i != PCB_ZONE_T && i != PCB_FP_ZONE_T )
64 s_allBasicItemsButZones.push_back( (KICAD_T) i );
65 }
66 }
67 }
68}
static std::vector< KICAD_T > s_allBasicItemsButZones
static std::vector< KICAD_T > s_allBasicItems
@ PCB_GROUP_T
class PCB_GROUP, a set of BOARD_ITEMs
Definition: typeinfo.h:115

References MAX_STRUCT_TYPE_ID, PCB_FOOTPRINT_T, PCB_FP_ZONE_T, PCB_GROUP_T, PCB_ZONE_T, DRC_TEST_PROVIDER::s_allBasicItems, and DRC_TEST_PROVIDER::s_allBasicItemsButZones.

Referenced by DRC_ENGINE::RunTests().

◆ isInvisibleText()

bool DRC_TEST_PROVIDER::isInvisibleText ( const BOARD_ITEM aItem) const
protectedinherited

Definition at line 346 of file drc_test_provider.cpp.

347{
348
349 if( const FP_TEXT* text = dyn_cast<const FP_TEXT*>( aItem ) )
350 {
351 if( !text->IsVisible() )
352 return true;
353 }
354
355 if( const PCB_TEXT* text = dyn_cast<const PCB_TEXT*>( aItem ) )
356 {
357 if( !text->IsVisible() )
358 return true;
359 }
360
361 return false;
362}

References text.

Referenced by DRC_TEST_PROVIDER_EDGE_CLEARANCE::Run(), DRC_TEST_PROVIDER_SILK_CLEARANCE::Run(), and DRC_TEST_PROVIDER_SOLDER_MASK::testSilkToMaskClearance().

◆ 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 }
constexpr EDA_IU_SCALE unityScale
Definition: base_units.h:112
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:319

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 }
EDA_UNITS GetUserUnits() const

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

Referenced by CheckLibSymbol(), checkSkews(), DIALOG_BOARD_REANNOTATE::CoordTowxString(), EDA_DRAW_FRAME::DisplayGridMsg(), GERBVIEW_FRAME::DisplayGridMsg(), PCB_BASE_FRAME::DisplayGridMsg(), GERBER_FILE_IMAGE::DisplayImageInfo(), DRAWING_TOOL::DrawBoardCharacteristics(), DRC_ENGINE::EvalRules(), DIALOG_NET_INSPECTOR::formatLength(), DRC_TEST_PROVIDER::formatMsg(), 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(), test::DRC_TEST_PROVIDER_DIFF_PAIR_COUPLING::Run(), runInternal(), DIALOG_BOARD_STATISTICS::saveReportClicked(), EDA_SHAPE::ShapeGetMsgPanelInfo(), showCoord(), 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().

◆ reportAux()

◆ reportPhase()

bool DRC_TEST_PROVIDER::reportPhase ( const wxString &  aStageName)
protectedvirtualinherited

◆ reportProgress()

bool DRC_TEST_PROVIDER::reportProgress ( int  aCount,
int  aSize,
int  aDelta 
)
protectedvirtualinherited

Definition at line 86 of file drc_test_provider.cpp.

87{
88 if( ( aCount % aDelta ) == 0 || aCount == aSize - 1 )
89 {
90 if( !m_drcEngine->ReportProgress( (double) aCount / (double) aSize ) )
91 return false;
92 }
93
94 return true;
95}
bool ReportProgress(double aProgress)

References DRC_TEST_PROVIDER::m_drcEngine, and DRC_ENGINE::ReportProgress().

Referenced by DRC_TEST_PROVIDER_SOLDER_MASK::buildRTrees(), DRC_CACHE_GENERATOR::Run(), DRC_TEST_PROVIDER_ANNULAR_WIDTH::Run(), DRC_TEST_PROVIDER_CONNECTIVITY::Run(), DRC_TEST_PROVIDER_DISALLOW::Run(), DRC_TEST_PROVIDER_EDGE_CLEARANCE::Run(), DRC_TEST_PROVIDER_HOLE_TO_HOLE::Run(), DRC_TEST_PROVIDER_LIBRARY_PARITY::Run(), DRC_TEST_PROVIDER_PHYSICAL_CLEARANCE::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(), runInternal(), 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_SOLDER_MASK::testMaskBridges(), DRC_TEST_PROVIDER_COPPER_CLEARANCE::testPadClearances(), DRC_TEST_PROVIDER_SOLDER_MASK::testSilkToMaskClearance(), DRC_TEST_PROVIDER_MISC::testTextVars(), DRC_TEST_PROVIDER_COPPER_CLEARANCE::testTrackClearances(), and DRC_TEST_PROVIDER_COPPER_CLEARANCE::testZonesToZones().

◆ reportRuleStatistics()

void DRC_TEST_PROVIDER::reportRuleStatistics ( )
protectedvirtualinherited

◆ reportViolation()

void DRC_TEST_PROVIDER::reportViolation ( std::shared_ptr< DRC_ITEM > &  item,
const VECTOR2I aMarkerPos,
int  aMarkerLayer 
)
protectedvirtualinherited

Definition at line 75 of file drc_test_provider.cpp.

77{
78 if( item->GetViolatingRule() )
79 accountCheck( item->GetViolatingRule() );
80
81 item->SetViolatingTest( this );
82 m_drcEngine->ReportViolation( item, aMarkerPos, aMarkerLayer );
83}
void ReportViolation(const std::shared_ptr< DRC_ITEM > &aItem, const VECTOR2I &aPos, int aMarkerLayer)

References DRC_TEST_PROVIDER::accountCheck(), DRC_TEST_PROVIDER::m_drcEngine, and DRC_ENGINE::ReportViolation().

Referenced by checkLengths(), DRC_TEST_PROVIDER_HOLE_SIZE::checkPadHole(), checkSkews(), checkViaCounts(), DRC_TEST_PROVIDER_HOLE_SIZE::checkViaHole(), DRC_TEST_PROVIDER_ANNULAR_WIDTH::Run(), DRC_TEST_PROVIDER_CONNECTION_WIDTH::Run(), DRC_TEST_PROVIDER_CONNECTIVITY::Run(), test::DRC_TEST_PROVIDER_DIFF_PAIR_COUPLING::Run(), DRC_TEST_PROVIDER_DISALLOW::Run(), DRC_TEST_PROVIDER_FOOTPRINT_CHECKS::Run(), DRC_TEST_PROVIDER_LIBRARY_PARITY::Run(), DRC_TEST_PROVIDER_SILK_CLEARANCE::Run(), DRC_TEST_PROVIDER_SLIVER_CHECKER::Run(), DRC_TEST_PROVIDER_TEXT_DIMS::Run(), DRC_TEST_PROVIDER_TRACK_WIDTH::Run(), DRC_TEST_PROVIDER_VIA_DIAMETER::Run(), DRC_TEST_PROVIDER_EDGE_CLEARANCE::testAgainstEdge(), 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_SOLDER_MASK::testItemAgainstItems(), DRC_TEST_PROVIDER_COPPER_CLEARANCE::testItemAgainstZone(), DRC_TEST_PROVIDER_PHYSICAL_CLEARANCE::testItemAgainstZones(), DRC_TEST_PROVIDER_SOLDER_MASK::testMaskItemAgainstZones(), DRC_TEST_PROVIDER_SCHEMATIC_PARITY::testNetlist(), DRC_TEST_PROVIDER_MISC::testOutline(), DRC_TEST_PROVIDER_COPPER_CLEARANCE::testPadAgainstItem(), DRC_TEST_PROVIDER_PHYSICAL_CLEARANCE::testShapeLineChain(), DRC_TEST_PROVIDER_MISC::testTextVars(), DRC_TEST_PROVIDER_COPPER_CLEARANCE::testTrackAgainstItem(), DRC_TEST_PROVIDER_ZONE_CONNECTIONS::testZoneLayer(), DRC_TEST_PROVIDER_PHYSICAL_CLEARANCE::testZoneLayer(), and DRC_TEST_PROVIDER_COPPER_CLEARANCE::testZonesToZones().

◆ Run()

bool DRC_TEST_PROVIDER_MATCHED_LENGTH::Run ( )
overridevirtual

Run this provider against the given PCB with configured options (if any).

Implements DRC_TEST_PROVIDER.

Definition at line 208 of file drc_test_provider_matched_length.cpp.

209{
210 return runInternal( false );
211}
bool runInternal(bool aDelayReportMode=false)

References runInternal().

◆ runInternal()

bool DRC_TEST_PROVIDER_MATCHED_LENGTH::runInternal ( bool  aDelayReportMode = false)
private

Definition at line 214 of file drc_test_provider_matched_length.cpp.

215{
217 m_report.Clear();
218
219 if( !aDelayReportMode )
220 {
221 if( !reportPhase( _( "Gathering length-constrained connections..." ) ) )
222 return false;
223 }
224
225 std::map<DRC_RULE*, std::set<BOARD_CONNECTED_ITEM*> > itemSets;
226
227 std::shared_ptr<FROM_TO_CACHE> ftCache = m_board->GetConnectivity()->GetFromToCache();
228
229 ftCache->Rebuild( m_board );
230
231 const size_t progressDelta = 100;
232 size_t count = 0;
233 size_t ii = 0;
234
236 [&]( BOARD_ITEM *item ) -> bool
237 {
238 count++;
239 return true;
240 } );
241
243 [&]( BOARD_ITEM *item ) -> bool
244 {
245 if( !reportProgress( ii++, count, progressDelta ) )
246 return false;
247
248 const DRC_CONSTRAINT_T constraintsToCheck[] = {
252 };
253
254 for( int i = 0; i < 3; i++ )
255 {
256 auto constraint = m_drcEngine->EvalRules( constraintsToCheck[i], item, nullptr,
257 item->GetLayer() );
258
259 if( constraint.IsNull() )
260 continue;
261
262 auto citem = static_cast<BOARD_CONNECTED_ITEM*>( item );
263
264 itemSets[ constraint.GetParentRule() ].insert( citem );
265 }
266
267 return true;
268 } );
269
270 std::map< DRC_RULE*, std::vector<CONNECTION> > matches;
271
272 for( const std::pair< DRC_RULE* const, std::set<BOARD_CONNECTED_ITEM*> >& it : itemSets )
273 {
274 std::map<int, std::set<BOARD_CONNECTED_ITEM*> > netMap;
275
276 for( BOARD_CONNECTED_ITEM* citem : it.second )
277 netMap[ citem->GetNetCode() ].insert( citem );
278
279 for( const std::pair< const int, std::set<BOARD_CONNECTED_ITEM*> >& nitem : netMap )
280 {
281 CONNECTION ent;
282 ent.items = nitem.second;
283 ent.netcode = nitem.first;
284 ent.netname = m_board->GetNetInfo().GetNetItem( ent.netcode )->GetNetname();
285
286 ent.viaCount = 0;
287 ent.totalRoute = 0;
288 ent.totalVia = 0;
289 ent.totalPadToDie = 0;
290 ent.fromItem = nullptr;
291 ent.toItem = nullptr;
292
293 for( BOARD_CONNECTED_ITEM* citem : nitem.second )
294 {
295 if( citem->Type() == PCB_VIA_T )
296 {
298 const BOARD_STACKUP& stackup = bds.GetStackupDescriptor();
299
300 ent.viaCount++;
301
303 {
304 const PCB_VIA* v = static_cast<PCB_VIA*>( citem );
305
306 ent.totalVia += stackup.GetLayerDistance( v->TopLayer(), v->BottomLayer() );
307 }
308 }
309 else if( citem->Type() == PCB_TRACE_T )
310 {
311 ent.totalRoute += static_cast<PCB_TRACK*>( citem )->GetLength();
312 }
313 else if ( citem->Type() == PCB_ARC_T )
314 {
315 ent.totalRoute += static_cast<PCB_ARC*>( citem )->GetLength();
316 }
317 else if( citem->Type() == PCB_PAD_T )
318 {
319 ent.totalPadToDie += static_cast<PAD*>( citem )->GetPadToDieLength();
320 }
321 }
322
323 ent.total = ent.totalRoute + ent.totalVia + ent.totalPadToDie;
324 ent.matchingRule = it.first;
325
326 // fixme: doesn't seem to work ;-)
327 auto ftPath = ftCache->QueryFromToPath( ent.items );
328
329 if( ftPath )
330 {
331 ent.from = ftPath->fromName;
332 ent.to = ftPath->toName;
333 }
334 else
335 {
336 ent.from = ent.to = _( "<unconstrained>" );
337 }
338
339 m_report.Add( ent );
340 matches[ it.first ].push_back(ent);
341 }
342 }
343
344 if( !aDelayReportMode )
345 {
346 if( !reportPhase( _( "Checking length constraints..." ) ) )
347 return false;
348
349 ii = 0;
350 count = matches.size();
351
352 for( std::pair< DRC_RULE* const, std::vector<CONNECTION> > it : matches )
353 {
354 DRC_RULE *rule = it.first;
355 auto& matchedConnections = it.second;
356
357 if( !reportProgress( ii++, count, progressDelta ) )
358 return false;
359
360 std::sort( matchedConnections.begin(), matchedConnections.end(),
361 [] ( const CONNECTION&a, const CONNECTION&b ) -> int
362 {
363 return a.netname < b.netname;
364 } );
365
366 reportAux( wxString::Format( wxT( "Length-constrained traces for rule '%s':" ),
367 it.first->m_Name ) );
368
369 for( const DRC_LENGTH_REPORT::ENTRY& ent : matchedConnections )
370 {
371 reportAux(wxString::Format( wxT( " - net: %s, from: %s, to: %s, "
372 "%d matching items, "
373 "total: %s (tracks: %s, vias: %s, pad-to-die: %s), "
374 "vias: %d" ),
375 ent.netname,
376 ent.from,
377 ent.to,
378 (int) ent.items.size(),
379 MessageTextFromValue( ent.total ),
380 MessageTextFromValue( ent.totalRoute ),
381 MessageTextFromValue( ent.totalVia ),
382 MessageTextFromValue( ent.totalPadToDie ),
383 ent.viaCount ) );
384 }
385
386
387 std::optional<DRC_CONSTRAINT> lengthConstraint = rule->FindConstraint( LENGTH_CONSTRAINT );
388
389 if( lengthConstraint && lengthConstraint->GetSeverity() != RPT_SEVERITY_IGNORE )
390 checkLengths( *lengthConstraint, matchedConnections );
391
392 std::optional<DRC_CONSTRAINT> skewConstraint = rule->FindConstraint( SKEW_CONSTRAINT );
393
394 if( skewConstraint && skewConstraint->GetSeverity() != RPT_SEVERITY_IGNORE )
395 checkSkews( *skewConstraint, matchedConnections );
396
397 std::optional<DRC_CONSTRAINT> viaCountConstraint = rule->FindConstraint( VIA_COUNT_CONSTRAINT );
398
399 if( viaCountConstraint && viaCountConstraint->GetSeverity() != RPT_SEVERITY_IGNORE )
400 checkViaCounts( *viaCountConstraint, matchedConnections );
401 }
402
404 }
405
406 return !m_drcEngine->IsCancelled();
407}
Container for design settings for a BOARD object.
BOARD_STACKUP & GetStackupDescriptor()
bool m_UseHeightForLengthCalcs
Enable inclusion of stackup height in track length measurements and length tuning.
Manage layers needed to make a physical board.
int GetLayerDistance(PCB_LAYER_ID aFirstLayer, PCB_LAYER_ID aSecondLayer) const
Calculate the distance (height) between the two given copper layers.
const NETINFO_LIST & GetNetInfo() const
Definition: board.h:765
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.cpp:643
std::shared_ptr< CONNECTIVITY_DATA > GetConnectivity() const
Return a list of missing connections between components/tracks.
Definition: board.h:424
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
bool IsCancelled() const
void Add(const ENTRY &ent)
std::optional< DRC_CONSTRAINT > FindConstraint(DRC_CONSTRAINT_T aType)
Definition: drc_rule.cpp:65
void checkSkews(const DRC_CONSTRAINT &aConstraint, const std::vector< CONNECTION > &aMatchedConnections)
void checkViaCounts(const DRC_CONSTRAINT &aConstraint, const std::vector< CONNECTION > &aMatchedConnections)
void checkLengths(const DRC_CONSTRAINT &aConstraint, const std::vector< CONNECTION > &aMatchedConnections)
virtual bool reportPhase(const wxString &aStageName)
int forEachGeometryItem(const std::vector< KICAD_T > &aTypes, LSET aLayers, const std::function< bool(BOARD_ITEM *)> &aFunc)
virtual bool reportProgress(int aCount, int aSize, int aDelta)
virtual void reportRuleStatistics()
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:97
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition: lset.cpp:773
const wxString & GetNetname() const
Definition: netinfo.h:119
NETINFO_ITEM * GetNetItem(int aNetCode) const
PCB_LAYER_ID BottomLayer() const
Definition: pcb_track.cpp:570
PCB_LAYER_ID TopLayer() const
Definition: pcb_track.cpp:564
DRC_CONSTRAINT_T
Definition: drc_rule.h:44
@ LENGTH_CONSTRAINT
Definition: drc_rule.h:63
@ VIA_COUNT_CONSTRAINT
Definition: drc_rule.h:68
@ SKEW_CONSTRAINT
Definition: drc_rule.h:64
@ RPT_SEVERITY_IGNORE
std::set< BOARD_CONNECTED_ITEM * > items

References _, DRC_LENGTH_REPORT::Add(), LSET::AllCuMask(), PCB_VIA::BottomLayer(), checkLengths(), checkSkews(), checkViaCounts(), DRC_LENGTH_REPORT::Clear(), DRC_ENGINE::EvalRules(), DRC_RULE::FindConstraint(), DRC_TEST_PROVIDER::forEachGeometryItem(), Format(), DRC_LENGTH_REPORT::ENTRY::from, DRC_LENGTH_REPORT::ENTRY::fromItem, DRC_ENGINE::GetBoard(), BOARD::GetConnectivity(), BOARD::GetDesignSettings(), BOARD_STACKUP::GetLayerDistance(), BOARD_CONNECTED_ITEM::GetNetCode(), BOARD::GetNetInfo(), NETINFO_LIST::GetNetItem(), NETINFO_ITEM::GetNetname(), BOARD_DESIGN_SETTINGS::GetStackupDescriptor(), DRC_ENGINE::IsCancelled(), DRC_LENGTH_REPORT::ENTRY::items, LENGTH_CONSTRAINT, m_board, DRC_TEST_PROVIDER::m_drcEngine, m_report, BOARD_DESIGN_SETTINGS::m_UseHeightForLengthCalcs, DRC_LENGTH_REPORT::ENTRY::matchingRule, UNITS_PROVIDER::MessageTextFromValue(), DRC_LENGTH_REPORT::ENTRY::netcode, DRC_LENGTH_REPORT::ENTRY::netname, PCB_ARC_T, PCB_PAD_T, PCB_TRACE_T, PCB_VIA_T, DRC_TEST_PROVIDER::reportAux(), DRC_TEST_PROVIDER::reportPhase(), DRC_TEST_PROVIDER::reportProgress(), DRC_TEST_PROVIDER::reportRuleStatistics(), RPT_SEVERITY_IGNORE, SKEW_CONSTRAINT, DRC_LENGTH_REPORT::ENTRY::to, DRC_LENGTH_REPORT::ENTRY::toItem, PCB_VIA::TopLayer(), DRC_LENGTH_REPORT::ENTRY::total, DRC_LENGTH_REPORT::ENTRY::totalPadToDie, DRC_LENGTH_REPORT::ENTRY::totalRoute, DRC_LENGTH_REPORT::ENTRY::totalVia, EDA_ITEM::Type(), VIA_COUNT_CONSTRAINT, and DRC_LENGTH_REPORT::ENTRY::viaCount.

Referenced by Run().

◆ RunTests()

bool DRC_TEST_PROVIDER::RunTests ( EDA_UNITS  aUnits)
inlineinherited

Definition at line 88 of file drc_test_provider.h.

89 {
90 SetUserUnits( aUnits );
91 return Run();
92 }
virtual bool Run()=0
Run this provider against the given PCB with configured options (if any).
void SetUserUnits(EDA_UNITS aUnits)

References DRC_TEST_PROVIDER::Run(), and UNITS_PROVIDER::SetUserUnits().

◆ SetDRCEngine()

void DRC_TEST_PROVIDER::SetDRCEngine ( DRC_ENGINE engine)
inlineinherited

◆ SetUserUnits()

◆ 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:229

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 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(), DRC_TEST_PROVIDER::formatMsg(), PIN_TABLE_DATA_MODEL::GetValue(), FP_TEXT_GRID_TABLE::GetValue(), BOARD_INSPECTION_TOOL::InspectClearance(), BOARD_INSPECTION_TOOL::InspectDRCError(), PANEL_SETUP_BOARD_STACKUP::onAdjustDielectricThickness(), WX_GRID::onCellEditorHidden(), DIALOG_TRACK_VIA_PROPERTIES::onUnitsChanged(), reportMax(), reportMin(), reportOpt(), PANEL_SETUP_BOARD_STACKUP::setDefaultLayerWidths(), WX_GRID::SetUnitValue(), PANEL_SETUP_BOARD_STACKUP::synchronizeWithBoard(), DIALOG_GRID_SETTINGS::TransferDataFromWindow(), PANEL_SETUP_CONSTRAINTS::TransferDataToWindow(), DIALOG_FOOTPRINT_PROPERTIES::Validate(), and DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::Validate().

◆ userUnits()

EDA_UNITS DRC_TEST_PROVIDER::userUnits ( ) const
protectedinherited

◆ ValueFromString()

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

Member Data Documentation

◆ m_board

BOARD* DRC_TEST_PROVIDER_MATCHED_LENGTH::m_board
private

Definition at line 84 of file drc_test_provider_matched_length.cpp.

Referenced by runInternal().

◆ m_drcEngine

DRC_ENGINE* DRC_TEST_PROVIDER::m_drcEngine
protectedinherited

Definition at line 128 of file drc_test_provider.h.

Referenced by DRC_TEST_PROVIDER_HOLE_SIZE::checkPadHole(), DRC_TEST_PROVIDER_HOLE_SIZE::checkViaHole(), DRC_TEST_PROVIDER::forEachGeometryItem(), DRC_TEST_PROVIDER_CONNECTION_WIDTH::layerDesc(), DRC_TEST_PROVIDER_SLIVER_CHECKER::layerDesc(), DRC_TEST_PROVIDER::reportAux(), DRC_TEST_PROVIDER::reportPhase(), DRC_TEST_PROVIDER::reportProgress(), DRC_TEST_PROVIDER::reportRuleStatistics(), DRC_TEST_PROVIDER::reportViolation(), DRC_CACHE_GENERATOR::Run(), DRC_INTERACTIVE_COURTYARD_CLEARANCE::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_COURTYARD_CLEARANCE::Run(), test::DRC_TEST_PROVIDER_DIFF_PAIR_COUPLING::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_SCHEMATIC_PARITY::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_ZONE_CONNECTIONS::Run(), runInternal(), DRC_TEST_PROVIDER::SetDRCEngine(), DRC_TEST_PROVIDER_EDGE_CLEARANCE::testAgainstEdge(), 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_SOLDER_MASK::testItemAgainstItems(), DRC_TEST_PROVIDER_COPPER_CLEARANCE::testItemAgainstZone(), DRC_TEST_PROVIDER_PHYSICAL_CLEARANCE::testItemAgainstZones(), DRC_TEST_PROVIDER_SOLDER_MASK::testMaskBridges(), DRC_TEST_PROVIDER_SOLDER_MASK::testMaskItemAgainstZones(), DRC_TEST_PROVIDER_SCHEMATIC_PARITY::testNetlist(), DRC_TEST_PROVIDER_COPPER_CLEARANCE::testPadAgainstItem(), DRC_TEST_PROVIDER_COPPER_CLEARANCE::testPadClearances(), DRC_TEST_PROVIDER_SOLDER_MASK::testSilkToMaskClearance(), 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().

◆ m_isRuleDriven

◆ m_iuScale

const EDA_IU_SCALE& UNITS_PROVIDER::m_iuScale
privateinherited

Definition at line 113 of file units_provider.h.

Referenced by UNITS_PROVIDER::GetIuScale().

◆ m_report

DRC_LENGTH_REPORT DRC_TEST_PROVIDER_MATCHED_LENGTH::m_report
private

Definition at line 85 of file drc_test_provider_matched_length.cpp.

Referenced by runInternal().

◆ m_stats

std::unordered_map<const DRC_RULE*, int> DRC_TEST_PROVIDER::m_stats
protectedinherited

◆ m_userUnits

EDA_UNITS UNITS_PROVIDER::m_userUnits
privateinherited

Definition at line 114 of file units_provider.h.

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

◆ s_allBasicItems

◆ s_allBasicItemsButZones

std::vector< KICAD_T > DRC_TEST_PROVIDER::s_allBasicItemsButZones
staticprotectedinherited

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