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-2019 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 
30 #ifndef _SCH_BITMAP_H_
31 #define _SCH_BITMAP_H_
32 
33 
34 #include <sch_item.h>
35 #include <bitmap_base.h>
36 
37 
42 class SCH_BITMAP : public SCH_ITEM
43 {
44  wxPoint m_pos; // XY coordinates of center of the bitmap
45  BITMAP_BASE* m_image; // the BITMAP_BASE item
46 
47 public:
48  SCH_BITMAP( const wxPoint& pos = wxPoint( 0, 0 ) );
49 
50  SCH_BITMAP( const SCH_BITMAP& aSchBitmap );
51 
53  {
54  delete m_image;
55  }
56 
57  SCH_ITEM& operator=( const SCH_ITEM& aItem );
58 
60  {
61  wxCHECK_MSG( m_image != NULL, NULL, "Invalid SCH_BITMAP init, m_image is NULL." );
62  return m_image;
63  }
64 
71  double GetImageScale() const
72  {
73  return m_image->GetScale();
74  }
75 
76  void SetImageScale( double aScale )
77  {
78  m_image->SetScale( aScale );
79  }
80 
81  static inline bool ClassOf( const EDA_ITEM* aItem )
82  {
83  return aItem && SCH_BITMAP_T == aItem->Type();
84  }
85 
86  wxString GetClass() const override
87  {
88  return wxT( "SCH_BITMAP" );
89  }
90 
94  wxSize GetSize() const;
95 
96  const EDA_RECT GetBoundingBox() const override;
97 
98  void SwapData( SCH_ITEM* aItem ) override;
99 
100  void Print( wxDC* aDC, const wxPoint& aOffset ) override;
101 
103  virtual void ViewGetLayers( int aLayers[], int& aCount ) const override;
104 
112  bool ReadImageFile( const wxString& aFullFilename );
113 
114  void Move( const wxPoint& aMoveVector ) override
115  {
116  m_pos += aMoveVector;
117  }
118 
125  bool IsMovableFromAnchorPoint() override { return false; }
126 
127  void MirrorY( int aYaxis_position ) override;
128  void MirrorX( int aXaxis_position ) override;
129  void Rotate( wxPoint aPosition ) override;
130 
131  wxString GetSelectMenuText( EDA_UNITS_T aUnits ) const override
132  {
133  return wxString( _( "Image" ) );
134  }
135 
136  BITMAP_DEF GetMenuImage() const override;
137 
138  void GetMsgPanelInfo( EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM >& aList ) override;
139 
140  wxPoint GetPosition() const override { return m_pos; }
141  void SetPosition( const wxPoint& aPosition ) override { m_pos = aPosition; }
142 
143  bool HitTest( const wxPoint& aPosition, int aAccuracy = 0 ) const override;
144  bool HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy = 0 ) const override;
145 
146  void Plot( PLOTTER* aPlotter ) override;
147 
148  EDA_ITEM* Clone() const override;
149 
150 #if defined(DEBUG)
151  void Show( int nestLevel, std::ostream& os ) const override;
152 #endif
153 };
154 
155 
156 #endif // _SCH_BITMAP_H_
SCH_ITEM & operator=(const SCH_ITEM &aItem)
Definition: sch_bitmap.cpp:60
wxString GetSelectMenuText(EDA_UNITS_T aUnits) const override
Function GetSelectMenuText returns the text to display to be used in the selection clarification cont...
Definition: sch_bitmap.h:131
void SetScale(double aScale)
Definition: bitmap_base.h:93
void Move(const wxPoint &aMoveVector) override
Function Move moves the item by aMoveVector to a new position.
Definition: sch_bitmap.h:114
double GetScale() const
Definition: bitmap_base.h:92
wxPoint m_pos
Definition: sch_bitmap.h:44
wxPoint GetPosition() const override
Function GetPosition.
Definition: sch_bitmap.h:140
void Print(wxDC *aDC, const wxPoint &aOffset) override
Function Print Print a schematic item.
Definition: sch_bitmap.cpp:115
BITMAP_DEF GetMenuImage() const override
Function GetMenuImage returns a pointer to an image to be used in menus.
Definition: sch_bitmap.cpp:190
const EDA_RECT GetBoundingBox() const override
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes.
Definition: sch_bitmap.cpp:105
void MirrorY(int aYaxis_position) override
Function MirrorY mirrors item relative to the Y axis about aYaxis_position.
Definition: sch_bitmap.cpp:136
This class handle bitmap images in KiCad.
Definition: bitmap_base.h:51
bool HitTest(const wxPoint &aPosition, int aAccuracy=0) const override
Function HitTest tests if aPosition is contained within or on the bounding box of an item.
Definition: sch_bitmap.cpp:161
void Rotate(wxPoint aPosition) override
Function Rotate rotates the item around aPosition 90 degrees in the clockwise direction.
Definition: sch_bitmap.cpp:143
wxSize GetSize() const
Definition: sch_bitmap.cpp:123
BITMAP_BASE * GetImage()
Definition: sch_bitmap.h:59
void SetImageScale(double aScale)
Definition: sch_bitmap.h:76
void SwapData(SCH_ITEM *aItem) override
Function SwapData swap the internal data structures aItem with the schematic item.
Definition: sch_bitmap.cpp:93
#define _(s)
Object to handle a bitmap image that can be inserted in a schematic.
Definition: sch_bitmap.h:42
Base plotter engine class.
Definition: plotter.h:97
void GetMsgPanelInfo(EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM > &aList) override
Function GetMsgPanelInfo populates aList of MSG_PANEL_ITEM objects with it's internal state for displ...
Definition: sch_bitmap.cpp:196
bool IsMovableFromAnchorPoint() override
Virtual function IsMovableFromAnchorPoint Return true for items which are moved with the anchor point...
Definition: sch_bitmap.h:125
void MirrorX(int aXaxis_position) override
Function MirrorX mirrors item relative to the X axis about aXaxis_position.
Definition: sch_bitmap.cpp:129
double GetImageScale() const
Definition: sch_bitmap.h:71
Class EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
EDA_ITEM * Clone() const override
Function Clone creates a duplicate of this item with linked list members set to NULL.
Definition: sch_bitmap.cpp:87
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:163
SCH_BITMAP(const wxPoint &pos=wxPoint(0, 0))
Definition: sch_bitmap.cpp:41
bool ReadImageFile(const wxString &aFullFilename)
Reads and stores an image file.
Definition: sch_bitmap.cpp:81
static bool ClassOf(const EDA_ITEM *aItem)
Definition: sch_bitmap.h:81
virtual void ViewGetLayers(int aLayers[], int &aCount) const override
Definition: sch_bitmap.cpp:205
BITMAP_BASE * m_image
Definition: sch_bitmap.h:45
wxString GetClass() const override
Function GetClass returns the class name.
Definition: sch_bitmap.h:86
Class SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container clas...
Definition: sch_item.h:114
void Plot(PLOTTER *aPlotter) override
Function Plot plots the schematic item to aPlotter.
Definition: sch_bitmap.cpp:184
void SetPosition(const wxPoint &aPosition) override
Function SetPosition set the schematic item position to aPosition.
Definition: sch_bitmap.h:141
EDA_UNITS_T
Definition: common.h:133
KICAD_T Type() const
Function Type()
Definition: base_struct.h:210