diff --git a/common/tool/tool_event.cpp b/common/tool/tool_event.cpp index f46ca0d1fb..044feffb67 100644 --- a/common/tool/tool_event.cpp +++ b/common/tool/tool_event.cpp @@ -89,7 +89,8 @@ const std::string TOOL_EVENT::Format() const { TA_CANCEL_TOOL, "cancel-tool" }, { TA_CONTEXT_MENU_UPDATE, "context-menu-update" }, { TA_CONTEXT_MENU_CHOICE, "context-menu-choice" }, - { TA_UNDO_REDO, "undo-redo" }, + { TA_UNDO_REDO_PRE, "undo-redo-pre" }, + { TA_UNDO_REDO_POST, "undo-redo-post" }, { TA_ACTION, "action" }, { TA_ACTIVATE, "activate" }, { 0, "" } diff --git a/include/tool/tool_event.h b/include/tool/tool_event.h index cd64c674cd..afad91622a 100644 --- a/include/tool/tool_event.h +++ b/include/tool/tool_event.h @@ -95,13 +95,16 @@ enum TOOL_ACTIONS TA_CONTEXT_MENU = TA_CONTEXT_MENU_UPDATE | TA_CONTEXT_MENU_CHOICE | TA_CONTEXT_MENU_CLOSED, // This event is sent *before* undo/redo command is performed. - TA_UNDO_REDO = 0x20000, + TA_UNDO_REDO_PRE = 0x20000, + + // This event is sent *after* undo/redo command is performed. + TA_UNDO_REDO_POST = 0x40000, // Tool action (allows to control tools). - TA_ACTION = 0x40000, + TA_ACTION = 0x80000, // Tool activation event. - TA_ACTIVATE = 0x80000, + TA_ACTIVATE = 0x100000, TA_ANY = 0xffffffff }; diff --git a/pcbnew/router/router_tool.cpp b/pcbnew/router/router_tool.cpp index 79f71a2205..8869a6967a 100644 --- a/pcbnew/router/router_tool.cpp +++ b/pcbnew/router/router_tool.cpp @@ -685,7 +685,11 @@ int ROUTER_TOOL::mainLoop( PNS::ROUTER_MODE aMode ) { break; // Finish } - else if( evt->Action() == TA_UNDO_REDO ) + else if( evt->Action() == TA_UNDO_REDO_PRE ) + { + m_router->ClearWorld(); + } + else if( evt->Action() == TA_UNDO_REDO_POST ) { m_router->SyncWorld(); } diff --git a/pcbnew/tools/edit_tool.cpp b/pcbnew/tools/edit_tool.cpp index 18021476ed..880ee1cc41 100644 --- a/pcbnew/tools/edit_tool.cpp +++ b/pcbnew/tools/edit_tool.cpp @@ -173,7 +173,7 @@ int EDIT_TOOL::Main( const TOOL_EVENT& aEvent ) break; // Finish } - else if( evt->Action() == TA_UNDO_REDO ) + else if( evt->Action() == TA_UNDO_REDO_PRE ) { unselect = true; break; diff --git a/pcbnew/tools/selection_tool.cpp b/pcbnew/tools/selection_tool.cpp index c8f2033013..ba0b3585a0 100644 --- a/pcbnew/tools/selection_tool.cpp +++ b/pcbnew/tools/selection_tool.cpp @@ -260,7 +260,7 @@ int SELECTION_TOOL::Main( const TOOL_EVENT& aEvent ) UnselectItem( *evt ); } - else if( evt->IsCancel() || evt->Action() == TA_UNDO_REDO || + else if( evt->IsCancel() || evt->Action() == TA_UNDO_REDO_PRE || evt->IsAction( &COMMON_ACTIONS::selectionClear ) ) { clearSelection(); diff --git a/pcbnew/undo_redo.cpp b/pcbnew/undo_redo.cpp index cd6e3d0900..7bdd2a8172 100644 --- a/pcbnew/undo_redo.cpp +++ b/pcbnew/undo_redo.cpp @@ -321,8 +321,7 @@ void PCB_BASE_EDIT_FRAME::RestoreCopyFromUndoList( wxCommandEvent& aEvent ) return; // Inform tools that undo command was issued - TOOL_EVENT event( TC_MESSAGE, TA_UNDO_REDO, AS_GLOBAL ); - m_toolManager->ProcessEvent( event ); + m_toolManager->ProcessEvent( { TC_MESSAGE, TA_UNDO_REDO_PRE, AS_GLOBAL } ); // Get the old list PICKED_ITEMS_LIST* List = GetScreen()->PopCommandFromUndoList(); @@ -335,6 +334,9 @@ void PCB_BASE_EDIT_FRAME::RestoreCopyFromUndoList( wxCommandEvent& aEvent ) GetScreen()->PushCommandToRedoList( List ); OnModify(); + + m_toolManager->ProcessEvent( { TC_MESSAGE, TA_UNDO_REDO_POST, AS_GLOBAL } ); + m_canvas->Refresh(); } @@ -348,8 +350,7 @@ void PCB_BASE_EDIT_FRAME::RestoreCopyFromRedoList( wxCommandEvent& aEvent ) return; // Inform tools that redo command was issued - TOOL_EVENT event( TC_MESSAGE, TA_UNDO_REDO, AS_GLOBAL ); - m_toolManager->ProcessEvent( event ); + m_toolManager->ProcessEvent( { TC_MESSAGE, TA_UNDO_REDO_PRE, AS_GLOBAL } ); // Get the old list PICKED_ITEMS_LIST* List = GetScreen()->PopCommandFromRedoList(); @@ -362,6 +363,9 @@ void PCB_BASE_EDIT_FRAME::RestoreCopyFromRedoList( wxCommandEvent& aEvent ) GetScreen()->PushCommandToUndoList( List ); OnModify(); + + m_toolManager->ProcessEvent( { TC_MESSAGE, TA_UNDO_REDO_POST, AS_GLOBAL } ); + m_canvas->Refresh(); }