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
This commit is contained in:
Tomasz Włostowski 2018-03-06 14:58:25 +01:00
parent 48459e4268
commit f2bb398ae6
3 changed files with 20 additions and 6 deletions

View File

@ -354,6 +354,13 @@ public:
*/ */
bool SetPrimitives( const std::vector<PAD_CS_PRIMITIVE>& aPrimitivesList ); bool SetPrimitives( const std::vector<PAD_CS_PRIMITIVE>& 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<PAD_CS_PRIMITIVE>& aPrimitivesList );
/** /**
* Function SetOrientation * Function SetOrientation

View File

@ -159,6 +159,15 @@ bool D_PAD::SetPrimitives( const std::vector<PAD_CS_PRIMITIVE>& aPrimitivesList
return MergePrimitivesAsPolygon(); return MergePrimitivesAsPolygon();
} }
bool D_PAD::AddPrimitives( const std::vector<PAD_CS_PRIMITIVE>& aPrimitivesList )
{
for( const auto& prim : aPrimitivesList )
m_basicShapes.push_back( prim );
return MergePrimitivesAsPolygon();
}
// clear the basic shapes list and associated data // clear the basic shapes list and associated data
void D_PAD::DeletePrimitivesList() void D_PAD::DeletePrimitivesList()
{ {

View File

@ -407,8 +407,6 @@ int MODULE_EDITOR_TOOLS::CreatePadFromShapes( const TOOL_EVENT& aEvent )
pad->SetOrientation( 0 ); pad->SetOrientation( 0 );
} }
pad->SetPrimitives( shapes );
pad->SetShape ( PAD_SHAPE_CUSTOM ); pad->SetShape ( PAD_SHAPE_CUSTOM );
OPT<VECTOR2I> anchor; OPT<VECTOR2I> anchor;
@ -441,8 +439,9 @@ int MODULE_EDITOR_TOOLS::CreatePadFromShapes( const TOOL_EVENT& aEvent )
pad->SetPosition( wxPoint( anchor->x, anchor->y ) ); pad->SetPosition( wxPoint( anchor->x, anchor->y ) );
pad->SetPrimitives( shapes ); pad->AddPrimitives( shapes );
pad->ClearFlags();
bool result = pad->MergePrimitivesAsPolygon(); bool result = pad->MergePrimitivesAsPolygon();
if( !result ) 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::selectionClear, true );
m_toolMgr->RunAction( PCB_ACTIONS::selectItem, true, padPtr );
commit.Push(_("Create Pad from Selected Shapes") ); commit.Push(_("Create Pad from Selected Shapes") );
m_toolMgr->RunAction( PCB_ACTIONS::selectItem, true, padPtr );
return 0; return 0;
} }