Minor Eeschema LIB_ITEM object improvements.

This commit is contained in:
Wayne Stambaugh 2012-02-27 18:02:08 -05:00
parent 07e5eee133
commit 4a7394038f
19 changed files with 620 additions and 290 deletions

View File

@ -1,5 +1,5 @@
/**
* @file dialog_lib_edit_one_field.cpp
* @file dialog_edit_one_field.cpp
* @brief dialog to editing a field ( not a graphic text) in current component.
*/

View File

@ -2,7 +2,6 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2008-2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors.
*
* This program is free software; you can redistribute it and/or
@ -228,7 +227,7 @@ EDA_ITEM* LIB_ARC::doClone() const
}
int LIB_ARC::DoCompare( const LIB_ITEM& aOther ) const
int LIB_ARC::compare( const LIB_ITEM& aOther ) const
{
wxASSERT( aOther.Type() == LIB_ARC_T );
@ -250,7 +249,7 @@ int LIB_ARC::DoCompare( const LIB_ITEM& aOther ) const
}
void LIB_ARC::DoOffset( const wxPoint& aOffset )
void LIB_ARC::SetOffset( const wxPoint& aOffset )
{
m_Pos += aOffset;
m_ArcStart += aOffset;
@ -258,14 +257,14 @@ void LIB_ARC::DoOffset( const wxPoint& aOffset )
}
bool LIB_ARC::DoTestInside( EDA_RECT& aRect ) const
bool LIB_ARC::Inside( EDA_RECT& aRect ) const
{
return aRect.Contains( m_ArcStart.x, -m_ArcStart.y )
|| aRect.Contains( m_ArcEnd.x, -m_ArcEnd.y );
}
void LIB_ARC::DoMove( const wxPoint& aPosition )
void LIB_ARC::Move( const wxPoint& aPosition )
{
wxPoint offset = aPosition - m_Pos;
m_Pos = aPosition;
@ -274,7 +273,7 @@ void LIB_ARC::DoMove( const wxPoint& aPosition )
}
void LIB_ARC::DoMirrorHorizontal( const wxPoint& aCenter )
void LIB_ARC::MirrorHorizontal( const wxPoint& aCenter )
{
m_Pos.x -= aCenter.x;
m_Pos.x *= -1;
@ -288,7 +287,7 @@ void LIB_ARC::DoMirrorHorizontal( const wxPoint& aCenter )
EXCHG( m_ArcStart, m_ArcEnd );
}
void LIB_ARC::DoMirrorVertical( const wxPoint& aCenter )
void LIB_ARC::MirrorVertical( const wxPoint& aCenter )
{
m_Pos.y -= aCenter.y;
m_Pos.y *= -1;
@ -302,7 +301,7 @@ void LIB_ARC::DoMirrorVertical( const wxPoint& aCenter )
EXCHG( m_ArcStart, m_ArcEnd );
}
void LIB_ARC::DoRotate( const wxPoint& aCenter, bool aRotateCCW )
void LIB_ARC::Rotate( const wxPoint& aCenter, bool aRotateCCW )
{
int rot_angle = aRotateCCW ? -900 : 900;
RotatePoint( &m_Pos, aCenter, rot_angle );
@ -312,8 +311,8 @@ void LIB_ARC::DoRotate( const wxPoint& aCenter, bool aRotateCCW )
void LIB_ARC::DoPlot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill,
const TRANSFORM& aTransform )
void LIB_ARC::Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill,
const TRANSFORM& aTransform )
{
wxASSERT( aPlotter != NULL );

View File

@ -2,7 +2,6 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2008-2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors.
*
* This program is free software; you can redistribute it and/or
@ -148,34 +147,80 @@ public:
*/
void EndEdit( const wxPoint& aPosition, bool aAbort = false );
/**
* @copydoc LIB_ITEM::SetOffset(const wxPoint&)
*/
virtual void SetOffset( const wxPoint& aOffset );
/**
* @copydoc LIB_ITEM::Inside()
*/
virtual bool Inside( EDA_RECT& aRect ) const;
/**
* @copydoc LIB_ITEM::Move()
*/
virtual void Move( const wxPoint& aPosition );
/**
* @copydoc LIB_ITEM::GetPosition()
*/
virtual wxPoint GetPosition() const { return m_Pos; }
/**
* @copydoc LIB_ITEM::MirrorHorizontal()
*/
virtual void MirrorHorizontal( const wxPoint& aCenter );
/**
* @copydoc LIB_ITEM::MirrorVertical()
*/
virtual void MirrorVertical( const wxPoint& aCenter );
/**
* @copydoc LIB_ITEM::Rotate(const wxPoint&,bool)
*/
virtual void Rotate( const wxPoint& aCenter, bool aRotateCCW = true );
/**
* @copydoc LIB_ITEM::Plot()
*/
virtual void Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill,
const TRANSFORM& aTransform );
/**
* @copydoc LIB_ITEM::GetWidth()
*/
virtual int GetWidth() const { return m_Width; }
/**
* @copydoc LIB_ITEM::SetWidth()
*/
virtual void SetWidth( int aWidth ) { m_Width = aWidth; }
virtual wxString GetSelectMenuText() const;
virtual BITMAP_DEF GetMenuImage() const { return add_arc_xpm; }
protected:
private:
virtual EDA_ITEM* doClone() const;
/**
* Provide the arc draw object specific comparison.
* Function compare
* provides the arc draw object specific comparison.
*
* The sort order is as follows:
* - Arc horizontal (X) position.
* - Arc vertical (Y) position.
* - Arc start angle.
* - Arc end angle.
*
* @param aOther A reference to the other #LIB_ITEM to compare the arc against.
* @return An integer value less than 0 if the arc is less than \a aOther, zero
* if the arc is equal to \a aOther, or greater than 0 if the arc is
* greater than \a aOther.
*/
virtual int DoCompare( const LIB_ITEM& aOther ) const;
virtual void DoOffset( const wxPoint& aOffset );
virtual bool DoTestInside( EDA_RECT& aRect ) const;
virtual void DoMove( const wxPoint& aPosition );
virtual wxPoint DoGetPosition() const { return m_Pos; }
virtual void DoMirrorHorizontal( const wxPoint& aCenter );
virtual void DoMirrorVertical( const wxPoint& aCenter );
virtual void DoRotate( const wxPoint& aCenter, bool aRotateCCW = true );
virtual void DoPlot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill,
const TRANSFORM& aTransform );
virtual int DoGetWidth() const { return m_Width; }
virtual void DoSetWidth( int aWidth ) { m_Width = aWidth; }
virtual int compare( const LIB_ITEM& aOther ) const;
};

View File

