KiCad PCB EDA Suite
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 KiCad Developers, see AUTHORS.txt for contributors.
6  * @author Maciej Suminski <maciej.suminski@cern.ch>
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, you may find one here:
20  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21  * or you may search the http://www.gnu.org website for the version 2 license,
22  * or you may write to the Free Software Foundation, Inc.,
23  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24  */
25 
26 #ifndef __ORIGIN_VIEWITEM_H
27 #define __ORIGIN_VIEWITEM_H
28 
29 #include <math/box2.h>
30 #include <view/view.h>
31 #include <class_board_item.h>
33 #include <gal/color4d.h>
34 
35 class PCB_BASE_FRAME;
36 
42 namespace KIGFX {
43 
45 {
46 public:
49  {
51  };
52 
53  ORIGIN_VIEWITEM( const COLOR4D& aColor = COLOR4D( 1.0, 1.0, 1.0, 1.0 ),
54  MARKER_STYLE aStyle = CIRCLE_X, int aSize = 16,
55  const VECTOR2D& aPosition = VECTOR2D( 0, 0 ) );
56 
57  ORIGIN_VIEWITEM( const VECTOR2D& aPosition, STATUS_FLAGS flags );
58 
59  ORIGIN_VIEWITEM* Clone() const override;
60 
61  const BOX2I ViewBBox() const override;
62 
63  void ViewDraw( int aLayer, VIEW* aView ) const override;
64 
65  void ViewGetLayers( int aLayers[], int& aCount ) const override
66  {
67  aLayers[0] = LAYER_GP_OVERLAY;
68  aCount = 1;
69  }
70 
71 #if defined(DEBUG)
72  void Show( int x, std::ostream& st ) const override
73  {
74  }
75 #endif
76 
80  wxString GetClass() const override
81  {
82  return wxT( "ORIGIN_VIEWITEM" );
83  }
84 
91  inline void SetDrawAtZero( bool aDrawFlag )
92  {
93  m_drawAtZero = aDrawFlag;
94  }
95 
96  inline void SetPosition( const VECTOR2D& aPosition )
97  {
98  m_position = aPosition;
99  }
100 
101  inline void SetPosition( const wxPoint& aPosition ) override
102  {
103  m_position = VECTOR2D( aPosition );
104  }
105 
106  inline const wxPoint GetPosition() const override
107  {
108  return wxPoint( m_position.x, m_position.y );
109  }
110 
111  inline void SetEndPosition( const VECTOR2D& aPosition )
112  {
113  m_end = aPosition;
114  }
115 
116  inline void SetEndPosition( const wxPoint& aPosition )
117  {
118  m_end = VECTOR2D( aPosition );
119  }
120 
121  inline const wxPoint GetEndPosition() const
122  {
123  return wxPoint( m_end.x, m_end.y );
124  }
125 
126  inline void SetSize( int aSize )
127  {
128  m_size = aSize;
129  }
130 
131  inline int GetSize() const
132  {
133  return m_size;
134  }
135 
136  inline void SetColor( const KIGFX::COLOR4D& aColor )
137  {
138  m_color = aColor;
139  }
140 
141  inline const KIGFX::COLOR4D& GetColor() const
142  {
143  return m_color;
144  }
145 
146  inline void SetStyle( MARKER_STYLE aStyle )
147  {
148  m_style = aStyle;
149  }
150 
151  inline MARKER_STYLE GetStyle() const
152  {
153  return m_style;
154  }
155 
156 protected:
159 
162 
164  int m_size;
165 
168 
171 
174 };
175 
176 } // namespace KIGFX
177 
178 #endif
void SetPosition(const wxPoint &aPosition) override
VECTOR2D m_end
Marker end position for markers that stretch between points
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))
COLOR4D m_color
Marker color.
Class CAIRO_GAL is the cairo implementation of the graphics abstraction layer.
Definition: color4d.cpp:175
void SetEndPosition(const wxPoint &aPosition)
BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class,...
MARKER_STYLE GetStyle() const
Classes BOARD_ITEM and BOARD_CONNECTED_ITEM.
void SetEndPosition(const VECTOR2D &aPosition)
VECTOR2D m_position
Marker coordinates.
wxString GetClass() const override
Get class name.
void ViewDraw(int aLayer, VIEW *aView) const override
Function ViewDraw() Draws the parts of the object belonging to layer aLayer.
MARKER_STYLE m_style
Marker symbol.
VECTOR2< double > VECTOR2D
Definition: vector2d.h:593
void ViewGetLayers(int aLayers[], int &aCount) const override
Function ViewGetLayers() Returns the all the layers within the VIEW the object is painted on.
void SetPosition(const VECTOR2D &aPosition)
void SetSize(int aSize)
void SetDrawAtZero(bool aDrawFlag)
Function SetDrawAtZero() Set the draw at zero flag.
unsigned STATUS_FLAGS
Definition: base_struct.h:152
const BOX2I ViewBBox() const override
Function ViewBBox() returns the bounding box of the item covering all its layers.
const wxPoint GetPosition() const override
const KIGFX::COLOR4D & GetColor() const
Board layer functions and definitions.
int m_size
Marker size (in pixels).
void SetColor(const KIGFX::COLOR4D &aColor)
bool m_drawAtZero
If set, the marker will be drawn even if its position is 0,0
VIEW.
Definition: view.h:61
void SetStyle(MARKER_STYLE aStyle)
MARKER_STYLE
Marker symbol styles
ORIGIN_VIEWITEM * Clone() const override
Function Clone creates a duplicate of this item with linked list members set to NULL.
PCB_BASE_FRAME basic PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
const wxPoint GetEndPosition() const
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:99