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.
This commit is contained in:
Wayne Stambaugh 2012-02-26 13:39:39 -05:00
parent a1ff326181
commit aaa1cc3e02
37 changed files with 431 additions and 548 deletions

View File

@ -2,7 +2,6 @@
* This program source code file is part of KiCad, a free EDA CAD application. * 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) 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. * Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * 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 ) if( &aItem != this )
{ {
m_StructType = aItem.Type(); m_Image = aItem.m_Image;
Pnext = aItem.Pnext;
Pback = aItem.Pback;
m_StructType = aItem.m_StructType; m_StructType = aItem.m_StructType;
m_Parent = aItem.m_Parent; m_Parent = aItem.m_Parent;
m_Son = aItem.m_Son; m_Son = aItem.m_Son;
m_Flags = aItem.m_Flags; m_Flags = aItem.m_Flags;
SetTimeStamp( aItem.m_TimeStamp ); m_TimeStamp = aItem.m_TimeStamp;
m_Status = aItem.m_Status; m_Status = aItem.m_Status;
m_forceVisible = aItem.m_forceVisible;
} }
return *this; return *this;

View File

@ -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 ) void DHEAD::insert( EDA_ITEM* aNewElement, EDA_ITEM* aAfterMe )
{ {
wxASSERT( aNewElement != NULL ); wxASSERT( aNewElement != NULL );

View File

@ -2,7 +2,6 @@
* This program source code file is part of KiCad, a free EDA CAD application. * 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) 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. * Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * 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 ) void SCH_ITEM::doPlot( PLOTTER* aPlotter )
{ {
wxFAIL_MSG( wxT( "doPlot() method not implemented for class " ) + GetClass() ); wxFAIL_MSG( wxT( "doPlot() method not implemented for class " ) + GetClass() );

View File

@ -559,8 +559,7 @@ void SCH_EDIT_FRAME::PasteListOfItems( wxDC* DC )
SetSchItemParent( Struct, GetScreen() ); SetSchItemParent( Struct, GetScreen() );
Struct->Draw( m_canvas, DC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE ); Struct->Draw( m_canvas, DC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE );
Struct->SetNext( GetScreen()->GetDrawItems() ); GetScreen()->Append( Struct );
GetScreen()->SetDrawItems( Struct );
} }
SaveCopyInUndoList( picklist, UR_NEW ); SaveCopyInUndoList( picklist, UR_NEW );

View File

