KiCad PCB EDA Suite
pcb_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) 2022 Mike Williams
6 * Copyright (C) 2011-2022 KiCad Developers, see AUTHORS.txt for contributors.
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, you may find one here:
20 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21 * or you may search the http://www.gnu.org website for the version 2 license,
22 * or you may write to the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24 */
25
30#ifndef _PCB_BITMAP_H_
31#define _PCB_BITMAP_H_
32
33
34#include <board_item.h>
35#include <bitmap_base.h>
36
37
41class PCB_BITMAP : public BOARD_ITEM
42{
43public:
44 PCB_BITMAP( BOARD_ITEM* aParent, const VECTOR2I& pos = VECTOR2I( 0, 0 ),
45 PCB_LAYER_ID aLayer = F_Cu );
46
47 PCB_BITMAP( const PCB_BITMAP& aPcbBitmap );
48
49 ~PCB_BITMAP() { delete m_image; }
50
51 PCB_BITMAP& operator=( const BOARD_ITEM& aItem );
52
54 {
55 wxCHECK_MSG( m_image != nullptr, nullptr, "Invalid PCB_BITMAP init, m_image is NULL." );
56 return m_image;
57 }
58
65 double GetImageScale() const { return m_image->GetScale(); }
66
67 void SetImageScale( double aScale ) { m_image->SetScale( aScale ); }
68
69 static inline bool ClassOf( const EDA_ITEM* aItem )
70 {
71 return aItem && PCB_BITMAP_T == aItem->Type();
72 }
73
74 wxString GetClass() const override { return wxT( "PCB_BITMAP" ); }
75
79 const VECTOR2I GetSize() const;
80
81 double ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const override;
82
83 const BOX2I GetBoundingBox() const override;
84
85 std::shared_ptr<SHAPE> GetEffectiveShape( PCB_LAYER_ID aLayer = UNDEFINED_LAYER,
86 FLASHING aFlash = FLASHING::DEFAULT ) const override;
87
88 void SwapData( BOARD_ITEM* aItem ) override;
89
90 //void Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset ) override;
91
93 virtual void ViewGetLayers( int aLayers[], int& aCount ) const override;
94
103 bool ReadImageFile( const wxString& aFullFilename );
104
105 void Move( const VECTOR2I& aMoveVector ) override { m_pos += aMoveVector; }
106
107 void Flip( const VECTOR2I& aCentre, bool aFlipLeftRight ) override;
108 void Rotate( const VECTOR2I& aCenter, const EDA_ANGLE& aAngle ) override;
109
110 wxString GetSelectMenuText( UNITS_PROVIDER* aUnitsProvider ) const override
111 {
112 return wxString( _( "Image" ) );
113 }
114
115 BITMAPS GetMenuImage() const override;
116
117 void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
118
119 VECTOR2I GetPosition() const override { return m_pos; }
120 void SetPosition( const VECTOR2I& aPosition ) override { m_pos = aPosition; }
121
122 bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override;
123 bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const override;
124
125 EDA_ITEM* Clone() const override;
126
127#if defined( DEBUG )
128 void Show( int nestLevel, std::ostream& os ) const override;
129#endif
130
131private:
132 VECTOR2I m_pos; // XY coordinates of center of the bitmap
133 BITMAP_BASE* m_image; // the BITMAP_BASE item
134};
135
136#endif // _PCB_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
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:50
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
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition: view.h:69
Object to handle a bitmap image that can be inserted in a PCB.
Definition: pcb_bitmap.h:42
VECTOR2I GetPosition() const override
Definition: pcb_bitmap.h:119
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: pcb_bitmap.cpp:91
static bool ClassOf(const EDA_ITEM *aItem)
Definition: pcb_bitmap.h:69
std::shared_ptr< SHAPE > GetEffectiveShape(PCB_LAYER_ID aLayer=UNDEFINED_LAYER, FLASHING aFlash=FLASHING::DEFAULT) const override
Some pad shapes can be complex (rounded/chamfered rectangle), even without considering custom shapes.
Definition: pcb_bitmap.cpp:132
void SetImageScale(double aScale)
Definition: pcb_bitmap.h:67
double GetImageScale() const
Definition: pcb_bitmap.h:65
PCB_BITMAP(BOARD_ITEM *aParent, const VECTOR2I &pos=VECTOR2I(0, 0), PCB_LAYER_ID aLayer=F_Cu)
Definition: pcb_bitmap.cpp:46
void Move(const VECTOR2I &aMoveVector) override
Move this object.
Definition: pcb_bitmap.h:105
void SwapData(BOARD_ITEM *aItem) override
Swap data between aItem and aImage.
Definition: pcb_bitmap.cpp:97
virtual void ViewGetLayers(int aLayers[], int &aCount) const override
Definition: pcb_bitmap.cpp:217
void SetPosition(const VECTOR2I &aPosition) override
Definition: pcb_bitmap.h:120
wxString GetClass() const override
Return the class name.
Definition: pcb_bitmap.h:74
const VECTOR2I GetSize() const
Definition: pcb_bitmap.cpp:140
double ViewGetLOD(int aLayer, KIGFX::VIEW *aView) const override
Return the level of detail (LOD) of the item.
Definition: pcb_bitmap.cpp:109
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: pcb_bitmap.cpp:122
BITMAP_BASE * GetImage() const
Definition: pcb_bitmap.h:53
bool HitTest(const VECTOR2I &aPosition, int aAccuracy=0) const override
Test if aPosition is inside or on the boundary of this item.
Definition: pcb_bitmap.cpp:178
bool ReadImageFile(const wxString &aFullFilename)
Read and store an image file.
Definition: pcb_bitmap.cpp:85
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: pcb_bitmap.h:110
void Rotate(const VECTOR2I &aCenter, const EDA_ANGLE &aAngle) override
Rotate this object.
Definition: pcb_bitmap.cpp:160
PCB_BITMAP & operator=(const BOARD_ITEM &aItem)
Definition: pcb_bitmap.cpp:63
VECTOR2I m_pos
Definition: pcb_bitmap.h:132
BITMAP_BASE * m_image
Definition: pcb_bitmap.h:133
void Flip(const VECTOR2I &aCentre, bool aFlipLeftRight) override
Flip this object, i.e.
Definition: pcb_bitmap.cpp:146
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: pcb_bitmap.cpp:207
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
Definition: pcb_bitmap.cpp:201
#define _(s)
FLASHING
Enum used during connectivity building to ensure we do not query connectivity while building the data...
Definition: layer_ids.h:147
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:59
@ UNDEFINED_LAYER
Definition: layer_ids.h:60
@ F_Cu
Definition: layer_ids.h:64
@ PCB_BITMAP_T
class PCB_BITMAP, bitmap on a layer
Definition: typeinfo.h:89
VECTOR2< int > VECTOR2I
Definition: vector2d.h:618