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.

128 lines
4.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, jp.charras at wanadoo.fr
  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_TARGET_H
  25. #define PCB_TARGET_H
  26. #include <board_item.h>
  27. class EDA_RECT;
  28. class LINE_READER;
  29. class PCB_TARGET : public BOARD_ITEM
  30. {
  31. public:
  32. PCB_TARGET( BOARD_ITEM* aParent );
  33. // Do not create a copy constructor. The one generated by the compiler is adequate.
  34. PCB_TARGET( BOARD_ITEM* aParent, int aShape, PCB_LAYER_ID aLayer, const VECTOR2I& aPos,
  35. int aSize, int aWidth );
  36. // Do not create a copy constructor & operator=.
  37. // The ones generated by the compiler are adequate.
  38. ~PCB_TARGET();
  39. static inline bool ClassOf( const EDA_ITEM* aItem )
  40. {
  41. return aItem && PCB_TARGET_T == aItem->Type();
  42. }
  43. void SetPosition( const VECTOR2I& aPos ) override { m_pos = aPos; }
  44. VECTOR2I GetPosition() const override { return m_pos; }
  45. void SetShape( int aShape ) { m_shape = aShape; }
  46. int GetShape() const { return m_shape; }
  47. void SetSize( int aSize ) { m_size = aSize; }
  48. int GetSize() const { return m_size; }
  49. void SetWidth( int aWidth ) { m_lineWidth = aWidth; }
  50. int GetWidth() const { return m_lineWidth; }
  51. void Move( const VECTOR2I& aMoveVector ) override
  52. {
  53. m_pos += aMoveVector;
  54. }
  55. void Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle ) override;
  56. void Flip( const VECTOR2I& aCentre, bool aFlipLeftRight ) override;
  57. wxString GetClass() const override
  58. {
  59. return wxT( "PCB_TARGET" );
  60. }
  61. bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override;
  62. bool HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy = 0 ) const override;
  63. // Virtual function
  64. const EDA_RECT GetBoundingBox() const override;
  65. std::shared_ptr<SHAPE> GetEffectiveShape( PCB_LAYER_ID aLayer ) const override;
  66. wxString GetSelectMenuText( EDA_UNITS aUnits ) const override;
  67. BITMAPS GetMenuImage() const override;
  68. EDA_ITEM* Clone() const override;
  69. virtual void SwapData( BOARD_ITEM* aImage ) override;
  70. void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
  71. /**
  72. * Convert the shape to a closed polygon.
  73. *
  74. * Used in filling zones calculations. Circles and arcs are approximated by segments.
  75. *
  76. * @param aCornerBuffer is a buffer to store the polygon.
  77. * @param aClearanceValue is the clearance around the pad.
  78. * @param aError is the maximum deviation from a true arc.
  79. * @param aErrorLoc whether any approximation error shoule be placed inside or outside
  80. * @param ignoreLineWidth is used for edge cut items where the line width is only
  81. * for visualization
  82. */
  83. void TransformShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBuffer,
  84. PCB_LAYER_ID aLayer, int aClearanceValue,
  85. int aError, ERROR_LOC aErrorLoc,
  86. bool ignoreLineWidth = false ) const override;
  87. #if defined(DEBUG)
  88. void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
  89. #endif
  90. private:
  91. int m_shape; // bit 0 : 0 = draw +, 1 = draw X
  92. int m_size;
  93. int m_lineWidth;
  94. VECTOR2I m_pos;
  95. };
  96. #endif