KiCad PCB EDA Suite
sch_bitmap.h
Go to the documentation of this file.
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 (C) 2011-2021 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 
29 #ifndef _SCH_BITMAP_H_
30 #define _SCH_BITMAP_H_
31 
32 
33 #include <sch_item.h>
34 #include <bitmap_base.h>
35 
36 
40 class SCH_BITMAP : public SCH_ITEM
41 {
42 public:
43  SCH_BITMAP( const wxPoint& pos = wxPoint( 0, 0 ) );
44 
45  SCH_BITMAP( const SCH_BITMAP& aSchBitmap );
46 
48  {
49  delete m_image;
50  }
51 
52  SCH_BITMAP& operator=( const SCH_ITEM& aItem );
53 
55  {
56  wxCHECK_MSG( m_image != nullptr, nullptr, "Invalid SCH_BITMAP init, m_image is NULL." );
57  return m_image;
58  }
59 
66  double GetImageScale() const
67  {
68  return m_image->GetScale();
69  }
70 
71  void SetImageScale( double aScale )
72  {
73  m_image->SetScale( aScale );
74  }
75 
76  static inline bool ClassOf( const EDA_ITEM* aItem )
77  {
78  return aItem && SCH_BITMAP_T == aItem->Type();
79  }
80 
81  wxString GetClass() const override
82  {
83  return wxT( "SCH_BITMAP" );
84  }
85 
89  wxSize GetSize() const;
90 
91  const EDA_RECT GetBoundingBox() const override;
92 
93  void SwapData( SCH_ITEM* aItem ) override;
94 
95  void Print( const RENDER_SETTINGS* aSettings, const wxPoint& aOffset ) override;
96 
98  virtual void ViewGetLayers( int aLayers[], int& aCount ) const override;
99 
108  bool ReadImageFile( const wxString& aFullFilename );
109 
110  void Move( const wxPoint& aMoveVector ) override
111  {
112  m_pos += aMoveVector;
113  }
114 
121  bool IsMovableFromAnchorPoint() const override { return false; }
122 
123  void MirrorHorizontally( int aCenter ) override;
124  void MirrorVertically( int aCenter ) override;
125  void Rotate( const wxPoint& aCenter ) override;
126 
127  wxString GetSelectMenuText( EDA_UNITS aUnits ) const override
128  {
129  return wxString( _( "Image" ) );
130  }
131 
132  BITMAPS GetMenuImage() const override;
133 
134  void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
135 
136  wxPoint GetPosition() const override { return m_pos; }
137  void SetPosition( const wxPoint& aPosition ) override { m_pos = aPosition; }
138 
139  bool HitTest( const wxPoint& aPosition, int aAccuracy = 0 ) const override;
140  bool HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy = 0 ) const override;
141 
142  void Plot( PLOTTER* aPlotter ) const override;
143 
144  EDA_ITEM* Clone() const override;
145 
146 #if defined(DEBUG)
147  void Show( int nestLevel, std::ostream& os ) const override;
148 #endif
149 
150 private:
151  wxPoint m_pos; // XY coordinates of center of the bitmap
152  BITMAP_BASE* m_image; // the BITMAP_BASE item
153 };
154 
155 
156 #endif // _SCH_BITMAP_H_
void GetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList) override
Populate aList of MSG_PANEL_ITEM objects with it's internal state for display purposes.
Definition: sch_bitmap.cpp:199
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
void SetScale(double aScale)
Definition: bitmap_base.h:80
void Move(const wxPoint &aMoveVector) override
Move the item by aMoveVector to a new position.
Definition: sch_bitmap.h:110
void Rotate(const wxPoint &aCenter) override
Rotate the item around aCenter 90 degrees in the clockwise direction.
Definition: sch_bitmap.cpp:145
double GetScale() const
Definition: bitmap_base.h:79
bool IsMovableFromAnchorPoint() const override
Return true for items which are moved with the anchor point at mouse cursor and false for items moved...
Definition: sch_bitmap.h:121
void Print(const RENDER_SETTINGS *aSettings, const wxPoint &aOffset) override
Print a schematic item.
Definition: sch_bitmap.cpp:117
wxPoint m_pos
Definition: sch_bitmap.h:151
void Plot(PLOTTER *aPlotter) const override
Plot the schematic item to aPlotter.
Definition: sch_bitmap.cpp:186
void MirrorVertically(int aCenter) override
Mirror item vertically about aCenter.
Definition: sch_bitmap.cpp:131
wxPoint GetPosition() const override
Definition: sch_bitmap.h:136
The base class for create windows for drawing purpose.
const EDA_RECT GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: sch_bitmap.cpp:107
This class handle bitmap images in KiCad.
Definition: bitmap_base.h:51
bool HitTest(const wxPoint &aPosition, int aAccuracy=0) const override
Test if aPosition is contained within or on the bounding box of an item.
Definition: sch_bitmap.cpp:163
wxString GetSelectMenuText(EDA_UNITS aUnits) const override
Return the text to display to be used in the selection clarification context menu when multiple items...
Definition: sch_bitmap.h:127
wxSize GetSize() const
Definition: sch_bitmap.cpp:125
BITMAP_BASE * GetImage() const
Definition: sch_bitmap.h:54
void SetImageScale(double aScale)
Definition: sch_bitmap.h:71
void SwapData(SCH_ITEM *aItem) override
Swap the internal data structures aItem with the schematic item.
Definition: sch_bitmap.cpp:95
#define _(s)
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
Definition: sch_bitmap.cpp:193
Object to handle a bitmap image that can be inserted in a schematic.
Definition: sch_bitmap.h:40
SCH_BITMAP & operator=(const SCH_ITEM &aItem)
Definition: sch_bitmap.cpp:62
EDA_UNITS
Definition: eda_units.h:38
Base plotter engine class.
Definition: plotter.h:121
BITMAPS
A list of all bitmap identifiers.
Definition: bitmaps_list.h:32
double GetImageScale() const
Definition: sch_bitmap.h:66
Handle the component boundary box.
Definition: eda_rect.h:42
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: sch_bitmap.cpp:89
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:100
SCH_BITMAP(const wxPoint &pos=wxPoint(0, 0))
Definition: sch_bitmap.cpp:43
bool ReadImageFile(const wxString &aFullFilename)
Read and store an image file.
Definition: sch_bitmap.cpp:83
static bool ClassOf(const EDA_ITEM *aItem)
Definition: sch_bitmap.h:76
void MirrorHorizontally(int aCenter) override
Mirror item horizontally about aCenter.
Definition: sch_bitmap.cpp:138
virtual void ViewGetLayers(int aLayers[], int &aCount) const override
Definition: sch_bitmap.cpp:210
BITMAP_BASE * m_image
Definition: sch_bitmap.h:152
wxString GetClass() const override
Return the class name.
Definition: sch_bitmap.h:81
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:197
void SetPosition(const wxPoint &aPosition) override
Definition: sch_bitmap.h:137
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:113