1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
|
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2013-2016 CERN
* @author Maciej Suminski <maciej.suminski@cern.ch>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef __ORIGIN_VIEWITEM_H
#define __ORIGIN_VIEWITEM_H
#include <math/box2.h>
#include <view/view.h>
#include <class_board_item.h>
#include <layers_id_colors_and_visibility.h>
#include <gal/color4d.h>
/**
* Class ORIGIN_VIEWITEM
*
* View item to draw an origin marker.
*/
namespace KIGFX {
class ORIGIN_VIEWITEM : public EDA_ITEM
{
public:
///> Marker symbol styles
enum MARKER_STYLE { NONE, CROSS, X, DOT, CIRCLE_CROSS, CIRCLE_X, CIRCLE_DOT };
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 ) );
const BOX2I ViewBBox() const;
void ViewDraw( int aLayer, KIGFX::GAL* aGal ) const;
void ViewGetLayers( int aLayers[], int& aCount ) const
{
aLayers[0] = ITEM_GAL_LAYER( GP_OVERLAY );
aCount = 1;
}
#if defined(DEBUG)
void Show( int x, std::ostream& st ) const
{
}
#endif
/** Get class name
* @return string "ORIGIN_VIEWITEM"
*/
wxString GetClass() const
{
return wxT( "ORIGIN_VIEWITEM" );
}
/**
* Function SetDrawAtZero()
* Set the draw at zero flag. When set the marker will be drawn when it's position is 0,0.
* Otherwise it will not be drawn when its position is 0,0
* @param aDrawFlag The value to set the draw at zero flag
*/
inline void SetDrawAtZero( bool aDrawFlag )
{
m_drawAtZero = aDrawFlag;
}
inline void SetPosition( const VECTOR2D& aPosition )
{
m_position = aPosition;
ViewUpdate();
}
inline const VECTOR2D& GetPosition() const
{
return m_position;
}
inline void SetSize( int aSize )
{
m_size = aSize;
}
inline int GetSize() const
{
return m_size;
}
inline void SetColor( const KIGFX::COLOR4D& aColor )
{
m_color = aColor;
}
inline const KIGFX::COLOR4D& GetColor() const
{
return m_color;
}
inline void SetStyle( MARKER_STYLE aStyle )
{
m_style = aStyle;
}
inline MARKER_STYLE GetStyle() const
{
return m_style;
}
protected:
///> Marker coordinates.
VECTOR2D m_position;
///> Marker size (in pixels).
int m_size;
///> Marker color.
COLOR4D m_color;
///> Marker symbol.
MARKER_STYLE m_style;
///> If set, the marker will be drawn even if its position is 0,0
bool m_drawAtZero;
};
} // namespace KIGFX
#endif
|