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
|
|
|
|
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
#define TARGET_PIN_DIAM 12 /* Circle diameter drawn at the active end of
|
|
|
|
* pins */
|
2008-09-13 18:59:57 +00:00
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
#define DEFAULT_TEXT_SIZE 50 /* Default size for field texts */
|
|
|
|
#define PART_NAME_LEN 15 /* Maximum length of part name. */
|
|
|
|
#define PREFIX_NAME_LEN 5 /* Maximum length of prefix (IC, R, SW etc.). */
|
|
|
|
#define PIN_WIDTH 100 /* Width between 2 pins in internal units. */
|
|
|
|
#define PIN_LENGTH 300 /* Default Length of each pin to be drawn. */
|
2008-09-13 18:59:57 +00:00
|
|
|
|
2009-06-16 09:03:40 +00:00
|
|
|
#if defined(KICAD_GOST)
|
|
|
|
#define INVERT_PIN_RADIUS 20 /* Radius of inverted pin circle. */
|
|
|
|
#else
|
2009-04-05 20:49:15 +00:00
|
|
|
#define INVERT_PIN_RADIUS 35 /* Radius of inverted pin circle. */
|
2009-06-16 09:03:40 +00:00
|
|
|
#endif
|
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
#define CLOCK_PIN_DIM 40 /* Dim of clock pin symbol. */
|
|
|
|
#define IEEE_SYMBOL_PIN_DIM 40 /* Dim of special pin symbol. */
|
2008-09-13 18:59:57 +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-30 19:26:25 +00:00
|
|
|
* The component library pin object electrical types used in ERC tests.
|
2008-09-13 18:59:57 +00:00
|
|
|
*/
|
2009-12-15 21:11:05 +00:00
|
|
|
enum ElectricPinType {
|
2008-09-13 18:59:57 +00:00
|
|
|
PIN_INPUT,
|
|
|
|
PIN_OUTPUT,
|
|
|
|
PIN_BIDI,
|
|
|
|
PIN_TRISTATE,
|
|
|
|
PIN_PASSIVE,
|
|
|
|
PIN_UNSPECIFIED,
|
|
|
|
PIN_POWER_IN,
|
|
|
|
PIN_POWER_OUT,
|
|
|
|
PIN_OPENCOLLECTOR,
|
|
|
|
PIN_OPENEMITTER,
|
|
|
|
PIN_NC, /* No connect */
|
|
|
|
PIN_NMAX /* End of List (no used as pin type) */
|
|
|
|
};
|
|
|
|
|
2009-10-30 19:26:25 +00:00
|
|
|
/* Electrical pin type names. */
|
2009-04-05 20:49:15 +00:00
|
|
|
extern const wxChar* MsgPinElectricType[];
|
2008-09-13 18:59:57 +00:00
|
|
|
|
2009-10-30 19:26:25 +00:00
|
|
|
/* Pin visibility flag bit. */
|
|
|
|
#define PINNOTDRAW 1 /* Set makes pin invisible */
|
2008-09-13 18:59:57 +00:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
2009-10-30 19:26:25 +00:00
|
|
|
* The component library pin object drawing shapes.
|
2008-09-13 18:59:57 +00:00
|
|
|
*/
|
2009-12-15 21:11:05 +00:00
|
|
|
enum DrawPinShape {
|
2009-10-01 14:17:47 +00:00
|
|
|
NONE = 0,
|
|
|
|
INVERT = 1,
|
|
|
|
CLOCK = 2,
|
2008-09-13 18:59:57 +00:00
|
|
|
LOWLEVEL_IN = 4,
|
|
|
|
LOWLEVEL_OUT = 8
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2009-10-30 19:26:25 +00:00
|
|
|
* The component library pin object orientations.
|
2008-09-13 18:59:57 +00:00
|
|
|
*/
|
2009-12-15 21:11:05 +00:00
|
|
|
enum DrawPinOrient {
|
2008-09-13 18:59:57 +00:00
|
|
|
PIN_RIGHT = 'R',
|
|
|
|
PIN_LEFT = 'L',
|
2009-10-01 14:17:47 +00:00
|
|
|
PIN_UP = 'U',
|
2008-09-13 18:59:57 +00:00
|
|
|
PIN_DOWN = 'D',
|
|
|
|
};
|
|
|
|
|
|
|
|
|
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
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/********/
|
|
|
|
/* Pins */
|
|
|
|
/********/
|
2009-10-08 13:19:28 +00:00
|
|
|
class LIB_PIN : public LIB_DRAW_ITEM
|
2008-09-13 18:59:57 +00:00
|
|
|
{
|
|
|
|
public:
|
2009-09-02 18:12:45 +00:00
|
|
|
int m_PinLen; /* Pin length */
|
2008-09-13 18:59:57 +00:00
|
|
|
int m_Orient; /* Pin orientation (Up, Down, Left, Right) */
|
|
|
|
int m_PinShape; /* Bitwise ORed: Pin shape (see enum DrawPinShape) */
|
|
|
|
int m_PinType; /* Electrical pin properties */
|
|
|
|
int m_Attributs; /* bit 0 != 0: pin invisible */
|
2009-09-02 18:12:45 +00:00
|
|
|
long m_PinNum; /* Pin number: 4 ASCII code like "12" or "anod"
|
2009-04-05 20:49:15 +00:00
|
|
|
* or "G6" "12" is stored as "12\0\0" ans does not
|
|
|
|
* depend on endian type*/
|
2008-09-13 18:59:57 +00:00
|
|
|
wxString m_PinName;
|
2009-04-05 20:49:15 +00:00
|
|
|
int m_PinNumSize;
|
|
|
|
int m_PinNameSize; /* Pin num and Pin name sizes */
|
2008-09-13 18:59:57 +00:00
|
|
|
|
2009-09-02 18:12:45 +00:00
|
|
|
/* (Currently Unused) Pin num and Pin name text options: italic/normal
|
|
|
|
* /bold, 0 = default */
|
2009-09-04 18:57:37 +00:00
|
|
|
char m_PinNumShapeOpt;
|
|
|
|
char m_PinNameShapeOpt;
|
2009-09-02 18:12:45 +00:00
|
|
|
// (Currently Unused) Pin num and Pin name text opt position, 0 = default:
|
2009-09-04 18:57:37 +00:00
|
|
|
char m_PinNumPositionOpt;
|
|
|
|
char m_PinNamePositionOpt;
|
2009-06-13 17:06:07 +00:00
|
|
|
|
2009-06-30 17:57:27 +00:00
|
|
|
wxPoint m_Pos; /* Position or centre (Arc and Circle) or start
|
2009-04-05 20:49:15 +00:00
|
|
|
* 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_PIN(LIB_COMPONENT * aParent);
|
2009-12-15 21:11:05 +00:00
|
|
|
LIB_PIN( const LIB_PIN& aPin );
|
2009-10-08 13:19:28 +00:00
|
|
|
~LIB_PIN() { }
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2009-10-08 13:19:28 +00:00
|
|
|
LIB_PIN* Next() const { return (LIB_PIN*) Pnext; }
|
|
|
|
LIB_PIN* Back() const { return (LIB_PIN*) Pback; }
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2008-09-13 18:59:57 +00:00
|
|
|
virtual wxString GetClass() const
|
|
|
|
{
|
2009-10-08 13:19:28 +00:00
|
|
|
return wxT( "LIB_PIN" );
|
2008-09-13 18:59:57 +00:00
|
|
|
}
|
2008-11-24 06:53:43 +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 pin 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-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.
|
|
|
|
*
|
2009-06-13 17:06:07 +00:00
|
|
|
* @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
|
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-12-15 21:11:05 +00:00
|
|
|
virtual bool HitTest( wxPoint aPosRef, int aThreshold, const int aTransMat[2][2] );
|
2009-06-13 17:06:07 +00:00
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
virtual void DisplayInfo( WinEDA_DrawFrame* frame );
|
|
|
|
virtual EDA_Rect GetBoundingBox();
|
2009-09-02 18:12:45 +00:00
|
|
|
wxPoint ReturnPinEndPoint();
|
2008-09-13 18:59:57 +00:00
|
|
|
|
2009-01-02 17:07:50 +00:00
|
|
|
int ReturnPinDrawOrient( const int TransMat[2][2] );
|
2009-07-05 12:09:41 +00:00
|
|
|
|
2009-10-30 19:26:25 +00:00
|
|
|
/**
|
|
|
|
* Fill a string buffer with pin number.
|
|
|
|
*
|
|
|
|
* Pin numbers are coded as a long or 4 ASCII characters. Used to print
|
|
|
|
* or draw the pin number.
|
|
|
|
*
|
|
|
|
* @param aStringBuffer - the wxString to store the pin num as an unicode
|
|
|
|
* string
|
2009-07-05 12:09:41 +00:00
|
|
|
*/
|
|
|
|
void ReturnPinStringNum( wxString& aStringBuffer ) const;
|
|
|
|
|
2009-12-15 21:11:05 +00:00
|
|
|
wxString GetNumber();
|
2009-10-30 19:26:25 +00:00
|
|
|
|
2009-07-05 12:09:41 +00:00
|
|
|
/** Function ReturnPinStringNum (static function)
|
|
|
|
* Pin num is coded as a long or 4 ascii chars
|
|
|
|
* @param aPinNum = a long containing a pin num
|
2009-09-02 18:12:45 +00:00
|
|
|
* @return aStringBuffer = the wxString to store the pin num as an
|
|
|
|
* unicode string
|
2009-07-05 12:09:41 +00:00
|
|
|
*/
|
2009-09-02 18:12:45 +00:00
|
|
|
static wxString ReturnPinStringNum( long aPinNum );
|
2009-07-05 12:09:41 +00:00
|
|
|
|
2009-12-15 21:11:05 +00:00
|
|
|
void SetPinNumFromString( wxString& aBuffer );
|
2008-09-13 18:59:57 +00:00
|
|
|
|
2009-10-30 19:26:25 +00:00
|
|
|
/**
|
|
|
|
* Set the pin name.
|
|
|
|
*
|
|
|
|
* This will also all of the pin names marked by EnableEditMode().
|
|
|
|
*
|
|
|
|
* @param name - New pin name.
|
2009-06-30 17:57:27 +00:00
|
|
|
*/
|
2009-12-15 21:11:05 +00:00
|
|
|
void SetName( const wxString& aName );
|
2009-10-30 19:26:25 +00:00
|
|
|
|
|
|
|
/**
|
2009-12-15 21:11:05 +00:00
|
|
|
* Set the /a aSize of the pin name text.
|
2009-10-30 19:26:25 +00:00
|
|
|
*
|
|
|
|
* This will also update the text size of the name of the pins marked
|
|
|
|
* by EnableEditMode().
|
|
|
|
*
|
2009-12-15 21:11:05 +00:00
|
|
|
* @param aSize - The text size of the pin name in schematic units ( mils ).
|
2009-10-30 19:26:25 +00:00
|
|
|
*/
|
2009-12-15 21:11:05 +00:00
|
|
|
void SetNameTextSize( int aSize );
|
2009-10-30 19:26:25 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the pin number.
|
|
|
|
*
|
|
|
|
* This will also all of the pin numbers marked by EnableEditMode().
|
|
|
|
*
|
2009-12-15 21:11:05 +00:00
|
|
|
* @param aNumber - New pin number.
|
2009-10-30 19:26:25 +00:00
|
|
|
*/
|
2009-12-15 21:11:05 +00:00
|
|
|
void SetNumber( const wxString& aNumber );
|
2009-10-30 19:26:25 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the size of the pin number text.
|
|
|
|
*
|
|
|
|
* This will also update the text size of the number of the pins marked
|
|
|
|
* by EnableEditMode().
|
|
|
|
*
|
2009-12-15 21:11:05 +00:00
|
|
|
* @param aSize - The text size of the pin number in schematic
|
|
|
|
* units ( mils ).
|
2009-10-30 19:26:25 +00:00
|
|
|
*/
|
2009-12-15 21:11:05 +00:00
|
|
|
void SetNumberTextSize( int aSize );
|
2009-10-30 19:26:25 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set orientation on the pin.
|
|
|
|
*
|
|
|
|
* This will also update the orientation of the pins marked by
|
|
|
|
* EnableEditMode().
|
|
|
|
*
|
2009-12-15 21:11:05 +00:00
|
|
|
* @param aOrientation - The orientation of the pin.
|
2009-10-30 19:26:25 +00:00
|
|
|
*/
|
2009-12-15 21:11:05 +00:00
|
|
|
void SetOrientation( int aOrientation );
|
2009-10-30 19:26:25 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the draw style of the pin.
|
|
|
|
*
|
|
|
|
* This will also update the draw style of the pins marked by
|
|
|
|
* EnableEditMode().
|
|
|
|
*
|
2009-12-15 21:11:05 +00:00
|
|
|
* @param aStyle - The draw style of the pin.
|
2009-10-30 19:26:25 +00:00
|
|
|
*/
|
2009-12-15 21:11:05 +00:00
|
|
|
void SetDrawStyle( int aStyle );
|
2009-10-30 19:26:25 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the electrical type of the pin.
|
|
|
|
*
|
|
|
|
* This will also update the electrical type of the pins marked by
|
|
|
|
* EnableEditMode().
|
|
|
|
*
|
2009-12-15 21:11:05 +00:00
|
|
|
* @param aType - The electrical type of the pin.
|
2009-10-30 19:26:25 +00:00
|
|
|
*/
|
2009-12-15 21:11:05 +00:00
|
|
|
void SetElectricalType( int aType );
|
2009-10-30 19:26:25 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the pin length.
|
|
|
|
*
|
|
|
|
* This will also update the length of the pins marked by EnableEditMode().
|
|
|
|
*
|
2009-12-15 21:11:05 +00:00
|
|
|
* @param aLength - The length of the pin in mils.
|
2009-10-30 19:26:25 +00:00
|
|
|
*/
|
2009-12-15 21:11:05 +00:00
|
|
|
void SetLength( int aLength );
|
2009-10-30 19:26:25 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the pin part number.
|
|
|
|
*
|
|
|
|
* If the pin is changed from not common to common to all parts, any
|
|
|
|
* linked pins will be removed from the parent component.
|
|
|
|
*
|
2009-12-15 21:11:05 +00:00
|
|
|
* @param aPart - Number of the part the pin belongs to. Set to zero to
|
|
|
|
* make pin common to all parts in a multi-part component.
|
2009-10-30 19:26:25 +00:00
|
|
|
*/
|
2009-12-15 21:11:05 +00:00
|
|
|
void SetPartNumber( int aPart );
|
2009-10-30 19:26:25 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the body style (conversion) of the pin.
|
|
|
|
*
|
|
|
|
* If the pin is changed from not common to common to all body styles, any
|
|
|
|
* linked pins will be removed from the parent component.
|
|
|
|
*
|
|
|
|
* @param conversion - Body style of the pin. Set to zero to make pin
|
|
|
|
* common to all body styles.
|
|
|
|
*/
|
2009-12-15 21:11:05 +00:00
|
|
|
void SetConversion( int aConversion );
|
2009-10-30 19:26:25 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set or clear the visibility flag for the pin.
|
|
|
|
*
|
|
|
|
* This will also update the visibility of the pins marked by
|
|
|
|
* EnableEditMode().
|
|
|
|
*
|
2009-12-15 21:11:05 +00:00
|
|
|
* @param aVisible - True to make the pin visible or false to hide the pin.
|
2009-10-30 19:26:25 +00:00
|
|
|
*/
|
2009-12-15 21:11:05 +00:00
|
|
|
void SetVisible( bool aVisible );
|
2009-10-30 19:26:25 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Enable or clear pin editing mode.
|
|
|
|
*
|
|
|
|
* The pin editing mode marks or unmarks all pins common to this
|
|
|
|
* pin object for further editing. If any of the pin modifcation
|
|
|
|
* methods are called after enabling the editing mode, all pins
|
|
|
|
* marked for editing will have the same attribute changed. The
|
|
|
|
* only case were this is not true making this pin common to all
|
|
|
|
* parts or body styles in the component. See SetCommonToAllParts()
|
|
|
|
* and SetCommonToAllBodyStyles() for more information.
|
|
|
|
*
|
2009-12-15 21:11:05 +00:00
|
|
|
* @params aEnable - True marks all common pins for editing mode. False
|
|
|
|
* clears the editing mode.
|
|
|
|
* @params aEditpinByPin - Enables the edit pin by pin mode.
|
2009-10-30 19:26:25 +00:00
|
|
|
*/
|
2009-12-15 21:11:05 +00:00
|
|
|
void EnableEditMode( bool aEnable, bool aEditPinByPin = false );
|
2009-10-30 19:26:25 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the visibility status of the draw object.
|
|
|
|
*
|
2009-12-15 21:11:05 +00:00
|
|
|
* @return True if draw object is visible otherwise false.
|
2009-10-30 19:26:25 +00:00
|
|
|
*/
|
2009-12-15 21:11:05 +00:00
|
|
|
bool IsVisible() { return ( m_Attributs & PINNOTDRAW ) == 0; }
|
2009-10-30 19:26:25 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return the size of the "pen" that be used to draw or plot this item.
|
|
|
|
*/
|
|
|
|
virtual int GetPenSize();
|
2009-06-30 17:57:27 +00:00
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
void Draw( WinEDA_DrawPanel * aPanel, wxDC * aDC, const wxPoint &aOffset,
|
2009-12-15 21:11:05 +00:00
|
|
|
int aColor, int aDrawMode, void* aData, const int aTransformMatrix[2][2] );
|
|
|
|
|
|
|
|
void DrawPinSymbol( WinEDA_DrawPanel* aPanel, wxDC* aDC, const wxPoint& aPosition,
|
|
|
|
int aOrientation, int aDrawMode, int aColor = -1 );
|
2009-01-02 17:07:50 +00:00
|
|
|
|
2009-12-15 21:11:05 +00:00
|
|
|
void DrawPinTexts( WinEDA_DrawPanel* aPanel, wxDC* aDC, wxPoint& aPosition,
|
|
|
|
int aOrientation, int TextInside, bool DrawPinNum, bool DrawPinName,
|
|
|
|
int aColor, int aDrawMode );
|
|
|
|
|
|
|
|
void PlotPinTexts( PLOTTER *aPlotter,
|
|
|
|
wxPoint& aPosition,
|
|
|
|
int aOrientation,
|
|
|
|
int aTextInside,
|
|
|
|
bool aDrawPinNum,
|
|
|
|
bool aDrawPinName,
|
2009-10-05 17:52:41 +00:00
|
|
|
int aWidth );
|
2009-09-02 18:12:45 +00:00
|
|
|
|
2009-10-30 19:26:25 +00:00
|
|
|
/**
|
|
|
|
* Get a list of pin orientation names.
|
|
|
|
*
|
2009-12-15 21:11:05 +00:00
|
|
|
* @return List of valid pin orientation names.
|
2009-10-30 19:26:25 +00:00
|
|
|
*/
|
2009-12-15 21:11:05 +00:00
|
|
|
static wxArrayString GetOrientationNames();
|
2009-10-30 19:26:25 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the orientation code by index used to set the pin orientation.
|
|
|
|
*
|
2009-12-15 21:11:05 +00:00
|
|
|
* @param aIndex - The index of the orientation code to look up.
|
|
|
|
* @return Orientation code if index is valid. Returns right
|
|
|
|
* orientation on index error.
|
2009-10-30 19:26:25 +00:00
|
|
|
*/
|
2009-12-15 21:11:05 +00:00
|
|
|
static int GetOrientationCode( int aIndex );
|
2009-10-30 19:26:25 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the index of the orientation code.
|
|
|
|
*
|
2009-12-15 21:11:05 +00:00
|
|
|
* @param aCode - The orientation code to look up.
|
|
|
|
* @return The index of the orientation code if found. Otherwise,
|
|
|
|
* return wxNOT_FOUND.
|
2009-10-30 19:26:25 +00:00
|
|
|
*/
|
2009-12-15 21:11:05 +00:00
|
|
|
static int GetOrientationCodeIndex( int aCode );
|
2009-10-30 19:26:25 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get a list of pin draw style names.
|
|
|
|
*
|
2009-12-15 21:11:05 +00:00
|
|
|
* @return List of valid pin draw style names.
|
2009-10-30 19:26:25 +00:00
|
|
|
*/
|
2009-12-15 21:11:05 +00:00
|
|
|
static wxArrayString GetStyleNames();
|
2009-10-30 19:26:25 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the pin draw style code by index used to set the pin draw style.
|
|
|
|
*
|
2009-12-15 21:11:05 +00:00
|
|
|
* @param aIndex - The index of the pin draw style code to look up.
|
|
|
|
* @return Pin draw style code if index is valid. Returns NONE
|
|
|
|
* style on index error.
|
2009-10-30 19:26:25 +00:00
|
|
|
*/
|
2009-12-15 21:11:05 +00:00
|
|
|
static int GetStyleCode( int aIndex );
|
2009-10-30 19:26:25 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the index of the pin draw style code.
|
|
|
|
*
|
2009-12-15 21:11:05 +00:00
|
|
|
* @param aCode - The pin draw style code to look up.
|
|
|
|
* @return The index of the pin draw style code if found. Otherwise,
|
|
|
|
* return wxNOT_FOUND.
|
2009-10-30 19:26:25 +00:00
|
|
|
*/
|
2009-12-15 21:11:05 +00:00
|
|
|
static int GetStyleCodeIndex( int aCode );
|
2009-10-30 19:26:25 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get a list of pin electrical type names.
|
2009-12-15 21:11:05 +00:00
|
|
|
*
|
|
|
|
* @return List of valid pin electrical type names.
|
2009-10-30 19:26:25 +00:00
|
|
|
*/
|
2009-12-15 21:11:05 +00:00
|
|
|
static wxArrayString GetElectricalTypeNames();
|
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();
|
2009-10-05 17:52:41 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Provide 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.
|
|
|
|
*/
|
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: 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
|