@ -2,7 +2,6 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2008-2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors.
*
* This program is free software; you can redistribute it and/or
@ -139,7 +138,7 @@ EDA_ITEM* LIB_BEZIER::doClone() const
}
int LIB_BEZIER::DoCompare( const LIB_ITEM& aOther ) const
int LIB_BEZIER::compare( const LIB_ITEM& aOther ) const
{
wxASSERT( aOther.Type() == LIB_BEZIER_T );
@ -161,7 +160,7 @@ int LIB_BEZIER::DoCompare( const LIB_ITEM& aOther ) const
}
void LIB_BEZIER::DoOffset( const wxPoint& aOffset )
void LIB_BEZIER::SetOffset( const wxPoint& aOffset )
{
size_t i;
@ -173,7 +172,7 @@ void LIB_BEZIER::DoOffset( const wxPoint& aOffset )
}
bool LIB_BEZIER::DoTestInside( EDA_RECT& aRect ) const
bool LIB_BEZIER::Inside( EDA_RECT& aRect ) const
{
for( size_t i = 0; i < m_PolyPoints.size(); i++ )
{
@ -185,13 +184,13 @@ bool LIB_BEZIER::DoTestInside( EDA_RECT& aRect ) const
}
void LIB_BEZIER::DoMove( const wxPoint& aPosition )
void LIB_BEZIER::Move( const wxPoint& aPosition )
{
DoOffset( aPosition - m_PolyPoints[0] );
SetOffset( aPosition - m_PolyPoints[0] );
}
void LIB_BEZIER::DoMirrorHorizontal( const wxPoint& aCenter )
void LIB_BEZIER::MirrorHorizontal( const wxPoint& aCenter )
{
size_t i, imax = m_PolyPoints.size();
@ -212,7 +211,7 @@ void LIB_BEZIER::DoMirrorHorizontal( const wxPoint& aCenter )
}
}
void LIB_BEZIER::DoMirrorVertical( const wxPoint& aCenter )
void LIB_BEZIER::MirrorVertical( const wxPoint& aCenter )
{
size_t i, imax = m_PolyPoints.size();
@ -233,7 +232,7 @@ void LIB_BEZIER::DoMirrorVertical( const wxPoint& aCenter )
}
}
void LIB_BEZIER::DoRotate( const wxPoint& aCenter, bool aRotateCCW )
void LIB_BEZIER::Rotate( const wxPoint& aCenter, bool aRotateCCW )
{
int rot_angle = aRotateCCW ? -900 : 900;
@ -253,8 +252,8 @@ void LIB_BEZIER::DoRotate( const wxPoint& aCenter, bool aRotateCCW )
}
void LIB_BEZIER::DoPlot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill,
const TRANSFORM& aTransform )
void LIB_BEZIER::Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill,
const TRANSFORM& aTransform )
{
wxASSERT( aPlotter != NULL );

View File

@ -2,7 +2,6 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2008-2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors.
*
* This program is free software; you can redistribute it and/or
@ -73,7 +72,12 @@ public:
virtual bool Load( LINE_READER& aLineReader, wxString& aErrorMsg );
void AddPoint( const wxPoint& aPoint );
void AddPoint( const wxPoint& aPoint );
/**
* @copydoc LIB_ITEM::SetOffset(const wxPoint&)
*/
virtual void SetOffset( const wxPoint& aOffset );
/**
* @return the number of corners
@ -102,6 +106,52 @@ public:
*/
virtual EDA_RECT GetBoundingBox() const;
/**
* @copydoc LIB_ITEM::Inside()
*/
virtual bool Inside( EDA_RECT& aRect ) const;
/**
* @copydoc LIB_ITEM::Move()
*/
virtual void Move( const wxPoint& aPosition );
/**
* @copydoc LIB_ITEM::GetPosition()
*/
virtual wxPoint GetPosition() const { return m_PolyPoints[0]; }
/**
* @copydoc LIB_ITEM::MirrorHorizontal()
*/
virtual void MirrorHorizontal( const wxPoint& aCenter );
/**
* @copydoc LIB_ITEM::MirrorVertical()
*/
virtual void MirrorVertical( const wxPoint& aCenter );
/**
* @copydoc LIB_ITEM::Rotate(const wxPoint&,bool)
*/
virtual void Rotate( const wxPoint& aCenter, bool aRotateCCW = true );
/**
* @copydoc LIB_ITEM::Plot()
*/
virtual void Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill,
const TRANSFORM& aTransform );
/**
* @copydoc LIB_ITEM::GetWidth()
*/
virtual int GetWidth() const { return m_Width; }
/**
* @copydoc LIB_ITEM::SetWidth()
*/
virtual void SetWidth( int aWidth ) { m_Width = aWidth; }
/**
* Function GetPenSize
* @return the size of the "pen" that be used to draw or plot this item
@ -110,29 +160,23 @@ public:
virtual void DisplayInfo( EDA_DRAW_FRAME* aFrame );
protected:
private:
virtual EDA_ITEM* doClone() const;
/**
* Provide the bezier curve draw object specific comparison.
* Function compare
* provides the bezier curve draw object specific comparison.
*
* The sort order for each bezier curve segment point is as follows:
* - Bezier point horizontal (X) point position.
* - Bezier point vertical (Y) point position.
*
* @param aOther A reference to the other #LIB_ITEM to compare the bezier curve against.
* @return An integer value less than 0 if the bezier curve is less than \a aOther, zero
* if the bezier curve is equal to \a aOther, or greater than 0 if the bezier
* curve is greater than \a aOther.
*/
virtual int DoCompare( const LIB_ITEM& aOther ) const;
virtual void DoOffset( const wxPoint& aOffset );
virtual bool DoTestInside( EDA_RECT& aRect ) const;
virtual void DoMove( const wxPoint& aPosition );
virtual wxPoint DoGetPosition() const { return m_PolyPoints[0]; }
virtual void DoMirrorHorizontal( const wxPoint& aCenter );
virtual void DoMirrorVertical( const wxPoint& aCenter );
virtual void DoRotate( const wxPoint& aCenter, bool aRotateCCW = true );
virtual void DoPlot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill,
const TRANSFORM& aTransform );
virtual int DoGetWidth() const { return m_Width; }
virtual void DoSetWidth( int aWidth ) { m_Width = aWidth; }
virtual int compare( const LIB_ITEM& aOther ) const;
};

View File

