Undo buffer for the PNS router. Still, it has a bug - it crashes when an undo/redo operation is performed while routing a track.
This commit is contained in:
parent
a73e386505
commit
bbb3972fb7
|
@ -241,7 +241,6 @@ void PNS_ROUTER::SyncWorld()
|
|||
|
||||
ClearWorld();
|
||||
|
||||
|
||||
m_clearanceFunc = new PCBNEW_CLEARANCE_FUNC( m_board );
|
||||
m_world = new PNS_NODE();
|
||||
m_world->SetClearanceFunctor( m_clearanceFunc );
|
||||
|
@ -584,8 +583,9 @@ void PNS_ROUTER::commitRouting( PNS_NODE* aNode )
|
|||
|
||||
if( parent )
|
||||
{
|
||||
m_view->Remove( parent );
|
||||
m_undoBuffer.PushItem( ITEM_PICKER( parent, UR_DELETED ) );
|
||||
m_board->Remove( parent );
|
||||
m_view->Remove( parent );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -632,6 +632,7 @@ void PNS_ROUTER::commitRouting( PNS_NODE* aNode )
|
|||
m_view->Add( newBI );
|
||||
m_board->Add( newBI );
|
||||
m_board->GetRatsnest()->Update( newBI );
|
||||
m_undoBuffer.PushItem( ITEM_PICKER( newBI, UR_NEW ) );
|
||||
newBI->ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include <boost/unordered_set.hpp>
|
||||
|
||||
#include <geometry/shape_line_chain.h>
|
||||
#include <class_undoredo_container.h>
|
||||
|
||||
#include "pns_routing_settings.h"
|
||||
#include "pns_item.h"
|
||||
|
@ -137,6 +138,18 @@ public:
|
|||
const PNS_ITEMSET QueryHoverItems( const VECTOR2I& aP );
|
||||
const VECTOR2I SnapToItem( PNS_ITEM* item, VECTOR2I aP, bool& aSplitsSegment );
|
||||
|
||||
/**
|
||||
* Returns the last changes introduced by the router. After calling the method the list of
|
||||
* changes is cleared, so only the latest changes are stored.
|
||||
*/
|
||||
PICKED_ITEMS_LIST GetLastChanges()
|
||||
{
|
||||
PICKED_ITEMS_LIST copy = m_undoBuffer;
|
||||
m_undoBuffer.ClearItemsList(); // TODO and delete?
|
||||
|
||||
return copy;
|
||||
}
|
||||
|
||||
private:
|
||||
void clearViewFlags();
|
||||
|
||||
|
@ -188,6 +201,9 @@ private:
|
|||
PNS_CLEARANCE_FUNC* m_clearanceFunc;
|
||||
|
||||
boost::unordered_set<BOARD_ITEM*> m_hiddenItems;
|
||||
|
||||
///> Stores list of modified items in the current operation
|
||||
PICKED_ITEMS_LIST m_undoBuffer;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -322,6 +322,11 @@ void ROUTER_TOOL::startRouting()
|
|||
updateEndItem( *evt );
|
||||
m_router->Move( m_endSnapPoint, m_endItem );
|
||||
}
|
||||
else if( evt->Action() == TA_UNDO_REDO )
|
||||
{
|
||||
std::cout << "syncing the world while routing, I am going to craaaaaaaaaaaash!" << std::endl;
|
||||
m_router->SyncWorld();
|
||||
}
|
||||
else if( evt->IsClick( BUT_LEFT ) )
|
||||
{
|
||||
updateEndItem( *evt );
|
||||
|
@ -371,6 +376,10 @@ void ROUTER_TOOL::startRouting()
|
|||
|
||||
m_router->StopRouting();
|
||||
|
||||
// Save the recent changes in the undo buffer
|
||||
getEditFrame<PCB_EDIT_FRAME>()->SaveCopyInUndoList( m_router->GetLastChanges(), UR_UNSPECIFIED );
|
||||
getEditFrame<PCB_EDIT_FRAME>()->OnModify();
|
||||
|
||||
ctls->SetAutoPan( false );
|
||||
ctls->ForceCursorPosition( false );
|
||||
highlightNet( false );
|
||||
|
@ -392,6 +401,8 @@ int ROUTER_TOOL::Main( TOOL_EVENT& aEvent )
|
|||
{
|
||||
if( evt->IsCancel() )
|
||||
break; // Finish
|
||||
else if( evt->Action() == TA_UNDO_REDO )
|
||||
m_router->SyncWorld();
|
||||
else if( evt->IsMotion() )
|
||||
updateStartItem( *evt );
|
||||
else if( evt->IsClick( BUT_LEFT ) )
|
||||
|
|
Loading…
Reference in New Issue