@ -2,7 +2,6 @@
* This program source code file is part of KiCad, a free EDA CAD application. * 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) 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. * Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
@ -51,8 +50,10 @@
static void AbortCreateNewLine( EDA_DRAW_PANEL* Panel, wxDC* DC ); static void AbortCreateNewLine( EDA_DRAW_PANEL* Panel, wxDC* DC );
static void ComputeBreakPoint( SCH_LINE* segment, const wxPoint& new_pos ); static void ComputeBreakPoint( SCH_LINE* segment, const wxPoint& new_pos );
SCH_ITEM* s_OldWiresList; static DLIST< SCH_ITEM > s_wires;
wxPoint s_ConnexionStartPoint; static DLIST< SCH_ITEM > s_oldWires;
static wxPoint s_startPoint;
/** /**
@ -61,19 +62,17 @@ wxPoint s_ConnexionStartPoint;
static void DrawSegment( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition, static void DrawSegment( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition,
bool aErase ) bool aErase )
{ {
SCH_LINE* CurrentLine = (SCH_LINE*) aPanel->GetScreen()->GetCurItem();
SCH_LINE* segment; SCH_LINE* segment;
int color; int color;
if( CurrentLine == NULL ) if( s_wires.GetCount() == 0 )
return; return;
color = ReturnLayerColor( CurrentLine->GetLayer() ) ^ HIGHLIGHT_FLAG; segment = (SCH_LINE*) s_wires.begin();
color = ReturnLayerColor( segment->GetLayer() ) ^ HIGHLIGHT_FLAG;
if( aErase ) if( aErase )
{ {
segment = CurrentLine;
while( segment ) while( segment )
{ {
if( !segment->IsNull() ) // Redraw if segment length != 0 if( !segment->IsNull() ) // Redraw if segment length != 0
@ -86,11 +85,11 @@ static void DrawSegment( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosi
wxPoint endpos = aPanel->GetScreen()->GetCrossHairPosition(); wxPoint endpos = aPanel->GetScreen()->GetCrossHairPosition();
if( g_HVLines ) /* Coerce the line to vertical or horizontal one: */ if( g_HVLines ) /* Coerce the line to vertical or horizontal one: */
ComputeBreakPoint( CurrentLine, endpos ); ComputeBreakPoint( (SCH_LINE*) s_wires.GetLast()->Back(), endpos );
else else
CurrentLine->SetEndPoint( endpos ); ( (SCH_LINE*) s_wires.GetLast() )->SetEndPoint( endpos );
segment = CurrentLine; segment = (SCH_LINE*) s_wires.begin();
while( segment ) while( segment )
{ {
@ -104,259 +103,195 @@ static void DrawSegment( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosi
void SCH_EDIT_FRAME::BeginSegment( wxDC* DC, int type ) void SCH_EDIT_FRAME::BeginSegment( wxDC* DC, int type )
{ {
SCH_LINE* oldsegment, * newsegment, * nextsegment; SCH_LINE* segment;
SCH_LINE* nextSegment;
wxPoint cursorpos = GetScreen()->GetCrossHairPosition(); wxPoint cursorpos = GetScreen()->GetCrossHairPosition();
if( GetScreen()->GetCurItem() && (GetScreen()->GetCurItem()->GetFlags() == 0) ) segment = (SCH_LINE*) GetScreen()->GetCurItem();
GetScreen()->SetCurItem( NULL );
if( GetScreen()->GetCurItem() ) if( !segment ) /* first point : Create first wire or bus */
{ {
switch( GetScreen()->GetCurItem()->Type() ) s_startPoint = cursorpos;
{ GetScreen()->ExtractWires( s_oldWires, true );
case SCH_LINE_T:
case SCH_POLYLINE_T:
break;
default:
return;
}
}
oldsegment = newsegment = (SCH_LINE*) GetScreen()->GetCurItem();
if( !newsegment ) /* first point : Create first wire or bus */
{
s_ConnexionStartPoint = cursorpos;
s_OldWiresList = GetScreen()->ExtractWires( true );
GetScreen()->SchematicCleanUp( m_canvas ); GetScreen()->SchematicCleanUp( m_canvas );
switch( type ) switch( type )
{ {
default: default:
newsegment = new SCH_LINE( cursorpos, LAYER_NOTES ); segment = new SCH_LINE( cursorpos, LAYER_NOTES );
break; break;
case LAYER_WIRE: case LAYER_WIRE:
newsegment = new SCH_LINE( cursorpos, LAYER_WIRE ); segment = new SCH_LINE( cursorpos, LAYER_WIRE );
/* A junction will be created later, when we'll know the /* A junction will be created later, when we'll know the
* segment end position, and if the junction is really needed */ * segment end position, and if the junction is really needed */
break; break;
case LAYER_BUS: case LAYER_BUS:
newsegment = new SCH_LINE( cursorpos, LAYER_BUS ); segment = new SCH_LINE( cursorpos, LAYER_BUS );
break; break;
} }
newsegment->SetFlags( IS_NEW ); segment->SetFlags( IS_NEW );
s_wires.PushBack( segment );
GetScreen()->SetCurItem( segment );
if( g_HVLines ) // We need 2 segments to go from a given start pin to an end point // We need 2 segments to go from a given start pin to an end point when the horizontal
// and vertical lines only switch is on.
if( g_HVLines )
{ {
nextsegment = new SCH_LINE( *newsegment ); nextSegment = new SCH_LINE( *segment );
nextsegment->SetFlags( IS_NEW ); nextSegment->SetFlags( IS_NEW );
newsegment->SetNext( nextsegment ); s_wires.PushBack( nextSegment );
nextsegment->SetBack( newsegment ); GetScreen()->SetCurItem( nextSegment );
} }
GetScreen()->SetCurItem( newsegment );
m_canvas->SetMouseCapture( DrawSegment, AbortCreateNewLine ); m_canvas->SetMouseCapture( DrawSegment, AbortCreateNewLine );
m_itemToRepeat = NULL; m_itemToRepeat = NULL;
} }
else // A segment is in progress: terminates the current segment and add a new segment. else // A segment is in progress: terminates the current segment and add a new segment.
{ {
nextsegment = oldsegment->Next(); SCH_LINE* prevSegment = (SCH_LINE*) segment->Back();
wxLogDebug( wxT( "Adding new segment after " ) + segment->GetSelectMenuText() );
if( !g_HVLines ) if( !g_HVLines )
{ {
// if only one segment is needed and it has length = 0, do not create a new one. // If only one segment is needed and it has a zero length, do not create a new one.
if( oldsegment->IsNull() ) if( segment->IsNull() )
return; return;
} }
else else
{ {
/* if we want 2 segment and the last two have len = 0, do not wxCHECK_RET( prevSegment != NULL, wxT( "Failed to create second line segment." ) );
* create a new one */
if( oldsegment->IsNull() && nextsegment && nextsegment->IsNull() ) // If two segments are required and they both have zero length, do not
// create a new one.
if( prevSegment && prevSegment->IsNull() && segment->IsNull() )
return; return;
} }
m_canvas->CallMouseCapture( DC, wxDefaultPosition, false ); m_canvas->CallMouseCapture( DC, wxDefaultPosition, false );
/* Creates the new segment, or terminates the command // Terminate the command if the end point is on a pin, junction, or another wire or bus.
* if the end point is on a pin, junction or an other wire or bus */ if( GetScreen()->IsTerminalPoint( cursorpos, segment->GetLayer() ) )
if( GetScreen()->IsTerminalPoint( cursorpos, oldsegment->GetLayer() ) )
{ {
EndSegment( DC ); EndSegment( DC );
return; return;
} }
oldsegment->SetNext( GetScreen()->GetDrawItems() ); // Create a new segment, and chain it after the current new segment.
GetScreen()->SetDrawItems( oldsegment ); nextSegment = new SCH_LINE( *segment );
m_canvas->CrossHairOff( DC ); // Erase schematic cursor nextSegment->SetStartPoint( cursorpos );
oldsegment->Draw( m_canvas, DC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE ); s_wires.PushBack( nextSegment );
m_canvas->CrossHairOn( DC ); // Display schematic cursor
/* Create a new segment, and chain it after the current new segment */ segment->SetEndPoint( cursorpos );
if( nextsegment ) segment->ClearFlags( IS_NEW );
{ segment->SetFlags( SELECTED );
newsegment = new SCH_LINE( *nextsegment ); nextSegment->SetFlags( IS_NEW );
nextsegment->SetStartPoint( newsegment->GetEndPoint() ); GetScreen()->SetCurItem( nextSegment );
nextsegment->SetNext( NULL );
nextsegment->SetBack( newsegment );
newsegment->SetNext( nextsegment );
newsegment->SetBack( NULL );
}
else
{
newsegment = new SCH_LINE( *oldsegment );
newsegment->SetStartPoint( oldsegment->GetEndPoint() );
}
newsegment->SetEndPoint( cursorpos );
oldsegment->ClearFlags( IS_NEW );
oldsegment->SetFlags( SELECTED );
newsegment->SetFlags( IS_NEW );
GetScreen()->SetCurItem( newsegment );
m_canvas->CallMouseCapture( DC, wxDefaultPosition, false ); m_canvas->CallMouseCapture( DC, wxDefaultPosition, false );
/* This is the first segment: Now we know the start segment position.
* Create a junction if needed. Note: a junction can be needed later,
* if the new segment is merged (after a cleanup) with an older one
* (tested when the connection will be finished)*/
if( oldsegment->GetStartPoint() == s_ConnexionStartPoint )
{
if( GetScreen()->IsJunctionNeeded( s_ConnexionStartPoint ) )
AddJunction( DC, s_ConnexionStartPoint );
}
} }
} }
void SCH_EDIT_FRAME::EndSegment( wxDC* DC ) void SCH_EDIT_FRAME::EndSegment( wxDC* DC )
{ {
SCH_LINE* firstsegment = (SCH_LINE*) GetScreen()->GetCurItem(); SCH_SCREEN* screen = GetScreen();
SCH_LINE* lastsegment = firstsegment; SCH_LINE* segment = (SCH_LINE*) screen->GetCurItem();
SCH_LINE* segment;
if( firstsegment == NULL ) if( segment == NULL || segment->Type() != SCH_LINE_T || !segment->IsNew() )
return; return;
if( !firstsegment->IsNew() ) // Delete zero length segments and clear item flags.
return; SCH_ITEM* item = s_wires.begin();
/* Delete Null segments and Put line it in Drawlist */
lastsegment = firstsegment;
while( lastsegment )
{
SCH_LINE* nextsegment = lastsegment->Next();
if( lastsegment->IsNull() )
{
SCH_LINE* previous_segment = lastsegment->Back();
if( firstsegment == lastsegment )
firstsegment = nextsegment;
if( nextsegment )
nextsegment->SetBack( NULL );
if( previous_segment )
previous_segment->SetNext( nextsegment );
delete lastsegment;
}
lastsegment = nextsegment;
}
/* put the segment list to the main linked list */
segment = lastsegment = firstsegment;
while( segment )
{
lastsegment = segment;
segment = segment->Next();
lastsegment->SetNext( GetScreen()->GetDrawItems() );
GetScreen()->SetDrawItems( lastsegment );
}
m_canvas->EndMouseCapture( -1, -1, wxEmptyString, false );
GetScreen()->SetCurItem( NULL );
wxPoint end_point, alt_end_point;
/* A junction can be needed to connect the last segment
* usually to m_end coordinate.
* But if the last segment is removed by a cleanup, because of redundancy,
* a junction can be needed to connect the previous segment m_end
* coordinate with is also the lastsegment->m_start coordinate */
if( lastsegment )
{
end_point = lastsegment->GetEndPoint();
alt_end_point = lastsegment->GetStartPoint();
}
GetScreen()->SchematicCleanUp( m_canvas );
/* clear flags and find last segment entered, for repeat function */
segment = (SCH_LINE*) GetScreen()->GetDrawItems();
while( segment )
{
if( segment->GetFlags() )
{
if( !m_itemToRepeat )
m_itemToRepeat = segment;
}
segment->ClearFlags();
segment = segment->Next();
}
// Automatic place of a junction on the end point, if needed
if( lastsegment )
{
if( GetScreen()->IsJunctionNeeded( end_point ) )
AddJunction( DC, end_point );
else if( GetScreen()->IsJunctionNeeded( alt_end_point ) )
AddJunction( DC, alt_end_point );
}
/* Automatic place of a junction on the start point if necessary because
* the cleanup can suppress intermediate points by merging wire segments */
if( GetScreen()->IsJunctionNeeded( s_ConnexionStartPoint ) )
AddJunction( DC, s_ConnexionStartPoint );
GetScreen()->TestDanglingEnds( m_canvas, DC );
/* Redraw wires and junctions which can be changed by TestDanglingEnds() */
m_canvas->CrossHairOff( DC ); // Erase schematic cursor
EDA_ITEM* item = GetScreen()->GetDrawItems();
while( item ) while( item )
{ {
switch( item->Type() ) item->ClearFlags();
{
case SCH_JUNCTION_T:
case SCH_LINE_T:
m_canvas->RefreshDrawingRect( item->GetBoundingBox() );
break;
default: wxCHECK_RET( item->Type() == SCH_LINE_T, wxT( "Unexpected object type in wire list." ) );
break;
segment = (SCH_LINE*) item;
if( segment->IsNull() )
{
wxLogDebug( wxT( "Removing null segment: " ) + segment->GetSelectMenuText() );
SCH_ITEM* previousSegment = item->Back();
delete s_wires.Remove( item );
if( previousSegment == NULL )
item = s_wires.begin();
else
item = previousSegment;
} }
item = item->Next(); item = item->Next();
} }
m_canvas->CrossHairOn( DC ); // Display schematic cursor if( s_wires.GetCount() == 0 )
return;
SaveCopyInUndoList( s_OldWiresList, UR_WIRE_IMAGE ); // Get the last non-null wire.
s_OldWiresList = NULL; m_itemToRepeat = segment = (SCH_LINE*) s_wires.GetLast();
screen->SetCurItem( NULL );
m_canvas->EndMouseCapture( -1, -1, wxEmptyString, false );
OnModify( ); DLIST< SCH_ITEM > tmp;
for( item = s_wires.begin(); item != NULL; item = item->Next() )
tmp.PushBack( (SCH_ITEM*) item->Clone() );
// Temporarily add the new segments to the schematic item list to test if any
// junctions are required.
screen->Append( tmp );
// Correct and remove segments that need merged.
screen->SchematicCleanUp( m_canvas, DC );
// A junction may be needed to connect the last segment. If the last segment was
// removed by a cleanup, a junction may be needed to connect the segment's end point
// which is also the same as the previous segment's start point.
if( screen->IsJunctionNeeded( segment->GetEndPoint() ) )
s_wires.Append( AddJunction( DC, segment->GetEndPoint() ) );
else if( screen->IsJunctionNeeded( segment->GetStartPoint() ) )
s_wires.Append( AddJunction( DC, segment->GetStartPoint() ) );
// Automatically place a junction on the start point if necessary because the cleanup
// can suppress intermediate points by merging wire segments.
if( screen->IsJunctionNeeded( s_startPoint ) )
s_wires.Append( AddJunction( DC, s_startPoint ) );
// Make a copy of the original wires, buses, and junctions.
for( item = s_oldWires.begin(); item != NULL; item = item->Next() )
tmp.PushBack( (SCH_ITEM*) item->Clone() );
// Restore the old wires.
if( tmp.GetCount() != 0 )
screen->ReplaceWires( tmp );
// Now add the new wires and any required junctions to the schematic item list.
screen->Append( s_wires );
screen->SchematicCleanUp( m_canvas, DC );
// Put the snap shot of the previous wire, buses, and junctions in the undo/redo list.
PICKED_ITEMS_LIST oldItems;
oldItems.m_Status = UR_WIRE_IMAGE;
while( s_oldWires.GetCount() != 0 )
{
ITEM_PICKER picker = ITEM_PICKER( s_oldWires.PopFront(), UR_WIRE_IMAGE );
oldItems.PushItem( picker );
}
SaveCopyInUndoList( oldItems, UR_WIRE_IMAGE );
OnModify();
} }
@ -364,45 +299,53 @@ void SCH_EDIT_FRAME::EndSegment( wxDC* DC )
* Function ComputeBreakPoint * Function ComputeBreakPoint
* computes the middle coordinate for 2 segments from the start point to \a aPosition * computes the middle coordinate for 2 segments from the start point to \a aPosition
* with the segments kept in the horizontal or vertical axis only. * with the segments kept in the horizontal or vertical axis only.
*
* @param aSegment A pointer to a #SCH_LINE object containing the first line break point
* to compute.
* @param aPosition A reference to a wxPoint object containing the coordinates of the
* position used to calculate the line break point.
*/ */
static void ComputeBreakPoint( SCH_LINE* aSegment, const wxPoint& aPosition ) static void ComputeBreakPoint( SCH_LINE* aSegment, const wxPoint& aPosition )
{ {
SCH_LINE* nextsegment = aSegment->Next(); wxCHECK_RET( aSegment != NULL, wxT( "Cannot compute break point of NULL line segment." ) );
wxPoint middle_position = aPosition;
SCH_LINE* nextSegment = aSegment->Next();
wxPoint midPoint = aPosition;
wxCHECK_RET( nextSegment != NULL,
wxT( "Cannot compute break point of NULL second line segment." ) );
if( nextsegment == NULL )
return;
#if 0 #if 0
if( ABS( middle_position.x - aSegment->GetStartPoint().x ) < if( ABS( midPoint.x - aSegment->GetStartPoint().x ) <
ABS( middle_position.y - aSegment->GetStartPoint().y ) ) ABS( midPoint.y - aSegment->GetStartPoint().y ) )
middle_position.x = aSegment->GetStartPoint().x; midPoint.x = aSegment->GetStartPoint().x;
else else
middle_position.y = aSegment->GetStartPoint().y; midPoint.y = aSegment->GetStartPoint().y;
#else #else
int iDx = aSegment->GetEndPoint().x - aSegment->GetStartPoint().x; int iDx = aSegment->GetEndPoint().x - aSegment->GetStartPoint().x;
int iDy = aSegment->GetEndPoint().y - aSegment->GetStartPoint().y; int iDy = aSegment->GetEndPoint().y - aSegment->GetStartPoint().y;
if( iDy != 0 ) // keep the first segment orientation (currently horizontal) if( iDy != 0 ) // keep the first segment orientation (currently horizontal)
{ {
middle_position.x = aSegment->GetStartPoint().x; midPoint.x = aSegment->GetStartPoint().x;
} }
else if( iDx != 0 ) // keep the first segment orientation (currently vertical) else if( iDx != 0 ) // keep the first segment orientation (currently vertical)
{ {
middle_position.y = aSegment->GetStartPoint().y; midPoint.y = aSegment->GetStartPoint().y;
} }
else else
{ {
if( ABS( middle_position.x - aSegment->GetStartPoint().x ) < if( ABS( midPoint.x - aSegment->GetStartPoint().x ) <
ABS( middle_position.y - aSegment->GetStartPoint().y ) ) ABS( midPoint.y - aSegment->GetStartPoint().y ) )
middle_position.x = aSegment->GetStartPoint().x; midPoint.x = aSegment->GetStartPoint().x;
else else
middle_position.y = aSegment->GetStartPoint().y; midPoint.y = aSegment->GetStartPoint().y;
} }
#endif #endif
aSegment->SetEndPoint( middle_position ); aSegment->SetEndPoint( midPoint );
nextsegment->SetStartPoint( middle_position ); nextSegment->SetStartPoint( midPoint );
nextsegment->SetEndPoint( aPosition ); nextSegment->SetEndPoint( aPosition );
} }
@ -443,7 +386,7 @@ void SCH_EDIT_FRAME::DeleteCurrentSegment( wxDC* DC )
DrawSegment( m_canvas, DC, wxDefaultPosition, false ); DrawSegment( m_canvas, DC, wxDefaultPosition, false );
} }
screen->RemoveFromDrawList( screen->GetCurItem() ); screen->Remove( screen->GetCurItem() );
m_canvas->SetMouseCaptureCallback( NULL ); m_canvas->SetMouseCaptureCallback( NULL );
screen->SetCurItem( NULL ); screen->SetCurItem( NULL );
} }
@ -460,12 +403,12 @@ SCH_JUNCTION* SCH_EDIT_FRAME::AddJunction( wxDC* aDC, const wxPoint& aPosition,
junction->Draw( m_canvas, aDC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE ); junction->Draw( m_canvas, aDC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE );
m_canvas->CrossHairOn( aDC ); // Display schematic cursor m_canvas->CrossHairOn( aDC ); // Display schematic cursor
junction->SetNext( GetScreen()->GetDrawItems() );
GetScreen()->SetDrawItems( junction );
OnModify();
if( aPutInUndoList ) if( aPutInUndoList )
{
GetScreen()->Append( junction );
SaveCopyInUndoList( junction, UR_NEW ); SaveCopyInUndoList( junction, UR_NEW );
OnModify();
}
return junction; return junction;
} }
@ -482,8 +425,7 @@ SCH_NO_CONNECT* SCH_EDIT_FRAME::AddNoConnect( wxDC* aDC, const wxPoint& aPositio
NewNoConnect->Draw( m_canvas, aDC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE ); NewNoConnect->Draw( m_canvas, aDC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE );
m_canvas->CrossHairOn( aDC ); // Display schematic cursor m_canvas->CrossHairOn( aDC ); // Display schematic cursor
NewNoConnect->SetNext( GetScreen()->GetDrawItems() ); GetScreen()->Append( NewNoConnect );
GetScreen()->SetDrawItems( NewNoConnect );
OnModify(); OnModify();
SaveCopyInUndoList( NewNoConnect, UR_NEW ); SaveCopyInUndoList( NewNoConnect, UR_NEW );
return NewNoConnect; return NewNoConnect;
@ -498,9 +440,9 @@ static void AbortCreateNewLine( EDA_DRAW_PANEL* Panel, wxDC* DC )
if( screen->GetCurItem() ) if( screen->GetCurItem() )
{ {
screen->RemoveFromDrawList( (SCH_ITEM*) screen->GetCurItem() ); s_wires.DeleteAll();
s_oldWires.DeleteAll();
screen->SetCurItem( NULL ); screen->SetCurItem( NULL );
screen->ReplaceWires( s_OldWiresList );
Panel->Refresh(); Panel->Refresh();
} }
else else
@ -540,8 +482,7 @@ void SCH_EDIT_FRAME::RepeatDrawItem( wxDC* DC )
if( m_itemToRepeat ) if( m_itemToRepeat )
{ {
m_itemToRepeat->SetNext( GetScreen()->GetDrawItems() ); GetScreen()->Append( m_itemToRepeat );
GetScreen()->SetDrawItems( m_itemToRepeat );
GetScreen()->TestDanglingEnds(); GetScreen()->TestDanglingEnds();
m_itemToRepeat->Draw( m_canvas, DC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE ); m_itemToRepeat->Draw( m_canvas, DC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE );
SaveCopyInUndoList( m_itemToRepeat, UR_NEW ); SaveCopyInUndoList( m_itemToRepeat, UR_NEW );

View File

@ -2,7 +2,6 @@
* This program source code file is part of KiCad, a free EDA CAD application. * 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) 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. * Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * 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 m_canvas->CrossHairOff( &dc ); // Erase schematic cursor
text->Draw( m_canvas, &dc, wxPoint( 0, 0 ), g_XorMode ); text->Draw( m_canvas, &dc, wxPoint( 0, 0 ), g_XorMode );
screen->RemoveFromDrawList( text ); screen->Remove( text );
screen->AddToDrawList( newtext ); screen->Append( newtext );
GetScreen()->SetCurItem( newtext );
m_itemToRepeat = NULL; m_itemToRepeat = NULL;
OnModify(); OnModify();
newtext->Draw( m_canvas, &dc, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE ); newtext->Draw( m_canvas, &dc, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE );

View File

@ -211,8 +211,7 @@ int TestDuplicateSheetNames( bool aCreateMarker )
( (SCH_SHEET*) test_item )->GetPosition() ); ( (SCH_SHEET*) test_item )->GetPosition() );
marker->SetMarkerType( MARK_ERC ); marker->SetMarkerType( MARK_ERC );
marker->SetErrorLevel( ERR ); marker->SetErrorLevel( ERR );
marker->SetNext( screen->GetDrawItems() ); screen->Append( marker );
screen->SetDrawItems( marker );
} }
err_count++; err_count++;
@ -242,8 +241,7 @@ void Diagnose( NETLIST_OBJECT* aNetItemRef, NETLIST_OBJECT* aNetItemTst,
marker->SetMarkerType( MARK_ERC ); marker->SetMarkerType( MARK_ERC );
marker->SetErrorLevel( WAR ); marker->SetErrorLevel( WAR );
screen = aNetItemRef->m_SheetList.LastScreen(); screen = aNetItemRef->m_SheetList.LastScreen();
marker->SetNext( screen->GetDrawItems() ); screen->Append( marker );
screen->SetDrawItems( marker );
wxString msg; wxString msg;

View File

@ -57,8 +57,6 @@ bool SCH_EDIT_FRAME::LoadOneEEFile( SCH_SCREEN* aScreen, const wxString& aFullFi
{ {
char Name1[256]; char Name1[256];
bool itemLoaded = false; bool itemLoaded = false;
SCH_ITEM* Phead;
SCH_ITEM* Pnext;
SCH_ITEM* item; SCH_ITEM* item;
wxString MsgDiag; // Error and log messages wxString MsgDiag; // Error and log messages
char* line; char* line;
@ -228,8 +226,7 @@ again." );
} }
else else
{ {
item->SetNext( aScreen->GetDrawItems() ); aScreen->Append( item );
aScreen->SetDrawItems( 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) #if 0 && defined (DEBUG)
aScreen->Show( 0, std::cout ); aScreen->Show( 0, std::cout );
#endif #endif

View File

@ -126,11 +126,9 @@ void DeleteItemsInList( EDA_DRAW_PANEL* panel, PICKED_ITEMS_LIST& aItemsList )
} }
else else
{ {
screen->RemoveFromDrawList( item ); screen->Remove( item );
/* Unlink the structure */ /* Unlink the structure */
item->SetNext( 0 );
item->SetBack( 0 );
itemsList.PushItem( itemWrapper ); itemsList.PushItem( itemWrapper );
} }
} }
@ -160,11 +158,7 @@ void SCH_EDIT_FRAME::DeleteItem( SCH_ITEM* aItem )
} }
else else
{ {
screen->RemoveFromDrawList( aItem ); screen->Remove( aItem );
aItem->SetNext( NULL );
aItem->SetBack( NULL ); // Only one struct -> no link
SaveCopyInUndoList( aItem, UR_DELETED ); SaveCopyInUndoList( aItem, UR_DELETED );
m_canvas->RefreshDrawingRect( aItem->GetBoundingBox() ); m_canvas->RefreshDrawingRect( aItem->GetBoundingBox() );
} }
@ -220,8 +214,7 @@ void DuplicateItemsInList( SCH_SCREEN* screen, PICKED_ITEMS_LIST& aItemsList,
} }
SetSchItemParent( newitem, screen ); SetSchItemParent( newitem, screen );
newitem->SetNext( screen->GetDrawItems() ); screen->Append( newitem );
screen->SetDrawItems( newitem );
} }
} }

