53 virtual bool Run()
override;
55 virtual const wxString
GetName()
const override {
return wxT(
"edge_clearance" ); }
72 std::shared_ptr<SHAPE> shape;
86 if( itemShape->
Collide( shape.get(), minClearance, &
actual, &pos ) )
89 if( minClearance > 0 &&
actual == minClearance )
97 if( castellatedPad->GetEffectiveHoleShape()->Collide( pos ) )
105 if( minClearance > 0 )
107 wxString msg =
formatMsg(
_(
"(%s clearance %s; actual %s)" ),
108 constraint.GetName(),
112 drce->SetErrorMessage( drce->GetErrorText() + wxS(
" " ) + msg );
116 drce->SetViolatingRule( constraint.GetParentRule() );
135 if( !
reportPhase(
_(
"Checking copper to board edge clearances..." ) ) )
140 if( !
reportPhase(
_(
"Checking silk to board edge clearances..." ) ) )
145 REPORT_AUX( wxT(
"Edge clearance violations ignored. Tests not run." ) );
160 std::vector<std::unique_ptr<PCB_SHAPE>> edges;
177 edges.back()->SetShape( SHAPE_T::SEGMENT );
178 edges.back()->SetEndX( shape->
GetStartX() );
179 edges.back()->SetStroke( stroke );
181 edges.back()->SetShape( SHAPE_T::SEGMENT );
182 edges.back()->SetEndY( shape->
GetStartY() );
183 edges.back()->SetStroke( stroke );
185 edges.back()->SetShape( SHAPE_T::SEGMENT );
186 edges.back()->SetStartX( shape->
GetEndX() );
187 edges.back()->SetStroke( stroke );
189 edges.back()->SetShape( SHAPE_T::SEGMENT );
190 edges.back()->SetStartY( shape->
GetEndY() );
191 edges.back()->SetStroke( stroke );
203 edges.back()->SetShape( SHAPE_T::SEGMENT );
204 edges.back()->SetStart( seg.
A );
205 edges.back()->SetEnd( seg.
B );
206 edges.back()->SetStroke( stroke );
212 edges.back()->SetStroke( stroke );
218 for(
const std::unique_ptr<PCB_SHAPE>& edge : edges )
222 if( edge->IsOnLayer( layer ) )
229 for(
PAD*
pad : footprint->Pads() )
231 if(
pad->GetAttribute() == PAD_ATTRIB::NPTH &&
pad->HasHole() )
235 if(
pad->GetDrillSizeX() !=
pad->GetDrillSizeY() )
239 if(
pad->GetProperty() == PAD_PROP::CASTELLATED )
247 const int progressDelta = 200;
264 if( !testCopper && !testSilk )
275 PAD* pad = static_cast<PAD*>( item );
277 if( pad->GetProperty() == PAD_PROP::CASTELLATED || pad->GetAttribute() == PAD_ATTRIB::CONN )
281 std::vector<PCB_LAYER_ID> layersToTest;
283 switch( item->
Type() )
286 layersToTest = static_cast<PAD*>( item )->Padstack().UniqueLayers();
290 layersToTest = static_cast<PCB_VIA*>( item )->Padstack().UniqueLayers();
294 layersToTest = { UNDEFINED_LAYER };
305 edgesTree.QueryColliding( item, shapeLayer, testLayer, nullptr,
306 [&]( BOARD_ITEM* edge ) -> bool
308 return testAgainstEdge( item, itemShape.get(), edge,
309 EDGE_CLEARANCE_CONSTRAINT,
310 DRCE_EDGE_CLEARANCE );
317 if( edgesTree.
QueryColliding( item, shapeLayer, testLayer,
nullptr,
320 return testAgainstEdge( item, itemShape.get(), edge,
321 SILK_CLEARANCE_CONSTRAINT,
322 DRCE_SILK_EDGE_CLEARANCE );
339 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
const FOOTPRINTS & Footprints() const
const MINOPTMAX< int > & GetValue() const
bool GetReportAllTrackErrors() 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()
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()=default
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)
virtual void reportViolation(std::shared_ptr< DRC_ITEM > &item, const VECTOR2I &aMarkerPos, int aMarkerLayer, DRC_CUSTOM_MARKER_HANDLER *aCustomHandler=nullptr)
int forEachGeometryItem(const std::vector< KICAD_T > &aTypes, const LSET &aLayers, const std::function< bool(BOARD_ITEM *)> &aFunc)
bool isInvisibleText(const BOARD_ITEM *aItem) const
wxString formatMsg(const wxString &aFormatString, const wxString &aSource, double aConstraint, double aActual, EDA_DATA_TYPE aDataType=EDA_DATA_TYPE::DISTANCE)
virtual bool reportProgress(size_t aCount, size_t aSize, size_t aDelta=1)
KICAD_T Type() const
Returns the type of object.
SHAPE_POLY_SET & GetPolyShape()
LSET is a set of PCB_LAYER_IDs.
static const LSET & AllLayersMask()
STROKE_PARAMS GetStroke() const override
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)