KiCad PCB EDA Suite
Loading...
Searching...
No Matches
pcb_target.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) 2004 Jean-Pierre Charras, jp.charras at wanadoo.fr
5 * Copyright The 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, see <https://www.gnu.org/licenses/>.
19 */
20
21#ifndef PCB_TARGET_H
22#define PCB_TARGET_H
23
24#include <board_item.h>
25
26
27class LINE_READER;
28
29
30class PCB_TARGET : public BOARD_ITEM
31{
32public:
33 PCB_TARGET( BOARD_ITEM* aParent );
34
35 // Do not create a copy constructor. The one generated by the compiler is adequate.
36
37 PCB_TARGET( BOARD_ITEM* aParent, int aShape, PCB_LAYER_ID aLayer, const VECTOR2I& aPos,
38 int aSize, int aWidth );
39
40 // Do not create a copy constructor & operator=.
41 // The ones generated by the compiler are adequate.
42
44
45 static inline bool ClassOf( const EDA_ITEM* aItem )
46 {
47 return aItem && PCB_TARGET_T == aItem->Type();
48 }
49
50 void SetPosition( const VECTOR2I& aPos ) override { m_pos = aPos; }
51 VECTOR2I GetPosition() const override { return m_pos; }
52
53 void SetShape( int aShape ) { m_shape = aShape; }
54 int GetShape() const { return m_shape; }
55
56 void SetSize( int aSize ) { m_size = aSize; }
57 int GetSize() const { return m_size; }
58
59 void SetWidth( int aWidth ) { m_lineWidth = aWidth; }
60 int GetWidth() const { return m_lineWidth; }
61
62 void Move( const VECTOR2I& aMoveVector ) override
63 {
64 m_pos += aMoveVector;
65 }
66
67 void Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle ) override;
68
69 void Flip( const VECTOR2I& aCentre, FLIP_DIRECTION aFlipDirection ) override;
70
71 wxString GetClass() const override
72 {
73 return wxT( "PCB_TARGET" );
74 }
75
76 bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override;
77 bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const override;
78
79 // Virtual function
80 const BOX2I GetBoundingBox() const override;
81
82 std::shared_ptr<SHAPE>
83 GetEffectiveShape( PCB_LAYER_ID aLayer, FLASHING aFlash = FLASHING::DEFAULT ) const override;
84
85 wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const override;
86
87 BITMAPS GetMenuImage() const override;
88
89 EDA_ITEM* Clone() const override;
90
91 void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
92
105 void TransformShapeToPolygon( SHAPE_POLY_SET& aBuffer, PCB_LAYER_ID aLayer, int aClearance,
106 int aError, ERROR_LOC aErrorLoc,
107 bool ignoreLineWidth = false ) const override;
108
109 double Similarity( const BOARD_ITEM& aBoardItem ) const override;
110
111 bool operator==( const PCB_TARGET& aOther ) const;
112 bool operator==( const BOARD_ITEM& aBoardItem ) const override;
113
114#if defined(DEBUG)
115 void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
116#endif
117
118protected:
119 virtual void swapData( BOARD_ITEM* aImage ) override;
120
121private:
122 int m_shape; // bit 0 : 0 = draw +, 1 = draw X
126};
127
128
129#endif
ERROR_LOC
When approximating an arc or circle, should the error be placed on the outside or inside of the curve...
BITMAPS
A list of all bitmap identifiers.
BOX2< VECTOR2I > BOX2I
Definition box2.h:918
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition board_item.h:81
BOARD_ITEM(BOARD_ITEM *aParent, KICAD_T idtype, PCB_LAYER_ID aLayer=F_Cu)
Definition board_item.h:83
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:96
KICAD_T Type() const
Returns the type of object.
Definition eda_item.h:108
EDA_ITEM(EDA_ITEM *parent, KICAD_T idType, bool isSCH_ITEM=false, bool isBOARD_ITEM=false)
Definition eda_item.cpp:37
An abstract class from which implementation specific LINE_READERs may be derived to read single lines...
Definition richio.h:62
int m_lineWidth
Definition pcb_target.h:124
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Return a user-visible description string of this item.
int GetShape() const
Definition pcb_target.h:54
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
int GetWidth() const
Definition pcb_target.h:60
PCB_TARGET(BOARD_ITEM *aParent)
void SetWidth(int aWidth)
Definition pcb_target.h:59
void Rotate(const VECTOR2I &aRotCentre, const EDA_ANGLE &aAngle) override
Rotate this object.
void Flip(const VECTOR2I &aCentre, FLIP_DIRECTION aFlipDirection) override
Flip this object, i.e.
void TransformShapeToPolygon(SHAPE_POLY_SET &aBuffer, PCB_LAYER_ID aLayer, int aClearance, int aError, ERROR_LOC aErrorLoc, bool ignoreLineWidth=false) const override
Convert the shape to a closed polygon.
void SetSize(int aSize)
Definition pcb_target.h:56
bool operator==(const PCB_TARGET &aOther) const
std::shared_ptr< SHAPE > GetEffectiveShape(PCB_LAYER_ID aLayer, FLASHING aFlash=FLASHING::DEFAULT) const override
Some pad shapes can be complex (rounded/chamfered rectangle), even without considering custom shapes.
void SetShape(int aShape)
Definition pcb_target.h:53
int GetSize() const
Definition pcb_target.h:57
bool HitTest(const VECTOR2I &aPosition, int aAccuracy=0) const override
Test if aPosition is inside or on the boundary of this item.
VECTOR2I m_pos
Definition pcb_target.h:125
void SetPosition(const VECTOR2I &aPos) override
Definition pcb_target.h:50
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
void Move(const VECTOR2I &aMoveVector) override
Move this object.
Definition pcb_target.h:62
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.
static bool ClassOf(const EDA_ITEM *aItem)
Definition pcb_target.h:45
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
wxString GetClass() const override
Return the class name.
Definition pcb_target.h:71
virtual void swapData(BOARD_ITEM *aImage) override
double Similarity(const BOARD_ITEM &aBoardItem) const override
Return a measure of how likely the other object is to represent the same object.
VECTOR2I GetPosition() const override
Definition pcb_target.h:51
Represent a set of closed polygons.
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
FLIP_DIRECTION
Definition mirror.h:23
@ PCB_TARGET_T
class PCB_TARGET, a target (graphic item)
Definition typeinfo.h:100
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:683