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.

117 lines
4.2 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-2022 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_SHAPE_H
  25. #define LIB_SHAPE_H
  26. #include <lib_item.h>
  27. #include <eda_shape.h>
  28. class LIB_SHAPE : public LIB_ITEM, public EDA_SHAPE
  29. {
  30. public:
  31. LIB_SHAPE( LIB_SYMBOL* aParent, SHAPE_T aShape, int aLineWidth = 0,
  32. FILL_T aFillType = FILL_T::NO_FILL, KICAD_T aType = LIB_SHAPE_T );
  33. // Do not create a copy constructor. The one generated by the compiler is adequate.
  34. ~LIB_SHAPE() { }
  35. wxString GetClass() const override
  36. {
  37. return wxT( "LIB_SHAPE" );
  38. }
  39. wxString GetTypeName() const override
  40. {
  41. return ShowShape();
  42. }
  43. STROKE_PARAMS GetStroke() const { return m_stroke; }
  44. void SetStroke( const STROKE_PARAMS& aStroke ) { m_stroke = aStroke; }
  45. bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override;
  46. bool HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy = 0 ) const override;
  47. int GetPenWidth() const override;
  48. const EDA_RECT GetBoundingBox() const override;
  49. void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
  50. void BeginEdit( const VECTOR2I& aStartPoint ) override { beginEdit( aStartPoint ); }
  51. bool ContinueEdit( const VECTOR2I& aPosition ) override { return continueEdit( aPosition ); }
  52. void CalcEdit( const VECTOR2I& aPosition ) override { calcEdit( aPosition ); }
  53. void EndEdit() override { endEdit( false ); }
  54. void SetEditState( int aState ) { setEditState( aState ); }
  55. void AddPoint( const VECTOR2I& aPosition );
  56. void Offset( const VECTOR2I& aOffset ) override;
  57. void MoveTo( const VECTOR2I& aPosition ) override;
  58. VECTOR2I GetPosition() const override { return getPosition(); }
  59. void SetPosition( const VECTOR2I& aPosition ) override { setPosition( aPosition ); }
  60. VECTOR2I GetCenter() const { return getCenter(); }
  61. void MirrorHorizontal( const VECTOR2I& aCenter ) override;
  62. void MirrorVertical( const VECTOR2I& aCenter ) override;
  63. void Rotate( const VECTOR2I& aCenter, bool aRotateCCW = true ) override;
  64. void Plot( PLOTTER* aPlotter, bool aBackground, const VECTOR2I& aOffset,
  65. const TRANSFORM& aTransform ) const override;
  66. wxString GetSelectMenuText( EDA_UNITS aUnits ) const override;
  67. BITMAPS GetMenuImage() const override;
  68. EDA_ITEM* Clone() const override;
  69. void ViewGetLayers( int aLayers[], int& aCount ) const override;
  70. private:
  71. /**
  72. * @copydoc LIB_ITEM::compare()
  73. *
  74. * The circle specific sort order is as follows:
  75. * - Circle horizontal (X) position.
  76. * - Circle vertical (Y) position.
  77. * - Circle radius.
  78. */
  79. int compare( const LIB_ITEM& aOther,
  80. LIB_ITEM::COMPARE_FLAGS aCompareFlags = LIB_ITEM::COMPARE_FLAGS::NORMAL ) const override;
  81. void print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset, void* aData,
  82. const TRANSFORM& aTransform ) override;
  83. EDA_ANGLE getParentOrientation() const override { return ANGLE_0; }
  84. VECTOR2I getParentPosition() const override { return VECTOR2I(); }
  85. };
  86. #endif // LIB_SHAPE_H