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-2020 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  int m_shape; // bit 0 : 0 = draw +, 1 = draw X
38  int m_size;
40  wxPoint m_pos;
41 
42 public:
43  PCB_TARGET( BOARD_ITEM* aParent );
44 
45  // Do not create a copy constructor. The one generated by the compiler is adequate.
46 
47  PCB_TARGET( BOARD_ITEM* aParent, int aShape, PCB_LAYER_ID aLayer,
48  const wxPoint& aPos, int aSize, int aWidth );
49 
50  // Do not create a copy constructor & operator=.
51  // The ones generated by the compiler are adequate.
52 
53  ~PCB_TARGET();
54 
55  static inline bool ClassOf( const EDA_ITEM* aItem )
56  {
57  return aItem && PCB_TARGET_T == aItem->Type();
58  }
59 
60  void SetPosition( const wxPoint& aPos ) override { m_pos = aPos; }
61  wxPoint GetPosition() const override { return m_pos; }
62 
63  void SetShape( int aShape ) { m_shape = aShape; }
64  int GetShape() const { return m_shape; }
65 
66  void SetSize( int aSize ) { m_size = aSize; }
67  int GetSize() const { return m_size; }
68 
69  void SetWidth( int aWidth ) { m_lineWidth = aWidth; }
70  int GetWidth() const { return m_lineWidth; }
71 
72  void Move( const wxPoint& aMoveVector ) override
73  {
74  m_pos += aMoveVector;
75  }
76 
77  void Rotate( const wxPoint& aRotCentre, double aAngle ) override;
78 
79  void Flip( const wxPoint& aCentre, bool aFlipLeftRight ) override;
80 
81  wxString GetClass() const override
82  {
83  return wxT( "PCB_TARGET" );
84  }
85 
86  bool HitTest( const wxPoint& aPosition, int aAccuracy = 0 ) const override;
87  bool HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy = 0 ) const override;
88 
89  // Virtual function
90  const EDA_RECT GetBoundingBox() const override;
91 
92  std::shared_ptr<SHAPE> GetEffectiveShape( PCB_LAYER_ID aLayer ) const override;
93 
94  wxString GetSelectMenuText( EDA_UNITS aUnits ) const override;
95 
96  BITMAP_DEF GetMenuImage() const override;
97 
98  EDA_ITEM* Clone() const override;
99 
100  virtual void SwapData( BOARD_ITEM* aImage ) override;
101 
102  void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
103 
104 #if defined(DEBUG)
105  void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
106 #endif
107 };
108 
109 
110 #endif
An abstract class from which implementation specific LINE_READERs may be derived to read single lines...
Definition: richio.h:80
PNG memory record (file in memory).
Definition: bitmap_def.h:29
BITMAP_DEF GetMenuImage() const override
Return a pointer to an image to be used in menus.
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:82
void SetSize(int aSize)
Definition: pcb_target.h:66
wxString GetSelectMenuText(EDA_UNITS aUnits) const override
Return the text to display to be used in the selection clarification context menu when multiple items...
int GetSize() const
Definition: pcb_target.h:67
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.
wxPoint GetPosition() const override
Definition: pcb_target.h:61
bool HitTest(const wxPoint &aPosition, int aAccuracy=0) const override
Test if aPosition is contained within or on the bounding box of an item.
int GetWidth() const
Definition: pcb_target.h:70
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.
PCB_LAYER_ID
A quick note on layer IDs:
static bool ClassOf(const EDA_ITEM *aItem)
Definition: pcb_target.h:55
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
virtual void SwapData(BOARD_ITEM *aImage) override
Swap data between aItem and aImage.
void Flip(const wxPoint &aCentre, bool aFlipLeftRight) override
Flip this object, i.e.
wxString GetClass() const override
Return the class name.
Definition: pcb_target.h:81
void SetPosition(const wxPoint &aPos) override
Definition: pcb_target.h:60
void SetShape(int aShape)
Definition: pcb_target.h:63
class PCB_TARGET, a target (graphic item)
Definition: typeinfo.h:104
int m_lineWidth
Definition: pcb_target.h:39
wxPoint m_pos
Definition: pcb_target.h:40
int m_shape
Definition: pcb_target.h:37
EDA_UNITS
Definition: eda_units.h:38
void Rotate(const wxPoint &aRotCentre, double aAngle) override
Rotate this object.
void Move(const wxPoint &aMoveVector) override
Move this object.
Definition: pcb_target.h:72
Handle the component boundary box.
Definition: eda_rect.h:42
int GetShape() const
Definition: pcb_target.h:64
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:149
int m_size
Definition: pcb_target.h:38
void SetWidth(int aWidth)
Definition: pcb_target.h:69
PCB_TARGET(BOARD_ITEM *aParent)
const EDA_RECT GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:162