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.

145 lines
4.7 KiB

  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 <eda_text.h>
  31. #include <class_board_item.h>
  32. #include <PolyLine.h>
  33. class LINE_READER;
  34. class EDA_DRAW_PANEL;
  35. class MSG_PANEL_ITEM;
  36. class TEXTE_PCB : public BOARD_ITEM, public EDA_TEXT
  37. {
  38. public:
  39. TEXTE_PCB( BOARD_ITEM* parent );
  40. // Do not create a copy constructor. The one generated by the compiler is adequate.
  41. ~TEXTE_PCB();
  42. virtual const wxPoint& GetPosition() const
  43. {
  44. return m_Pos;
  45. }
  46. virtual void SetPosition( const wxPoint& aPos )
  47. {
  48. m_Pos = aPos;
  49. }
  50. void Move( const wxPoint& aMoveVector )
  51. {
  52. m_Pos += aMoveVector;
  53. }
  54. void Rotate( const wxPoint& aRotCentre, double aAngle );
  55. void Flip( const wxPoint& aCentre );
  56. /* duplicate structure */
  57. void Copy( TEXTE_PCB* source );
  58. void Draw( EDA_DRAW_PANEL* panel, wxDC* DC,
  59. GR_DRAWMODE aDrawMode, const wxPoint& offset = ZeroOffset );
  60. void GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList );
  61. bool HitTest( const wxPoint& aPosition )
  62. {
  63. return TextHitTest( aPosition );
  64. }
  65. bool HitTest( const EDA_RECT& aRect ) const
  66. {
  67. return TextHitTest( aRect );
  68. }
  69. wxString GetClass() const
  70. {
  71. return wxT( "PTEXT" );
  72. }
  73. /**
  74. * Function TransformBoundingBoxWithClearanceToPolygon
  75. * Convert the text bounding box to a rectangular polygon
  76. * depending on the text orientation, the bounding box
  77. * is not always horizontal or vertical
  78. * Used in filling zones calculations
  79. * Circles and arcs are approximated by segments
  80. * @param aCornerBuffer = a buffer to store the polygon
  81. * @param aClearanceValue = the clearance around the text bounding box
  82. * to the real clearance value (usually near from 1.0)
  83. */
  84. void TransformBoundingBoxWithClearanceToPolygon(
  85. CPOLYGONS_LIST& aCornerBuffer,
  86. int aClearanceValue ) const;
  87. /**
  88. * Function TransformShapeWithClearanceToPolygonSet
  89. * Convert the text shape to a set of polygons (one by segment)
  90. * Used in 3D viewer
  91. * Circles and arcs are approximated by segments
  92. * @param aCornerBuffer = a buffer to store the polygon
  93. * @param aClearanceValue = the clearance around the text
  94. * @param aCircleToSegmentsCount = the number of segments to approximate a circle
  95. * @param aCorrectionFactor = the correction to apply to circles radius to keep
  96. * clearance when the circle is approximated by segment bigger or equal
  97. * to the real clearance value (usually near from 1.0)
  98. */
  99. void TransformShapeWithClearanceToPolygonSet( CPOLYGONS_LIST& aCornerBuffer,
  100. int aClearanceValue,
  101. int aCircleToSegmentsCount,
  102. double aCorrectionFactor ) const;
  103. wxString GetSelectMenuText() const;
  104. BITMAP_DEF GetMenuImage() const { return add_text_xpm; }
  105. EDA_RECT GetBoundingBox() const { return GetTextBox(); };
  106. EDA_ITEM* Clone() const;
  107. /// @copydoc VIEW_ITEM::ViewBBox()
  108. virtual const BOX2I ViewBBox() const;
  109. /// @copydoc VIEW_ITEM::ViewGetLayers()
  110. virtual void ViewGetLayers( int aLayers[], int& aCount ) const;
  111. #if defined(DEBUG)
  112. virtual void Show( int nestLevel, std::ostream& os ) const { ShowDummy( os ); } // override
  113. #endif
  114. };
  115. #endif // #define CLASS_PCB_TEXT_H