Commit b98538ec authored by Wayne Stambaugh's avatar Wayne Stambaugh
Browse files

Add copy constructors and cloning to schematic objects and other minor fixes.

parent c699c726
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -4,6 +4,20 @@ KiCad ChangeLog 2010
Please add newer entries at the top, list the date and your name with
email address.

2010-dec-21 UPDATE Wayne Stambaugh <stambaughw@verizon.net>
================================================================================
++all
  * Doxygen comment warning fixes.
  * Coding policy fixes.
++common
  * Add clone method to EDA_ITEM object.
++EESchema
  * Replace GenCopy() method with Clone() in all items derived from SCH_ITEM.
  * Simplify repeat last schematic item with new Clone() method.
  * Simplify duplicate schematic item method with new Clone() method.
  * Separate objects in sch_items.h/cpp into separate files per object.


2010-dec-20, UPDATE Jean-Pierre Charras <jean-pierre.charras@gipsa-lab.inpg.fr>
================================================================================
common:
+47 −119
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@ EDA_ITEM::EDA_ITEM( KICAD_T idType )

EDA_ITEM::EDA_ITEM( const EDA_ITEM& base )
{
    InitVars();
    m_StructType = base.m_StructType;
    m_Parent     = base.m_Parent;
    m_Son        = base.m_Son;
@@ -73,6 +74,13 @@ void EDA_ITEM::SetModified()
}


EDA_ITEM* EDA_ITEM::doClone() const
{
    wxCHECK_MSG( false, NULL, wxT( "doClone not implemented in derived class " ) + GetClass() +
                 wxT( ".  Bad programmer." ) );
}


