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.

152 lines
5.3 KiB

14 years ago
  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr
  5. * Copyright (C) 2013 Wayne Stambaugh <stambaughw@verizon.net>
  6. * Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors.
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License
  10. * as published by the Free Software Foundation; either version 2
  11. * of the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, you may find one here:
  20. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  21. * or you may search the http://www.gnu.org website for the version 2 license,
  22. * or you may write to the Free Software Foundation, Inc.,
  23. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  24. */
  25. #ifndef FP_SHAPE_H
  26. #define FP_SHAPE_H
  27. #include <pcb_shape.h>
  28. class LINE_READER;
  29. class MSG_PANEL_ITEM;
  30. class FP_SHAPE : public PCB_SHAPE
  31. {
  32. public:
  33. FP_SHAPE( FOOTPRINT* aParent, SHAPE_T aShape = SHAPE_T::SEGMENT,
  34. KICAD_T aItemType = PCB_FP_SHAPE_T );
  35. // Do not create a copy constructor & operator=.
  36. // The ones generated by the compiler are adequate.
  37. ~FP_SHAPE();
  38. static inline bool ClassOf( const EDA_ITEM* aItem )
  39. {
  40. return aItem && PCB_FP_SHAPE_T == aItem->Type();
  41. }
  42. bool IsType( const std::vector<KICAD_T>& aScanTypes ) const override
  43. {
  44. if( PCB_SHAPE::IsType( aScanTypes ) )
  45. return true;
  46. // No special processing above and beyond PCB_SHAPE at present....
  47. return false;
  48. }
  49. /**
  50. * Sets the angle for arcs, and normalizes it within the range 0 - 360 degrees.
  51. * @param aAngle is tenths of degrees, but will soon be degrees.
  52. */
  53. void SetArcAngleAndEnd0( const EDA_ANGLE& aAngle, bool aCheckNegativeAngle = false );
  54. void SetArcGeometry0( const VECTOR2I& aStart, const VECTOR2I& aMid, const VECTOR2I& aEnd );
  55. void Move( const VECTOR2I& aMoveVector ) override;
  56. /**
  57. * Mirror horizontally or vertically. Do not change the layer.
  58. */
  59. void Mirror( const VECTOR2I& aCentre, bool aMirrorAroundXAxis ) override;
  60. void Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle ) override;
  61. /**
  62. * Flip entity relative to aCentre.
  63. * The item is mirrored, and layer changed to the paired corresponding layer if it is on a
  64. * paired layer.
  65. * This function should be called only from FOOTPRINT::Flip because it is not usual to flip
  66. * an item alone, without flipping the parent footprint (consider Mirror() instead).
  67. */
  68. void Flip( const VECTOR2I& aCentre, bool aFlipLeftRight ) override;
  69. bool IsParentFlipped() const;
  70. void SetStart0( const VECTOR2I& aPoint ) { m_start0 = aPoint; }
  71. const VECTOR2I& GetStart0() const { return m_start0; }
  72. void SetEnd0( const VECTOR2I& aPoint ) { m_end0 = aPoint; }
  73. const VECTOR2I& GetEnd0() const { return m_end0; }
  74. void SetBezierC1_0( const VECTOR2I& aPoint ) { m_bezierC1_0 = aPoint; }
  75. const VECTOR2I& GetBezierC1_0() const { return m_bezierC1_0; }
  76. void SetBezierC2_0( const VECTOR2I& aPoint ) { m_bezierC2_0 = aPoint; }
  77. const VECTOR2I& GetBezierC2_0() const { return m_bezierC2_0; }
  78. VECTOR2I GetCenter0() const;
  79. void SetCenter0( const VECTOR2I& aPt );
  80. VECTOR2I GetArcMid0() const;
  81. /**
  82. * Set relative coordinates from draw coordinates.
  83. * Call in only when the geometry or the footprint is modified and therefore the relative
  84. * coordinates have to be updated from the draw coordinates.
  85. */
  86. virtual void SetLocalCoord();
  87. /**
  88. * Set draw coordinates (absolute values ) from relative coordinates.
  89. * Must be called when a relative coordinate has changed in order to see the changes on screen
  90. */
  91. virtual void SetDrawCoord();
  92. void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
  93. wxString GetClass() const override
  94. {
  95. return wxT( "MGRAPHIC" );
  96. }
  97. wxString GetParentAsString() const;
  98. wxString GetSelectMenuText( UNITS_PROVIDER* aUnitsProvider ) const override;
  99. BITMAPS GetMenuImage() const override;
  100. EDA_ITEM* Clone() const override;
  101. double ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const override;
  102. #if defined(DEBUG)
  103. void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
  104. #endif
  105. protected:
  106. VECTOR2I m_start0; ///< Start point or circle center, relative to footprint origin, orient 0.
  107. VECTOR2I m_end0; ///< End point or circle edge, relative to footprint origin, orient 0.
  108. VECTOR2I m_arcCenter0; ///< Center of arc, relative to footprint origin, orient 0.
  109. VECTOR2I m_bezierC1_0; ///< Bezier Control Point 1, relative to footprint origin, orient 0.
  110. VECTOR2I m_bezierC2_0; ///< Bezier Control Point 2, relative to footprint origin, orient 0.
  111. ARC_MID m_arcMidData_0; ///< Originating Arc data, orient 0
  112. };
  113. #endif // FP_SHAPE_H