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-2017 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_struct.h>
35 #include <class_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 
59  /*
60  * Accessors:
61  */
62  double GetPixelScaleFactor() const { return m_image->GetPixelScaleFactor(); }
63  void SetPixelScaleFactor( double aSF ) { m_image->SetPixelScaleFactor( aSF ); }
64 
66  {
67  wxCHECK_MSG( m_image != NULL, NULL, "Invalid SCH_BITMAP initialization, m_image is NULL." );
68 
69  return m_image;
70  }
71 
82  double GetScalingFactor() const
83  {
84  return m_image->GetScalingFactor();
85  }
86 
87 
88  wxString GetClass() const override
89  {
90  return wxT( "SCH_BITMAP" );
91  }
92 
93 
97  wxSize GetSize() const;
98 
99  const EDA_RECT GetBoundingBox() const override;
100 
101  void SwapData( SCH_ITEM* aItem ) override;
102 
103  void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
104  GR_DRAWMODE aDrawMode, COLOR4D aColor = COLOR4D::UNSPECIFIED ) override;
105 
113  bool ReadImageFile( const wxString& aFullFilename );
114 
115  void Move( const wxPoint& aMoveVector ) override
116  {
117  m_pos += aMoveVector;
118  }
119 
120 
121  void MirrorY( int aYaxis_position ) override;
122 
123  void MirrorX( int aXaxis_position ) override;
124 
125  void Rotate( wxPoint aPosition ) override;
126 
127  bool IsSelectStateChanged( const wxRect& aRect ) override;
128 
129  wxString GetSelectMenuText() const override { return wxString( _( "Image" ) ); }
130 
131  BITMAP_DEF GetMenuImage() const override;
132 
133  wxPoint GetPosition() const override { return m_pos; }
134 
135  void SetPosition( const wxPoint& aPosition ) override { m_pos = aPosition; }
136 
137  bool HitTest( const wxPoint& aPosition, int aAccuracy ) const override;
138 
139  bool HitTest( const EDA_RECT& aRect, bool aContained = false, int aAccuracy = 0 ) const override;
140 
141  void Plot( PLOTTER* aPlotter ) override;
142 
143  EDA_ITEM* Clone() const override;
144 
145 #if defined(DEBUG)
146  void Show( int nestLevel, std::ostream& os ) const override;
147 #endif
148 };
149 
150 
151 #endif // _SCH_BITMAP_H_
double GetPixelScaleFactor() const
SCH_ITEM & operator=(const SCH_ITEM &aItem)
Definition: sch_bitmap.cpp:59
void Draw(EDA_DRAW_PANEL *aPanel, wxDC *aDC, const wxPoint &aOffset, GR_DRAWMODE aDrawMode, COLOR4D aColor=COLOR4D::UNSPECIFIED) override
Function Draw Draw a schematic item.
Definition: sch_bitmap.cpp:114
PNG memory record (file in memory).
Definition: bitmap_types.h:38
Base schematic object class definition.
void Move(const wxPoint &aMoveVector) override
Function Move moves the item by aMoveVector to a new position.
Definition: sch_bitmap.h:115
double GetPixelScaleFactor() const
Definition: sch_bitmap.h:62
wxPoint m_pos
Definition: sch_bitmap.h:44
void SetPixelScaleFactor(double aSF)
Definition: sch_bitmap.h:63
wxPoint GetPosition() const override
Function GetPosition.
Definition: sch_bitmap.h:133
BITMAP_DEF GetMenuImage() const override
Function GetMenuImage returns a pointer to an image to be used in menus.
Definition: sch_bitmap.cpp:228
const EDA_RECT GetBoundingBox() const override
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes...
Definition: sch_bitmap.cpp:104
void MirrorY(int aYaxis_position) override
Function MirrorY mirrors item relative to the Y axis about aYaxis_position.
Definition: sch_bitmap.cpp:159
This class handle bitmap images in KiCad.
void Rotate(wxPoint aPosition) override
Function Rotate rotates the item around aPosition 90 degrees in the clockwise direction.
Definition: sch_bitmap.cpp:166
BITMAP_BASE * GetImage()
Definition: sch_bitmap.h:65
GR_DRAWMODE
Drawmode. Compositing mode plus a flag or two.
Definition: gr_basic.h:41
wxSize GetSize() const
Definition: sch_bitmap.cpp:146
void SwapData(SCH_ITEM *aItem) override
Function SwapData swap the internal data structures aItem with the schematic item.
Definition: sch_bitmap.cpp:92
Object to handle a bitmap image that can be inserted in a schematic.
Definition: sch_bitmap.h:42
double GetScalingFactor() const
Definition: sch_bitmap.h:82
void SetPixelScaleFactor(double aSF)
Base plotter engine class.
Definition: class_plotter.h:97
void MirrorX(int aXaxis_position) override
Function MirrorX mirrors item relative to the X axis about aXaxis_position.
Definition: sch_bitmap.cpp:152
wxString GetSelectMenuText() const override
Function GetSelectMenuText returns the text to display to be used in the selection clarification cont...
Definition: sch_bitmap.h:129
Class EDA_RECT handles the component boundary box.
EDA_ITEM * Clone() const override
Function Clone creates a duplicate of this item with linked list members set to NULL.
Definition: sch_bitmap.cpp:86
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:165
bool HitTest(const wxPoint &aPosition, int aAccuracy) const override
Function HitTest tests if aPosition is contained within or on the bounding box of an item...
Definition: sch_bitmap.cpp:199
double GetScalingFactor() const
Function GetScalingFactor.
SCH_BITMAP(const wxPoint &pos=wxPoint(0, 0))
Definition: sch_bitmap.cpp:40
bool ReadImageFile(const wxString &aFullFilename)
Reads and stores an image file.
Definition: sch_bitmap.cpp:80
bool IsSelectStateChanged(const wxRect &aRect) override
Function IsSelectStateChanged checks if the selection state of an item inside aRect has changed...
Definition: sch_bitmap.cpp:173
BITMAP_BASE * m_image
Definition: sch_bitmap.h:45
wxString GetClass() const override
Function GetClass returns the class name.
Definition: sch_bitmap.h:88
Class SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container clas...
void Plot(PLOTTER *aPlotter) override
Function Plot plots the schematic item to aPlotter.
Definition: sch_bitmap.cpp:222
void SetPosition(const wxPoint &aPosition) override
Function SetPosition set the schematic item position to aPosition.
Definition: sch_bitmap.h:135
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39