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 "general.h"
|
|
|
|
#include "protos.h"
|
2010-02-16 16:21:52 +00:00
|
|
|
#include "libeditframe.h"
|
2009-09-25 18:49:04 +00:00
|
|
|
#include "class_libentry.h"
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
|
2010-10-22 12:11:52 +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
|
|
|
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
|
|
|
|
|
|
|
if( CopyItem == NULL )
|
|
|
|
return;
|
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 current flags (which can be temporary set by a current edit command).
|
2009-09-29 18:38:21 +00:00
|
|
|
CopyItem->ClearStatus();
|
2008-11-24 06:53:43 +00:00
|
|
|
|
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-10-22 12:11:52 +00:00
|
|
|
void WinEDA_LibeditFrame::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();
|
2009-09-25 18:49:04 +00:00
|
|
|
m_component = (LIB_COMPONENT*) wrapper.m_PickedItem;
|
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-02-18 20:07:29 +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
|
|
|
|
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-10-22 12:11:52 +00:00
|
|
|
void WinEDA_LibeditFrame::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();
|
2009-09-25 18:49:04 +00:00
|
|
|
m_component = (LIB_COMPONENT*) wrapper.m_PickedItem;
|
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();
|
2009-07-29 13:10:36 +00:00
|
|
|
DrawPanel->Refresh();
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|