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.

133 lines
4.5 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-2022 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. #ifndef PCB_TEXTBOX_H
  25. #define PCB_TEXTBOX_H
  26. #include <eda_text.h>
  27. #include <pcb_shape.h>
  28. class LINE_READER;
  29. class MSG_PANEL_ITEM;
  30. class PCB_TEXTBOX : public PCB_SHAPE, public EDA_TEXT
  31. {
  32. public:
  33. PCB_TEXTBOX( BOARD_ITEM* parent );
  34. // Do not create a copy constructor & operator=.
  35. // The ones generated by the compiler are adequate.
  36. ~PCB_TEXTBOX();
  37. static inline bool ClassOf( const EDA_ITEM* aItem )
  38. {
  39. return aItem && PCB_TEXTBOX_T == aItem->Type();
  40. }
  41. bool IsType( const KICAD_T aScanTypes[] ) const override
  42. {
  43. if( BOARD_ITEM::IsType( aScanTypes ) )
  44. return true;
  45. for( const KICAD_T* p = aScanTypes; *p != EOT; ++p )
  46. {
  47. if( *p == PCB_LOCATE_TEXT_T )
  48. return true;
  49. }
  50. return false;
  51. }
  52. int GetTextMargin() const;
  53. VECTOR2I GetDrawPos() const override;
  54. wxString GetShownText( int aDepth = 0 ) const override;
  55. /// PCB_TEXTBOXes are always visible:
  56. void SetVisible( bool aVisible ) override { /* do nothing */}
  57. bool IsVisible() const override { return true; }
  58. bool Matches( const wxFindReplaceData& aSearchData, void* aAuxData ) const override
  59. {
  60. return BOARD_ITEM::Matches( GetShownText(), aSearchData );
  61. }
  62. std::vector<VECTOR2I> GetAnchorAndOppositeCorner() const;
  63. void Move( const VECTOR2I& aMoveVector ) override;
  64. void Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle ) override;
  65. void Flip( const VECTOR2I& aCentre, bool aFlipLeftRight ) override;
  66. void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
  67. bool HitTest( const VECTOR2I& aPosition, int aAccuracy ) const override;
  68. bool HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy = 0 ) const override;
  69. wxString GetClass() const override
  70. {
  71. return wxT( "PCB_TEXTBOX" );
  72. }
  73. /**
  74. * Function TransformTextShapeWithClearanceToPolygon
  75. * Convert the text to a polygonSet describing the actual character strokes (one per segment).
  76. * Used in 3D viewer
  77. * Circles and arcs are approximated by segments
  78. * @aCornerBuffer = SHAPE_POLY_SET to store the polygon corners
  79. * @aClearanceValue = the clearance around the text
  80. * @aError = the maximum error to allow when approximating curves
  81. */
  82. void TransformTextShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBuffer,
  83. PCB_LAYER_ID aLayer, int aClearanceValue,
  84. int aError, ERROR_LOC aErrorLoc ) const;
  85. void TransformShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBuffer, PCB_LAYER_ID aLayer,
  86. int aClearanceValue, int aError, ERROR_LOC aErrorLoc,
  87. bool aIgnoreLineWidth = false ) const override;
  88. // @copydoc BOARD_ITEM::GetEffectiveShape
  89. virtual std::shared_ptr<SHAPE> GetEffectiveShape( PCB_LAYER_ID aLayer = UNDEFINED_LAYER,
  90. FLASHING aFlash = FLASHING::DEFAULT ) const override;
  91. wxString GetSelectMenuText( EDA_UNITS aUnits ) const override;
  92. BITMAPS GetMenuImage() const override;
  93. ///< @copydoc VIEW_ITEM::ViewGetLOD
  94. double ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const override;
  95. // Virtual function
  96. EDA_ITEM* Clone() const override;
  97. virtual void SwapData( BOARD_ITEM* aImage ) override;
  98. };
  99. #endif // #define PCB_TEXTBOX_H