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
3.8 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_circle.h
  26. */
  27. #ifndef _LIB_CIRCLE_H_
  28. #define _LIB_CIRCLE_H_
  29. #include <lib_draw_item.h>
  30. class LIB_CIRCLE : public LIB_ITEM
  31. {
  32. int m_Radius;
  33. wxPoint m_Pos; // Position or centre (Arc and Circle) or start point (segments).
  34. int m_Width; // Line width.
  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_CIRCLE( LIB_PART * aParent );
  41. // Do not create a copy constructor. The one generated by the compiler is adequate.
  42. ~LIB_CIRCLE() { }
  43. wxString GetClass() const override
  44. {
  45. return wxT( "LIB_CIRCLE" );
  46. }
  47. bool Save( OUTPUTFORMATTER& aFormatter ) override;
  48. bool Load( LINE_READER& aLineReader, wxString& aErrorMsg ) override;
  49. bool HitTest( const wxPoint& aPosition ) const override;
  50. bool HitTest( const wxPoint& aPosRef, int aThreshold, const TRANSFORM& aTransform ) const override;
  51. int GetPenSize( ) const override;
  52. const EDA_RECT GetBoundingBox() const override;
  53. void GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ) override;
  54. void BeginEdit( STATUS_FLAGS aEditMode, const wxPoint aStartPoint = wxPoint( 0, 0 ) ) override;
  55. bool ContinueEdit( const wxPoint aNextPoint ) override;
  56. void EndEdit( const wxPoint& aPosition, bool aAbort = false ) override;
  57. void SetOffset( const wxPoint& aOffset ) override;
  58. bool Inside( EDA_RECT& aRect ) const override;
  59. void Move( const wxPoint& aPosition ) override;
  60. wxPoint GetPosition() const override { return m_Pos; }
  61. void MirrorHorizontal( const wxPoint& aCenter ) override;
  62. void MirrorVertical( const wxPoint& aCenter ) override;
  63. void Rotate( const wxPoint& aCenter, bool aRotateCCW = true ) override;
  64. void Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill,
  65. const TRANSFORM& aTransform ) override;
  66. int GetWidth() const override { return m_Width; }
  67. void SetWidth( int aWidth ) override { m_Width = aWidth; }
  68. void SetRadius( int aRadius ) { m_Radius = aRadius; }
  69. int GetRadius() const { return m_Radius; }
  70. wxString GetSelectMenuText() const override;
  71. BITMAP_DEF GetMenuImage() const override;
  72. EDA_ITEM* Clone() const override;
  73. private:
  74. /**
  75. * @copydoc LIB_ITEM::compare()
  76. *
  77. * The circle specific sort order is as follows:
  78. * - Circle horizontal (X) position.
  79. * - Circle vertical (Y) position.
  80. * - Circle radius.
  81. */
  82. int compare( const LIB_ITEM& aOther ) const override;
  83. };
  84. #endif // _LIB_CIRCLE_H_