2008-11-24 06:53:43 +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>
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <general.h>
|
|
|
|
#include <protos.h>
|
|
|
|
#include <libeditframe.h>
|
|
|
|
#include <class_libentry.h>
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
void LIB_EDIT_FRAME::SaveCopyInUndoList( EDA_ITEM* ItemToCopy, int unused_flag )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2009-09-18 14:56:05 +00:00
|
|
|
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-25 18:49:04 +00:00
|
|
|
CopyItem = new LIB_COMPONENT( *( (LIB_COMPONENT*) ItemToCopy ) );
|
2009-08-27 11:41:56 +00:00
|
|
|
|
2011-05-20 18:29:35 +00:00
|
|
|
// Clear current flags (which can be temporary set by a current edit command).
|
|
|
|
CopyItem->ClearStatus();
|
2009-07-23 15:37:00 +00:00
|
|
|
|
|
|
|
lastcmd = new PICKED_ITEMS_LIST();
|
2010-10-22 12:11:52 +00:00
|
|
|
ITEM_PICKER wrapper( CopyItem, UR_LIBEDIT );
|
2009-07-23 15:37:00 +00:00
|
|
|
lastcmd->PushItem(wrapper);
|
|
|
|
GetScreen()->PushCommandToUndoList( lastcmd );
|
2010-10-22 12:11:52 +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 );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/* Redo the last edition:
|
2010-10-22 12:11:52 +00:00
|
|
|
* - Place the current edited library component in undo list
|
|
|
|
* - Get old version of the current edited library component
|
2008-11-24 06:53:43 +00:00
|
|
|
*/
|
2010-11-19 16:28:46 +00:00
|
|
|
void LIB_EDIT_FRAME::GetComponentFromRedoList( wxCommandEvent& event )
|
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();
|
2010-10-22 12:11:52 +00:00
|
|
|
ITEM_PICKER wrapper( m_component, UR_LIBEDIT );
|
|
|
|
lastcmd->PushItem( wrapper );
|
2009-07-23 15:37:00 +00:00
|
|
|
GetScreen()->PushCommandToUndoList( lastcmd );
|
|
|
|
|
2010-10-22 12:11:52 +00:00
|
|
|
lastcmd = GetScreen()->PopCommandFromRedoList();
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2009-07-23 15:37:00 +00:00
|
|
|
wrapper = lastcmd->PopItem();
|
2012-02-05 13:02:46 +00:00
|
|
|
m_component = (LIB_COMPONENT*) wrapper.GetItem();
|
2010-10-22 12:11:52 +00:00
|
|
|
|
|
|
|
if( m_component == NULL )
|
|
|
|
return;
|
|
|
|
|
|
|
|
if( !m_aliasName.IsEmpty() && !m_component->HasAlias( m_aliasName ) )
|
|
|
|
m_aliasName = m_component->GetName();
|
|
|
|
|
2009-09-25 18:49:04 +00:00
|
|
|
m_drawItem = NULL;
|
2010-02-16 08:34:09 +00:00
|
|
|
UpdateAliasSelectList();
|
|
|
|
UpdatePartSelectList();
|
2010-10-22 12:11:52 +00:00
|
|
|
SetShowDeMorgan( m_component->HasConversion() );
|
2010-02-16 08:34:09 +00:00
|
|
|
DisplayLibInfos();
|
|
|
|
DisplayCmpDoc();
|
2011-12-22 13:28:11 +00:00
|
|
|
OnModify();
|
|
|
|
m_canvas->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
|
|
|
|
2010-02-16 08:34:09 +00:00
|
|
|
/** Undo the last edition:
|
2010-10-22 12:11:52 +00:00
|
|
|
* - Place the current edited library component in Redo list
|
|
|
|
* - Get old version of the current edited library component
|
2008-11-24 06:53:43 +00:00
|
|
|
*/
|
2010-11-19 16:28:46 +00:00
|
|
|
void LIB_EDIT_FRAME::GetComponentFromUndoList( wxCommandEvent& event )
|
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();
|
2010-10-22 12:11:52 +00:00
|
|
|
ITEM_PICKER wrapper( m_component, UR_LIBEDIT );
|
|
|
|
lastcmd->PushItem( wrapper );
|
2009-07-23 15:37:00 +00:00
|
|
|
GetScreen()->PushCommandToRedoList( lastcmd );
|
|
|
|
|
2010-10-22 12:11:52 +00:00
|
|
|
lastcmd = GetScreen()->PopCommandFromUndoList();
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2009-07-23 15:37:00 +00:00
|
|
|
wrapper = lastcmd->PopItem();
|
2012-02-05 13:02:46 +00:00
|
|
|
m_component = (LIB_COMPONENT*) wrapper.GetItem();
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2010-10-22 12:11:52 +00:00
|
|
|
if( m_component == NULL )
|
|
|
|
return;
|
|
|
|
|
|
|
|
if( !m_aliasName.IsEmpty() && !m_component->HasAlias( m_aliasName ) )
|
|
|
|
m_aliasName = m_component->GetName();
|
|
|
|
|
2009-09-25 18:49:04 +00:00
|
|
|
m_drawItem = NULL;
|
2010-02-16 08:34:09 +00:00
|
|
|
UpdateAliasSelectList();
|
|
|
|
UpdatePartSelectList();
|
2010-10-22 12:11:52 +00:00
|
|
|
SetShowDeMorgan( m_component->HasConversion() );
|
2010-02-16 08:34:09 +00:00
|
|
|
DisplayLibInfos();
|
|
|
|
DisplayCmpDoc();
|
2010-10-22 12:11:52 +00:00
|
|
|
OnModify();
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->Refresh();
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|