@ -2,7 +2,6 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2008-2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors.
*
* This program is free software; you can redistribute it and/or
@ -121,7 +120,7 @@ EDA_ITEM* LIB_CIRCLE::doClone() const
}
int LIB_CIRCLE::DoCompare( const LIB_ITEM& aOther ) const
int LIB_CIRCLE::compare( const LIB_ITEM& aOther ) const
{
wxASSERT( aOther.Type() == LIB_CIRCLE_T );
@ -140,13 +139,13 @@ int LIB_CIRCLE::DoCompare( const LIB_ITEM& aOther ) const
}
void LIB_CIRCLE::DoOffset( const wxPoint& aOffset )
void LIB_CIRCLE::SetOffset( const wxPoint& aOffset )
{
m_Pos += aOffset;
}
bool LIB_CIRCLE::DoTestInside( EDA_RECT& aRect ) const
bool LIB_CIRCLE::Inside( EDA_RECT& aRect ) const
{
/*
* FIXME: This fails to take into account the radius around the center
@ -156,13 +155,13 @@ bool LIB_CIRCLE::DoTestInside( EDA_RECT& aRect ) const
}
void LIB_CIRCLE::DoMove( const wxPoint& aPosition )
void LIB_CIRCLE::Move( const wxPoint& aPosition )
{
m_Pos = aPosition;
}
void LIB_CIRCLE::DoMirrorHorizontal( const wxPoint& aCenter )
void LIB_CIRCLE::MirrorHorizontal( const wxPoint& aCenter )
{
m_Pos.x -= aCenter.x;
m_Pos.x *= -1;
@ -170,7 +169,7 @@ void LIB_CIRCLE::DoMirrorHorizontal( const wxPoint& aCenter )
}
void LIB_CIRCLE::DoMirrorVertical( const wxPoint& aCenter )
void LIB_CIRCLE::MirrorVertical( const wxPoint& aCenter )
{
m_Pos.y -= aCenter.y;
m_Pos.y *= -1;
@ -178,7 +177,7 @@ void LIB_CIRCLE::DoMirrorVertical( const wxPoint& aCenter )
}
void LIB_CIRCLE::DoRotate( const wxPoint& aCenter, bool aRotateCCW )
void LIB_CIRCLE::Rotate( const wxPoint& aCenter, bool aRotateCCW )
{
int rot_angle = aRotateCCW ? -900 : 900;
@ -186,8 +185,8 @@ void LIB_CIRCLE::DoRotate( const wxPoint& aCenter, bool aRotateCCW )
}
void LIB_CIRCLE::DoPlot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill,
const TRANSFORM& aTransform )
void LIB_CIRCLE::Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill,
const TRANSFORM& aTransform )
{
wxPoint pos = aTransform.TransformCoordinate( m_Pos ) + aOffset;

View File

@ -2,7 +2,6 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2008-2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors.
*
* This program is free software; you can redistribute it and/or
@ -118,34 +117,79 @@ public:
*/
void EndEdit( const wxPoint& aPosition, bool aAbort = false );
/**
* @copydoc LIB_ITEM::SetOffset(const wxPoint&)
*/
virtual void SetOffset( const wxPoint& aOffset );
/**
* @copydoc LIB_ITEM::Inside()
*/
virtual bool Inside( EDA_RECT& aRect ) const;
/**
* @copydoc LIB_ITEM::Move()
*/
virtual void Move( const wxPoint& aPosition );
/**
* @copydoc LIB_ITEM::GetPosition()
*/
virtual wxPoint GetPosition() const { return m_Pos; }
/**
* @copydoc LIB_ITEM::MirrorHorizontal()
*/
virtual void MirrorHorizontal( const wxPoint& aCenter );
/**
* @copydoc LIB_ITEM::MirrorVertical()
*/
virtual void MirrorVertical( const wxPoint& aCenter );
/**
* @copydoc LIB_ITEM::Rotate(const wxPoint&,bool)
*/
virtual void Rotate( const wxPoint& aCenter, bool aRotateCCW = true );
/**
* @copydoc LIB_ITEM::Plot()
*/
virtual void Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill,
const TRANSFORM& aTransform );
/**
* @copydoc LIB_ITEM::GetWidth()
*/
virtual int GetWidth() const { return m_Width; }
/**
* @copydoc LIB_ITEM::SetWidth()
*/
virtual void SetWidth( int aWidth ) { m_Width = aWidth; }
virtual wxString GetSelectMenuText() const;
virtual BITMAP_DEF GetMenuImage() const { return add_circle_xpm; }
protected:
private:
virtual EDA_ITEM* doClone() const;
/**
* Provide the circle draw object specific comparison.
* Function compare
* provides the circle draw object specific comparison.
*
* The sort order is as follows:
* - Circle horizontal (X) position.
* - Circle vertical (Y) position.
* - Circle radius.
*
* @param aOther A reference to the other #LIB_ITEM to compare the circle against.
* @return An integer value less than 0 if the circle is less than \a aOther, zero
* if the circle is equal to \a aOther, or greater than 0 if the circle is
* greater than \a aOther.
*/
virtual int DoCompare( const LIB_ITEM& aOther ) const;
virtual void DoOffset( const wxPoint& aOffset );
virtual bool DoTestInside( EDA_RECT& aRect ) const;
virtual void DoMove( const wxPoint& aPosition );
virtual wxPoint DoGetPosition() const { return m_Pos; }
virtual void DoMirrorHorizontal( const wxPoint& aCenter );
virtual void DoMirrorVertical( const wxPoint& aCenter );
virtual void DoRotate( const wxPoint& aCenter, bool aRotateCCW = true );
virtual void DoPlot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill,
const TRANSFORM& aTransform );
virtual int DoGetWidth() const { return m_Width; }
virtual void DoSetWidth( int aWidth ) { m_Width = aWidth; }
virtual int compare( const LIB_ITEM& aOther ) const;
};

View File

@ -2,7 +2,6 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2008-2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors.
*
* This program is free software; you can redistribute it and/or
@ -90,7 +89,7 @@ bool LIB_ITEM::operator==( const LIB_ITEM& aOther ) const
return ( ( Type() == aOther.Type() )
&& ( m_Unit == aOther.m_Unit )
&& ( m_Convert == aOther.m_Convert )
&& DoCompare( aOther ) == 0 );
&& compare( aOther ) == 0 );
}
@ -111,7 +110,7 @@ bool LIB_ITEM::operator<( const LIB_ITEM& aOther ) const
if( result != 0 )
return result < 0;
return ( DoCompare( aOther ) < 0 );
return ( compare( aOther ) < 0 );
}
@ -125,6 +124,7 @@ void LIB_ITEM::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
int color = GetDefaultColor();
m_Fill = NO_FILL;
#ifndef USE_WX_OVERLAY
// Erase the old items using the previous attributes.
if( m_eraseLastDrawItem )

View File

