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>
38 
39 #include <eda_item.h>
40 
41 namespace PNS {
42 
43 class ITEM;
44 class ROUTER;
45 
46 }
47 
49 {
50 public:
51  enum ITEM_TYPE
52  {
56  };
57 
58  ROUTER_PREVIEW_ITEM( const PNS::ITEM* aItem = NULL, KIGFX::VIEW* aView = NULL);
60 
61  void Update( const PNS::ITEM* aItem );
62 
63  void Line( const SHAPE_LINE_CHAIN& aLine, int aWidth = 0, int aStyle = 0 );
64  void Box( const BOX2I& aBox, int aStyle = 0 );
65  void Point ( const VECTOR2I& aPos, int aStyle = 0);
66 
67  void SetColor( const KIGFX::COLOR4D& aColor )
68  {
69  m_color = aColor;
70  }
71 
72  void SetClearance( int aClearance )
73  {
74  m_clearance = aClearance;
75  }
76 
77  void ShowTrackClearance( bool aEnabled )
78  {
79  m_showTrackClearance = aEnabled;
80  }
81 
82  void ShowViaClearance( bool aEnabled )
83  {
84  m_showViaClearance = aEnabled;
85  }
86 
87 #if defined(DEBUG)
88  void Show( int aA, std::ostream& aB ) const override {}
89 #endif
90 
94  virtual wxString GetClass() const override
95  {
96  return wxT( "ROUTER_PREVIEW_ITEM" );
97  }
98 
99  const BOX2I ViewBBox() const override;
100 
101  virtual void ViewDraw( int aLayer, KIGFX::VIEW* aView ) const override;
102 
103  virtual void ViewGetLayers( int aLayers[], int& aCount ) const override
104  {
105  aLayers[0] = m_layer;
106  aCount = 1;
107  }
108 
109  void drawLineChain( const SHAPE_LINE_CHAIN_BASE* aL, KIGFX::GAL* aGal ) const;
110 
111  void drawShape( const SHAPE* aShape, KIGFX::GAL* aGal ) const;
112 
113 private:
114  const KIGFX::COLOR4D assignColor( int aStyle ) const;
115  const KIGFX::COLOR4D getLayerColor( int aLayer ) const;
116 
118 
121 
123 
124  int m_style;
125  int m_width;
126  int m_layer;
129 
132 
133  // fixme: shouldn't this go to VIEW?
134  static const int ClearanceOverlayDepth;
135  static const int BaseOverlayDepth;
136  static const int ViaOverlayDepth;
137 
138  double m_depth;
139 
142 };
143 
144 #endif
Base class for PNS router board items.
Definition: pns_item.h:55
void drawShape(const SHAPE *aShape, KIGFX::GAL *aGal) const
static const int ClearanceOverlayDepth
void drawLineChain(const SHAPE_LINE_CHAIN_BASE *aL, KIGFX::GAL *aGal) const
static const int BaseOverlayDepth
void SetClearance(int aClearance)
void Line(const SHAPE_LINE_CHAIN &aLine, int aWidth=0, int aStyle=0)
void ShowTrackClearance(bool aEnabled)
const KIGFX::COLOR4D getLayerColor(int aLayer) const
VIEW_ITEM class definition.
#define NULL
void Update(const PNS::ITEM *aItem)
const KIGFX::COLOR4D assignColor(int aStyle) const
void ShowViaClearance(bool aEnabled)
An abstract shape on 2D plane.
Definition: shape.h:116
virtual void ViewGetLayers(int aLayers[], int &aCount) const override
Return the all the layers within the VIEW the object is painted on.
virtual void ViewDraw(int aLayer, KIGFX::VIEW *aView) const override
Draw the parts of the object belonging to layer aLayer.
void SetColor(const KIGFX::COLOR4D &aColor)
void Point(const VECTOR2I &aPos, int aStyle=0)
SHAPE_LINE_CHAIN.
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:150
const BOX2I ViewBBox() const override
Return the bounding box of the item covering all its layers.
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition: view.h:67
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.
Abstract interface for drawing on a 2D-surface.
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:98