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.

169 lines
5.9 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-2018 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 KICAD_T aScanTypes[] ) const override
  43. {
  44. if( BOARD_ITEM::IsType( aScanTypes ) )
  45. return true;
  46. for( const KICAD_T* p = aScanTypes; *p != EOT; ++p )
  47. {
  48. if( *p == PCB_LOCATE_GRAPHIC_T )
  49. return true;
  50. else if( *p == PCB_LOCATE_BOARD_EDGE_T )
  51. return m_layer == Edge_Cuts;
  52. }
  53. return false;
  54. }
  55. /**
  56. * Sets the angle for arcs, and normalizes it within the range 0 - 360 degrees.
  57. * @param aAngle is tenths of degrees, but will soon be degrees.
  58. */
  59. void SetArcAngleAndEnd0( const EDA_ANGLE& aAngle, bool aCheckNegativeAngle = false );
  60. void SetArcGeometry0( const VECTOR2I& aStart, const VECTOR2I& aMid, const VECTOR2I& aEnd );
  61. /**
  62. * Move an edge of the footprint.
  63. * This is a footprint shape modification.
  64. * (should be only called by a footprint editing function)
  65. */
  66. void Move( const VECTOR2I& aMoveVector ) override;
  67. /**
  68. * Mirror an edge of the footprint.
  69. * Do not change the layer
  70. * This is a footprint shape modification.
  71. * (should be only called by a footprint editing function)
  72. */
  73. void Mirror( const VECTOR2I& aCentre, bool aMirrorAroundXAxis );
  74. /**
  75. * Rotate an edge of the footprint.
  76. * This is a footprint shape modification.
  77. * (should be only called by a footprint editing function )
  78. */
  79. void Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle ) override;
  80. /**
  81. * Flip entity relative to aCentre.
  82. * The item is mirrored, and layer changed to the paired corresponding layer if it is on a
  83. * paired layer.
  84. * This function should be called only from FOOTPRINT::Flip because it is not usual to flip
  85. * an item alone, without flipping the parent footprint (consider Mirror() instead).
  86. */
  87. void Flip( const VECTOR2I& aCentre, bool aFlipLeftRight ) override;
  88. bool IsParentFlipped() const;
  89. void SetStart0( const VECTOR2I& aPoint ) { m_start0 = aPoint; }
  90. const VECTOR2I& GetStart0() const { return m_start0; }
  91. void SetEnd0( const VECTOR2I& aPoint ) { m_end0 = aPoint; }
  92. const VECTOR2I& GetEnd0() const { return m_end0; }
  93. void SetBezierC1_0( const VECTOR2I& aPoint ) { m_bezierC1_0 = aPoint; }
  94. const VECTOR2I& GetBezierC1_0() const { return m_bezierC1_0; }
  95. void SetBezierC2_0( const VECTOR2I& aPoint ) { m_bezierC2_0 = aPoint; }
  96. const VECTOR2I& GetBezierC2_0() const { return m_bezierC2_0; }
  97. VECTOR2I GetCenter0() const;
  98. void SetCenter0( const VECTOR2I& aPt );
  99. VECTOR2I GetArcMid0() const;
  100. /**
  101. * Set relative coordinates from draw coordinates.
  102. * Call in only when the geometry or the footprint is modified and therefore the relative
  103. * coordinates have to be updated from the draw coordinates.
  104. */
  105. virtual void SetLocalCoord();
  106. /**
  107. * Set draw coordinates (absolute values ) from relative coordinates.
  108. * Must be called when a relative coordinate has changed in order to see the changes on screen
  109. */
  110. virtual void SetDrawCoord();
  111. void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
  112. wxString GetClass() const override
  113. {
  114. return wxT( "MGRAPHIC" );
  115. }
  116. wxString GetParentAsString() const { return m_parent->m_Uuid.AsString(); }
  117. wxString GetSelectMenuText( EDA_UNITS aUnits ) const override;
  118. BITMAPS GetMenuImage() const override;
  119. EDA_ITEM* Clone() const override;
  120. double ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const override;
  121. #if defined(DEBUG)
  122. void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
  123. #endif
  124. protected:
  125. VECTOR2I m_start0; ///< Start point or circle center, relative to footprint origin, orient 0.
  126. VECTOR2I m_end0; ///< End point or circle edge, relative to footprint origin, orient 0.
  127. VECTOR2I m_arcCenter0; ///< Center of arc, relative to footprint origin, orient 0.
  128. VECTOR2I m_bezierC1_0; ///< Bezier Control Point 1, relative to footprint origin, orient 0.
  129. VECTOR2I m_bezierC2_0; ///< Bezier Control Point 2, relative to footprint origin, orient 0.
  130. };
  131. #endif // FP_SHAPE_H