@ -2,7 +2,6 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2008-2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors.
*
* This program is free software; you can redistribute it and/or
@ -67,14 +66,9 @@ typedef boost::ptr_vector< LIB_ITEM > LIB_ITEMS;
typedef std::vector< LIB_PIN* > LIB_PINS;
/****************************************************************************/
/* Classes for handle the body items of a component: pins add graphic items */
/****************************************************************************/
/**
* Base class for drawable items used in library components.
* (graphic shapes, texts, fields, pins)
* Class LIB_ITEM
* is the base class for drawable items used by schematic library components.
*/
class LIB_ITEM : public EDA_ITEM
{
@ -135,6 +129,9 @@ protected:
wxPoint m_initialPos; ///< Temporary position when moving an existing item.
wxPoint m_initialCursorPos; ///< Initial cursor position at the beginning of a move.
/** Flag to indicate if draw item is fillable. Default is false. */
bool m_isFillable;
public:
LIB_ITEM( KICAD_T aType,
@ -217,7 +214,7 @@ public:
* Function Save
* writes draw item object to \a aFormatter in component library "*.lib" format.
*
* @param aFormatter A referenct to an #OUTPUTFORMATTER object to write the
* @param aFormatter A reference to an #OUTPUTFORMATTER object to write the
* component library item to.
* @return True if success writing else false.
*/
@ -294,68 +291,64 @@ public:
bool operator<( const LIB_ITEM& aOther) const;
/**
* Set drawing object offset from the current position.
* Function Offset
* sets the drawing object by \a aOffset from the current position.
*
* @param aOffset - Coordinates to offset position.
* @param aOffset Coordinates to offset the item position.
*/
void SetOffset( const wxPoint& aOffset ) { DoOffset( aOffset ); }
virtual void SetOffset( const wxPoint& aOffset ) = 0;
/**
* Test if any part of the draw object is inside rectangle bounds.
* Function Inside
* tests if any part of the draw object is inside rectangle bounds of \a aRect.
*
* This is used for block selection. The real work is done by the
* DoTestInside method for each derived object type.
*
* @param aRect - Rectangle to check against.
* @return - True if object is inside rectangle.
* @param aRect Rectangle to check against.
* @return True if object is inside rectangle.
*/
bool Inside( EDA_RECT& aRect ) const { return DoTestInside( aRect ); }
virtual bool Inside( EDA_RECT& aRect ) const = 0;
/**
* Move a draw object to a new \a aPosition.
* Function Move
* moves a draw object to \a aPosition.
*
* The real work is done by the DoMove method for each derived object type.
*
* @param aPosition - Position to move draw item to.
* @param aPosition Position to move draw item to.
*/
void Move( const wxPoint& aPosition ) { DoMove( aPosition ); }
virtual void Move( const wxPoint& aPosition ) = 0;
/**
* Return the current draw object start position.
* Function GetPosition
* returns the current draw object position.
*
* @return A wxPoint object containing the position of the object.
*/
wxPoint GetPosition() const { return DoGetPosition(); }
virtual wxPoint GetPosition() const = 0;
void SetPosition( const wxPoint& aPosition ) { DoMove( aPosition ); }
void SetPosition( const wxPoint& aPosition ) { Move( aPosition ); }
/**
* Mirror the draw object along the horizontal (X) axis about a point.
* Function MirrorHorizontal
* mirrors the draw object along the horizontal (X) axis about \a aCenter point.
*
* @param aCenter - Point to mirror around.
* @param aCenter Point to mirror around.
*/
void MirrorHorizontal( const wxPoint& aCenter )
{
DoMirrorHorizontal( aCenter );
}
virtual void MirrorHorizontal( const wxPoint& aCenter ) = 0;
/**
* Mirror the draw object along the MirrorVertical (Y) axis about a point.
* Function MirrorVertical
* mirrors the draw object along the MirrorVertical (Y) axis about \a aCenter point.
*
* @param aCenter - Point to mirror around.
* @param aCenter Point to mirror around.
*/
void MirrorVertical( const wxPoint& aCenter )
{
DoMirrorVertical( aCenter );
}
virtual void MirrorVertical( const wxPoint& aCenter ) = 0;
/**
* Rotate about a point.
* Function Rotate
* rotates the object about \a aCenter point.
*
* @param aCenter - Point to rotate around.
* @param aCenter Point to rotate around.
* @param aRotateCCW True to rotate counter clockwise. False to rotate clockwise.
*/
void Rotate( const wxPoint& aCenter )
{
DoRotate( aCenter );
}
virtual void Rotate( const wxPoint& aCenter, bool aRotateCCW = true ) = 0;
/**
* Rotate the draw item.
@ -365,23 +358,27 @@ public:
/**
* Plot the draw item using the plot object.
*
* @param aPlotter - The plot object to plot to.
* @param aOffset - Plot offset position.
* @param aFill - Flag to indicate whether or not the object is filled.
* @param aTransform - The plot transform.
* @param aPlotter The plot object to plot to.
* @param aOffset Plot offset position.
* @param aFill Flag to indicate whether or not the object is filled.
* @param aTransform The plot transform.
*/
void Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill, const TRANSFORM& aTransform )
{
DoPlot( aPlotter, aOffset, aFill, aTransform );
}
virtual void Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill,
const TRANSFORM& aTransform ) = 0;
/**
* Return the width of the draw item.
* Function GetWidth
* return the width of the draw item.
*
* @return Width of draw object.
*/
int GetWidth() const { return DoGetWidth(); }
void SetWidth( int aWidth ) { DoSetWidth( aWidth ); }
virtual int GetWidth() const = 0;
/**
* Function SetWidth
* sets the width of the draw item to \a aWidth.
*/
virtual void SetWidth( int aWidth ) = 0;
/**
* Check if draw object can be filled.
@ -420,10 +417,11 @@ public:
void Show( int nestLevel, std::ostream& os ) const { ShowDummy( os ); } // override
#endif
protected:
private:
/**
* Provide the draw object specific comparison.
* Function compare
* provides the draw object specific comparison.
*
* This is called by the == and < operators.
*
@ -433,21 +431,7 @@ protected:
* - KICAD_T enum value.
* - Result of derived classes comparison.
*/
virtual int DoCompare( const LIB_ITEM& aOther ) const = 0;
virtual void DoOffset( const wxPoint& aOffset ) = 0;
virtual bool DoTestInside( EDA_RECT& aRect ) const = 0;
virtual void DoMove( const wxPoint& aPosition ) = 0;
virtual wxPoint DoGetPosition() const = 0;
virtual void DoMirrorHorizontal( const wxPoint& aCenter ) = 0;
virtual void DoMirrorVertical( const wxPoint& aCenter ) = 0;
virtual void DoRotate( const wxPoint& aCenter, bool aRotateCCW = true ) = 0;
virtual void DoPlot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill,
const TRANSFORM& aTransform ) = 0;
virtual int DoGetWidth() const = 0;
virtual void DoSetWidth( int aWidth ) = 0;
/** Flag to indicate if draw item is fillable. Default is false. */
bool m_isFillable;
virtual int compare( const LIB_ITEM& aOther ) const = 0;
};

View File

