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.

125 lines
4.1 KiB

  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
  5. * Copyright (C) 2004-2021 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 _LIB_POLYLINE_H_
  25. #define _LIB_POLYLINE_H_
  26. #include <lib_item.h>
  27. class LIB_POLYLINE : public LIB_ITEM
  28. {
  29. public:
  30. LIB_POLYLINE( LIB_SYMBOL* aParent );
  31. // Do not create a copy constructor. The one generated by the compiler is adequate.
  32. ~LIB_POLYLINE() { }
  33. wxString GetClass() const override
  34. {
  35. return wxT( "LIB_POLYLINE" );
  36. }
  37. wxString GetTypeName() const override
  38. {
  39. return _( "PolyLine" );
  40. }
  41. void ClearPoints() { m_PolyPoints.clear(); }
  42. void Reserve( size_t aPointCount ) { m_PolyPoints.reserve( aPointCount ); }
  43. void AddPoint( const wxPoint& aPoint );
  44. const std::vector< wxPoint >& GetPolyPoints() const { return m_PolyPoints; }
  45. /**
  46. * Delete the segment at \a aPosition.
  47. */
  48. void DeleteSegment( const wxPoint aPosition );
  49. void AddCorner( const wxPoint& aPosition );
  50. void RemoveCorner( int aIdx );
  51. /**
  52. * @return the number of corners
  53. */
  54. unsigned GetCornerCount() const { return m_PolyPoints.size(); }
  55. bool HitTest( const wxPoint& aPosition, int aAccuracy = 0 ) const override;
  56. bool HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy = 0 ) const override;
  57. const EDA_RECT GetBoundingBox() const override;
  58. int GetPenWidth() const override;
  59. void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
  60. void BeginEdit( const wxPoint& aStartPoint ) override;
  61. void CalcEdit( const wxPoint& aPosition ) override;
  62. bool ContinueEdit( const wxPoint& aNextPoint ) override;
  63. void EndEdit() override;
  64. void Offset( const wxPoint& aOffset ) override;
  65. void MoveTo( const wxPoint& aPosition ) override;
  66. wxPoint GetPosition() const override { return m_PolyPoints[0]; }
  67. void MirrorHorizontal( const wxPoint& aCenter ) override;
  68. void MirrorVertical( const wxPoint& aCenter ) override;
  69. void Rotate( const wxPoint& aCenter, bool aRotateCCW = true ) override;
  70. void Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill,
  71. const TRANSFORM& aTransform ) const override;
  72. int GetWidth() const override { return m_Width; }
  73. void SetWidth( int aWidth ) override { m_Width = aWidth; }
  74. wxString GetSelectMenuText( EDA_UNITS aUnits ) const override;
  75. BITMAPS GetMenuImage() const override;
  76. EDA_ITEM* Clone() const override;
  77. private:
  78. /**
  79. * @copydoc LIB_ITEM::compare()
  80. *
  81. * The sort order for specific to each polyline segment point is as follows:
  82. * - Line segment point horizontal (X) position.
  83. * - Line segment point vertical (Y) position.
  84. */
  85. int compare( const LIB_ITEM& aOther,
  86. LIB_ITEM::COMPARE_FLAGS aCompareFlags = LIB_ITEM::COMPARE_FLAGS::NORMAL ) const override;
  87. void print( const RENDER_SETTINGS* aSettings, const wxPoint& aOffset, void* aData,
  88. const TRANSFORM& aTransform ) override;
  89. int m_Width; // Line width
  90. std::vector<wxPoint> m_PolyPoints; // list of points (>= 2)
  91. };
  92. #endif // _LIB_POLYLINE_H_