KiCad PCB EDA Suite
origin_viewitem.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) 2013-2016 CERN
5  * @author Maciej Suminski <maciej.suminski@cern.ch>
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 __ORIGIN_VIEWITEM_H
26 #define __ORIGIN_VIEWITEM_H
27 
28 #include <math/box2.h>
29 #include <view/view.h>
30 #include <class_board_item.h>
32 #include <gal/color4d.h>
33 
34 class PCB_BASE_FRAME;
35 
41 namespace KIGFX {
42 
44 {
45 public:
48 
49  ORIGIN_VIEWITEM( const COLOR4D& aColor = COLOR4D( 1.0, 1.0, 1.0, 1.0 ),
50  MARKER_STYLE aStyle = CIRCLE_X, int aSize = 16,
51  const VECTOR2D& aPosition = VECTOR2D( 0, 0 ) );
52 
53  ORIGIN_VIEWITEM( const VECTOR2D& aPosition, STATUS_FLAGS flags );
54 
55  ORIGIN_VIEWITEM* Clone() const override;
56 
57  const BOX2I ViewBBox() const override;
58 
59  void ViewDraw( int aLayer, VIEW* aView ) const override;
60 
61  void Print( PCB_BASE_FRAME* aFrame, wxDC* DC, const wxPoint& offset = ZeroOffset ) override
62  {
63  wxASSERT( 0 ); // ORIGIN_VIEWITEM never added to BOARD
64  }
65 
66  void ViewGetLayers( int aLayers[], int& aCount ) const override
67  {
68  aLayers[0] = LAYER_GP_OVERLAY;
69  aCount = 1;
70  }
71 
72 #if defined(DEBUG)
73  void Show( int x, std::ostream& st ) const override
74  {
75  }
76 #endif
77 
81  wxString GetClass() const override
82  {
83  return wxT( "ORIGIN_VIEWITEM" );
84  }
85 
92  inline void SetDrawAtZero( bool aDrawFlag )
93  {
94  m_drawAtZero = aDrawFlag;
95  }
96 
97  inline void SetPosition( const VECTOR2D& aPosition )
98  {
99  m_position = aPosition;
100  }
101 
102  inline void SetPosition( const wxPoint& aPosition ) override
103  {
104  m_position = VECTOR2D( aPosition );
105  }
106 
107  inline const wxPoint GetPosition() const override
108  {
109  return wxPoint( m_position.x, m_position.y );
110  }
111 
112  inline void SetSize( int aSize )
113  {
114  m_size = aSize;
115  }
116 
117  inline int GetSize() const
118  {
119  return m_size;
120  }
121 
122  inline void SetColor( const KIGFX::COLOR4D& aColor )
123  {
124  m_color = aColor;
125  }
126 
127  inline const KIGFX::COLOR4D& GetColor() const
128  {
129  return m_color;
130  }
131 
132  inline void SetStyle( MARKER_STYLE aStyle )
133  {
134  m_style = aStyle;
135  }
136 
137  inline MARKER_STYLE GetStyle() const
138  {
139  return m_style;
140  }
141 
142 protected:
145 
147  int m_size;
148 
151 
154 
157 };
158 
159 } // namespace KIGFX
160 
161 #endif
void SetPosition(const wxPoint &aPosition) override
ORIGIN_VIEWITEM(const COLOR4D &aColor=COLOR4D(1.0, 1.0, 1.0, 1.0), MARKER_STYLE aStyle=CIRCLE_X, int aSize=16, const VECTOR2D &aPosition=VECTOR2D(0, 0))
void Print(PCB_BASE_FRAME *aFrame, wxDC *DC, const wxPoint &offset=ZeroOffset) override
Function Print BOARD_ITEMs have their own color information.
COLOR4D m_color
Marker color.
Class CAIRO_GAL is the cairo implementation of the graphics abstraction layer.
Definition: class_module.h:58
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class,...
MARKER_STYLE GetStyle() const
Classes BOARD_ITEM and BOARD_CONNECTED_ITEM.
VECTOR2D m_position
Marker coordinates.
static wxPoint ZeroOffset
A value of wxPoint(0,0) which can be passed to the Draw() functions.
wxString GetClass() const override
Get class name.
void ViewDraw(int aLayer, VIEW *aView) const override
Function ViewDraw() Draws the parts of the object belonging to layer aLayer.
MARKER_STYLE m_style
Marker symbol.
VECTOR2< double > VECTOR2D
Definition: vector2d.h:586
void ViewGetLayers(int aLayers[], int &aCount) const override
Function ViewGetLayers() Returns the all the layers within the VIEW the object is painted on.
void SetPosition(const VECTOR2D &aPosition)
void SetSize(int aSize)
void SetDrawAtZero(bool aDrawFlag)
Function SetDrawAtZero() Set the draw at zero flag.
unsigned STATUS_FLAGS
Definition: base_struct.h:156
const BOX2I ViewBBox() const override
Function ViewBBox() returns the bounding box of the item covering all its layers.
const wxPoint GetPosition() const override
const KIGFX::COLOR4D & GetColor() const
Board layer functions and definitions.
int m_size
Marker size (in pixels).
void SetColor(const KIGFX::COLOR4D &aColor)
bool m_drawAtZero
If set, the marker will be drawn even if its position is 0,0
Class VIEW.
Definition: view.h:61
void SetStyle(MARKER_STYLE aStyle)
MARKER_STYLE
Marker symbol styles
ORIGIN_VIEWITEM * Clone() const override
Function Clone creates a duplicate of this item with linked list members set to NULL.
class PCB_BASE_FRAME basic PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39