@ -2,7 +2,6 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2008-2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors.
*
* This program is free software; you can redistribute it and/or
@ -397,7 +396,7 @@ void LIB_FIELD::Copy( LIB_FIELD* aTarget ) const
}
int LIB_FIELD::DoCompare( const LIB_ITEM& other ) const
int LIB_FIELD::compare( const LIB_ITEM& other ) const
{
wxASSERT( other.Type() == LIB_FIELD_T );
@ -427,13 +426,13 @@ int LIB_FIELD::DoCompare( const LIB_ITEM& other ) const
}
void LIB_FIELD::DoOffset( const wxPoint& offset )
void LIB_FIELD::SetOffset( const wxPoint& aOffset )
{
m_Pos += offset;
m_Pos += aOffset;
}
bool LIB_FIELD::DoTestInside( EDA_RECT& rect ) const
bool LIB_FIELD::Inside( EDA_RECT& rect ) const
{
/*
* FIXME: This fails to take into account the size and/or orientation of
@ -443,27 +442,27 @@ bool LIB_FIELD::DoTestInside( EDA_RECT& rect ) const
}
void LIB_FIELD::DoMove( const wxPoint& newPosition )
void LIB_FIELD::Move( const wxPoint& newPosition )
{
m_Pos = newPosition;
}
void LIB_FIELD::DoMirrorHorizontal( const wxPoint& center )
void LIB_FIELD::MirrorHorizontal( const wxPoint& center )
{
m_Pos.x -= center.x;
m_Pos.x *= -1;
m_Pos.x += center.x;
}
void LIB_FIELD::DoMirrorVertical( const wxPoint& center )
void LIB_FIELD::MirrorVertical( const wxPoint& center )
{
m_Pos.y -= center.y;
m_Pos.y *= -1;
m_Pos.y += center.y;
}
void LIB_FIELD::DoRotate( const wxPoint& center, bool aRotateCCW )
void LIB_FIELD::Rotate( const wxPoint& center, bool aRotateCCW )
{
int rot_angle = aRotateCCW ? -900 : 900;
RotatePoint( &m_Pos, center, rot_angle );
@ -471,8 +470,8 @@ void LIB_FIELD::DoRotate( const wxPoint& center, bool aRotateCCW )
}
void LIB_FIELD::DoPlot( PLOTTER* plotter, const wxPoint& offset, bool fill,
const TRANSFORM& aTransform )
void LIB_FIELD::Plot( PLOTTER* plotter, const wxPoint& offset, bool fill,
const TRANSFORM& aTransform )
{
}

View File

@ -2,7 +2,6 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2008-2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors.
*
* This program is free software; you can redistribute it and/or
@ -269,15 +268,67 @@ public:
*/
void SetText( const wxString& aText );
/**
* @copydoc LIB_ITEM::SetOffset(const wxPoint&)
*/
virtual void SetOffset( const wxPoint& aOffset );
/**
* @copydoc LIB_ITEM::Inside()
*/
virtual bool Inside( EDA_RECT& aRect ) const;
/**
* @copydoc LIB_ITEM::Move()
*/
virtual void Move( const wxPoint& aPosition );
/**
* @copydoc LIB_ITEM::GetPosition()
*/
virtual wxPoint GetPosition() const { return m_Pos; }
/**
* @copydoc LIB_ITEM::MirrorHorizontal()
*/
virtual void MirrorHorizontal( const wxPoint& aCenter );
/**
* @copydoc LIB_ITEM::MirrorVertical()
*/
virtual void MirrorVertical( const wxPoint& aCenter );
/**
* @copydoc LIB_ITEM::Rotate(const wxPoint&,bool)
*/
virtual void Rotate( const wxPoint& aCenter, bool aRotateCCW = true );
/**
* @copydoc LIB_ITEM::Plot()
*/
virtual void Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill,
const TRANSFORM& aTransform );
/**
* @copydoc LIB_ITEM::GetWidth()
*/
virtual int GetWidth() const { return m_Thickness; }
/**
* @copydoc LIB_ITEM::SetWidth()
*/
virtual void SetWidth( int aWidth ) { m_Thickness = aWidth; }
virtual wxString GetSelectMenuText() const;
virtual BITMAP_DEF GetMenuImage() const { return move_field_xpm; }
protected:
private:
virtual EDA_ITEM* doClone() const;
/**
* Provide the field draw object specific comparison.
* Function compare
* provides the field draw object specific comparison.
*
* The sort order for field is as follows:
*
@ -287,20 +338,13 @@ protected:
* - Field vertical (Y) position.
* - Field width.
* - Field height.
*
* @param aOther A reference to the other #LIB_ITEM to compare the field against.
* @return An integer value less than 0 if the field is less than \a aOther, zero
* if the field is equal to \a aOther, or greater than 0 if the field is
* greater than \a aOther.
*/
virtual int DoCompare( const LIB_ITEM& other ) const;
virtual void DoOffset( const wxPoint& offset );
virtual bool DoTestInside( EDA_RECT& rect ) const;
virtual void DoMove( const wxPoint& newPosition );
virtual wxPoint DoGetPosition( void ) const { return m_Pos; }
virtual void DoMirrorHorizontal( const wxPoint& center );
virtual void DoMirrorVertical( const wxPoint& aCenter );
virtual void DoRotate( const wxPoint& aCenter, bool aRotateCCW = true );
virtual void DoPlot( PLOTTER* plotter, const wxPoint& offset, bool fill,
const TRANSFORM& aTransform );
virtual int DoGetWidth( void ) const { return m_Thickness; }
virtual void DoSetWidth( int width ) { m_Thickness = width; }
virtual int compare( const LIB_ITEM& aOther ) const;
};
typedef std::vector< LIB_FIELD > LIB_FIELDS;

View File

