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.

119 lines
3.5 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_bezier.h
  26. */
  27. #ifndef _LIB_BEZIER_H_
  28. #define _LIB_BEZIER_H_
  29. #include <lib_draw_item.h>
  30. /**
  31. * Class LIB_BEZIER
  32. * defines bezier curve graphic body item.
  33. */
  34. class LIB_BEZIER : public LIB_ITEM
  35. {
  36. int m_Width; // Line width
  37. std::vector<wxPoint> m_BezierPoints; // list of parameter (3|4)
  38. std::vector<wxPoint> m_PolyPoints; // list of points (>= 2)
  39. void drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
  40. EDA_COLOR_T aColor, GR_DRAWMODE aDrawMode, void* aData,
  41. const TRANSFORM& aTransform );
  42. public:
  43. LIB_BEZIER( LIB_PART * aParent );
  44. // Do not create a copy constructor. The one generated by the compiler is adequate.
  45. ~LIB_BEZIER() { }
  46. wxString GetClass() const
  47. {
  48. return wxT( "LIB_BEZIER" );
  49. }
  50. bool Save( OUTPUTFORMATTER& aFormatter );
  51. bool Load( LINE_READER& aLineReader, wxString& aErrorMsg );
  52. void AddPoint( const wxPoint& aPoint );
  53. void SetOffset( const wxPoint& aOffset );
  54. /**
  55. * @return the number of corners
  56. */
  57. unsigned GetCornerCount() const { return m_PolyPoints.size(); }
  58. bool HitTest( const wxPoint& aPosition ) const;
  59. bool HitTest( const wxPoint& aPosRef, int aThreshold, const TRANSFORM& aTransform ) const;
  60. const EDA_RECT GetBoundingBox() const; // Virtual
  61. bool Inside( EDA_RECT& aRect ) const;
  62. void Move( const wxPoint& aPosition );
  63. wxPoint GetPosition() const { return m_PolyPoints[0]; }
  64. void MirrorHorizontal( const wxPoint& aCenter );
  65. void MirrorVertical( const wxPoint& aCenter );
  66. void Rotate( const wxPoint& aCenter, bool aRotateCCW = true );
  67. void Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill,
  68. const TRANSFORM& aTransform );
  69. int GetWidth() const { return m_Width; }
  70. void SetWidth( int aWidth ) { m_Width = aWidth; }
  71. int GetPenSize( ) const;
  72. void GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList );
  73. EDA_ITEM* Clone() const;
  74. private:
  75. /**
  76. * @copydoc LIB_ITEM::compare()
  77. *
  78. * The bezier curve specific sort order for each curve segment point is as follows:
  79. * - Bezier horizontal (X) point position.
  80. * - Bezier vertical (Y) point position.
  81. */
  82. int compare( const LIB_ITEM& aOther ) const;
  83. };
  84. #endif // _LIB_BEZIER_H_