2011-10-19 20:32:21 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
|
2017-09-21 16:37:12 +00:00
|
|
|
* Copyright (C) 2004-2017 KiCad Developers, see change_log.txt for contributors.
|
2011-10-19 20:32:21 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
2011-09-30 18:15:37 +00:00
|
|
|
/**
|
|
|
|
* @file schematic_undo_redo.cpp
|
|
|
|
* @brief Eeschema undo and redo functions for schematic editor.
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
|
|
|
#include <class_drawpanel.h>
|
2015-02-21 09:46:44 +00:00
|
|
|
#include <schframe.h>
|
2009-02-04 15:25:03 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <general.h>
|
|
|
|
#include <protos.h>
|
|
|
|
#include <sch_bus_entry.h>
|
|
|
|
#include <sch_marker.h>
|
|
|
|
#include <sch_junction.h>
|
|
|
|
#include <sch_line.h>
|
|
|
|
#include <sch_no_connect.h>
|
|
|
|
#include <sch_component.h>
|
|
|
|
#include <sch_sheet.h>
|
|
|
|
#include <sch_bitmap.h>
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-07-26 17:16:42 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/* Functions to undo and redo edit commands.
|
2009-12-02 21:44:03 +00:00
|
|
|
* commands to undo are stored in CurrentScreen->m_UndoList
|
|
|
|
* commands to redo are stored in CurrentScreen->m_RedoList
|
2008-02-26 19:19:54 +00:00
|
|
|
*
|
2009-07-25 04:53:39 +00:00
|
|
|
* m_UndoList and m_RedoList handle a std::vector of PICKED_ITEMS_LIST
|
|
|
|
* Each PICKED_ITEMS_LIST handle a std::vector of pickers (class ITEM_PICKER),
|
2009-12-02 21:44:03 +00:00
|
|
|
* that store the list of schematic items that are concerned by the command to
|
|
|
|
* undo or redo and is created for each command to undo (handle also a command
|
|
|
|
* to redo). each picker has a pointer pointing to an item to undo or redo (in
|
|
|
|
* fact: deleted, added or modified), and has a pointer to a copy of this item,
|
|
|
|
* when this item has been modified (the old values of parameters are
|
|
|
|
* therefore saved)
|
2008-02-26 19:19:54 +00:00
|
|
|
*
|
2007-09-01 12:00:30 +00:00
|
|
|
* there are 3 cases:
|
|
|
|
* - delete item(s) command
|
|
|
|
* - change item(s) command
|
|
|
|
* - add item(s) command
|
2009-07-29 13:10:36 +00:00
|
|
|
* and 2 cases for block:
|
|
|
|
* - move list of items
|
|
|
|
* - mirror (Y) list of items
|
2008-02-26 19:19:54 +00:00
|
|
|
*
|
2007-09-01 12:00:30 +00:00
|
|
|
* Undo command
|
|
|
|
* - delete item(s) command:
|
2009-07-25 04:53:39 +00:00
|
|
|
* => deleted items are moved in undo list
|
2008-02-26 19:19:54 +00:00
|
|
|
*
|
2007-09-01 12:00:30 +00:00
|
|
|
* - change item(s) command
|
2009-07-25 04:53:39 +00:00
|
|
|
* => A copy of item(s) is made (a DrawPickedStruct list of wrappers)
|
|
|
|
* the .m_Link member of each wrapper points the modified item.
|
|
|
|
* the .m_Item member of each wrapper points the old copy of this item.
|
2008-02-26 19:19:54 +00:00
|
|
|
*
|
2007-09-01 12:00:30 +00:00
|
|
|
* - add item(s) command
|
2009-12-02 21:44:03 +00:00
|
|
|
* =>A list of item(s) is made. The .m_Item member of each wrapper points
|
|
|
|
* the new item.
|
2008-02-26 19:19:54 +00:00
|
|
|
*
|
2007-09-01 12:00:30 +00:00
|
|
|
* Redo command
|
|
|
|
* - delete item(s) old command:
|
2010-12-08 20:12:46 +00:00
|
|
|
* => deleted items are moved in GetDrawItems() list, and in
|
2008-02-26 19:19:54 +00:00
|
|
|
*
|
2007-09-01 12:00:30 +00:00
|
|
|
* - change item(s) command
|
2009-07-25 04:53:39 +00:00
|
|
|
* => the copy of item(s) is moved in Undo list
|
2008-02-26 19:19:54 +00:00
|
|
|
*
|
2007-09-01 12:00:30 +00:00
|
|
|
* - add item(s) command
|
2009-12-02 21:44:03 +00:00
|
|
|
* => The list of item(s) is used to create a deleted list in undo
|
|
|
|
* list(same as a delete command)
|
2008-02-26 19:19:54 +00:00
|
|
|
*
|
2009-12-02 21:44:03 +00:00
|
|
|
* Some block operations that change items can be undone without memorized
|
|
|
|
* items, just the coordinates of the transform: move list of items (undo/
|
|
|
|
* redo is made by moving with the opposite move vector) mirror (Y) and flip
|
|
|
|
* list of items (undo/redo is made by mirror or flip items) so they are
|
|
|
|
* handled specifically.
|
2009-07-29 13:10:36 +00:00
|
|
|
*
|
2007-09-01 12:00:30 +00:00
|
|
|
* A problem is the hierarchical sheet handling.
|
2009-12-02 21:44:03 +00:00
|
|
|
* the data associated (sub-hierarchy, undo/redo list) is deleted only
|
2007-09-01 12:00:30 +00:00
|
|
|
* when the sheet is really deleted (i.e. when deleted from undo or redo list)
|
2009-07-25 04:53:39 +00:00
|
|
|
* This is handled by its destructor.
|
2007-09-01 12:00:30 +00:00
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* Used if undo / redo command:
|
2016-06-03 13:33:44 +00:00
|
|
|
* swap data between Item and its copy, pointed by its picked item link member
|
2009-07-25 04:53:39 +00:00
|
|
|
* swapped data is data modified by edition, so not all values are swapped
|
2007-09-01 12:00:30 +00:00
|
|
|
*/
|
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
void SCH_EDIT_FRAME::SaveCopyInUndoList( SCH_ITEM* aItem,
|
2011-04-05 14:46:51 +00:00
|
|
|
UNDO_REDO_T aCommandType,
|
2010-12-08 20:12:46 +00:00
|
|
|
const wxPoint& aTransformPoint )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2012-02-26 18:39:39 +00:00
|
|
|
/* Does not save a null item or a UR_WIRE_IMAGE command type. UR_WIRE_IMAGE commands
|
|
|
|
* are handled by the overloaded version of SaveCopyInUndoList that takes a reference
|
|
|
|
* to a PICKED_ITEMS_LIST.
|
2009-08-04 18:21:32 +00:00
|
|
|
*/
|
2012-02-26 18:39:39 +00:00
|
|
|
if( aItem == NULL || aCommandType == UR_WIRE_IMAGE )
|
2009-08-04 18:21:32 +00:00
|
|
|
return;
|
|
|
|
|
2009-07-23 15:37:00 +00:00
|
|
|
PICKED_ITEMS_LIST* commandToUndo = new PICKED_ITEMS_LIST();
|
2009-07-26 17:16:42 +00:00
|
|
|
commandToUndo->m_TransformPoint = aTransformPoint;
|
2007-09-01 12:00:30 +00:00
|
|
|
|
2012-02-05 13:02:46 +00:00
|
|
|
ITEM_PICKER itemWrapper( aItem, aCommandType );
|
2015-11-03 19:44:05 +00:00
|
|
|
itemWrapper.SetFlags( aItem->GetFlags() );
|
2007-09-01 12:00:30 +00:00
|
|
|
|
2009-07-25 07:31:07 +00:00
|
|
|
switch( aCommandType )
|
2007-09-01 12:00:30 +00:00
|
|
|
{
|
2009-08-03 07:55:08 +00:00
|
|
|
case UR_CHANGED: /* Create a copy of item */
|
2012-02-05 13:02:46 +00:00
|
|
|
itemWrapper.SetLink( DuplicateStruct( aItem, true ) );
|
|
|
|
commandToUndo->PushItem( itemWrapper );
|
2009-07-25 07:31:07 +00:00
|
|
|
break;
|
2007-09-01 12:00:30 +00:00
|
|
|
|
2009-07-26 17:16:42 +00:00
|
|
|
case UR_NEW:
|
|
|
|
case UR_DELETED:
|
2011-08-31 14:59:20 +00:00
|
|
|
case UR_ROTATED:
|
2009-07-26 17:16:42 +00:00
|
|
|
case UR_MOVED:
|
2009-07-25 07:31:07 +00:00
|
|
|
commandToUndo->PushItem( itemWrapper );
|
2009-07-25 04:53:39 +00:00
|
|
|
break;
|
2009-07-25 07:31:07 +00:00
|
|
|
|
|
|
|
default:
|
2012-02-26 18:39:39 +00:00
|
|
|
wxFAIL_MSG( wxString::Format( wxT( "SaveCopyInUndoList() error (unknown code %X)" ),
|
|
|
|
aCommandType ) );
|
|
|
|
break;
|
2009-07-25 04:53:39 +00:00
|
|
|
}
|
2009-07-25 07:31:07 +00:00
|
|
|
|
2009-07-29 13:10:36 +00:00
|
|
|
if( commandToUndo->GetCount() )
|
|
|
|
{
|
|
|
|
/* Save the copy in undo list */
|
|
|
|
GetScreen()->PushCommandToUndoList( commandToUndo );
|
2009-07-25 04:53:39 +00:00
|
|
|
|
2009-07-29 13:10:36 +00:00
|
|
|
/* Clear redo list, because after new save there is no redo to do */
|
|
|
|
GetScreen()->ClearUndoORRedoList( GetScreen()->m_RedoList );
|
|
|
|
}
|
|
|
|
else
|
2012-02-26 18:39:39 +00:00
|
|
|
{
|
2009-07-29 13:10:36 +00:00
|
|
|
delete commandToUndo;
|
2012-02-26 18:39:39 +00:00
|
|
|
}
|
2009-07-25 04:53:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-12-18 12:27:18 +00:00
|
|
|
void SCH_EDIT_FRAME::SaveCopyInUndoList( const PICKED_ITEMS_LIST& aItemsList,
|
2011-04-05 14:46:51 +00:00
|
|
|
UNDO_REDO_T aTypeCommand,
|
2010-12-08 20:12:46 +00:00
|
|
|
const wxPoint& aTransformPoint )
|
2009-07-25 04:53:39 +00:00
|
|
|
{
|
|
|
|
PICKED_ITEMS_LIST* commandToUndo = new PICKED_ITEMS_LIST();
|
2010-09-05 17:01:48 +00:00
|
|
|
|
2009-07-26 17:16:42 +00:00
|
|
|
commandToUndo->m_TransformPoint = aTransformPoint;
|
2012-02-26 18:39:39 +00:00
|
|
|
commandToUndo->m_Status = aTypeCommand;
|
2010-09-05 17:01:48 +00:00
|
|
|
|
2009-08-06 15:42:09 +00:00
|
|
|
// Copy picker list:
|
|
|
|
commandToUndo->CopyList( aItemsList );
|
2009-07-25 04:53:39 +00:00
|
|
|
|
2009-08-06 15:42:09 +00:00
|
|
|
// Verify list, and creates data if needed
|
|
|
|
for( unsigned ii = 0; ii < commandToUndo->GetCount(); ii++ )
|
2009-07-25 04:53:39 +00:00
|
|
|
{
|
2011-04-05 14:46:51 +00:00
|
|
|
SCH_ITEM* item = (SCH_ITEM*) commandToUndo->GetPickedItem( ii );
|
2009-08-06 15:42:09 +00:00
|
|
|
wxASSERT( item );
|
|
|
|
|
2011-04-05 14:46:51 +00:00
|
|
|
UNDO_REDO_T command = commandToUndo->GetPickedItemStatus( ii );
|
|
|
|
|
2009-07-26 17:16:42 +00:00
|
|
|
if( command == UR_UNSPECIFIED )
|
2009-07-25 04:53:39 +00:00
|
|
|
{
|
|
|
|
command = aTypeCommand;
|
2010-09-05 17:01:48 +00:00
|
|
|
commandToUndo->SetPickedItemStatus( command, ii );
|
2009-07-23 15:37:00 +00:00
|
|
|
}
|
2009-08-06 15:42:09 +00:00
|
|
|
|
2009-07-25 04:53:39 +00:00
|
|
|
switch( command )
|
|
|
|
{
|
2009-08-03 07:55:08 +00:00
|
|
|
case UR_CHANGED: /* Create a copy of item */
|
2010-09-05 17:01:48 +00:00
|
|
|
|
2009-08-06 15:42:09 +00:00
|
|
|
/* If needed, create a copy of item, and put in undo list
|
|
|
|
* in the picker, as link
|
|
|
|
* If this link is not null, the copy is already done
|
|
|
|
*/
|
2010-09-05 17:01:48 +00:00
|
|
|
if( commandToUndo->GetPickedItemLink( ii ) == NULL )
|
2010-03-24 18:26:04 +00:00
|
|
|
commandToUndo->SetPickedItemLink( DuplicateStruct( item, true ), ii );
|
2012-02-26 18:39:39 +00:00
|
|
|
|
2010-09-05 17:01:48 +00:00
|
|
|
wxASSERT( commandToUndo->GetPickedItemLink( ii ) );
|
2009-07-25 04:53:39 +00:00
|
|
|
break;
|
|
|
|
|
2009-07-26 17:16:42 +00:00
|
|
|
case UR_MOVED:
|
|
|
|
case UR_MIRRORED_Y:
|
2010-09-05 17:01:48 +00:00
|
|
|
case UR_MIRRORED_X:
|
|
|
|
case UR_ROTATED:
|
2009-07-26 17:16:42 +00:00
|
|
|
case UR_NEW:
|
|
|
|
case UR_DELETED:
|
2011-04-05 14:46:51 +00:00
|
|
|
case UR_EXCHANGE_T:
|
2012-02-26 18:39:39 +00:00
|
|
|
case UR_WIRE_IMAGE:
|
2007-09-01 12:00:30 +00:00
|
|
|
break;
|
2009-07-25 04:53:39 +00:00
|
|
|
|
|
|
|
default:
|
2011-04-05 14:46:51 +00:00
|
|
|
wxFAIL_MSG( wxString::Format( wxT( "Unknown undo/redo command %d" ), command ) );
|
|
|
|
break;
|
2007-09-01 12:00:30 +00:00
|
|
|
}
|
|
|
|
}
|
2009-07-25 04:53:39 +00:00
|
|
|
|
2012-02-26 18:39:39 +00:00
|
|
|
if( commandToUndo->GetCount() || aTypeCommand == UR_WIRE_IMAGE )
|
2009-07-29 13:10:36 +00:00
|
|
|
{
|
|
|
|
/* Save the copy in undo list */
|
|
|
|
GetScreen()->PushCommandToUndoList( commandToUndo );
|
2008-02-26 19:19:54 +00:00
|
|
|
|
2009-07-29 13:10:36 +00:00
|
|
|
/* Clear redo list, because after new save there is no redo to do */
|
|
|
|
GetScreen()->ClearUndoORRedoList( GetScreen()->m_RedoList );
|
|
|
|
}
|
2009-08-06 15:42:09 +00:00
|
|
|
else // Should not occur
|
2012-02-26 18:39:39 +00:00
|
|
|
{
|
2009-07-29 13:10:36 +00:00
|
|
|
delete commandToUndo;
|
2012-02-26 18:39:39 +00:00
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
void SCH_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bool aRedoCommand )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2009-07-25 04:53:39 +00:00
|
|
|
SCH_ITEM* item;
|
|
|
|
SCH_ITEM* alt_item;
|
2007-09-01 12:00:30 +00:00
|
|
|
|
2012-02-26 18:39:39 +00:00
|
|
|
// Exchange the current wires, buses, and junctions with the copy save by the last edit.
|
|
|
|
if( aList->m_Status == UR_WIRE_IMAGE )
|
|
|
|
{
|
|
|
|
DLIST< SCH_ITEM > oldWires;
|
|
|
|
|
|
|
|
// Prevent items from being deleted when the DLIST goes out of scope.
|
|
|
|
oldWires.SetOwnership( false );
|
|
|
|
|
|
|
|
// Remove all of the wires, buses, and junctions from the current screen.
|
|
|
|
GetScreen()->ExtractWires( oldWires, false );
|
|
|
|
|
|
|
|
// Copy the saved wires, buses, and junctions to the current screen.
|
|
|
|
for( unsigned int i = 0; i < aList->GetCount(); i++ )
|
|
|
|
GetScreen()->Append( (SCH_ITEM*) aList->GetPickedItem( i ) );
|
|
|
|
|
|
|
|
aList->ClearItemsList();
|
|
|
|
|
|
|
|
// Copy the previous wires, buses, and junctions to the picked item list for the
|
|
|
|
// redo operation.
|
|
|
|
while( oldWires.GetCount() != 0 )
|
|
|
|
{
|
|
|
|
ITEM_PICKER picker = ITEM_PICKER( oldWires.PopFront(), UR_WIRE_IMAGE );
|
|
|
|
aList->PushItem( picker );
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Undo in the reverse order of list creation: (this can allow stacked changes like the
|
|
|
|
// same item can be changes and deleted in the same complex command.
|
2010-09-05 17:01:48 +00:00
|
|
|
for( int ii = aList->GetCount() - 1; ii >= 0; ii-- )
|
2007-09-01 12:00:30 +00:00
|
|
|
{
|
2011-03-10 19:36:30 +00:00
|
|
|
item = (SCH_ITEM*) aList->GetPickedItem( ii );
|
2013-12-29 22:05:06 +00:00
|
|
|
wxASSERT( item );
|
2011-03-10 19:36:30 +00:00
|
|
|
|
2013-12-29 15:12:27 +00:00
|
|
|
item->ClearFlags();
|
2011-03-10 19:36:30 +00:00
|
|
|
|
|
|
|
SCH_ITEM* image = (SCH_ITEM*) aList->GetPickedItemLink( ii );
|
|
|
|
|
|
|
|
switch( aList->GetPickedItemStatus( ii ) )
|
2007-09-01 12:00:30 +00:00
|
|
|
{
|
2009-12-02 21:44:03 +00:00
|
|
|
case UR_CHANGED: /* Exchange old and new data for each item */
|
2011-10-19 20:32:21 +00:00
|
|
|
item->SwapData( image );
|
2007-09-01 12:00:30 +00:00
|
|
|
break;
|
|
|
|
|
2009-12-02 21:44:03 +00:00
|
|
|
case UR_NEW: /* new items are deleted */
|
2009-07-31 05:33:11 +00:00
|
|
|
aList->SetPickedItemStatus( UR_DELETED, ii );
|
2012-02-26 18:39:39 +00:00
|
|
|
GetScreen()->Remove( item );
|
2009-07-23 15:37:00 +00:00
|
|
|
break;
|
2007-09-01 12:00:30 +00:00
|
|
|
|
2012-02-26 18:39:39 +00:00
|
|
|
case UR_DELETED: /* deleted items are put in the draw item list, as new items */
|
2009-07-31 05:33:11 +00:00
|
|
|
aList->SetPickedItemStatus( UR_NEW, ii );
|
2012-02-26 18:39:39 +00:00
|
|
|
GetScreen()->Append( item );
|
2009-07-23 15:37:00 +00:00
|
|
|
break;
|
|
|
|
|
2009-07-26 17:16:42 +00:00
|
|
|
case UR_MOVED:
|
2011-03-10 19:36:30 +00:00
|
|
|
item->ClearFlags();
|
|
|
|
item->SetFlags( aList->GetPickerFlags( ii ) );
|
|
|
|
item->Move( aRedoCommand ? aList->m_TransformPoint : -aList->m_TransformPoint );
|
|
|
|
item->ClearFlags();
|
2009-07-26 17:16:42 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case UR_MIRRORED_Y:
|
2012-03-15 14:31:16 +00:00
|
|
|
item->MirrorY( aList->m_TransformPoint.x );
|
2012-02-26 18:39:39 +00:00
|
|
|
break;
|
2010-09-05 17:01:48 +00:00
|
|
|
|
|
|
|
case UR_MIRRORED_X:
|
2012-03-15 14:31:16 +00:00
|
|
|
item->MirrorX( aList->m_TransformPoint.y );
|
2012-02-26 18:39:39 +00:00
|
|
|
break;
|
2010-09-05 17:01:48 +00:00
|
|
|
|
|
|
|
case UR_ROTATED:
|
2011-08-31 18:16:02 +00:00
|
|
|
// To undo a rotate 90 deg transform we must rotate 270 deg to undo
|
|
|
|
// and 90 deg to redo:
|
2012-02-26 18:39:39 +00:00
|
|
|
item->Rotate( aList->m_TransformPoint );
|
|
|
|
|
2011-08-31 18:16:02 +00:00
|
|
|
if( aRedoCommand )
|
|
|
|
break; // A only one rotate transform is OK
|
2009-07-25 04:53:39 +00:00
|
|
|
|
2012-02-26 18:39:39 +00:00
|
|
|
// Make 3 rotate 90 deg transforms is this is actually an undo command
|
|
|
|
item->Rotate( aList->m_TransformPoint );
|
|
|
|
item->Rotate( aList->m_TransformPoint );
|
2009-07-23 15:37:00 +00:00
|
|
|
break;
|
2007-09-01 12:00:30 +00:00
|
|
|
|
2011-04-05 14:46:51 +00:00
|
|
|
case UR_EXCHANGE_T:
|
2011-08-31 14:59:20 +00:00
|
|
|
alt_item = (SCH_ITEM*) aList->GetPickedItemLink( ii );
|
|
|
|
alt_item->SetNext( NULL );
|
|
|
|
alt_item->SetBack( NULL );
|
2012-02-26 18:39:39 +00:00
|
|
|
GetScreen()->Remove( item );
|
|
|
|
GetScreen()->Append( alt_item );
|
2011-08-31 14:59:20 +00:00
|
|
|
aList->SetPickedItem( alt_item, ii );
|
2011-04-05 14:46:51 +00:00
|
|
|
aList->SetPickedItemLink( item, ii );
|
|
|
|
break;
|
|
|
|
|
2009-07-23 15:37:00 +00:00
|
|
|
default:
|
2011-04-05 14:46:51 +00:00
|
|
|
wxFAIL_MSG( wxString::Format( wxT( "Unknown undo/redo command %d" ),
|
|
|
|
aList->GetPickedItemStatus( ii ) ) );
|
|
|
|
break;
|
2007-09-01 12:00:30 +00:00
|
|
|
}
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-09-01 12:00:30 +00:00
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
void SCH_EDIT_FRAME::GetSchematicFromUndoList( wxCommandEvent& event )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2017-09-21 16:37:12 +00:00
|
|
|
if( GetScreen()->GetUndoCommandCount() <= 0 || isBusy() )
|
2009-07-29 13:10:36 +00:00
|
|
|
return;
|
2007-09-01 12:00:30 +00:00
|
|
|
|
2009-08-11 10:27:21 +00:00
|
|
|
/* Get the old list */
|
2009-07-23 15:37:00 +00:00
|
|
|
PICKED_ITEMS_LIST* List = GetScreen()->PopCommandFromUndoList();
|
2009-08-11 10:27:21 +00:00
|
|
|
|
2007-09-01 12:00:30 +00:00
|
|
|
/* Undo the command */
|
2009-08-01 19:26:05 +00:00
|
|
|
PutDataInPreviousState( List, false );
|
2007-09-01 12:00:30 +00:00
|
|
|
|
2009-08-11 10:27:21 +00:00
|
|
|
/* Put the old list in RedoList */
|
|
|
|
List->ReversePickersListOrder();
|
|
|
|
GetScreen()->PushCommandToRedoList( List );
|
|
|
|
|
2010-09-05 17:01:48 +00:00
|
|
|
OnModify();
|
2009-01-06 20:09:32 +00:00
|
|
|
SetSheetNumberAndCount();
|
2008-02-26 19:19:54 +00:00
|
|
|
|
2011-01-21 19:30:59 +00:00
|
|
|
GetScreen()->TestDanglingEnds();
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->Refresh();
|
2009-07-29 13:10:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
void SCH_EDIT_FRAME::GetSchematicFromRedoList( wxCommandEvent& event )
|
2009-07-29 13:10:36 +00:00
|
|
|
{
|
2017-09-21 16:37:12 +00:00
|
|
|
if( GetScreen()->GetRedoCommandCount() == 0 || isBusy() )
|
2009-07-29 13:10:36 +00:00
|
|
|
return;
|
|
|
|
|
2009-08-11 10:27:21 +00:00
|
|
|
/* Get the old list */
|
2009-07-29 13:10:36 +00:00
|
|
|
PICKED_ITEMS_LIST* List = GetScreen()->PopCommandFromRedoList();
|
|
|
|
|
|
|
|
/* Redo the command: */
|
2009-08-01 19:26:05 +00:00
|
|
|
PutDataInPreviousState( List, true );
|
2009-07-29 13:10:36 +00:00
|
|
|
|
2009-08-11 10:27:21 +00:00
|
|
|
/* Put the old list in UndoList */
|
|
|
|
List->ReversePickersListOrder();
|
|
|
|
GetScreen()->PushCommandToUndoList( List );
|
|
|
|
|
2010-09-05 17:01:48 +00:00
|
|
|
OnModify();
|
2009-07-29 13:10:36 +00:00
|
|
|
SetSheetNumberAndCount();
|
|
|
|
|
2011-01-21 19:30:59 +00:00
|
|
|
GetScreen()->TestDanglingEnds();
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->Refresh();
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|