@ -2,7 +2,6 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2009 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2009 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
@ -1677,7 +1676,7 @@ EDA_ITEM* LIB_PIN::doClone() const
}
int LIB_PIN::DoCompare( const LIB_ITEM& other ) const
int LIB_PIN::compare( const LIB_ITEM& other ) const
{
wxASSERT( other.Type() == LIB_PIN_T );
@ -1701,13 +1700,13 @@ int LIB_PIN::DoCompare( const LIB_ITEM& other ) const
}
void LIB_PIN::DoOffset( const wxPoint& offset )
void LIB_PIN::SetOffset( const wxPoint& aOffset )
{
m_position += offset;
m_position += aOffset;
}
bool LIB_PIN::DoTestInside( EDA_RECT& rect ) const
bool LIB_PIN::Inside( EDA_RECT& rect ) const
{
wxPoint end = ReturnPinEndPoint();
@ -1715,7 +1714,7 @@ bool LIB_PIN::DoTestInside( EDA_RECT& rect ) const
}
void LIB_PIN::DoMove( const wxPoint& newPosition )
void LIB_PIN::Move( const wxPoint& newPosition )
{
if( m_position != newPosition )
{
@ -1725,7 +1724,7 @@ void LIB_PIN::DoMove( const wxPoint& newPosition )
}
void LIB_PIN::DoMirrorHorizontal( const wxPoint& center )
void LIB_PIN::MirrorHorizontal( const wxPoint& center )
{
m_position.x -= center.x;
m_position.x *= -1;
@ -1737,7 +1736,7 @@ void LIB_PIN::DoMirrorHorizontal( const wxPoint& center )
m_orientation = PIN_RIGHT;
}
void LIB_PIN::DoMirrorVertical( const wxPoint& center )
void LIB_PIN::MirrorVertical( const wxPoint& center )
{
m_position.y -= center.y;
m_position.y *= -1;
@ -1749,7 +1748,7 @@ void LIB_PIN::DoMirrorVertical( const wxPoint& center )
m_orientation = PIN_UP;
}
void LIB_PIN::DoRotate( const wxPoint& center, bool aRotateCCW )
void LIB_PIN::Rotate( const wxPoint& center, bool aRotateCCW )
{
int rot_angle = aRotateCCW ? -900 : 900;
@ -1798,8 +1797,8 @@ void LIB_PIN::DoRotate( const wxPoint& center, bool aRotateCCW )
}
void LIB_PIN::DoPlot( PLOTTER* plotter, const wxPoint& offset, bool fill,
const TRANSFORM& aTransform )
void LIB_PIN::Plot( PLOTTER* plotter, const wxPoint& offset, bool fill,
const TRANSFORM& aTransform )
{
if( ! IsVisible() )
return;
@ -1816,7 +1815,7 @@ void LIB_PIN::DoPlot( PLOTTER* plotter, const wxPoint& offset, bool fill,
}
void LIB_PIN::DoSetWidth( int aWidth )
void LIB_PIN::SetWidth( int aWidth )
{
if( m_width != aWidth )
{

View File

@ -2,7 +2,6 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2008-2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors.
*
* This program is free software; you can redistribute it and/or
@ -519,34 +518,80 @@ public:
*/
static const BITMAP_DEF* GetElectricalTypeSymbols();
/**
* @copydoc LIB_ITEM::SetOffset(const wxPoint&)
*/
virtual void SetOffset( const wxPoint& aOffset );
/**
* @copydoc LIB_ITEM::Inside()
*/
virtual bool Inside( EDA_RECT& aRect ) const;
/**
* @copydoc LIB_ITEM::Move()
*/
virtual void Move( const wxPoint& aPosition );
/**
* @copydoc LIB_ITEM::GetPosition()
*/
virtual wxPoint GetPosition() const { return m_position; }
/**
* @copydoc LIB_ITEM::MirrorHorizontal()
*/
virtual void MirrorHorizontal( const wxPoint& aCenter );
/**
* @copydoc LIB_ITEM::MirrorVertical()
*/
virtual void MirrorVertical( const wxPoint& aCenter );
/**
* @copydoc LIB_ITEM::Rotate(const wxPoint&,bool)
*/
virtual void Rotate( const wxPoint& aCenter, bool aRotateCCW = true );
/**
* @copydoc LIB_ITEM::Plot()
*/
virtual void Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill,
const TRANSFORM& aTransform );
/**
* @copydoc LIB_ITEM::GetWidth()
*/
virtual int GetWidth() const { return m_width; }
/**
* @copydoc LIB_ITEM::SetWidth()
*/
virtual void SetWidth( int aWidth );
virtual BITMAP_DEF GetMenuImage() const;
virtual wxString GetSelectMenuText() const;
protected:
private:
virtual EDA_ITEM* doClone() const;
/**
* Provide the pin draw object specific comparison.
* Function compare
* provides the pin draw object specific comparison.
*
* The sort order is as follows:
* - Pin number.
* - Pin name, case insensitive compare.
* - Pin horizontal (X) position.
* - Pin vertical (Y) position.
*
* @param aOther A reference to the other #LIB_ITEM to compare the pin against.
* @return An integer value less than 0 if the pin is less than \a aOther, zero
* if the pin is equal to \a aOther, or greater than 0 if the pin is
* greater than \a aOther.
*/
virtual int DoCompare( const LIB_ITEM& aOther ) const;
virtual void DoOffset( const wxPoint& aOffset );
virtual bool DoTestInside( EDA_RECT& aRect ) const;
virtual void DoMove( const wxPoint& aPosition );
virtual wxPoint DoGetPosition() const { return m_position; }
virtual void DoMirrorHorizontal( const wxPoint& aCenter );
virtual void DoMirrorVertical( const wxPoint& aCenter );
virtual void DoRotate( const wxPoint& aCenter, bool aRotateCCW = true );
virtual void DoPlot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill,
const TRANSFORM& aTransform );
virtual int DoGetWidth() const { return m_width; }
virtual void DoSetWidth( int aWidth );
virtual int compare( const LIB_ITEM& aOther ) const;
};

View File

@ -2,7 +2,6 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2008-2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors.
*
* This program is free software; you can redistribute it and/or
@ -140,7 +139,7 @@ EDA_ITEM* LIB_POLYLINE::doClone() const
}
int LIB_POLYLINE::DoCompare( const LIB_ITEM& aOther ) const
int LIB_POLYLINE::compare( const LIB_ITEM& aOther ) const
{
wxASSERT( aOther.Type() == LIB_POLYLINE_T );
@ -162,14 +161,14 @@ int LIB_POLYLINE::DoCompare( const LIB_ITEM& aOther ) const
}
void LIB_POLYLINE::DoOffset( const wxPoint& aOffset )
void LIB_POLYLINE::SetOffset( const wxPoint& aOffset )
{
for( size_t i = 0; i < m_PolyPoints.size(); i++ )
m_PolyPoints[i] += aOffset;
}
bool LIB_POLYLINE::DoTestInside( EDA_RECT& aRect ) const
bool LIB_POLYLINE::Inside( EDA_RECT& aRect ) const
{
for( size_t i = 0; i < m_PolyPoints.size(); i++ )
{
@ -181,13 +180,13 @@ bool LIB_POLYLINE::DoTestInside( EDA_RECT& aRect ) const
}
void LIB_POLYLINE::DoMove( const wxPoint& aPosition )
void LIB_POLYLINE::Move( const wxPoint& aPosition )
{
DoOffset( aPosition - m_PolyPoints[0] );
SetOffset( aPosition - m_PolyPoints[0] );
}
void LIB_POLYLINE::DoMirrorHorizontal( const wxPoint& aCenter )
void LIB_POLYLINE::MirrorHorizontal( const wxPoint& aCenter )
{
size_t i, imax = m_PolyPoints.size();
@ -199,7 +198,7 @@ void LIB_POLYLINE::DoMirrorHorizontal( const wxPoint& aCenter )
}
}
void LIB_POLYLINE::DoMirrorVertical( const wxPoint& aCenter )
void LIB_POLYLINE::MirrorVertical( const wxPoint& aCenter )
{
size_t i, imax = m_PolyPoints.size();
@ -211,7 +210,7 @@ void LIB_POLYLINE::DoMirrorVertical( const wxPoint& aCenter )
}
}
void LIB_POLYLINE::DoRotate( const wxPoint& aCenter, bool aRotateCCW )
void LIB_POLYLINE::Rotate( const wxPoint& aCenter, bool aRotateCCW )
{
int rot_angle = aRotateCCW ? -900 : 900;
@ -224,8 +223,8 @@ void LIB_POLYLINE::DoRotate( const wxPoint& aCenter, bool aRotateCCW )
}
void LIB_POLYLINE::DoPlot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill,
const TRANSFORM& aTransform )
void LIB_POLYLINE::Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill,
const TRANSFORM& aTransform )
{
wxASSERT( aPlotter != NULL );

View File

@ -2,7 +2,6 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2008-2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors.
*
* This program is free software; you can redistribute it and/or
@ -134,33 +133,78 @@ public:
*/
void EndEdit( const wxPoint& aPosition, bool aAbort = false );
/**
* @copydoc LIB_ITEM::SetOffset(const wxPoint&)
*/
virtual void SetOffset( const wxPoint& aOffset );
/**
* @copydoc LIB_ITEM::Inside()
*/
virtual bool Inside( EDA_RECT& aRect ) const;
/**
* @copydoc LIB_ITEM::Move()
*/
virtual void Move( const wxPoint& aPosition );
/**
* @copydoc LIB_ITEM::GetPosition()
*/
virtual wxPoint GetPosition() const { return m_PolyPoints[0]; }
/**
* @copydoc LIB_ITEM::MirrorHorizontal()
*/
virtual void MirrorHorizontal( const wxPoint& aCenter );
/**
* @copydoc LIB_ITEM::MirrorVertical()
*/
virtual void MirrorVertical( const wxPoint& aCenter );
/**
* @copydoc LIB_ITEM::Rotate(const wxPoint&,bool)
*/
virtual void Rotate( const wxPoint& aCenter, bool aRotateCCW = true );
/**
* @copydoc LIB_ITEM::Plot()
*/
virtual void Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill,
const TRANSFORM& aTransform );
/**
* @copydoc LIB_ITEM::GetWidth()
*/
virtual int GetWidth() const { return m_Width; }
/**
* @copydoc LIB_ITEM::SetWidth()
*/
virtual void SetWidth( int aWidth ) { m_Width = aWidth; }
virtual wxString GetSelectMenuText() const;
virtual BITMAP_DEF GetMenuImage() const { return add_polygon_xpm; }
protected:
private:
virtual EDA_ITEM* doClone() const;
/**
* Provide the polyline segment draw object specific comparison.
* Function compare
* provides the polyline segment draw object specific comparison.
*
* The sort order for each polyline segment point is as follows:
* - Line segment point horizontal (X) position.
* - Line segment point vertical (Y) position.
*
* @param aOther A reference to the other #LIB_ITEM to compare the polyline against.
* @return An integer value less than 0 if the polyline is less than \a aOther, zero
* if the polyline is equal to \a aOther, or greater than 0 if the polyline
* is greater than \a aOther.
*/
virtual int DoCompare( const LIB_ITEM& aOther ) const;
virtual void DoOffset( const wxPoint& aOffset );
virtual bool DoTestInside( EDA_RECT& aRect ) const;
virtual void DoMove( const wxPoint& aPosition );
virtual wxPoint DoGetPosition() const { return m_PolyPoints[0]; }
virtual void DoMirrorHorizontal( const wxPoint& aCenter );
virtual void DoMirrorVertical( const wxPoint& aCenter );
virtual void DoRotate( const wxPoint& aCenter, bool aRotateCCW = true );
virtual void DoPlot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill,
const TRANSFORM& aTransform );
virtual int DoGetWidth() const { return m_Width; }
virtual void DoSetWidth( int aWidth ) { m_Width = aWidth; }
virtual int compare( const LIB_ITEM& aOther ) const;
};

