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.

164 lines
5.5 KiB

14 years ago
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) 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. /**
  26. * @file class_edge_mod.h
  27. * @brief EDGE_MODULE class definition.
  28. */
  29. #ifndef CLASS_EDGE_MOD_H_
  30. #define CLASS_EDGE_MOD_H_
  31. #include <wx/gdicmn.h>
  32. #include <class_drawsegment.h>
  33. class LINE_READER;
  34. class MSG_PANEL_ITEM;
  35. class EDGE_MODULE : public DRAWSEGMENT
  36. {
  37. public:
  38. EDGE_MODULE( MODULE* parent, STROKE_T aShape = S_SEGMENT );
  39. // Do not create a copy constructor & operator=.
  40. // The ones generated by the compiler are adequate.
  41. ~EDGE_MODULE();
  42. static inline bool ClassOf( const EDA_ITEM* aItem )
  43. {
  44. return aItem && PCB_MODULE_EDGE_T == aItem->Type();
  45. }
  46. bool IsType( const KICAD_T aScanTypes[] ) const override
  47. {
  48. if( BOARD_ITEM::IsType( aScanTypes ) )
  49. return true;
  50. for( const KICAD_T* p = aScanTypes; *p != EOT; ++p )
  51. {
  52. if( *p == PCB_LOCATE_GRAPHIC_T )
  53. return true;
  54. else if( *p == PCB_LOCATE_BOARD_EDGE_T )
  55. return m_Layer == Edge_Cuts;
  56. }
  57. return false;
  58. }
  59. void SetAngle( double aAngle ) override;
  60. /**
  61. * Move an edge of the footprint.
  62. * This is a footprint shape modification.
  63. * (should be only called by a footprint editing function)
  64. */
  65. void Move( const wxPoint& aMoveVector ) override;
  66. /**
  67. * Mirror an edge of the footprint.
  68. * Do not change the layer
  69. * This is a footprint shape modification.
  70. * (should be only called by a footprint editing function)
  71. */
  72. void Mirror( const wxPoint& aCentre, bool aMirrorAroundXAxis );
  73. /**
  74. * Rotate an edge of the footprint.
  75. * This is a footprint shape modification.
  76. * (should be only called by a footprint editing function )
  77. */
  78. void Rotate( const wxPoint& aRotCentre, double aAngle ) override;
  79. /**
  80. * Flip entity relative to aCentre.
  81. * The item is mirrored, and layer changed to the paired corresponding layer if it is on
  82. * a paired layer.
  83. * This function should be called only from MODULE::Flip because it is not usual to flip
  84. * an item alone, without flipping the parent footprint (consider Mirror() instead).
  85. */
  86. void Flip( const wxPoint& aCentre, bool aFlipLeftRight ) override;
  87. bool IsParentFlipped() const;
  88. void SetStart0( const wxPoint& aPoint ) { m_Start0 = aPoint; }
  89. const wxPoint& GetStart0() const { return m_Start0; }
  90. void SetEnd0( const wxPoint& aPoint ) { m_End0 = aPoint; }
  91. const wxPoint& GetEnd0() const { return m_End0; }
  92. void SetThirdPoint0( const wxPoint& aPoint ){ m_ThirdPoint0 = aPoint; }
  93. const wxPoint& GetThirdPoint0() const { return m_ThirdPoint0; }
  94. void SetBezier0_C1( const wxPoint& aPoint ) { m_Bezier0_C1 = aPoint; }
  95. const wxPoint& GetBezier0_C1() const { return m_Bezier0_C1; }
  96. void SetBezier0_C2( const wxPoint& aPoint ) { m_Bezier0_C2 = aPoint; }
  97. const wxPoint& GetBezier0_C2() const { return m_Bezier0_C2; }
  98. /**
  99. * Set relative coordinates from draw coordinates.
  100. * Call in only when the geometry or the footprint is modified and therefore the relative
  101. * coordinates have to be updated from the draw coordinates.
  102. */
  103. void SetLocalCoord();
  104. /**
  105. * Set draw coordinates (absolute values ) from relative coordinates.
  106. * Must be called when a relative coordinate has changed in order to see the changes on screen
  107. */
  108. void SetDrawCoord();
  109. void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
  110. wxString GetClass() const override
  111. {
  112. return wxT( "MGRAPHIC" );
  113. }
  114. wxString GetSelectMenuText( EDA_UNITS aUnits ) const override;
  115. BITMAP_DEF GetMenuImage() const override;
  116. EDA_ITEM* Clone() const override;
  117. virtual unsigned int ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const override;
  118. #if defined(DEBUG)
  119. void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
  120. #endif
  121. wxPoint m_Start0; ///< Start point or center, relative to module origin, orient 0.
  122. wxPoint m_End0; ///< End point, relative to module origin, orient 0.
  123. wxPoint m_ThirdPoint0; ///< End point for an arc.
  124. wxPoint m_Bezier0_C1; ///< Bezier Control Point 1, relative to module origin, orient 0.
  125. wxPoint m_Bezier0_C2; ///< Bezier Control Point 2, relative to module origin, orient 0.
  126. };
  127. #endif // CLASS_EDGE_MOD_H_