62 virtual bool Run()
override;
64 virtual const wxString
GetName()
const override
66 return wxT(
"edge_clearance" );
71 return wxT(
"Tests items vs board edge clearance" );
89 std::shared_ptr<SHAPE> shape;
103 if( itemShape->
Collide( shape.get(), minClearance, &actual, &pos ) )
106 if( minClearance > 0 && actual == minClearance )
114 if( castellatedPad->GetEffectiveHoleShape()->Collide( pos ) )
122 if( minClearance > 0 )
124 wxString msg =
formatMsg(
_(
"(%s clearance %s; actual %s)" ),
125 constraint.GetName(),
129 drce->SetErrorMessage( drce->GetErrorText() + wxS(
" " ) + msg );
133 drce->SetViolatingRule( constraint.GetParentRule() );
148 if( !
reportPhase(
_(
"Checking copper to board edge clearances..." ) ) )
153 if( !
reportPhase(
_(
"Checking silk to board edge clearances..." ) ) )
158 reportAux( wxT(
"Edge clearance violations ignored. Tests not run." ) );
175 std::vector<std::unique_ptr<PCB_SHAPE>> edges;
192 edges.back()->SetShape( SHAPE_T::SEGMENT );
193 edges.back()->SetEndX( shape->
GetStartX() );
194 edges.back()->SetStroke( stroke );
195 edges.back()->SetParentGroup(
nullptr );
197 edges.back()->SetShape( SHAPE_T::SEGMENT );
198 edges.back()->SetEndY( shape->
GetStartY() );
199 edges.back()->SetStroke( stroke );
200 edges.back()->SetParentGroup(
nullptr );
202 edges.back()->SetShape( SHAPE_T::SEGMENT );
203 edges.back()->SetStartX( shape->
GetEndX() );
204 edges.back()->SetStroke( stroke );
205 edges.back()->SetParentGroup(
nullptr );
207 edges.back()->SetShape( SHAPE_T::SEGMENT );
208 edges.back()->SetStartY( shape->
GetEndY() );
209 edges.back()->SetStroke( stroke );
210 edges.back()->SetParentGroup(
nullptr );
222 edges.back()->SetShape( SHAPE_T::SEGMENT );
223 edges.back()->SetStart( seg.
A );
224 edges.back()->SetEnd( seg.
B );
225 edges.back()->SetStroke( stroke );
226 edges.back()->SetParentGroup(
nullptr );
232 edges.back()->SetStroke( stroke );
233 edges.back()->SetParentGroup(
nullptr );
239 for(
const std::unique_ptr<PCB_SHAPE>& edge : edges )
243 if( edge->IsOnLayer( layer ) )
250 for(
PAD*
pad : footprint->Pads() )
252 if(
pad->GetAttribute() == PAD_ATTRIB::NPTH &&
pad->HasHole() )
256 if(
pad->GetDrillSizeX() !=
pad->GetDrillSizeY() )
260 if(
pad->GetProperty() == PAD_PROP::CASTELLATED )
268 const int progressDelta = 200;
285 if( !testCopper && !testSilk )
296 PAD* pad = static_cast<PAD*>( item );
298 if( pad->GetProperty() == PAD_PROP::CASTELLATED
299 || pad->GetAttribute() == PAD_ATTRIB::CONN )
311 edgesTree.QueryColliding( item, UNDEFINED_LAYER, testLayer, nullptr,
312 [&]( BOARD_ITEM* edge ) -> bool
314 return testAgainstEdge( item, itemShape.get(), edge,
315 EDGE_CLEARANCE_CONSTRAINT,
316 DRCE_EDGE_CLEARANCE );
326 return testAgainstEdge( item, itemShape.get(), edge,
327 SILK_CLEARANCE_CONSTRAINT,
328 DRCE_SILK_EDGE_CLEARANCE );
344 reportRuleStatistics();
346 return !m_drcEngine->IsCancelled();
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
virtual bool IsOnLayer(PCB_LAYER_ID aLayer) const
Test to see if this object is on the given layer.
virtual std::shared_ptr< SHAPE > GetEffectiveShape(PCB_LAYER_ID aLayer=UNDEFINED_LAYER, FLASHING aFlash=FLASHING::DEFAULT) const
Some pad shapes can be complex (rounded/chamfered rectangle), even without considering custom shapes.
virtual bool IsOnCopperLayer() const
virtual std::shared_ptr< SHAPE_SEGMENT > GetEffectiveHoleShape() const
FOOTPRINTS & Footprints()
const MINOPTMAX< int > & GetValue() const
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)
bool QueryWorstConstraint(DRC_CONSTRAINT_T aRuleId, DRC_CONSTRAINT &aConstraint)
static std::shared_ptr< DRC_ITEM > Create(int aErrorCode)
Constructs a DRC_ITEM for the given error code.
Implement an R-tree for fast spatial and layer indexing of connectable items.
void Insert(BOARD_ITEM *aItem, PCB_LAYER_ID aLayer, int aWorstClearance=0)
Insert an item into the tree on a particular layer with an optional worst clearance.
int QueryColliding(BOARD_ITEM *aRefItem, PCB_LAYER_ID aRefLayer, PCB_LAYER_ID aTargetLayer, std::function< bool(BOARD_ITEM *)> aFilter=nullptr, std::function< bool(BOARD_ITEM *)> aVisitor=nullptr, int aClearance=0) const
This is a fast test which essentially does bounding-box overlap given a worst-case clearance.
DRC_TEST_PROVIDER_EDGE_CLEARANCE()
virtual const wxString GetDescription() const override
int m_largestEdgeClearance
virtual bool Run() override
Run this provider against the given PCB with configured options (if any).
virtual ~DRC_TEST_PROVIDER_EDGE_CLEARANCE()
virtual const wxString GetName() const override
std::vector< PAD * > m_castellatedPads
bool testAgainstEdge(BOARD_ITEM *item, SHAPE *itemShape, BOARD_ITEM *other, DRC_CONSTRAINT_T aConstraintType, PCB_DRC_CODE aErrorCode)
static std::vector< KICAD_T > s_allBasicItemsButZones
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 reportViolation(std::shared_ptr< DRC_ITEM > &item, const VECTOR2I &aMarkerPos, int aMarkerLayer)
bool isInvisibleText(const BOARD_ITEM *aItem) const
void reportAux(const wxString &aMsg)
wxString formatMsg(const wxString &aFormatString, const wxString &aSource, int aConstraint, int aActual)
KICAD_T Type() const
Returns the type of object.
SHAPE_POLY_SET & GetPolyShape()
LSET is a set of PCB_LAYER_IDs.
static LSET AllLayersMask()
STROKE_PARAMS GetStroke() const override
virtual EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
virtual size_t GetSegmentCount() const override
const SEG CSegment(int aIndex) const
Return a constant copy of the aIndex segment in the line chain.
SHAPE_LINE_CHAIN & Outline(int aIndex)
Return the reference to aIndex-th outline in the set.
An abstract shape on 2D plane.
virtual bool Collide(const VECTOR2I &aP, int aClearance=0, int *aActual=nullptr, VECTOR2I *aLocation=nullptr) const
Check if the boundary of shape (this) lies closer to the point aP than aClearance,...
Simple container to manage line stroke parameters.
void SetWidth(int aWidth)
@ DRCE_SILK_EDGE_CLEARANCE
@ EDGE_CLEARANCE_CONSTRAINT
PCB_LAYER_ID
A quick note on layer IDs:
static DRC_REGISTER_TEST_PROVIDER< DRC_TEST_PROVIDER_ANNULAR_WIDTH > dummy
@ PCB_SHAPE_T
class PCB_SHAPE, a segment not on copper layers
@ PCB_PAD_T
class PAD, a pad in a footprint
@ PCB_ARC_T
class PCB_ARC, an arc track segment on a copper layer
@ PCB_TRACE_T
class PCB_TRACK, a track segment (segment on a copper layer)