2011-09-30 18:15:37 +00:00
|
|
|
/**
|
|
|
|
* @file sch_field.h
|
|
|
|
* @brief Definition of the SCH_FIELD class for Eeschema.
|
|
|
|
*/
|
2008-09-20 17:20:40 +00:00
|
|
|
|
2009-12-02 21:44:03 +00:00
|
|
|
#ifndef CLASS_SCH_FIELD_H
|
|
|
|
#define CLASS_SCH_FIELD_H
|
2008-09-20 17:20:40 +00:00
|
|
|
|
|
|
|
|
2010-11-10 15:30:12 +00:00
|
|
|
#include "sch_item_struct.h"
|
|
|
|
#include "general.h"
|
|
|
|
|
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
class SCH_EDIT_FRAME;
|
2008-10-06 05:44:29 +00:00
|
|
|
class SCH_COMPONENT;
|
2009-10-08 13:19:28 +00:00
|
|
|
class LIB_FIELD;
|
2008-10-06 05:44:29 +00:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
2009-12-02 21:44:03 +00:00
|
|
|
* Class SCH_FIELD
|
2010-12-21 15:13:09 +00:00
|
|
|
* instances are attached to a component and provide a place for the component's value,
|
|
|
|
* reference designator, footprint, and user definable name-value pairs of arbitrary purpose.
|
|
|
|
*
|
|
|
|
* <ul> <li>Field 0 is reserved for the component reference.</li>
|
|
|
|
* <li>Field 1 is reserved for the component value.</li>
|
|
|
|
* <li>Field 2 is reserved for the component footprint.</li>
|
|
|
|
* <li>Field 3 is reserved for the component data sheet file.</li>
|
|
|
|
* <li>Fields 4 and higher are user defineable.</li></ul>
|
2008-10-06 05:44:29 +00:00
|
|
|
*/
|
2010-12-21 15:13:09 +00:00
|
|
|
|
2011-03-29 19:33:07 +00:00
|
|
|
class SCH_FIELD : public SCH_ITEM, public EDA_TEXT
|
2008-09-20 17:20:40 +00:00
|
|
|
{
|
|
|
|
public:
|
2010-06-17 16:30:10 +00:00
|
|
|
int m_FieldId; ///< Field index, @see enum NumFieldType
|
2008-10-06 05:44:29 +00:00
|
|
|
|
2010-06-17 16:30:10 +00:00
|
|
|
wxString m_Name;
|
|
|
|
|
|
|
|
bool m_AddExtraText; /**< for REFERENCE, add extra info
|
2009-12-02 21:44:03 +00:00
|
|
|
* (for REFERENCE: add part selection text */
|
2008-09-20 17:20:40 +00:00
|
|
|
|
|
|
|
public:
|
2010-09-05 17:01:48 +00:00
|
|
|
SCH_FIELD( const wxPoint& aPos, int aFieldId, SCH_COMPONENT* aParent,
|
2009-12-02 21:44:03 +00:00
|
|
|
wxString aName = wxEmptyString );
|
2010-06-17 16:30:10 +00:00
|
|
|
|
2010-12-21 15:13:09 +00:00
|
|
|
SCH_FIELD( const SCH_FIELD& aField );
|
|
|
|
|
2009-12-02 21:44:03 +00:00
|
|
|
~SCH_FIELD();
|
2008-09-20 17:20:40 +00:00
|
|
|
|
|
|
|
virtual wxString GetClass() const
|
|
|
|
{
|
2009-12-02 21:44:03 +00:00
|
|
|
return wxT( "SCH_FIELD" );
|
2008-09-20 17:20:40 +00:00
|
|
|
}
|
|
|
|
|
2011-03-25 19:16:05 +00:00
|
|
|
/**
|
|
|
|
* Function GetName
|
2011-06-17 13:24:22 +00:00
|
|
|
* returns the field name. If the field name is empty, the default field name is
|
2011-03-25 19:16:05 +00:00
|
|
|
* returned. Field names are VALUE, REFERENCE, etc.
|
|
|
|
* @return The name of the field.
|
|
|
|
*/
|
|
|
|
wxString GetName() const;
|
|
|
|
|
|
|
|
int GetId() const { return m_FieldId; }
|
|
|
|
|
2010-12-10 19:47:44 +00:00
|
|
|
void Place( SCH_EDIT_FRAME* frame, wxDC* DC );
|
2010-09-05 17:01:48 +00:00
|
|
|
|
2011-03-29 19:33:07 +00:00
|
|
|
EDA_RECT GetBoundingBox() const;
|
2010-07-30 21:41:55 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Function IsVoid
|
|
|
|
* returns true if the field is either empty or holds "~".
|
|
|
|
*/
|
2010-12-10 19:47:44 +00:00
|
|
|
bool IsVoid() const
|
2010-07-30 21:41:55 +00:00
|
|
|
{
|
|
|
|
size_t len = m_Text.Len();
|
2010-09-05 17:01:48 +00:00
|
|
|
|
2010-07-30 21:41:55 +00:00
|
|
|
return len == 0 || ( len == 1 && m_Text[0] == wxChar( '~' ) );
|
|
|
|
}
|
|
|
|
|
2010-12-21 15:13:09 +00:00
|
|
|
/**
|
|
|
|
* Function SwapData
|
|
|
|
* exchanges the date between the field and \a aField.
|
|
|
|
*
|
|
|
|
* @param aField The field to exchange data with.
|
|
|
|
*/
|
|
|
|
void SwapData( SCH_FIELD* aField );
|
2008-09-20 17:20:40 +00:00
|
|
|
|
2010-11-12 15:17:10 +00:00
|
|
|
/**
|
|
|
|
* Function ImportValues
|
2008-12-31 15:01:29 +00:00
|
|
|
* copy parameters from a source.
|
|
|
|
* Pointers and specific values (position) are not copied
|
2009-10-08 13:19:28 +00:00
|
|
|
* @param aSource = the LIB_FIELD to read
|
2008-12-31 15:01:29 +00:00
|
|
|
*/
|
2010-09-05 17:01:48 +00:00
|
|
|
void ImportValues( const LIB_FIELD& aSource );
|
2008-12-31 15:01:29 +00:00
|
|
|
|
2010-11-12 15:17:10 +00:00
|
|
|
/**
|
|
|
|
* Function GetPenSize
|
2009-06-30 17:57:27 +00:00
|
|
|
* @return the size of the "pen" that be used to draw or plot this item
|
|
|
|
*/
|
2010-12-10 19:47:44 +00:00
|
|
|
int GetPenSize() const;
|
2009-06-30 17:57:27 +00:00
|
|
|
|
2010-11-12 15:17:10 +00:00
|
|
|
/**
|
|
|
|
* Function IsVisible
|
2009-12-30 18:06:12 +00:00
|
|
|
* @return true is this field is visible, false if flagged invisible
|
|
|
|
*/
|
2010-12-10 19:47:44 +00:00
|
|
|
bool IsVisible() const
|
2009-12-30 18:06:12 +00:00
|
|
|
{
|
|
|
|
return (m_Attributs & TEXT_NO_VISIBLE) == 0 ? true : false;
|
|
|
|
}
|
|
|
|
|
2010-09-05 17:01:48 +00:00
|
|
|
|
2008-09-20 17:20:40 +00:00
|
|
|
/**
|
|
|
|
* Function Draw
|
|
|
|
*/
|
2011-01-21 19:30:59 +00:00
|
|
|
void Draw( EDA_DRAW_PANEL* aPanel,
|
|
|
|
wxDC* aDC,
|
|
|
|
const wxPoint& aOffset,
|
|
|
|
int aDrawMode,
|
|
|
|
int aColor = -1 );
|
2008-09-20 17:20:40 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Function Save
|
2009-12-02 21:44:03 +00:00
|
|
|
* writes the data structures for this object out to a FILE in "*.sch"
|
|
|
|
* format.
|
2008-09-20 17:20:40 +00:00
|
|
|
* @param aFile The FILE to write to.
|
|
|
|
* @return bool - true if success writing else false.
|
|
|
|
*/
|
|
|
|
bool Save( FILE* aFile ) const;
|
2009-07-27 14:32:40 +00:00
|
|
|
|
|
|
|
// Geometric transforms (used in block operations):
|
2010-09-05 17:01:48 +00:00
|
|
|
|
2009-07-27 14:32:40 +00:00
|
|
|
/** virtual function Move
|
|
|
|
* move item to a new position.
|
2009-12-02 21:44:03 +00:00
|
|
|
* @param aMoveVector = the displacement vector
|
2009-07-27 14:32:40 +00:00
|
|
|
*/
|
2010-09-05 17:01:48 +00:00
|
|
|
virtual void Move( const wxPoint& aMoveVector )
|
2009-07-27 14:32:40 +00:00
|
|
|
{
|
|
|
|
m_Pos += aMoveVector;
|
|
|
|
}
|
|
|
|
|
2010-09-05 17:01:48 +00:00
|
|
|
|
|
|
|
virtual void Rotate( wxPoint rotationPoint );
|
|
|
|
|
|
|
|
virtual void Mirror_X( int aXaxis_position )
|
|
|
|
{
|
|
|
|
/* Do Nothing: fields are never mirrored alone.
|
|
|
|
* they are moved when the parent component is mirrored
|
|
|
|
* this function is only needed by the virtual pure function of the
|
|
|
|
* master class */
|
|
|
|
}
|
|
|
|
|
2009-07-27 14:32:40 +00:00
|
|
|
/** virtual function Mirror_Y
|
|
|
|
* mirror item relative to an Y axis
|
|
|
|
* @param aYaxis_position = the y axis position
|
|
|
|
*/
|
2010-09-05 17:01:48 +00:00
|
|
|
virtual void Mirror_Y( int aYaxis_position )
|
2009-07-27 14:32:40 +00:00
|
|
|
{
|
|
|
|
/* Do Nothing: fields are never mirrored alone.
|
|
|
|
* they are moved when the parent component is mirrored
|
2009-12-02 21:44:03 +00:00
|
|
|
* this function is only needed by the virtual pure function of the
|
|
|
|
* master class */
|
2009-07-27 14:32:40 +00:00
|
|
|
}
|
2010-03-16 18:22:59 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Compare schematic field text against search string.
|
|
|
|
*
|
|
|
|
* @param aSearchData - Criteria to search against.
|
2010-04-01 13:15:48 +00:00
|
|
|
* @param aAuxData - a pointer on auxiliary data, if needed.
|
|
|
|
* the sheet path is needed for REFERENCE field because m_Text
|
2011-06-17 13:24:22 +00:00
|
|
|
* value is just the value displayed, and in complex hierarchies
|
2010-04-01 13:15:48 +00:00
|
|
|
* this is only one of all references (one per sheet path)
|
2010-10-20 19:43:58 +00:00
|
|
|
* @param aFindLocation - a wxPoint where to put the location of matched item. can be NULL.
|
2010-03-16 18:22:59 +00:00
|
|
|
* @return True if this field text matches the search criteria.
|
|
|
|
*/
|
2010-10-20 19:43:58 +00:00
|
|
|
virtual bool Matches( wxFindReplaceData& aSearchData,
|
2011-03-25 19:16:05 +00:00
|
|
|
void* aAuxData, wxPoint* aFindLocation );
|
|
|
|
|
|
|
|
virtual wxString GetSelectMenuText() const;
|
|
|
|
|
2011-08-29 03:04:59 +00:00
|
|
|
virtual BITMAP_DEF GetMenuImage() const;
|
2010-12-10 19:47:44 +00:00
|
|
|
|
|
|
|
private:
|
2011-03-25 19:16:05 +00:00
|
|
|
virtual bool doHitTest( const wxPoint& aPoint, int aAccuracy ) const;
|
2011-03-29 19:33:07 +00:00
|
|
|
virtual bool doHitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const;
|
2010-12-21 15:13:09 +00:00
|
|
|
virtual EDA_ITEM* doClone() const;
|
2011-06-17 13:24:22 +00:00
|
|
|
virtual void doPlot( PLOTTER* aPlotter );
|
2008-09-20 17:20:40 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-12-02 21:44:03 +00:00
|
|
|
#endif /* CLASS_SCH_FIELD_H */
|