// see base_struct.h
SEARCH_RESULT EDA_ITEM::IterateForward( EDA_ITEM*     listStart,
                                        INSPECTOR*    inspector,
@@ -117,9 +125,9 @@ SEARCH_RESULT EDA_ITEM::Visit( INSPECTOR* inspector, const void* testData,
    return SEARCH_CONTINUE;
}


#if defined(DEBUG)


// A function that should have been in wxWidgets
std::ostream& operator<<( std::ostream& out, const wxSize& size )
{
@@ -136,13 +144,6 @@ std::ostream& operator<<( std::ostream& out, const wxPoint& pt )
}


/**
 * Function Show
 * is used to output the object tree, currently for debugging only.
 * @param nestLevel An aid to prettier tree indenting, and is the level
 *          of nesting of this object within the overall tree.
 * @param os The ostream& to output to.
 */
void EDA_ITEM::Show( int nestLevel, std::ostream& os ) const
{
    // XML output:
@@ -154,13 +155,6 @@ void EDA_ITEM::Show( int nestLevel, std::ostream& os ) const
}


/**
 * Function NestedSpace
 * outputs nested space for pretty indenting.
 * @param nestLevel The nest count
 * @param os The ostream&, where to output
 * @return std::ostream& - for continuation.
 **/
std::ostream& EDA_ITEM::NestedSpace( int nestLevel, std::ostream& os )
{
    for( int i = 0; i<nestLevel; ++i )
@@ -180,31 +174,42 @@ std::ostream& EDA_ITEM::NestedSpace( int nestLevel, std::ostream& os )
/**************************************************/
EDA_TextStruct::EDA_TextStruct( const wxString& text )
{
    m_Size.x    = m_Size.y = DEFAULT_SIZE_TEXT;     /* XY size of font */
    m_Orient    = 0;                                /* Orient in 0.1 degrees */
    m_Size.x    = m_Size.y = DEFAULT_SIZE_TEXT;  // Width and height of font.
    m_Orient    = 0;                             // Rotation angle in 0.1 degrees.
    m_Attributs = 0;
    m_Mirror    = false;                         // display mirror if true
    m_HJustify  = GR_TEXT_HJUSTIFY_CENTER;
    m_VJustify  = GR_TEXT_VJUSTIFY_CENTER;          /* Justifications Horiz et Vert du texte */
    m_Thickness     = 0;                                /* thickness */
    m_Italic    = false;                            /* true = italic shape */
    m_HJustify  = GR_TEXT_HJUSTIFY_CENTER;       // Defualt horizontal justification is centered.
    m_VJustify  = GR_TEXT_VJUSTIFY_CENTER;       // Defualt vertical justification is centered.
    m_Thickness     = 0;                         // thickness
    m_Italic    = false;                         // true = italic shape.
    m_Bold      = false;
    m_MultilineAllowed = false;                     // Set to true only for texts that can use multiline.
    m_MultilineAllowed = false;                  // Set to true for multiline text.
    m_Text = text;
}


EDA_TextStruct::EDA_TextStruct( const EDA_TextStruct& aText )
{
    m_Pos = aText.m_Pos;
    m_Size = aText.m_Size;
    m_Orient = aText.m_Orient;
    m_Attributs = aText.m_Attributs;
    m_Mirror = aText.m_Mirror;
    m_HJustify = aText.m_HJustify;
    m_VJustify = aText.m_VJustify;
    m_Thickness = aText.m_Thickness;
    m_Italic = aText.m_Italic;
    m_Bold = aText.m_Bold;
    m_MultilineAllowed = aText.m_MultilineAllowed;
    m_Text = aText.m_Text;
}


EDA_TextStruct::~EDA_TextStruct()
{
}


/**
 * Function LenSize
 * @return the text lenght in internal units
 * @param aLine : the line of text to consider.
 * For single line text, this parameter is always m_Text
 */
int EDA_TextStruct::LenSize( const wxString& aLine ) const
{
    return ReturnGraphicTextWidth(aLine, m_Size.x, m_Italic, m_Bold ) + m_Thickness;
@@ -332,25 +337,9 @@ bool EDA_TextStruct::TextHitTest( const EDA_Rect& aRect, bool aContains, int aAc
}


/***************************************************************/
void EDA_TextStruct::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC,
                           const wxPoint& aOffset, EDA_Colors aColor,
                           int aDrawMode,
void EDA_TextStruct::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, const wxPoint& aOffset,
                           EDA_Colors aColor, int aDrawMode,
                           GRTraceMode aFillMode, EDA_Colors aAnchor_color )
/***************************************************************/

/**
 * Function Draw
 * Draws this, that can be a multiline text
 *  @param aPanel = the current DrawPanel
 *  @param aDC = the current Device Context
 *  @param aOffset = draw offset (usually (0,0))
 *  @param EDA_Colors aColor = text color
 *  @param aDrawMode = GR_OR, GR_XOR.., -1 to use the current mode.
 *  @param aFillMode = FILAIRE, FILLED or SKETCH
 *  @param EDA_Colors aAnchor_color = anchor color ( UNSPECIFIED_COLOR = do not draw anchor ).
 */

{
    if( m_MultilineAllowed )
    {
@@ -361,6 +350,7 @@ void EDA_TextStruct::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC,
        offset.y = GetInterline();

        RotatePoint( &offset, m_Orient );

        for( unsigned i = 0; i<list->Count(); i++ )
        {
            wxString txt = list->Item( i );
@@ -391,24 +381,10 @@ void EDA_TextStruct::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC,
}


/**
 * Function DrawOneLineOfText
 * Draw a single text line.
 * Used to draw each line of this EDA_TextStruct, that can be multiline
 *  @param aPanel = the current DrawPanel
 *  @param aDC = the current Device Context
 *  @param aOffset = draw offset (usually (0,0))
 *  @param EDA_Colors aColor = text color
 *  @param aDrawMode = GR_OR, GR_XOR.., -1 to use the current mode.
 *  @param aFillMode = FILAIRE, FILLED or SKETCH
 *  @param EDA_Colors aAnchor_color = anchor color ( UNSPECIFIED_COLOR = do not draw anchor ).
 *  @param EDA_Colors aText = the single line of text to draw.
 *  @param EDA_Colors aPos = the position of this line ).
 */
void EDA_TextStruct::DrawOneLineOfText( WinEDA_DrawPanel* aPanel, wxDC* aDC,
                                        const wxPoint& aOffset, EDA_Colors aColor,
                                        int aDrawMode,
                                        GRTraceMode aFillMode, EDA_Colors aAnchor_color,
                                        int aDrawMode, GRTraceMode aFillMode,
                                        EDA_Colors aAnchor_color,
                                        wxString& aText, wxPoint aPos )
{
    int width = m_Thickness;
@@ -449,23 +425,20 @@ void EDA_TextStruct::DrawOneLineOfText( WinEDA_DrawPanel* aPanel, wxDC* aDC,
    if( m_Mirror )
        size.x = -size.x;

    DrawGraphicText( aPanel, aDC,
                     aOffset + aPos, aColor, aText,
                     m_Orient, size,
    DrawGraphicText( aPanel, aDC, aOffset + aPos, aColor, aText, m_Orient, size,
                     m_HJustify, m_VJustify, width, m_Italic, m_Bold );
}

/**
 * Function GetStyleName
 * @return a wwString withe the style name( Normal, Italic, Bold, Bold+Italic)
 */
wxString EDA_TextStruct::GetTextStyleName()
{
    int style = 0;

    if( m_Italic )
        style = 1;

    if( m_Bold )
        style += 2;

    wxString stylemsg[4] = {
        _("Normal"),
        _("Italic"),
@@ -481,17 +454,14 @@ wxString EDA_TextStruct::GetTextStyleName()
/* Class EDA_Rect */
/******************/

/******************************/
void EDA_Rect::Normalize()
/******************************/

// Ensure the height ant width are >= 0
{
    if( m_Size.y < 0 )
    {
        m_Size.y = -m_Size.y;
        m_Pos.y -= m_Size.y;
    }

    if( m_Size.x < 0 )
    {
        m_Size.x = -m_Size.x;
@@ -500,21 +470,12 @@ void EDA_Rect::Normalize()
}



/**
 * Function Move
 * Move this rectangle by the aMoveVector value (this is a relative move)
 * @param aMoveVector = a wxPoint that is the value to move this rectangle
 */
void EDA_Rect::Move( const wxPoint& aMoveVector )
{
    m_Pos += aMoveVector;
}


/* Return TRUE if point is in Rect
 *  Accept rect size < 0
 */
bool EDA_Rect::Contains( const wxPoint& aPoint ) const
{
    wxPoint rel_pos = aPoint - m_Pos;
@@ -576,35 +537,14 @@ bool EDA_Rect::Intersects( const EDA_Rect& aRect ) const
}


/**************************************************/
EDA_Rect& EDA_Rect::Inflate( int aDelta )
/**************************************************/

/**
 * Function Inflate
 * Inflate "this": move each horizontal edgeand each vertical edge by aDelta
 * toward rect outside
 * if aDelta is negative, move toward rect inside (deflate)
 * Works for positive and negative rect size
 *
 */
{
    Inflate( aDelta, aDelta );
    return *this;
}

/**************************************************/
EDA_Rect& EDA_Rect::Inflate( wxCoord dx, wxCoord dy )
/**************************************************/

/**
 * Function Inflate
 * Inflate "this": move each horizontal edge by dx and each vertical edge by dy
 * toward rect outside
 * if dx and/or dy is negative, move toward rect inside (deflate)
 * Works for positive and negative rect size
 *
 */
EDA_Rect& EDA_Rect::Inflate( wxCoord dx, wxCoord dy )
{
    if( m_Size.x >= 0 )
    {
@@ -637,7 +577,6 @@ EDA_Rect& EDA_Rect::Inflate( wxCoord dx, wxCoord dy )
        }
    }


    if( m_Size.y >= 0 )
    {
        if( m_Size.y < -2 * dy )
@@ -673,12 +612,6 @@ EDA_Rect& EDA_Rect::Inflate( wxCoord dx, wxCoord dy )
}


/**
 * Function Merge
 * modifies Position and Size of this in order to contain the given rect
 * mainly used to calculate bounding boxes
 * @param aRect = given rect to merge with this
 */
void EDA_Rect::Merge( const EDA_Rect& aRect )
{
    Normalize();        // ensure width and height >= 0
@@ -695,12 +628,7 @@ void EDA_Rect::Merge( const EDA_Rect& aRect )
    SetEnd( end );
}

/**
 * Function Merge
 * modifies Position and Size of this in order to contain the given point
 * mainly used to calculate bounding boxes
 * @param aPoint = given point to merge with this
 */

void EDA_Rect::Merge( const wxPoint& aPoint )
{
    Normalize();        // ensure width and height >= 0
+2 −2
Original line number Diff line number Diff line
@@ -282,7 +282,7 @@ void WinEDA_BasicFrame::GetKicadHelp( wxCommandEvent& event )
/*
 *
 */
void WinEDA_BasicFrame::GetKicadAbout( wxCommandEvent& WXUNUSED(event) )
void WinEDA_BasicFrame::GetKicadAbout( wxCommandEvent& event )
{
    bool ShowAboutDialog(wxWindow * parent);
    ShowAboutDialog(this);
@@ -364,7 +364,7 @@ static inline const char* KICAD_BUILD_OPTIONS_SIGNATURE()

#endif

void WinEDA_BasicFrame::CopyVersionInfoToClipboard( wxCommandEvent& WXUNUSED( event ) )
void WinEDA_BasicFrame::CopyVersionInfoToClipboard( wxCommandEvent&  event )
{
    if( !wxTheClipboard->Open() )
    {
+13 −21
Original line number Diff line number Diff line
@@ -59,6 +59,17 @@ void MARKER_BASE::init()
}


MARKER_BASE::MARKER_BASE( const MARKER_BASE& aMarker )
{
    m_Pos = aMarker.m_Pos;
    m_Corners = aMarker.m_Corners;
    m_MarkerType = aMarker.m_MarkerType;
    m_Color = aMarker.m_Color;
    m_ShapeBoundingBox = aMarker.m_ShapeBoundingBox;
    m_ScalingFactor = aMarker.m_ScalingFactor;
}


MARKER_BASE::MARKER_BASE()
{
    m_ScalingFactor = M_SHAPE_SCALE;
@@ -122,13 +133,6 @@ bool MARKER_BASE::HitTestMarker( const wxPoint& refPos ) const
}


/**
 * Function GetBoundingBoxMarker
 * returns the orthogonal, bounding box of this object for display purposes.
 * This box should be an enclosing perimeter for visible components of this
 * object, and the units should be in the pcb or schematic coordinate system.
 * It is OK to overestimate the size by a few counts.
 */
EDA_Rect MARKER_BASE::GetBoundingBoxMarker() const
{
    wxSize realsize = m_ShapeBoundingBox.GetSize();
@@ -141,15 +145,8 @@ EDA_Rect MARKER_BASE::GetBoundingBoxMarker() const
    return EDA_Rect( m_Pos, realsize );
}

/**********************************************************************/
void MARKER_BASE::DrawMarker( WinEDA_DrawPanel* aPanel, wxDC* aDC, int aDrawMode,
                              const wxPoint& aOffset )
/**********************************************************************/

/**
 * Function DrawMarker
 *  The shape is the polygon defined in m_Corners (array of wxPoints)
 */
{
    wxPoint corners[CORNERS_COUNT];

@@ -172,15 +169,10 @@ void MARKER_BASE::DrawMarker( WinEDA_DrawPanel* aPanel, wxDC* aDC, int aDrawMode
}


/**
 * Function DisplayMarkerInfo
 * Displays the full info of this marker, within an HTML window
 */
void MARKER_BASE::DisplayMarkerInfo( WinEDA_DrawFrame* aFrame )
{
    wxString msg = m_drc.ShowHtml();
    DIALOG_DISPLAY_HTML_TEXT_BASE
        infodisplay( (wxWindow*)aFrame, wxID_ANY, _("Marker Info"),
    DIALOG_DISPLAY_HTML_TEXT_BASE infodisplay( (wxWindow*)aFrame, wxID_ANY, _( "Marker Info" ),
                                               wxGetMousePosition(), wxSize( 550, 140 ) );

    infodisplay.m_htmlWindow->SetPage( msg );
+1 −1
Original line number Diff line number Diff line
@@ -879,7 +879,7 @@ void wxSVGFileDC::DoDrawIcon( const class wxIcon& myIcon, wxCoord x, wxCoord y )
void wxSVGFileDC::DoDrawBitmap( const class wxBitmap& bmp,
                                wxCoord               x,
                                wxCoord               y,
                                bool WXUNUSED (       bTransparent) /*=0*/ )
                                bool                  bTransparent /*=0*/ )
{
    if( m_graphics_changed )
        NewGraphics();
Loading