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 
39 
40 class PCB_TARGET : public BOARD_ITEM
41 {
42  int m_Shape; // bit 0 : 0 = draw +, 1 = draw X
43  int m_Size;
44  int m_Width;
45  wxPoint m_Pos;
46 
47 public:
48  PCB_TARGET( BOARD_ITEM* aParent );
49 
50  // Do not create a copy constructor. The one generated by the compiler is adequate.
51 
52  PCB_TARGET( BOARD_ITEM* aParent, int aShape, PCB_LAYER_ID aLayer,
53  const wxPoint& aPos, int aSize, int aWidth );
54 
55  // Do not create a copy constructor & operator=.
56  // The ones generated by the compiler are adequate.
57 
58  ~PCB_TARGET();
59 
60  static inline bool ClassOf( const EDA_ITEM* aItem )
61  {
62  return aItem && PCB_TARGET_T == aItem->Type();
63  }
64 
65  void SetPosition( const wxPoint& aPos ) override { m_Pos = aPos; }
66  const wxPoint GetPosition() const override { return m_Pos; }
67 
68  void SetShape( int aShape ) { m_Shape = aShape; }
69  int GetShape() const { return m_Shape; }
70 
71  void SetSize( int aSize ) { m_Size = aSize; }
72  int GetSize() const { return m_Size; }
73 
74  void SetWidth( int aWidth ) { m_Width = aWidth; }
75  int GetWidth() const { return m_Width; }
76 
77  void Move( const wxPoint& aMoveVector ) override
78  {
79  m_Pos += aMoveVector;
80  }
81 
82  void Rotate( const wxPoint& aRotCentre, double aAngle ) override;
83 
84  void Flip( const wxPoint& aCentre, bool aFlipLeftRight ) override;
85 
86  void Print( PCB_BASE_FRAME* aFrame, wxDC* DC, const wxPoint& offset = ZeroOffset ) override;
87 
88  wxString GetClass() const override
89  {
90  return wxT( "PCB_TARGET" );
91  }
92 
93  bool HitTest( const wxPoint& aPosition, int aAccuracy = 0 ) const override;
94  bool HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy = 0 ) const override;
95 
96  // Virtual function
97  const EDA_RECT GetBoundingBox() const override;
98 
99  wxString GetSelectMenuText( EDA_UNITS_T aUnits ) const override;
100 
101  BITMAP_DEF GetMenuImage() const override;
102 
103  EDA_ITEM* Clone() const override;
104 
105  virtual void SwapData( BOARD_ITEM* aImage ) override;
106 
107 #if defined(DEBUG)
108  void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
109 #endif
110 };
111 
112 
113 #endif
Class LINE_READER is an abstract class from which implementation specific LINE_READERs may be derived...
Definition: richio.h:81
BITMAP_DEF GetMenuImage() const override
Function GetMenuImage returns a pointer to an image to be used in menus.
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.
int GetSize() const
static wxPoint ZeroOffset
A value of wxPoint(0,0) which can be passed to the Draw() functions.
bool HitTest(const wxPoint &aPosition, int aAccuracy=0) const override
Function HitTest tests if aPosition is contained within or on the bounding box of an item.
int GetWidth() const
PCB_LAYER_ID
A quick note on layer IDs:
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.
void Flip(const wxPoint &aCentre, bool aFlipLeftRight) override
Function Flip Flip this object, i.e.
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)
class PCB_TARGET, a target (graphic item)
Definition: typeinfo.h:99
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
int GetShape() const
void Print(PCB_BASE_FRAME *aFrame, wxDC *DC, const wxPoint &offset=ZeroOffset) override
Function Print BOARD_ITEMs have their own color information.
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:163
void SetWidth(int aWidth)
PCB_TARGET(BOARD_ITEM *aParent)
class PCB_BASE_FRAME basic PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
EDA_UNITS_T
Definition: common.h:133
const EDA_RECT GetBoundingBox() const override
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes.
const wxPoint GetPosition() const override
KICAD_T Type() const
Function Type()
Definition: base_struct.h:210