2007-08-20 01:20:48 +00:00
|
|
|
/********************************************/
|
|
|
|
/* library editor: undo and redo functions */
|
|
|
|
/********************************************/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
|
|
|
#include <class_drawpanel.h>
|
|
|
|
#include <wxPcbStruct.h>
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <class_board.h>
|
|
|
|
#include <class_module.h>
|
2011-09-23 13:57:12 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <pcbnew.h>
|
|
|
|
#include <protos.h>
|
|
|
|
#include <module_editor_frame.h>
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
|
2011-08-26 17:01:17 +00:00
|
|
|
void FOOTPRINT_EDIT_FRAME::SaveCopyInUndoList( BOARD_ITEM* aItem,
|
|
|
|
UNDO_REDO_T aTypeCommand,
|
|
|
|
const wxPoint& aTransformPoint )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2010-12-08 20:12:46 +00:00
|
|
|
EDA_ITEM* item;
|
2009-08-03 18:54:48 +00:00
|
|
|
MODULE* CopyItem;
|
2009-07-23 15:37:00 +00:00
|
|
|
PICKED_ITEMS_LIST* lastcmd;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2012-01-14 19:50:32 +00:00
|
|
|
CopyItem = new MODULE( *( (MODULE*) aItem ) );
|
2009-01-05 05:21:35 +00:00
|
|
|
CopyItem->SetParent( GetBoard() );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-07-23 15:37:00 +00:00
|
|
|
lastcmd = new PICKED_ITEMS_LIST();
|
2009-08-03 18:54:48 +00:00
|
|
|
ITEM_PICKER wrapper( CopyItem, UR_MODEDIT );
|
|
|
|
lastcmd->PushItem( wrapper );
|
2009-07-23 15:37:00 +00:00
|
|
|
|
|
|
|
GetScreen()->PushCommandToUndoList( lastcmd );
|
2007-08-20 01:20:48 +00:00
|
|
|
/* Clear current flags (which can be temporary set by a current edit command) */
|
2013-03-18 19:36:07 +00:00
|
|
|
for( item = CopyItem->GraphicalItems(); item != NULL; item = item->Next() )
|
2011-12-21 13:42:02 +00:00
|
|
|
item->ClearFlags();
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
/* Clear redo list, because after new save there is no redo to do */
|
2009-08-03 18:54:48 +00:00
|
|
|
GetScreen()->ClearUndoORRedoList( GetScreen()->m_RedoList );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-08-26 17:01:17 +00:00
|
|
|
void FOOTPRINT_EDIT_FRAME::SaveCopyInUndoList( PICKED_ITEMS_LIST& aItemsList,
|
|
|
|
UNDO_REDO_T aTypeCommand,
|
|
|
|
const wxPoint& aTransformPoint )
|
2009-08-03 18:54:48 +00:00
|
|
|
{
|
2009-08-04 18:21:32 +00:00
|
|
|
// Currently unused in modedit, because the module itself is saved for each change
|
2009-08-03 18:54:48 +00:00
|
|
|
wxMessageBox( wxT( "SaveCopyInUndoList( PICKED_ITEMS_LIST& aItemsList..) not yet in use" ) );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2011-08-26 17:01:17 +00:00
|
|
|
void FOOTPRINT_EDIT_FRAME::GetComponentFromRedoList( wxCommandEvent& event )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2009-08-03 18:54:48 +00:00
|
|
|
if( GetScreen()->GetRedoCommandCount() <= 0 )
|
2007-08-20 01:20:48 +00:00
|
|
|
return;
|
|
|
|
|
2009-08-04 18:21:32 +00:00
|
|
|
// Save current module state in undo list
|
2009-07-23 15:37:00 +00:00
|
|
|
PICKED_ITEMS_LIST* lastcmd = new PICKED_ITEMS_LIST();
|
2009-08-04 18:21:32 +00:00
|
|
|
MODULE * module = GetBoard()->m_Modules.PopFront();
|
|
|
|
ITEM_PICKER wrapper( module, UR_MODEDIT );
|
2009-08-03 18:54:48 +00:00
|
|
|
lastcmd->PushItem( wrapper );
|
2009-07-23 15:37:00 +00:00
|
|
|
GetScreen()->PushCommandToUndoList( lastcmd );
|
|
|
|
|
2009-08-04 18:21:32 +00:00
|
|
|
// Retrieve last module state from undo list
|
2009-08-03 18:54:48 +00:00
|
|
|
lastcmd = GetScreen()->PopCommandFromRedoList();
|
2009-07-23 15:37:00 +00:00
|
|
|
wrapper = lastcmd->PopItem();
|
2012-02-05 13:02:46 +00:00
|
|
|
module = (MODULE *)wrapper.GetItem();
|
2009-08-04 18:21:32 +00:00
|
|
|
delete lastcmd;
|
2008-12-04 04:28:11 +00:00
|
|
|
|
2009-08-04 18:21:32 +00:00
|
|
|
if( module )
|
|
|
|
GetBoard()->Add( module );
|
|
|
|
|
|
|
|
SetCurItem( NULL );
|
2008-12-04 04:28:11 +00:00
|
|
|
|
2010-02-19 13:23:58 +00:00
|
|
|
OnModify();
|
2013-09-06 09:31:16 +00:00
|
|
|
RefreshCanvas();
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2011-08-26 17:01:17 +00:00
|
|
|
void FOOTPRINT_EDIT_FRAME::GetComponentFromUndoList( wxCommandEvent& event )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2009-08-03 18:54:48 +00:00
|
|
|
if( GetScreen()->GetUndoCommandCount() <= 0 )
|
2007-08-20 01:20:48 +00:00
|
|
|
return;
|
|
|
|
|
2009-08-04 18:21:32 +00:00
|
|
|
// Save current module state in redo list
|
2009-07-23 15:37:00 +00:00
|
|
|
PICKED_ITEMS_LIST* lastcmd = new PICKED_ITEMS_LIST();
|
2009-08-04 18:21:32 +00:00
|
|
|
MODULE * module = GetBoard()->m_Modules.PopFront();
|
|
|
|
ITEM_PICKER wrapper( module, UR_MODEDIT );
|
2009-08-03 18:54:48 +00:00
|
|
|
lastcmd->PushItem( wrapper );
|
2009-07-23 15:37:00 +00:00
|
|
|
GetScreen()->PushCommandToRedoList( lastcmd );
|
|
|
|
|
2009-08-04 18:21:32 +00:00
|
|
|
// Retrieve last module state from undo list
|
2009-08-03 18:54:48 +00:00
|
|
|
lastcmd = GetScreen()->PopCommandFromUndoList();
|
2009-07-23 15:37:00 +00:00
|
|
|
wrapper = lastcmd->PopItem();
|
2012-02-05 13:02:46 +00:00
|
|
|
module = (MODULE *)wrapper.GetItem();
|
2009-08-04 18:21:32 +00:00
|
|
|
delete lastcmd;
|
2008-12-04 04:28:11 +00:00
|
|
|
|
2009-08-04 18:21:32 +00:00
|
|
|
if( module )
|
|
|
|
GetBoard()->Add( module, ADD_APPEND );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2008-12-06 08:21:54 +00:00
|
|
|
|
2011-03-03 19:08:13 +00:00
|
|
|
SetCurItem( NULL );
|
2009-08-04 18:21:32 +00:00
|
|
|
|
2010-02-19 13:23:58 +00:00
|
|
|
OnModify();
|
2013-09-06 09:31:16 +00:00
|
|
|
RefreshCanvas();
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|