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

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