2007-08-20 01:20:48 +00:00
|
|
|
/********************************************/
|
|
|
|
/* library editor: undo and redo functions */
|
|
|
|
/********************************************/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
#include "fctsys.h"
|
2009-07-29 13:10:36 +00:00
|
|
|
#include "class_drawpanel.h"
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
#include "pcbnew.h"
|
2009-07-30 11:04:07 +00:00
|
|
|
#include "wxPcbStruct.h"
|
2010-08-10 18:34:26 +00:00
|
|
|
#include "module_editor_frame.h"
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
#include "protos.h"
|
|
|
|
|
|
|
|
|
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
|
|
|
|
2009-01-05 05:21:35 +00:00
|
|
|
CopyItem = new MODULE( GetBoard() );
|
2009-08-03 18:54:48 +00:00
|
|
|
CopyItem->Copy( (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) */
|
2008-11-24 06:53:43 +00:00
|
|
|
for( item = CopyItem->m_Drawings; item != NULL; item = item->Next() )
|
2007-08-20 01:20:48 +00:00
|
|
|
item->m_Flags = 0;
|
|
|
|
|
|
|
|
/* 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();
|
2009-08-04 18:21:32 +00:00
|
|
|
module = (MODULE *)wrapper.m_PickedItem;
|
|
|
|
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();
|
2009-07-29 13:10:36 +00:00
|
|
|
DrawPanel->Refresh();
|
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();
|
2009-08-04 18:21:32 +00:00
|
|
|
module = (MODULE *)wrapper.m_PickedItem;
|
|
|
|
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();
|
2009-07-29 13:10:36 +00:00
|
|
|
DrawPanel->Refresh();
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|