2008-11-24 06:53:43 +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 "program.h"
|
|
|
|
#include "libcmp.h"
|
|
|
|
#include "general.h"
|
2009-07-29 13:10:36 +00:00
|
|
|
//#include "id.h"
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
#include "protos.h"
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
2008-11-24 06:53:43 +00:00
|
|
|
void WinEDA_LibeditFrame::SaveCopyInUndoList( EDA_BaseStruct* ItemToCopy,
|
|
|
|
int unused_flag )
|
2007-06-05 12:10:51 +00:00
|
|
|
/*************************************************************************/
|
|
|
|
{
|
2009-09-18 14:56:05 +00:00
|
|
|
EDA_BaseStruct* item;
|
|
|
|
LIB_COMPONENT* CopyItem;
|
2009-07-23 15:37:00 +00:00
|
|
|
PICKED_ITEMS_LIST* lastcmd;
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2009-09-18 14:56:05 +00:00
|
|
|
CopyItem = CopyLibEntryStruct( (LIB_COMPONENT*) ItemToCopy );
|
2009-08-27 11:41:56 +00:00
|
|
|
|
|
|
|
if( CopyItem == NULL )
|
|
|
|
return;
|
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_LIBEDIT);
|
2009-07-23 15:37:00 +00:00
|
|
|
lastcmd->PushItem(wrapper);
|
|
|
|
GetScreen()->PushCommandToUndoList( lastcmd );
|
2008-11-24 06:53:43 +00:00
|
|
|
/* Clear current flags (which can be temporary set by a current edit command) */
|
|
|
|
for( item = CopyItem->m_Drawings; item != NULL; item = item->Next() )
|
|
|
|
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 );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/******************************************************/
|
2009-07-29 13:10:36 +00:00
|
|
|
void WinEDA_LibeditFrame::GetComponentFromRedoList(wxCommandEvent& event)
|
2007-05-06 16:03:28 +00:00
|
|
|
/******************************************************/
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/* Redo the last edition:
|
2008-11-24 06:53:43 +00:00
|
|
|
* - Place the current edited library component in undo list
|
|
|
|
* - Get old version of the current edited library component
|
2009-07-23 15:37:00 +00:00
|
|
|
* @return FALSE if nothing done, else true
|
2008-11-24 06:53:43 +00:00
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2009-07-23 15:37:00 +00:00
|
|
|
if ( GetScreen()->GetRedoCommandCount() <= 0 )
|
2009-07-29 13:10:36 +00:00
|
|
|
return;
|
2009-07-23 15:37:00 +00:00
|
|
|
|
|
|
|
PICKED_ITEMS_LIST* lastcmd = new PICKED_ITEMS_LIST();
|
2009-08-03 18:54:48 +00:00
|
|
|
ITEM_PICKER wrapper(CurrentLibEntry, UR_LIBEDIT);
|
2009-07-23 15:37:00 +00:00
|
|
|
lastcmd->PushItem(wrapper);
|
|
|
|
GetScreen()->PushCommandToUndoList( lastcmd );
|
|
|
|
|
|
|
|
lastcmd = GetScreen()->PopCommandFromRedoList( );
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2009-07-23 15:37:00 +00:00
|
|
|
wrapper = lastcmd->PopItem();
|
2009-09-18 14:56:05 +00:00
|
|
|
CurrentLibEntry = (LIB_COMPONENT*) wrapper.m_PickedItem;
|
2008-11-24 06:53:43 +00:00
|
|
|
if( CurrentLibEntry )
|
|
|
|
CurrentLibEntry->SetNext( NULL );
|
|
|
|
CurrentDrawItem = NULL;
|
|
|
|
GetScreen()->SetModify();
|
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
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
/******************************************************/
|
2009-07-29 13:10:36 +00:00
|
|
|
void WinEDA_LibeditFrame::GetComponentFromUndoList(wxCommandEvent& event)
|
2007-05-06 16:03:28 +00:00
|
|
|
/******************************************************/
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/* Undo the last edition:
|
2008-11-24 06:53:43 +00:00
|
|
|
* - Place the current edited library component in Redo list
|
|
|
|
* - Get old version of the current edited library component
|
2009-07-23 15:37:00 +00:00
|
|
|
* @return FALSE if nothing done, else true
|
2008-11-24 06:53:43 +00:00
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2009-07-23 15:37:00 +00:00
|
|
|
if ( GetScreen()->GetUndoCommandCount() <= 0 )
|
2009-07-29 13:10:36 +00:00
|
|
|
return;
|
2009-07-23 15:37:00 +00:00
|
|
|
|
|
|
|
PICKED_ITEMS_LIST* lastcmd = new PICKED_ITEMS_LIST();
|
2009-08-03 18:54:48 +00:00
|
|
|
ITEM_PICKER wrapper(CurrentLibEntry, UR_LIBEDIT);
|
2009-07-23 15:37:00 +00:00
|
|
|
lastcmd->PushItem(wrapper);
|
|
|
|
GetScreen()->PushCommandToRedoList( lastcmd );
|
|
|
|
|
|
|
|
lastcmd = GetScreen()->PopCommandFromUndoList( );
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2009-07-23 15:37:00 +00:00
|
|
|
wrapper = lastcmd->PopItem();
|
2009-09-18 14:56:05 +00:00
|
|
|
CurrentLibEntry = (LIB_COMPONENT*) wrapper.m_PickedItem;
|
2008-11-24 06:53:43 +00:00
|
|
|
|
|
|
|
if( CurrentLibEntry )
|
|
|
|
CurrentLibEntry->SetNext( NULL );
|
|
|
|
CurrentDrawItem = NULL;
|
|
|
|
GetScreen()->SetModify();
|
2009-07-29 13:10:36 +00:00
|
|
|
DrawPanel->Refresh();
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|