From f2bb398ae6e9fedf0e79a5c9a2561ac535591964 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20W=C5=82ostowski?= Date: Tue, 6 Mar 2018 14:58:25 +0100 Subject: [PATCH] pcbnew: fixes in primitives->custom pad tool Fixes: lp:1753712 * https://bugs.launchpad.net/kicad/+bug/1753712 Fixes: lp:1753711 * https://bugs.launchpad.net/kicad/+bug/1753711 --- pcbnew/class_pad.h | 7 +++++++ pcbnew/pad_custom_shape_functions.cpp | 9 +++++++++ pcbnew/tools/footprint_editor_tools.cpp | 10 ++++------ 3 files changed, 20 insertions(+), 6 deletions(-) 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; }