KiCad PCB EDA Suite
class_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, jaen-pierre.charras@gipsa-lab.inpg.com
5  * Copyright (C) 1992-2011 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 
30 #ifndef PCB_TARGET_H_
31 #define PCB_TARGET_H_
32 
33 #include <class_board_item.h>
34 
35 
36 class EDA_RECT;
37 class LINE_READER;
38 class EDA_DRAW_PANEL;
39 
40 
41 class PCB_TARGET : public BOARD_ITEM
42 {
43  int m_Shape; // bit 0 : 0 = draw +, 1 = draw X
44  int m_Size;
45  int m_Width;
47 
48 public:
49  PCB_TARGET( BOARD_ITEM* aParent );
50 
51  // Do not create a copy constructor. The one generated by the compiler is adequate.
52 
53  PCB_TARGET( BOARD_ITEM* aParent, int aShape, PCB_LAYER_ID aLayer,
54  const wxPoint& aPos, int aSize, int aWidth );
55 
56  // Do not create a copy constructor & operator=.
57  // The ones generated by the compiler are adequate.
58 
59  ~PCB_TARGET();
60 
61  static inline bool ClassOf( const EDA_ITEM* aItem )
62  {
63  return aItem && PCB_TARGET_T == aItem->Type();
64  }
65 
66  void SetPosition( const wxPoint& aPos ) override { m_Pos = aPos; }
67  const wxPoint GetPosition() const override { return m_Pos; }
68 
69  void SetShape( int aShape ) { m_Shape = aShape; }
70  int GetShape() const { return m_Shape; }
71 
72  void SetSize( int aSize ) { m_Size = aSize; }
73  int GetSize() const { return m_Size; }
74 
75  void SetWidth( int aWidth ) { m_Width = aWidth; }
76  int GetWidth() const { return m_Width; }
77 
78  void Move( const wxPoint& aMoveVector ) override
79  {
80  m_Pos += aMoveVector;
81  }
82 
83  void Rotate( const wxPoint& aRotCentre, double aAngle ) override;
84 
85  void Flip( const wxPoint& aCentre ) override;
86 
87  void Draw( EDA_DRAW_PANEL* panel, wxDC* DC,
88  GR_DRAWMODE aDrawMode, const wxPoint& offset = ZeroOffset ) override;
89 
90  bool HitTest( const wxPoint& aPosition ) const override;
91 
92  wxString GetClass() const override
93  {
94  return wxT( "PCB_TARGET" );
95  }
96 
100  bool HitTest( const EDA_RECT& aRect, bool aContained = true, int aAccuracy = 0 ) const override;
101 
102  // Virtual function
103  const EDA_RECT GetBoundingBox() const override;
104 
105  wxString GetSelectMenuText( EDA_UNITS_T aUnits ) const override;
106 
107  BITMAP_DEF GetMenuImage() const override;
108 
109  EDA_ITEM* Clone() const override;
110 
111  virtual void SwapData( BOARD_ITEM* aImage ) override;
112 
113 #if defined(DEBUG)
114  void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
115 #endif
116 };
117 
118 
119 #endif
KICAD_T Type() const
Function Type()
Definition: base_struct.h:201
Class LINE_READER is an abstract class from which implementation specific LINE_READERs may be derived...
Definition: richio.h:81
PNG memory record (file in memory).
Definition: bitmap_types.h:43
BITMAP_DEF GetMenuImage() const override
Function GetMenuImage returns a pointer to an image to be used in menus.
int GetWidth() const
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class...
void SetSize(int aSize)
Classes BOARD_ITEM and BOARD_CONNECTED_ITEM.
void Flip(const wxPoint &aCentre) override
Function Flip Flip this object, i.e.
static wxPoint ZeroOffset
A value of wxPoint(0,0) which can be passed to the Draw() functions.
PCB_LAYER_ID
A quick note on layer IDs:
int GetShape() const
static bool ClassOf(const EDA_ITEM *aItem)
EDA_ITEM * Clone() const override
Function Clone creates 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.
GR_DRAWMODE
Drawmode. Compositing mode plus a flag or two.
Definition: gr_basic.h:37
wxString GetClass() const override
Function GetClass returns the class name.
wxString GetSelectMenuText(EDA_UNITS_T aUnits) const override
Function GetSelectMenuText returns the text to display to be used in the selection clarification cont...
void SetPosition(const wxPoint &aPos) override
void SetShape(int aShape)
void Draw(EDA_DRAW_PANEL *panel, wxDC *DC, GR_DRAWMODE aDrawMode, const wxPoint &offset=ZeroOffset) override
Function Draw BOARD_ITEMs have their own color information.
class PCB_TARGET, a target (graphic item)
Definition: typeinfo.h:101
void Rotate(const wxPoint &aRotCentre, double aAngle) override
Function Rotate Rotate this object.
void Move(const wxPoint &aMoveVector) override
Function Move move this object.
Class EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:154
void SetWidth(int aWidth)
int GetSize() const
PCB_TARGET(BOARD_ITEM *aParent)
EDA_UNITS_T
Definition: common.h:159
const EDA_RECT GetBoundingBox() const override
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes...
const wxPoint GetPosition() const override
bool HitTest(const wxPoint &aPosition) const override
Function HitTest tests if aPosition is contained within or on the bounding area of an item...