From 796d888f8f68e37e76c01a2611ebed123c4a23ea Mon Sep 17 00:00:00 2001 From: Ian McInerney Date: Fri, 9 Aug 2019 01:22:57 +0200 Subject: [PATCH] cvpcb: Add individual association deleting --- cvpcb/cvpcb_mainframe.cpp | 2 ++ cvpcb/tools/cvpcb_actions.cpp | 6 ++++++ cvpcb/tools/cvpcb_actions.h | 1 + cvpcb/tools/cvpcb_control.cpp | 18 ++++++++++++++++++ cvpcb/tools/cvpcb_control.h | 7 +++++++ 5 files changed, 34 insertions(+) diff --git a/cvpcb/cvpcb_mainframe.cpp b/cvpcb/cvpcb_mainframe.cpp index dc8cd00691..c7758a0d39 100644 --- a/cvpcb/cvpcb_mainframe.cpp +++ b/cvpcb/cvpcb_mainframe.cpp @@ -227,6 +227,8 @@ void CVPCB_MAINFRAME::setupTools() m_componentContextMenu = new ACTION_MENU( true ); m_componentContextMenu->SetTool( tool ); m_componentContextMenu->Add( CVPCB_ACTIONS::showFootprintViewer ); + m_componentContextMenu->AppendSeparator(); + m_componentContextMenu->Add( CVPCB_ACTIONS::deleteAssoc ); // Create the context menu for the footprint list box m_footprintContextMenu = new ACTION_MENU( true ); diff --git a/cvpcb/tools/cvpcb_actions.cpp b/cvpcb/tools/cvpcb_actions.cpp index d74761a2de..05e9ab6b51 100644 --- a/cvpcb/tools/cvpcb_actions.cpp +++ b/cvpcb/tools/cvpcb_actions.cpp @@ -114,6 +114,12 @@ TOOL_ACTION CVPCB_ACTIONS::autoAssociate( "cvpcb.Control.AutoAssociate", AS_GLOB _( "Perform automatic footprint association" ), auto_associe_xpm ); +TOOL_ACTION CVPCB_ACTIONS::deleteAssoc( "cvpcb.Control.Delete", AS_GLOBAL, + WXK_DELETE, "", + _( "Delete association" ), + _( "Delete selected footprint associations" ), + delete_association_xpm ); + TOOL_ACTION CVPCB_ACTIONS::deleteAll( "cvpcb.Control.DeleteAll", AS_GLOBAL, 0, "", _( "Delete all footprint associations" ), diff --git a/cvpcb/tools/cvpcb_actions.h b/cvpcb/tools/cvpcb_actions.h index e6ce0bbace..7f394a02ab 100644 --- a/cvpcb/tools/cvpcb_actions.h +++ b/cvpcb/tools/cvpcb_actions.h @@ -65,6 +65,7 @@ public: static TOOL_ACTION autoAssociate; static TOOL_ACTION associate; static TOOL_ACTION deleteAll; + static TOOL_ACTION deleteAssoc; /// Footprint Filtering actions static TOOL_ACTION filterFPbyKeywords; diff --git a/cvpcb/tools/cvpcb_control.cpp b/cvpcb/tools/cvpcb_control.cpp index 1fa158c344..cff12382dc 100644 --- a/cvpcb/tools/cvpcb_control.cpp +++ b/cvpcb/tools/cvpcb_control.cpp @@ -262,6 +262,23 @@ int CVPCB_CONTROL::AutoAssociate( const TOOL_EVENT& aEvent ) } +int CVPCB_CONTROL::DeleteAssoc( const TOOL_EVENT& aEvent ) +{ + // Get all the components that are selected + std::vector sel = m_frame->GetComponentIndices( CVPCB_MAINFRAME::SEL_COMPONENTS ); + + // Delete the association + bool firstAssoc = true; + for( auto i : sel ) + { + m_frame->AssociateFootprint( CVPCB_ASSOCIATION( i, LIB_ID() ), firstAssoc ); + firstAssoc = false; + } + + return 0; +} + + int CVPCB_CONTROL::DeleteAll( const TOOL_EVENT& aEvent ) { if( IsOK( m_frame, _( "Delete all associations?" ) ) ) @@ -401,6 +418,7 @@ void CVPCB_CONTROL::setTransitions() Go( &CVPCB_CONTROL::ShowEquFileTable, CVPCB_ACTIONS::showEquFileTable.MakeEvent() ); Go( &CVPCB_CONTROL::SaveAssociations, CVPCB_ACTIONS::saveAssociations.MakeEvent() ); Go( &CVPCB_CONTROL::DeleteAll, CVPCB_ACTIONS::deleteAll.MakeEvent() ); + Go( &CVPCB_CONTROL::DeleteAssoc, CVPCB_ACTIONS::deleteAssoc.MakeEvent() ); // Navigation actions Go( &CVPCB_CONTROL::ToNA, CVPCB_ACTIONS::gotoNextNA.MakeEvent() ); diff --git a/cvpcb/tools/cvpcb_control.h b/cvpcb/tools/cvpcb_control.h index ab7939a85e..0810397864 100644 --- a/cvpcb/tools/cvpcb_control.h +++ b/cvpcb/tools/cvpcb_control.h @@ -91,6 +91,13 @@ public: */ int DeleteAll( const TOOL_EVENT& aEvent ); + /** + * Delete the selected associations. + * + * @param aEvent is the event generated by the tool framework + */ + int DeleteAssoc( const TOOL_EVENT& aEvent ); + /** * Move the selected component to the not associated one in the specified direction. *