Browse Source

Tighten up footprint c'tor and copy c'tor.

Several fields weren't being initialized; several
other fields weren't being copied.
pull/18/head
Jeff Young 4 months ago
parent
commit
a3c9454221
  1. 87
      pcbnew/footprint.cpp
  2. 32
      pcbnew/footprint.h
  3. 19
      qa/pcbnew_utils/board_test_utils.cpp

87
pcbnew/footprint.cpp

@ -70,19 +70,24 @@
FOOTPRINT::FOOTPRINT( BOARD* parent ) :
BOARD_ITEM_CONTAINER( (BOARD_ITEM*) parent, PCB_FOOTPRINT_T ),
m_boundingBoxCacheTimeStamp( 0 ), m_textExcludedBBoxCacheTimeStamp( 0 ),
m_hullCacheTimeStamp( 0 ), m_initial_comments( nullptr ),
m_orient( ANGLE_0 ),
m_attributes( 0 ),
m_fpStatus( FP_PADS_are_LOCKED ),
m_fileFormatVersionAtLoad( 0 ),
m_boundingBoxCacheTimeStamp( 0 ),
m_textExcludedBBoxCacheTimeStamp( 0 ),
m_hullCacheTimeStamp( 0 ),
m_duplicatePadNumbersAreJumpers( false ),
m_allowMissingCourtyard( false ),
m_allowSolderMaskBridges( false ),
m_zoneConnection( ZONE_CONNECTION::INHERITED ),
m_lastEditTime( 0 ),
m_arflag( 0 ),
m_link( 0 ),
m_initial_comments( nullptr ),
m_componentClassCacheProxy( std::make_unique<COMPONENT_CLASS_CACHE_PROXY>( this ) )
{
m_attributes = 0;
m_layer = F_Cu;
m_orient = ANGLE_0;
m_fpStatus = FP_PADS_are_LOCKED;
m_arflag = 0;
m_link = 0;
m_lastEditTime = 0;
m_zoneConnection = ZONE_CONNECTION::INHERITED;
m_fileFormatVersionAtLoad = 0;
m_layer = F_Cu;
m_embedFonts = false;
auto addField =
@ -107,15 +112,12 @@ FOOTPRINT::FOOTPRINT( const FOOTPRINT& aFootprint ) :
BOARD_ITEM_CONTAINER( aFootprint ), EMBEDDED_FILES( aFootprint ),
m_componentClassCacheProxy( std::make_unique<COMPONENT_CLASS_CACHE_PROXY>( this ) )
{
m_pos = aFootprint.m_pos;
m_fpid = aFootprint.m_fpid;
m_attributes = aFootprint.m_attributes;
m_fpStatus = aFootprint.m_fpStatus;
m_orient = aFootprint.m_orient;
m_lastEditTime = aFootprint.m_lastEditTime;
m_link = aFootprint.m_link;
m_path = aFootprint.m_path;
m_embedFonts = aFootprint.m_embedFonts;
m_orient = aFootprint.m_orient;
m_pos = aFootprint.m_pos;
m_fpid = aFootprint.m_fpid;
m_attributes = aFootprint.m_attributes;
m_fpStatus = aFootprint.m_fpStatus;
m_fileFormatVersionAtLoad = aFootprint.m_fileFormatVersionAtLoad;
m_cachedBoundingBox = aFootprint.m_cachedBoundingBox;
m_boundingBoxCacheTimeStamp = aFootprint.m_boundingBoxCacheTimeStamp;
@ -124,18 +126,38 @@ FOOTPRINT::FOOTPRINT( const FOOTPRINT& aFootprint ) :
m_cachedHull = aFootprint.m_cachedHull;
m_hullCacheTimeStamp = aFootprint.m_hullCacheTimeStamp;
m_clearance = aFootprint.m_clearance;
m_solderMaskMargin = aFootprint.m_solderMaskMargin;
m_solderPasteMargin = aFootprint.m_solderPasteMargin;
m_solderPasteMarginRatio = aFootprint.m_solderPasteMarginRatio;
m_zoneConnection = aFootprint.m_zoneConnection;
m_netTiePadGroups = aFootprint.m_netTiePadGroups;
m_fileFormatVersionAtLoad = aFootprint.m_fileFormatVersionAtLoad;
m_duplicatePadNumbersAreJumpers = aFootprint.m_duplicatePadNumbersAreJumpers;
std::ranges::copy( aFootprint.m_jumperPadGroups,
std::inserter( m_jumperPadGroups, m_jumperPadGroups.end() ) );
m_duplicatePadNumbersAreJumpers = aFootprint.m_duplicatePadNumbersAreJumpers;
m_allowMissingCourtyard = aFootprint.m_allowMissingCourtyard;
m_allowSolderMaskBridges = aFootprint.m_allowSolderMaskBridges;
m_zoneConnection = aFootprint.m_zoneConnection;
m_clearance = aFootprint.m_clearance;
m_solderMaskMargin = aFootprint.m_solderMaskMargin;
m_solderPasteMargin = aFootprint.m_solderPasteMargin;
m_solderPasteMarginRatio = aFootprint.m_solderPasteMarginRatio;
m_libDescription = aFootprint.m_libDescription;
m_keywords = aFootprint.m_keywords;
m_path = aFootprint.m_path;
m_sheetname = aFootprint.m_sheetname;
m_sheetfile = aFootprint.m_sheetfile;
m_filters = aFootprint.m_filters;
m_lastEditTime = aFootprint.m_lastEditTime;
m_arflag = 0;
m_link = aFootprint.m_link;
m_privateLayers = aFootprint.m_privateLayers;
m_3D_Drawings = aFootprint.m_3D_Drawings;
m_initial_comments = aFootprint.m_initial_comments ? new wxArrayString( *aFootprint.m_initial_comments )
: nullptr;
m_embedFonts = aFootprint.m_embedFonts;
std::map<EDA_ITEM*, EDA_ITEM*> ptrMap;
// Copy fields
@ -210,17 +232,6 @@ FOOTPRINT::FOOTPRINT( const FOOTPRINT& aFootprint ) :
for( auto& [ name, file ] : aFootprint.EmbeddedFileMap() )
AddFile( new EMBEDDED_FILES::EMBEDDED_FILE( *file ) );
// Copy auxiliary data
m_3D_Drawings = aFootprint.m_3D_Drawings;
m_libDescription = aFootprint.m_libDescription;
m_keywords = aFootprint.m_keywords;
m_privateLayers = aFootprint.m_privateLayers;
m_arflag = 0;
m_initial_comments = aFootprint.m_initial_comments ?
new wxArrayString( *aFootprint.m_initial_comments ) : nullptr;
}

32
pcbnew/footprint.h

@ -1098,6 +1098,17 @@ private:
// A list of 1:N footprint item to allowed net numbers
std::map<const BOARD_ITEM*, std::set<int>> m_netTieCache;
/// A list of jumper pad groups, each of which is a set of pad numbers that should be jumpered
/// together (treated as internally connected for the purposes of connectivity)
std::vector<std::set<wxString>> m_jumperPadGroups;
/// Flag that this footprint should automatically treat sets of two or more pads with the same
/// number as jumpered pin groups
bool m_duplicatePadNumbersAreJumpers;
bool m_allowMissingCourtyard;
bool m_allowSolderMaskBridges;
// Optional overrides
ZONE_CONNECTION m_zoneConnection;
std::optional<int> m_clearance;
@ -1117,23 +1128,12 @@ private:
KIID m_link; // Temporary logical link used during editing
LSET m_privateLayers; // Layers visible only in the footprint editor
std::vector<FP_3DMODEL> m_3D_Drawings; // 3D models.
wxArrayString* m_initial_comments; // s-expression comments in the footprint,
// lazily allocated only if needed for speed
/// A list of jumper pad groups, each of which is a set of pad numbers that should be jumpered
/// together (treated as internally connected for the purposes of connectivity)
std::vector<std::set<wxString>> m_jumperPadGroups;
/// Flag that this footprint should automatically treat sets of two or more pads with the same
/// number as jumpered pin groups
bool m_duplicatePadNumbersAreJumpers;
bool m_allowMissingCourtyard;
bool m_allowSolderMaskBridges;
std::vector<FP_3DMODEL> m_3D_Drawings; // 3D models.
wxArrayString* m_initial_comments; // s-expression comments in the footprint,
// lazily allocated only if needed for speed
SHAPE_POLY_SET m_courtyard_cache_front; // Note that a footprint can have both front and back
SHAPE_POLY_SET m_courtyard_cache_back; // courtyards populated.
SHAPE_POLY_SET m_courtyard_cache_front; // Note that a footprint can have both front and back
SHAPE_POLY_SET m_courtyard_cache_back; // courtyards populated.
mutable HASH_128 m_courtyard_cache_front_hash;
mutable HASH_128 m_courtyard_cache_back_hash;
mutable std::mutex m_courtyard_cache_mutex;

19
qa/pcbnew_utils/board_test_utils.cpp

@ -426,9 +426,12 @@ void CheckFootprint( const FOOTPRINT* expected, const FOOTPRINT* fp )
// TODO: Groups
// Use FootprintNeedsUpdate as sanity check (which should do the same thing as our manually coded checks)
// If we get the reporter working, and COMPARE_FLAGS::DRC is enough for us, we can remove the old code
BOOST_CHECK( !const_cast<FOOTPRINT*>(expected)->FootprintNeedsUpdate(fp, BOARD_ITEM::COMPARE_FLAGS::DRC, nullptr) );
// Use FootprintNeedsUpdate as sanity check (which should do many of the same checks as above,
// but neither is guaranteed to be complete).
WX_STRING_REPORTER reporter;
if( const_cast<FOOTPRINT*>(expected)->FootprintNeedsUpdate(fp, BOARD_ITEM::COMPARE_FLAGS::DRC, &reporter) )
BOOST_REQUIRE_MESSAGE( false, reporter.GetMessages() );
}
@ -466,11 +469,11 @@ void CheckFpPad( const PAD* expected, const PAD* pad )
BOOST_CHECK_EQUAL( expected->GetPadToDieLength(), pad->GetPadToDieLength() );
BOOST_CHECK_EQUAL( expected->GetPadToDieDelay(), pad->GetPadToDieDelay() );
BOOST_CHECK_EQUAL( expected->GetLocalSolderMaskMargin().value_or( 0 ),
pad->GetLocalSolderMaskMargin().value_or( 0 ) );
pad->GetLocalSolderMaskMargin().value_or( 0 ) );
BOOST_CHECK_EQUAL( expected->GetLocalSolderPasteMargin().value_or( 0 ),
pad->GetLocalSolderPasteMargin().value_or( 0 ) );
pad->GetLocalSolderPasteMargin().value_or( 0 ) );
BOOST_CHECK_EQUAL( expected->GetLocalSolderPasteMarginRatio().value_or( 0 ),
pad->GetLocalSolderPasteMarginRatio().value_or( 0 ) );
pad->GetLocalSolderPasteMarginRatio().value_or( 0 ) );
BOOST_CHECK_EQUAL( expected->GetLocalClearance().value_or( 0 ),
pad->GetLocalClearance().value_or( 0 ) );
CHECK_ENUM_CLASS_EQUAL( expected->GetLocalZoneConnection(), pad->GetLocalZoneConnection() );
@ -505,7 +508,6 @@ void CheckFpPad( const PAD* expected, const PAD* pad )
pad->GetPrimitives( PADSTACK::ALL_LAYERS ).at( i ).get() );
}
}
}
}
@ -534,8 +536,7 @@ void CheckFpText( const PCB_TEXT* expected, const PCB_TEXT* text )
BOOST_CHECK_EQUAL( expected->GetHorizJustify(), text->GetHorizJustify() );
BOOST_CHECK_EQUAL( expected->GetVertJustify(), text->GetVertJustify() );
BOOST_CHECK_EQUAL( expected->IsMirrored(), text->IsMirrored() );
BOOST_CHECK_EQUAL( expected->GetFontName(),
text->GetFontName() ); // TODO: bold/italic setting?
BOOST_CHECK_EQUAL( expected->GetFontName(), text->GetFontName() );
// TODO: render cache?
}

Loading…
Cancel
Save