From bb618f2d55edd0aa2e74562e1c97c80a9b2cb1b6 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sat, 5 Nov 2022 16:36:10 +0000 Subject: [PATCH] Update pointEditor after cancelled move. --- pcbnew/tools/edit_tool_move_fct.cpp | 26 +++++++++++++++++--------- pcbnew/tools/pcb_point_editor.cpp | 1 + 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/pcbnew/tools/edit_tool_move_fct.cpp b/pcbnew/tools/edit_tool_move_fct.cpp index 624ab5da1b..720f855636 100644 --- a/pcbnew/tools/edit_tool_move_fct.cpp +++ b/pcbnew/tools/edit_tool_move_fct.cpp @@ -749,26 +749,34 @@ int EDIT_TOOL::doMoveSelection( const TOOL_EVENT& aEvent, bool aPickReference ) m_dragging = false; editFrame->UndoRedoBlock( false ); - m_toolMgr->GetTool()->UpdateStatusBar(); - - if( hasRedrawn3D && restore_state ) - editFrame->Update3DView( false, true ); - // Discard reference point when selection is "dropped" onto the board selection.ClearReferencePoint(); // Unselect all items to clear selection flags and then re-select the originally selected - // items. + // items (after the potential Revert()). m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true ); - m_toolMgr->RunAction( PCB_ACTIONS::selectItems, true, &orig_items ); // TODO: there's an encapsulation leak here: this commit often has more than just the move // in it; for instance it might have a paste, append board, etc. as well. if( restore_state ) + { m_commit->Revert(); - else - m_commit->Push( _( "Drag" ) ); + // Mainly for point editor, but there might be other clients that need to adjust to + // reverted state. + m_toolMgr->PostEvent( EVENTS::SelectedItemsMoved ); + + if( hasRedrawn3D ) + editFrame->Update3DView( false, true ); + } + else + { + m_commit->Push( _( "Drag" ) ); + } + + m_toolMgr->RunAction( PCB_ACTIONS::selectItems, true, &orig_items ); + + m_toolMgr->GetTool()->UpdateStatusBar(); // Remove the dynamic ratsnest from the screen m_toolMgr->RunAction( PCB_ACTIONS::hideLocalRatsnest, true ); diff --git a/pcbnew/tools/pcb_point_editor.cpp b/pcbnew/tools/pcb_point_editor.cpp index ca163f116f..8af462d0fa 100644 --- a/pcbnew/tools/pcb_point_editor.cpp +++ b/pcbnew/tools/pcb_point_editor.cpp @@ -2472,6 +2472,7 @@ void PCB_POINT_EDITOR::setTransitions() Go( &PCB_POINT_EDITOR::addCorner, PCB_ACTIONS::pointEditorAddCorner.MakeEvent() ); Go( &PCB_POINT_EDITOR::removeCorner, PCB_ACTIONS::pointEditorRemoveCorner.MakeEvent() ); Go( &PCB_POINT_EDITOR::modifiedSelection, EVENTS::SelectedItemsModified ); + Go( &PCB_POINT_EDITOR::modifiedSelection, EVENTS::SelectedItemsMoved ); Go( &PCB_POINT_EDITOR::OnSelectionChange, EVENTS::PointSelectedEvent ); Go( &PCB_POINT_EDITOR::OnSelectionChange, EVENTS::SelectedEvent ); Go( &PCB_POINT_EDITOR::OnSelectionChange, EVENTS::UnselectedEvent );