diff --git a/pcbnew/class_pad.h b/pcbnew/class_pad.h index 9ed61fff55..7eeb28943d 100644 --- a/pcbnew/class_pad.h +++ b/pcbnew/class_pad.h @@ -354,6 +354,13 @@ public: */ bool SetPrimitives( const std::vector& aPrimitivesList ); + /** + * Add to the basic shape list + * @return true if OK, false if issues + * (more than one polygon to build the polygon shape list) + */ + bool AddPrimitives( const std::vector& aPrimitivesList ); + /** * Function SetOrientation diff --git a/pcbnew/pad_custom_shape_functions.cpp b/pcbnew/pad_custom_shape_functions.cpp index 1a8deb3c60..123d7bbaf4 100644 --- a/pcbnew/pad_custom_shape_functions.cpp +++ b/pcbnew/pad_custom_shape_functions.cpp @@ -159,6 +159,15 @@ bool D_PAD::SetPrimitives( const std::vector& aPrimitivesList return MergePrimitivesAsPolygon(); } +bool D_PAD::AddPrimitives( const std::vector& aPrimitivesList ) +{ + for( const auto& prim : aPrimitivesList ) + m_basicShapes.push_back( prim ); + + return MergePrimitivesAsPolygon(); +} + + // clear the basic shapes list and associated data void D_PAD::DeletePrimitivesList() { diff --git a/pcbnew/tools/footprint_editor_tools.cpp b/pcbnew/tools/footprint_editor_tools.cpp index f6a1ae682b..2d6f5f8aec 100644 --- a/pcbnew/tools/footprint_editor_tools.cpp +++ b/pcbnew/tools/footprint_editor_tools.cpp @@ -407,8 +407,6 @@ int MODULE_EDITOR_TOOLS::CreatePadFromShapes( const TOOL_EVENT& aEvent ) pad->SetOrientation( 0 ); } - - pad->SetPrimitives( shapes ); pad->SetShape ( PAD_SHAPE_CUSTOM ); OPT anchor; @@ -441,8 +439,9 @@ int MODULE_EDITOR_TOOLS::CreatePadFromShapes( const TOOL_EVENT& aEvent ) pad->SetPosition( wxPoint( anchor->x, anchor->y ) ); - pad->SetPrimitives( shapes ); - + pad->AddPrimitives( shapes ); + pad->ClearFlags(); + bool result = pad->MergePrimitivesAsPolygon(); if( !result ) @@ -462,9 +461,8 @@ int MODULE_EDITOR_TOOLS::CreatePadFromShapes( const TOOL_EVENT& aEvent ) } m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true ); - m_toolMgr->RunAction( PCB_ACTIONS::selectItem, true, padPtr ); - commit.Push(_("Create Pad from Selected Shapes") ); + m_toolMgr->RunAction( PCB_ACTIONS::selectItem, true, padPtr ); return 0; }