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.

150 lines
5.0 KiB

11 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 <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 & operator=.
  41. // The ones generated by the compiler are adequate.
  42. ~TEXTE_PCB();
  43. static inline bool ClassOf( const EDA_ITEM* aItem )
  44. {
  45. return aItem && PCB_TEXT_T == aItem->Type();
  46. }
  47. virtual const wxPoint GetPosition() const override
  48. {
  49. return EDA_TEXT::GetTextPos();
  50. }
  51. virtual void SetPosition( const wxPoint& aPos ) override
  52. {
  53. EDA_TEXT::SetTextPos( aPos );
  54. }
  55. void Move( const wxPoint& aMoveVector ) override
  56. {
  57. EDA_TEXT::Offset( aMoveVector );
  58. }
  59. void SetTextAngle( double aAngle );
  60. void Rotate( const wxPoint& aRotCentre, double aAngle ) override;
  61. void Flip( const wxPoint& aCentre ) override;
  62. void Draw( EDA_DRAW_PANEL* panel, wxDC* DC,
  63. GR_DRAWMODE aDrawMode, const wxPoint& offset = ZeroOffset ) override;
  64. void GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ) override;
  65. virtual bool HitTest( const wxPoint& aPosition ) const override
  66. {
  67. return TextHitTest( aPosition );
  68. }
  69. /** @copydoc BOARD_ITEM::HitTest(const EDA_RECT& aRect,
  70. * bool aContained = true, int aAccuracy ) const
  71. */
  72. virtual bool HitTest( const EDA_RECT& aRect, bool aContained = true, int aAccuracy = 0 ) const override
  73. {
  74. return TextHitTest( aRect, aContained, aAccuracy );
  75. }
  76. wxString GetClass() const override
  77. {
  78. return wxT( "PTEXT" );
  79. }
  80. /**
  81. * Function TransformBoundingBoxWithClearanceToPolygon
  82. * Convert the text bounding box to a rectangular polygon
  83. * depending on the text orientation, the bounding box
  84. * is not always horizontal or vertical
  85. * Used in filling zones calculations
  86. * Circles and arcs are approximated by segments
  87. * @param aCornerBuffer = a buffer to store the polygon
  88. * @param aClearanceValue = the clearance around the text bounding box
  89. * to the real clearance value (usually near from 1.0)
  90. */
  91. void TransformBoundingBoxWithClearanceToPolygon(
  92. SHAPE_POLY_SET& aCornerBuffer,
  93. int aClearanceValue ) const;
  94. /**
  95. * Function TransformShapeWithClearanceToPolygonSet
  96. * Convert the text shape to a set of polygons (one by segment)
  97. * Used in 3D viewer
  98. * Circles and arcs are approximated by segments
  99. * @param aCornerBuffer = a buffer to store the polygon
  100. * @param aClearanceValue = the clearance around the text
  101. * @param aCircleToSegmentsCount = the number of segments to approximate a circle
  102. * @param aCorrectionFactor = the correction to apply to circles radius to keep
  103. * clearance when the circle is approximated by segment bigger or equal
  104. * to the real clearance value (usually near from 1.0)
  105. */
  106. void TransformShapeWithClearanceToPolygonSet( SHAPE_POLY_SET& aCornerBuffer,
  107. int aClearanceValue,
  108. int aCircleToSegmentsCount,
  109. double aCorrectionFactor ) const;
  110. wxString GetSelectMenuText() const override;
  111. BITMAP_DEF GetMenuImage() const override;
  112. // Virtual function
  113. const EDA_RECT GetBoundingBox() const override;
  114. EDA_ITEM* Clone() const override;
  115. virtual void SwapData( BOARD_ITEM* aImage ) override;
  116. #if defined(DEBUG)
  117. virtual void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
  118. #endif
  119. };
  120. #endif // #define CLASS_PCB_TEXT_H