KiCad PCB EDA Suite
Loading...
Searching...
No Matches
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
40class SCH_BITMAP : public SCH_ITEM
41{
42public:
43 SCH_BITMAP( const VECTOR2I& pos = VECTOR2I( 0, 0 ) );
44
45 SCH_BITMAP( const SCH_BITMAP& aSchBitmap );
46
48 {
49 delete m_bitmapBase;
50 }
51
52 SCH_BITMAP& operator=( const SCH_ITEM& aItem );
53
55 {
56 wxCHECK_MSG( m_bitmapBase != nullptr, nullptr,
57 "Invalid SCH_BITMAP init, m_bitmapBase is NULL." );
58 return m_bitmapBase;
59 }
60
67 double GetImageScale() const
68 {
69 return m_bitmapBase->GetScale();
70 }
71
72 void SetImageScale( double aScale )
73 {
74 m_bitmapBase->SetScale( aScale );
75 }
76
77 static inline bool ClassOf( const EDA_ITEM* aItem )
78 {
79 return aItem && SCH_BITMAP_T == aItem->Type();
80 }
81
82 wxString GetClass() const override
83 {
84 return wxT( "SCH_BITMAP" );
85 }
86
90 VECTOR2I GetSize() const;
91
92 const BOX2I GetBoundingBox() const override;
93
94 void SwapData( SCH_ITEM* aItem ) override;
95
97 virtual void ViewGetLayers( int aLayers[], int& aCount ) const override;
98
107 bool ReadImageFile( const wxString& aFullFilename );
108
117 bool ReadImageFile( wxMemoryBuffer& aBuf );
118
119 void Move( const VECTOR2I& aMoveVector ) override
120 {
121 m_pos += aMoveVector;
122 }
123
130 bool IsMovableFromAnchorPoint() const override { return false; }
131
132 void MirrorHorizontally( int aCenter ) override;
133 void MirrorVertically( int aCenter ) override;
134 void Rotate( const VECTOR2I& aCenter, bool aRotateCCW ) override;
135
136 wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const override
137 {
138 return wxString( _( "Image" ) );
139 }
140
141 BITMAPS GetMenuImage() const override;
142
143 void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
144
145 VECTOR2I GetPosition() const override { return m_pos; }
146 void SetPosition( const VECTOR2I& aPosition ) override { m_pos = aPosition; }
147
148 bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override;
149 bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const override;
150
151 void Print( const SCH_RENDER_SETTINGS* aSettings, int aUnit, int aBodyStyle,
152 const VECTOR2I& aOffset, bool aForceNoFill, bool aDimmed ) override;
153
154 void Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS& aPlotOpts,
155 int aUnit, int aBodyStyle, const VECTOR2I& aOffset, bool aDimmed ) override;
156
157 EDA_ITEM* Clone() const override;
158
159 double Similarity( const SCH_ITEM& aOther ) const override;
160
161 bool operator==( const SCH_ITEM& aOther ) const override;
162
163#if defined(DEBUG)
164 void Show( int nestLevel, std::ostream& os ) const override;
165#endif
166
167private:
168 VECTOR2I m_pos; // XY coordinates of center of the bitmap
169 BITMAP_BASE* m_bitmapBase; // the BITMAP_BASE item
170};
171
172
173#endif // _SCH_BITMAP_H_
BITMAPS
A list of all bitmap identifiers.
Definition: bitmaps_list.h:33
This class handle bitmap images in KiCad.
Definition: bitmap_base.h:48
double GetScale() const
Definition: bitmap_base.h:72
void SetScale(double aScale)
Definition: bitmap_base.h:73
The base class for create windows for drawing purpose.
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:88
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:100
Base plotter engine class.
Definition: plotter.h:104
Object to handle a bitmap image that can be inserted in a schematic.
Definition: sch_bitmap.h:41
void Rotate(const VECTOR2I &aCenter, bool aRotateCCW) override
Rotate the item around aCenter 90 degrees in the clockwise direction.
Definition: sch_bitmap.cpp:166
double GetImageScale() const
Definition: sch_bitmap.h:67
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: sch_bitmap.cpp:108
VECTOR2I GetPosition() const override
Definition: sch_bitmap.h:145
static bool ClassOf(const EDA_ITEM *aItem)
Definition: sch_bitmap.h:77
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider) const override
Return a user-visible description string of this item.
Definition: sch_bitmap.h:136
void Plot(PLOTTER *aPlotter, bool aBackground, const SCH_PLOT_OPTS &aPlotOpts, int aUnit, int aBodyStyle, const VECTOR2I &aOffset, bool aDimmed) override
Plot the item to aPlotter.
Definition: sch_bitmap.cpp:207
VECTOR2I m_pos
Definition: sch_bitmap.h:168
BITMAP_BASE * GetImage() const
Definition: sch_bitmap.h:54
virtual void ViewGetLayers(int aLayers[], int &aCount) const override
Definition: sch_bitmap.cpp:237
BITMAP_BASE * m_bitmapBase
Definition: sch_bitmap.h:169
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: sch_bitmap.cpp:128
wxString GetClass() const override
Return the class name.
Definition: sch_bitmap.h:82
void MirrorVertically(int aCenter) override
Mirror item vertically about aCenter.
Definition: sch_bitmap.cpp:152
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:225
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:130
VECTOR2I GetSize() const
Definition: sch_bitmap.cpp:146
double Similarity(const SCH_ITEM &aOther) const override
Return a measure of how likely the other object is to represent the same object.
Definition: sch_bitmap.cpp:276
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
Definition: sch_bitmap.cpp:219
bool HitTest(const VECTOR2I &aPosition, int aAccuracy=0) const override
Test if aPosition is inside or on the boundary of this item.
Definition: sch_bitmap.cpp:184
void SetPosition(const VECTOR2I &aPosition) override
Definition: sch_bitmap.h:146
void Move(const VECTOR2I &aMoveVector) override
Move the item by aMoveVector to a new position.
Definition: sch_bitmap.h:119
SCH_BITMAP & operator=(const SCH_ITEM &aItem)
Definition: sch_bitmap.cpp:63
void SwapData(SCH_ITEM *aItem) override
Swap the internal data structures aItem with the schematic item.
Definition: sch_bitmap.cpp:114
bool ReadImageFile(const wxString &aFullFilename)
Read and store an image file.
Definition: sch_bitmap.cpp:84
void MirrorHorizontally(int aCenter) override
Mirror item horizontally about aCenter.
Definition: sch_bitmap.cpp:159
bool operator==(const SCH_ITEM &aOther) const override
Definition: sch_bitmap.cpp:256
void Print(const SCH_RENDER_SETTINGS *aSettings, int aUnit, int aBodyStyle, const VECTOR2I &aOffset, bool aForceNoFill, bool aDimmed) override
Print an item.
Definition: sch_bitmap.cpp:137
void SetImageScale(double aScale)
Definition: sch_bitmap.h:72
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:174
#define _(s)
@ SCH_BITMAP_T
Definition: typeinfo.h:164
VECTOR2< int > VECTOR2I
Definition: vector2d.h:588