58 virtual bool Run()
override;
60 virtual const wxString
GetName()
const override
62 return wxT(
"annular_width" );
67 return wxT(
"Tests pad/via annular rings" );
76 reportAux( wxT(
"Annular width violations ignored. Skipping check." ) );
80 const int progressDelta = 500;
84 reportAux( wxT(
"No annular width constraints found. Tests not run." ) );
88 if( !
reportPhase(
_(
"Checking pad & via annular rings..." ) ) )
96 switch( item->Type() )
105 if( !
pad->HasHole() ||
pad->GetAttribute() != PAD_ATTRIB::PTH )
110 switch(
pad->GetShape() )
112 case PAD_SHAPE::CHAMFERED_RECT:
113 if(
pad->GetChamferRectRatio() > 0.30 )
118 case PAD_SHAPE::CIRCLE:
119 case PAD_SHAPE::OVAL:
120 case PAD_SHAPE::RECTANGLE:
121 case PAD_SHAPE::ROUNDRECT:
137 auto checkAnnularWidth =
143 int annularWidth = 0;
145 switch( item->Type() )
150 annularWidth = (
via->GetWidth() -
via->GetDrillValue() ) / 2;
157 bool handled =
false;
159 if( !
pad->HasHole() ||
pad->GetAttribute() != PAD_ATTRIB::PTH )
164 switch(
pad->GetShape() )
166 case PAD_SHAPE::CHAMFERED_RECT:
167 if(
pad->GetChamferRectRatio() > 0.30 )
172 case PAD_SHAPE::CIRCLE:
173 case PAD_SHAPE::OVAL:
174 case PAD_SHAPE::RECTANGLE:
175 case PAD_SHAPE::ROUNDRECT:
176 annularWidth = std::min(
pad->GetSizeX() -
pad->GetDrillSizeX(),
177 pad->GetSizeY() -
pad->GetDrillSizeY() ) / 2;
194 if( !padOutline.
Collide(
pad->GetPosition() ) )
201 std::shared_ptr<SHAPE_SEGMENT> slot =
pad->GetEffectiveHoleShape();
207 annularWidth = sqrt( dist_sq ) - slot->GetWidth() / 2;
223 bool fail_min =
false;
224 bool fail_max =
false;
229 if( constraint.Value().HasMin() )
232 fail_min = annularWidth < v_min;
235 if( constraint.Value().HasMax() )
237 v_max = constraint.Value().Max();
238 fail_max = annularWidth > v_max;
241 if( fail_min || fail_max )
248 msg =
formatMsg(
_(
"(%s min annular width %s; actual %s)" ),
249 constraint.GetName(),
256 msg =
formatMsg(
_(
"(%s max annular width %s; actual %s)" ),
257 constraint.GetName(),
262 drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS(
" " ) + msg );
263 drcItem->SetItems( item );
264 drcItem->SetViolatingRule( constraint.GetParentRule() );
277 total += calcEffort( item );
281 for(
PAD*
pad : footprint->Pads() )
282 total += calcEffort(
pad );
287 ii += calcEffort( item );
292 if( !checkAnnularWidth( item ) )
298 for(
PAD*
pad : footprint->Pads() )
300 ii += calcEffort(
pad );
305 if( !checkAnnularWidth(
pad ) )
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Information pertinent to a Pcbnew printed circuit board.
FOOTPRINTS & Footprints()
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
MINOPTMAX< int > & Value()
bool HasRulesForConstraintType(DRC_CONSTRAINT_T constraintID)
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)
static std::shared_ptr< DRC_ITEM > Create(int aErrorCode)
Constructs a DRC_ITEM for the given error code.
DRC_TEST_PROVIDER_ANNULAR_WIDTH()
virtual bool Run() override
Run this provider against the given PCB with configured options (if any).
virtual ~DRC_TEST_PROVIDER_ANNULAR_WIDTH()
virtual const wxString GetDescription() const override
virtual const wxString GetName() const override
Represent a DRC "provider" which runs some DRC functions over a BOARD and spits out DRC_ITEM and posi...
wxString formatMsg(const wxString &aFormatString, const wxString &aSource, double aConstraint, double aActual)
virtual bool reportPhase(const wxString &aStageName)
virtual bool reportProgress(int aCount, int aSize, int aDelta)
virtual void reportViolation(std::shared_ptr< DRC_ITEM > &item, const VECTOR2I &aMarkerPos, int aMarkerLayer)
void reportAux(const wxString &aMsg)
virtual void reportRuleStatistics()
VECTOR2I::extended_type ecoord
void SetClosed(bool aClosed)
Mark the line chain as closed (i.e.
Represent a set of closed polygons.
bool Collide(const SHAPE *aShape, int aClearance=0, int *aActual=nullptr, VECTOR2I *aLocation=nullptr) const override
Check if the boundary of shape (this) lies closer to the shape aShape than aClearance,...
SHAPE_LINE_CHAIN & Outline(int aIndex)
Return the reference to aIndex-th outline in the set.
SEG::ecoord SquaredDistanceToSeg(const SEG &aSegment, VECTOR2I *aNearest=nullptr) const
Compute the minimum distance squared between aSegment and all the polygons in the set.
@ ANNULAR_WIDTH_CONSTRAINT
This file contains miscellaneous commonly used macros and functions.
#define KI_FALLTHROUGH
The KI_FALLTHROUGH macro is to be used when switch statement cases should purposely fallthrough from ...
static DRC_REGISTER_TEST_PROVIDER< DRC_TEST_PROVIDER_ANNULAR_WIDTH > dummy
@ PCB_VIA_T
class PCB_VIA, a via (like a track segment on a copper layer)
@ PCB_PAD_T
class PAD, a pad in a footprint