Commit aaa1cc3e authored by Wayne Stambaugh's avatar Wayne Stambaugh

Eeschema object list and other minor improvements.

* Convert Eeschema from manually linked list to DLIST for storing
  SCH_ITEM objects.
* Add helper functions to SCH_SCREEN for appending list of SCH_ITEM
  objects.
* Fix bug in wire editing code for accurate undo/redo behavior.
* Add member to DLIST to append another DLIST.
* Other minor code cleaning.
parent a1ff3261
......@@ -2,7 +2,6 @@
* 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
* Copyright (C) 2008-20011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
......@@ -217,15 +216,14 @@ EDA_ITEM& EDA_ITEM::operator=( const EDA_ITEM& aItem )
{
if( &aItem != this )
{
m_StructType = aItem.Type();
Pnext = aItem.Pnext;
Pback = aItem.Pback;
m_Image = aItem.m_Image;
m_StructType = aItem.m_StructType;
m_Parent = aItem.m_Parent;
m_Son = aItem.m_Son;
m_Flags = aItem.m_Flags;
SetTimeStamp( aItem.m_TimeStamp );
m_TimeStamp = aItem.m_TimeStamp;
m_Status = aItem.m_Status;
m_forceVisible = aItem.m_forceVisible;
}
return *this;
......
......@@ -85,6 +85,36 @@ void DHEAD::append( EDA_ITEM* aNewElement )
}
void DHEAD::append( DHEAD& aList )
{
wxCHECK_RET( aList.GetCount() != 0, wxT( "Attempt to append empty list." ) );
// Change the item's list to me.
for( EDA_ITEM* item = aList.first; item != NULL; item = item->Next() )
item->SetList( this );
if( first ) // list is not empty, set last item's next to the first item in aList
{
wxCHECK_RET( last != NULL, wxT( "Last list element not set." ) );
last->SetNext( aList.first );
aList.first->SetBack( last );
last = aList.last;
}
else // list is empty, first and last are same as aList
{
first = aList.first;
last = aList.last;
}
count += aList.count;
aList.count = 0;
aList.first = NULL;
aList.last = NULL;
}
void DHEAD::insert( EDA_ITEM* aNewElement, EDA_ITEM* aAfterMe )
{
wxASSERT( aNewElement != NULL );
......
......@@ -2,7 +2,6 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2006 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
......@@ -102,23 +101,6 @@ bool SCH_ITEM::operator < ( const SCH_ITEM& aItem ) const
}
SCH_ITEM& SCH_ITEM::operator=( const SCH_ITEM& aItem )
{
wxCHECK_MSG( Type() == aItem.Type(), *this,
wxT( "Cannot assign object type " ) + aItem.GetClass() + wxT( " to type " ) +
GetClass() );
if( &aItem != this )
{
EDA_ITEM::operator=( aItem );
m_Layer = aItem.m_Layer;
m_connections = aItem.m_connections;
}
return *this;
}
void SCH_ITEM::doPlot( PLOTTER* aPlotter )
{
wxFAIL_MSG( wxT( "doPlot() method not implemented for class " ) + GetClass() );
......
......@@ -559,8 +559,7 @@ void SCH_EDIT_FRAME::PasteListOfItems( wxDC* DC )
SetSchItemParent( Struct, GetScreen() );
Struct->Draw( m_canvas, DC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE );
Struct->SetNext( GetScreen()->GetDrawItems() );
GetScreen()->SetDrawItems( Struct );
GetScreen()->Append( Struct );
}
SaveCopyInUndoList( picklist, UR_NEW );
......
This diff is collapsed.
......@@ -2,7 +2,6 @@
* 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
* Copyright (C) 2008-2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors.
*
* This program is free software; you can redistribute it and/or
......@@ -224,9 +223,8 @@ void SCH_EDIT_FRAME::OnConvertTextType( wxCommandEvent& aEvent )
m_canvas->CrossHairOff( &dc ); // Erase schematic cursor
text->Draw( m_canvas, &dc, wxPoint( 0, 0 ), g_XorMode );
screen->RemoveFromDrawList( text );
screen->AddToDrawList( newtext );
GetScreen()->SetCurItem( newtext );
screen->Remove( text );
screen->Append( newtext );
m_itemToRepeat = NULL;
OnModify();
newtext->Draw( m_canvas, &dc, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE );
......
......@@ -211,8 +211,7 @@ int TestDuplicateSheetNames( bool aCreateMarker )
( (SCH_SHEET*) test_item )->GetPosition() );
marker->SetMarkerType( MARK_ERC );
marker->SetErrorLevel( ERR );
marker->SetNext( screen->GetDrawItems() );
screen->SetDrawItems( marker );
screen->Append( marker );
}
err_count++;
......@@ -242,8 +241,7 @@ void Diagnose( NETLIST_OBJECT* aNetItemRef, NETLIST_OBJECT* aNetItemTst,
marker->SetMarkerType( MARK_ERC );
marker->SetErrorLevel( WAR );
screen = aNetItemRef->m_SheetList.LastScreen();
marker->SetNext( screen->GetDrawItems() );
screen->SetDrawItems( marker );
screen->Append( marker );
wxString msg;
......
......@@ -57,8 +57,6 @@ bool SCH_EDIT_FRAME::LoadOneEEFile( SCH_SCREEN* aScreen, const wxString& aFullFi
{
char Name1[256];
bool itemLoaded = false;
SCH_ITEM* Phead;
SCH_ITEM* Pnext;
SCH_ITEM* item;
wxString MsgDiag; // Error and log messages
char* line;
......@@ -228,8 +226,7 @@ again." );
}
else
{
item->SetNext( aScreen->GetDrawItems() );
aScreen->SetDrawItems( item );
aScreen->Append( item );
}
}
......@@ -240,19 +237,6 @@ again." );
}
}
/* GetDrawItems() was constructed in reverse order - reverse it back: */
Phead = NULL;
while( aScreen->GetDrawItems() )
{
Pnext = aScreen->GetDrawItems();
aScreen->SetDrawItems( aScreen->GetDrawItems()->Next() );
Pnext->SetNext( Phead );
Phead = Pnext;
}
aScreen->SetDrawItems( Phead );
#if 0 && defined (DEBUG)
aScreen->Show( 0, std::cout );
#endif
......
......@@ -126,11 +126,9 @@ void DeleteItemsInList( EDA_DRAW_PANEL* panel, PICKED_ITEMS_LIST& aItemsList )
}
else
{
screen->RemoveFromDrawList( item );
screen->Remove( item );
/* Unlink the structure */
item->SetNext( 0 );
item->SetBack( 0 );
itemsList.PushItem( itemWrapper );
}
}
......@@ -160,11 +158,7 @@ void SCH_EDIT_FRAME::DeleteItem( SCH_ITEM* aItem )
}
else
{
screen->RemoveFromDrawList( aItem );
aItem->SetNext( NULL );
aItem->SetBack( NULL ); // Only one struct -> no link
screen->Remove( aItem );
SaveCopyInUndoList( aItem, UR_DELETED );
m_canvas->RefreshDrawingRect( aItem->GetBoundingBox() );
}
......@@ -220,8 +214,7 @@ void DuplicateItemsInList( SCH_SCREEN* screen, PICKED_ITEMS_LIST& aItemsList,
}
SetSchItemParent( newitem, screen );
newitem->SetNext( screen->GetDrawItems() );
screen->SetDrawItems( newitem );
screen->Append( newitem );
}
}
......
......@@ -2,7 +2,6 @@
* 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
* Copyright (C) 2008-2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors.
*
* This program is free software; you can redistribute it and/or
......
......@@ -2,7 +2,6 @@
* 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
* Copyright (C) 2008-2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors.
*
* This program is free software; you can redistribute it and/or
......
......@@ -2,7 +2,6 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2009 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
......
......@@ -2,7 +2,6 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2009 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
......
......@@ -2,7 +2,6 @@
* 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
* Copyright (C) 2008-2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors.
*
* This program is free software; you can redistribute it and/or
......
......@@ -2,7 +2,6 @@
* 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
* Copyright (C) 2008-2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors.
*
* This program is free software; you can redistribute it and/or
......
......@@ -2,7 +2,6 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2009 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
......
......@@ -2,7 +2,6 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2009 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
......
......@@ -2,7 +2,6 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2009 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
......
......@@ -2,7 +2,6 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2009 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
......
......@@ -2,7 +2,6 @@
* 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
* Copyright (C) 2008-2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors.
*
* This program is free software; you can redistribute it and/or
......
......@@ -2,7 +2,6 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2009 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
......
......@@ -2,7 +2,6 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2009 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
......
......@@ -2,7 +2,6 @@
* 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
* Copyright (C) 2008-2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors.
*
* This program is free software; you can redistribute it and/or
......
......@@ -2,7 +2,6 @@
* 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
* Copyright (C) 2008-2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors.
*
* This program is free software; you can redistribute it and/or
......@@ -37,7 +36,7 @@
class SCH_POLYLINE : public SCH_ITEM
{
int m_width; /* Thickness */
int m_width; // Thickness
std::vector<wxPoint> m_points; // list of points (>= 2)
public:
......
This diff is collapsed.
......@@ -2,7 +2,6 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2009 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2011 Kicad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
......
......@@ -2,7 +2,6 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2009 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
......
......@@ -2,7 +2,6 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2006 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
......
......@@ -2,7 +2,6 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2009 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
......
......@@ -2,7 +2,6 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2009 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
......
......@@ -178,12 +178,27 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_SCH_BREAK_WIRE:
{
DLIST< SCH_ITEM > oldWires;
oldWires.SetOwnership( false ); // Prevent DLIST for deleting items in destructor.
m_canvas->MoveCursorToCrossHair();
SCH_ITEM* oldWiresList = screen->ExtractWires( true );
screen->ExtractWires( oldWires, true );
screen->BreakSegment( screen->GetCrossHairPosition() );
if( oldWiresList )
SaveCopyInUndoList( oldWiresList, UR_WIRE_IMAGE );
if( oldWires.GetCount() != 0 )
{
PICKED_ITEMS_LIST oldItems;
oldItems.m_Status = UR_WIRE_IMAGE;
while( oldWires.GetCount() != 0 )
{
ITEM_PICKER picker = ITEM_PICKER( oldWires.PopFront(), UR_WIRE_IMAGE );
oldItems.PushItem( picker );
}
SaveCopyInUndoList( oldItems, UR_WIRE_IMAGE );
}
screen->TestDanglingEnds( m_canvas, &dc );
}
......
......@@ -2,7 +2,6 @@
* 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
* Copyright (C) 2008-2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors.
*
* This program is free software; you can redistribute it and/or
......@@ -112,13 +111,11 @@ void SCH_EDIT_FRAME::SaveCopyInUndoList( SCH_ITEM* aItem,
UNDO_REDO_T aCommandType,
const wxPoint& aTransformPoint )
{
/* Does not save a null item.
* but if aCommandType == UR_WIRE_IMAGE, we must save null item.
* It happens for the first wire entered in schematic:
* To undo this first command, the previous state is a NULL item,
* and we accept this
/* 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 || aCommandType == UR_WIRE_IMAGE )
return;
PICKED_ITEMS_LIST* commandToUndo = new PICKED_ITEMS_LIST();
......@@ -137,7 +134,6 @@ void SCH_EDIT_FRAME::SaveCopyInUndoList( SCH_ITEM* aItem,
break;
case UR_NEW:
case UR_WIRE_IMAGE:
case UR_DELETED:
case UR_ROTATED:
case UR_MOVED:
......@@ -145,12 +141,8 @@ void SCH_EDIT_FRAME::SaveCopyInUndoList( SCH_ITEM* aItem,
break;
default:
{
wxString msg;
msg.Printf( wxT( "SaveCopyInUndoList() error (unknown code %X)" ),
aCommandType );
wxMessageBox( msg );
}
wxFAIL_MSG( wxString::Format( wxT( "SaveCopyInUndoList() error (unknown code %X)" ),
aCommandType ) );
break;
}
......@@ -163,7 +155,9 @@ void SCH_EDIT_FRAME::SaveCopyInUndoList( SCH_ITEM* aItem,
GetScreen()->ClearUndoORRedoList( GetScreen()->m_RedoList );
}
else
{
delete commandToUndo;
}
}
......@@ -174,6 +168,7 @@ void SCH_EDIT_FRAME::SaveCopyInUndoList( PICKED_ITEMS_LIST& aItemsList,
PICKED_ITEMS_LIST* commandToUndo = new PICKED_ITEMS_LIST();
commandToUndo->m_TransformPoint = aTransformPoint;
commandToUndo->m_Status = aTypeCommand;
// Copy picker list:
commandToUndo->CopyList( aItemsList );
......@@ -202,6 +197,7 @@ void SCH_EDIT_FRAME::SaveCopyInUndoList( PICKED_ITEMS_LIST& aItemsList,
*/
if( commandToUndo->GetPickedItemLink( ii ) == NULL )
commandToUndo->SetPickedItemLink( DuplicateStruct( item, true ), ii );
wxASSERT( commandToUndo->GetPickedItemLink( ii ) );
break;
......@@ -212,6 +208,7 @@ void SCH_EDIT_FRAME::SaveCopyInUndoList( PICKED_ITEMS_LIST& aItemsList,
case UR_NEW:
case UR_DELETED:
case UR_EXCHANGE_T:
case UR_WIRE_IMAGE:
break;
default:
......@@ -220,7 +217,7 @@ void SCH_EDIT_FRAME::SaveCopyInUndoList( PICKED_ITEMS_LIST& aItemsList,
}
}
if( commandToUndo->GetCount() )
if( commandToUndo->GetCount() || aTypeCommand == UR_WIRE_IMAGE )
{
/* Save the copy in undo list */
GetScreen()->PushCommandToUndoList( commandToUndo );
......@@ -229,7 +226,9 @@ void SCH_EDIT_FRAME::SaveCopyInUndoList( PICKED_ITEMS_LIST& aItemsList,
GetScreen()->ClearUndoORRedoList( GetScreen()->m_RedoList );
}
else // Should not occur
{
delete commandToUndo;
}
}
......@@ -238,9 +237,36 @@ void SCH_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bool aRed
SCH_ITEM* item;
SCH_ITEM* alt_item;
// 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
// 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.
for( int ii = aList->GetCount() - 1; ii >= 0; ii-- )
{
item = (SCH_ITEM*) aList->GetPickedItem( ii );
......@@ -253,18 +279,21 @@ void SCH_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bool aRed
switch( aList->GetPickedItemStatus( ii ) )
{
case UR_CHANGED: /* Exchange old and new data for each item */
// tmp = item->Clone();
// *item = *image;
// *image = *tmp;
// delete tmp;
item->SwapData( image );
break;
case UR_NEW: /* new items are deleted */
aList->SetPickedItemStatus( UR_DELETED, ii );
GetScreen()->RemoveFromDrawList( item );
GetScreen()->Remove( item );
break;
case UR_DELETED: /* deleted items are put in EEdrawList, as new items */
case UR_DELETED: /* deleted items are put in the draw item list, as new items */
aList->SetPickedItemStatus( UR_NEW, ii );
item->SetNext( GetScreen()->GetDrawItems() );
GetScreen()->SetDrawItems( item );
GetScreen()->Append( item );
break;
case UR_MOVED:
......@@ -275,55 +304,32 @@ void SCH_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bool aRed
break;
case UR_MIRRORED_Y:
{
wxPoint mirrorPoint = aList->m_TransformPoint;
item->Mirror_Y( mirrorPoint.x );
}
item->Mirror_Y( aList->m_TransformPoint.x );
break;
case UR_MIRRORED_X:
{
wxPoint mirrorPoint = aList->m_TransformPoint;
item->Mirror_X( mirrorPoint.y );
}
item->Mirror_X( aList->m_TransformPoint.y );
break;
case UR_ROTATED:
{
// To undo a rotate 90 deg transform we must rotate 270 deg to undo
// and 90 deg to redo:
wxPoint RotationPoint = aList->m_TransformPoint;
item->Rotate( RotationPoint );
item->Rotate( aList->m_TransformPoint );
if( aRedoCommand )
break; // A only one rotate transform is OK
// Make 3 rotate 90 deg transforms is this is actually an undo command
item->Rotate( RotationPoint );
item->Rotate( RotationPoint );
}
break;
case UR_WIRE_IMAGE:
/* Exchange the current wires and the old wires */
alt_item = GetScreen()->ExtractWires( false );
aList->SetPickedItem( alt_item, ii );
while( item )
{
SCH_ITEM* nextitem = item->Next();
item->SetNext( GetScreen()->GetDrawItems() );
GetScreen()->SetDrawItems( item );
item->ClearFlags();
item = nextitem;
}
// Make 3 rotate 90 deg transforms is this is actually an undo command
item->Rotate( aList->m_TransformPoint );
item->Rotate( aList->m_TransformPoint );
break;
case UR_EXCHANGE_T:
alt_item = (SCH_ITEM*) aList->GetPickedItemLink( ii );
alt_item->SetNext( NULL );
alt_item->SetBack( NULL );
GetScreen()->RemoveFromDrawList( item );
GetScreen()->AddToDrawList( alt_item );
GetScreen()->Remove( item );
GetScreen()->Append( alt_item );
aList->SetPickedItem( alt_item, ii );
aList->SetPickedItemLink( item, ii );
break;
......
......@@ -2,7 +2,6 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2009 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
......@@ -930,7 +929,7 @@ void SCH_EDIT_FRAME::addCurrentItemToList( wxDC* aDC )
if( undoItem == item )
{
if( !screen->CheckIfOnDrawList( item ) ) // don't want a loop!
screen->AddToDrawList( item );
screen->Append( item );
SetRepeatItem( item );
......
......@@ -2,7 +2,6 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2006 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2009-2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors.
*
* This program is free software; you can redistribute it and/or
......@@ -282,14 +281,14 @@ static void ExitSheet( EDA_DRAW_PANEL* aPanel, wxDC* aDC )
}
else if( item->IsMoving() || item->IsResized() )
{
screen->RemoveFromDrawList( item );
screen->Remove( item );
delete item;
item = parent->GetUndoItem();
wxCHECK_RET( item != NULL, wxT( "Cannot restore undefined last sheet item." ) );
screen->AddToDrawList( item );
screen->Append( item );
// the owner of item is no more parent, this is the draw list of screen:
parent->SetUndoItem( NULL );
......
......@@ -2,7 +2,6 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2009 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
......@@ -32,6 +31,7 @@
#define CLASS_SCREEN_H
#include <macros.h>
#include <dlist.h>
#include <sch_item_struct.h>
#include <class_base_screen.h>
#include <class_title_block.h>
......@@ -73,7 +73,7 @@ class SCH_SCREEN : public BASE_SCREEN
/// Position of the origin axis, which is used in exports mostly, but not yet in EESCHEMA
wxPoint m_originAxisPosition;
SCH_ITEM* m_drawList; ///< Object list for the screen.
DLIST< SCH_ITEM > m_drawList; ///< Object list for the screen.
/// @todo use DLIST<SCH_ITEM> or superior container
/**
......@@ -122,8 +122,17 @@ public:
* Function GetDrawItems().
* @return - A pointer to the first item in the linked list of draw items.
*/
SCH_ITEM* GetDrawItems() const { return m_drawList; }
void SetDrawItems( SCH_ITEM* aItem ) { m_drawList = aItem; }
SCH_ITEM* GetDrawItems() const { return m_drawList.begin(); }
void Append( SCH_ITEM* aItem ) { m_drawList.Append( aItem ); }
/**
* Function Append
* adds \a aList of SCH_ITEM objects to the list for draw items for the sheet.
*
* @param aList A reference to a #DLIST containing the #SCH_ITEM to add to the sheet.
*/
void Append( DLIST< SCH_ITEM >& aList ) { m_drawList.Append( aList ); }
/**
* Function GetCurItem
......@@ -184,11 +193,13 @@ public:
void Plot( PLOTTER* aPlotter );
/**
* Remove \a aItem from the schematic associated with this screen.
* Function Remove
* removes \a aItem from the schematic associated with this screen.
*
* @param aItem - Item to be removed from schematic.
* @note The removed item is not deleted. It is only unlinked from the item list.
* @param aItem Item to be removed from schematic.
*/
void RemoveFromDrawList( SCH_ITEM* aItem );
void Remove( SCH_ITEM* aItem );
/**
* Function DeleteItem
......@@ -201,8 +212,6 @@ public:
bool CheckIfOnDrawList( SCH_ITEM* st );
void AddToDrawList( SCH_ITEM* st );
/**
* Function SchematicCleanUp
* performs routine schematic cleaning including breaking wire and buses and
......@@ -226,23 +235,24 @@ public:
/**
* Function ExtractWires
* extracts the old wires, junctions and buses. If \a aCreateCopy is true, replace
* them with a copy. Old item must be put in undo list, and the new ones can be
* modified by clean up safely. If an abort command is made, old wires must be put
* in GetDrawItems(), and copies must be deleted. This is because previously stored
* undo commands can handle pointers on wires or buses, and we do not delete wires or
* buss-es, we must put they in undo list.
* extracted items with a copy of the original. Old items are to be put in undo list,
* and the new ones can be modified by clean up safely. If an abort draw segmat command
* is made, the old wires must be put back into #m_drawList, and the copies must be
* deleted. This is because previously stored undo commands can handle pointers on wires
* or buses, and we do not delete wires or buses, we must put them in undo list.
*
* Because cleanup delete and/or modify bus and wires, the it is easier is to put
* all wires in undo list and use a new copy of wires for cleanup.
* Because cleanup deletes and/or modify bus and wires, it is easier is to put
* all the existing wires in undo list and use a new copy of wires for cleanup.
*/
SCH_ITEM* ExtractWires( bool aCreateCopy );
void ExtractWires( DLIST< SCH_ITEM >& aList, bool aCreateCopy );
/**
* Function ReplaceWires
* replaces all of the wires and junction in the screen with \a aWireList.
* @param aWireList List of wire to replace the existing wires with.
* replaces all of the wires, buses, and junctions in the screen with \a aWireList.
*
* @param aWireList List of wires to replace the existing wires with.
*/
void ReplaceWires( SCH_ITEM* aWireList );
void ReplaceWires( DLIST< SCH_ITEM >& aWireList );
/**
* Function MarkConnections
......
......@@ -63,22 +63,31 @@ protected:
/**
* Function append
* adds \a aNewElement to the end of the list.
* @param aNewElement The element to insert.
*/
void append( EDA_ITEM* aNewElement );
/**
* Function append
* adds \a aList to the end of the list.
* @param aList The list to aList.
*/
void append( DHEAD& aList );
/**
* Function insert
* puts aNewElement just in front of aElementAfterMe in the list sequence.
* If aElementAfterMe is NULL, then simply append().
* puts \a aNewElement just in front of \a aElementAfterMe in the list sequence.
* If \a aElementAfterMe is NULL, then simply append().
* @param aNewElement The element to insert.
* @param aElementAfterMe The element to insert \a aNewElement before,
* if NULL then append aNewElement onto end of list.
* if NULL then append \a aNewElement onto end of list.
*/
void insert( EDA_ITEM* aNewElement, EDA_ITEM* aElementAfterMe );
/**
* Function insert
* puts aNewElement in front of list sequence.
* puts \a aNewElement in front of list sequence.
* @param aNewElement The element to insert.
*/
void insert( EDA_ITEM* aNewElement )
{
......@@ -88,6 +97,7 @@ protected:
/**
* Function remove
* removes \a aElement from the list, but does not delete it.
* @param aElement The element to remove.
*/
void remove( EDA_ITEM* aElement );
......@@ -162,16 +172,30 @@ public:
/**
* Function Append
* adds \a aNewElement to the end of the list.
* @param aNewElement The element to insert.
*/
void Append( T* aNewElement )
{
append( aNewElement );
}
/**
* Function Append
* adds \a aList to the end of the list.
* @param aList The list to append to the end of the list.
*/
void Append( DLIST& aList )
{
append( aList );
}
/**
* Function Insert
* puts aNewElement just in front of aElementAfterMe in the list sequence.
* puts \a aNewElement just in front of \a aElementAfterMe in the list sequence.
* If aElementAfterMe is NULL, then simply Append()
* @param aNewElement The element to insert.
* @param aElementAfterMe The element to insert \a aNewElement before,
* if NULL then append \a aNewElement onto end of list.
*/
void Insert( T* aNewElement, T* aElementAfterMe )
{
......@@ -181,6 +205,7 @@ public:
/**
* Function Remove
* removes \a aElement from the list, but does not delete it.
* @param aElement The element to remove from the list.
* @return T* - the removed element, so you can easily delete it upon return.
*/
T* Remove( T* aElement )
......@@ -210,6 +235,7 @@ public:
/**
* Function PushFront
* puts aNewElement at front of list sequence.
* @param aNewElement The element to insert at the front of the list.
*/
void PushFront( T* aNewElement )
{
......@@ -219,6 +245,7 @@ public:
/**
* Function PushBack
* puts aNewElement at the end of the list sequence.
* @param aNewElement The element to push to the end of the list.
*/
void PushBack( T* aNewElement )
{
......
......@@ -2,7 +2,6 @@
* 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
* Copyright (C) 2008-2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors.
*
* This program is free software; you can redistribute it and/or
......@@ -352,8 +351,6 @@ public:
virtual bool operator <( const SCH_ITEM& aItem ) const;
virtual SCH_ITEM& operator=( const SCH_ITEM& aItem );
/**
* @note - The DoXXX() functions below are used to enforce the interface while retaining
* the ability of change the implementation behavior of derived classes. See
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment