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>
32 #include <layer_ids.h>
33 #include <gal/color4d.h>
34 #include <eda_item.h>
35 
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, EDA_ITEM_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 
79  wxString GetClass() const override
80  {
81  return wxT( "ORIGIN_VIEWITEM" );
82  }
83 
92  inline void SetDrawAtZero( bool aDrawFlag )
93  {
94  m_drawAtZero = aDrawFlag;
95  }
96 
97  void SetPosition( const wxPoint& aPosition ) override
98  {
99  m_position = VECTOR2D( aPosition );
100  }
101 
102  wxPoint GetPosition() const override
103  {
104  return wxPoint( m_position.x, m_position.y );
105  }
106 
107  inline void SetEndPosition( const VECTOR2D& aPosition )
108  {
109  m_end = aPosition;
110  }
111 
112  inline void SetEndPosition( const wxPoint& aPosition )
113  {
114  m_end = VECTOR2D( aPosition );
115  }
116 
117  inline const wxPoint GetEndPosition() const
118  {
119  return wxPoint( m_end.x, m_end.y );
120  }
121 
122  inline void SetSize( int aSize )
123  {
124  m_size = aSize;
125  }
126 
127  inline int GetSize() const
128  {
129  return m_size;
130  }
131 
132  inline void SetColor( const KIGFX::COLOR4D& aColor )
133  {
134  m_color = aColor;
135  }
136 
137  inline const KIGFX::COLOR4D& GetColor() const
138  {
139  return m_color;
140  }
141 
142  inline void SetStyle( MARKER_STYLE aStyle )
143  {
144  m_style = aStyle;
145  }
146 
147  inline MARKER_STYLE GetStyle() const
148  {
149  return m_style;
150  }
151 
152 protected:
155 
158 
160  int m_size;
161 
164 
167 
170 };
171 
172 } // namespace KIGFX
173 
174 #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:236
void SetEndPosition(const wxPoint &aPosition)
MARKER_STYLE GetStyle() const
std::uint32_t EDA_ITEM_FLAGS
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.
const BOX2I ViewBBox() const override
Return the bounding box of the item covering all its layers.
const KIGFX::COLOR4D & GetColor() const
int m_size
Marker color.
general purpose overlay
Definition: layer_ids.h:213
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:100
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition: view.h:68
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:103