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  * Copyright (C) 2020-2021 KiCad Developers, see AUTHORS.txt for contributors.
6  *
7  * @author Maciej Suminski <maciej.suminski@cern.ch>
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License
11  * as published by the Free Software Foundation; either version 2
12  * of the License, or (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, you may find one here:
21  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
22  * or you may search the http://www.gnu.org website for the version 2 license,
23  * or you may write to the Free Software Foundation, Inc.,
24  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
25  */
26 
27 #ifndef __ORIGIN_VIEWITEM_H
28 #define __ORIGIN_VIEWITEM_H
29 
30 #include <math/box2.h>
31 #include <view/view.h>
33 #include <gal/color4d.h>
34 
35 class EDA_ITEM;
36 
40 namespace KIGFX {
41 
42 class ORIGIN_VIEWITEM : public EDA_ITEM
43 {
44 public:
47  {
49  };
50 
51  ORIGIN_VIEWITEM( const COLOR4D& aColor = COLOR4D( 1.0, 1.0, 1.0, 1.0 ),
52  MARKER_STYLE aStyle = CIRCLE_X, int aSize = 16,
53  const VECTOR2D& aPosition = VECTOR2D( 0, 0 ) );
54 
55  ORIGIN_VIEWITEM( const VECTOR2D& aPosition, STATUS_FLAGS flags );
56 
57  ORIGIN_VIEWITEM* Clone() const override;
58 
59  const BOX2I ViewBBox() const override;
60 
61  void ViewDraw( int aLayer, VIEW* aView ) const override;
62 
63  void ViewGetLayers( int aLayers[], int& aCount ) const override
64  {
65  aLayers[0] = LAYER_GP_OVERLAY;
66  aCount = 1;
67  }
68 
69 #if defined(DEBUG)
70  void Show( int x, std::ostream& st ) const override
71  {
72  }
73 #endif
74 
80  wxString GetClass() const override
81  {
82  return wxT( "ORIGIN_VIEWITEM" );
83  }
84 
93  inline void SetDrawAtZero( bool aDrawFlag )
94  {
95  m_drawAtZero = aDrawFlag;
96  }
97 
98  void SetPosition( const wxPoint& aPosition ) override
99  {
100  m_position = VECTOR2D( aPosition );
101  }
102 
103  wxPoint GetPosition() const override
104  {
105  return wxPoint( m_position.x, m_position.y );
106  }
107 
108  inline void SetEndPosition( const VECTOR2D& aPosition )
109  {
110  m_end = aPosition;
111  }
112 
113  inline void SetEndPosition( const wxPoint& aPosition )
114  {
115  m_end = VECTOR2D( aPosition );
116  }
117 
118  inline const wxPoint GetEndPosition() const
119  {
120  return wxPoint( m_end.x, m_end.y );
121  }
122 
123  inline void SetSize( int aSize )
124  {
125  m_size = aSize;
126  }
127 
128  inline int GetSize() const
129  {
130  return m_size;
131  }
132 
133  inline void SetColor( const KIGFX::COLOR4D& aColor )
134  {
135  m_color = aColor;
136  }
137 
138  inline const KIGFX::COLOR4D& GetColor() const
139  {
140  return m_color;
141  }
142 
143  inline void SetStyle( MARKER_STYLE aStyle )
144  {
145  m_style = aStyle;
146  }
147 
148  inline MARKER_STYLE GetStyle() const
149  {
150  return m_style;
151  }
152 
153 protected:
156 
159 
161  int m_size;
162 
165 
168 
171 };
172 
173 } // namespace KIGFX
174 
175 #endif
void SetPosition(const wxPoint &aPosition) override
VECTOR2D m_end
Marker size (in pixels).
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))
wxPoint GetPosition() const override
COLOR4D m_color
Marker symbol.
The Cairo implementation of the graphics abstraction layer.
Definition: color4d.cpp:175
void SetEndPosition(const wxPoint &aPosition)
MARKER_STYLE GetStyle() const
void SetEndPosition(const VECTOR2D &aPosition)
VECTOR2D m_position
< Marker coordinates.
wxString GetClass() const override
Get class name.
void ViewDraw(int aLayer, VIEW *aView) const override
Draw the parts of the object belonging to layer aLayer.
MARKER_STYLE m_style
If set, the marker will be drawn even if its position is 0,0.
VECTOR2< double > VECTOR2D
Definition: vector2d.h:622
void ViewGetLayers(int aLayers[], int &aCount) const override
Return the all the layers within the VIEW the object is painted on.
void SetSize(int aSize)
void SetDrawAtZero(bool aDrawFlag)
Set the draw at zero flag.
unsigned STATUS_FLAGS
Definition: eda_item.h:145
const BOX2I ViewBBox() const override
Return the bounding box of the item covering all its layers.
const KIGFX::COLOR4D & GetColor() const
Board layer functions and definitions.
int m_size
Marker color.
void SetColor(const KIGFX::COLOR4D &aColor)
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:150
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition: view.h:67
void SetStyle(MARKER_STYLE aStyle)
MARKER_STYLE
< Marker symbol styles
ORIGIN_VIEWITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
const wxPoint GetEndPosition() const
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:98