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 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 VECTOR2I& aPosition ) override
98 {
99 m_position = VECTOR2D( aPosition );
100 }
101
102 VECTOR2I GetPosition() const override
103 {
104 return VECTOR2I( m_position.x, m_position.y );
105 }
106
107 inline void SetEndPosition( const VECTOR2D& aPosition )
108 {
109 m_end = aPosition;
110 }
111
112 inline const VECTOR2I GetEndPosition() const
113 {
114 return VECTOR2I( m_end.x, m_end.y );
115 }
116
117 inline void SetSize( int aSize )
118 {
119 m_size = aSize;
120 }
121
122 inline int GetSize() const
123 {
124 return m_size;
125 }
126
127 inline void SetColor( const KIGFX::COLOR4D& aColor )
128 {
129 m_color = aColor;
130 }
131
132 inline const KIGFX::COLOR4D& GetColor() const
133 {
134 return m_color;
135 }
136
137 inline void SetStyle( MARKER_STYLE aStyle )
138 {
139 m_style = aStyle;
140 }
141
142 inline MARKER_STYLE GetStyle() const
143 {
144 return m_style;
145 }
146
147protected:
150
153
156
159
162
165};
166
167} // namespace KIGFX
168
169#endif
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:88
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:104
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 ViewGetLayers(int aLayers[], int &aCount) const override
Return the all the layers within the VIEW the object is painted on.
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:222
The Cairo implementation of the graphics abstraction layer.
Definition: color4d.cpp:247
VECTOR2< double > VECTOR2D
Definition: vector2d.h:587
VECTOR2< int > VECTOR2I
Definition: vector2d.h:588