KiCad PCB EDA Suite
Loading...
Searching...
No Matches
pcb_reference_image.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-2023 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
26#ifndef PCB_REFERENCE_IMAGE_H
27#define PCB_REFERENCE_IMAGE_H
28
29
30#include <board_item.h>
31#include <bitmap_base.h>
32
33
38{
39public:
40 PCB_REFERENCE_IMAGE( BOARD_ITEM* aParent, const VECTOR2I& pos = VECTOR2I( 0, 0 ),
41 PCB_LAYER_ID aLayer = F_Cu );
42
43 PCB_REFERENCE_IMAGE( const PCB_REFERENCE_IMAGE& aPcbBitmap );
44
46
48
49 const BITMAP_BASE* GetImage() const
50 {
51 wxCHECK_MSG( m_bitmapBase != nullptr, nullptr,
52 wxS( "Invalid PCB_REFERENCE_IMAGE init, m_bitmapBase is NULL." ) );
53 return m_bitmapBase;
54 }
55
60 {
61 return m_bitmapBase;
62 }
63
70 double GetImageScale() const { return m_bitmapBase->GetScale(); }
71
72 void SetImageScale( double aScale ) { m_bitmapBase->SetScale( aScale ); }
73
74 static inline bool ClassOf( const EDA_ITEM* aItem )
75 {
76 return aItem && PCB_REFERENCE_IMAGE_T == aItem->Type();
77 }
78
79 wxString GetClass() const override { return wxT( "PCB_REFERENCE_IMAGE" ); }
80
84 const VECTOR2I GetSize() const;
85
86 double ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const override;
87
88 const BOX2I GetBoundingBox() const override;
89
90 std::shared_ptr<SHAPE> GetEffectiveShape( PCB_LAYER_ID aLayer = UNDEFINED_LAYER,
91 FLASHING aFlash = FLASHING::DEFAULT ) const override;
92
93 //void Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset ) override;
94
96 virtual void ViewGetLayers( int aLayers[], int& aCount ) const override;
97
106 bool ReadImageFile( const wxString& aFullFilename );
107
116 bool ReadImageFile( wxMemoryBuffer& aBuf );
117
118 void Move( const VECTOR2I& aMoveVector ) override { m_pos += aMoveVector; }
119
120 void Flip( const VECTOR2I& aCentre, bool aFlipLeftRight ) override;
121 void Rotate( const VECTOR2I& aCenter, const EDA_ANGLE& aAngle ) override;
122
123 wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const override
124 {
125 return wxString( _( "Reference Image" ) );
126 }
127
128 BITMAPS GetMenuImage() const override;
129
130 void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
131
132 VECTOR2I GetPosition() const override { return m_pos; }
133 void SetPosition( const VECTOR2I& aPosition ) override { m_pos = aPosition; }
134
135 bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override;
136 bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const override;
137
138 EDA_ITEM* Clone() const override;
139
140 double Similarity( const BOARD_ITEM& aBoardItem ) const override;
141
142 bool operator==( const BOARD_ITEM& aBoardItem ) const override;
143
144#if defined( DEBUG )
145 void Show( int nestLevel, std::ostream& os ) const override;
146#endif
147
148protected:
149 void swapData( BOARD_ITEM* aItem ) override;
150
151private:
152 VECTOR2I m_pos; // XY coordinates of center of the bitmap
153 BITMAP_BASE* m_bitmapBase; // the BITMAP_BASE item
154};
155
156#endif // PCB_REFERENCE_IMAGE_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
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:77
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
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition: view.h:68
Object to handle a bitmap image that can be inserted in a PCB.
void swapData(BOARD_ITEM *aItem) override
VECTOR2I GetPosition() const override
double Similarity(const BOARD_ITEM &aBoardItem) const override
Return a measure of how likely the other object is to represent the same object.
void Move(const VECTOR2I &aMoveVector) override
Move this object.
double GetImageScale() const
bool HitTest(const VECTOR2I &aPosition, int aAccuracy=0) const override
Test if aPosition is inside or on the boundary of this item.
bool ReadImageFile(const wxString &aFullFilename)
Read and store an image file.
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
const BITMAP_BASE * GetImage() const
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
void SetImageScale(double aScale)
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider) const override
Return a user-visible description string of this item.
void Flip(const VECTOR2I &aCentre, bool aFlipLeftRight) override
Flip this object, i.e.
wxString GetClass() const override
Return the class name.
void Rotate(const VECTOR2I &aCenter, const EDA_ANGLE &aAngle) override
Rotate this object.
bool operator==(const BOARD_ITEM &aBoardItem) const override
BITMAP_BASE * MutableImage() const
Only use this if you really need to modify the underlying image.
void SetPosition(const VECTOR2I &aPosition) override
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
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.
const VECTOR2I GetSize() const
static bool ClassOf(const EDA_ITEM *aItem)
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.
virtual void ViewGetLayers(int aLayers[], int &aCount) const override
double ViewGetLOD(int aLayer, KIGFX::VIEW *aView) const override
Return the level of detail (LOD) of the item.
PCB_REFERENCE_IMAGE & operator=(const BOARD_ITEM &aItem)
#define _(s)
FLASHING
Enum used during connectivity building to ensure we do not query connectivity while building the data...
Definition: layer_ids.h:149
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:60
@ UNDEFINED_LAYER
Definition: layer_ids.h:61
@ F_Cu
Definition: layer_ids.h:64
@ PCB_REFERENCE_IMAGE_T
class PCB_REFERENCE_IMAGE, bitmap on a layer
Definition: typeinfo.h:89
VECTOR2< int > VECTOR2I
Definition: vector2d.h:588