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, see <https://www.gnu.org/licenses/>.
21 */
22
23#pragma once
24
25#include <math/box2.h>
26#include <view/view.h>
27#include <layer_ids.h>
28#include <gal/color4d.h>
29#include <eda_item.h>
30
34namespace KIGFX {
35
37{
38public:
44
45 ORIGIN_VIEWITEM( const COLOR4D& aColor = COLOR4D( 1.0, 1.0, 1.0, 1.0 ),
46 MARKER_STYLE aStyle = CIRCLE_X, int aSize = 16,
47 const VECTOR2D& aPosition = VECTOR2D( 0, 0 ) );
48
49 ORIGIN_VIEWITEM( const VECTOR2D& aPosition, EDA_ITEM_FLAGS flags );
50
51 ORIGIN_VIEWITEM* Clone() const override;
52
53 const BOX2I ViewBBox() const override;
54
55 void ViewDraw( int aLayer, VIEW* aView ) const override;
56
57 std::vector<int> ViewGetLayers() const override
58 {
59 return { LAYER_GP_OVERLAY };
60 }
61
62#if defined(DEBUG)
63 void Show( int x, std::ostream& st ) const override
64 {
65 }
66#endif
67
73 wxString GetClass() const override
74 {
75 return wxT( "ORIGIN_VIEWITEM" );
76 }
77
86 inline void SetDrawAtZero( bool aDrawFlag )
87 {
88 m_drawAtZero = aDrawFlag;
89 }
90
91 void SetPosition( const VECTOR2I& aPosition ) override
92 {
93 m_position = VECTOR2D( aPosition );
94 }
95
96 VECTOR2I GetPosition() const override
97 {
98 return VECTOR2I( m_position.x, m_position.y );
99 }
100
101 inline void SetSize( int aSize )
102 {
103 m_size = aSize;
104 }
105
106 inline int GetSize() const
107 {
108 return m_size;
109 }
110
111 inline void SetColor( const KIGFX::COLOR4D& aColor )
112 {
113 m_color = aColor;
114 }
115
116 inline void SetStyle( MARKER_STYLE aStyle )
117 {
118 m_style = aStyle;
119 }
120
121protected:
123 int m_size;
127};
128
129} // namespace KIGFX
BOX2< VECTOR2I > BOX2I
Definition box2.h:918
EDA_ITEM(EDA_ITEM *parent, KICAD_T idType, bool isSCH_ITEM=false, bool isBOARD_ITEM=false)
Definition eda_item.cpp:37
A color representation with 4 components: red, green, blue, alpha.
Definition color4d.h:101
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.
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))
MARKER_STYLE
Marker symbol styles.
VECTOR2I GetPosition() const override
void SetStyle(MARKER_STYLE aStyle)
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:63
std::uint32_t EDA_ITEM_FLAGS
@ LAYER_GP_OVERLAY
General purpose overlay.
Definition layer_ids.h:275
The Cairo implementation of the graphics abstraction layer.
Definition eda_group.h:29
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:683
VECTOR2< double > VECTOR2D
Definition vector2d.h:682