KiCad PCB EDA Suite
router_preview_item.h
Go to the documentation of this file.
1 /*
2  * KiRouter - a push-and-(sometimes-)shove PCB router
3  *
4  * Copyright (C) 2013-2014 CERN
5  * Copyright (C) 2016 KiCad Developers, see AUTHORS.txt for contributors.
6  * Author: Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
7  *
8  * This program is free software: you can redistribute it and/or modify it
9  * under the terms of the GNU General Public License as published by the
10  * Free Software Foundation, either version 3 of the License, or (at your
11  * option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful, but
14  * WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License along
19  * with this program. If not, see <http://www.gnu.org/licenses/>.
20  */
21 
22 #ifndef __ROUTER_PREVIEW_ITEM_H
23 #define __ROUTER_PREVIEW_ITEM_H
24 
25 #include <cstdio>
26 
27 #include <view/view.h>
28 #include <view/view_item.h>
29 #include <view/view_group.h>
30 
31 #include <math/vector2d.h>
32 #include <math/box2.h>
33 
35 #include <geometry/shape_circle.h>
36 
37 #include <gal/color4d.h>
39 
41 
42 namespace PNS {
43 
44 class ITEM;
45 class ROUTER;
46 
47 }
48 
50 {
51 public:
52  enum ITEM_TYPE
53  {
57  };
58 
59  ROUTER_PREVIEW_ITEM( const PNS::ITEM* aItem = NULL, KIGFX::VIEW* aView = NULL);
61 
62  void Update( const PNS::ITEM* aItem );
63 
64  void StuckMarker( VECTOR2I& aPosition );
65 
66  void Line( const SHAPE_LINE_CHAIN& aLine, int aWidth = 0, int aStyle = 0 );
67  void Box( const BOX2I& aBox, int aStyle = 0 );
68  void Point ( const VECTOR2I& aPos, int aStyle = 0);
69 
70  void SetColor( const KIGFX::COLOR4D& aColor )
71  {
72  m_color = aColor;
73  }
74 
75  void SetClearance( int aClearance )
76  {
77  m_clearance = aClearance;
78  }
79 
80  void ShowTrackClearance( bool aEnabled )
81  {
82  m_showTrackClearance = aEnabled;
83  }
84 
85  void ShowViaClearance( bool aEnabled )
86  {
87  m_showViaClearance = aEnabled;
88  }
89 
90 #if defined(DEBUG)
91  void Show( int aA, std::ostream& aB ) const override {}
92 #endif
93 
97  virtual wxString GetClass() const override
98  {
99  return wxT( "ROUTER_PREVIEW_ITEM" );
100  }
101 
102  const BOX2I ViewBBox() const override;
103 
104  virtual void ViewDraw( int aLayer, KIGFX::VIEW* aView ) const override;
105 
106  virtual void ViewGetLayers( int aLayers[], int& aCount ) const override
107  {
108  aLayers[0] = m_layer;
109  aCount = 1;
110  }
111 
112  void drawLineChain( const SHAPE_LINE_CHAIN& aL, KIGFX::GAL* aGal ) const;
113 
114 private:
115  const KIGFX::COLOR4D assignColor( int aStyle ) const;
116  const KIGFX::COLOR4D getLayerColor( int aLayer ) const;
117 
119 
122 
124 
125  int m_style;
126  int m_width;
127  int m_layer;
130 
133 
134  // fixme: shouldn't this go to VIEW?
135  static const int ClearanceOverlayDepth;
136  static const int BaseOverlayDepth;
137  static const int ViaOverlayDepth;
138 
139  double m_depth;
140 
143 };
144 
145 #endif
Class ITEM.
Definition: pns_item.h:53
static const int ClearanceOverlayDepth
const KIGFX::COLOR4D assignColor(int aStyle) const
static const int BaseOverlayDepth
void SetClearance(int aClearance)
const KIGFX::COLOR4D getLayerColor(int aLayer) const
void Line(const SHAPE_LINE_CHAIN &aLine, int aWidth=0, int aStyle=0)
void ShowTrackClearance(bool aEnabled)
VIEW_ITEM class definition.
void StuckMarker(VECTOR2I &aPosition)
void Update(const PNS::ITEM *aItem)
void ShowViaClearance(bool aEnabled)
VIEW_GROUP extends VIEW_ITEM by possibility of grouping items into a single object.
Class SHAPE.
Definition: shape.h:57
void drawLineChain(const SHAPE_LINE_CHAIN &aL, KIGFX::GAL *aGal) const
virtual void ViewGetLayers(int aLayers[], int &aCount) const override
virtual void ViewDraw(int aLayer, KIGFX::VIEW *aView) const override
Function ViewDraw() Draws the parts of the object belonging to layer aLayer.
void SetColor(const KIGFX::COLOR4D &aColor)
void Point(const VECTOR2I &aPos, int aStyle=0)
Board layer functions and definitions.
Class SHAPE_LINE_CHAIN.
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:151
const BOX2I ViewBBox() const override
Class VIEW.
Definition: view.h:58
static const int ViaOverlayDepth
Push and Shove diff pair dimensions (gap) settings dialog.
void Box(const BOX2I &aBox, int aStyle=0)
ROUTER_PREVIEW_ITEM(const PNS::ITEM *aItem=NULL, KIGFX::VIEW *aView=NULL)
virtual wxString GetClass() const override
Get class name.
Class GAL is the abstract interface for drawing on a 2D-surface.
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39