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

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
Loading
Loading
Loading
Loading
+21 −0
Original line number Original line Diff line number Diff line
@@ -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
+17 −0
Original line number Original line Diff line number Diff line
@@ -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() );
+8 −5
Original line number Original line Diff line number Diff line
/**
 * @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 @@
 * 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 @@
#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 )


        // 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 );
+0 −13
Original line number Original line Diff line number Diff line
@@ -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;
+3 −1
Original line number Original line Diff line number Diff line
@@ -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
Loading