View File

@ -2,7 +2,6 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2008-2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors.
*
* This program is free software; you can redistribute it and/or
@ -95,7 +94,7 @@ EDA_ITEM* LIB_RECTANGLE::doClone() const
}
int LIB_RECTANGLE::DoCompare( const LIB_ITEM& aOther ) const
int LIB_RECTANGLE::compare( const LIB_ITEM& aOther ) const
{
wxASSERT( aOther.Type() == LIB_RECTANGLE_T );
@ -117,20 +116,20 @@ int LIB_RECTANGLE::DoCompare( const LIB_ITEM& aOther ) const
}
void LIB_RECTANGLE::DoOffset( const wxPoint& aOffset )
void LIB_RECTANGLE::SetOffset( const wxPoint& aOffset )
{
m_Pos += aOffset;
m_End += aOffset;
}
bool LIB_RECTANGLE::DoTestInside( EDA_RECT& aRect ) const
bool LIB_RECTANGLE::Inside( EDA_RECT& aRect ) const
{
return aRect.Contains( m_Pos.x, -m_Pos.y ) || aRect.Contains( m_End.x, -m_End.y );
}
void LIB_RECTANGLE::DoMove( const wxPoint& aPosition )
void LIB_RECTANGLE::Move( const wxPoint& aPosition )
{
wxPoint size = m_End - m_Pos;
m_Pos = aPosition;
@ -138,7 +137,7 @@ void LIB_RECTANGLE::DoMove( const wxPoint& aPosition )
}
void LIB_RECTANGLE::DoMirrorHorizontal( const wxPoint& aCenter )
void LIB_RECTANGLE::MirrorHorizontal( const wxPoint& aCenter )
{
m_Pos.x -= aCenter.x;
m_Pos.x *= -1;
@ -149,7 +148,7 @@ void LIB_RECTANGLE::DoMirrorHorizontal( const wxPoint& aCenter )
}
void LIB_RECTANGLE::DoMirrorVertical( const wxPoint& aCenter )
void LIB_RECTANGLE::MirrorVertical( const wxPoint& aCenter )
{
m_Pos.y -= aCenter.y;
m_Pos.y *= -1;
@ -160,7 +159,7 @@ void LIB_RECTANGLE::DoMirrorVertical( const wxPoint& aCenter )
}
void LIB_RECTANGLE::DoRotate( const wxPoint& aCenter, bool aRotateCCW )
void LIB_RECTANGLE::Rotate( const wxPoint& aCenter, bool aRotateCCW )
{
int rot_angle = aRotateCCW ? -900 : 900;
RotatePoint( &m_Pos, aCenter, rot_angle );
@ -168,8 +167,8 @@ void LIB_RECTANGLE::DoRotate( const wxPoint& aCenter, bool aRotateCCW )
}
void LIB_RECTANGLE::DoPlot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill,
const TRANSFORM& aTransform )
void LIB_RECTANGLE::Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill,
const TRANSFORM& aTransform )
{
wxASSERT( aPlotter != NULL );

View File

@ -2,7 +2,6 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2008-2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors.
*
* This program is free software; you can redistribute it and/or
@ -122,35 +121,80 @@ public:
*/
void EndEdit( const wxPoint& aPosition, bool aAbort = false );
/**
* @copydoc LIB_ITEM::SetOffset(const wxPoint&)
*/
virtual void SetOffset( const wxPoint& aOffset );
/**
* @copydoc LIB_ITEM::Inside()
*/
virtual bool Inside( EDA_RECT& aRect ) const;
/**
* @copydoc LIB_ITEM::Move()
*/
virtual void Move( const wxPoint& aPosition );
/**
* @copydoc LIB_ITEM::GetPosition()
*/
virtual wxPoint GetPosition() const { return m_Pos; }
/**
* @copydoc LIB_ITEM::MirrorHorizontal()
*/
virtual void MirrorHorizontal( const wxPoint& aCenter );
/**
* @copydoc LIB_ITEM::MirrorVertical()
*/
virtual void MirrorVertical( const wxPoint& aCenter );
/**
* @copydoc LIB_ITEM::Rotate(const wxPoint&,bool)
*/
virtual void Rotate( const wxPoint& aCenter, bool aRotateCCW = true );
/**
* @copydoc LIB_ITEM::Plot()
*/
virtual void Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill,
const TRANSFORM& aTransform );
/**
* @copydoc LIB_ITEM::GetWidth()
*/
virtual int GetWidth() const { return m_Width; }
/**
* @copydoc LIB_ITEM::SetWidth()
*/
virtual void SetWidth( int aWidth ) { m_Width = aWidth; }
virtual wxString GetSelectMenuText() const;
virtual BITMAP_DEF GetMenuImage() const { return add_rectangle_xpm; }
protected:
private:
virtual EDA_ITEM* doClone() const;
/**
* Provide the rectangle draw object specific comparison.
* Function compare
* provides the rectangle draw object specific comparison.
*
* The sort order is as follows:
* - Rectangle horizontal (X) start position.
* - Rectangle vertical (Y) start position.
* - Rectangle horizontal (X) end position.
* - Rectangle vertical (Y) end position.
*
* @param aOther A reference to the other #LIB_ITEM to compare the rectangle against.
* @return An integer value less than 0 if the rectangle is less than \a aOther, zero
* if the rectangle is equal to \a aOther, or greater than 0 if the rectangle
* is greater than \a aOther.
*/
virtual int DoCompare( const LIB_ITEM& aOther ) const;
virtual void DoOffset( const wxPoint& aOffset );
virtual bool DoTestInside( EDA_RECT& aRect ) const;
virtual void DoMove( const wxPoint& aPosition );
virtual wxPoint DoGetPosition() const { return m_Pos; }
virtual void DoMirrorHorizontal( const wxPoint& aCenter );
virtual void DoMirrorVertical( const wxPoint& aCenter );
virtual void DoRotate( const wxPoint& aCenter, bool aRotateCCW = true );
virtual void DoPlot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill,
const TRANSFORM& aTransform );
virtual int DoGetWidth() const { return m_Width; }
virtual void DoSetWidth( int aWidth ) { m_Width = aWidth; }
virtual int compare( const LIB_ITEM& aOther ) const;
};

