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-2021 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 ) const override;
88 
89  wxString GetSelectMenuText( EDA_UNITS aUnits ) const override;
90 
91  BITMAPS GetMenuImage() const override;
92 
93  EDA_ITEM* Clone() const override;
94 
95  virtual void SwapData( BOARD_ITEM* aImage ) override;
96 
97  void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
98 
99 #if defined(DEBUG)
100  void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
101 #endif
102 
103 private:
104  int m_shape; // bit 0 : 0 = draw +, 1 = draw X
105  int m_size;
107  wxPoint m_pos;
108 };
109 
110 
111 #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:128
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:80
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:121
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:148
wxPoint GetPosition() const override
Definition: pcb_target.h:56
bool HitTest(const wxPoint &aPosition, int aAccuracy=0) const override
Test if aPosition is contained within or on the bounding box of an item.
Definition: pcb_target.cpp:65
int GetWidth() const
Definition: pcb_target.h:65
std::shared_ptr< SHAPE > GetEffectiveShape(PCB_LAYER_ID aLayer) const override
Some pad shapes can be complex (rounded/chamfered rectangle), even without considering custom shapes.
Definition: pcb_target.cpp:115
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:134
virtual void SwapData(BOARD_ITEM *aImage) override
Swap data between aItem and aImage.
Definition: pcb_target.cpp:140
void Flip(const wxPoint &aCentre, bool aFlipLeftRight) override
Flip this object, i.e.
Definition: pcb_target.cpp:92
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
class PCB_TARGET, a target (graphic item)
Definition: typeinfo.h:104
int m_lineWidth
Definition: pcb_target.h:106
wxPoint m_pos
Definition: pcb_target.h:107
EDA_UNITS
Definition: eda_units.h:38
void Rotate(const wxPoint &aRotCentre, double aAngle) override
Rotate this object.
Definition: pcb_target.cpp:86
void Move(const wxPoint &aMoveVector) override
Move this object.
Definition: pcb_target.h:67
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:64
Handle the component boundary box.
Definition: eda_rect.h:42
int GetShape() const
Definition: pcb_target.h:59
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:100
void SetWidth(int aWidth)
Definition: pcb_target.h:64
PCB_TARGET(BOARD_ITEM *aParent)
Definition: pcb_target.cpp:39
const EDA_RECT GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: pcb_target.cpp:103
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:113