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 Print( PCB_BASE_FRAME* aFrame, wxDC* DC, const wxPoint& offset = ZeroOffset ) override
66  {
67  wxASSERT( 0 ); // ORIGIN_VIEWITEM never added to BOARD
68  }
69 
70  void ViewGetLayers( int aLayers[], int& aCount ) const override
71  {
72  aLayers[0] = LAYER_GP_OVERLAY;
73  aCount = 1;
74  }
75 
76 #if defined(DEBUG)
77  void Show( int x, std::ostream& st ) const override
78  {
79  }
80 #endif
81 
85  wxString GetClass() const override
86  {
87  return wxT( "ORIGIN_VIEWITEM" );
88  }
89 
96  inline void SetDrawAtZero( bool aDrawFlag )
97  {
98  m_drawAtZero = aDrawFlag;
99  }
100 
101  inline void SetPosition( const VECTOR2D& aPosition )
102  {
103  m_position = aPosition;
104  }
105 
106  inline void SetPosition( const wxPoint& aPosition ) override
107  {
108  m_position = VECTOR2D( aPosition );
109  }
110 
111  inline const wxPoint GetPosition() const override
112  {
113  return wxPoint( m_position.x, m_position.y );
114  }
115 
116  inline void SetEndPosition( const VECTOR2D& aPosition )
117  {
118  m_end = aPosition;
119  }
120 
121  inline void SetEndPosition( const wxPoint& aPosition )
122  {
123  m_end = VECTOR2D( aPosition );
124  }
125 
126  inline const wxPoint GetEndPosition() const
127  {
128  return wxPoint( m_end.x, m_end.y );
129  }
130 
131  inline void SetSize( int aSize )
132  {
133  m_size = aSize;
134  }
135 
136  inline int GetSize() const
137  {
138  return m_size;
139  }
140 
141  inline void SetColor( const KIGFX::COLOR4D& aColor )
142  {
143  m_color = aColor;
144  }
145 
146  inline const KIGFX::COLOR4D& GetColor() const
147  {
148  return m_color;
149  }
150 
151  inline void SetStyle( MARKER_STYLE aStyle )
152  {
153  m_style = aStyle;
154  }
155 
156  inline MARKER_STYLE GetStyle() const
157  {
158  return m_style;
159  }
160 
161 protected:
164 
167 
169  int m_size;
170 
173 
176 
179 };
180 
181 } // namespace KIGFX
182 
183 #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))
void Print(PCB_BASE_FRAME *aFrame, wxDC *DC, const wxPoint &offset=ZeroOffset) override
Function Print BOARD_ITEMs have their own color information.
COLOR4D m_color
Marker color.
Class CAIRO_GAL is the cairo implementation of the graphics abstraction layer.
Definition: color4d.cpp:131
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.
static wxPoint ZeroOffset
A value of wxPoint(0,0) which can be passed to the Draw() functions.
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:156
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:39