2008-12-31 09:27:19 +00:00
|
|
|
/**************************************************************/
|
2009-11-03 13:26:31 +00:00
|
|
|
/* Lib component definitions (libentry) definition of fields */
|
2008-12-31 09:27:19 +00:00
|
|
|
/**************************************************************/
|
|
|
|
|
|
|
|
#ifndef CLASS_LIBENTRY_FIELDS_H
|
|
|
|
#define CLASS_LIBENTRY_FIELDS_H
|
|
|
|
|
|
|
|
|
2009-09-25 18:49:04 +00:00
|
|
|
#include "classes_body_items.h"
|
|
|
|
|
|
|
|
|
2010-06-17 16:30:10 +00:00
|
|
|
/**
|
|
|
|
* Class LIB_FIELD
|
|
|
|
* is used in symbol libraries. At least MANDATORY_FIELDS are always present
|
|
|
|
* in a ram resident library symbol. All constructors must ensure this because
|
|
|
|
* the component property editor assumes it.
|
|
|
|
* @see enum NumFieldType
|
2008-12-31 09:27:19 +00:00
|
|
|
*/
|
2009-10-08 13:19:28 +00:00
|
|
|
class LIB_FIELD : public LIB_DRAW_ITEM, public EDA_TextStruct
|
2008-12-31 09:27:19 +00:00
|
|
|
{
|
|
|
|
public:
|
2010-06-17 16:30:10 +00:00
|
|
|
int m_FieldId; ///< @see enum NumFieldType
|
|
|
|
|
|
|
|
wxString m_Name; ///< Name (not the field text value itself, that is .m_Text)
|
2008-12-31 09:27:19 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
2009-10-08 13:19:28 +00:00
|
|
|
LIB_FIELD* Next() const { return (LIB_FIELD*) Pnext; }
|
|
|
|
LIB_FIELD* Back() const { return (LIB_FIELD*) Pback; }
|
2008-12-31 09:27:19 +00:00
|
|
|
|
|
|
|
|
2009-10-08 13:19:28 +00:00
|
|
|
LIB_FIELD( int idfield = 2 );
|
|
|
|
LIB_FIELD( LIB_COMPONENT * aParent, int idfield = 2 );
|
|
|
|
LIB_FIELD( const LIB_FIELD& field );
|
|
|
|
~LIB_FIELD();
|
2009-10-20 19:36:58 +00:00
|
|
|
|
2008-12-31 09:27:19 +00:00
|
|
|
virtual wxString GetClass() const
|
|
|
|
{
|
2009-10-08 13:19:28 +00:00
|
|
|
return wxT( "LIB_FIELD" );
|
2008-12-31 09:27:19 +00:00
|
|
|
}
|
|
|
|
|
2009-10-20 19:36:58 +00:00
|
|
|
/**
|
|
|
|
* Object constructor initialization helper.
|
|
|
|
*/
|
|
|
|
void Init( int idfield );
|
2008-12-31 09:27:19 +00:00
|
|
|
|
2009-06-30 17:57:27 +00:00
|
|
|
/** Function GetPenSize virtual pure
|
|
|
|
* @return the size of the "pen" that be used to draw or plot this item
|
|
|
|
*/
|
|
|
|
int GetPenSize( );
|
|
|
|
|
2008-12-31 09:27:19 +00:00
|
|
|
/**
|
2009-10-30 19:26:25 +00:00
|
|
|
* Writes field object out to a FILE in "*.lib" format.
|
|
|
|
*
|
2008-12-31 09:27:19 +00:00
|
|
|
* @param aFile The FILE to write to.
|
2009-10-30 19:26:25 +00:00
|
|
|
* @return True if success writing else false.
|
2008-12-31 09:27:19 +00:00
|
|
|
*/
|
2009-10-30 19:26:25 +00:00
|
|
|
virtual bool Save( FILE* aFile );
|
2009-04-05 20:49:15 +00:00
|
|
|
virtual bool Load( char* line, wxString& errorMsg );
|
2008-12-31 09:27:19 +00:00
|
|
|
|
2009-10-30 19:26:25 +00:00
|
|
|
/**
|
|
|
|
* Copy parameters of this field to another field. Pointers are not copied.
|
|
|
|
*
|
|
|
|
* @param aTarget = Target field to copy values to.
|
2008-12-31 09:27:19 +00:00
|
|
|
*/
|
2009-10-08 13:19:28 +00:00
|
|
|
void Copy( LIB_FIELD* aTarget ) const;
|
2008-12-31 09:27:19 +00:00
|
|
|
|
2009-10-08 13:19:28 +00:00
|
|
|
void SetFields( const std::vector <LIB_FIELD> aFields );
|
2008-12-31 09:27:19 +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] );
|
2008-12-31 09:27:19 +00:00
|
|
|
|
2010-06-17 16:30:10 +00:00
|
|
|
/**
|
|
|
|
* Function IsVisible
|
2009-12-30 18:06:12 +00:00
|
|
|
* @return true is this field is visible, false if flagged invisible
|
|
|
|
*/
|
|
|
|
bool IsVisible()
|
|
|
|
{
|
|
|
|
return (m_Attributs & TEXT_NO_VISIBLE) == 0 ? true : false;
|
|
|
|
}
|
|
|
|
|
2009-09-29 18:38:21 +00:00
|
|
|
/**
|
|
|
|
* Return the bounding rectangle of the field text.
|
2009-10-30 19:26:25 +00:00
|
|
|
* @return Bounding rectangle.
|
2009-09-29 18:38:21 +00:00
|
|
|
*/
|
2009-10-01 14:17:47 +00:00
|
|
|
virtual EDA_Rect GetBoundingBox();
|
2009-09-29 18:38:21 +00:00
|
|
|
|
2008-12-31 09:27:19 +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 point to test in field coordinate system
|
|
|
|
* @return True if a hit, else false
|
2008-12-31 09:27:19 +00:00
|
|
|
*/
|
2008-12-31 15:01:29 +00:00
|
|
|
bool HitTest( const wxPoint& refPos );
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2009-09-29 18:38:21 +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
|
|
|
|
* thickness of a line)
|
|
|
|
* @param aTransMat = the transform matrix
|
|
|
|
* @return True if the point aPosRef is near this object
|
|
|
|
*/
|
2009-09-29 18:38:21 +00:00
|
|
|
virtual bool HitTest( wxPoint aPosRef, int aThreshold,
|
|
|
|
const int aTransMat[2][2] );
|
2009-06-13 17:06:07 +00:00
|
|
|
|
2009-10-08 13:19:28 +00:00
|
|
|
void operator=( const LIB_FIELD& field )
|
2009-04-05 20:49:15 +00:00
|
|
|
{
|
|
|
|
m_FieldId = field.m_FieldId;
|
|
|
|
m_Text = field.m_Text;
|
2010-02-22 19:56:32 +00:00
|
|
|
m_Name = field.m_Name;
|
2009-04-05 20:49:15 +00:00
|
|
|
m_Pos = field.m_Pos;
|
|
|
|
m_Size = field.m_Size;
|
|
|
|
m_Width = field.m_Width;
|
|
|
|
m_Orient = field.m_Orient;
|
|
|
|
m_Mirror = field.m_Mirror;
|
|
|
|
m_Attributs = field.m_Attributs;
|
|
|
|
m_Italic = field.m_Italic;
|
2009-05-28 17:39:40 +00:00
|
|
|
m_Bold = field.m_Bold;
|
2009-04-05 20:49:15 +00:00
|
|
|
m_HJustify = field.m_HJustify;
|
|
|
|
m_VJustify = field.m_VJustify;
|
2009-06-18 13:30:52 +00:00
|
|
|
m_Parent = field.m_Parent;
|
2009-04-05 20:49:15 +00:00
|
|
|
}
|
2009-09-02 18:12:45 +00:00
|
|
|
|
2009-09-25 18:49:04 +00:00
|
|
|
/**
|
|
|
|
* Return the text of a field.
|
|
|
|
*
|
|
|
|
* If the field is the reference field, the unit number is used to
|
|
|
|
* create a pseudo reference text. If the base reference field is U,
|
|
|
|
* the string U?A will be returned for unit = 1.
|
|
|
|
*
|
|
|
|
* @param unit - The package unit number. Only effects reference field.
|
2009-10-30 19:26:25 +00:00
|
|
|
* @return Field text.
|
2009-09-25 18:49:04 +00:00
|
|
|
*/
|
|
|
|
wxString GetFullText( int unit = 1 );
|
2009-09-22 12:27:57 +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 field draw object specific comparison.
|
|
|
|
*
|
|
|
|
* The sort order for field is as follows:
|
|
|
|
*
|
|
|
|
* - Field ID, REFERENCE, VALUE, etc.
|
|
|
|
* - Field string, case insensitive compare.
|
|
|
|
* - Field horizontal (X) position.
|
|
|
|
* - Field vertical (Y) position.
|
|
|
|
* - Field width.
|
|
|
|
* - Field height.
|
|
|
|
*/
|
2009-10-01 14:17:47 +00:00
|
|
|
virtual int DoCompare( const LIB_DRAW_ITEM& other ) const;
|
2009-10-05 17:52:41 +00:00
|
|
|
|
2009-09-14 13:24:17 +00:00
|
|
|
virtual void DoOffset( const wxPoint& offset );
|
|
|
|
virtual bool DoTestInside( EDA_Rect& rect );
|
2009-09-25 18:49:04 +00:00
|
|
|
virtual void DoMove( const wxPoint& newPosition );
|
|
|
|
virtual wxPoint DoGetPosition( void ) { return m_Pos; }
|
2009-09-29 18:38:21 +00:00
|
|
|
virtual void DoMirrorHorizontal( const wxPoint& center );
|
2009-10-05 17:52:41 +00:00
|
|
|
virtual void DoPlot( PLOTTER* plotter, const wxPoint& offset, bool fill,
|
|
|
|
const int transform[2][2] );
|
2009-10-08 13:19:28 +00:00
|
|
|
virtual int DoGetWidth( void ) { return m_Width; }
|
2009-10-19 19:00:47 +00:00
|
|
|
virtual void DoSetWidth( int width ) { m_Width = width; }
|
2008-12-31 09:27:19 +00:00
|
|
|
};
|
|
|
|
|
2010-06-17 16:30:10 +00:00
|
|
|
typedef std::vector< LIB_FIELD > LIB_FIELD_LIST;
|
|
|
|
|
2008-12-31 09:27:19 +00:00
|
|
|
#endif // CLASS_LIBENTRY_FIELDS_H
|