2008-09-13 18:59:57 +00:00
|
|
|
/****************************************************************/
|
2009-09-02 18:12:45 +00:00
|
|
|
/* Headers for library definition and lib component definitions */
|
2008-09-13 18:59:57 +00:00
|
|
|
/****************************************************************/
|
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
/* Definitions of graphic items used to create shapes in component libraries.
|
2009-01-02 17:07:50 +00:00
|
|
|
*/
|
2008-09-13 18:59:57 +00:00
|
|
|
#ifndef CLASSES_BODY_ITEMS_H
|
|
|
|
#define CLASSES_BODY_ITEMS_H
|
|
|
|
|
2009-09-25 18:49:04 +00:00
|
|
|
|
|
|
|
class LIB_COMPONENT;
|
|
|
|
class PLOTTER;
|
2009-10-01 14:17:47 +00:00
|
|
|
class LIB_DRAW_ITEM;
|
2009-10-14 19:43:31 +00:00
|
|
|
class LIB_PIN;
|
2009-09-25 18:49:04 +00:00
|
|
|
|
|
|
|
|
2010-02-04 17:46:12 +00:00
|
|
|
#define MINIMUM_SELECTION_DISTANCE 15 // Minimum selection distance in mils
|
2008-09-13 18:59:57 +00:00
|
|
|
|
|
|
|
|
2009-10-14 19:43:31 +00:00
|
|
|
/**
|
|
|
|
* Helper for defining a list of library draw object pointers. The Boost
|
|
|
|
* pointer containers are responsible for deleting object pointers placed
|
|
|
|
* in them. If you access a object pointer from the list, do not delete
|
|
|
|
* it directly.
|
|
|
|
*/
|
|
|
|
typedef boost::ptr_vector< LIB_DRAW_ITEM > LIB_DRAW_ITEM_LIST;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Helper for defining a list of pin object pointers. The list does not
|
|
|
|
* use a Boost pointer class so the ojbect pointers do not accidently get
|
|
|
|
* deleted when the container is deleted.
|
|
|
|
*/
|
|
|
|
typedef std::vector< LIB_PIN* > LIB_PIN_LIST;
|
|
|
|
|
|
|
|
|
2008-09-13 18:59:57 +00:00
|
|
|
/****************************************************************************/
|
2009-09-02 18:12:45 +00:00
|
|
|
/* Classes for handle the body items of a component: pins add graphic items */
|
2008-09-13 18:59:57 +00:00
|
|
|
/****************************************************************************/
|
|
|
|
|
|
|
|
|
2009-10-30 19:26:25 +00:00
|
|
|
/**
|
|
|
|
* Base class for drawable items used in library components.
|
2008-09-13 18:59:57 +00:00
|
|
|
* (graphic shapes, texts, fields, pins)
|
|
|
|
*/
|
2009-09-25 18:49:04 +00:00
|
|
|
class LIB_DRAW_ITEM : public EDA_BaseStruct
|
2008-09-13 18:59:57 +00:00
|
|
|
{
|
|
|
|
public:
|
2009-10-30 19:26:25 +00:00
|
|
|
/**
|
|
|
|
* Unit identification for multiple parts per package. Set to 0 if the
|
|
|
|
* item is common to all units.
|
|
|
|
*/
|
|
|
|
int m_Unit;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Shape identification for alternate body styles. Set 0 if the item
|
|
|
|
* is common to all body styles. This is commonly referred to as
|
|
|
|
* DeMorgan style and this is typically how it is used in Kicad.
|
|
|
|
*/
|
|
|
|
int m_Convert;
|
2009-09-04 18:57:37 +00:00
|
|
|
FILL_T m_Fill; /* NO_FILL, FILLED_SHAPE or FILLED_WITH_BG_BODYCOLOR.
|
2009-04-05 20:49:15 +00:00
|
|
|
* has meaning only for some items */
|
|
|
|
wxString m_typeName; /* Name of object displayed in the message panel. */
|
2008-09-13 18:59:57 +00:00
|
|
|
|
|
|
|
public:
|
2009-09-25 18:49:04 +00:00
|
|
|
LIB_DRAW_ITEM* Next()
|
2008-09-13 18:59:57 +00:00
|
|
|
{
|
2009-09-25 18:49:04 +00:00
|
|
|
return (LIB_DRAW_ITEM*) Pnext;
|
2008-09-13 18:59:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-12-15 21:11:05 +00:00
|
|
|
LIB_DRAW_ITEM( KICAD_T aType, LIB_COMPONENT * aParent );
|
|
|
|
LIB_DRAW_ITEM( const LIB_DRAW_ITEM& aItem );
|
2009-09-25 18:49:04 +00:00
|
|
|
virtual ~LIB_DRAW_ITEM() { }
|
2008-09-13 18:59:57 +00:00
|
|
|
|
2009-09-29 18:38:21 +00:00
|
|
|
/**
|
2009-12-15 21:11:05 +00:00
|
|
|
* Draw a body item
|
2009-10-30 19:26:25 +00:00
|
|
|
*
|
|
|
|
* @param aPanel - DrawPanel to use (can be null) mainly used for clipping
|
2009-04-05 20:49:15 +00:00
|
|
|
* purposes
|
2009-10-30 19:26:25 +00:00
|
|
|
* @param aDC - Device Context (can be null)
|
|
|
|
* @param aOffset - offset to draw
|
|
|
|
* @param aColor - -1 to use the normal body item color, or use this color
|
2009-04-05 20:49:15 +00:00
|
|
|
* if >= 0
|
2009-10-30 19:26:25 +00:00
|
|
|
* @param aDrawMode - GR_OR, GR_XOR, ...
|
|
|
|
* @param aData - value or pointer used to pass others parameters,
|
2009-04-05 20:49:15 +00:00
|
|
|
* depending on body items. used for some items to force
|
|
|
|
* to force no fill mode ( has meaning only for items what
|
|
|
|
* can be filled ). used in printing or moving objects mode
|
2009-09-02 18:12:45 +00:00
|
|
|
* or to pass reference to the lib component for pins
|
2009-10-30 19:26:25 +00:00
|
|
|
* @param aTransformMatrix - Transform Matrix (rotation, mirror ..)
|
2008-09-13 18:59:57 +00:00
|
|
|
*/
|
2009-04-05 20:49:15 +00:00
|
|
|
virtual void Draw( WinEDA_DrawPanel * aPanel, wxDC * aDC,
|
|
|
|
const wxPoint &aOffset, int aColor, int aDrawMode,
|
|
|
|
void* aData, const int aTransformMatrix[2][2] ) = 0;
|
2008-09-13 18:59:57 +00:00
|
|
|
|
2009-10-30 19:26:25 +00:00
|
|
|
/**
|
2009-06-30 17:57:27 +00:00
|
|
|
* @return the size of the "pen" that be used to draw or plot this item
|
|
|
|
*/
|
2009-12-15 21:11:05 +00:00
|
|
|
virtual int GetPenSize() = 0;
|
2009-06-30 17:57:27 +00:00
|
|
|
|
2008-09-18 17:10:54 +00:00
|
|
|
/**
|
2009-12-15 21:11:05 +00:00
|
|
|
* Write draw item object to /a aFile in "*.lib" format.
|
2009-10-30 19:26:25 +00:00
|
|
|
*
|
2009-12-15 21:11:05 +00:00
|
|
|
* @param aFile - The file to write to.
|
|
|
|
* @param aErrorMsg - Error message if write fails.
|
|
|
|
* @return - true if success writing else false.
|
2008-09-18 17:10:54 +00:00
|
|
|
*/
|
2009-10-30 19:26:25 +00:00
|
|
|
virtual bool Save( FILE* aFile ) = 0;
|
2009-12-15 21:11:05 +00:00
|
|
|
virtual bool Load( char* aLine, wxString& aErrorMsg ) = 0;
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2009-12-15 21:11:05 +00:00
|
|
|
LIB_COMPONENT* GetParent()
|
2009-06-18 13:30:52 +00:00
|
|
|
{
|
2009-09-18 14:56:05 +00:00
|
|
|
return (LIB_COMPONENT *)m_Parent;
|
2009-06-18 13:30:52 +00:00
|
|
|
}
|
2009-06-13 17:06:07 +00:00
|
|
|
|
|
|
|
/**
|
2009-10-30 19:26:25 +00:00
|
|
|
* Tests if the given point is within the bounds of this object.
|
|
|
|
*
|
2009-12-15 21:11:05 +00:00
|
|
|
* Derived classes should override this function.
|
|
|
|
*
|
|
|
|
* @param aPosition - The coordinats to test.
|
|
|
|
* @return - true if a hit, else false
|
2009-06-13 17:06:07 +00:00
|
|
|
*/
|
2009-12-15 21:11:05 +00:00
|
|
|
virtual bool HitTest( const wxPoint& aPosition )
|
2009-06-13 17:06:07 +00:00
|
|
|
{
|
2009-12-15 21:11:05 +00:00
|
|
|
return false;
|
2009-06-13 17:06:07 +00:00
|
|
|
}
|
|
|
|
|
2009-10-30 19:26:25 +00:00
|
|
|
/**
|
|
|
|
* @param aPosRef - a wxPoint to test
|
|
|
|
* @param aThreshold - max distance to this object (usually the half
|
2009-09-02 18:12:45 +00:00
|
|
|
* thickness of a line)
|
2009-10-30 19:26:25 +00:00
|
|
|
* @param aTransMat - the transform matrix
|
2009-12-15 21:11:05 +00:00
|
|
|
* @return - true if the point aPosRef is near this object
|
2009-06-13 17:06:07 +00:00
|
|
|
*/
|
2009-09-02 18:12:45 +00:00
|
|
|
virtual bool HitTest( wxPoint aPosRef, int aThreshold,
|
|
|
|
const int aTransMat[2][2] ) = 0;
|
2009-06-13 17:06:07 +00:00
|
|
|
|
2009-10-30 19:26:25 +00:00
|
|
|
/**
|
2009-06-13 17:06:07 +00:00
|
|
|
* @return the boundary box for this, in library coordinates
|
|
|
|
*/
|
2009-04-05 20:49:15 +00:00
|
|
|
virtual EDA_Rect GetBoundingBox()
|
|
|
|
{
|
|
|
|
return EDA_BaseStruct::GetBoundingBox();
|
|
|
|
}
|
2008-09-18 17:10:54 +00:00
|
|
|
|
2009-12-15 21:11:05 +00:00
|
|
|
virtual void DisplayInfo( WinEDA_DrawFrame* aFrame );
|
2009-09-02 18:12:45 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Make a copy of this draw item.
|
|
|
|
*
|
2009-09-25 18:49:04 +00:00
|
|
|
* Classes derived from LIB_DRAW_ITEM must implement DoGenCopy().
|
2009-09-02 18:12:45 +00:00
|
|
|
* This is just a placeholder for the derived class.
|
|
|
|
*
|
|
|
|
* @return Copy of this draw item.
|
|
|
|
*/
|
2009-09-25 18:49:04 +00:00
|
|
|
LIB_DRAW_ITEM* GenCopy() { return DoGenCopy(); }
|
2009-09-02 18:12:45 +00:00
|
|
|
|
2009-09-14 13:24:17 +00:00
|
|
|
/**
|
2009-09-25 18:49:04 +00:00
|
|
|
* Test LIB_DRAW_ITEM objects for equivalence.
|
2009-09-14 13:24:17 +00:00
|
|
|
*
|
2009-12-15 21:11:05 +00:00
|
|
|
* @param aOther - Object to test against.
|
|
|
|
* @return - True if object is identical to this object.
|
2009-09-14 13:24:17 +00:00
|
|
|
*/
|
2009-12-15 21:11:05 +00:00
|
|
|
bool operator==( const LIB_DRAW_ITEM& aOther ) const;
|
|
|
|
bool operator==( const LIB_DRAW_ITEM* aOther ) const
|
2009-09-14 13:24:17 +00:00
|
|
|
{
|
2009-12-15 21:11:05 +00:00
|
|
|
return *this == *aOther;
|
2009-09-14 13:24:17 +00:00
|
|
|
}
|
|
|
|
|
2009-10-01 14:17:47 +00:00
|
|
|
/**
|
|
|
|
* Test if another draw item is less than this draw object.
|
|
|
|
*
|
2009-12-15 21:11:05 +00:00
|
|
|
* @param aOther - Draw item to compare against.
|
|
|
|
* @return - True if object is less than this object.
|
2009-10-01 14:17:47 +00:00
|
|
|
*/
|
2009-12-15 21:11:05 +00:00
|
|
|
bool operator<( const LIB_DRAW_ITEM& aOther) const;
|
2009-10-01 14:17:47 +00:00
|
|
|
|
2009-09-14 13:24:17 +00:00
|
|
|
/**
|
|
|
|
* Set drawing object offset from the current position.
|
|
|
|
*
|
2009-12-15 21:11:05 +00:00
|
|
|
* @param aOffset - Cooridinates to offset position.
|
2009-09-14 13:24:17 +00:00
|
|
|
*/
|
2009-12-15 21:11:05 +00:00
|
|
|
void SetOffset( const wxPoint& aOffset ) { DoOffset( aOffset ); }
|
2009-09-14 13:24:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Test if any part of the draw object is inside rectangle bounds.
|
|
|
|
*
|
|
|
|
* This is used for block selection. The real work is done by the
|
|
|
|
* DoTestInside method for each derived object type.
|
|
|
|
*
|
2009-12-15 21:11:05 +00:00
|
|
|
* @param aRect - Rectangle to check against.
|
|
|
|
* @return - True if object is inside rectangle.
|
2009-09-14 13:24:17 +00:00
|
|
|
*/
|
2009-12-15 21:11:05 +00:00
|
|
|
bool Inside( EDA_Rect& aRect ) { return DoTestInside( aRect ); }
|
2009-09-14 13:24:17 +00:00
|
|
|
|
2009-09-25 18:49:04 +00:00
|
|
|
/**
|
2009-12-15 21:11:05 +00:00
|
|
|
* Move a draw object to a new /a aPosition.
|
2009-09-25 18:49:04 +00:00
|
|
|
*
|
|
|
|
* The real work is done by the DoMove method for each derived object type.
|
|
|
|
*
|
2009-12-15 21:11:05 +00:00
|
|
|
* @param aPosition - Position to move draw item to.
|
2009-09-25 18:49:04 +00:00
|
|
|
*/
|
2009-12-15 21:11:05 +00:00
|
|
|
void Move( const wxPoint& aPosition ) { DoMove( aPosition ); }
|
2009-09-25 18:49:04 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the current draw object start position.
|
|
|
|
*/
|
2009-12-15 21:11:05 +00:00
|
|
|
wxPoint GetPosition() { return DoGetPosition(); }
|
2009-09-25 18:49:04 +00:00
|
|
|
|
2009-09-29 18:38:21 +00:00
|
|
|
/**
|
|
|
|
* Mirror the draw object along the horizontal (X) axis about a point.
|
|
|
|
*
|
2009-12-15 21:11:05 +00:00
|
|
|
* @param aCenter - Point to mirror around.
|
2009-09-29 18:38:21 +00:00
|
|
|
*/
|
2009-12-15 21:11:05 +00:00
|
|
|
void MirrorHorizontal( const wxPoint& aCenter )
|
2009-09-29 18:38:21 +00:00
|
|
|
{
|
2009-12-15 21:11:05 +00:00
|
|
|
DoMirrorHorizontal( aCenter );
|
2009-09-29 18:38:21 +00:00
|
|
|
}
|
|
|
|
|
2009-10-05 17:52:41 +00:00
|
|
|
/**
|
|
|
|
* Plot the draw item using the plot object.
|
|
|
|
*
|
2009-12-15 21:11:05 +00:00
|
|
|
* @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.
|
2009-10-05 17:52:41 +00:00
|
|
|
*/
|
2009-12-15 21:11:05 +00:00
|
|
|
void Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill,
|
|
|
|
const int aTransform[2][2] )
|
2009-10-05 17:52:41 +00:00
|
|
|
{
|
2009-12-15 21:11:05 +00:00
|
|
|
DoPlot( aPlotter, aOffset, aFill, aTransform );
|
2009-10-05 17:52:41 +00:00
|
|
|
}
|
|
|
|
|
2009-10-08 13:19:28 +00:00
|
|
|
/**
|
|
|
|
* Return the width of the draw item.
|
|
|
|
*
|
2009-12-15 21:11:05 +00:00
|
|
|
* @return Width of draw object.
|
2009-10-08 13:19:28 +00:00
|
|
|
*/
|
2009-12-15 21:11:05 +00:00
|
|
|
int GetWidth() { return DoGetWidth(); }
|
|
|
|
void SetWidth( int aWidth ) { DoSetWidth( aWidth ); }
|
2009-10-08 13:19:28 +00:00
|
|
|
|
2009-10-20 19:36:58 +00:00
|
|
|
/**
|
|
|
|
* Check if draw object can be filled.
|
|
|
|
*
|
|
|
|
* The default setting is false. If the derived object support filling,
|
|
|
|
* set the m_isFillable member to true.
|
|
|
|
*
|
2009-12-15 21:11:05 +00:00
|
|
|
* @return - True if draw object can be fill. Default is false.
|
2009-10-20 19:36:58 +00:00
|
|
|
*/
|
2009-12-15 21:11:05 +00:00
|
|
|
bool IsFillable() { return m_isFillable; }
|
2009-10-20 19:36:58 +00:00
|
|
|
|
2009-10-30 19:26:25 +00:00
|
|
|
/**
|
|
|
|
* Return the modified status of the draw object.
|
|
|
|
*
|
2009-12-15 21:11:05 +00:00
|
|
|
* @return - True if the draw object has been modified.
|
2009-10-30 19:26:25 +00:00
|
|
|
*/
|
2009-12-15 21:11:05 +00:00
|
|
|
bool IsModified() { return ( m_Flags & IS_CHANGED ) != 0; }
|
2009-10-30 19:26:25 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the new item status of the draw object.
|
|
|
|
*
|
2009-12-15 21:11:05 +00:00
|
|
|
* @return - True if the draw item has been added to the parent component.
|
2009-10-30 19:26:25 +00:00
|
|
|
*/
|
2009-12-15 21:11:05 +00:00
|
|
|
bool IsNew() { return ( m_Flags & IS_NEW ) != 0; }
|
2009-10-30 19:26:25 +00:00
|
|
|
|
2009-09-02 18:12:45 +00:00
|
|
|
protected:
|
2009-09-25 18:49:04 +00:00
|
|
|
virtual LIB_DRAW_ITEM* DoGenCopy() = 0;
|
2009-09-14 13:24:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Provide the draw object specific comparison.
|
|
|
|
*
|
2009-10-05 17:52:41 +00:00
|
|
|
* This is called by the == and < operators.
|
|
|
|
*
|
|
|
|
* The sort order is as follows:
|
|
|
|
* - Component alternate part (DeMorgan) number.
|
|
|
|
* - Component part number.
|
|
|
|
* - KICAD_T enum value.
|
|
|
|
* - Result of derived classes comparison.
|
2009-09-14 13:24:17 +00:00
|
|
|
*/
|
2009-12-15 21:11:05 +00:00
|
|
|
virtual int DoCompare( const LIB_DRAW_ITEM& aOther ) const = 0;
|
|
|
|
virtual void DoOffset( const wxPoint& aOffset ) = 0;
|
|
|
|
virtual bool DoTestInside( EDA_Rect& aRect ) = 0;
|
|
|
|
virtual void DoMove( const wxPoint& aPosition ) = 0;
|
|
|
|
virtual wxPoint DoGetPosition() = 0;
|
|
|
|
virtual void DoMirrorHorizontal( const wxPoint& aCenter ) = 0;
|
|
|
|
virtual void DoPlot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill,
|
|
|
|
const int aTransform[2][2] ) = 0;
|
|
|
|
virtual int DoGetWidth() = 0;
|
|
|
|
virtual void DoSetWidth( int aWidth ) = 0;
|
2009-10-20 19:36:58 +00:00
|
|
|
|
|
|
|
/** Flag to indicate if draw item is fillable. Default is false. */
|
|
|
|
bool m_isFillable;
|
2008-09-13 18:59:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**************************/
|
|
|
|
/* Graphic Body Item: Arc */
|
|
|
|
/**************************/
|
|
|
|
|
2009-10-08 13:19:28 +00:00
|
|
|
class LIB_ARC : public LIB_DRAW_ITEM
|
2008-09-13 18:59:57 +00:00
|
|
|
{
|
|
|
|
public:
|
2009-09-14 13:24:17 +00:00
|
|
|
int m_Radius;
|
2009-10-30 19:26:25 +00:00
|
|
|
int m_t1; /* First radius angle of the arc in 0.1 degrees. */
|
|
|
|
int m_t2; /* Second radius angle of the arc in 0.1 degrees. */
|
2009-04-05 20:49:15 +00:00
|
|
|
wxPoint m_ArcStart;
|
2009-10-30 19:26:25 +00:00
|
|
|
wxPoint m_ArcEnd; /* Arc end position. */
|
|
|
|
wxPoint m_Pos; /* Radius center point. */
|
2009-04-05 20:49:15 +00:00
|
|
|
int m_Width; /* Line width */
|
2008-09-13 18:59:57 +00:00
|
|
|
|
|
|
|
public:
|
2009-10-08 13:19:28 +00:00
|
|
|
LIB_ARC(LIB_COMPONENT * aParent);
|
2009-12-15 21:11:05 +00:00
|
|
|
LIB_ARC( const LIB_ARC& aArc );
|
2009-10-08 13:19:28 +00:00
|
|
|
~LIB_ARC() { }
|
2008-09-13 18:59:57 +00:00
|
|
|
virtual wxString GetClass() const
|
|
|
|
{
|
2009-10-08 13:19:28 +00:00
|
|
|
return wxT( "LIB_ARC" );
|
2008-09-13 18:59:57 +00:00
|
|
|
}
|
2008-12-16 19:44:57 +00:00
|
|
|
|
|
|
|
|
2008-09-18 17:10:54 +00:00
|
|
|
/**
|
2009-10-30 19:26:25 +00:00
|
|
|
* Save arc object to a FILE in "*.lib" format.
|
|
|
|
*
|
2008-09-18 17:10:54 +00:00
|
|
|
* @param aFile The FILE to write to.
|
2009-12-15 21:11:05 +00:00
|
|
|
* @return - True if success writing else false.
|
2008-09-18 17:10:54 +00:00
|
|
|
*/
|
2009-10-30 19:26:25 +00:00
|
|
|
virtual bool Save( FILE* aFile );
|
2009-12-15 21:11:05 +00:00
|
|
|
virtual bool Load( char* aLine, wxString& aErrorMsg );
|
2008-09-13 18:59:57 +00:00
|
|
|
|
2009-06-11 14:26:17 +00:00
|
|
|
/**
|
2009-10-30 19:26:25 +00:00
|
|
|
* Tests if the given wxPoint is within the bounds of this object.
|
|
|
|
*
|
2009-12-15 21:11:05 +00:00
|
|
|
* @param aRefPos - Coordinates to test
|
|
|
|
* @return - True if a hit, else false
|
2009-06-11 14:26:17 +00:00
|
|
|
*/
|
|
|
|
virtual bool HitTest( const wxPoint& aRefPos );
|
2009-06-13 17:06:07 +00:00
|
|
|
|
2009-10-30 19:26:25 +00:00
|
|
|
/**
|
|
|
|
* @param aPosRef - a wxPoint to test
|
|
|
|
* @param aThreshold - max distance to this object (usually the half
|
2009-09-02 18:12:45 +00:00
|
|
|
* thickness of a line)
|
2009-10-30 19:26:25 +00:00
|
|
|
* @param aTransMat - the transform matrix
|
2009-12-15 21:11:05 +00:00
|
|
|
* @return - True if the point aPosRef is near this object
|
2009-06-13 17:06:07 +00:00
|
|
|
*/
|
2009-09-02 18:12:45 +00:00
|
|
|
virtual bool HitTest( wxPoint aPosRef, int aThreshold,
|
|
|
|
const int aTransMat[2][2] );
|
2008-12-16 19:44:57 +00:00
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
void Draw( WinEDA_DrawPanel * aPanel, wxDC * aDC, const wxPoint &aOffset,
|
|
|
|
int aColor, int aDrawMode, void* aData,
|
|
|
|
const int aTransformMatrix[2][2] );
|
|
|
|
|
|
|
|
virtual EDA_Rect GetBoundingBox();
|
|
|
|
virtual void DisplayInfo( WinEDA_DrawFrame* frame );
|
2009-10-30 19:26:25 +00:00
|
|
|
/**
|
2009-06-30 17:57:27 +00:00
|
|
|
* @return the size of the "pen" that be used to draw or plot this item
|
|
|
|
*/
|
|
|
|
virtual int GetPenSize( );
|
|
|
|
|
2009-09-02 18:12:45 +00:00
|
|
|
protected:
|
2009-09-25 18:49:04 +00:00
|
|
|
virtual LIB_DRAW_ITEM* DoGenCopy();
|
2009-10-05 17:52:41 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Provide 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.
|
|
|
|
*/
|
2009-12-15 21:11:05 +00:00
|
|
|
virtual int DoCompare( const LIB_DRAW_ITEM& aOther ) const;
|
|
|
|
virtual void DoOffset( const wxPoint& aOffset );
|
|
|
|
virtual bool DoTestInside( EDA_Rect& aRect );
|
|
|
|
virtual void DoMove( const wxPoint& aPosition );
|
|
|
|
virtual wxPoint DoGetPosition() { return m_Pos; }
|
|
|
|
virtual void DoMirrorHorizontal( const wxPoint& aCenter );
|
|
|
|
virtual void DoPlot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill,
|
|
|
|
const int aTransform[2][2] );
|
|
|
|
virtual int DoGetWidth() { return m_Width; }
|
|
|
|
virtual void DoSetWidth( int aWidth ) { m_Width = aWidth; }
|
2008-09-13 18:59:57 +00:00
|
|
|
};
|
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2008-09-13 18:59:57 +00:00
|
|
|
/*****************************/
|
|
|
|
/* Graphic Body Item: Circle */
|
|
|
|
/*****************************/
|
2009-10-08 13:19:28 +00:00
|
|
|
class LIB_CIRCLE : public LIB_DRAW_ITEM
|
2008-09-13 18:59:57 +00:00
|
|
|
{
|
|
|
|
public:
|
2009-09-14 13:24:17 +00:00
|
|
|
int m_Radius;
|
2009-04-05 20:49:15 +00:00
|
|
|
wxPoint m_Pos; /* Position or centre (Arc and Circle) or start
|
|
|
|
* point (segments) */
|
|
|
|
int m_Width; /* Line width */
|
2008-09-13 18:59:57 +00:00
|
|
|
|
|
|
|
public:
|
2009-10-08 13:19:28 +00:00
|
|
|
LIB_CIRCLE(LIB_COMPONENT * aParent);
|
2009-12-15 21:11:05 +00:00
|
|
|
LIB_CIRCLE( const LIB_CIRCLE& aCircle );
|
2009-10-08 13:19:28 +00:00
|
|
|
~LIB_CIRCLE() { }
|
2008-09-13 18:59:57 +00:00
|
|
|
virtual wxString GetClass() const
|
|
|
|
{
|
2009-10-08 13:19:28 +00:00
|
|
|
return wxT( "LIB_CIRCLE" );
|
2008-09-13 18:59:57 +00:00
|
|
|
}
|
2008-12-16 19:44:57 +00:00
|
|
|
|
|
|
|
|
2008-09-18 17:10:54 +00:00
|
|
|
/**
|
2009-10-30 19:26:25 +00:00
|
|
|
* Write circle object to a FILE in "*.lib" format.
|
|
|
|
*
|
|
|
|
* @param aFile - The FILE to write to.
|
2009-12-15 21:11:05 +00:00
|
|
|
* @return - true if success writing else false.
|
2008-09-18 17:10:54 +00:00
|
|
|
*/
|
2009-10-30 19:26:25 +00:00
|
|
|
virtual bool Save( FILE* aFile );
|
2009-12-15 21:11:05 +00:00
|
|
|
virtual bool Load( char* aLine, wxString& aErrorMsg );
|
2008-09-13 18:59:57 +00:00
|
|
|
|
2009-06-11 14:26:17 +00:00
|
|
|
/**
|
2009-10-30 19:26:25 +00:00
|
|
|
* Test if the given point is within the bounds of this object.
|
|
|
|
*
|
|
|
|
* @param aRefPos - A wxPoint to test
|
2009-06-11 14:26:17 +00:00
|
|
|
* @return bool - true if a hit, else false
|
|
|
|
*/
|
|
|
|
virtual bool HitTest( const wxPoint& aRefPos );
|
|
|
|
|
2009-10-30 19:26:25 +00:00
|
|
|
/**
|
|
|
|
* @param aPosRef - a wxPoint to test
|
|
|
|
* @param aThreshold - max distance to this object (usually the half
|
|
|
|
* thickness of a line)
|
|
|
|
* @param aTransMat - the transform matrix
|
|
|
|
* @return true if the point aPosRef is near this object
|
|
|
|
*/
|
2009-09-02 18:12:45 +00:00
|
|
|
virtual bool HitTest( wxPoint aPosRef, int aThreshold,
|
|
|
|
const int aTransMat[2][2] );
|
2008-12-16 19:44:57 +00:00
|
|
|
|
2009-10-30 19:26:25 +00:00
|
|
|
/**
|
2009-06-30 17:57:27 +00:00
|
|
|
* @return the size of the "pen" that be used to draw or plot this item
|
|
|
|
*/
|
|
|
|
virtual int GetPenSize( );
|
|
|
|
|
2009-12-15 21:11:05 +00:00
|
|
|
void Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, const wxPoint &aOffset,
|
2009-04-05 20:49:15 +00:00
|
|
|
int aColor, int aDrawMode, void* aData,
|
|
|
|
const int aTransformMatrix[2][2] );
|
|
|
|
|
|
|
|
virtual EDA_Rect GetBoundingBox();
|
2009-12-15 21:11:05 +00:00
|
|
|
virtual void DisplayInfo( WinEDA_DrawFrame* aFrame );
|
2009-09-02 18:12:45 +00:00
|
|
|
|
|
|
|
protected:
|
2009-09-25 18:49:04 +00:00
|
|
|
virtual LIB_DRAW_ITEM* DoGenCopy();
|
2009-10-05 17:52:41 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Provide the circle draw object specific comparison.
|
|
|
|
*
|
|
|
|
* The sort order is as follows:
|
|
|
|
* - Circle horizontal (X) position.
|
|
|
|
* - Circle vertical (Y) position.
|
|
|
|
* - Circle radius.
|
|
|
|
*/
|
2009-12-15 21:11:05 +00:00
|
|
|
virtual int DoCompare( const LIB_DRAW_ITEM& aOther ) const;
|
|
|
|
|
|
|
|
virtual void DoOffset( const wxPoint& aOffset );
|
|
|
|
virtual bool DoTestInside( EDA_Rect& aRect );
|
|
|
|
virtual void DoMove( const wxPoint& aPosition );
|
|
|
|
virtual wxPoint DoGetPosition() { return m_Pos; }
|
|
|
|
virtual void DoMirrorHorizontal( const wxPoint& aCenter );
|
|
|
|
virtual void DoPlot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill,
|
|
|
|
const int aTransform[2][2] );
|
|
|
|
virtual int DoGetWidth() { return m_Width; }
|
|
|
|
virtual void DoSetWidth( int aWidth ) { m_Width = aWidth; }
|
2008-09-13 18:59:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/*********************************************/
|
|
|
|
/* Graphic Body Item: Text */
|
|
|
|
/* This is only a graphic text. */
|
|
|
|
/* Fields like Ref , value... are not Text, */
|
|
|
|
/* they are a separate class */
|
|
|
|
/*********************************************/
|
2009-10-08 13:19:28 +00:00
|
|
|
class LIB_TEXT : public LIB_DRAW_ITEM, public EDA_TextStruct
|
2008-09-13 18:59:57 +00:00
|
|
|
{
|
|
|
|
public:
|
2009-10-08 13:19:28 +00:00
|
|
|
LIB_TEXT(LIB_COMPONENT * aParent);
|
2009-12-15 21:11:05 +00:00
|
|
|
LIB_TEXT( const LIB_TEXT& aText );
|
2009-10-08 13:19:28 +00:00
|
|
|
~LIB_TEXT() { }
|
2008-09-13 18:59:57 +00:00
|
|
|
virtual wxString GetClass() const
|
|
|
|
{
|
2009-10-08 13:19:28 +00:00
|
|
|
return wxT( "LIB_TEXT" );
|
2008-09-13 18:59:57 +00:00
|
|
|
}
|
2008-12-16 19:44:57 +00:00
|
|
|
|
|
|
|
|
2008-09-18 17:10:54 +00:00
|
|
|
/**
|
2009-10-30 19:26:25 +00:00
|
|
|
* Write text object out to a FILE in "*.lib" format.
|
|
|
|
*
|
|
|
|
* @param aFile - The FILE to write to.
|
2009-12-15 21:11:05 +00:00
|
|
|
* @return - true if success writing else false.
|
2008-09-18 17:10:54 +00:00
|
|
|
*/
|
2009-10-30 19:26:25 +00:00
|
|
|
virtual bool Save( FILE* aFile );
|
2009-12-15 21:11:05 +00:00
|
|
|
virtual bool Load( char* aLine, wxString& aErrorMsg );
|
2008-09-13 18:59:57 +00:00
|
|
|
|
2009-06-11 14:26:17 +00:00
|
|
|
/**
|
2009-10-30 19:26:25 +00:00
|
|
|
* Test if the given point is within the bounds of this object.
|
|
|
|
*
|
|
|
|
* @param refPos - A wxPoint to test
|
2009-12-15 21:11:05 +00:00
|
|
|
* @return - true if a hit, else false
|
2009-06-11 14:26:17 +00:00
|
|
|
*/
|
2009-10-01 14:17:47 +00:00
|
|
|
virtual bool HitTest( const wxPoint& refPos );
|
2009-06-11 14:26:17 +00:00
|
|
|
|
2009-10-30 19:26:25 +00:00
|
|
|
/**
|
|
|
|
* @param aPosRef = a wxPoint to test, in eeschema coordinates
|
|
|
|
* @param aThreshold = max distance to a segment
|
|
|
|
* @param aTransMat = the transform matrix
|
|
|
|
* @return true if the point aPosRef is near a segment
|
|
|
|
*/
|
2009-09-02 18:12:45 +00:00
|
|
|
virtual bool HitTest( wxPoint aPosRef, int aThreshold,
|
|
|
|
const int aTransMat[2][2] );
|
2009-06-13 17:06:07 +00:00
|
|
|
|
2009-06-11 14:26:17 +00:00
|
|
|
/**
|
2009-10-30 19:26:25 +00:00
|
|
|
* Test if the given rectangle intersects this object.
|
|
|
|
*
|
2009-06-11 14:26:17 +00:00
|
|
|
* For now, an ending point must be inside this rect.
|
2009-10-30 19:26:25 +00:00
|
|
|
*
|
2009-12-15 21:11:05 +00:00
|
|
|
* @param aRect - the given EDA_Rect
|
|
|
|
* @return - true if a hit, else false
|
2009-06-11 14:26:17 +00:00
|
|
|
*/
|
2009-12-15 21:11:05 +00:00
|
|
|
virtual bool HitTest( EDA_Rect& aRect )
|
2009-06-11 14:26:17 +00:00
|
|
|
{
|
2009-12-15 21:11:05 +00:00
|
|
|
return TextHitTest( aRect );
|
2009-06-11 14:26:17 +00:00
|
|
|
}
|
|
|
|
|
2009-10-30 19:26:25 +00:00
|
|
|
/**
|
2009-06-30 17:57:27 +00:00
|
|
|
* @return the size of the "pen" that be used to draw or plot this item
|
|
|
|
*/
|
|
|
|
virtual int GetPenSize( );
|
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
void Draw( WinEDA_DrawPanel * aPanel, wxDC * aDC, const wxPoint &aOffset,
|
|
|
|
int aColor, int aDrawMode, void* aData,
|
|
|
|
const int aTransformMatrix[2][2] );
|
|
|
|
|
2009-12-15 21:11:05 +00:00
|
|
|
virtual void DisplayInfo( WinEDA_DrawFrame* aFrame );
|
2009-09-02 18:12:45 +00:00
|
|
|
|
2009-10-01 14:17:47 +00:00
|
|
|
virtual EDA_Rect GetBoundingBox();
|
|
|
|
|
2009-09-02 18:12:45 +00:00
|
|
|
protected:
|
2009-09-25 18:49:04 +00:00
|
|
|
virtual LIB_DRAW_ITEM* DoGenCopy();
|
2009-10-05 17:52:41 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Provide the text draw object specific comparison.
|
|
|
|
*
|
|
|
|
* The sort order is as follows:
|
|
|
|
* - Text string, case insensitive compare.
|
|
|
|
* - Text horizontal (X) position.
|
|
|
|
* - Text vertical (Y) position.
|
|
|
|
* - Text width.
|
|
|
|
* - Text height.
|
|
|
|
*/
|
2009-12-15 21:11:05 +00:00
|
|
|
virtual int DoCompare( const LIB_DRAW_ITEM& aOther ) const;
|
|
|
|
|
|
|
|
virtual void DoOffset( const wxPoint& aOffset );
|
|
|
|
virtual bool DoTestInside( EDA_Rect& aRect );
|
|
|
|
virtual void DoMove( const wxPoint& aPosition );
|
|
|
|
virtual wxPoint DoGetPosition() { return m_Pos; }
|
|
|
|
virtual void DoMirrorHorizontal( const wxPoint& aCenter );
|
|
|
|
virtual void DoPlot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill,
|
|
|
|
const int aTransform[2][2] );
|
|
|
|
virtual int DoGetWidth() { return m_Width; }
|
|
|
|
virtual void DoSetWidth( int aWidth ) { m_Width = aWidth; }
|
2008-09-13 18:59:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/********************************/
|
|
|
|
/* Graphic Body Item: Rectangle */
|
|
|
|
/********************************/
|
2009-10-08 13:19:28 +00:00
|
|
|
class LIB_RECTANGLE : public LIB_DRAW_ITEM
|
2008-09-13 18:59:57 +00:00
|
|
|
{
|
|
|
|
public:
|
2009-04-05 20:49:15 +00:00
|
|
|
wxPoint m_End; /* Rectangle end point. */
|
|
|
|
wxPoint m_Pos; /* Rectangle start point. */
|
|
|
|
int m_Width; /* Line width */
|
2010-02-04 17:46:12 +00:00
|
|
|
bool m_isWidthLocked; /* Flag: Keep width locked */
|
|
|
|
bool m_isHeightLocked; /* Flag: Keep height locked */
|
|
|
|
bool m_isStartPointSelected; /* Flag: is the upper left edge selected ? */
|
2008-09-13 18:59:57 +00:00
|
|
|
|
|
|
|
public:
|
2009-10-08 13:19:28 +00:00
|
|
|
LIB_RECTANGLE(LIB_COMPONENT * aParent);
|
2009-12-15 21:11:05 +00:00
|
|
|
LIB_RECTANGLE( const LIB_RECTANGLE& aRect );
|
2009-10-08 13:19:28 +00:00
|
|
|
~LIB_RECTANGLE() { }
|
2008-09-13 18:59:57 +00:00
|
|
|
virtual wxString GetClass() const
|
|
|
|
{
|
2009-10-08 13:19:28 +00:00
|
|
|
return wxT( "LIB_RECTANGLE" );
|
2008-09-13 18:59:57 +00:00
|
|
|
}
|
2008-12-16 19:44:57 +00:00
|
|
|
|
|
|
|
|
2008-09-18 17:10:54 +00:00
|
|
|
/**
|
2009-10-30 19:26:25 +00:00
|
|
|
* Write rectangle object out to a FILE in "*.lib" format.
|
|
|
|
*
|
|
|
|
* @param aFile - The FILE to write to.
|
2009-12-15 21:11:05 +00:00
|
|
|
* @return - true if success writing else false.
|
2008-09-18 17:10:54 +00:00
|
|
|
*/
|
2009-10-30 19:26:25 +00:00
|
|
|
virtual bool Save( FILE* aFile );
|
2009-12-15 21:11:05 +00:00
|
|
|
virtual bool Load( char* aLine, wxString& aErrorMsg );
|
2008-09-13 18:59:57 +00:00
|
|
|
|
2009-06-13 17:06:07 +00:00
|
|
|
/**
|
2009-10-30 19:26:25 +00:00
|
|
|
* Test if the given point is within the bounds of this object.
|
|
|
|
*
|
|
|
|
* @param aRefPos - A wxPoint to test
|
2009-12-15 21:11:05 +00:00
|
|
|
* @return - true if a hit, else false
|
2009-06-13 17:06:07 +00:00
|
|
|
*/
|
|
|
|
virtual bool HitTest( const wxPoint& aRefPos );
|
|
|
|
|
2009-10-30 19:26:25 +00:00
|
|
|
/**
|
|
|
|
* @param aPosRef - a wxPoint to test
|
|
|
|
* @param aThreshold - max distance to this object (usually the half
|
2009-09-02 18:12:45 +00:00
|
|
|
* thickness of a line)
|
2009-10-30 19:26:25 +00:00
|
|
|
* @param aTransMat - the transform matrix
|
|
|
|
* @return true if the point aPosRef is near this object
|
2009-06-13 17:06:07 +00:00
|
|
|
*/
|
2009-09-02 18:12:45 +00:00
|
|
|
virtual bool HitTest( wxPoint aPosRef, int aThreshold,
|
|
|
|
const int aTransMat[2][2] );
|
2008-09-13 18:59:57 +00:00
|
|
|
|
2009-10-30 19:26:25 +00:00
|
|
|
/**
|
2009-06-30 17:57:27 +00:00
|
|
|
* @return the size of the "pen" that be used to draw or plot this item
|
|
|
|
*/
|
|
|
|
virtual int GetPenSize( );
|
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
void Draw( WinEDA_DrawPanel * aPanel, wxDC * aDC, const wxPoint &aOffset,
|
|
|
|
int aColor, int aDrawMode, void* aData,
|
|
|
|
const int aTransformMatrix[2][2] );
|
|
|
|
|
|
|
|
virtual EDA_Rect GetBoundingBox();
|
2009-12-15 21:11:05 +00:00
|
|
|
virtual void DisplayInfo( WinEDA_DrawFrame* aFrame );
|
2009-09-02 18:12:45 +00:00
|
|
|
|
|
|
|
protected:
|
2009-09-25 18:49:04 +00:00
|
|
|
virtual LIB_DRAW_ITEM* DoGenCopy();
|
2009-10-05 17:52:41 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Provide 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.
|
|
|
|
*/
|
2009-12-15 21:11:05 +00:00
|
|
|
virtual int DoCompare( const LIB_DRAW_ITEM& aOther ) const;
|
|
|
|
|
|
|
|
virtual void DoOffset( const wxPoint& aOffset );
|
|
|
|
virtual bool DoTestInside( EDA_Rect& aRect );
|
|
|
|
virtual void DoMove( const wxPoint& aPosition );
|
|
|
|
virtual wxPoint DoGetPosition() { return m_Pos; }
|
|
|
|
virtual void DoMirrorHorizontal( const wxPoint& aCenter );
|
|
|
|
virtual void DoPlot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill,
|
|
|
|
const int aTransform[2][2] );
|
|
|
|
virtual int DoGetWidth() { return m_Width; }
|
|
|
|
virtual void DoSetWidth( int aWidth ) { m_Width = aWidth; }
|
2008-09-13 18:59:57 +00:00
|
|
|
};
|
|
|
|
|
2009-12-15 21:11:05 +00:00
|
|
|
|
2008-09-13 18:59:57 +00:00
|
|
|
/**********************************/
|
|
|
|
/* Graphic Body Item: single line */
|
|
|
|
/**********************************/
|
2009-10-08 13:19:28 +00:00
|
|
|
class LIB_SEGMENT : public LIB_DRAW_ITEM
|
2008-09-13 18:59:57 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
wxPoint m_End;
|
2009-10-30 19:26:25 +00:00
|
|
|
wxPoint m_Pos; /* Segment start point */
|
2009-04-05 20:49:15 +00:00
|
|
|
int m_Width; /* Line width */
|
2008-09-13 18:59:57 +00:00
|
|
|
|
|
|
|
public:
|
2009-10-08 13:19:28 +00:00
|
|
|
LIB_SEGMENT(LIB_COMPONENT * aParent);
|
2009-12-15 21:11:05 +00:00
|
|
|
LIB_SEGMENT( const LIB_SEGMENT& aSegment );
|
2009-10-08 13:19:28 +00:00
|
|
|
~LIB_SEGMENT() { }
|
2008-09-13 18:59:57 +00:00
|
|
|
virtual wxString GetClass() const
|
|
|
|
{
|
2009-10-08 13:19:28 +00:00
|
|
|
return wxT( "LIB_SEGMENT" );
|
2008-09-13 18:59:57 +00:00
|
|
|
}
|
2008-12-16 19:44:57 +00:00
|
|
|
|
|
|
|
|
2008-09-18 17:10:54 +00:00
|
|
|
/**
|
2009-10-30 19:26:25 +00:00
|
|
|
* Writes segment object out to a FILE in "*.lib" format.
|
|
|
|
*
|
|
|
|
* @param aFile - The FILE to write to.
|
2009-12-15 21:11:05 +00:00
|
|
|
* @return - true if success writing else false.
|
2008-09-18 17:10:54 +00:00
|
|
|
*/
|
2009-10-30 19:26:25 +00:00
|
|
|
virtual bool Save( FILE* aFile );
|
2009-12-15 21:11:05 +00:00
|
|
|
virtual bool Load( char* aLine, wxString& aErrorMsg );
|
2008-09-13 18:59:57 +00:00
|
|
|
|
2009-06-13 17:06:07 +00:00
|
|
|
/**
|
2009-10-30 19:26:25 +00:00
|
|
|
* Test if the given point is within the bounds of this object.
|
|
|
|
*
|
|
|
|
* @param aRefPos - A wxPoint to test
|
2009-06-13 17:06:07 +00:00
|
|
|
* @return bool - true if a hit, else false
|
|
|
|
*/
|
|
|
|
virtual bool HitTest( const wxPoint& aRefPos );
|
|
|
|
|
2009-10-30 19:26:25 +00:00
|
|
|
/**
|
2009-06-13 17:06:07 +00:00
|
|
|
* @param aPosRef = a wxPoint to test
|
2009-09-02 18:12:45 +00:00
|
|
|
* @param aThreshold = max distance to this object (usually the half
|
|
|
|
* thickness of a line)
|
2009-06-13 17:06:07 +00:00
|
|
|
* @param aTransMat = the transform matrix
|
2009-10-30 19:26:25 +00:00
|
|
|
* @return true if the point aPosRef is near this object
|
2009-06-13 17:06:07 +00:00
|
|
|
*/
|
2009-09-02 18:12:45 +00:00
|
|
|
virtual bool HitTest( wxPoint aPosRef, int aThreshold,
|
|
|
|
const int aTransMat[2][2] );
|
2008-12-16 19:44:57 +00:00
|
|
|
|
2009-10-30 19:26:25 +00:00
|
|
|
/**
|
2009-06-30 17:57:27 +00:00
|
|
|
* @return the size of the "pen" that be used to draw or plot this item
|
|
|
|
*/
|
|
|
|
virtual int GetPenSize( );
|
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
void Draw( WinEDA_DrawPanel * aPanel, wxDC * aDC, const wxPoint &aOffset,
|
|
|
|
int aColor, int aDrawMode, void* aData,
|
|
|
|
const int aTransformMatrix[2][2] );
|
|
|
|
|
2009-12-15 21:11:05 +00:00
|
|
|
virtual void DisplayInfo( WinEDA_DrawFrame* aFrame );
|
2009-09-02 18:12:45 +00:00
|
|
|
|
|
|
|
protected:
|
2009-09-25 18:49:04 +00:00
|
|
|
virtual LIB_DRAW_ITEM* DoGenCopy();
|
2009-10-05 17:52:41 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Provide the line segment draw object specific comparison.
|
|
|
|
*
|
|
|
|
* The sort order is as follows:
|
|
|
|
* - Line segment horizontal (X) start position.
|
|
|
|
* - Line segment vertical (Y) start position.
|
|
|
|
* - Line segment horizontal (X) end position.
|
|
|
|
* - Line segment vertical (Y) end position.
|
|
|
|
*/
|
2009-12-15 21:11:05 +00:00
|
|
|
virtual int DoCompare( const LIB_DRAW_ITEM& aOther ) const;
|
|
|
|
|
|
|
|
virtual void DoOffset( const wxPoint& aOffset );
|
|
|
|
virtual bool DoTestInside( EDA_Rect& aRect );
|
|
|
|
virtual void DoMove( const wxPoint& aPosition );
|
|
|
|
virtual wxPoint DoGetPosition() { return m_Pos; }
|
|
|
|
virtual void DoMirrorHorizontal( const wxPoint& aCenter );
|
|
|
|
virtual void DoPlot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill,
|
|
|
|
const int aTransform[2][2] );
|
|
|
|
virtual int DoGetWidth() { return m_Width; }
|
|
|
|
virtual void DoSetWidth( int aWidth ) { m_Width = aWidth; }
|
2008-09-13 18:59:57 +00:00
|
|
|
};
|
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2009-01-02 13:19:34 +00:00
|
|
|
/**********************************************************/
|
|
|
|
/* Graphic Body Item: Polygon and polyline (set of lines) */
|
|
|
|
/**********************************************************/
|
2009-10-08 13:19:28 +00:00
|
|
|
class LIB_POLYLINE : public LIB_DRAW_ITEM
|
2008-09-13 18:59:57 +00:00
|
|
|
{
|
|
|
|
public:
|
2009-04-05 20:49:15 +00:00
|
|
|
int m_Width; /* Line width */
|
2009-01-02 17:07:50 +00:00
|
|
|
std::vector<wxPoint> m_PolyPoints; // list of points (>= 2)
|
2010-02-04 17:46:12 +00:00
|
|
|
int m_ModifyIndex; // Index of the polyline point to modify
|
2008-09-13 18:59:57 +00:00
|
|
|
|
|
|
|
public:
|
2009-10-08 13:19:28 +00:00
|
|
|
LIB_POLYLINE(LIB_COMPONENT * aParent);
|
2009-12-15 21:11:05 +00:00
|
|
|
LIB_POLYLINE( const LIB_POLYLINE& aPolyline );
|
2009-10-08 13:19:28 +00:00
|
|
|
~LIB_POLYLINE() { }
|
2008-09-13 18:59:57 +00:00
|
|
|
|
|
|
|
virtual wxString GetClass() const
|
|
|
|
{
|
2009-10-08 13:19:28 +00:00
|
|
|
return wxT( "LIB_POLYLINE" );
|
2008-09-13 18:59:57 +00:00
|
|
|
}
|
|
|
|
|
2008-12-16 19:44:57 +00:00
|
|
|
|
2008-09-18 17:10:54 +00:00
|
|
|
/**
|
2009-10-30 19:26:25 +00:00
|
|
|
* Write polyline object out to a FILE in "*.lib" format.
|
|
|
|
*
|
|
|
|
* @param aFile - The FILE to write to.
|
2009-12-15 21:11:05 +00:00
|
|
|
* @return - true if success writing else false.
|
2008-09-18 17:10:54 +00:00
|
|
|
*/
|
2009-10-30 19:26:25 +00:00
|
|
|
virtual bool Save( FILE* aFile );
|
2009-12-15 21:11:05 +00:00
|
|
|
virtual bool Load( char* aLine, wxString& aErrorMsg );
|
2008-12-16 19:44:57 +00:00
|
|
|
|
2009-12-15 21:11:05 +00:00
|
|
|
void AddPoint( const wxPoint& aPoint );
|
2008-09-13 18:59:57 +00:00
|
|
|
|
2009-10-30 19:26:25 +00:00
|
|
|
/**
|
2009-01-02 13:19:34 +00:00
|
|
|
* @return the number of corners
|
|
|
|
*/
|
|
|
|
unsigned GetCornerCount() const { return m_PolyPoints.size(); }
|
|
|
|
|
2009-06-13 17:06:07 +00:00
|
|
|
/**
|
2009-10-30 19:26:25 +00:00
|
|
|
* Test if the given point is within the bounds of this object.
|
|
|
|
*
|
|
|
|
* @param aRefPos - A wxPoint to test
|
2009-12-15 21:11:05 +00:00
|
|
|
* @return - true if a hit, else false
|
2009-06-13 17:06:07 +00:00
|
|
|
*/
|
|
|
|
virtual bool HitTest( const wxPoint& aRefPos );
|
|
|
|
|
2009-10-30 19:26:25 +00:00
|
|
|
/**
|
2009-01-02 13:19:34 +00:00
|
|
|
* @param aPosRef = a wxPoint to test
|
|
|
|
* @param aThreshold = max distance to a segment
|
|
|
|
* @param aTransMat = the transform matrix
|
2009-10-30 19:26:25 +00:00
|
|
|
* @return true if the point aPosRef is near a segment
|
2009-01-02 13:19:34 +00:00
|
|
|
*/
|
2009-09-02 18:12:45 +00:00
|
|
|
virtual bool HitTest( wxPoint aPosRef, int aThreshold,
|
|
|
|
const int aTransMat[2][2] );
|
2009-01-02 13:19:34 +00:00
|
|
|
|
2009-10-30 19:26:25 +00:00
|
|
|
/**
|
2009-01-02 13:19:34 +00:00
|
|
|
* @return the boundary box for this, in library coordinates
|
|
|
|
*/
|
2009-04-05 20:49:15 +00:00
|
|
|
virtual EDA_Rect GetBoundingBox();
|
|
|
|
|
2009-10-30 19:26:25 +00:00
|
|
|
/**
|
2009-06-30 17:57:27 +00:00
|
|
|
* @return the size of the "pen" that be used to draw or plot this item
|
|
|
|
*/
|
|
|
|
virtual int GetPenSize( );
|
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
void Draw( WinEDA_DrawPanel * aPanel, wxDC * aDC, const wxPoint &aOffset,
|
|
|
|
int aColor, int aDrawMode, void* aData,
|
|
|
|
const int aTransformMatrix[2][2] );
|
2009-01-02 13:19:34 +00:00
|
|
|
|
2009-12-15 21:11:05 +00:00
|
|
|
virtual void DisplayInfo( WinEDA_DrawFrame* aFrame );
|
2009-09-02 18:12:45 +00:00
|
|
|
|
|
|
|
protected:
|
2009-09-25 18:49:04 +00:00
|
|
|
virtual LIB_DRAW_ITEM* DoGenCopy();
|
2009-10-05 17:52:41 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Provide the ployline 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.
|
|
|
|
*/
|
2009-12-15 21:11:05 +00:00
|
|
|
virtual int DoCompare( const LIB_DRAW_ITEM& aOther ) const;
|
|
|
|
|
|
|
|
virtual void DoOffset( const wxPoint& aOffset );
|
|
|
|
virtual bool DoTestInside( EDA_Rect& aRect );
|
|
|
|
virtual void DoMove( const wxPoint& aPosition );
|
|
|
|
virtual wxPoint DoGetPosition() { return m_PolyPoints[0]; }
|
|
|
|
virtual void DoMirrorHorizontal( const wxPoint& aCenter );
|
|
|
|
virtual void DoPlot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill,
|
|
|
|
const int aTransform[2][2] );
|
|
|
|
virtual int DoGetWidth() { return m_Width; }
|
|
|
|
virtual void DoSetWidth( int aWidth ) { m_Width = aWidth; }
|
2008-09-13 18:59:57 +00:00
|
|
|
};
|
|
|
|
|
2009-12-15 21:11:05 +00:00
|
|
|
|
2009-06-25 20:45:27 +00:00
|
|
|
/**********************************************************/
|
|
|
|
/* Graphic Body Item: Bezier Curve (set of lines) */
|
|
|
|
/**********************************************************/
|
2009-10-08 13:19:28 +00:00
|
|
|
class LIB_BEZIER : public LIB_DRAW_ITEM
|
2009-06-30 17:57:27 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
int m_Width; /* Line width */
|
|
|
|
std::vector<wxPoint> m_BezierPoints; // list of parameter (3|4)
|
|
|
|
std::vector<wxPoint> m_PolyPoints; // list of points (>= 2)
|
|
|
|
|
|
|
|
public:
|
2009-10-08 13:19:28 +00:00
|
|
|
LIB_BEZIER( LIB_COMPONENT * aParent );
|
2009-12-15 21:11:05 +00:00
|
|
|
LIB_BEZIER( const LIB_BEZIER& aBezier );
|
2009-10-08 13:19:28 +00:00
|
|
|
~LIB_BEZIER() { }
|
2009-06-30 17:57:27 +00:00
|
|
|
|
|
|
|
virtual wxString GetClass() const
|
|
|
|
{
|
2009-10-08 13:19:28 +00:00
|
|
|
return wxT( "LIB_BEZIER" );
|
2009-06-30 17:57:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2009-10-30 19:26:25 +00:00
|
|
|
* Write bezier curve object out to a FILE in "*.lib" format.
|
|
|
|
*
|
|
|
|
* @param aFile - The FILE to write to.
|
2009-12-15 21:11:05 +00:00
|
|
|
* @return true if success writing else false.
|
2009-06-30 17:57:27 +00:00
|
|
|
*/
|
2009-10-30 19:26:25 +00:00
|
|
|
virtual bool Save( FILE* aFile );
|
2009-12-15 21:11:05 +00:00
|
|
|
virtual bool Load( char* aLine, wxString& aErrorMsg );
|
2009-06-30 17:57:27 +00:00
|
|
|
|
2009-12-15 21:11:05 +00:00
|
|
|
void AddPoint( const wxPoint& aPoint );
|
2009-06-30 17:57:27 +00:00
|
|
|
|
2009-10-30 19:26:25 +00:00
|
|
|
/**
|
2009-06-30 17:57:27 +00:00
|
|
|
* @return the number of corners
|
|
|
|
*/
|
|
|
|
unsigned GetCornerCount() const { return m_PolyPoints.size(); }
|
|
|
|
|
|
|
|
/**
|
2009-10-30 19:26:25 +00:00
|
|
|
* Test if the given point is within the bounds of this object.
|
|
|
|
*
|
|
|
|
* @param aRefPos - A wxPoint to test
|
2009-12-15 21:11:05 +00:00
|
|
|
* @return true if a hit, else false
|
2009-06-30 17:57:27 +00:00
|
|
|
*/
|
|
|
|
virtual bool HitTest( const wxPoint& aRefPos );
|
|
|
|
|
2009-10-30 19:26:25 +00:00
|
|
|
/**
|
2009-06-30 17:57:27 +00:00
|
|
|
* @param aPosRef = a wxPoint to test
|
|
|
|
* @param aThreshold = max distance to a segment
|
|
|
|
* @param aTransMat = the transform matrix
|
2009-10-30 19:26:25 +00:00
|
|
|
* @return true if the point aPosRef is near a segment
|
2009-06-30 17:57:27 +00:00
|
|
|
*/
|
2009-09-02 18:12:45 +00:00
|
|
|
virtual bool HitTest( wxPoint aPosRef, int aThreshold,
|
|
|
|
const int aTransMat[2][2] );
|
2009-06-30 17:57:27 +00:00
|
|
|
|
2009-10-30 19:26:25 +00:00
|
|
|
/**
|
2009-06-30 17:57:27 +00:00
|
|
|
* @return the boundary box for this, in library coordinates
|
|
|
|
*/
|
|
|
|
virtual EDA_Rect GetBoundingBox();
|
|
|
|
|
2009-10-30 19:26:25 +00:00
|
|
|
/**
|
2009-06-30 17:57:27 +00:00
|
|
|
* @return the size of the "pen" that be used to draw or plot this item
|
|
|
|
*/
|
|
|
|
virtual int GetPenSize( );
|
|
|
|
|
|
|
|
void Draw( WinEDA_DrawPanel * aPanel, wxDC * aDC, const wxPoint &aOffset,
|
2009-09-02 18:12:45 +00:00
|
|
|
int aColor, int aDrawMode, void* aData,
|
|
|
|
const int aTransformMatrix[2][2] );
|
2009-06-30 17:57:27 +00:00
|
|
|
|
2009-12-15 21:11:05 +00:00
|
|
|
virtual void DisplayInfo( WinEDA_DrawFrame* aFrame );
|
2009-09-02 18:12:45 +00:00
|
|
|
|
|
|
|
protected:
|
2009-09-25 18:49:04 +00:00
|
|
|
virtual LIB_DRAW_ITEM* DoGenCopy();
|
2009-10-05 17:52:41 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Provide 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.
|
|
|
|
*/
|
2009-12-15 21:11:05 +00:00
|
|
|
virtual int DoCompare( const LIB_DRAW_ITEM& aOther ) const;
|
|
|
|
|
|
|
|
virtual void DoOffset( const wxPoint& aOffset );
|
|
|
|
virtual bool DoTestInside( EDA_Rect& aRect );
|
|
|
|
virtual void DoMove( const wxPoint& aPosition );
|
|
|
|
virtual wxPoint DoGetPosition() { return m_PolyPoints[0]; }
|
|
|
|
virtual void DoMirrorHorizontal( const wxPoint& aCenter );
|
|
|
|
virtual void DoPlot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill,
|
|
|
|
const int aTransform[2][2] );
|
|
|
|
virtual int DoGetWidth() { return m_Width; }
|
|
|
|
virtual void DoSetWidth( int aWidth ) { m_Width = aWidth; }
|
2009-06-30 17:57:27 +00:00
|
|
|
};
|
2009-06-25 20:45:27 +00:00
|
|
|
|
2008-09-13 18:59:57 +00:00
|
|
|
#endif // CLASSES_BODY_ITEMS_H
|