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.

126 lines
3.9 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_rectangle.h
  26. */
  27. #ifndef _LIB_RECTANGLE_H_
  28. #define _LIB_RECTANGLE_H_
  29. #include <lib_draw_item.h>
  30. class LIB_RECTANGLE : public LIB_ITEM
  31. {
  32. wxPoint m_End; // Rectangle end point.
  33. wxPoint m_Pos; // Rectangle start point.
  34. int m_Width; // Line width
  35. bool m_isWidthLocked; // Flag: Keep width locked
  36. bool m_isHeightLocked; // Flag: Keep height locked
  37. bool m_isStartPointSelected; // Flag: is the upper left edge selected?
  38. void drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
  39. EDA_COLOR_T aColor, GR_DRAWMODE aDrawMode, void* aData,
  40. const TRANSFORM& aTransform );
  41. void calcEdit( const wxPoint& aPosition );
  42. public:
  43. LIB_RECTANGLE( LIB_PART * aParent );
  44. // Do not create a copy constructor. The one generated by the compiler is adequate.
  45. ~LIB_RECTANGLE() { }
  46. wxString GetClass() const
  47. {
  48. return wxT( "LIB_RECTANGLE" );
  49. }
  50. void SetEndPosition( const wxPoint& aPosition ) { m_End = aPosition; }
  51. bool Save( OUTPUTFORMATTER& aFormatter );
  52. bool Load( LINE_READER& aLineReader, wxString& aErrorMsg );
  53. bool HitTest( const wxPoint& aPosition ) const;
  54. bool HitTest( const wxPoint &aPosRef, int aThreshold, const TRANSFORM& aTransform ) const;
  55. int GetPenSize( ) const;
  56. const EDA_RECT GetBoundingBox() const; // Virtual
  57. void GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList );
  58. void BeginEdit( STATUS_FLAGS aEditMode, const wxPoint aStartPoint = wxPoint( 0, 0 ) );
  59. bool ContinueEdit( const wxPoint aNextPoint );
  60. void EndEdit( const wxPoint& aPosition, bool aAbort = false );
  61. void SetOffset( const wxPoint& aOffset );
  62. bool Inside( EDA_RECT& aRect ) const;
  63. void Move( const wxPoint& aPosition );
  64. wxPoint GetPosition() const { return m_Pos; }
  65. void MirrorHorizontal( const wxPoint& aCenter );
  66. void MirrorVertical( const wxPoint& aCenter );
  67. void Rotate( const wxPoint& aCenter, bool aRotateCCW = true );
  68. void Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill,
  69. const TRANSFORM& aTransform );
  70. int GetWidth() const { return m_Width; }
  71. void SetWidth( int aWidth ) { m_Width = aWidth; }
  72. wxString GetSelectMenuText() const;
  73. BITMAP_DEF GetMenuImage() const { return add_rectangle_xpm; }
  74. EDA_ITEM* Clone() const;
  75. private:
  76. /**
  77. * @copydoc LIB_ITEM::compare()
  78. *
  79. * The rectangle specific sort order is as follows:
  80. * - Rectangle horizontal (X) start position.
  81. * - Rectangle vertical (Y) start position.
  82. * - Rectangle horizontal (X) end position.
  83. * - Rectangle vertical (Y) end position.
  84. */
  85. int compare( const LIB_ITEM& aOther ) const;
  86. };
  87. #endif // _LIB_RECTANGLE_H_