From 95ab0b1813d8420d07f7526080f97820247d98a4 Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Sun, 2 Jun 2019 20:22:57 -0700 Subject: [PATCH] pcbnew: Hide dynamic ratsnest after canceling edit The dynamic ratsnest is shown while moving items but this needs to be hidden after cancelling. Previously this was handled by the SelectionClear event but we've changed this to (correctly) keep the previous selection when canceling. Fixes: lp:1831350 * https://bugs.launchpad.net/kicad/+bug/1831350 --- pcbnew/tools/edit_tool.cpp | 6 ++++++ pcbnew/tools/pcb_actions.h | 2 +- pcbnew/tools/pcb_editor_control.cpp | 11 +++++------ pcbnew/tools/pcb_editor_control.h | 2 +- pcbnew/tools/selection_tool.cpp | 2 +- qa/qa_utils/mocks.cpp | 5 ++--- 6 files changed, 16 insertions(+), 12 deletions(-) diff --git a/pcbnew/tools/edit_tool.cpp b/pcbnew/tools/edit_tool.cpp index d59b2154ba..d7b2ff90ba 100644 --- a/pcbnew/tools/edit_tool.cpp +++ b/pcbnew/tools/edit_tool.cpp @@ -585,10 +585,16 @@ int EDIT_TOOL::Main( const TOOL_EVENT& aEvent ) if( unselect ) m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true ); + // If canceled, we need to remove the dynamic ratsnest from the screen if( restore_state ) + { + m_toolMgr->RunAction( PCB_ACTIONS::hideDynamicRatsnest, true ); m_commit->Revert(); + } else + { m_commit->Push( _( "Drag" ) ); + } return 0; } diff --git a/pcbnew/tools/pcb_actions.h b/pcbnew/tools/pcb_actions.h index 9ada457175..6de8fdf072 100644 --- a/pcbnew/tools/pcb_actions.h +++ b/pcbnew/tools/pcb_actions.h @@ -314,7 +314,7 @@ public: // Ratsnest static TOOL_ACTION localRatsnestTool; - static TOOL_ACTION hideLocalRatsnest; + static TOOL_ACTION hideDynamicRatsnest; static TOOL_ACTION updateLocalRatsnest; /// Find an item diff --git a/pcbnew/tools/pcb_editor_control.cpp b/pcbnew/tools/pcb_editor_control.cpp index 73963083c2..3d7a661fce 100644 --- a/pcbnew/tools/pcb_editor_control.cpp +++ b/pcbnew/tools/pcb_editor_control.cpp @@ -157,9 +157,8 @@ TOOL_ACTION PCB_ACTIONS::localRatsnestTool( "pcbnew.Control.localRatsnestTool", _( "Highlight Ratsnest" ), "", tool_ratsnest_xpm ); -TOOL_ACTION PCB_ACTIONS::hideLocalRatsnest( "pcbnew.Control.hideLocalRatsnest", - AS_GLOBAL, 0, - "", "" ); +TOOL_ACTION PCB_ACTIONS::hideDynamicRatsnest( + "pcbnew.Control.hideDynamicRatsnest", AS_GLOBAL, 0, "", "" ); TOOL_ACTION PCB_ACTIONS::updateLocalRatsnest( "pcbnew.Control.updateLocalRatsnest", AS_GLOBAL, 0, @@ -1295,9 +1294,9 @@ int PCB_EDITOR_CONTROL::UpdateSelectionRatsnest( const TOOL_EVENT& aEvent ) } -int PCB_EDITOR_CONTROL::HideSelectionRatsnest( const TOOL_EVENT& aEvent ) +int PCB_EDITOR_CONTROL::HideDynamicRatsnest( const TOOL_EVENT& aEvent ) { - getModel()->GetConnectivity()->ClearDynamicRatsnest(); + getModel()->GetConnectivity()->HideDynamicRatsnest(); m_slowRatsnest = false; return 0; } @@ -1384,7 +1383,7 @@ void PCB_EDITOR_CONTROL::setTransitions() Go( &PCB_EDITOR_CONTROL::HighlightNetCursor, PCB_ACTIONS::highlightNetSelection.MakeEvent() ); Go( &PCB_EDITOR_CONTROL::LocalRatsnestTool, PCB_ACTIONS::localRatsnestTool.MakeEvent() ); - Go( &PCB_EDITOR_CONTROL::HideSelectionRatsnest, PCB_ACTIONS::hideLocalRatsnest.MakeEvent() ); + Go( &PCB_EDITOR_CONTROL::HideDynamicRatsnest, PCB_ACTIONS::hideDynamicRatsnest.MakeEvent() ); Go( &PCB_EDITOR_CONTROL::UpdateSelectionRatsnest, PCB_ACTIONS::updateLocalRatsnest.MakeEvent() ); } diff --git a/pcbnew/tools/pcb_editor_control.h b/pcbnew/tools/pcb_editor_control.h index 22c295bbfd..6ff697a780 100644 --- a/pcbnew/tools/pcb_editor_control.h +++ b/pcbnew/tools/pcb_editor_control.h @@ -124,7 +124,7 @@ public: int UpdateSelectionRatsnest( const TOOL_EVENT& aEvent ); ///> Hides ratsnest for selected items. Called when there are no items selected. - int HideSelectionRatsnest( const TOOL_EVENT& aEvent ); + int HideDynamicRatsnest( const TOOL_EVENT& aEvent ); ///> Shows local ratsnest of a component int LocalRatsnestTool( const TOOL_EVENT& aEvent ); diff --git a/pcbnew/tools/selection_tool.cpp b/pcbnew/tools/selection_tool.cpp index bfd2870e24..8239e4a8e6 100644 --- a/pcbnew/tools/selection_tool.cpp +++ b/pcbnew/tools/selection_tool.cpp @@ -1352,7 +1352,7 @@ void SELECTION_TOOL::clearSelection() // Inform other potentially interested tools m_toolMgr->ProcessEvent( EVENTS::ClearedEvent ); - m_toolMgr->RunAction( PCB_ACTIONS::hideLocalRatsnest, true ); + m_toolMgr->RunAction( PCB_ACTIONS::hideDynamicRatsnest, true ); } diff --git a/qa/qa_utils/mocks.cpp b/qa/qa_utils/mocks.cpp index 6b94490eed..17667fa605 100644 --- a/qa/qa_utils/mocks.cpp +++ b/qa/qa_utils/mocks.cpp @@ -229,9 +229,8 @@ MODULE* PCB_BASE_FRAME::GetFootprintFromBoardByReference() return nullptr; } -TOOL_ACTION PCB_ACTIONS::hideLocalRatsnest( "pcbnew.Control.hideLocalRatsnest", - AS_GLOBAL, 0, - "", "" ); +TOOL_ACTION PCB_ACTIONS::hideDynamicRatsnest( + "pcbnew.Control.hideLocalRatsnest", AS_GLOBAL, 0, "", "" ); TOOL_ACTION PCB_ACTIONS::flip( "pcbnew.InteractiveEdit.flip", AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_FLIP_ITEM ),