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.

137 lines
4.3 KiB

7 years ago
  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2011 jean-pierre.charras
  5. * Copyright The 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. /**
  25. * @file sch_bitmap.h
  26. */
  27. #pragma once
  28. #include <sch_item.h>
  29. #include <reference_image.h>
  30. /**
  31. * Object to handle a bitmap image that can be inserted in a schematic.
  32. */
  33. class SCH_BITMAP : public SCH_ITEM
  34. {
  35. public:
  36. SCH_BITMAP( const VECTOR2I& pos = VECTOR2I( 0, 0 ) );
  37. SCH_BITMAP( const SCH_BITMAP& aSchBitmap );
  38. SCH_BITMAP& operator=( const SCH_ITEM& aItem );
  39. /**
  40. * @return the underlying reference image object.
  41. */
  42. REFERENCE_IMAGE& GetReferenceImage() { return m_referenceImage; }
  43. const REFERENCE_IMAGE& GetReferenceImage() const { return m_referenceImage; }
  44. int GetX() const { return GetPosition().x; };
  45. void SetX( int aX ) { SetPosition( VECTOR2I( aX, GetY() ) ); }
  46. int GetY() const { return GetPosition().y; }
  47. void SetY( int aY ) { SetPosition( VECTOR2I( GetX(), aY ) ); }
  48. static inline bool ClassOf( const EDA_ITEM* aItem )
  49. {
  50. return aItem && SCH_BITMAP_T == aItem->Type();
  51. }
  52. wxString GetClass() const override
  53. {
  54. return wxT( "SCH_BITMAP" );
  55. }
  56. const BOX2I GetBoundingBox() const override;
  57. /// @copydoc VIEW_ITEM::ViewGetLayers()
  58. virtual std::vector<int> ViewGetLayers() const override;
  59. void Move( const VECTOR2I& aMoveVector ) override;
  60. /**
  61. * Return true for items which are moved with the anchor point at mouse cursor and false
  62. * for items moved with no reference to anchor.
  63. *
  64. * @return false for a bus entry.
  65. */
  66. bool IsMovableFromAnchorPoint() const override { return false; }
  67. void MirrorHorizontally( int aCenter ) override;
  68. void MirrorVertically( int aCenter ) override;
  69. void Rotate( const VECTOR2I& aCenter, bool aRotateCCW ) override;
  70. wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const override
  71. {
  72. return wxString( _( "Image" ) );
  73. }
  74. BITMAPS GetMenuImage() const override;
  75. void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
  76. VECTOR2I GetPosition() const override;
  77. void SetPosition( const VECTOR2I& aPosition ) override;
  78. bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override;
  79. bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const override;
  80. void Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS& aPlotOpts,
  81. int aUnit, int aBodyStyle, const VECTOR2I& aOffset, bool aDimmed ) override;
  82. EDA_ITEM* Clone() const override;
  83. double Similarity( const SCH_ITEM& aOther ) const override;
  84. bool operator==( const SCH_ITEM& aOther ) const override;
  85. #if defined(DEBUG)
  86. void Show( int nestLevel, std::ostream& os ) const override;
  87. #endif
  88. protected:
  89. void swapData( SCH_ITEM* aItem ) override;
  90. private:
  91. friend struct SCH_BITMAP_DESC;
  92. // Property manager interfaces
  93. int GetWidth() const;
  94. void SetWidth( int aWidth );
  95. int GetHeight() const;
  96. void SetHeight( int aHeight );
  97. int GetTransformOriginOffsetX() const;
  98. void SetTransformOriginOffsetX( int aX );
  99. int GetTransformOriginOffsetY() const;
  100. void SetTransformOriginOffsetY( int aY );
  101. double GetImageScale() const;
  102. void SetImageScale( double aScale );
  103. REFERENCE_IMAGE m_referenceImage;
  104. };