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 "common.h"
|
|
|
|
#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"
|
|
|
|
|
|
|
|
|
2010-11-12 16:36:43 +00:00
|
|
|
/**
|
|
|
|
* Function SaveCopyInUndoList.
|
2009-08-03 18:54:48 +00:00
|
|
|
* Creates a new entry in undo list of commands.
|
|
|
|
* add a picker to handle aItemToCopy
|
|
|
|
* @param aItem = the board item modified by the command to undo
|
2011-04-05 14:46:51 +00:00
|
|
|
* @param aTypeCommand = command type (see enum UNDO_REDO_T)
|
2009-08-03 18:54:48 +00:00
|
|
|
* @param aTransformPoint = the reference point of the transformation, for commands like move
|
|
|
|
*/
|
|
|
|
void WinEDA_ModuleEditFrame::SaveCopyInUndoList( BOARD_ITEM* aItem,
|
2011-04-05 14:46:51 +00:00
|
|
|
UNDO_REDO_T aTypeCommand,
|
2009-08-03 18:54:48 +00:00
|
|
|
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 );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-12 16:36:43 +00:00
|
|
|
/**
|
|
|
|
* Function SaveCopyInUndoList (overloaded).
|
2009-08-03 18:54:48 +00:00
|
|
|
* Creates a new entry in undo list of commands.
|
|
|
|
* add a list of pickers to handle a list of items
|
|
|
|
* @param aItemsList = the list of items modified by the command to undo
|
2011-04-05 14:46:51 +00:00
|
|
|
* @param aTypeCommand = command type (see enum UNDO_REDO_T)
|
2009-08-03 18:54:48 +00:00
|
|
|
* @param aTransformPoint = the reference point of the transformation, for commands like move
|
|
|
|
*/
|
|
|
|
void WinEDA_ModuleEditFrame::SaveCopyInUndoList( PICKED_ITEMS_LIST& aItemsList,
|
2011-04-05 14:46:51 +00:00
|
|
|
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
|
|
|
|
2009-08-04 18:21:32 +00:00
|
|
|
/********************************************************************************/
|
2009-08-03 18:54:48 +00:00
|
|
|
void WinEDA_ModuleEditFrame::GetComponentFromRedoList( wxCommandEvent& event )
|
2009-08-04 18:21:32 +00:00
|
|
|
/********************************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/* Redo the last edition:
|
2007-08-20 01:20:48 +00:00
|
|
|
* - Place the current edited library component in undo list
|
|
|
|
* - Get old version of the current edited library component
|
|
|
|
*/
|
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
|
|
|
|
2009-07-29 13:10:36 +00:00
|
|
|
/***************************************************************************/
|
2009-08-03 18:54:48 +00:00
|
|
|
void WinEDA_ModuleEditFrame::GetComponentFromUndoList( wxCommandEvent& event )
|
2009-07-29 13:10:36 +00:00
|
|
|
/***************************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/* Undo the last edition:
|
2007-08-20 01:20:48 +00:00
|
|
|
* - Place the current edited library component in Redo list
|
|
|
|
* - Get old version of the current edited library component
|
|
|
|
*/
|
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
|
|
|
}
|