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.

174 lines
5.3 KiB

14 years ago
14 years ago
14 years ago
  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
  5. * Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License
  9. * as published by the Free Software Foundation; either version 2
  10. * of the License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, you may find one here:
  19. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  20. * or you may search the http://www.gnu.org website for the version 2 license,
  21. * or you may write to the Free Software Foundation, Inc.,
  22. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  23. */
  24. /**
  25. * @file class_pcb_text.h
  26. * @brief TEXTE_PCB class definition.
  27. */
  28. #ifndef CLASS_PCB_TEXT_H
  29. #define CLASS_PCB_TEXT_H
  30. #include <class_board_item.h>
  31. #include <PolyLine.h>
  32. class LINE_READER;
  33. class EDA_DRAW_PANEL;
  34. class TEXTE_PCB : public BOARD_ITEM, public EDA_TEXT
  35. {
  36. public:
  37. TEXTE_PCB( BOARD_ITEM* parent );
  38. // Do not create a copy constructor. The one generated by the compiler is adequate.
  39. ~TEXTE_PCB();
  40. const wxPoint& GetPosition() const // was overload
  41. {
  42. return m_Pos; // within EDA_TEXT
  43. }
  44. void SetPosition( const wxPoint& aPos ) // was overload
  45. {
  46. m_Pos = aPos; // within EDA_TEXT
  47. }
  48. /**
  49. * Function Move
  50. * move this object.
  51. * @param aMoveVector - the move vector for this object.
  52. */
  53. virtual void Move( const wxPoint& aMoveVector )
  54. {
  55. m_Pos += aMoveVector;
  56. }
  57. /**
  58. * Function Rotate
  59. * Rotate this object.
  60. * @param aRotCentre - the rotation point.
  61. * @param aAngle - the rotation angle in 0.1 degree.
  62. */
  63. virtual void Rotate( const wxPoint& aRotCentre, double aAngle );
  64. /**
  65. * Function Flip
  66. * Flip this object, i.e. change the board side for this object
  67. * @param aCentre - the rotation point.
  68. */
  69. virtual void Flip( const wxPoint& aCentre );
  70. /* duplicate structure */
  71. void Copy( TEXTE_PCB* source );
  72. void Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int aDrawMode,
  73. const wxPoint& offset = ZeroOffset );
  74. // File Operations:
  75. int ReadTextePcbDescr( LINE_READER* aReader );
  76. /**
  77. * Function Save
  78. * writes the data structures for this object out to a FILE in "*.brd" format.
  79. * @param aFile The FILE to write to.
  80. * @return bool - true if success writing else false.
  81. */
  82. bool Save( FILE* aFile ) const;
  83. /**
  84. * Function DisplayInfo
  85. * has knowledge about the frame and how and where to put status information
  86. * about this object into the frame's message panel.
  87. * Is virtual from EDA_ITEM.
  88. * @param frame A EDA_DRAW_FRAME in which to print status information.
  89. */
  90. void DisplayInfo( EDA_DRAW_FRAME* frame );
  91. /**
  92. * Function HitTest
  93. * tests if the given wxPoint is within the bounds of this object.
  94. * @param refPos A wxPoint to test
  95. * @return bool - true if a hit, else false
  96. */
  97. bool HitTest( const wxPoint& refPos )
  98. {
  99. return TextHitTest( refPos );
  100. }
  101. /**
  102. * Function HitTest (overloaded)
  103. * tests if the given EDA_RECT intersect this object.
  104. * @param refArea the given EDA_RECT to test
  105. * @return bool - true if a hit, else false
  106. */
  107. bool HitTest( EDA_RECT& refArea )
  108. {
  109. return TextHitTest( refArea );
  110. }
  111. /**
  112. * Function GetClass
  113. * returns the class name.
  114. * @return wxString
  115. */
  116. virtual wxString GetClass() const
  117. {
  118. return wxT("PTEXT");
  119. }
  120. /**
  121. * Function TransformShapeWithClearanceToPolygon
  122. * Convert the track shape to a closed polygon
  123. * Used in filling zones calculations
  124. * Circles and arcs are approximated by segments
  125. * @param aCornerBuffer = a buffer to store the polygon
  126. * @param aClearanceValue = the clearance around the pad
  127. * @param aCircleToSegmentsCount = the number of segments to approximate a circle
  128. * @param aCorrectionFactor = the correction to apply to circles radius to keep
  129. * clearance when the circle is approximated by segment bigger or equal
  130. * to the real clearance value (usually near from 1.0)
  131. */
  132. void TransformShapeWithClearanceToPolygon( std::vector <CPolyPt>& aCornerBuffer,
  133. int aClearanceValue,
  134. int aCircleToSegmentsCount,
  135. double aCorrectionFactor );
  136. virtual wxString GetSelectMenuText() const;
  137. virtual BITMAP_DEF GetMenuImage() const { return add_text_xpm; }
  138. virtual EDA_RECT GetBoundingBox() const { return GetTextBox(); };
  139. #if defined(DEBUG)
  140. void Show( int nestLevel, std::ostream& os ) const;
  141. #endif
  142. private:
  143. virtual EDA_ITEM* doClone() const;
  144. };
  145. #endif // #define CLASS_PCB_TEXT_H