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
96 void Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset ) override;
97
99 virtual void ViewGetLayers( int aLayers[], int& aCount ) const override;
100
109 bool ReadImageFile( const wxString& aFullFilename );
110
119 bool ReadImageFile( wxMemoryBuffer& aBuf );
120
121 void Move( const VECTOR2I& aMoveVector ) override
122 {
123 m_pos += aMoveVector;
124 }
125
132 bool IsMovableFromAnchorPoint() const override { return false; }
133
134 void MirrorHorizontally( int aCenter ) override;
135 void MirrorVertically( int aCenter ) override;
136 void Rotate( const VECTOR2I& aCenter ) override;
137
138 wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const override
139 {
140 return wxString( _( "Image" ) );
141 }
142
143 BITMAPS GetMenuImage() const override;
144
145 void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
146
147 VECTOR2I GetPosition() const override { return m_pos; }
148 void SetPosition( const VECTOR2I& aPosition ) override { m_pos = aPosition; }
149
150 bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override;
151 bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const override;
152
153 void Plot( PLOTTER* aPlotter, bool aBackground,
154 const SCH_PLOT_SETTINGS& aPlotSettings ) const override;
155
156 EDA_ITEM* Clone() const override;
157
158 double Similarity( const SCH_ITEM& aOther ) const override;
159
160 bool operator==( const SCH_ITEM& aOther ) const override;
161
162#if defined(DEBUG)
163 void Show( int nestLevel, std::ostream& os ) const override;
164#endif
165
166private:
167 VECTOR2I m_pos; // XY coordinates of center of the bitmap
168 BITMAP_BASE* m_bitmapBase; // the BITMAP_BASE item
169};
170
171
172#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:85
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:97
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
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
double GetImageScale() const
Definition: sch_bitmap.h:67
void Print(const RENDER_SETTINGS *aSettings, const VECTOR2I &aOffset) override
Print a schematic item.
Definition: sch_bitmap.cpp:137
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:147
static bool ClassOf(const EDA_ITEM *aItem)
Definition: sch_bitmap.h:77
void Rotate(const VECTOR2I &aCenter) override
Rotate the item around aCenter 90 degrees in the clockwise direction.
Definition: sch_bitmap.cpp:165
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider) const override
Return a user-visible description string of this item.
Definition: sch_bitmap.h:138
VECTOR2I m_pos
Definition: sch_bitmap.h:167
BITMAP_BASE * GetImage() const
Definition: sch_bitmap.h:54
virtual void ViewGetLayers(int aLayers[], int &aCount) const override
Definition: sch_bitmap.cpp:236
BITMAP_BASE * m_bitmapBase
Definition: sch_bitmap.h:168
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:151
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:224
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:132
VECTOR2I GetSize() const
Definition: sch_bitmap.cpp:145
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:275
void Plot(PLOTTER *aPlotter, bool aBackground, const SCH_PLOT_SETTINGS &aPlotSettings) const override
Plot the schematic item to aPlotter.
Definition: sch_bitmap.cpp:206
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
Definition: sch_bitmap.cpp:218
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:183
void SetPosition(const VECTOR2I &aPosition) override
Definition: sch_bitmap.h:148
void Move(const VECTOR2I &aMoveVector) override
Move the item by aMoveVector to a new position.
Definition: sch_bitmap.h:121
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:158
bool operator==(const SCH_ITEM &aOther) const override
Definition: sch_bitmap.cpp:255
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:151
#define _(s)
@ SCH_BITMAP_T
Definition: typeinfo.h:148
VECTOR2< int > VECTOR2I
Definition: vector2d.h:588