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 
39 namespace KIGFX {
40 
42 {
43 public:
46 
47  ORIGIN_VIEWITEM( const COLOR4D& aColor = COLOR4D( 1.0, 1.0, 1.0, 1.0 ),
48  MARKER_STYLE aStyle = CIRCLE_X, int aSize = 16,
49  const VECTOR2D& aPosition = VECTOR2D( 0, 0 ) );
50 
51  ORIGIN_VIEWITEM( const VECTOR2D& aPosition, STATUS_FLAGS flags );
52 
53  ORIGIN_VIEWITEM* Clone() const override;
54 
55  const BOX2I ViewBBox() const override;
56 
57  void ViewDraw( int aLayer, VIEW* aView ) const override;
58 
59  void Draw( EDA_DRAW_PANEL* panel, wxDC* DC,
60  GR_DRAWMODE aDrawMode, const wxPoint& offset = ZeroOffset ) override
61  {
62  wxASSERT( 0 ); // ORIGIN_VIEWITEM never added to BOARD; drawn directly through ViewDraw().
63  }
64 
65  void ViewGetLayers( int aLayers[], int& aCount ) const override
66  {
67  aLayers[0] = LAYER_GP_OVERLAY;
68  aCount = 1;
69  }
70 
71 #if defined(DEBUG)
72  void Show( int x, std::ostream& st ) const override
73  {
74  }
75 #endif
76 
80  wxString GetClass() const override
81  {
82  return wxT( "ORIGIN_VIEWITEM" );
83  }
84 
91  inline void SetDrawAtZero( bool aDrawFlag )
92  {
93  m_drawAtZero = aDrawFlag;
94  }
95 
96  inline void SetPosition( const VECTOR2D& aPosition )
97  {
98  m_position = aPosition;
99  }
100 
101  inline void SetPosition( const wxPoint& aPosition ) override
102  {
103  m_position = VECTOR2D( aPosition );
104  }
105 
106  inline const wxPoint GetPosition() const override
107  {
108  return wxPoint( m_position.x, m_position.y );
109  }
110 
111  inline void SetSize( int aSize )
112  {
113  m_size = aSize;
114  }
115 
116  inline int GetSize() const
117  {
118  return m_size;
119  }
120 
121  inline void SetColor( const KIGFX::COLOR4D& aColor )
122  {
123  m_color = aColor;
124  }
125 
126  inline const KIGFX::COLOR4D& GetColor() const
127  {
128  return m_color;
129  }
130 
131  inline void SetStyle( MARKER_STYLE aStyle )
132  {
133  m_style = aStyle;
134  }
135 
136  inline MARKER_STYLE GetStyle() const
137  {
138  return m_style;
139  }
140 
141 protected:
144 
146  int m_size;
147 
150 
153 
156 };
157 
158 } // namespace KIGFX
159 
160 #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))
COLOR4D m_color
Marker color.
Class CAIRO_GAL is the cairo implementation of the graphics abstraction layer.
Definition: class_module.h:57
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.
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.
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)
GR_DRAWMODE
Drawmode. Compositing mode plus a flag or two.
Definition: gr_basic.h:37
void SetSize(int aSize)
void SetDrawAtZero(bool aDrawFlag)
Function SetDrawAtZero() Set the draw at zero flag.
unsigned STATUS_FLAGS
Definition: base_struct.h:150
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 COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39