View File

@ -2,7 +2,6 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2008-2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors.
*
* This program is free software; you can redistribute it and/or
@ -236,7 +235,7 @@ EDA_ITEM* LIB_TEXT::doClone() const
}
int LIB_TEXT::DoCompare( const LIB_ITEM& other ) const
int LIB_TEXT::compare( const LIB_ITEM& other ) const
{
wxASSERT( other.Type() == LIB_TEXT_T );
@ -263,13 +262,13 @@ int LIB_TEXT::DoCompare( const LIB_ITEM& other ) const
}
void LIB_TEXT::DoOffset( const wxPoint& offset )
void LIB_TEXT::SetOffset( const wxPoint& aOffset )
{
m_Pos += offset;
m_Pos += aOffset;
}
bool LIB_TEXT::DoTestInside( EDA_RECT& rect ) const
bool LIB_TEXT::Inside( EDA_RECT& rect ) const
{
/*
* FIXME: This should calculate the text size and justification and
@ -279,27 +278,27 @@ bool LIB_TEXT::DoTestInside( EDA_RECT& rect ) const
}
void LIB_TEXT::DoMove( const wxPoint& newPosition )
void LIB_TEXT::Move( const wxPoint& newPosition )
{
m_Pos = newPosition;
}
void LIB_TEXT::DoMirrorHorizontal( const wxPoint& center )
void LIB_TEXT::MirrorHorizontal( const wxPoint& center )
{
m_Pos.x -= center.x;
m_Pos.x *= -1;
m_Pos.x += center.x;
}
void LIB_TEXT::DoMirrorVertical( const wxPoint& center )
void LIB_TEXT::MirrorVertical( const wxPoint& center )
{
m_Pos.y -= center.y;
m_Pos.y *= -1;
m_Pos.y += center.y;
}
void LIB_TEXT::DoRotate( const wxPoint& center, bool aRotateCCW )
void LIB_TEXT::Rotate( const wxPoint& center, bool aRotateCCW )
{
int rot_angle = aRotateCCW ? -900 : 900;
@ -308,8 +307,8 @@ void LIB_TEXT::DoRotate( const wxPoint& center, bool aRotateCCW )
}
void LIB_TEXT::DoPlot( PLOTTER* plotter, const wxPoint& offset, bool fill,
const TRANSFORM& aTransform )
void LIB_TEXT::Plot( PLOTTER* plotter, const wxPoint& offset, bool fill,
const TRANSFORM& aTransform )
{
wxASSERT( plotter != NULL );

View File

@ -2,7 +2,6 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2008-2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors.
*
* This program is free software; you can redistribute it and/or
@ -154,15 +153,67 @@ public:
*/
void EndEdit( const wxPoint& aPosition, bool aAbort = false );
/**
* @copydoc LIB_ITEM::SetOffset(const wxPoint&)
*/
virtual void SetOffset( const wxPoint& aOffset );
/**
* @copydoc LIB_ITEM::Inside()
*/
virtual bool Inside( EDA_RECT& aRect ) const;
/**
* @copydoc LIB_ITEM::Move()
*/
virtual void Move( const wxPoint& aPosition );
/**
* @copydoc LIB_ITEM::GetPosition()
*/
virtual wxPoint GetPosition() const { return m_Pos; }
/**
* @copydoc LIB_ITEM::MirrorHorizontal()
*/
virtual void MirrorHorizontal( const wxPoint& aCenter );
/**
* @copydoc LIB_ITEM::MirrorVertical()
*/
virtual void MirrorVertical( const wxPoint& aCenter );
/**
* @copydoc LIB_ITEM::Rotate(const wxPoint&,bool)
*/
virtual void Rotate( const wxPoint& aCenter, bool aRotateCCW = true );
/**
* @copydoc LIB_ITEM::Plot()
*/
virtual void Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill,
const TRANSFORM& aTransform );
/**
* @copydoc LIB_ITEM::GetWidth()
*/
virtual int GetWidth() const { return m_Thickness; }
/**
* @copydoc LIB_ITEM::SetWidth()
*/
virtual void SetWidth( int aWidth ) { m_Thickness = aWidth; }
virtual wxString GetSelectMenuText() const;
virtual BITMAP_DEF GetMenuImage() const { return add_text_xpm; }
protected:
private:
virtual EDA_ITEM* doClone() const;
/**
* Provide the text draw object specific comparison.
* Function compare
* provides the text draw object specific comparison.
*
* The sort order is as follows:
* - Text string, case insensitive compare.
@ -170,20 +221,13 @@ protected:
* - Text vertical (Y) position.
* - Text width.
* - Text height.
*
* @param aOther A reference to the other #LIB_ITEM to compare the text against.
* @return An integer value less than 0 if the text is less than \a aOther, zero
* if the text is equal to \a aOther, or greater than 0 if the text is
* greater than \a aOther.
*/
virtual int DoCompare( const LIB_ITEM& aOther ) const;
virtual void DoOffset( const wxPoint& aOffset );
virtual bool DoTestInside( EDA_RECT& aRect ) const;
virtual void DoMove( const wxPoint& aPosition );
virtual wxPoint DoGetPosition() const { return m_Pos; }
virtual void DoMirrorHorizontal( const wxPoint& aCenter );
virtual void DoMirrorVertical( const wxPoint& aCenter );
virtual void DoRotate( const wxPoint& aCenter, bool aRotateCCW = true );
virtual void DoPlot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill,
const TRANSFORM& aTransform );
virtual int DoGetWidth() const { return m_Thickness; }
virtual void DoSetWidth( int aWidth ) { m_Thickness = aWidth; }
virtual int compare( const LIB_ITEM& aOther ) const;
};