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.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-2011 KiCad Developers, see change_log.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. /**
  25. * @file lib_polyline.h
  26. */
  27. #ifndef _LIB_POLYLINE_H_
  28. #define _LIB_POLYLINE_H_
  29. #include <lib_draw_item.h>
  30. class LIB_POLYLINE : public LIB_ITEM
  31. {
  32. int m_Width; // Line width
  33. std::vector<wxPoint> m_PolyPoints; // list of points (>= 2)
  34. int m_ModifyIndex; // Index of the polyline point to modify
  35. void drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
  36. COLOR4D aColor, GR_DRAWMODE aDrawMode, void* aData,
  37. const TRANSFORM& aTransform ) override;
  38. void calcEdit( const wxPoint& aPosition ) override;
  39. public:
  40. LIB_POLYLINE( LIB_PART * aParent );
  41. // Do not create a copy constructor. The one generated by the compiler is adequate.
  42. ~LIB_POLYLINE() { }
  43. wxString GetClass() const override
  44. {
  45. return wxT( "LIB_POLYLINE" );
  46. }
  47. bool Save( OUTPUTFORMATTER& aFormatter ) override;
  48. bool Load( LINE_READER& aLineReader, wxString& aErrorMsg ) override;
  49. void AddPoint( const wxPoint& aPoint );
  50. /**
  51. * Delete the segment at \a aPosition.
  52. */
  53. void DeleteSegment( const wxPoint aPosition );
  54. /**
  55. * @return the number of corners
  56. */
  57. unsigned GetCornerCount() const { return m_PolyPoints.size(); }
  58. bool HitTest( const wxPoint& aPosition ) const override;
  59. bool HitTest( const wxPoint &aPosition, int aThreshold, const TRANSFORM& aTransform ) const override;
  60. const EDA_RECT GetBoundingBox() const override;
  61. int GetPenSize( ) const override;
  62. void GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ) override;
  63. void BeginEdit( STATUS_FLAGS aEditMode, const wxPoint aStartPoint = wxPoint( 0, 0 ) ) override;
  64. bool ContinueEdit( const wxPoint aNextPoint ) override;
  65. void EndEdit( const wxPoint& aPosition, bool aAbort = false ) override;
  66. void SetOffset( const wxPoint& aOffset ) override;
  67. bool Inside( EDA_RECT& aRect ) const override;
  68. void Move( const wxPoint& aPosition ) override;
  69. wxPoint GetPosition() const override { return m_PolyPoints[0]; }
  70. void MirrorHorizontal( const wxPoint& aCenter ) override;
  71. void MirrorVertical( const wxPoint& aCenter ) override;
  72. void Rotate( const wxPoint& aCenter, bool aRotateCCW = true ) override;
  73. void Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill,
  74. const TRANSFORM& aTransform ) override;
  75. int GetWidth() const override { return m_Width; }
  76. void SetWidth( int aWidth ) override { m_Width = aWidth; }
  77. wxString GetSelectMenuText() const override;
  78. BITMAP_DEF GetMenuImage() const override;
  79. EDA_ITEM* Clone() const override;
  80. private:
  81. /**
  82. * @copydoc LIB_ITEM::compare()
  83. *
  84. * The sort order for specific to each polyline segment point is as follows:
  85. * - Line segment point horizontal (X) position.
  86. * - Line segment point vertical (Y) position.
  87. */
  88. int compare( const LIB_ITEM& aOther ) const override;
  89. };
  90. #endif // _LIB_POLYLINE_H_