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