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
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_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 VECTOR2I GetSize() const;
90
91 const BOX2I GetBoundingBox() const override;
92
93 void SwapData( SCH_ITEM* aItem ) override;
94
95 void Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& 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 VECTOR2I& 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 VECTOR2I& aCenter ) override;
126
127 wxString GetSelectMenuText( UNITS_PROVIDER* aUnitsProvider ) 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 VECTOR2I GetPosition() const override { return m_pos; }
137 void SetPosition( const VECTOR2I& aPosition ) override { m_pos = aPosition; }
138
139 bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override;
140 bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const override;
141
142 void Plot( PLOTTER* aPlotter, bool aBackground ) 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
150private:
151 VECTOR2I 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_
BITMAPS
A list of all bitmap identifiers.
Definition: bitmaps_list.h:33
This class handle bitmap images in KiCad.
Definition: bitmap_base.h:51
double GetScale() const
Definition: bitmap_base.h:78
void SetScale(double aScale)
Definition: bitmap_base.h:79
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:110
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:66
void Print(const RENDER_SETTINGS *aSettings, const VECTOR2I &aOffset) override
Print a schematic item.
Definition: sch_bitmap.cpp:117
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: sch_bitmap.cpp:89
SCH_BITMAP(const VECTOR2I &pos=VECTOR2I(0, 0))
Definition: sch_bitmap.cpp:43
VECTOR2I GetPosition() const override
Definition: sch_bitmap.h:136
static bool ClassOf(const EDA_ITEM *aItem)
Definition: sch_bitmap.h:76
void Rotate(const VECTOR2I &aCenter) override
Rotate the item around aCenter 90 degrees in the clockwise direction.
Definition: sch_bitmap.cpp:145
VECTOR2I m_pos
Definition: sch_bitmap.h:151
BITMAP_BASE * GetImage() const
Definition: sch_bitmap.h:54
virtual void ViewGetLayers(int aLayers[], int &aCount) const override
Definition: sch_bitmap.cpp:212
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: sch_bitmap.cpp:107
wxString GetClass() const override
Return the class name.
Definition: sch_bitmap.h:81
void MirrorVertically(int aCenter) override
Mirror item vertically about aCenter.
Definition: sch_bitmap.cpp:131
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:203
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
VECTOR2I GetSize() const
Definition: sch_bitmap.cpp:125
wxString GetSelectMenuText(UNITS_PROVIDER *aUnitsProvider) const override
Return the text to display to be used in the selection clarification context menu when multiple items...
Definition: sch_bitmap.h:127
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
Definition: sch_bitmap.cpp:197
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:163
BITMAP_BASE * m_image
Definition: sch_bitmap.h:152
void SetPosition(const VECTOR2I &aPosition) override
Definition: sch_bitmap.h:137
void Move(const VECTOR2I &aMoveVector) override
Move the item by aMoveVector to a new position.
Definition: sch_bitmap.h:110
SCH_BITMAP & operator=(const SCH_ITEM &aItem)
Definition: sch_bitmap.cpp:62
void SwapData(SCH_ITEM *aItem) override
Swap the internal data structures aItem with the schematic item.
Definition: sch_bitmap.cpp:95
bool ReadImageFile(const wxString &aFullFilename)
Read and store an image file.
Definition: sch_bitmap.cpp:83
void Plot(PLOTTER *aPlotter, bool aBackground) const override
Plot the schematic item to aPlotter.
Definition: sch_bitmap.cpp:186
void MirrorHorizontally(int aCenter) override
Mirror item horizontally about aCenter.
Definition: sch_bitmap.cpp:138
void SetImageScale(double aScale)
Definition: sch_bitmap.h:71
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:147
#define _(s)
@ SCH_BITMAP_T
Definition: typeinfo.h:147
VECTOR2< int > VECTOR2I
Definition: vector2d.h:618