Commit 3e2e11fb authored by Maciej Suminski's avatar Maciej Suminski

Undo/redo buffer fixed once again..

parent 24ba75ba
......@@ -89,7 +89,7 @@ enum TOOL_ACTIONS
// closed it without selecting anything.
TA_CONTEXT_MENU_CHOICE = 0x10000,
// This event is sent *after* undo/redo command is finished.
// This event is sent *before* undo/redo command is performed.
TA_UNDO_REDO = 0x20000,
// Tool action (allows to control tools)
......
......@@ -523,8 +523,8 @@ void PCB_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bool aRed
{
MODULE* oldModule = static_cast<MODULE*>( item );
oldModule->RunOnChildren( std::bind1st( std::mem_fun( &KIGFX::VIEW::Remove ), view ) );
oldModule->RunOnChildren( std::bind1st( std::mem_fun( &RN_DATA::Remove ), ratsnest ) );
}
ratsnest->Remove( item );
item->SwapData( image );
......@@ -534,8 +534,8 @@ void PCB_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bool aRed
{
MODULE* newModule = static_cast<MODULE*>( item );
newModule->RunOnChildren( std::bind1st( std::mem_fun( &KIGFX::VIEW::Add ), view ) );
newModule->RunOnChildren( std::bind1st( std::mem_fun( &RN_DATA::Add ), ratsnest ) );
}
ratsnest->Add( item );
item->ViewUpdate( KIGFX::VIEW_ITEM::LAYERS );
}
......@@ -626,6 +626,10 @@ void PCB_EDIT_FRAME::GetBoardFromUndoList( wxCommandEvent& aEvent )
if( GetScreen()->GetUndoCommandCount() <= 0 )
return;
// Inform tools that undo command was issued
TOOL_EVENT event( TC_MESSAGE, TA_UNDO_REDO, AS_GLOBAL );
m_toolManager->ProcessEvent( event );
/* Get the old list */
PICKED_ITEMS_LIST* List = GetScreen()->PopCommandFromUndoList();
/* Undo the command */
......@@ -635,10 +639,6 @@ void PCB_EDIT_FRAME::GetBoardFromUndoList( wxCommandEvent& aEvent )
List->ReversePickersListOrder();
GetScreen()->PushCommandToRedoList( List );
// Inform tools that undo has just occurred
TOOL_EVENT event( TC_MESSAGE, TA_UNDO_REDO, AS_GLOBAL );
m_toolManager->ProcessEvent( event );
OnModify();
m_canvas->Refresh();
}
......@@ -649,6 +649,10 @@ void PCB_EDIT_FRAME::GetBoardFromRedoList( wxCommandEvent& aEvent )
if( GetScreen()->GetRedoCommandCount() == 0 )
return;
// Inform tools that redo command was issued
TOOL_EVENT event( TC_MESSAGE, TA_UNDO_REDO, AS_GLOBAL );
m_toolManager->ProcessEvent( event );
/* Get the old list */
PICKED_ITEMS_LIST* List = GetScreen()->PopCommandFromRedoList();
......@@ -659,10 +663,6 @@ void PCB_EDIT_FRAME::GetBoardFromRedoList( wxCommandEvent& aEvent )
List->ReversePickersListOrder();
GetScreen()->PushCommandToUndoList( List );
// Inform tools that redo has just occurred
TOOL_EVENT event( TC_MESSAGE, TA_UNDO_REDO, AS_GLOBAL );
m_toolManager->ProcessEvent( event );
OnModify();
m_canvas->Refresh();
}
......
......@@ -31,7 +31,6 @@
#include <pcb_painter.h>
#include <tool/context_menu.h>
#include <tool/tool_action.h>
#include "router_tool.h"
#include "pns_segment.h"
......@@ -82,6 +81,7 @@ void ROUTER_TOOL::Reset( RESET_REASON aReason )
m_router->ClearWorld();
m_router->SetBoard( getModel<BOARD>( PCB_T ) );
m_router->SyncWorld();
m_needsSync = false;
if( getView() )
m_router->SetView( getView() );
......@@ -380,13 +380,14 @@ void ROUTER_TOOL::startRouting()
if( saveUndoBuffer )
{
// Save the recent changes in the undo buffer
getEditFrame<PCB_EDIT_FRAME>()->SaveCopyInUndoList( m_router->GetLastChanges(), UR_UNSPECIFIED );
getEditFrame<PCB_EDIT_FRAME>()->SaveCopyInUndoList( m_router->GetLastChanges(),
UR_UNSPECIFIED );
getEditFrame<PCB_EDIT_FRAME>()->OnModify();
}
else
{
// It was interrupted by TA_UNDO_REDO event, so we have to sync the world now
m_router->SyncWorld();
m_needsSync = true;
}
ctls->SetAutoPan( false );
......@@ -408,10 +409,16 @@ int ROUTER_TOOL::Main( TOOL_EVENT& aEvent )
// Main loop: keep receiving events
while( OPT_TOOL_EVENT evt = Wait() )
{
if( m_needsSync )
{
m_router->SyncWorld();
m_needsSync = false;
}
if( evt->IsCancel() )
break; // Finish
else if( evt->Action() == TA_UNDO_REDO )
m_router->SyncWorld();
m_needsSync = true;
else if( evt->IsMotion() )
updateStartItem( *evt );
else if( evt->IsClick( BUT_LEFT ) )
......
......@@ -72,6 +72,9 @@ private:
PNS_ITEM* m_endItem;
VECTOR2I m_endSnapPoint;
///> Flag marking that the router's world needs syncing.
bool m_needsSync;
/*boost::shared_ptr<CONTEXT_MENU> m_menu;*/
CONTEXT_MENU* m_menu;
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment