From 0fcb36bc2e03f346da2695493cc964eb2b46730d Mon Sep 17 00:00:00 2001 From: Alex Shvartzkop Date: Fri, 6 Oct 2023 15:03:09 +0300 Subject: [PATCH] Add reselectItem action. --- common/tool/selection_tool.cpp | 14 +++++++++++++- include/tool/selection_tool.h | 4 +++- pcbnew/tools/pcb_actions.cpp | 6 +++++- pcbnew/tools/pcb_actions.h | 3 ++- pcbnew/tools/pcb_selection_tool.cpp | 1 + 5 files changed, 24 insertions(+), 4 deletions(-) diff --git a/common/tool/selection_tool.cpp b/common/tool/selection_tool.cpp index e753373948..85e3aed29b 100644 --- a/common/tool/selection_tool.cpp +++ b/common/tool/selection_tool.cpp @@ -1,7 +1,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2021-2022 KiCad Developers, see AUTHORS.TXT for contributors. + * Copyright (C) 2021-2023 KiCad Developers, see AUTHORS.TXT for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -125,6 +125,18 @@ void SELECTION_TOOL::AddItemToSel( EDA_ITEM* aItem, bool aQuietMode ) } +int SELECTION_TOOL::ReselectItem( const TOOL_EVENT& aEvent ) +{ + RemoveItemFromSel( aEvent.Parameter() ); + selection().SetIsHover( false ); + + AddItemToSel( aEvent.Parameter() ); + selection().SetIsHover( false ); + + return 0; +} + + int SELECTION_TOOL::AddItemsToSel( const TOOL_EVENT& aEvent ) { AddItemsToSel( aEvent.Parameter(), false ); diff --git a/include/tool/selection_tool.h b/include/tool/selection_tool.h index a5a2ffbdec..28be6ab2cd 100644 --- a/include/tool/selection_tool.h +++ b/include/tool/selection_tool.h @@ -1,7 +1,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2021-2022 KiCad Developers, see AUTHORS.TXT for contributors. + * Copyright (C) 2021-2023 KiCad Developers, see AUTHORS.TXT for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -54,6 +54,8 @@ public: int RemoveItemsFromSel( const TOOL_EVENT& aEvent ); void RemoveItemsFromSel( EDA_ITEMS* aList, bool aQuietMode = false ); + int ReselectItem( const TOOL_EVENT& aEvent ); + /** * A safer version of RemoveItemsFromSel( EDA_ITEMS ) which doesn't require the items to * still exist. diff --git a/pcbnew/tools/pcb_actions.cpp b/pcbnew/tools/pcb_actions.cpp index 9cf0951a84..8366676321 100644 --- a/pcbnew/tools/pcb_actions.cpp +++ b/pcbnew/tools/pcb_actions.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2013-2016 CERN - * Copyright (C) 2016-2022 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2016-2023 KiCad Developers, see AUTHORS.txt for contributors. * @author Maciej Suminski * * This program is free software; you can redistribute it and/or @@ -2011,6 +2011,10 @@ TOOL_ACTION PCB_ACTIONS::unselectItems( TOOL_ACTION_ARGS() .Name( "pcbnew.InteractiveSelection.UnselectItems" ) .Scope( AS_GLOBAL ) ); +TOOL_ACTION PCB_ACTIONS::reselectItem( TOOL_ACTION_ARGS() + .Name( "pcbnew.InteractiveSelection.ReselectItem" ) + .Scope( AS_GLOBAL ) ); + TOOL_ACTION PCB_ACTIONS::selectionClear( TOOL_ACTION_ARGS() .Name( "pcbnew.InteractiveSelection.Clear" ) .Scope( AS_GLOBAL ) ); diff --git a/pcbnew/tools/pcb_actions.h b/pcbnew/tools/pcb_actions.h index 15e1e2e25f..24ec67ba5d 100644 --- a/pcbnew/tools/pcb_actions.h +++ b/pcbnew/tools/pcb_actions.h @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2013-2016 CERN - * Copyright (C) 2016-2022 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2016-2023 KiCad Developers, see AUTHORS.txt for contributors. * * @author Maciej Suminski * @@ -70,6 +70,7 @@ public: /// Select an item (specified as the event parameter). static TOOL_ACTION selectItem; static TOOL_ACTION unselectItem; + static TOOL_ACTION reselectItem; /// Select a list of items (specified as the event parameter) static TOOL_ACTION selectItems; diff --git a/pcbnew/tools/pcb_selection_tool.cpp b/pcbnew/tools/pcb_selection_tool.cpp index 01dc1bb657..0bc74ee5ff 100644 --- a/pcbnew/tools/pcb_selection_tool.cpp +++ b/pcbnew/tools/pcb_selection_tool.cpp @@ -3509,6 +3509,7 @@ void PCB_SELECTION_TOOL::setTransitions() Go( &PCB_SELECTION_TOOL::AddItemsToSel, PCB_ACTIONS::selectItems.MakeEvent() ); Go( &PCB_SELECTION_TOOL::RemoveItemFromSel, PCB_ACTIONS::unselectItem.MakeEvent() ); Go( &PCB_SELECTION_TOOL::RemoveItemsFromSel, PCB_ACTIONS::unselectItems.MakeEvent() ); + Go( &PCB_SELECTION_TOOL::ReselectItem, PCB_ACTIONS::reselectItem.MakeEvent() ); Go( &PCB_SELECTION_TOOL::SelectionMenu, PCB_ACTIONS::selectionMenu.MakeEvent() ); Go( &PCB_SELECTION_TOOL::filterSelection, PCB_ACTIONS::filterSelection.MakeEvent() );