You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

120 lines
3.5 KiB

  1. /*************************************************************/
  2. /* Definitions for the component fields classes for EESchema */
  3. /*************************************************************/
  4. #ifndef CLASS_SCH_FIELD_H
  5. #define CLASS_SCH_FIELD_H
  6. /* Fields are texts attached to a component, having a special meaning
  7. * Fields 0 and 1 are very important: reference and value
  8. * Field 2 is used as default footprint name.
  9. * Field 3 is reserved (not currently used
  10. * Fields 4 and more are user fields.
  11. * They can be renamed and can appear in reports
  12. */
  13. class SCH_COMPONENT;
  14. class LIB_FIELD;
  15. /**
  16. * Class SCH_FIELD
  17. * instances are attached to a component and provide a place for the
  18. * component's value,
  19. * reference designator, footprint, and user definable name-value pairs of
  20. * arbitrary purpose.
  21. */
  22. class SCH_FIELD : public SCH_ITEM, public EDA_TextStruct
  23. {
  24. public:
  25. int m_FieldId; /* Field indicator type (REFERENCE, VALUE or
  26. * other id) */
  27. wxString m_Name; /* Field name (ref, value,pcb, sheet, filed 1..
  28. * and for fields 1 to 8 the name is editable
  29. */
  30. bool m_AddExtraText; /* Mainly for REFERENCE, add extra info
  31. * (for REFERENCE: add part selection text */
  32. public:
  33. SCH_FIELD( const wxPoint& aPos, int aFieldId, SCH_COMPONENT* aParent,
  34. wxString aName = wxEmptyString );
  35. ~SCH_FIELD();
  36. virtual wxString GetClass() const
  37. {
  38. return wxT( "SCH_FIELD" );
  39. }
  40. void Place( WinEDA_SchematicFrame* frame, wxDC* DC );
  41. EDA_Rect GetBoundaryBox() const;
  42. bool IsVoid();
  43. void SwapData( SCH_FIELD* copyitem );
  44. /** Function ImportValues
  45. * copy parameters from a source.
  46. * Pointers and specific values (position) are not copied
  47. * @param aSource = the LIB_FIELD to read
  48. */
  49. void ImportValues( const LIB_FIELD& aSource );
  50. /** Function GetPenSize
  51. * @return the size of the "pen" that be used to draw or plot this item
  52. */
  53. int GetPenSize( );
  54. /** Function IsVisible
  55. * @return true is this field is visible, false if flagged invisible
  56. */
  57. bool IsVisible()
  58. {
  59. return (m_Attributs & TEXT_NO_VISIBLE) == 0 ? true : false;
  60. }
  61. /**
  62. * Function Draw
  63. */
  64. void Draw( WinEDA_DrawPanel* panel,
  65. wxDC* DC,
  66. const wxPoint& offset,
  67. int draw_mode,
  68. int Color = -1 );
  69. /**
  70. * Function Save
  71. * writes the data structures for this object out to a FILE in "*.sch"
  72. * format.
  73. * @param aFile The FILE to write to.
  74. * @return bool - true if success writing else false.
  75. */
  76. bool Save( FILE* aFile ) const;
  77. // Geometric transforms (used in block operations):
  78. /** virtual function Move
  79. * move item to a new position.
  80. * @param aMoveVector = the displacement vector
  81. */
  82. virtual void Move(const wxPoint& aMoveVector)
  83. {
  84. m_Pos += aMoveVector;
  85. }
  86. /** virtual function Mirror_Y
  87. * mirror item relative to an Y axis
  88. * @param aYaxis_position = the y axis position
  89. */
  90. virtual void Mirror_Y(int aYaxis_position)
  91. {
  92. /* Do Nothing: fields are never mirrored alone.
  93. * they are moved when the parent component is mirrored
  94. * this function is only needed by the virtual pure function of the
  95. * master class */
  96. }
  97. };
  98. #endif /* CLASS_SCH_FIELD_H */