Repair copy/paste of footprint fields.
Some of the code got lost in the move to PCB_FIELDs.
(cherry picked from commit a9c4a17c38
)
This commit is contained in:
parent
e7f18e7eab
commit
3938c35f17
|
@ -221,16 +221,6 @@ void CLIPBOARD_IO::SaveSelection( const PCB_SELECTION& aSelected, bool isFootpri
|
|||
else if( textItem->GetText() == wxT( "${REFERENCE}" ) )
|
||||
textItem->SetText( boardItem->GetParentFootprint()->GetReference() );
|
||||
}
|
||||
else if( boardItem->Type() == PCB_PAD_T )
|
||||
{
|
||||
// Create a parent to own the copied pad
|
||||
FOOTPRINT* footprint = new FOOTPRINT( m_board );
|
||||
PAD* pad = (PAD*) boardItem->Clone();
|
||||
|
||||
footprint->SetPosition( pad->GetPosition() );
|
||||
footprint->Add( pad );
|
||||
copy = footprint;
|
||||
}
|
||||
else if( boardItem->Type() == PCB_GROUP_T )
|
||||
{
|
||||
copy = static_cast<PCB_GROUP*>( boardItem )->DeepClone();
|
||||
|
@ -246,6 +236,23 @@ void CLIPBOARD_IO::SaveSelection( const PCB_SELECTION& aSelected, bool isFootpri
|
|||
|
||||
if( copy )
|
||||
{
|
||||
if( copy->Type() == PCB_FIELD_T || copy->Type() == PCB_PAD_T )
|
||||
{
|
||||
// Create a parent footprint to own the copied item
|
||||
FOOTPRINT* footprint = new FOOTPRINT( m_board );
|
||||
|
||||
footprint->SetPosition( copy->GetPosition() );
|
||||
footprint->Add( copy );
|
||||
|
||||
if( PCB_FIELD* field = dynamic_cast<PCB_FIELD*>( copy ) )
|
||||
{
|
||||
if( field->IsMandatoryField() )
|
||||
field->SetId( footprint->GetFieldCount() );
|
||||
}
|
||||
|
||||
copy = footprint;
|
||||
}
|
||||
|
||||
copy->SetLocked( false );
|
||||
|
||||
// locate the reference point at (0, 0) in the copied items
|
||||
|
|
|
@ -104,6 +104,7 @@ public:
|
|||
void SetName( const wxString& aName ) { m_name = aName; }
|
||||
|
||||
int GetId() const { return m_id; }
|
||||
void SetId( int aId ) { m_id = aId; }
|
||||
|
||||
double Similarity( const BOARD_ITEM& aOther ) const override;
|
||||
|
||||
|
|
|
@ -740,8 +740,32 @@ static void pasteFootprintItemsToFootprintEditor( FOOTPRINT* aClipFootprint, BOA
|
|||
aClipFootprint->Pads().clear();
|
||||
|
||||
// Not all graphic items can be added to the current footprint:
|
||||
// Reference and value are already existing in the current footprint, and must be unique.
|
||||
// So they will be skipped
|
||||
// mandatory fields are already existing in the current footprint.
|
||||
//
|
||||
for( PCB_FIELD* field : aClipFootprint->Fields() )
|
||||
{
|
||||
if( field->IsMandatoryField() )
|
||||
{
|
||||
if( PCB_GROUP* parentGroup = field->GetParentGroup() )
|
||||
parentGroup->RemoveItem( field );
|
||||
}
|
||||
else
|
||||
{
|
||||
PCB_TEXT* text = static_cast<PCB_TEXT*>( field );
|
||||
|
||||
text->SetTextAngle( text->GetTextAngle() - aClipFootprint->GetOrientation() );
|
||||
text->SetTextAngle( text->GetTextAngle() + editorFootprint->GetOrientation() );
|
||||
|
||||
VECTOR2I pos = field->GetFPRelativePosition();
|
||||
field->SetParent( editorFootprint );
|
||||
field->SetFPRelativePosition( pos );
|
||||
|
||||
aPastedItems.push_back( field );
|
||||
}
|
||||
}
|
||||
|
||||
aClipFootprint->Fields().clear();
|
||||
|
||||
for( BOARD_ITEM* item : aClipFootprint->GraphicalItems() )
|
||||
{
|
||||
if( item->Type() == PCB_TEXT_T )
|
||||
|
@ -814,7 +838,6 @@ void PCB_CONTROL::pruneItemLayers( std::vector<BOARD_ITEM*>& aItems )
|
|||
|
||||
for( BOARD_ITEM* item : aItems )
|
||||
{
|
||||
|
||||
if( item->Type() == PCB_FOOTPRINT_T )
|
||||
{
|
||||
FOOTPRINT* fp = static_cast<FOOTPRINT*>( item );
|
||||
|
@ -827,6 +850,16 @@ void PCB_CONTROL::pruneItemLayers( std::vector<BOARD_ITEM*>& aItems )
|
|||
|
||||
// NOTE: all traversals from the back as processFPItem() might delete the item
|
||||
|
||||
for( int ii = static_cast<int>( fp->Fields().size() ) - 1; ii >= 0; ii-- )
|
||||
{
|
||||
PCB_FIELD* field = fp->Fields()[ii];
|
||||
|
||||
if( field->GetId() == REFERENCE_FIELD || field->GetId() == VALUE_FIELD )
|
||||
continue;
|
||||
|
||||
processFPItem( fp, field );
|
||||
}
|
||||
|
||||
for( int ii = static_cast<int>( fp->Pads().size() ) - 1; ii >= 0; ii-- )
|
||||
processFPItem( fp, fp->Pads()[ii] );
|
||||
|
||||
|
@ -837,7 +870,14 @@ void PCB_CONTROL::pruneItemLayers( std::vector<BOARD_ITEM*>& aItems )
|
|||
processFPItem( fp, fp->GraphicalItems()[ii] );
|
||||
|
||||
if( fp->GraphicalItems().size() || fp->Pads().size() || fp->Zones().size() )
|
||||
{
|
||||
returnItems.push_back( fp );
|
||||
}
|
||||
else
|
||||
{
|
||||
if( PCB_GROUP* parentGroup = fp->GetParentGroup() )
|
||||
parentGroup->RemoveItem( item );
|
||||
}
|
||||
}
|
||||
else if( item->Type() == PCB_GROUP_T || item->Type() == PCB_GENERATOR_T )
|
||||
{
|
||||
|
@ -852,6 +892,11 @@ void PCB_CONTROL::pruneItemLayers( std::vector<BOARD_ITEM*>& aItems )
|
|||
item->SetLayerSet( allowed );
|
||||
returnItems.push_back( item );
|
||||
}
|
||||
else
|
||||
{
|
||||
if( PCB_GROUP* parentGroup = item->GetParentGroup() )
|
||||
parentGroup->RemoveItem( item );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue