Undo/redo buffer fixed once again..
This commit is contained in:
parent
24ba75ba92
commit
3e2e11fb42
|
@ -89,7 +89,7 @@ enum TOOL_ACTIONS
|
||||||
// closed it without selecting anything.
|
// closed it without selecting anything.
|
||||||
TA_CONTEXT_MENU_CHOICE = 0x10000,
|
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,
|
TA_UNDO_REDO = 0x20000,
|
||||||
|
|
||||||
// Tool action (allows to control tools)
|
// 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 );
|
MODULE* oldModule = static_cast<MODULE*>( item );
|
||||||
oldModule->RunOnChildren( std::bind1st( std::mem_fun( &KIGFX::VIEW::Remove ), view ) );
|
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 );
|
item->SwapData( image );
|
||||||
|
|
||||||
|
@ -534,8 +534,8 @@ void PCB_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bool aRed
|
||||||
{
|
{
|
||||||
MODULE* newModule = static_cast<MODULE*>( item );
|
MODULE* newModule = static_cast<MODULE*>( item );
|
||||||
newModule->RunOnChildren( std::bind1st( std::mem_fun( &KIGFX::VIEW::Add ), view ) );
|
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 );
|
item->ViewUpdate( KIGFX::VIEW_ITEM::LAYERS );
|
||||||
}
|
}
|
||||||
|
@ -626,6 +626,10 @@ void PCB_EDIT_FRAME::GetBoardFromUndoList( wxCommandEvent& aEvent )
|
||||||
if( GetScreen()->GetUndoCommandCount() <= 0 )
|
if( GetScreen()->GetUndoCommandCount() <= 0 )
|
||||||
return;
|
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 */
|
/* Get the old list */
|
||||||
PICKED_ITEMS_LIST* List = GetScreen()->PopCommandFromUndoList();
|
PICKED_ITEMS_LIST* List = GetScreen()->PopCommandFromUndoList();
|
||||||
/* Undo the command */
|
/* Undo the command */
|
||||||
|
@ -635,10 +639,6 @@ void PCB_EDIT_FRAME::GetBoardFromUndoList( wxCommandEvent& aEvent )
|
||||||
List->ReversePickersListOrder();
|
List->ReversePickersListOrder();
|
||||||
GetScreen()->PushCommandToRedoList( List );
|
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();
|
OnModify();
|
||||||
m_canvas->Refresh();
|
m_canvas->Refresh();
|
||||||
}
|
}
|
||||||
|
@ -649,6 +649,10 @@ void PCB_EDIT_FRAME::GetBoardFromRedoList( wxCommandEvent& aEvent )
|
||||||
if( GetScreen()->GetRedoCommandCount() == 0 )
|
if( GetScreen()->GetRedoCommandCount() == 0 )
|
||||||
return;
|
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 */
|
/* Get the old list */
|
||||||
PICKED_ITEMS_LIST* List = GetScreen()->PopCommandFromRedoList();
|
PICKED_ITEMS_LIST* List = GetScreen()->PopCommandFromRedoList();
|
||||||
|
|
||||||
|
@ -659,10 +663,6 @@ void PCB_EDIT_FRAME::GetBoardFromRedoList( wxCommandEvent& aEvent )
|
||||||
List->ReversePickersListOrder();
|
List->ReversePickersListOrder();
|
||||||
GetScreen()->PushCommandToUndoList( List );
|
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();
|
OnModify();
|
||||||
m_canvas->Refresh();
|
m_canvas->Refresh();
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,6 @@
|
||||||
#include <pcb_painter.h>
|
#include <pcb_painter.h>
|
||||||
|
|
||||||
#include <tool/context_menu.h>
|
#include <tool/context_menu.h>
|
||||||
#include <tool/tool_action.h>
|
|
||||||
|
|
||||||
#include "router_tool.h"
|
#include "router_tool.h"
|
||||||
#include "pns_segment.h"
|
#include "pns_segment.h"
|
||||||
|
@ -82,6 +81,7 @@ void ROUTER_TOOL::Reset( RESET_REASON aReason )
|
||||||
m_router->ClearWorld();
|
m_router->ClearWorld();
|
||||||
m_router->SetBoard( getModel<BOARD>( PCB_T ) );
|
m_router->SetBoard( getModel<BOARD>( PCB_T ) );
|
||||||
m_router->SyncWorld();
|
m_router->SyncWorld();
|
||||||
|
m_needsSync = false;
|
||||||
|
|
||||||
if( getView() )
|
if( getView() )
|
||||||
m_router->SetView( getView() );
|
m_router->SetView( getView() );
|
||||||
|
@ -380,13 +380,14 @@ void ROUTER_TOOL::startRouting()
|
||||||
if( saveUndoBuffer )
|
if( saveUndoBuffer )
|
||||||
{
|
{
|
||||||
// Save the recent changes in the undo buffer
|
// 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();
|
getEditFrame<PCB_EDIT_FRAME>()->OnModify();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// It was interrupted by TA_UNDO_REDO event, so we have to sync the world now
|
// 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 );
|
ctls->SetAutoPan( false );
|
||||||
|
@ -408,10 +409,16 @@ int ROUTER_TOOL::Main( TOOL_EVENT& aEvent )
|
||||||
// Main loop: keep receiving events
|
// Main loop: keep receiving events
|
||||||
while( OPT_TOOL_EVENT evt = Wait() )
|
while( OPT_TOOL_EVENT evt = Wait() )
|
||||||
{
|
{
|
||||||
|
if( m_needsSync )
|
||||||
|
{
|
||||||
|
m_router->SyncWorld();
|
||||||
|
m_needsSync = false;
|
||||||
|
}
|
||||||
|
|
||||||
if( evt->IsCancel() )
|
if( evt->IsCancel() )
|
||||||
break; // Finish
|
break; // Finish
|
||||||
else if( evt->Action() == TA_UNDO_REDO )
|
else if( evt->Action() == TA_UNDO_REDO )
|
||||||
m_router->SyncWorld();
|
m_needsSync = true;
|
||||||
else if( evt->IsMotion() )
|
else if( evt->IsMotion() )
|
||||||
updateStartItem( *evt );
|
updateStartItem( *evt );
|
||||||
else if( evt->IsClick( BUT_LEFT ) )
|
else if( evt->IsClick( BUT_LEFT ) )
|
||||||
|
|
|
@ -72,6 +72,9 @@ private:
|
||||||
PNS_ITEM* m_endItem;
|
PNS_ITEM* m_endItem;
|
||||||
VECTOR2I m_endSnapPoint;
|
VECTOR2I m_endSnapPoint;
|
||||||
|
|
||||||
|
///> Flag marking that the router's world needs syncing.
|
||||||
|
bool m_needsSync;
|
||||||
|
|
||||||
/*boost::shared_ptr<CONTEXT_MENU> m_menu;*/
|
/*boost::shared_ptr<CONTEXT_MENU> m_menu;*/
|
||||||
CONTEXT_MENU* m_menu;
|
CONTEXT_MENU* m_menu;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue