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 The 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, see <https://www.gnu.org/licenses/>.
20 */
21
22#pragma once
23
24#include <board_item.h>
25#include <bitmap_base.h>
26#include <reference_image.h>
27
28
33{
34public:
35 PCB_REFERENCE_IMAGE( BOARD_ITEM* aParent, const VECTOR2I& pos = VECTOR2I( 0, 0 ),
36 PCB_LAYER_ID aLayer = F_Cu );
37
38 PCB_REFERENCE_IMAGE( const PCB_REFERENCE_IMAGE& aPcbBitmap );
39
41
42 void CopyFrom( const BOARD_ITEM* aOther ) override;
43
45
51
52 static inline bool ClassOf( const EDA_ITEM* aItem )
53 {
54 return aItem && PCB_REFERENCE_IMAGE_T == aItem->Type();
55 }
56
57 wxString GetClass() const override { return wxT( "PCB_REFERENCE_IMAGE" ); }
58
59 double ViewGetLOD( int aLayer, const KIGFX::VIEW* aView ) const override;
60
61 const BOX2I GetBoundingBox() const override;
62
63 std::shared_ptr<SHAPE> GetEffectiveShape( PCB_LAYER_ID aLayer = UNDEFINED_LAYER,
65 DRC_CONSTRAINT_T aUsage = NULL_CONSTRAINT ) const override;
66
67 //void Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset ) override;
68
70 virtual std::vector<int> ViewGetLayers() const override;
71
72 void Move( const VECTOR2I& aMoveVector ) override;
73
74 void Serialize( google::protobuf::Any& aContainer ) const override;
75 bool Deserialize( const google::protobuf::Any& aContainer ) override;
76
77 void Flip( const VECTOR2I& aCentre, FLIP_DIRECTION aFlipDirection ) override;
78 void Rotate( const VECTOR2I& aCenter, const EDA_ANGLE& aAngle ) override;
79 void Mirror( const VECTOR2I& aMirrorRef, FLIP_DIRECTION aFlipDirection ) override;
80
81 wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const override
82 {
83 return wxString( _( "Reference Image" ) );
84 }
85
86 BITMAPS GetMenuImage() const override;
87
88 void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
89
93 VECTOR2I GetPosition() const override;
94
100 void SetPosition( const VECTOR2I& aPosition ) override;
101
102 bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override;
103 bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const override;
104 bool HitTest( const SHAPE_LINE_CHAIN& aPoly, bool aContained ) const override;
105
106 EDA_ITEM* Clone() const override;
107
108 double Similarity( const BOARD_ITEM& aBoardItem ) const override;
109
110 bool operator==( const PCB_REFERENCE_IMAGE& aOther ) const;
111 bool operator==( const BOARD_ITEM& aBoardItem ) const override;
112
113#if defined( DEBUG )
114 void Show( int nestLevel, std::ostream& os ) const override;
115#endif
116
117protected:
118 void swapData( BOARD_ITEM* aItem ) override;
119
120private:
122
123 // Property manager interfaces
124 int GetWidth() const;
125 void SetWidth( int aWidth );
126 int GetHeight() const;
127 void SetHeight( int aHeight );
128 int GetTransformOriginOffsetX() const;
129 void SetTransformOriginOffsetX( int aX );
130 int GetTransformOriginOffsetY() const;
131 void SetTransformOriginOffsetY( int aY );
132
133 double GetImageScale() const;
134 void SetImageScale( double aScale );
135
137};
BITMAPS
A list of all bitmap identifiers.
BOX2< VECTOR2I > BOX2I
Definition box2.h:927
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition board_item.h:84
BOARD_ITEM(BOARD_ITEM *aParent, KICAD_T idtype, PCB_LAYER_ID aLayer=F_Cu)
Definition board_item.h:86
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:98
KICAD_T Type() const
Returns the type of object.
Definition eda_item.h:110
EDA_ITEM(EDA_ITEM *parent, KICAD_T idType, bool isSCH_ITEM=false, bool isBOARD_ITEM=false)
Definition eda_item.cpp:84
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition view.h:63
Object to handle a bitmap image that can be inserted in a PCB.
void SetTransformOriginOffsetY(int aY)
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
void swapData(BOARD_ITEM *aItem) override
VECTOR2I GetPosition() const override
Get the position of the image (this is the center of the image).
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.
virtual std::vector< int > ViewGetLayers() const override
friend struct PCB_REFERENCE_IMAGE_DESC
bool HitTest(const VECTOR2I &aPosition, int aAccuracy=0) const override
Test if aPosition is inside or on the boundary of this item.
std::shared_ptr< SHAPE > GetEffectiveShape(PCB_LAYER_ID aLayer=UNDEFINED_LAYER, FLASHING aFlash=FLASHING::DEFAULT, DRC_CONSTRAINT_T aUsage=NULL_CONSTRAINT) const override
Some pad shapes can be complex (rounded/chamfered rectangle), even without considering custom shapes.
void SetTransformOriginOffsetX(int aX)
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
bool operator==(const PCB_REFERENCE_IMAGE &aOther) const
void SetImageScale(double aScale)
double ViewGetLOD(int aLayer, const KIGFX::VIEW *aView) const override
Return the level of detail (LOD) of the item.
wxString GetClass() const override
Return the class name.
void Rotate(const VECTOR2I &aCenter, const EDA_ANGLE &aAngle) override
Rotate this object.
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
void SetPosition(const VECTOR2I &aPosition) override
Set the position of the image.
void Flip(const VECTOR2I &aCentre, FLIP_DIRECTION aFlipDirection) override
Flip this object, i.e.
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
static bool ClassOf(const EDA_ITEM *aItem)
PCB_REFERENCE_IMAGE(BOARD_ITEM *aParent, const VECTOR2I &pos=VECTOR2I(0, 0), PCB_LAYER_ID aLayer=F_Cu)
REFERENCE_IMAGE & GetReferenceImage()
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.
const REFERENCE_IMAGE & GetReferenceImage() const
REFERENCE_IMAGE m_referenceImage
void Mirror(const VECTOR2I &aMirrorRef, FLIP_DIRECTION aFlipDirection) override
Mirror this object relative to a given horizontal axis the layer is not changed.
void SetHeight(int aHeight)
PCB_REFERENCE_IMAGE & operator=(const BOARD_ITEM &aItem)
void CopyFrom(const BOARD_ITEM *aOther) override
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Return a user-visible description string of this item.
A REFERENCE_IMAGE is a wrapper around a BITMAP_IMAGE that is displayed in an editor as a reference fo...
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
DRC_CONSTRAINT_T
Definition drc_rule.h:49
@ NULL_CONSTRAINT
Definition drc_rule.h:50
#define _(s)
FLASHING
Enum used during connectivity building to ensure we do not query connectivity while building the data...
Definition layer_ids.h:180
@ DEFAULT
Flashing follows connectivity.
Definition layer_ids.h:181
PCB_LAYER_ID
A quick note on layer IDs:
Definition layer_ids.h:56
@ UNDEFINED_LAYER
Definition layer_ids.h:57
@ F_Cu
Definition layer_ids.h:60
FLIP_DIRECTION
Definition mirror.h:23
@ PCB_REFERENCE_IMAGE_T
class PCB_REFERENCE_IMAGE, bitmap on a layer
Definition typeinfo.h:81
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:683