View File

@ -2,7 +2,6 @@
* This program source code file is part of KiCad, a free EDA CAD application. * 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) 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. * Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or

View File

@ -2,7 +2,6 @@
* This program source code file is part of KiCad, a free EDA CAD application. * 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) 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. * Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or

View File

@ -2,7 +2,6 @@
* This program source code file is part of KiCad, a free EDA CAD application. * 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) 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. * Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or

View File

@ -2,7 +2,6 @@
* This program source code file is part of KiCad, a free EDA CAD application. * 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) 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. * Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or

View File

@ -2,7 +2,6 @@
* This program source code file is part of KiCad, a free EDA CAD application. * 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) 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. * Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or

View File

@ -2,7 +2,6 @@
* This program source code file is part of KiCad, a free EDA CAD application. * 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) 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. * Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or

View File

@ -2,7 +2,6 @@
* This program source code file is part of KiCad, a free EDA CAD application. * 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) 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. * Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or

View File

@ -2,7 +2,6 @@
* This program source code file is part of KiCad, a free EDA CAD application. * 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) 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. * Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or

View File

@ -2,7 +2,6 @@
* This program source code file is part of KiCad, a free EDA CAD application. * 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) 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. * Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or

View File

@ -2,7 +2,6 @@
* This program source code file is part of KiCad, a free EDA CAD application. * 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) 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. * Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or

