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 (C) 1992-2022 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
25#ifndef PCB_TARGET_H
26#define PCB_TARGET_H
27
28#include <board_item.h>
29
30
31class LINE_READER;
32
33
34class PCB_TARGET : public BOARD_ITEM
35{
36public:
37 PCB_TARGET( BOARD_ITEM* aParent );
38
39 // Do not create a copy constructor. The one generated by the compiler is adequate.
40
41 PCB_TARGET( BOARD_ITEM* aParent, int aShape, PCB_LAYER_ID aLayer, const VECTOR2I& aPos,
42 int aSize, int aWidth );
43
44 // Do not create a copy constructor & operator=.
45 // The ones generated by the compiler are adequate.
46
48
49 static inline bool ClassOf( const EDA_ITEM* aItem )
50 {
51 return aItem && PCB_TARGET_T == aItem->Type();
52 }
53
54 void SetPosition( const VECTOR2I& aPos ) override { m_pos = aPos; }
55 VECTOR2I GetPosition() const override { return m_pos; }
56
57 void SetShape( int aShape ) { m_shape = aShape; }
58 int GetShape() const { return m_shape; }
59
60 void SetSize( int aSize ) { m_size = aSize; }
61 int GetSize() const { return m_size; }
62
63 void SetWidth( int aWidth ) { m_lineWidth = aWidth; }
64 int GetWidth() const { return m_lineWidth; }
65
66 void Move( const VECTOR2I& aMoveVector ) override
67 {
68 m_pos += aMoveVector;
69 }
70
71 void Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle ) override;
72
73 void Flip( const VECTOR2I& aCentre, bool aFlipLeftRight ) override;
74
75 wxString GetClass() const override
76 {
77 return wxT( "PCB_TARGET" );
78 }
79
80 bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override;
81 bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const override;
82
83 // Virtual function
84 const BOX2I GetBoundingBox() const override;
85
86 std::shared_ptr<SHAPE>
87 GetEffectiveShape( PCB_LAYER_ID aLayer, FLASHING aFlash = FLASHING::DEFAULT ) const override;
88
89 wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const override;
90
91 BITMAPS GetMenuImage() const override;
92
93 EDA_ITEM* Clone() const override;
94
95 void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
96
109 void TransformShapeToPolygon( SHAPE_POLY_SET& aBuffer, PCB_LAYER_ID aLayer, int aClearance,
110 int aError, ERROR_LOC aErrorLoc,
111 bool ignoreLineWidth = false ) const override;
112
113 double Similarity( const BOARD_ITEM& aBoardItem ) const override;
114
115 bool operator==( const BOARD_ITEM& aBoardItem ) const override;
116
117#if defined(DEBUG)
118 void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
119#endif
120
121protected:
122 virtual void swapData( BOARD_ITEM* aImage ) override;
123
124private:
125 int m_shape; // bit 0 : 0 = draw +, 1 = draw X
129};
130
131
132#endif
BITMAPS
A list of all bitmap identifiers.
Definition: bitmaps_list.h:33
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
An abstract class from which implementation specific LINE_READERs may be derived to read single lines...
Definition: richio.h:93
int m_lineWidth
Definition: pcb_target.h:127
int GetShape() const
Definition: pcb_target.h:58
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: pcb_target.cpp:135
int GetWidth() const
Definition: pcb_target.h:64
void SetWidth(int aWidth)
Definition: pcb_target.h:63
void Rotate(const VECTOR2I &aRotCentre, const EDA_ANGLE &aAngle) override
Rotate this object.
Definition: pcb_target.cpp:87
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.
Definition: pcb_target.cpp:161
bool operator==(const BOARD_ITEM &aBoardItem) const override
Definition: pcb_target.cpp:192
void SetSize(int aSize)
Definition: pcb_target.h:60
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider) const override
Return a user-visible description string of this item.
Definition: pcb_target.cpp:122
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.
Definition: pcb_target.cpp:116
void Flip(const VECTOR2I &aCentre, bool aFlipLeftRight) override
Flip this object, i.e.
Definition: pcb_target.cpp:93
void SetShape(int aShape)
Definition: pcb_target.h:57
int GetSize() const
Definition: pcb_target.h:61
bool HitTest(const VECTOR2I &aPosition, int aAccuracy=0) const override
Test if aPosition is inside or on the boundary of this item.
Definition: pcb_target.cpp:66
VECTOR2I m_pos
Definition: pcb_target.h:128
void SetPosition(const VECTOR2I &aPos) override
Definition: pcb_target.h:54
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
Definition: pcb_target.cpp:129
void Move(const VECTOR2I &aMoveVector) override
Move this object.
Definition: pcb_target.h:66
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_target.cpp:149
static bool ClassOf(const EDA_ITEM *aItem)
Definition: pcb_target.h:49
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: pcb_target.cpp:104
wxString GetClass() const override
Return the class name.
Definition: pcb_target.h:75
virtual void swapData(BOARD_ITEM *aImage) override
Definition: pcb_target.cpp:141
double Similarity(const BOARD_ITEM &aBoardItem) const override
Return a measure of how likely the other object is to represent the same object.
Definition: pcb_target.cpp:204
VECTOR2I GetPosition() const override
Definition: pcb_target.h:55
Represent a set of closed polygons.
ERROR_LOC
When approximating an arc or circle, should the error be placed on the outside or inside of the curve...
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
@ PCB_TARGET_T
class PCB_TARGET, a target (graphic item)
Definition: typeinfo.h:106