KiCad PCB EDA Suite
Loading...
Searching...
No Matches
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 <[email protected]>
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
39namespace KIGFX {
40
42{
43public:
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 std::vector<int> ViewGetLayers() const override
63 {
64 return { LAYER_GP_OVERLAY };
65 }
66
67#if defined(DEBUG)
68 void Show( int x, std::ostream& st ) const override
69 {
70 }
71#endif
72
78 wxString GetClass() const override
79 {
80 return wxT( "ORIGIN_VIEWITEM" );
81 }
82
91 inline void SetDrawAtZero( bool aDrawFlag )
92 {
93 m_drawAtZero = aDrawFlag;
94 }
95
96 void SetPosition( const VECTOR2I& aPosition ) override
97 {
98 m_position = VECTOR2D( aPosition );
99 }
100
101 VECTOR2I GetPosition() const override
102 {
103 return VECTOR2I( m_position.x, m_position.y );
104 }
105
106 inline void SetEndPosition( const VECTOR2D& aPosition )
107 {
108 m_end = aPosition;
109 }
110
111 inline const VECTOR2I GetEndPosition() const
112 {
113 return VECTOR2I( m_end.x, m_end.y );
114 }
115
116 inline void SetSize( int aSize )
117 {
118 m_size = aSize;
119 }
120
121 inline int GetSize() const
122 {
123 return m_size;
124 }
125
126 inline void SetColor( const KIGFX::COLOR4D& aColor )
127 {
128 m_color = aColor;
129 }
130
131 inline const KIGFX::COLOR4D& GetColor() const
132 {
133 return m_color;
134 }
135
136 inline void SetStyle( MARKER_STYLE aStyle )
137 {
138 m_style = aStyle;
139 }
140
141 inline MARKER_STYLE GetStyle() const
142 {
143 return m_style;
144 }
145
146protected:
149
152
155
158
161
164};
165
166} // namespace KIGFX
167
168#endif
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:89
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:104
std::vector< int > ViewGetLayers() const override
Return the all the layers within the VIEW the object is painted on.
ORIGIN_VIEWITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
COLOR4D m_color
Marker symbol.
VECTOR2D m_position
< Marker coordinates.
void SetPosition(const VECTOR2I &aPosition) override
void SetColor(const KIGFX::COLOR4D &aColor)
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.
const VECTOR2I GetEndPosition() const
VECTOR2D m_end
Marker size (in pixels).
MARKER_STYLE
< Marker symbol styles
VECTOR2I GetPosition() const override
void SetStyle(MARKER_STYLE aStyle)
void SetSize(int aSize)
MARKER_STYLE GetStyle() const
int m_size
Marker color.
void SetDrawAtZero(bool aDrawFlag)
Set the draw at zero flag.
void SetEndPosition(const VECTOR2D &aPosition)
const KIGFX::COLOR4D & GetColor() const
const BOX2I ViewBBox() const override
Return the bounding box of the item covering all its layers.
wxString GetClass() const override
Get class name.
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition: view.h:68
std::uint32_t EDA_ITEM_FLAGS
@ LAYER_GP_OVERLAY
general purpose overlay
Definition: layer_ids.h:219
The Cairo implementation of the graphics abstraction layer.
Definition: color4d.cpp:247
VECTOR2< int32_t > VECTOR2I
Definition: vector2d.h:691
VECTOR2< double > VECTOR2D
Definition: vector2d.h:690