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 The 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#pragma once
28
29#include <math/box2.h>
30#include <view/view.h>
31#include <layer_ids.h>
32#include <gal/color4d.h>
33#include <eda_item.h>
34
38namespace KIGFX {
39
41{
42public:
45 {
47 };
48
49 ORIGIN_VIEWITEM( const COLOR4D& aColor = COLOR4D( 1.0, 1.0, 1.0, 1.0 ),
50 MARKER_STYLE aStyle = CIRCLE_X, int aSize = 16,
51 const VECTOR2D& aPosition = VECTOR2D( 0, 0 ) );
52
53 ORIGIN_VIEWITEM( const VECTOR2D& aPosition, EDA_ITEM_FLAGS flags );
54
55 ORIGIN_VIEWITEM* Clone() const override;
56
57 const BOX2I ViewBBox() const override;
58
59 void ViewDraw( int aLayer, VIEW* aView ) const override;
60
61 std::vector<int> ViewGetLayers() const override
62 {
63 return { LAYER_GP_OVERLAY };
64 }
65
66#if defined(DEBUG)
67 void Show( int x, std::ostream& st ) const override
68 {
69 }
70#endif
71
77 wxString GetClass() const override
78 {
79 return wxT( "ORIGIN_VIEWITEM" );
80 }
81
90 inline void SetDrawAtZero( bool aDrawFlag )
91 {
92 m_drawAtZero = aDrawFlag;
93 }
94
95 void SetPosition( const VECTOR2I& aPosition ) override
96 {
97 m_position = VECTOR2D( aPosition );
98 }
99
100 VECTOR2I GetPosition() const override
101 {
102 return VECTOR2I( m_position.x, m_position.y );
103 }
104
105 inline void SetSize( int aSize )
106 {
107 m_size = aSize;
108 }
109
110 inline int GetSize() const
111 {
112 return m_size;
113 }
114
115 inline void SetColor( const KIGFX::COLOR4D& aColor )
116 {
117 m_color = aColor;
118 }
119
120 inline void SetStyle( MARKER_STYLE aStyle )
121 {
122 m_style = aStyle;
123 }
124
125protected:
127 int m_size;
131};
132
133} // namespace KIGFX
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:98
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
(in pixels)
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
Marker symbol styles.
VECTOR2I GetPosition() const override
void SetStyle(MARKER_STYLE aStyle)
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.
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:66
std::uint32_t EDA_ITEM_FLAGS
@ LAYER_GP_OVERLAY
General purpose overlay.
Definition: layer_ids.h:278
The Cairo implementation of the graphics abstraction layer.
Definition: eda_group.h:33
VECTOR2< int32_t > VECTOR2I
Definition: vector2d.h:695
VECTOR2< double > VECTOR2D
Definition: vector2d.h:694