eeschema: Remove UR_WIRE_IMAGE
The wire image undo/redo option required special handling and was only used in a single location. Replacing with single change handling reduces the code complexity
This commit is contained in:
parent
94470f7da6
commit
822cd9c6ef
|
@ -114,20 +114,6 @@ void PICKED_ITEMS_LIST::ClearListAndDeleteItems()
|
|||
{
|
||||
delete wrapper.GetItem();
|
||||
}
|
||||
else if( wrapper.GetStatus() == UR_WIRE_IMAGE )
|
||||
{
|
||||
// Specific to eeschema: a linked list of wires is stored. The wrapper picks only
|
||||
// the first item (head of list), and is owner of all picked items.
|
||||
EDA_ITEM* item = wrapper.GetItem();
|
||||
|
||||
while( item )
|
||||
{
|
||||
// Delete old copy of wires
|
||||
EDA_ITEM* nextitem = item->Next();
|
||||
delete item;
|
||||
item = nextitem;
|
||||
}
|
||||
}
|
||||
else if( wrapper.GetStatus() == UR_DELETED )
|
||||
{
|
||||
// This should really be replaced with UR_TRANSIENT, but currently many clients
|
||||
|
|
|
@ -554,37 +554,6 @@ void SCH_EDIT_FRAME::DeleteCurrentSegment()
|
|||
}
|
||||
|
||||
|
||||
void SCH_EDIT_FRAME::SaveWireImage()
|
||||
{
|
||||
PICKED_ITEMS_LIST oldItems;
|
||||
oldItems.m_Status = UR_WIRE_IMAGE;
|
||||
|
||||
SCH_ITEM* item;
|
||||
SCH_ITEM* next_item;
|
||||
|
||||
for( item = GetScreen()->GetDrawItems(); item; item = next_item )
|
||||
{
|
||||
next_item = item->Next();
|
||||
|
||||
if( item->Type() == SCH_JUNCTION_T || item->Type() == SCH_LINE_T )
|
||||
{
|
||||
GetScreen()->Remove( item );
|
||||
GetCanvas()->GetView()->Remove( item );
|
||||
|
||||
oldItems.PushItem( ITEM_PICKER( item, UR_WIRE_IMAGE ) );
|
||||
|
||||
SCH_ITEM* item_copy = static_cast<SCH_ITEM*>( item->Clone() );
|
||||
|
||||
GetScreen()->GetDrawList().Insert( item_copy, next_item );
|
||||
GetCanvas()->GetView()->Add( item_copy );
|
||||
}
|
||||
}
|
||||
|
||||
if( oldItems.GetCount() != 0 )
|
||||
SaveCopyInUndoList( oldItems, UR_WIRE_IMAGE );
|
||||
}
|
||||
|
||||
|
||||
bool SCH_EDIT_FRAME::TrimWire( const wxPoint& aStart, const wxPoint& aEnd, bool aAppend )
|
||||
{
|
||||
SCH_LINE* line;
|
||||
|
|
|
@ -1001,11 +1001,6 @@ private:
|
|||
bool aAppendToUndo = false,
|
||||
bool aFinal = true );
|
||||
|
||||
/**
|
||||
* Save a copy of the current wire image in the undo list.
|
||||
*/
|
||||
void SaveWireImage();
|
||||
|
||||
/**
|
||||
* Collects a unique list of all possible connection points in the schematic.
|
||||
*
|
||||
|
|
|
@ -202,10 +202,8 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
|
|||
break;
|
||||
|
||||
case ID_POPUP_SCH_BREAK_WIRE:
|
||||
SaveWireImage();
|
||||
m_canvas->MoveCursorToCrossHair();
|
||||
BreakSegments( GetCrossHairPosition() );
|
||||
|
||||
TestDanglingEnds();
|
||||
m_canvas->Refresh();
|
||||
|
||||
|
|
|
@ -113,11 +113,7 @@ void SCH_EDIT_FRAME::SaveCopyInUndoList( SCH_ITEM* aItem,
|
|||
{
|
||||
PICKED_ITEMS_LIST* commandToUndo = NULL;
|
||||
|
||||
/* 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.
|
||||
*/
|
||||
if( aItem == NULL || aCommandType == UR_WIRE_IMAGE )
|
||||
if( aItem == NULL )
|
||||
return;
|
||||
|
||||
// Connectivity may change
|
||||
|
@ -181,15 +177,8 @@ void SCH_EDIT_FRAME::SaveCopyInUndoList( const PICKED_ITEMS_LIST& aItemsList,
|
|||
return;
|
||||
|
||||
// Can't append a WIRE IMAGE, so fail to a new undo point
|
||||
if( aAppend && ( aTypeCommand != UR_WIRE_IMAGE ) )
|
||||
{
|
||||
if( aAppend )
|
||||
commandToUndo = GetScreen()->PopCommandFromUndoList();
|
||||
if( commandToUndo && commandToUndo->m_Status == UR_WIRE_IMAGE )
|
||||
{
|
||||
GetScreen()->PushCommandToUndoList( commandToUndo );
|
||||
commandToUndo = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if( !commandToUndo )
|
||||
{
|
||||
|
@ -246,7 +235,6 @@ void SCH_EDIT_FRAME::SaveCopyInUndoList( const PICKED_ITEMS_LIST& aItemsList,
|
|||
case UR_NEW:
|
||||
case UR_DELETED:
|
||||
case UR_EXCHANGE_T:
|
||||
case UR_WIRE_IMAGE:
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -255,7 +243,7 @@ void SCH_EDIT_FRAME::SaveCopyInUndoList( const PICKED_ITEMS_LIST& aItemsList,
|
|||
}
|
||||
}
|
||||
|
||||
if( commandToUndo->GetCount() || aTypeCommand == UR_WIRE_IMAGE )
|
||||
if( commandToUndo->GetCount() )
|
||||
{
|
||||
/* Save the copy in undo list */
|
||||
GetScreen()->PushCommandToUndoList( commandToUndo );
|
||||
|
@ -273,44 +261,8 @@ void SCH_EDIT_FRAME::SaveCopyInUndoList( const PICKED_ITEMS_LIST& aItemsList,
|
|||
void SCH_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bool aRedoCommand )
|
||||
{
|
||||
SCH_ITEM* item;
|
||||
SCH_ITEM* next_item;
|
||||
SCH_ITEM* alt_item;
|
||||
|
||||
// Exchange the current wires, buses, and junctions with the copy save by the last edit.
|
||||
if( aList->m_Status == UR_WIRE_IMAGE )
|
||||
{
|
||||
PICKED_ITEMS_LIST oldItems;
|
||||
oldItems.m_Status = UR_WIRE_IMAGE;
|
||||
|
||||
// Remove all of the wires, buses, and junctions from the current screen.
|
||||
for( item = GetScreen()->GetDrawItems(); item; item = next_item )
|
||||
{
|
||||
next_item = item->Next();
|
||||
|
||||
if( item->Type() == SCH_JUNCTION_T || item->Type() == SCH_LINE_T )
|
||||
{
|
||||
GetScreen()->Remove( item );
|
||||
GetCanvas()->GetView()->Remove( item );
|
||||
|
||||
oldItems.PushItem( ITEM_PICKER( item, UR_WIRE_IMAGE ) );
|
||||
}
|
||||
}
|
||||
|
||||
// Copy the saved wires, buses, and junctions to the current screen.
|
||||
for( unsigned int i = 0; i < aList->GetCount(); i++ )
|
||||
{
|
||||
item = static_cast<SCH_ITEM*>( aList->GetPickedItem( i ) );
|
||||
|
||||
AddToScreen( item );
|
||||
}
|
||||
|
||||
// Copy the previous wires, buses, and junctions to the picked item list for the
|
||||
// redo operation.
|
||||
*aList = oldItems;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Undo in the reverse order of list creation: (this can allow stacked changes like the
|
||||
// same item can be changed and deleted in the same complex command).
|
||||
for( int ii = aList->GetCount() - 1; ii >= 0; ii-- )
|
||||
|
@ -411,7 +363,6 @@ void SCH_EDIT_FRAME::GetSchematicFromUndoList( wxCommandEvent& event )
|
|||
GetScreen()->PushCommandToRedoList( List );
|
||||
|
||||
SetSheetNumberAndCount();
|
||||
|
||||
TestDanglingEnds();
|
||||
|
||||
SyncView();
|
||||
|
|
|
@ -68,7 +68,6 @@ enum UNDO_REDO_T {
|
|||
UR_ROTATED, // Rotated item (counterclockwise), undo by rotating it
|
||||
UR_ROTATED_CLOCKWISE, // Rotated item (clockwise), undo by rotating it
|
||||
UR_FLIPPED, // flipped (board items only), undo by flipping it
|
||||
UR_WIRE_IMAGE, // Specific to Eeschema for handling wires changes.
|
||||
UR_LIBEDIT, // Specific to the component editor (libedit creates a full copy
|
||||
// of the current component when changed)
|
||||
UR_LIB_RENAME, // As UR_LIBEDIT, but old copy should be removed from library
|
||||
|
|
Loading…
Reference in New Issue