View File

@ -2,7 +2,6 @@
* This program source code file is part of KiCad, a free EDA CAD application. * 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) 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. * Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or

View File

@ -2,7 +2,6 @@
* This program source code file is part of KiCad, a free EDA CAD application. * 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) 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. * Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or

View File

@ -2,7 +2,6 @@
* This program source code file is part of KiCad, a free EDA CAD application. * 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) 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. * Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or

View File

@ -2,7 +2,6 @@
* This program source code file is part of KiCad, a free EDA CAD application. * 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) 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. * Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or

View File

@ -2,7 +2,6 @@
* This program source code file is part of KiCad, a free EDA CAD application. * 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) 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. * Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
@ -37,7 +36,7 @@
class SCH_POLYLINE : public SCH_ITEM class SCH_POLYLINE : public SCH_ITEM
{ {
int m_width; /* Thickness */ int m_width; // Thickness
std::vector<wxPoint> m_points; // list of points (>= 2) std::vector<wxPoint> m_points; // list of points (>= 2)
public: public:

View File

@ -2,7 +2,6 @@
* This program source code file is part of KiCad, a free EDA CAD application. * 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) 2009 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2010 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
@ -103,8 +102,6 @@ SCH_SCREEN::SCH_SCREEN() :
{ {
size_t i; size_t i;
SetDrawItems( NULL ); // Schematic items list
SetZoom( 32 ); SetZoom( 32 );
for( i = 0; i < SCHEMATIC_ZOOM_LIST_CNT; i++ ) for( i = 0; i < SCHEMATIC_ZOOM_LIST_CNT; i++ )
@ -158,46 +155,19 @@ void SCH_SCREEN::Clear()
void SCH_SCREEN::FreeDrawList() void SCH_SCREEN::FreeDrawList()
{ {
SCH_ITEM* item; m_drawList.DeleteAll();
while( GetDrawItems() != NULL )
{
item = GetDrawItems();
SetDrawItems( GetDrawItems()->Next() );
SAFE_DELETE( item );
}
SetDrawItems( NULL );
} }
void SCH_SCREEN::RemoveFromDrawList( SCH_ITEM* aItem ) void SCH_SCREEN::Remove( SCH_ITEM* aItem )
{ {
if( aItem == GetDrawItems() ) m_drawList.Remove( aItem );
{
SetDrawItems( GetDrawItems()->Next() );
}
else
{
EDA_ITEM* DrawList = GetDrawItems();
while( DrawList && DrawList->Next() )
{
if( DrawList->Next() == aItem )
{
DrawList->SetNext( DrawList->Next()->Next() );
break;
}
DrawList = DrawList->Next();
}
}
} }
void SCH_SCREEN::DeleteItem( SCH_ITEM* aItem ) void SCH_SCREEN::DeleteItem( SCH_ITEM* aItem )
{ {
wxCHECK_RET( aItem != NULL, wxT( "Cannot delete invaled item from screen." ) ); wxCHECK_RET( aItem != NULL, wxT( "Cannot delete invalid item from screen." ) );
SetModify(); SetModify();
@ -213,34 +183,14 @@ void SCH_SCREEN::DeleteItem( SCH_ITEM* aItem )
} }
else else
{ {
if( aItem == GetDrawItems() ) delete m_drawList.Remove( aItem );
{
SetDrawItems( aItem->Next() );
SAFE_DELETE( aItem );
}
else
{
SCH_ITEM* itemList = GetDrawItems();
while( itemList && itemList->Next() )
{
if( itemList->Next() == aItem )
{
itemList->SetNext( aItem->Next() );
SAFE_DELETE( aItem );
return;
}
itemList = itemList->Next();
}
}
} }
} }
bool SCH_SCREEN::CheckIfOnDrawList( SCH_ITEM* aItem ) bool SCH_SCREEN::CheckIfOnDrawList( SCH_ITEM* aItem )
{ {
SCH_ITEM* itemList = GetDrawItems(); SCH_ITEM* itemList = m_drawList.begin();
while( itemList ) while( itemList )
{ {
@ -254,19 +204,9 @@ bool SCH_SCREEN::CheckIfOnDrawList( SCH_ITEM* aItem )
} }
void SCH_SCREEN::AddToDrawList( SCH_ITEM* aItem )
{
if( aItem == NULL )
return;
aItem->SetNext( GetDrawItems() );
SetDrawItems( aItem );
}
SCH_ITEM* SCH_SCREEN::GetItem( const wxPoint& aPosition, int aAccuracy, KICAD_T aType ) const SCH_ITEM* SCH_SCREEN::GetItem( const wxPoint& aPosition, int aAccuracy, KICAD_T aType ) const
{ {
for( SCH_ITEM* item = GetDrawItems(); item != NULL; item = item->Next() ) for( SCH_ITEM* item = m_drawList.begin(); item != NULL; item = item->Next() )
{ {
if( item->HitTest( aPosition, aAccuracy ) && (aType == NOT_USED) ) if( item->HitTest( aPosition, aAccuracy ) && (aType == NOT_USED) )
return item; return item;
@ -302,11 +242,12 @@ SCH_ITEM* SCH_SCREEN::GetItem( const wxPoint& aPosition, int aAccuracy, KICAD_T
} }
SCH_ITEM* SCH_SCREEN::ExtractWires( bool CreateCopy ) void SCH_SCREEN::ExtractWires( DLIST< SCH_ITEM >& aList, bool aCreateCopy )
{ {
SCH_ITEM* item, * next_item, * new_item, * List = NULL; SCH_ITEM* item;
SCH_ITEM* next_item;
for( item = GetDrawItems(); item != NULL; item = next_item ) for( item = m_drawList.begin(); item != NULL; item = next_item )
{ {
next_item = item->Next(); next_item = item->Next();
@ -314,33 +255,27 @@ SCH_ITEM* SCH_SCREEN::ExtractWires( bool CreateCopy )
{ {
case SCH_JUNCTION_T: case SCH_JUNCTION_T:
case SCH_LINE_T: case SCH_LINE_T:
RemoveFromDrawList( item ); m_drawList.Remove( item );
item->SetNext( List ); aList.Append( item );
List = item;
if( aCreateCopy )
m_drawList.Insert( item->Clone(), next_item );
if( CreateCopy )
{
new_item = item->Clone();
new_item->SetNext( GetDrawItems() );
SetDrawItems( new_item );
}
break; break;
default: default:
break; break;
} }
} }
return List;
} }
void SCH_SCREEN::ReplaceWires( SCH_ITEM* aWireList ) void SCH_SCREEN::ReplaceWires( DLIST< SCH_ITEM >& aWireList )
{ {
SCH_ITEM* item; SCH_ITEM* item;
SCH_ITEM* next_item; SCH_ITEM* next_item;
for( item = GetDrawItems(); item != NULL; item = next_item ) for( item = m_drawList.begin(); item != NULL; item = next_item )
{ {
next_item = item->Next(); next_item = item->Next();
@ -348,7 +283,7 @@ void SCH_SCREEN::ReplaceWires( SCH_ITEM* aWireList )
{ {
case SCH_JUNCTION_T: case SCH_JUNCTION_T:
case SCH_LINE_T: case SCH_LINE_T:
RemoveFromDrawList( item ); Remove( item );
delete item; delete item;
break; break;
@ -357,14 +292,7 @@ void SCH_SCREEN::ReplaceWires( SCH_ITEM* aWireList )
} }
} }
while( aWireList ) m_drawList.Append( aWireList );
{
next_item = aWireList->Next();
aWireList->SetNext( GetDrawItems() );
SetDrawItems( aWireList );
aWireList = next_item;
}
} }
@ -373,7 +301,7 @@ void SCH_SCREEN::MarkConnections( SCH_LINE* aSegment )
wxCHECK_RET( (aSegment != NULL) && (aSegment->Type() == SCH_LINE_T), wxCHECK_RET( (aSegment != NULL) && (aSegment->Type() == SCH_LINE_T),
wxT( "Invalid object pointer." ) ); wxT( "Invalid object pointer." ) );
for( SCH_ITEM* item = GetDrawItems(); item != NULL; item = item->Next() ) for( SCH_ITEM* item = m_drawList.begin(); item != NULL; item = item->Next() )
{ {
if( item->GetFlags() & CANDIDATE ) if( item->GetFlags() & CANDIDATE )
continue; continue;
@ -498,50 +426,50 @@ bool SCH_SCREEN::IsTerminalPoint( const wxPoint& aPosition, int aLayer )
bool SCH_SCREEN::SchematicCleanUp( EDA_DRAW_PANEL* aCanvas, wxDC* aDC ) bool SCH_SCREEN::SchematicCleanUp( EDA_DRAW_PANEL* aCanvas, wxDC* aDC )
{ {
SCH_ITEM* DrawList, * TstDrawList; SCH_ITEM* item, * testItem;
bool Modify = false; bool modified = false;
DrawList = GetDrawItems(); item = m_drawList.begin();
for( ; DrawList != NULL; DrawList = DrawList->Next() ) for( ; item != NULL; item = item->Next() )
{ {
if( DrawList->Type() == SCH_LINE_T ) if( item->Type() != SCH_LINE_T )
continue;
testItem = item->Next();
while( testItem )
{ {
TstDrawList = DrawList->Next(); if( testItem->Type() == SCH_LINE_T )
while( TstDrawList )
{ {
if( TstDrawList->Type() == SCH_LINE_T ) SCH_LINE* line = (SCH_LINE*) item;
{
SCH_LINE* line = (SCH_LINE*) DrawList;
if( line->MergeOverlap( (SCH_LINE*) TstDrawList ) ) if( line->MergeOverlap( (SCH_LINE*) testItem ) )
{ {
// Keep the current flags, because the deleted segment can be flagged. // Keep the current flags, because the deleted segment can be flagged.
DrawList->SetFlags( TstDrawList->GetFlags() ); item->SetFlags( testItem->GetFlags() );
DeleteItem( TstDrawList ); DeleteItem( testItem );
TstDrawList = GetDrawItems(); testItem = m_drawList.begin();
Modify = true; modified = true;
}
else
{
TstDrawList = TstDrawList->Next();
}
} }
else else
{ {
TstDrawList = TstDrawList->Next(); testItem = testItem->Next();
} }
} }
else
{
testItem = testItem->Next();
}
} }
} }
TestDanglingEnds( aCanvas, aDC ); TestDanglingEnds( aCanvas, aDC );
if( aCanvas && Modify ) if( aCanvas && modified )
aCanvas->Refresh(); aCanvas->Refresh();
return Modify; return modified;
} }
@ -590,7 +518,7 @@ bool SCH_SCREEN::Save( FILE* aFile ) const
|| fprintf( aFile, "$EndDescr\n" ) < 0 ) || fprintf( aFile, "$EndDescr\n" ) < 0 )
return false; return false;
for( SCH_ITEM* item = GetDrawItems(); item; item = item->Next() ) for( SCH_ITEM* item = m_drawList.begin(); item; item = item->Next() )
{ {
if( !item->Save( aFile ) ) if( !item->Save( aFile ) )
return false; return false;
@ -605,7 +533,7 @@ bool SCH_SCREEN::Save( FILE* aFile ) const
void SCH_SCREEN::Draw( EDA_DRAW_PANEL* aCanvas, wxDC* aDC, int aDrawMode, int aColor ) void SCH_SCREEN::Draw( EDA_DRAW_PANEL* aCanvas, wxDC* aDC, int aDrawMode, int aColor )
{ {
for( SCH_ITEM* item = GetDrawItems(); item != NULL; item = item->Next() ) for( SCH_ITEM* item = m_drawList.begin(); item != NULL; item = item->Next() )
{ {
if( item->IsMoving() || item->IsResized() ) if( item->IsMoving() || item->IsResized() )
continue; continue;
@ -621,7 +549,7 @@ void SCH_SCREEN::Draw( EDA_DRAW_PANEL* aCanvas, wxDC* aDC, int aDrawMode, int aC
void SCH_SCREEN::Plot( PLOTTER* aPlotter ) void SCH_SCREEN::Plot( PLOTTER* aPlotter )
{ {
for( SCH_ITEM* item = GetDrawItems(); item; item = item->Next() ) for( SCH_ITEM* item = m_drawList.begin(); item; item = item->Next() )
{ {
aPlotter->set_current_line_width( item->GetPenSize() ); aPlotter->set_current_line_width( item->GetPenSize() );
item->Plot( aPlotter ); item->Plot( aPlotter );
@ -655,7 +583,7 @@ void SCH_SCREEN::ClearUndoORRedoList( UNDO_REDO_CONTAINER& aList, int aItemCount
void SCH_SCREEN::ClearDrawingState() void SCH_SCREEN::ClearDrawingState()
{ {
for( SCH_ITEM* item = GetDrawItems(); item != NULL; item = item->Next() ) for( SCH_ITEM* item = m_drawList.begin(); item != NULL; item = item->Next() )
item->ClearFlags(); item->ClearFlags();
} }
@ -667,7 +595,7 @@ LIB_PIN* SCH_SCREEN::GetPin( const wxPoint& aPosition, SCH_COMPONENT** aComponen
SCH_COMPONENT* component = NULL; SCH_COMPONENT* component = NULL;
LIB_PIN* pin = NULL; LIB_PIN* pin = NULL;
for( item = GetDrawItems(); item != NULL; item = item->Next() ) for( item = m_drawList.begin(); item != NULL; item = item->Next() )
{ {
if( item->Type() != SCH_COMPONENT_T ) if( item->Type() != SCH_COMPONENT_T )
continue; continue;
@ -717,7 +645,7 @@ LIB_PIN* SCH_SCREEN::GetPin( const wxPoint& aPosition, SCH_COMPONENT** aComponen
SCH_SHEET* SCH_SCREEN::GetSheet( const wxString& aName ) SCH_SHEET* SCH_SCREEN::GetSheet( const wxString& aName )
{ {
for( SCH_ITEM* item = GetDrawItems(); item != NULL; item = item->Next() ) for( SCH_ITEM* item = m_drawList.begin(); item != NULL; item = item->Next() )
{ {
if( item->Type() != SCH_SHEET_T ) if( item->Type() != SCH_SHEET_T )
continue; continue;
@ -736,7 +664,7 @@ SCH_SHEET_PIN* SCH_SCREEN::GetSheetLabel( const wxPoint& aPosition )
{ {
SCH_SHEET_PIN* sheetPin = NULL; SCH_SHEET_PIN* sheetPin = NULL;
for( SCH_ITEM* item = GetDrawItems(); item != NULL; item = item->Next() ) for( SCH_ITEM* item = m_drawList.begin(); item != NULL; item = item->Next() )
{ {
if( item->Type() != SCH_SHEET_T ) if( item->Type() != SCH_SHEET_T )
continue; continue;
@ -757,7 +685,7 @@ int SCH_SCREEN::CountConnectedItems( const wxPoint& aPos, bool aTestJunctions )
SCH_ITEM* item; SCH_ITEM* item;
int count = 0; int count = 0;
for( item = GetDrawItems(); item != NULL; item = item->Next() ) for( item = m_drawList.begin(); item != NULL; item = item->Next() )
{ {
if( item->Type() == SCH_JUNCTION_T && !aTestJunctions ) if( item->Type() == SCH_JUNCTION_T && !aTestJunctions )
continue; continue;
@ -772,7 +700,7 @@ int SCH_SCREEN::CountConnectedItems( const wxPoint& aPos, bool aTestJunctions )
void SCH_SCREEN::ClearAnnotation( SCH_SHEET_PATH* aSheetPath ) void SCH_SCREEN::ClearAnnotation( SCH_SHEET_PATH* aSheetPath )
{ {
for( SCH_ITEM* item = GetDrawItems(); item != NULL; item = item->Next() ) for( SCH_ITEM* item = m_drawList.begin(); item != NULL; item = item->Next() )
{ {
if( item->Type() == SCH_COMPONENT_T ) if( item->Type() == SCH_COMPONENT_T )
{ {
@ -786,7 +714,7 @@ void SCH_SCREEN::ClearAnnotation( SCH_SHEET_PATH* aSheetPath )
void SCH_SCREEN::GetHierarchicalItems( EDA_ITEMS& aItems ) void SCH_SCREEN::GetHierarchicalItems( EDA_ITEMS& aItems )
{ {
SCH_ITEM* item = GetDrawItems(); SCH_ITEM* item = m_drawList.begin();
while( item ) while( item )
{ {
@ -869,7 +797,7 @@ void SCH_SCREEN::addConnectedItemsToBlock( const wxPoint& position )
ITEM_PICKER picker; ITEM_PICKER picker;
bool addinlist = true; bool addinlist = true;
for( item = GetDrawItems(); item != NULL; item = item->Next() ) for( item = m_drawList.begin(); item != NULL; item = item->Next() )
{ {
picker.SetItem( item ); picker.SetItem( item );
@ -915,7 +843,7 @@ int SCH_SCREEN::UpdatePickList()
area.SetSize( m_BlockLocate.GetSize() ); area.SetSize( m_BlockLocate.GetSize() );
area.Normalize(); area.Normalize();
for( SCH_ITEM* item = GetDrawItems(); item != NULL; item = item->Next() ) for( SCH_ITEM* item = m_drawList.begin(); item != NULL; item = item->Next() )
{ {
// An item is picked if its bounding box intersects the reference area. // An item is picked if its bounding box intersects the reference area.
if( item->HitTest( area ) ) if( item->HitTest( area ) )
@ -935,10 +863,10 @@ bool SCH_SCREEN::TestDanglingEnds( EDA_DRAW_PANEL* aCanvas, wxDC* aDC )
std::vector< DANGLING_END_ITEM > endPoints; std::vector< DANGLING_END_ITEM > endPoints;
bool hasDanglingEnds = false; bool hasDanglingEnds = false;
for( item = GetDrawItems(); item != NULL; item = item->Next() ) for( item = m_drawList.begin(); item != NULL; item = item->Next() )
item->GetEndPoints( endPoints ); item->GetEndPoints( endPoints );
for( item = GetDrawItems(); item; item = item->Next() ) for( item = m_drawList.begin(); item; item = item->Next() )
{ {
if( item->IsDanglingStateChanged( endPoints ) && ( aCanvas != NULL ) && ( aDC != NULL ) ) if( item->IsDanglingStateChanged( endPoints ) && ( aCanvas != NULL ) && ( aDC != NULL ) )
{ {
@ -960,7 +888,7 @@ bool SCH_SCREEN::BreakSegment( const wxPoint& aPoint )
SCH_LINE* newSegment; SCH_LINE* newSegment;
bool brokenSegments = false; bool brokenSegments = false;
for( SCH_ITEM* item = GetDrawItems(); item != NULL; item = item->Next() ) for( SCH_ITEM* item = m_drawList.begin(); item != NULL; item = item->Next() )
{ {
if( (item->Type() != SCH_LINE_T) || (item->GetLayer() == LAYER_NOTES) ) if( (item->Type() != SCH_LINE_T) || (item->GetLayer() == LAYER_NOTES) )
continue; continue;
@ -974,8 +902,7 @@ bool SCH_SCREEN::BreakSegment( const wxPoint& aPoint )
newSegment = new SCH_LINE( *segment ); newSegment = new SCH_LINE( *segment );
newSegment->SetStartPoint( aPoint ); newSegment->SetStartPoint( aPoint );
segment->SetEndPoint( aPoint ); segment->SetEndPoint( aPoint );
newSegment->SetNext( segment->Next() ); m_drawList.Insert( newSegment, segment->Next() );
segment->SetNext( newSegment );
item = newSegment; item = newSegment;
brokenSegments = true; brokenSegments = true;
} }
@ -988,7 +915,7 @@ bool SCH_SCREEN::BreakSegmentsOnJunctions()
{ {
bool brokenSegments = false; bool brokenSegments = false;
for( SCH_ITEM* item = GetDrawItems(); item != NULL; item = item->Next() ) for( SCH_ITEM* item = m_drawList.begin(); item != NULL; item = item->Next() )
{ {
if( item->Type() == SCH_JUNCTION_T ) if( item->Type() == SCH_JUNCTION_T )
{ {
@ -1013,7 +940,7 @@ bool SCH_SCREEN::BreakSegmentsOnJunctions()
int SCH_SCREEN::GetNode( const wxPoint& aPosition, EDA_ITEMS& aList ) int SCH_SCREEN::GetNode( const wxPoint& aPosition, EDA_ITEMS& aList )
{ {
for( SCH_ITEM* item = GetDrawItems(); item != NULL; item = item->Next() ) for( SCH_ITEM* item = m_drawList.begin(); item != NULL; item = item->Next() )
{ {
if( item->Type() == SCH_LINE_T && item->HitTest( aPosition ) if( item->Type() == SCH_LINE_T && item->HitTest( aPosition )
&& (item->GetLayer() == LAYER_BUS || item->GetLayer() == LAYER_WIRE) ) && (item->GetLayer() == LAYER_BUS || item->GetLayer() == LAYER_WIRE) )
@ -1032,7 +959,7 @@ int SCH_SCREEN::GetNode( const wxPoint& aPosition, EDA_ITEMS& aList )
SCH_LINE* SCH_SCREEN::GetWireOrBus( const wxPoint& aPosition ) SCH_LINE* SCH_SCREEN::GetWireOrBus( const wxPoint& aPosition )
{ {
for( SCH_ITEM* item = GetDrawItems(); item != NULL; item = item->Next() ) for( SCH_ITEM* item = m_drawList.begin(); item != NULL; item = item->Next() )
{ {
if( (item->Type() == SCH_LINE_T) && item->HitTest( aPosition ) if( (item->Type() == SCH_LINE_T) && item->HitTest( aPosition )
&& (item->GetLayer() == LAYER_BUS || item->GetLayer() == LAYER_WIRE) ) && (item->GetLayer() == LAYER_BUS || item->GetLayer() == LAYER_WIRE) )
@ -1048,7 +975,7 @@ SCH_LINE* SCH_SCREEN::GetWireOrBus( const wxPoint& aPosition )
SCH_LINE* SCH_SCREEN::GetLine( const wxPoint& aPosition, int aAccuracy, int aLayer, SCH_LINE* SCH_SCREEN::GetLine( const wxPoint& aPosition, int aAccuracy, int aLayer,
SCH_LINE_TEST_T aSearchType ) SCH_LINE_TEST_T aSearchType )
{ {
for( SCH_ITEM* item = GetDrawItems(); item != NULL; item = item->Next() ) for( SCH_ITEM* item = m_drawList.begin(); item != NULL; item = item->Next() )
{ {
if( item->Type() != SCH_LINE_T ) if( item->Type() != SCH_LINE_T )
continue; continue;
@ -1081,7 +1008,7 @@ SCH_LINE* SCH_SCREEN::GetLine( const wxPoint& aPosition, int aAccuracy, int aLay
SCH_TEXT* SCH_SCREEN::GetLabel( const wxPoint& aPosition, int aAccuracy ) SCH_TEXT* SCH_SCREEN::GetLabel( const wxPoint& aPosition, int aAccuracy )
{ {
for( SCH_ITEM* item = GetDrawItems(); item != NULL; item = item->Next() ) for( SCH_ITEM* item = m_drawList.begin(); item != NULL; item = item->Next() )
{ {
switch( item->Type() ) switch( item->Type() )
{ {
@ -1106,7 +1033,7 @@ bool SCH_SCREEN::SetComponentFootprint( SCH_SHEET_PATH* aSheetPath, const wxStri
SCH_COMPONENT* component; SCH_COMPONENT* component;
bool found = false; bool found = false;
for( SCH_ITEM* item = GetDrawItems(); item != NULL; item = item->Next() ) for( SCH_ITEM* item = m_drawList.begin(); item != NULL; item = item->Next() )
{ {
if( item->Type() != SCH_COMPONENT_T ) if( item->Type() != SCH_COMPONENT_T )
continue; continue;
@ -1179,7 +1106,7 @@ int SCH_SCREEN::GetConnection( const wxPoint& aPosition, PICKED_ITEMS_LIST& aLis
{ {
SCH_LINE* segment; SCH_LINE* segment;
for( item = GetDrawItems(); item != NULL; item = item->Next() ) for( item = m_drawList.begin(); item != NULL; item = item->Next() )
{ {
if( !(item->GetFlags() & SELECTEDNODE) ) if( !(item->GetFlags() & SELECTEDNODE) )
continue; continue;
@ -1191,7 +1118,7 @@ int SCH_SCREEN::GetConnection( const wxPoint& aPosition, PICKED_ITEMS_LIST& aLis
} }
// Search all attached wires (i.e wire with one new dangling end ) // Search all attached wires (i.e wire with one new dangling end )
for( item = GetDrawItems(); item != NULL; item = item->Next() ) for( item = m_drawList.begin(); item != NULL; item = item->Next() )
{ {
bool noconnect = false; bool noconnect = false;
@ -1210,7 +1137,7 @@ int SCH_SCREEN::GetConnection( const wxPoint& aPosition, PICKED_ITEMS_LIST& aLis
/* If the wire start point is connected to a wire that was already found /* If the wire start point is connected to a wire that was already found
* and now is not connected, add the wire to the list. */ * and now is not connected, add the wire to the list. */
for( tmp = GetDrawItems(); tmp != NULL; tmp = tmp->Next() ) for( tmp = m_drawList.begin(); tmp != NULL; tmp = tmp->Next() )
{ {
// Ensure tmp is a previously deleted segment: // Ensure tmp is a previously deleted segment:
if( ( tmp->GetFlags() & STRUCT_DELETED ) == 0 ) if( ( tmp->GetFlags() & STRUCT_DELETED ) == 0 )
@ -1234,7 +1161,7 @@ int SCH_SCREEN::GetConnection( const wxPoint& aPosition, PICKED_ITEMS_LIST& aLis
/* If the wire end point is connected to a wire that has already been found /* If the wire end point is connected to a wire that has already been found
* and now is not connected, add the wire to the list. */ * and now is not connected, add the wire to the list. */
for( tmp = GetDrawItems(); tmp != NULL; tmp = tmp->Next() ) for( tmp = m_drawList.begin(); tmp != NULL; tmp = tmp->Next() )
{ {
// Ensure tmp is a previously deleted segment: // Ensure tmp is a previously deleted segment:
if( ( tmp->GetFlags() & STRUCT_DELETED ) == 0 ) if( ( tmp->GetFlags() & STRUCT_DELETED ) == 0 )
@ -1265,13 +1192,13 @@ int SCH_SCREEN::GetConnection( const wxPoint& aPosition, PICKED_ITEMS_LIST& aLis
ITEM_PICKER picker( item, UR_DELETED ); ITEM_PICKER picker( item, UR_DELETED );
aList.PushItem( picker ); aList.PushItem( picker );
item = GetDrawItems(); item = m_drawList.begin();
} }
} }
// Get redundant junctions (junctions which connect < 3 end wires // Get redundant junctions (junctions which connect < 3 end wires
// and no pin) // and no pin)
for( item = GetDrawItems(); item != NULL; item = item->Next() ) for( item = m_drawList.begin(); item != NULL; item = item->Next() )
{ {
if( item->GetFlags() & STRUCT_DELETED ) if( item->GetFlags() & STRUCT_DELETED )
continue; continue;
@ -1293,7 +1220,7 @@ int SCH_SCREEN::GetConnection( const wxPoint& aPosition, PICKED_ITEMS_LIST& aLis
} }
} }
for( item = GetDrawItems(); item != NULL; item = item->Next() ) for( item = m_drawList.begin(); item != NULL; item = item->Next() )
{ {
if( item->GetFlags() & STRUCT_DELETED ) if( item->GetFlags() & STRUCT_DELETED )
continue; continue;
@ -1560,7 +1487,7 @@ void SCH_SCREEN::Show( int nestLevel, std::ostream& os ) const
// for now, make it look like XML, expand on this later. // for now, make it look like XML, expand on this later.
NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str() << ">\n"; NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str() << ">\n";
for( EDA_ITEM* item = m_drawList; item; item = item->Next() ) for( EDA_ITEM* item = m_drawList.begin(); item != NULL; item = item->Next() )
{ {
item->Show( nestLevel+1, os ); item->Show( nestLevel+1, os );
} }

View File

@ -2,7 +2,6 @@
* This program source code file is part of KiCad, a free EDA CAD application. * 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) 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. * Copyright (C) 1992-2011 Kicad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or

View File

@ -2,7 +2,6 @@
* This program source code file is part of KiCad, a free EDA CAD application. * 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) 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. * Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or

View File

@ -2,7 +2,6 @@
* This program source code file is part of KiCad, a free EDA CAD application. * 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) 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. * Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or

View File

@ -2,7 +2,6 @@
* This program source code file is part of KiCad, a free EDA CAD application. * 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) 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. * Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or

View File

@ -2,7 +2,6 @@
* This program source code file is part of KiCad, a free EDA CAD application. * 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) 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. * Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or

View File

@ -178,12 +178,27 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_SCH_BREAK_WIRE: case ID_POPUP_SCH_BREAK_WIRE:
{ {
DLIST< SCH_ITEM > oldWires;
oldWires.SetOwnership( false ); // Prevent DLIST for deleting items in destructor.
m_canvas->MoveCursorToCrossHair(); m_canvas->MoveCursorToCrossHair();
SCH_ITEM* oldWiresList = screen->ExtractWires( true ); screen->ExtractWires( oldWires, true );
screen->BreakSegment( screen->GetCrossHairPosition() ); screen->BreakSegment( screen->GetCrossHairPosition() );
if( oldWiresList ) if( oldWires.GetCount() != 0 )
SaveCopyInUndoList( oldWiresList, UR_WIRE_IMAGE ); {
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 ); screen->TestDanglingEnds( m_canvas, &dc );
} }

View File

@ -2,7 +2,6 @@
* This program source code file is part of KiCad, a free EDA CAD application. * 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) 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. * Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * 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, UNDO_REDO_T aCommandType,
const wxPoint& aTransformPoint ) const wxPoint& aTransformPoint )
{ {
/* Does not save a null item. /* Does not save a null item or a UR_WIRE_IMAGE command type. UR_WIRE_IMAGE commands
* but if aCommandType == UR_WIRE_IMAGE, we must save null item. * are handled by the overloaded version of SaveCopyInUndoList that takes a reference
* It happens for the first wire entered in schematic: * to a PICKED_ITEMS_LIST.
* To undo this first command, the previous state is a NULL item,
* and we accept this
*/ */
if( aItem == NULL && ( aCommandType != UR_WIRE_IMAGE ) ) if( aItem == NULL || aCommandType == UR_WIRE_IMAGE )
return; return;
PICKED_ITEMS_LIST* commandToUndo = new PICKED_ITEMS_LIST(); PICKED_ITEMS_LIST* commandToUndo = new PICKED_ITEMS_LIST();
@ -137,7 +134,6 @@ void SCH_EDIT_FRAME::SaveCopyInUndoList( SCH_ITEM* aItem,
break; break;
case UR_NEW: case UR_NEW:
case UR_WIRE_IMAGE:
case UR_DELETED: case UR_DELETED:
case UR_ROTATED: case UR_ROTATED:
case UR_MOVED: case UR_MOVED:
@ -145,13 +141,9 @@ void SCH_EDIT_FRAME::SaveCopyInUndoList( SCH_ITEM* aItem,
break; break;
default: default:
{ wxFAIL_MSG( wxString::Format( wxT( "SaveCopyInUndoList() error (unknown code %X)" ),
wxString msg; aCommandType ) );
msg.Printf( wxT( "SaveCopyInUndoList() error (unknown code %X)" ), break;
aCommandType );
wxMessageBox( msg );
}
break;
} }
if( commandToUndo->GetCount() ) if( commandToUndo->GetCount() )
@ -163,7 +155,9 @@ void SCH_EDIT_FRAME::SaveCopyInUndoList( SCH_ITEM* aItem,
GetScreen()->ClearUndoORRedoList( GetScreen()->m_RedoList ); GetScreen()->ClearUndoORRedoList( GetScreen()->m_RedoList );
} }
else else
{
delete commandToUndo; delete commandToUndo;
}
} }
@ -174,6 +168,7 @@ void SCH_EDIT_FRAME::SaveCopyInUndoList( PICKED_ITEMS_LIST& aItemsList,
PICKED_ITEMS_LIST* commandToUndo = new PICKED_ITEMS_LIST(); PICKED_ITEMS_LIST* commandToUndo = new PICKED_ITEMS_LIST();
commandToUndo->m_TransformPoint = aTransformPoint; commandToUndo->m_TransformPoint = aTransformPoint;
commandToUndo->m_Status = aTypeCommand;
// Copy picker list: // Copy picker list:
commandToUndo->CopyList( aItemsList ); commandToUndo->CopyList( aItemsList );
@ -202,6 +197,7 @@ void SCH_EDIT_FRAME::SaveCopyInUndoList( PICKED_ITEMS_LIST& aItemsList,
*/ */
if( commandToUndo->GetPickedItemLink( ii ) == NULL ) if( commandToUndo->GetPickedItemLink( ii ) == NULL )
commandToUndo->SetPickedItemLink( DuplicateStruct( item, true ), ii ); commandToUndo->SetPickedItemLink( DuplicateStruct( item, true ), ii );
wxASSERT( commandToUndo->GetPickedItemLink( ii ) ); wxASSERT( commandToUndo->GetPickedItemLink( ii ) );
break; break;
@ -212,6 +208,7 @@ void SCH_EDIT_FRAME::SaveCopyInUndoList( PICKED_ITEMS_LIST& aItemsList,
case UR_NEW: case UR_NEW:
case UR_DELETED: case UR_DELETED:
case UR_EXCHANGE_T: case UR_EXCHANGE_T:
case UR_WIRE_IMAGE:
break; break;
default: 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 */ /* Save the copy in undo list */
GetScreen()->PushCommandToUndoList( commandToUndo ); GetScreen()->PushCommandToUndoList( commandToUndo );
@ -229,7 +226,9 @@ void SCH_EDIT_FRAME::SaveCopyInUndoList( PICKED_ITEMS_LIST& aItemsList,
GetScreen()->ClearUndoORRedoList( GetScreen()->m_RedoList ); GetScreen()->ClearUndoORRedoList( GetScreen()->m_RedoList );
} }
else // Should not occur else // Should not occur
{
delete commandToUndo; delete commandToUndo;
}
} }
@ -238,9 +237,36 @@ void SCH_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bool aRed
SCH_ITEM* item; SCH_ITEM* item;
SCH_ITEM* alt_item; SCH_ITEM* alt_item;
// Undo in the reverse order of list creation: (this can allow stacked // Exchange the current wires, buses, and junctions with the copy save by the last edit.
// changes like the same item can be changes and deleted in the same if( aList->m_Status == UR_WIRE_IMAGE )
// complex command {
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-- ) for( int ii = aList->GetCount() - 1; ii >= 0; ii-- )
{ {
item = (SCH_ITEM*) aList->GetPickedItem( 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 ) ) switch( aList->GetPickedItemStatus( ii ) )
{ {
case UR_CHANGED: /* Exchange old and new data for each item */ case UR_CHANGED: /* Exchange old and new data for each item */
// tmp = item->Clone();
// *item = *image;
// *image = *tmp;
// delete tmp;
item->SwapData( image ); item->SwapData( image );
break; break;
case UR_NEW: /* new items are deleted */ case UR_NEW: /* new items are deleted */
aList->SetPickedItemStatus( UR_DELETED, ii ); aList->SetPickedItemStatus( UR_DELETED, ii );
GetScreen()->RemoveFromDrawList( item ); GetScreen()->Remove( item );
break; 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 ); aList->SetPickedItemStatus( UR_NEW, ii );
item->SetNext( GetScreen()->GetDrawItems() ); GetScreen()->Append( item );
GetScreen()->SetDrawItems( item );
break; break;
case UR_MOVED: case UR_MOVED:
@ -275,55 +304,32 @@ void SCH_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bool aRed
break; break;
case UR_MIRRORED_Y: case UR_MIRRORED_Y:
{ item->Mirror_Y( aList->m_TransformPoint.x );
wxPoint mirrorPoint = aList->m_TransformPoint; break;
item->Mirror_Y( mirrorPoint.x );
}
break;
case UR_MIRRORED_X: case UR_MIRRORED_X:
{ item->Mirror_X( aList->m_TransformPoint.y );
wxPoint mirrorPoint = aList->m_TransformPoint; break;
item->Mirror_X( mirrorPoint.y );
}
break;
case UR_ROTATED: case UR_ROTATED:
{
// To undo a rotate 90 deg transform we must rotate 270 deg to undo // To undo a rotate 90 deg transform we must rotate 270 deg to undo
// and 90 deg to redo: // and 90 deg to redo:
wxPoint RotationPoint = aList->m_TransformPoint; item->Rotate( aList->m_TransformPoint );
item->Rotate( RotationPoint );
if( aRedoCommand ) if( aRedoCommand )
break; // A only one rotate transform is OK break; // A only one rotate transform is OK
// Make 3 rotate 90 deg transforms is this is actually an undo command // Make 3 rotate 90 deg transforms is this is actually an undo command
item->Rotate( RotationPoint ); item->Rotate( aList->m_TransformPoint );
item->Rotate( RotationPoint ); item->Rotate( aList->m_TransformPoint );
}
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;
}
break; break;
case UR_EXCHANGE_T: case UR_EXCHANGE_T:
alt_item = (SCH_ITEM*) aList->GetPickedItemLink( ii ); alt_item = (SCH_ITEM*) aList->GetPickedItemLink( ii );
alt_item->SetNext( NULL ); alt_item->SetNext( NULL );
alt_item->SetBack( NULL ); alt_item->SetBack( NULL );
GetScreen()->RemoveFromDrawList( item ); GetScreen()->Remove( item );
GetScreen()->AddToDrawList( alt_item ); GetScreen()->Append( alt_item );
aList->SetPickedItem( alt_item, ii ); aList->SetPickedItem( alt_item, ii );
aList->SetPickedItemLink( item, ii ); aList->SetPickedItemLink( item, ii );
break; break;

View File

@ -2,7 +2,6 @@
* This program source code file is part of KiCad, a free EDA CAD application. * 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) 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. * Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * 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( undoItem == item )
{ {
if( !screen->CheckIfOnDrawList( item ) ) // don't want a loop! if( !screen->CheckIfOnDrawList( item ) ) // don't want a loop!
screen->AddToDrawList( item ); screen->Append( item );
SetRepeatItem( item ); SetRepeatItem( item );

View File

@ -2,7 +2,6 @@
* This program source code file is part of KiCad, a free EDA CAD application. * 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) 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. * Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * 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() ) else if( item->IsMoving() || item->IsResized() )
{ {
screen->RemoveFromDrawList( item ); screen->Remove( item );
delete item; delete item;
item = parent->GetUndoItem(); item = parent->GetUndoItem();
wxCHECK_RET( item != NULL, wxT( "Cannot restore undefined last sheet item." ) ); 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: // the owner of item is no more parent, this is the draw list of screen:
parent->SetUndoItem( NULL ); parent->SetUndoItem( NULL );

View File

@ -2,7 +2,6 @@
* This program source code file is part of KiCad, a free EDA CAD application. * 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) 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. * Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
@ -32,6 +31,7 @@
#define CLASS_SCREEN_H #define CLASS_SCREEN_H
#include <macros.h> #include <macros.h>
#include <dlist.h>
#include <sch_item_struct.h> #include <sch_item_struct.h>
#include <class_base_screen.h> #include <class_base_screen.h>
#include <class_title_block.h> #include <class_title_block.h>
@ -73,8 +73,8 @@ class SCH_SCREEN : public BASE_SCREEN
/// Position of the origin axis, which is used in exports mostly, but not yet in EESCHEMA /// Position of the origin axis, which is used in exports mostly, but not yet in EESCHEMA
wxPoint m_originAxisPosition; 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 /// @todo use DLIST<SCH_ITEM> or superior container
/** /**
* Function addConnectedItemsToBlock * Function addConnectedItemsToBlock
@ -122,8 +122,17 @@ public:
* Function GetDrawItems(). * Function GetDrawItems().
* @return - A pointer to the first item in the linked list of draw items. * @return - A pointer to the first item in the linked list of draw items.
*/ */
SCH_ITEM* GetDrawItems() const { return m_drawList; } SCH_ITEM* GetDrawItems() const { return m_drawList.begin(); }
void SetDrawItems( SCH_ITEM* aItem ) { m_drawList = aItem; }
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 * Function GetCurItem
@ -184,11 +193,13 @@ public:
void Plot( PLOTTER* aPlotter ); 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 * Function DeleteItem
@ -201,8 +212,6 @@ public:
bool CheckIfOnDrawList( SCH_ITEM* st ); bool CheckIfOnDrawList( SCH_ITEM* st );
void AddToDrawList( SCH_ITEM* st );
/** /**
* Function SchematicCleanUp * Function SchematicCleanUp
* performs routine schematic cleaning including breaking wire and buses and * performs routine schematic cleaning including breaking wire and buses and
@ -226,23 +235,24 @@ public:
/** /**
* Function ExtractWires * Function ExtractWires
* extracts the old wires, junctions and buses. If \a aCreateCopy is true, replace * 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 * extracted items with a copy of the original. Old items are to be put in undo list,
* modified by clean up safely. If an abort command is made, old wires must be put * and the new ones can be modified by clean up safely. If an abort draw segmat command
* in GetDrawItems(), and copies must be deleted. This is because previously stored * is made, the old wires must be put back into #m_drawList, and the copies must be
* undo commands can handle pointers on wires or buses, and we do not delete wires or * deleted. This is because previously stored undo commands can handle pointers on wires
* buss-es, we must put they in undo list. * 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 * Because cleanup deletes and/or modify bus and wires, it is easier is to put
* all wires in undo list and use a new copy of wires for cleanup. * 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 * Function ReplaceWires
* replaces all of the wires and junction in the screen with \a aWireList. * replaces all of the wires, buses, and junctions in the screen with \a aWireList.
* @param aWireList List of wire to replace the existing wires with. *
* @param aWireList List of wires to replace the existing wires with.
*/ */
void ReplaceWires( SCH_ITEM* aWireList ); void ReplaceWires( DLIST< SCH_ITEM >& aWireList );
/** /**
* Function MarkConnections * Function MarkConnections

View File

@ -63,22 +63,31 @@ protected:
/** /**
* Function append * Function append
* adds \a aNewElement to the end of the list. * adds \a aNewElement to the end of the list.
* @param aNewElement The element to insert.
*/ */
void append( EDA_ITEM* aNewElement ); 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 * 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(). * If \a aElementAfterMe is NULL, then simply append().
* @param aNewElement The element to insert. * @param aNewElement The element to insert.
* @param aElementAfterMe The element to insert \a aNewElement before, * @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 ); void insert( EDA_ITEM* aNewElement, EDA_ITEM* aElementAfterMe );
/** /**
* Function insert * 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 ) void insert( EDA_ITEM* aNewElement )
{ {
@ -88,6 +97,7 @@ protected:
/** /**
* Function remove * Function remove
* removes \a aElement from the list, but does not delete it. * removes \a aElement from the list, but does not delete it.
* @param aElement The element to remove.
*/ */
void remove( EDA_ITEM* aElement ); void remove( EDA_ITEM* aElement );
@ -162,16 +172,30 @@ public:
/** /**
* Function Append * Function Append
* adds \a aNewElement to the end of the list. * adds \a aNewElement to the end of the list.
* @param aNewElement The element to insert.
*/ */
void Append( T* aNewElement ) void Append( T* aNewElement )
{ {
append( 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 * 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() * 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 ) void Insert( T* aNewElement, T* aElementAfterMe )
{ {
@ -181,6 +205,7 @@ public:
/** /**
* Function Remove * Function Remove
* removes \a aElement from the list, but does not delete it. * 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. * @return T* - the removed element, so you can easily delete it upon return.
*/ */
T* Remove( T* aElement ) T* Remove( T* aElement )
@ -210,6 +235,7 @@ public:
/** /**
* Function PushFront * Function PushFront
* puts aNewElement at front of list sequence. * puts aNewElement at front of list sequence.
* @param aNewElement The element to insert at the front of the list.
*/ */
void PushFront( T* aNewElement ) void PushFront( T* aNewElement )
{ {
@ -219,6 +245,7 @@ public:
/** /**
* Function PushBack * Function PushBack
* puts aNewElement at the end of the list sequence. * 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 ) void PushBack( T* aNewElement )
{ {

View File

@ -2,7 +2,6 @@
* This program source code file is part of KiCad, a free EDA CAD application. * 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) 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. * Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * 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 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 * @note - The DoXXX() functions below are used to enforce the interface while retaining
* the ability of change the implementation behavior of derived classes. See * the ability of change the implementation behavior of derived classes. See