58 virtual bool Run()
override;
60 virtual const wxString
GetName()
const override
62 return wxT(
"library_parity" );
67 return wxT(
"Performs board footprint vs library integity checks" );
72#define TEST( a, b ) { if( a != b ) return true; }
73#define TEST_PADS( a, b ) { if( padsNeedUpdate( a, b ) ) return true; }
74#define TEST_SHAPES( a, b ) { if( shapesNeedUpdate( a, b ) ) return true; }
75#define TEST_PRIMITIVES( a, b ) { if( primitivesNeedUpdate( a, b ) ) return true; }
76#define TEST_ZONES( a, b ) { if( zonesNeedUpdate( a, b ) ) return true; }
77#define TEST_MODELS( a, b ) { if( modelsNeedUpdate( a, b ) ) return true; }
79#define EPSILON 0.000001
80#define TEST_D( a, b ) { if( abs( a - b ) > EPSILON ) return true; }
83 const std::shared_ptr<PCB_SHAPE>& b )
85 TEST( a->GetShape(), b->GetShape() );
87 switch( a->GetShape() )
92 TEST( a->GetStart(), b->GetStart() );
93 TEST( a->GetEnd(), b->GetEnd() );
97 TEST( a->GetStart(), b->GetStart() );
98 TEST( a->GetEnd(), b->GetEnd() );
99 TEST( a->GetCenter(), b->GetCenter() );
100 TEST_D( a->GetArcAngle().AsDegrees(), b->GetArcAngle().AsDegrees() );
104 TEST( a->GetStart(), b->GetStart() );
105 TEST( a->GetEnd(), b->GetEnd() );
106 TEST( a->GetBezierC1(), b->GetBezierC1() );
107 TEST( a->GetBezierC2(), b->GetBezierC2() );
111 TEST( a->GetPolyShape().TotalVertices(), b->GetPolyShape().TotalVertices() );
113 for(
int ii = 0; ii < a->GetPolyShape().TotalVertices(); ++ii )
114 TEST( a->GetPolyShape().CVertex( ii ), b->GetPolyShape().CVertex( ii ) );
122 TEST( a->GetStroke(), b->GetStroke() );
123 TEST( a->IsFilled(), b->IsFilled() );
152 TEST( aLayers, bLayers );
236 for(
int ii = 0; ii < a->
GetPolyShape().TotalVertices(); ++ii )
335#define TEST_V3D( a, b ) { TEST_D( a.x, b.x ); TEST_D( a.y, b.y ); TEST_D( a.z, b.z ); }
350#define TEST_ATTR( a, b, attr ) TEST( ( a & attr ), ( b & attr ) );
351 wxASSERT( aLibFootprint );
355 std::unique_ptr<FOOTPRINT> temp(
static_cast<FOOTPRINT*
>(
Clone() ) );
356 temp->Flip( {0,0}, false );
357 temp->SetParentGroup(
nullptr );
358 return temp->FootprintNeedsUpdate( aLibFootprint );
406 std::set<BOARD_ITEM*, FOOTPRINT::cmp_drawings> aShapes;
408 std::inserter( aShapes, aShapes.begin() ),
411 return item->Type() == PCB_FP_SHAPE_T;
413 std::set<BOARD_ITEM*, FOOTPRINT::cmp_drawings> bShapes;
415 std::inserter( bShapes, bShapes.begin() ),
418 return item->Type() == PCB_FP_SHAPE_T;
421 std::set<PAD*, FOOTPRINT::cmp_pads> aPads(
Pads().begin(),
Pads().end() );
422 std::set<PAD*, FOOTPRINT::cmp_pads> bPads( aLibFootprint->
Pads().begin(), aLibFootprint->
Pads().end() );
424 std::set<FP_ZONE*, FOOTPRINT::cmp_zones> aZones(
Zones().begin(),
Zones().end() );
425 std::set<FP_ZONE*, FOOTPRINT::cmp_zones> bZones( aLibFootprint->
Zones().begin(), aLibFootprint->
Zones().end() );
427 TEST( aPads.size(), bPads.size() );
428 TEST( aZones.size(), bZones.size() );
429 TEST( aShapes.size(), bShapes.size() );
431 for(
auto aIt = aPads.begin(), bIt = bPads.begin(); aIt != aPads.end(); aIt++, bIt++ )
434 for(
auto aIt = aShapes.begin(), bIt = bShapes.begin(); aIt != aShapes.end(); aIt++, bIt++ )
440 for(
auto aIt = aZones.begin(), bIt = bZones.begin(); aIt != aZones.end(); aIt++, bIt++ )
445 for(
size_t ii = 0; ii <
Models().size(); ++ii )
459 reportAux(
_(
"No project loaded, skipping library parity tests." ) );
463 if( !
reportPhase(
_(
"Loading footprint library table..." ) ) )
466 std::map<LIB_ID, std::shared_ptr<FOOTPRINT>> libFootprintCache;
471 const int progressDelta = 250;
473 if( !
reportPhase(
_(
"Checking board footprints against library..." ) ) )
487 LIB_ID fpID = footprint->GetFPID();
494 libTableRow = libTable->
FindRow( libName );
505 msg.Printf(
_(
"The current configuration does not include the library '%s'." ),
507 drcItem->SetErrorMessage( msg );
508 drcItem->SetItems( footprint );
514 else if( !libTable->
HasLibrary( libName,
true ) )
519 msg.Printf(
_(
"The library '%s' is not enabled in the current configuration." ),
521 drcItem->SetErrorMessage( msg );
522 drcItem->SetItems( footprint );
529 auto cacheIt = libFootprintCache.find( fpID );
530 std::shared_ptr<FOOTPRINT> libFootprint;
532 if( cacheIt != libFootprintCache.end() )
534 libFootprint = cacheIt->second;
540 libFootprint.reset( libTable->
FootprintLoad( libName, fpName,
true ) );
543 libFootprintCache[ fpID ] = libFootprint;
555 msg.Printf(
_(
"Footprint '%s' not found in library '%s'." ),
558 drcItem->SetErrorMessage( msg );
559 drcItem->SetItems( footprint );
563 else if( footprint->FootprintNeedsUpdate( libFootprint.get() ) )
568 msg.Printf(
_(
"Footprint '%s' does not match copy in library '%s'." ),
571 drcItem->SetErrorMessage( msg );
572 drcItem->SetItems( footprint );
constexpr EDA_IU_SCALE pcbIUScale
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
virtual const BOARD * GetBoard() const
Return the BOARD in which this BOARD_ITEM resides, or NULL if none.
BOARD_ITEM_CONTAINER * GetParentFootprint() const
Information pertinent to a Pcbnew printed circuit board.
LSET GetEnabledLayers() const
A proxy function that calls the corresponding function in m_BoardSettings.
FOOTPRINTS & Footprints()
PROJECT * GetProject() const
bool IsErrorLimitExceeded(int error_code)
static std::shared_ptr< DRC_ITEM > Create(int aErrorCode)
Constructs a DRC_ITEM for the given error code.
virtual const wxString GetDescription() const override
virtual ~DRC_TEST_PROVIDER_LIBRARY_PARITY()
virtual bool Run() override
Run this provider against the given PCB with configured options (if any).
virtual const wxString GetName() const override
DRC_TEST_PROVIDER_LIBRARY_PARITY()
Represent a DRC "provider" which runs some DRC functions over a BOARD and spits out #DRC_ITEMs and po...
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)
virtual void reportAux(wxString fmt,...)
SHAPE_POLY_SET & GetPolyShape()
wxString SHAPE_T_asString() const
const EDA_ANGLE & GetTextAngle() const
virtual const wxString & GetText() const
Return the string associated with the text object.
bool IsKeepUpright() const
virtual bool IsVisible() const
GR_TEXT_H_ALIGN_T GetHorizJustify() const
GR_TEXT_V_ALIGN_T GetVertJustify() const
int GetTextThickness() const
VECTOR2I GetTextSize() const
VECTOR3D m_Offset
3D model offset (mm)
VECTOR3D m_Rotation
3D model rotation (degrees)
VECTOR3D m_Scale
3D model scaling factor (dimensionless)
wxString m_Filename
The 3D shape filename in 3D library.
bool m_Show
Include model in rendering.
const FP_LIB_TABLE_ROW * FindRow(const wxString &aNickName, bool aCheckIfEnabled=false)
Return an FP_LIB_TABLE_ROW if aNickName is found in this table or in any chained fall back table frag...
FOOTPRINT * FootprintLoad(const wxString &aNickname, const wxString &aFootprintName, bool aKeepUUID=false)
Load a footprint having aFootprintName from the library given by aNickname.
const VECTOR2I & GetBezierC1_0() const
const VECTOR2I & GetEnd0() const
const VECTOR2I & GetBezierC2_0() const
VECTOR2I GetCenter0() const
const VECTOR2I & GetStart0() const
const VECTOR2I & GetPos0() const
A specialization of ZONE for use in footprints.
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
A logical library item identifier and consists of various portions much like a URI.
const UTF8 & GetLibItemName() const
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
Hold a record identifying a library accessed by the appropriate plug in object in the LIB_TABLE.
bool HasLibrary(const wxString &aNickname, bool aCheckEnabled=false) const
Test for the existence of aNickname in the library table.
LSET is a set of PCB_LAYER_IDs.
int GetLocalClearance(wxString *aSource) const override
Return any local clearances set in the "classic" (ie: pre-rule) system.
PAD_PROP GetProperty() const
bool GetRemoveUnconnected() const
PAD_DRILL_SHAPE_T GetDrillShape() const
LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
const VECTOR2I & GetDrillSize() const
PAD_ATTRIB GetAttribute() const
ZONE_CONNECTION GetZoneConnection() const
const wxString & GetNumber() const
double GetLocalSolderPasteMarginRatio() const
int GetRoundRectCornerRadius() const
const std::vector< std::shared_ptr< PCB_SHAPE > > & GetPrimitives() const
Accessor to the basic shape list for custom-shaped pads.
EDA_ANGLE GetThermalSpokeAngle() const
const VECTOR2I & GetOffset() const
int GetLocalSolderMaskMargin() const
bool GetKeepTopBottom() const
CUST_PAD_SHAPE_IN_ZONE GetCustomShapeInZoneOpt() const
FOOTPRINT * GetParent() const
const VECTOR2I & GetDelta() const
PAD_SHAPE GetShape() const
EDA_ANGLE GetOrientation() const
Return the rotation angle of the pad.
int GetThermalSpokeWidth() const
int GetLocalSolderPasteMargin() const
int GetChamferPositions() const
double GetRoundRectRadiusRatio() const
int GetThermalGap() const
const VECTOR2I & GetPos0() const
const VECTOR2I & GetSize() const
double GetChamferRectRatio() const
int GetPadToDieLength() const
STROKE_PARAMS GetStroke() const override
Container for project specific data.
Represent a set of closed polygons.
void Rotate(const EDA_ANGLE &aAngle, const VECTOR2I &aCenter={ 0, 0 }) override
Rotate all vertices by a given angle.
int TotalVertices() const
Delete aIdx-th polygon from the set.
const VECTOR2I & CVertex(int aIndex, int aOutline, int aHole) const
Return the aGlobalIndex-th vertex in the poly set.
void Move(const VECTOR2I &aVector) override
SHAPE_POLY_SET CloneDropTriangulation() const
Creates a new empty polygon in the set and returns its index.
bool GetIsRuleArea() const
Accessors to parameters used in Rule Area zones:
bool GetDoNotAllowVias() const
const ISLAND_REMOVAL_MODE GetIslandRemovalMode() const
bool GetDoNotAllowPads() const
bool GetDoNotAllowTracks() const
SHAPE_POLY_SET * Outline()
long long int GetMinIslandArea() const
wxString GetZoneName() const
int GetLocalClearance(wxString *aSource) const override
Return any local clearances set in the "classic" (ie: pre-rule) system.
int GetMinThickness() const
ZONE_CONNECTION GetPadConnection() const
int GetHatchThickness() const
double GetHatchHoleMinArea() const
int GetThermalReliefSpokeWidth() const
EDA_ANGLE GetHatchOrientation() const
bool GetDoNotAllowFootprints() const
ZONE_FILL_MODE GetFillMode() const
virtual LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
bool GetDoNotAllowCopperPour() const
double GetHatchSmoothingValue() const
int GetHatchSmoothingLevel() const
unsigned int GetCornerRadius() const
int GetCornerSmoothingType() const
int GetThermalReliefGap() const
unsigned GetAssignedPriority() const
@ DRCE_LIB_FOOTPRINT_ISSUES
@ DRCE_LIB_FOOTPRINT_MISMATCH
#define TEST_PRIMITIVES(a, b)
#define TEST_ATTR(a, b, attr)
bool shapesNeedUpdate(const FP_SHAPE *a, const FP_SHAPE *b)
bool primitivesNeedUpdate(const std::shared_ptr< PCB_SHAPE > &a, const std::shared_ptr< PCB_SHAPE > &b)
bool textsNeedUpdate(const FP_TEXT *a, const FP_TEXT *b)
#define TEST_MODELS(a, b)
#define TEST_SHAPES(a, b)
bool zonesNeedUpdate(const FP_ZONE *a, const FP_ZONE *b)
bool modelsNeedUpdate(const FP_3DMODEL &a, const FP_3DMODEL &b)
bool padsNeedUpdate(const PAD *a, const PAD *b)
This file contains miscellaneous commonly used macros and functions.
#define UNIMPLEMENTED_FOR(type)
static DRC_REGISTER_TEST_PROVIDER< DRC_TEST_PROVIDER_ANNULAR_WIDTH > dummy
constexpr int mmToIU(double mm) const
@ PCB_FP_SHAPE_T
class FP_SHAPE, a footprint edge