diff --git a/pcbnew/kicad_clipboard.cpp b/pcbnew/kicad_clipboard.cpp index 559a1bac79..f9364bf957 100644 --- a/pcbnew/kicad_clipboard.cpp +++ b/pcbnew/kicad_clipboard.cpp @@ -100,6 +100,13 @@ void CLIPBOARD_IO::SaveSelection( const PCBNEW_SELECTION& aSelected, bool isFoot { FOOTPRINT partialFootprint( m_board ); + // Usefull to copy the selection to the board editor (if any), and provides + // a dummy lib id. + // Perhaps not a good Id, but better than a empty id + KIID dummy; + LIB_ID id( "clipboard", dummy.AsString() ); + partialFootprint.SetFPID( id ); + for( const EDA_ITEM* item : aSelected ) { const PCB_GROUP* group = dynamic_cast( item ); @@ -110,10 +117,6 @@ void CLIPBOARD_IO::SaveSelection( const PCBNEW_SELECTION& aSelected, bool isFoot else clone = static_cast( item->Clone() ); - // Do not add reference/value - convert them to the common type - if( FP_TEXT* text = dyn_cast( clone ) ) - text->SetType( FP_TEXT::TEXT_is_DIVERS ); - // If it is only a footprint, clear the nets from the pads if( PAD* pad = dyn_cast( clone ) ) pad->SetNetCode( 0 ); diff --git a/pcbnew/tools/pcbnew_control.cpp b/pcbnew/tools/pcbnew_control.cpp index bff082a359..da8e08ac8b 100644 --- a/pcbnew/tools/pcbnew_control.cpp +++ b/pcbnew/tools/pcbnew_control.cpp @@ -539,8 +539,8 @@ int PCBNEW_CONTROL::DeleteItemCursor( const TOOL_EVENT& aEvent ) } -void pasteFootprintItemsToFootprintEditor( FOOTPRINT* aClipFootprint, BOARD* aBoard, - std::vector& aPastedItems ) +static void pasteFootprintItemsToFootprintEditor( FOOTPRINT* aClipFootprint, BOARD* aBoard, + std::vector& aPastedItems ) { FOOTPRINT* editorFootprint = aBoard->GetFirstFootprint(); @@ -554,6 +554,10 @@ void pasteFootprintItemsToFootprintEditor( FOOTPRINT* aClipFootprint, BOARD* aBo 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 for( BOARD_ITEM* item : aClipFootprint->GraphicalItems() ) { if( item->Type() == PCB_FP_SHAPE_T ) @@ -568,12 +572,7 @@ void pasteFootprintItemsToFootprintEditor( FOOTPRINT* aClipFootprint, BOARD* aBo FP_TEXT* text = static_cast( item ); if( text->GetType() != FP_TEXT::TEXT_is_DIVERS ) - text->SetType( FP_TEXT::TEXT_is_DIVERS ); - - if( text->GetText() == "${VALUE}" ) - text->SetText( aClipFootprint->GetValue() ); - else if( text->GetText() == "${REFERENCE}" ) - text->SetText( aClipFootprint->GetReference() ); + continue; text->SetTextAngle( aClipFootprint->GetOrientation() ); @@ -594,32 +593,6 @@ void pasteFootprintItemsToFootprintEditor( FOOTPRINT* aClipFootprint, BOARD* aBo } aClipFootprint->Groups().clear(); - - if( !aClipFootprint->GetReference().IsEmpty() ) - { - FP_TEXT* text = new FP_TEXT( aClipFootprint->Reference() ); - text->SetType( FP_TEXT::TEXT_is_DIVERS ); - text->SetTextAngle( aClipFootprint->GetOrientation() ); - - text->SetParent( nullptr ); - text->SetLocalCoord(); - - text->SetParent( editorFootprint ); - aPastedItems.push_back( text ); - } - - if( !aClipFootprint->GetValue().IsEmpty() ) - { - FP_TEXT* text = new FP_TEXT( aClipFootprint->Value() ); - text->SetType( FP_TEXT::TEXT_is_DIVERS ); - text->SetTextAngle( aClipFootprint->GetOrientation() ); - - text->SetParent( nullptr ); - text->SetLocalCoord(); - - text->SetParent( editorFootprint ); - aPastedItems.push_back( text ); - } }