7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-21 16:53:44 +00:00

Clear fields when flag is set.

Also make sure we set aUpdated when deleting extra
text items or fields, and when updating fabrication
attributes or 3D models.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/17756
This commit is contained in:
Jeff Young 2024-07-22 17:14:47 +01:00
parent 1f0ce80f49
commit dab3972165
2 changed files with 51 additions and 19 deletions

View File

@ -101,6 +101,16 @@ public:
double m_Opacity;
wxString m_Filename; ///< The 3D shape filename in 3D library
bool m_Show; ///< Include model in rendering
bool operator==( const FP_3DMODEL& aOther ) const
{
return m_Scale == aOther.m_Scale
&& m_Rotation == aOther.m_Rotation
&& m_Offset == aOther.m_Offset
&& m_Opacity == aOther.m_Opacity
&& m_Filename == aOther.m_Filename
&& m_Show == aOther.m_Show;
}
};

View File

@ -2338,7 +2338,11 @@ void PCB_EDIT_FRAME::ExchangeFootprint( FOOTPRINT* aExisting, FOOTPRINT* aNew,
processTextItem( *oldTextItem, *newTextItem, resetTextContent, resetTextLayers,
resetTextEffects, aUpdated );
}
else if( !deleteExtraTexts )
else if( deleteExtraTexts )
{
*aUpdated = true;
}
else
{
aNew->Add( static_cast<BOARD_ITEM*>( oldTextItem->Clone() ) );
}
@ -2365,42 +2369,60 @@ void PCB_EDIT_FRAME::ExchangeFootprint( FOOTPRINT* aExisting, FOOTPRINT* aNew,
PCB_FIELD* newField = aNew->GetFieldByName( oldField->GetName() );
if( !newField )
if( newField )
{
processTextItem( *oldField, *newField, resetTextContent, resetTextLayers,
resetTextEffects, aUpdated );
}
else if( deleteExtraTexts )
{
*aUpdated = true;
}
else
{
newField = new PCB_FIELD( *oldField );
aNew->Add( newField );
processTextItem( *oldField, *newField, true, true, true, aUpdated );
}
else
{
processTextItem( *oldField, *newField, resetTextContent, resetTextLayers,
resetTextEffects, aUpdated );
}
}
// Careful; allow-soldermask-bridges is in the m_attributes field but is not presented
// as a fabrication attribute in the GUI....
int existingFabAttrs = aExisting->GetAttributes() & ~FP_ALLOW_SOLDERMASK_BRIDGES;
int libraryFabAttrs = aNew->GetAttributes() & ~FP_ALLOW_SOLDERMASK_BRIDGES;
if( resetFabricationAttrs )
{
// We've replaced the existing footprint with the library one, so the fabrication attrs
// are already reset.
//
// We only have to do anything if resetFabricationAttrs is *not* set....
// are already reset. Just set the aUpdated flag if appropriate.
if( libraryFabAttrs != existingFabAttrs )
*aUpdated = true;
}
else
{
// Careful; allow-soldermask-bridges is in the m_attributes field but is not presented
// as a fabrication attribute in the GUI....
int libraryFlagsToKeep = aNew->GetAttributes() & FP_ALLOW_SOLDERMASK_BRIDGES;
int existingFlagsToKeep = aExisting->GetAttributes() & ~FP_ALLOW_SOLDERMASK_BRIDGES;
aNew->SetAttributes( existingFlagsToKeep | libraryFlagsToKeep );
int solderMaskBridgesFlag = aNew->GetAttributes() & FP_ALLOW_SOLDERMASK_BRIDGES;
aNew->SetAttributes( existingFabAttrs | solderMaskBridgesFlag );
}
if( reset3DModels )
{
// We've replaced the existing footprint with the library one, so the 3D models are
// already reset.
//
// We only have to do anything if reset3DModels is *not* set....
// already reset. Just set the aUpdated flag if appropriate.
if( aNew->Models().size() != aExisting->Models().size() )
{
*aUpdated = true;
}
else
{
for( size_t ii = 0; ii < aNew->Models().size(); ++ii )
{
if( aNew->Models()[ii] != aExisting->Models()[ii] )
{
*aUpdated = true;
break;
}
}
}
}
else
{