KiCad PCB EDA Suite
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 
31 class EDA_RECT;
32 class LINE_READER;
33 
34 
35 class PCB_TARGET : public BOARD_ITEM
36 {
37 public:
38  PCB_TARGET( BOARD_ITEM* aParent );
39 
40  // Do not create a copy constructor. The one generated by the compiler is adequate.
41 
42  PCB_TARGET( BOARD_ITEM* aParent, int aShape, PCB_LAYER_ID aLayer,
43  const wxPoint& aPos, int aSize, int aWidth );
44 
45  // Do not create a copy constructor & operator=.
46  // The ones generated by the compiler are adequate.
47 
48  ~PCB_TARGET();
49 
50  static inline bool ClassOf( const EDA_ITEM* aItem )
51  {
52  return aItem && PCB_TARGET_T == aItem->Type();
53  }
54 
55  void SetPosition( const wxPoint& aPos ) override { m_pos = aPos; }
56  wxPoint GetPosition() const override { return m_pos; }
57 
58  void SetShape( int aShape ) { m_shape = aShape; }
59  int GetShape() const { return m_shape; }
60 
61  void SetSize( int aSize ) { m_size = aSize; }
62  int GetSize() const { return m_size; }
63 
64  void SetWidth( int aWidth ) { m_lineWidth = aWidth; }
65  int GetWidth() const { return m_lineWidth; }
66 
67  void Move( const wxPoint& aMoveVector ) override
68  {
69  m_pos += aMoveVector;
70  }
71 
72  void Rotate( const wxPoint& aRotCentre, double aAngle ) override;
73 
74  void Flip( const wxPoint& aCentre, bool aFlipLeftRight ) override;
75 
76  wxString GetClass() const override
77  {
78  return wxT( "PCB_TARGET" );
79  }
80 
81  bool HitTest( const wxPoint& aPosition, int aAccuracy = 0 ) const override;
82  bool HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy = 0 ) const override;
83 
84  // Virtual function
85  const EDA_RECT GetBoundingBox() const override;
86 
87  std::shared_ptr<SHAPE> GetEffectiveShape( PCB_LAYER_ID aLayer,
88  FLASHING aFlash = FLASHING::DEFAULT ) const override;
89 
90  wxString GetSelectMenuText( EDA_UNITS aUnits ) const override;
91 
92  BITMAPS GetMenuImage() const override;
93 
94  EDA_ITEM* Clone() const override;
95 
96  virtual void SwapData( BOARD_ITEM* aImage ) override;
97 
98  void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
99 
113  PCB_LAYER_ID aLayer, int aClearanceValue,
114  int aError, ERROR_LOC aErrorLoc,
115  bool ignoreLineWidth = false ) const override;
116 
117 #if defined(DEBUG)
118  void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
119 #endif
120 
121 private:
122  int m_shape; // bit 0 : 0 = draw +, 1 = draw X
123  int m_size;
125  wxPoint m_pos;
126 };
127 
128 
129 #endif
An abstract class from which implementation specific LINE_READERs may be derived to read single lines...
Definition: richio.h:80
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
Definition: pcb_target.cpp:129
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:49
void SetSize(int aSize)
Definition: pcb_target.h:61
wxString GetSelectMenuText(EDA_UNITS aUnits) const override
Return the text to display to be used in the selection clarification context menu when multiple items...
Definition: pcb_target.cpp:122
int GetSize() const
Definition: pcb_target.h:62
The base class for create windows for drawing purpose.
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
ERROR_LOC
When approximating an arc or circle, should the error be placed on the outside or inside of the curve...
wxPoint GetPosition() const override
Definition: pcb_target.h:56
bool HitTest(const wxPoint &aPosition, int aAccuracy=0) const override
Test if aPosition is inside or on the boundary of this item.
Definition: pcb_target.cpp:66
int GetWidth() const
Definition: pcb_target.h:65
static bool ClassOf(const EDA_ITEM *aItem)
Definition: pcb_target.h:50
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: pcb_target.cpp:135
virtual void SwapData(BOARD_ITEM *aImage) override
Swap data between aItem and aImage.
Definition: pcb_target.cpp:141
Represent a set of closed polygons.
void Flip(const wxPoint &aCentre, bool aFlipLeftRight) override
Flip this object, i.e.
Definition: pcb_target.cpp:93
wxString GetClass() const override
Return the class name.
Definition: pcb_target.h:76
void SetPosition(const wxPoint &aPos) override
Definition: pcb_target.h:55
void SetShape(int aShape)
Definition: pcb_target.h:58
FLASHING
Enum used during connectivity building to ensure we do not query connectivity while building the data...
Definition: layer_ids.h:153
class PCB_TARGET, a target (graphic item)
Definition: typeinfo.h:104
int m_lineWidth
Definition: pcb_target.h:124
wxPoint m_pos
Definition: pcb_target.h:125
EDA_UNITS
Definition: eda_units.h:38
void Rotate(const wxPoint &aRotCentre, double aAngle) override
Rotate this object.
Definition: pcb_target.cpp:87
void Move(const wxPoint &aMoveVector) override
Move this object.
Definition: pcb_target.h:67
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
BITMAPS
A list of all bitmap identifiers.
Definition: bitmaps_list.h:32
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:65
Handle the component boundary box.
Definition: eda_rect.h:42
int GetShape() const
Definition: pcb_target.h:59
void TransformShapeWithClearanceToPolygon(SHAPE_POLY_SET &aCornerBuffer, PCB_LAYER_ID aLayer, int aClearanceValue, int aError, ERROR_LOC aErrorLoc, bool ignoreLineWidth=false) const override
Convert the shape to a closed polygon.
Definition: pcb_target.cpp:163
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:99
void SetWidth(int aWidth)
Definition: pcb_target.h:64
PCB_TARGET(BOARD_ITEM *aParent)
Definition: pcb_target.cpp:40
const EDA_RECT GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: pcb_target.cpp:104
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:112