Fix errors resulting from FP fields being moved from m_drawings to m_fields.

This commit is contained in:
Jeff Young 2024-01-27 23:15:53 +00:00
parent f6128cd01e
commit 27534074ac
5 changed files with 27 additions and 18 deletions

View File

@ -1159,11 +1159,11 @@ BOARD_ITEM* BOARD::GetItem( const KIID& aID ) const
return pad;
}
if( footprint->Reference().m_Uuid == aID )
return &footprint->Reference();
if( footprint->Value().m_Uuid == aID )
return &footprint->Value();
for( PCB_FIELD* field : footprint->Fields() )
{
if( field->m_Uuid == aID )
return field;
}
for( BOARD_ITEM* drawing : footprint->GraphicalItems() )
{

View File

@ -1046,7 +1046,11 @@ const BOX2I FOOTPRINT::GetBoundingBox( bool aIncludeText, bool aIncludeInvisible
}
for( PCB_FIELD* field : m_fields )
texts.push_back( field );
{
// Reference and value get their own processing
if( !field->IsReference() && !field->IsValue() )
texts.push_back( field );
}
for( PAD* pad : m_pads )
bbox.Merge( pad->GetBoundingBox() );

View File

@ -158,6 +158,14 @@ EDA_ITEM* PCB_FIELD::Clone() const
}
void PCB_FIELD::swapData( BOARD_ITEM* aImage )
{
assert( aImage->Type() == PCB_FIELD_T );
std::swap( *((PCB_FIELD*) this), *((PCB_FIELD*) aImage) );
}
bool PCB_FIELD::operator==( const BOARD_ITEM& aOther ) const
{
if( aOther.Type() != Type() )

View File

@ -103,18 +103,15 @@ public:
void SetName( const wxString& aName ) { m_name = aName; }
/**
* Get the initial name of the field set at creation (or set by SetName()).
* This is the raw field name with no translation and no change.
*/
const wxString& GetInternalName() { return m_name; }
int GetId() const { return m_id; }
double Similarity( const BOARD_ITEM& aOther ) const override;
bool operator==( const BOARD_ITEM& aOther ) const override;
protected:
void swapData( BOARD_ITEM* aImage ) override;
private:
int m_id; ///< Field index, @see enum MANDATORY_FIELD_T

View File

@ -874,14 +874,14 @@ void PlotSolderMaskLayer( BOARD *aBoard, PLOTTER* aPlotter, LSET aLayerMask,
// add shapes inflated by aMinThickness/2 in areas
footprint->TransformPadsToPolySet( areas, layer, inflate, maxError, ERROR_OUTSIDE );
if( itemplotter.GetPlotReference() && footprint->Reference().IsOnLayer( layer ) )
plotFPTextItem( footprint->Reference() );
if( itemplotter.GetPlotValue() && footprint->Value().IsOnLayer( layer ) )
plotFPTextItem( footprint->Value() );
for( const PCB_FIELD* field : footprint->Fields() )
{
if( field->IsReference() && !itemplotter.GetPlotReference() )
continue;
if( field->IsValue() && !itemplotter.GetPlotValue() )
continue;
if( field->IsOnLayer( layer ) )
plotFPTextItem( static_cast<const PCB_TEXT&>( *field ) );
}