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
61 void SetImage( wxImage* aImage );
62
69 double GetImageScale() const
70 {
71 return m_bitmapBase->GetScale();
72 }
73
74 void SetImageScale( double aScale )
75 {
76 m_bitmapBase->SetScale( aScale );
77 }
78
79 static inline bool ClassOf( const EDA_ITEM* aItem )
80 {
81 return aItem && SCH_BITMAP_T == aItem->Type();
82 }
83
84 wxString GetClass() const override
85 {
86 return wxT( "SCH_BITMAP" );
87 }
88
92 VECTOR2I GetSize() const;
93
94 const BOX2I GetBoundingBox() const override;
95
96 void SwapData( SCH_ITEM* aItem ) override;
97
98 void Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset ) override;
99
101 virtual void ViewGetLayers( int aLayers[], int& aCount ) const override;
102
111 bool ReadImageFile( const wxString& aFullFilename );
112
113 void Move( const VECTOR2I& aMoveVector ) override
114 {
115 m_pos += aMoveVector;
116 }
117
124 bool IsMovableFromAnchorPoint() const override { return false; }
125
126 void MirrorHorizontally( int aCenter ) override;
127 void MirrorVertically( int aCenter ) override;
128 void Rotate( const VECTOR2I& aCenter ) override;
129
130 wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const override
131 {
132 return wxString( _( "Image" ) );
133 }
134
135 BITMAPS GetMenuImage() const override;
136
137 void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
138
139 VECTOR2I GetPosition() const override { return m_pos; }
140 void SetPosition( const VECTOR2I& aPosition ) override { m_pos = aPosition; }
141
142 bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override;
143 bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const override;
144
145 void Plot( PLOTTER* aPlotter, bool aBackground ) const override;
146
147 EDA_ITEM* Clone() const override;
148
149#if defined(DEBUG)
150 void Show( int nestLevel, std::ostream& os ) const override;
151#endif
152
153private:
154 VECTOR2I m_pos; // XY coordinates of center of the bitmap
155 BITMAP_BASE* m_bitmapBase; // the BITMAP_BASE item
156};
157
158
159#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:52
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:69
void Print(const RENDER_SETTINGS *aSettings, const VECTOR2I &aOffset) override
Print a schematic item.
Definition: sch_bitmap.cpp:130
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: sch_bitmap.cpp:102
VECTOR2I GetPosition() const override
Definition: sch_bitmap.h:139
static bool ClassOf(const EDA_ITEM *aItem)
Definition: sch_bitmap.h:79
void Rotate(const VECTOR2I &aCenter) override
Rotate the item around aCenter 90 degrees in the clockwise direction.
Definition: sch_bitmap.cpp:158
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider) const override
Return a user-visible description string of this item.
Definition: sch_bitmap.h:130
VECTOR2I m_pos
Definition: sch_bitmap.h:154
BITMAP_BASE * GetImage() const
Definition: sch_bitmap.h:54
virtual void ViewGetLayers(int aLayers[], int &aCount) const override
Definition: sch_bitmap.cpp:228
BITMAP_BASE * m_bitmapBase
Definition: sch_bitmap.h:155
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: sch_bitmap.cpp:120
wxString GetClass() const override
Return the class name.
Definition: sch_bitmap.h:84
void MirrorVertically(int aCenter) override
Mirror item vertically about aCenter.
Definition: sch_bitmap.cpp:144
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:216
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:124
void SetImage(wxImage *aImage)
Definition: sch_bitmap.cpp:95
VECTOR2I GetSize() const
Definition: sch_bitmap.cpp:138
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
Definition: sch_bitmap.cpp:210
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:176
void SetPosition(const VECTOR2I &aPosition) override
Definition: sch_bitmap.h:140
void Move(const VECTOR2I &aMoveVector) override
Move the item by aMoveVector to a new position.
Definition: sch_bitmap.h:113
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:108
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:199
void MirrorHorizontally(int aCenter) override
Mirror item horizontally about aCenter.
Definition: sch_bitmap.cpp:151
void SetImageScale(double aScale)
Definition: sch_bitmap.h:74
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:138
VECTOR2< int > VECTOR2I
Definition: vector2d.h:588