Commit 409d6e8e authored by Wayne Stambaugh's avatar Wayne Stambaugh

Eeschema schematic object improvements.

* Remove unnecessary copy constructors from schematic and component
  library objects.
* Add comment to class definitions where the default copy constructor
  generated by the compiler was adequate.
* Add assignment operator to EDA_ITEM, SCH_ITEM, and all schematic
  objects where the default assignment operator generated by the
  compiler would not be adequate.
parent d000d486
...@@ -212,6 +212,27 @@ bool EDA_ITEM::operator<( const EDA_ITEM& aItem ) const ...@@ -212,6 +212,27 @@ bool EDA_ITEM::operator<( const EDA_ITEM& aItem ) const
} }
EDA_ITEM& EDA_ITEM::operator=( const EDA_ITEM& aItem )
{
wxCHECK_MSG( Type() == aItem.Type(), *this,
wxT( "Cannot assign object type " ) + aItem.GetClass() + wxT( " to type " ) +
GetClass() );
if( &aItem != this )
{
// Do not assign the linked list pointers.
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_Status = aItem.m_Status;
}
return *this;
}
#if defined(DEBUG) #if defined(DEBUG)
// A function that should have been in wxWidgets // A function that should have been in wxWidgets
......
...@@ -102,6 +102,23 @@ bool SCH_ITEM::operator < ( const SCH_ITEM& aItem ) const ...@@ -102,6 +102,23 @@ 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() );
......
/**
* @file edit_bitmap.cpp
*/
/* /*
* 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.
* *
...@@ -26,6 +22,10 @@ ...@@ -26,6 +22,10 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
/**
* @file edit_bitmap.cpp
*/
#include "fctsys.h" #include "fctsys.h"
#include "gr_basic.h" #include "gr_basic.h"
#include "macros.h" #include "macros.h"
...@@ -39,6 +39,9 @@ ...@@ -39,6 +39,9 @@
#include "sch_bitmap.h" #include "sch_bitmap.h"
#include "dialog_image_editor.h" #include "dialog_image_editor.h"
#include <algorithm>
static void abortMoveBitmap( EDA_DRAW_PANEL* aPanel, wxDC* aDC ) static void abortMoveBitmap( EDA_DRAW_PANEL* aPanel, wxDC* aDC )
{ {
SCH_SCREEN* screen = (SCH_SCREEN*) aPanel->GetScreen(); SCH_SCREEN* screen = (SCH_SCREEN*) aPanel->GetScreen();
...@@ -67,7 +70,7 @@ static void abortMoveBitmap( EDA_DRAW_PANEL* aPanel, wxDC* aDC ) ...@@ -67,7 +70,7 @@ static void abortMoveBitmap( EDA_DRAW_PANEL* aPanel, wxDC* aDC )
// Never delete existing item, because it can be referenced by an undo/redo command // Never delete existing item, because it can be referenced by an undo/redo command
// Just restore its data // Just restore its data
item->SwapData( olditem ); swap( *item, *olditem );
} }
screen->SetCurItem( item ); screen->SetCurItem( item );
......
...@@ -92,19 +92,6 @@ LIB_ARC::LIB_ARC( LIB_COMPONENT* aParent ) : LIB_ITEM( LIB_ARC_T, aParent ) ...@@ -92,19 +92,6 @@ LIB_ARC::LIB_ARC( LIB_COMPONENT* aParent ) : LIB_ITEM( LIB_ARC_T, aParent )
} }
LIB_ARC::LIB_ARC( const LIB_ARC& aArc ) : LIB_ITEM( aArc )
{
m_Radius = aArc.m_Radius;
m_t1 = aArc.m_t1;
m_t2 = aArc.m_t2;
m_Width = aArc.m_Width;
m_Fill = aArc.m_Fill;
m_Pos = aArc.m_Pos;
m_ArcStart = aArc.m_ArcStart;
m_ArcEnd = aArc.m_ArcEnd;
}
bool LIB_ARC::Save( OUTPUTFORMATTER& aFormatter ) bool LIB_ARC::Save( OUTPUTFORMATTER& aFormatter )
{ {
int x1 = m_t1; int x1 = m_t1;
......
...@@ -85,7 +85,9 @@ class LIB_ARC : public LIB_ITEM ...@@ -85,7 +85,9 @@ class LIB_ARC : public LIB_ITEM
public: public:
LIB_ARC( LIB_COMPONENT * aParent ); LIB_ARC( LIB_COMPONENT * aParent );
LIB_ARC( const LIB_ARC& aArc );
// Do not create a copy constructor. The one generated by the compiler is adequate.
~LIB_ARC() { } ~LIB_ARC() { }
virtual wxString GetClass() const virtual wxString GetClass() const
......
...@@ -53,15 +53,6 @@ LIB_BEZIER::LIB_BEZIER( LIB_COMPONENT* aParent ) : ...@@ -53,15 +53,6 @@ LIB_BEZIER::LIB_BEZIER( LIB_COMPONENT* aParent ) :
} }
LIB_BEZIER::LIB_BEZIER( const LIB_BEZIER& aBezier ) : LIB_ITEM( aBezier )
{
m_PolyPoints = aBezier.m_PolyPoints;
m_BezierPoints = aBezier.m_BezierPoints; // Vector copy
m_Width = aBezier.m_Width;
m_Fill = aBezier.m_Fill;
}
bool LIB_BEZIER::Save( OUTPUTFORMATTER& aFormatter ) bool LIB_BEZIER::Save( OUTPUTFORMATTER& aFormatter )
{ {
int ccount = GetCornerCount(); int ccount = GetCornerCount();
......
...@@ -51,7 +51,9 @@ class LIB_BEZIER : public LIB_ITEM ...@@ -51,7 +51,9 @@ class LIB_BEZIER : public LIB_ITEM
public: public:
LIB_BEZIER( LIB_COMPONENT * aParent ); LIB_BEZIER( LIB_COMPONENT * aParent );
LIB_BEZIER( const LIB_BEZIER& aBezier );
// Do not create a copy constructor. The one generated by the compiler is adequate.
~LIB_BEZIER() { } ~LIB_BEZIER() { }
virtual wxString GetClass() const virtual wxString GetClass() const
......
...@@ -54,16 +54,6 @@ LIB_CIRCLE::LIB_CIRCLE( LIB_COMPONENT* aParent ) : ...@@ -54,16 +54,6 @@ LIB_CIRCLE::LIB_CIRCLE( LIB_COMPONENT* aParent ) :
} }
LIB_CIRCLE::LIB_CIRCLE( const LIB_CIRCLE& aCircle ) :
LIB_ITEM( aCircle )
{
m_Pos = aCircle.m_Pos;
m_Radius = aCircle.m_Radius;
m_Fill = aCircle.m_Fill;
m_Width = aCircle.m_Width;
}
bool LIB_CIRCLE::Save( OUTPUTFORMATTER& aFormatter ) bool LIB_CIRCLE::Save( OUTPUTFORMATTER& aFormatter )
{ {
aFormatter.Print( 0, "C %d %d %d %d %d %d %c\n", m_Pos.x, m_Pos.y, aFormatter.Print( 0, "C %d %d %d %d %d %d %c\n", m_Pos.x, m_Pos.y,
......
...@@ -54,7 +54,9 @@ class LIB_CIRCLE : public LIB_ITEM ...@@ -54,7 +54,9 @@ class LIB_CIRCLE : public LIB_ITEM
public: public:
LIB_CIRCLE( LIB_COMPONENT * aParent ); LIB_CIRCLE( LIB_COMPONENT * aParent );
LIB_CIRCLE( const LIB_CIRCLE& aCircle );
// Do not create a copy constructor. The one generated by the compiler is adequate.
~LIB_CIRCLE() { } ~LIB_CIRCLE() { }
virtual wxString GetClass() const virtual wxString GetClass() const
......
...@@ -58,18 +58,6 @@ LIB_ITEM::LIB_ITEM( KICAD_T aType, ...@@ -58,18 +58,6 @@ LIB_ITEM::LIB_ITEM( KICAD_T aType,
} }
LIB_ITEM::LIB_ITEM( const LIB_ITEM& aItem ) :
EDA_ITEM( aItem )
{
m_Unit = aItem.m_Unit;
m_Convert = aItem.m_Convert;
m_Fill = aItem.m_Fill;
m_typeName = aItem.m_typeName;
m_isFillable = aItem.m_isFillable;
m_eraseLastDrawItem = false;
}
void LIB_ITEM::DisplayInfo( EDA_DRAW_FRAME* aFrame ) void LIB_ITEM::DisplayInfo( EDA_DRAW_FRAME* aFrame )
{ {
wxString msg; wxString msg;
...@@ -81,6 +69,7 @@ void LIB_ITEM::DisplayInfo( EDA_DRAW_FRAME* aFrame ) ...@@ -81,6 +69,7 @@ void LIB_ITEM::DisplayInfo( EDA_DRAW_FRAME* aFrame )
msg = _( "All" ); msg = _( "All" );
else else
msg.Printf( wxT( "%d" ), m_Unit ); msg.Printf( wxT( "%d" ), m_Unit );
aFrame->AppendMsgPanel( _( "Unit" ), msg, BROWN ); aFrame->AppendMsgPanel( _( "Unit" ), msg, BROWN );
if( m_Convert == 0 ) if( m_Convert == 0 )
...@@ -91,6 +80,7 @@ void LIB_ITEM::DisplayInfo( EDA_DRAW_FRAME* aFrame ) ...@@ -91,6 +80,7 @@ void LIB_ITEM::DisplayInfo( EDA_DRAW_FRAME* aFrame )
msg = _( "yes" ); msg = _( "yes" );
else else
msg = wxT( "?" ); msg = wxT( "?" );
aFrame->AppendMsgPanel( _( "Convert" ), msg, BROWN ); aFrame->AppendMsgPanel( _( "Convert" ), msg, BROWN );
} }
......
...@@ -143,7 +143,7 @@ public: ...@@ -143,7 +143,7 @@ public:
int aConvert = 0, int aConvert = 0,
FILL_T aFillType = NO_FILL ); FILL_T aFillType = NO_FILL );
LIB_ITEM( const LIB_ITEM& aItem ); // Do not create a copy constructor. The one generated by the compiler is adequate.
virtual ~LIB_ITEM() { } virtual ~LIB_ITEM() { }
......
...@@ -59,23 +59,6 @@ LIB_FIELD::LIB_FIELD( int idfield ) : LIB_ITEM( LIB_FIELD_T, NULL ) ...@@ -59,23 +59,6 @@ LIB_FIELD::LIB_FIELD( int idfield ) : LIB_ITEM( LIB_FIELD_T, NULL )
} }
LIB_FIELD::LIB_FIELD( const LIB_FIELD& field ) : LIB_ITEM( field )
{
m_id = field.m_id;
m_Pos = field.m_Pos;
m_Size = field.m_Size;
m_Thickness = field.m_Thickness;
m_Orient = field.m_Orient;
m_Attributs = field.m_Attributs;
m_Text = field.m_Text;
m_name = field.m_name;
m_HJustify = field.m_HJustify;
m_VJustify = field.m_VJustify;
m_Italic = field.m_Italic;
m_Bold = field.m_Bold;
}
LIB_FIELD::~LIB_FIELD() LIB_FIELD::~LIB_FIELD()
{ {
} }
......
...@@ -83,8 +83,11 @@ class LIB_FIELD : public LIB_ITEM, public EDA_TEXT ...@@ -83,8 +83,11 @@ class LIB_FIELD : public LIB_ITEM, public EDA_TEXT
public: public:
LIB_FIELD( int idfield = 2 ); LIB_FIELD( int idfield = 2 );
LIB_FIELD( LIB_COMPONENT * aParent, int idfield = 2 ); LIB_FIELD( LIB_COMPONENT * aParent, int idfield = 2 );
LIB_FIELD( const LIB_FIELD& field );
// Do not create a copy constructor. The one generated by the compiler is adequate.
~LIB_FIELD(); ~LIB_FIELD();
virtual wxString GetClass() const virtual wxString GetClass() const
......
...@@ -198,22 +198,6 @@ LIB_PIN::LIB_PIN( LIB_COMPONENT* aParent ) : ...@@ -198,22 +198,6 @@ LIB_PIN::LIB_PIN( LIB_COMPONENT* aParent ) :
} }
LIB_PIN::LIB_PIN( const LIB_PIN& pin ) : LIB_ITEM( pin )
{
m_position = pin.m_position;
m_length = pin.m_length;
m_orientation = pin.m_orientation;
m_shape = pin.m_shape;
m_type = pin.m_type;
m_attributes = pin.m_attributes;
m_number = pin.m_number;
m_numTextSize = pin.m_numTextSize;
m_nameTextSize = pin.m_nameTextSize;
m_width = pin.m_width;
m_name = pin.m_name;
}
void LIB_PIN::SetName( const wxString& aName ) void LIB_PIN::SetName( const wxString& aName )
{ {
wxString tmp = ( aName.IsEmpty() ) ? wxT( "~" ) : aName; wxString tmp = ( aName.IsEmpty() ) ? wxT( "~" ) : aName;
......
...@@ -125,7 +125,9 @@ class LIB_PIN : public LIB_ITEM ...@@ -125,7 +125,9 @@ class LIB_PIN : public LIB_ITEM
public: public:
LIB_PIN( LIB_COMPONENT* aParent ); LIB_PIN( LIB_COMPONENT* aParent );
LIB_PIN( const LIB_PIN& aPin );
// Do not create a copy constructor. The one generated by the compiler is adequate.
~LIB_PIN() { } ~LIB_PIN() { }
virtual wxString GetClass() const virtual wxString GetClass() const
......
...@@ -54,14 +54,6 @@ LIB_POLYLINE::LIB_POLYLINE( LIB_COMPONENT* aParent ) : ...@@ -54,14 +54,6 @@ LIB_POLYLINE::LIB_POLYLINE( LIB_COMPONENT* aParent ) :
} }
LIB_POLYLINE::LIB_POLYLINE( const LIB_POLYLINE& polyline ) :
LIB_ITEM( polyline )
{
m_PolyPoints = polyline.m_PolyPoints; // Vector copy
m_Width = polyline.m_Width;
}
bool LIB_POLYLINE::Save( OUTPUTFORMATTER& aFormatter ) bool LIB_POLYLINE::Save( OUTPUTFORMATTER& aFormatter )
{ {
int ccount = GetCornerCount(); int ccount = GetCornerCount();
......
...@@ -55,7 +55,9 @@ class LIB_POLYLINE : public LIB_ITEM ...@@ -55,7 +55,9 @@ class LIB_POLYLINE : public LIB_ITEM
public: public:
LIB_POLYLINE( LIB_COMPONENT * aParent ); LIB_POLYLINE( LIB_COMPONENT * aParent );
LIB_POLYLINE( const LIB_POLYLINE& aPolyline );
// Do not create a copy constructor. The one generated by the compiler is adequate.
~LIB_POLYLINE() { } ~LIB_POLYLINE() { }
virtual wxString GetClass() const virtual wxString GetClass() const
......
...@@ -55,16 +55,6 @@ LIB_RECTANGLE::LIB_RECTANGLE( LIB_COMPONENT* aParent ) : ...@@ -55,16 +55,6 @@ LIB_RECTANGLE::LIB_RECTANGLE( LIB_COMPONENT* aParent ) :
} }
LIB_RECTANGLE::LIB_RECTANGLE( const LIB_RECTANGLE& aRect ) :
LIB_ITEM( aRect )
{
m_Pos = aRect.m_Pos;
m_End = aRect.m_End;
m_Width = aRect.m_Width;
m_Fill = aRect.m_Fill;
}
bool LIB_RECTANGLE::Save( OUTPUTFORMATTER& aFormatter ) bool LIB_RECTANGLE::Save( OUTPUTFORMATTER& aFormatter )
{ {
aFormatter.Print( 0, "S %d %d %d %d %d %d %d %c\n", m_Pos.x, m_Pos.y, aFormatter.Print( 0, "S %d %d %d %d %d %d %d %c\n", m_Pos.x, m_Pos.y,
......
...@@ -55,10 +55,11 @@ class LIB_RECTANGLE : public LIB_ITEM ...@@ -55,10 +55,11 @@ class LIB_RECTANGLE : public LIB_ITEM
*/ */
void calcEdit( const wxPoint& aPosition ); void calcEdit( const wxPoint& aPosition );
public:
public: public:
LIB_RECTANGLE( LIB_COMPONENT * aParent ); LIB_RECTANGLE( LIB_COMPONENT * aParent );
LIB_RECTANGLE( const LIB_RECTANGLE& aRect );
// Do not create a copy constructor. The one generated by the compiler is adequate.
~LIB_RECTANGLE() { } ~LIB_RECTANGLE() { }
virtual wxString GetClass() const virtual wxString GetClass() const
......
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
#include "lib_text.h" #include "lib_text.h"
LIB_TEXT::LIB_TEXT(LIB_COMPONENT * aParent) : LIB_TEXT::LIB_TEXT( LIB_COMPONENT * aParent ) :
LIB_ITEM( LIB_TEXT_T, aParent ), LIB_ITEM( LIB_TEXT_T, aParent ),
EDA_TEXT() EDA_TEXT()
{ {
......
...@@ -62,7 +62,9 @@ class LIB_TEXT : public LIB_ITEM, public EDA_TEXT ...@@ -62,7 +62,9 @@ class LIB_TEXT : public LIB_ITEM, public EDA_TEXT
public: public:
LIB_TEXT( LIB_COMPONENT * aParent ); LIB_TEXT( LIB_COMPONENT * aParent );
LIB_TEXT( const LIB_TEXT& aText );
// Do not create a copy constructor. The one generated by the compiler is adequate.
~LIB_TEXT() { } ~LIB_TEXT() { }
virtual wxString GetClass() const virtual wxString GetClass() const
......
...@@ -67,6 +67,27 @@ SCH_BITMAP::SCH_BITMAP( const SCH_BITMAP& aSchBitmap ) : ...@@ -67,6 +67,27 @@ SCH_BITMAP::SCH_BITMAP( const SCH_BITMAP& aSchBitmap ) :
} }
SCH_ITEM& SCH_BITMAP::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 )
{
SCH_ITEM::operator=( aItem );
SCH_BITMAP* bitmap = (SCH_BITMAP*) &aItem;
delete m_Image;
m_Image = new BITMAP_BASE( *bitmap->m_Image );
m_Pos = bitmap->m_Pos;
}
return *this;
}
bool SCH_BITMAP::ReadImageFile( const wxString& aFullFilename ) bool SCH_BITMAP::ReadImageFile( const wxString& aFullFilename )
{ {
return m_Image->ReadImageFile( aFullFilename ); return m_Image->ReadImageFile( aFullFilename );
......
...@@ -53,6 +53,7 @@ public: ...@@ -53,6 +53,7 @@ public:
delete m_Image; delete m_Image;
} }
SCH_ITEM& operator=( const SCH_ITEM& aItem );
/* /*
* Accessors: * Accessors:
......
...@@ -61,15 +61,6 @@ SCH_BUS_ENTRY::SCH_BUS_ENTRY( const wxPoint& pos, int shape, int id ) : ...@@ -61,15 +61,6 @@ SCH_BUS_ENTRY::SCH_BUS_ENTRY( const wxPoint& pos, int shape, int id ) :
} }
SCH_BUS_ENTRY::SCH_BUS_ENTRY( const SCH_BUS_ENTRY& aBusEntry ) :
SCH_ITEM( aBusEntry )
{
m_pos = aBusEntry.m_pos;
m_size = aBusEntry.m_size;
m_width = aBusEntry.m_width;
}
EDA_ITEM* SCH_BUS_ENTRY::doClone() const EDA_ITEM* SCH_BUS_ENTRY::doClone() const
{ {
return new SCH_BUS_ENTRY( *this ); return new SCH_BUS_ENTRY( *this );
......
...@@ -53,7 +53,7 @@ class SCH_BUS_ENTRY : public SCH_ITEM ...@@ -53,7 +53,7 @@ class SCH_BUS_ENTRY : public SCH_ITEM
public: public:
SCH_BUS_ENTRY( const wxPoint& pos = wxPoint( 0, 0 ), int shape = '\\', int id = WIRE_TO_BUS ); SCH_BUS_ENTRY( const wxPoint& pos = wxPoint( 0, 0 ), int shape = '\\', int id = WIRE_TO_BUS );
SCH_BUS_ENTRY( const SCH_BUS_ENTRY& aBusEntry ); // Do not create a copy constructor. The one generated by the compiler is adequate.
~SCH_BUS_ENTRY() { } ~SCH_BUS_ENTRY() { }
......
...@@ -1780,6 +1780,37 @@ bool SCH_COMPONENT::operator <( const SCH_ITEM& aItem ) const ...@@ -1780,6 +1780,37 @@ bool SCH_COMPONENT::operator <( const SCH_ITEM& aItem ) const
} }
SCH_ITEM& SCH_COMPONENT::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 )
{
SCH_ITEM::operator=( aItem );
SCH_COMPONENT* component = (SCH_COMPONENT*) &aItem;
m_ChipName = component->m_ChipName;
m_Pos = component->m_Pos;
m_unit = component->m_unit;
m_convert = component->m_convert;
m_transform = component->m_transform;
m_PathsAndReferences = component->m_PathsAndReferences;
m_Fields = component->m_Fields; // std::vector's assignment operator.
// Reparent fields after assignment to new component.
for( int ii = 0; ii < GetFieldCount(); ++ii )
{
GetField( ii )->SetParent( this );
}
}
return *this;
}
bool SCH_COMPONENT::doHitTest( const wxPoint& aPoint, int aAccuracy ) const bool SCH_COMPONENT::doHitTest( const wxPoint& aPoint, int aAccuracy ) const
{ {
EDA_RECT bBox = GetBodyBoundingBox(); EDA_RECT bBox = GetBodyBoundingBox();
......
...@@ -401,6 +401,8 @@ public: ...@@ -401,6 +401,8 @@ public:
virtual bool operator <( const SCH_ITEM& aItem ) const; virtual bool operator <( const SCH_ITEM& aItem ) const;
SCH_ITEM& operator=( const SCH_ITEM& aItem );
/** /**
* @copydoc EDA_ITEM::IsReplaceable() * @copydoc EDA_ITEM::IsReplaceable()
*/ */
......
...@@ -80,15 +80,6 @@ SCH_FIELD::SCH_FIELD( const wxPoint& aPos, int aFieldId, SCH_COMPONENT* aParent, ...@@ -80,15 +80,6 @@ SCH_FIELD::SCH_FIELD( const wxPoint& aPos, int aFieldId, SCH_COMPONENT* aParent,
} }
SCH_FIELD::SCH_FIELD( const SCH_FIELD& aField ) :
SCH_ITEM( aField ),
EDA_TEXT( aField )
{
m_id = aField.m_id;
m_name = aField.m_name;
}
SCH_FIELD::~SCH_FIELD() SCH_FIELD::~SCH_FIELD()
{ {
} }
......
...@@ -50,7 +50,7 @@ class LIB_FIELD; ...@@ -50,7 +50,7 @@ class LIB_FIELD;
* <li>Field 1 is reserved for the component value.</li> * <li>Field 1 is reserved for the component value.</li>
* <li>Field 2 is reserved for the component footprint.</li> * <li>Field 2 is reserved for the component footprint.</li>
* <li>Field 3 is reserved for the component data sheet file.</li> * <li>Field 3 is reserved for the component data sheet file.</li>
* <li>Fields 4 and higher are user defineable.</li></ul> * <li>Field 4 and higher are user defineable.</li></ul>
*/ */
class SCH_FIELD : public SCH_ITEM, public EDA_TEXT class SCH_FIELD : public SCH_ITEM, public EDA_TEXT
...@@ -63,7 +63,7 @@ public: ...@@ -63,7 +63,7 @@ public:
SCH_FIELD( const wxPoint& aPos, int aFieldId, SCH_COMPONENT* aParent, SCH_FIELD( const wxPoint& aPos, int aFieldId, SCH_COMPONENT* aParent,
wxString aName = wxEmptyString ); wxString aName = wxEmptyString );
SCH_FIELD( const SCH_FIELD& aField ); // Do not create a copy constructor. The one generated by the compiler is adequate.
~SCH_FIELD(); ~SCH_FIELD();
......
...@@ -53,14 +53,6 @@ SCH_JUNCTION::SCH_JUNCTION( const wxPoint& pos ) : ...@@ -53,14 +53,6 @@ SCH_JUNCTION::SCH_JUNCTION( const wxPoint& pos ) :
} }
SCH_JUNCTION::SCH_JUNCTION( const SCH_JUNCTION& aJunction ) :
SCH_ITEM( aJunction )
{
m_pos = aJunction.m_pos;
m_size = aJunction.m_size;
}
bool SCH_JUNCTION::Save( FILE* aFile ) const bool SCH_JUNCTION::Save( FILE* aFile ) const
{ {
bool success = true; bool success = true;
......
...@@ -42,7 +42,7 @@ class SCH_JUNCTION : public SCH_ITEM ...@@ -42,7 +42,7 @@ class SCH_JUNCTION : public SCH_ITEM
public: public:
SCH_JUNCTION( const wxPoint& pos = wxPoint( 0, 0 ) ); SCH_JUNCTION( const wxPoint& pos = wxPoint( 0, 0 ) );
SCH_JUNCTION( const SCH_JUNCTION& aJunction ); // Do not create a copy constructor. The one generated by the compiler is adequate.
~SCH_JUNCTION() { } ~SCH_JUNCTION() { }
......
...@@ -49,7 +49,9 @@ class SCH_LINE : public SCH_ITEM ...@@ -49,7 +49,9 @@ class SCH_LINE : public SCH_ITEM
public: public:
SCH_LINE( const wxPoint& pos = wxPoint( 0, 0 ), int layer = LAYER_NOTES ); SCH_LINE( const wxPoint& pos = wxPoint( 0, 0 ), int layer = LAYER_NOTES );
SCH_LINE( const SCH_LINE& aLine ); SCH_LINE( const SCH_LINE& aLine );
~SCH_LINE() { } ~SCH_LINE() { }
SCH_LINE* Next() const { return (SCH_LINE*) Pnext; } SCH_LINE* Next() const { return (SCH_LINE*) Pnext; }
......
...@@ -43,13 +43,6 @@ SCH_MARKER::SCH_MARKER( const wxPoint& pos, const wxString& text ) : ...@@ -43,13 +43,6 @@ SCH_MARKER::SCH_MARKER( const wxPoint& pos, const wxString& text ) :
} }
SCH_MARKER::SCH_MARKER( const SCH_MARKER& aMarker ) :
SCH_ITEM( aMarker ),
MARKER_BASE( aMarker )
{
}
SCH_MARKER::~SCH_MARKER() SCH_MARKER::~SCH_MARKER()
{ {
} }
......
...@@ -55,8 +55,11 @@ class SCH_MARKER : public SCH_ITEM, public MARKER_BASE ...@@ -55,8 +55,11 @@ class SCH_MARKER : public SCH_ITEM, public MARKER_BASE
{ {
public: public:
SCH_MARKER(); SCH_MARKER();
SCH_MARKER( const wxPoint& aPos, const wxString& aText ); SCH_MARKER( const wxPoint& aPos, const wxString& aText );
SCH_MARKER( const SCH_MARKER& aMarker );
// Do not create a copy constructor. The one generated by the compiler is adequate.
~SCH_MARKER(); ~SCH_MARKER();
virtual wxString GetClass() const virtual wxString GetClass() const
......
...@@ -55,14 +55,6 @@ SCH_NO_CONNECT::SCH_NO_CONNECT( const wxPoint& pos ) : ...@@ -55,14 +55,6 @@ SCH_NO_CONNECT::SCH_NO_CONNECT( const wxPoint& pos ) :
} }
SCH_NO_CONNECT::SCH_NO_CONNECT( const SCH_NO_CONNECT& aNoConnect ) :
SCH_ITEM( aNoConnect )
{
m_pos = aNoConnect.m_pos;
m_size = aNoConnect.m_size;
}
EDA_ITEM* SCH_NO_CONNECT::doClone() const EDA_ITEM* SCH_NO_CONNECT::doClone() const
{ {
return new SCH_NO_CONNECT( *this ); return new SCH_NO_CONNECT( *this );
......
...@@ -42,7 +42,7 @@ class SCH_NO_CONNECT : public SCH_ITEM ...@@ -42,7 +42,7 @@ class SCH_NO_CONNECT : public SCH_ITEM
public: public:
SCH_NO_CONNECT( const wxPoint& pos = wxPoint( 0, 0 ) ); SCH_NO_CONNECT( const wxPoint& pos = wxPoint( 0, 0 ) );
SCH_NO_CONNECT( const SCH_NO_CONNECT& aNoConnect ); // Do not create a copy constructor. The one generated by the compiler is adequate.
~SCH_NO_CONNECT() { } ~SCH_NO_CONNECT() { }
......
...@@ -60,14 +60,6 @@ SCH_POLYLINE::SCH_POLYLINE( int layer ) : ...@@ -60,14 +60,6 @@ SCH_POLYLINE::SCH_POLYLINE( int layer ) :
} }
SCH_POLYLINE::SCH_POLYLINE( const SCH_POLYLINE& aPolyLine ) :
SCH_ITEM( aPolyLine )
{
m_width = aPolyLine.m_width;
m_points = aPolyLine.m_points;
}
SCH_POLYLINE::~SCH_POLYLINE() SCH_POLYLINE::~SCH_POLYLINE()
{ {
} }
......
...@@ -43,7 +43,7 @@ class SCH_POLYLINE : public SCH_ITEM ...@@ -43,7 +43,7 @@ class SCH_POLYLINE : public SCH_ITEM
public: public:
SCH_POLYLINE( int layer = LAYER_NOTES ); SCH_POLYLINE( int layer = LAYER_NOTES );
SCH_POLYLINE( const SCH_POLYLINE& aPolyLine ); // Do not create a copy constructor. The one generated by the compiler is adequate.
~SCH_POLYLINE(); ~SCH_POLYLINE();
......
...@@ -1181,6 +1181,39 @@ void SCH_SHEET::doPlot( PLOTTER* aPlotter ) ...@@ -1181,6 +1181,39 @@ void SCH_SHEET::doPlot( PLOTTER* aPlotter )
} }
SCH_ITEM& SCH_SHEET::operator=( const SCH_ITEM& aItem )
{
wxLogDebug( wxT( "Sheet assignment operator." ) );
wxCHECK_MSG( Type() == aItem.Type(), *this,
wxT( "Cannot assign object type " ) + aItem.GetClass() + wxT( " to type " ) +
GetClass() );
if( &aItem != this )
{
SCH_ITEM::operator=( aItem );
SCH_SHEET* sheet = (SCH_SHEET*) &aItem;
m_pos = sheet->m_pos;
m_size = sheet->m_size;
m_name = sheet->m_name;
m_sheetNameSize = sheet->m_sheetNameSize;
m_fileNameSize = sheet->m_fileNameSize;
m_pins = sheet->m_pins;
// Ensure sheet labels have their #m_Parent member pointing really on their
// parent, after assigning.
BOOST_FOREACH( SCH_SHEET_PIN& sheetPin, m_pins )
{
sheetPin.SetParent( this );
}
}
return *this;
}
#if defined(DEBUG) #if defined(DEBUG)
void SCH_SHEET::Show( int nestLevel, std::ostream& os ) const void SCH_SHEET::Show( int nestLevel, std::ostream& os ) const
......
...@@ -88,7 +88,7 @@ public: ...@@ -88,7 +88,7 @@ public:
const wxPoint& pos = wxPoint( 0, 0 ), const wxPoint& pos = wxPoint( 0, 0 ),
const wxString& text = wxEmptyString ); const wxString& text = wxEmptyString );
SCH_SHEET_PIN( const SCH_SHEET_PIN& aSheetLabel ); // Do not create a copy constructor. The one generated by the compiler is adequate.
~SCH_SHEET_PIN() { } ~SCH_SHEET_PIN() { }
...@@ -273,6 +273,11 @@ class SCH_SHEET : public SCH_ITEM ...@@ -273,6 +273,11 @@ class SCH_SHEET : public SCH_ITEM
public: public:
SCH_SHEET( const wxPoint& pos = wxPoint( 0, 0 ) ); SCH_SHEET( const wxPoint& pos = wxPoint( 0, 0 ) );
/**
* Copy Constructor
* clones \a aSheet into a new object. All sheet pins are copied as is except and
* the SCH_SHEET_PIN's #m_Parent pointers are set to the new copied parent object.
*/
SCH_SHEET( const SCH_SHEET& aSheet ); SCH_SHEET( const SCH_SHEET& aSheet );
~SCH_SHEET(); ~SCH_SHEET();
...@@ -625,6 +630,8 @@ public: ...@@ -625,6 +630,8 @@ public:
virtual void GetNetListItem( vector<NETLIST_OBJECT*>& aNetListItems, virtual void GetNetListItem( vector<NETLIST_OBJECT*>& aNetListItems,
SCH_SHEET_PATH* aSheetPath ); SCH_SHEET_PATH* aSheetPath );
SCH_ITEM& operator=( const SCH_ITEM& aSheet );
#if defined(DEBUG) #if defined(DEBUG)
void Show( int nestLevel, std::ostream& os ) const; // override void Show( int nestLevel, std::ostream& os ) const; // override
#endif #endif
......
...@@ -62,14 +62,6 @@ SCH_SHEET_PIN::SCH_SHEET_PIN( SCH_SHEET* parent, const wxPoint& pos, const wxStr ...@@ -62,14 +62,6 @@ SCH_SHEET_PIN::SCH_SHEET_PIN( SCH_SHEET* parent, const wxPoint& pos, const wxStr
} }
SCH_SHEET_PIN::SCH_SHEET_PIN( const SCH_SHEET_PIN& aSheetLabel ) :
SCH_HIERLABEL( aSheetLabel )
{
m_number = aSheetLabel.m_number;
m_edge = aSheetLabel.m_edge;
}
EDA_ITEM* SCH_SHEET_PIN::doClone() const EDA_ITEM* SCH_SHEET_PIN::doClone() const
{ {
return new SCH_SHEET_PIN( *this ); return new SCH_SHEET_PIN( *this );
......
...@@ -759,12 +759,6 @@ SCH_LABEL::SCH_LABEL( const wxPoint& pos, const wxString& text ) : ...@@ -759,12 +759,6 @@ SCH_LABEL::SCH_LABEL( const wxPoint& pos, const wxString& text ) :
} }
SCH_LABEL::SCH_LABEL( const SCH_LABEL& aLabel ) :
SCH_TEXT( aLabel )
{
}
EDA_ITEM* SCH_LABEL::doClone() const EDA_ITEM* SCH_LABEL::doClone() const
{ {
return new SCH_LABEL( *this ); return new SCH_LABEL( *this );
...@@ -967,12 +961,6 @@ SCH_GLOBALLABEL::SCH_GLOBALLABEL( const wxPoint& pos, const wxString& text ) : ...@@ -967,12 +961,6 @@ SCH_GLOBALLABEL::SCH_GLOBALLABEL( const wxPoint& pos, const wxString& text ) :
} }
SCH_GLOBALLABEL::SCH_GLOBALLABEL( const SCH_GLOBALLABEL& aGlobalLabel ) :
SCH_TEXT( aGlobalLabel )
{
}
EDA_ITEM* SCH_GLOBALLABEL::doClone() const EDA_ITEM* SCH_GLOBALLABEL::doClone() const
{ {
return new SCH_GLOBALLABEL( *this ); return new SCH_GLOBALLABEL( *this );
...@@ -1402,12 +1390,6 @@ SCH_HIERLABEL::SCH_HIERLABEL( const wxPoint& pos, const wxString& text, KICAD_T ...@@ -1402,12 +1390,6 @@ SCH_HIERLABEL::SCH_HIERLABEL( const wxPoint& pos, const wxString& text, KICAD_T
} }
SCH_HIERLABEL::SCH_HIERLABEL( const SCH_HIERLABEL& aHierLabel ) :
SCH_TEXT( aHierLabel )
{
}
EDA_ITEM* SCH_HIERLABEL::doClone() const EDA_ITEM* SCH_HIERLABEL::doClone() const
{ {
return new SCH_HIERLABEL( *this ); return new SCH_HIERLABEL( *this );
......
...@@ -79,6 +79,13 @@ public: ...@@ -79,6 +79,13 @@ public:
const wxString& text = wxEmptyString, const wxString& text = wxEmptyString,
KICAD_T aType = SCH_TEXT_T ); KICAD_T aType = SCH_TEXT_T );
/**
* Copy Constructor
* clones \a aText into a new object. All members are copied as is except
* for the #m_isDangling member which is set to false. This prevents newly
* copied objects derived from #SCH_TEXT from having their connection state
* improperly set.
*/
SCH_TEXT( const SCH_TEXT& aText ); SCH_TEXT( const SCH_TEXT& aText );
~SCH_TEXT() { } ~SCH_TEXT() { }
...@@ -257,7 +264,7 @@ class SCH_LABEL : public SCH_TEXT ...@@ -257,7 +264,7 @@ class SCH_LABEL : public SCH_TEXT
public: public:
SCH_LABEL( const wxPoint& pos = wxPoint( 0, 0 ), const wxString& text = wxEmptyString ); SCH_LABEL( const wxPoint& pos = wxPoint( 0, 0 ), const wxString& text = wxEmptyString );
SCH_LABEL( const SCH_LABEL& aLabel ); // Do not create a copy constructor. The one generated by the compiler is adequate.
~SCH_LABEL() { } ~SCH_LABEL() { }
...@@ -352,7 +359,7 @@ class SCH_GLOBALLABEL : public SCH_TEXT ...@@ -352,7 +359,7 @@ class SCH_GLOBALLABEL : public SCH_TEXT
public: public:
SCH_GLOBALLABEL( const wxPoint& pos = wxPoint( 0, 0 ), const wxString& text = wxEmptyString ); SCH_GLOBALLABEL( const wxPoint& pos = wxPoint( 0, 0 ), const wxString& text = wxEmptyString );
SCH_GLOBALLABEL( const SCH_GLOBALLABEL& aGlobalLabel ); // Do not create a copy constructor. The one generated by the compiler is adequate.
~SCH_GLOBALLABEL() { } ~SCH_GLOBALLABEL() { }
...@@ -458,7 +465,7 @@ public: ...@@ -458,7 +465,7 @@ public:
const wxString& text = wxEmptyString, const wxString& text = wxEmptyString,
KICAD_T aType = SCH_HIERARCHICAL_LABEL_T ); KICAD_T aType = SCH_HIERARCHICAL_LABEL_T );
SCH_HIERLABEL( const SCH_HIERLABEL& aHierLabel ); // Do not create a copy constructor. The one generated by the compiler is adequate.
~SCH_HIERLABEL() { } ~SCH_HIERLABEL() { }
......
...@@ -698,6 +698,15 @@ public: ...@@ -698,6 +698,15 @@ public:
*/ */
static bool Sort( const EDA_ITEM* aLeft, const EDA_ITEM* aRight ) { return *aLeft < *aRight; } static bool Sort( const EDA_ITEM* aLeft, const EDA_ITEM* aRight ) { return *aLeft < *aRight; }
/**
* Operator assignment
* is used to assign the members of \a aItem to another object.
*
* @warning This is still a work in progress and not ready for prime time. Do not use
* as there is a known issue with wxString buffers.
*/
virtual EDA_ITEM& operator=( const EDA_ITEM& aItem );
#if defined(DEBUG) #if defined(DEBUG)
/** /**
......
...@@ -141,7 +141,7 @@ public: ...@@ -141,7 +141,7 @@ public:
SCH_ITEM* Clone() const { return ( SCH_ITEM* ) EDA_ITEM::Clone(); } SCH_ITEM* Clone() const { return ( SCH_ITEM* ) EDA_ITEM::Clone(); }
/** /**
* Function SwapDate * Function SwapData
* swap the internal data structures \a aItem with the schematic item. * swap the internal data structures \a aItem with the schematic item.
* Obviously, aItem must have the same type than me * Obviously, aItem must have the same type than me
* @param aItem The item to swap the data structures with. * @param aItem The item to swap the data structures with.
...@@ -352,6 +352,8 @@ public: ...@@ -352,6 +352,8 @@ 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
......
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