KiCad PCB EDA Suite
Loading...
Searching...
No Matches
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 The KiCad Developers, see AUTHORS.txt for contributors.
6 * Author: Tomasz Wlostowski <[email protected]>
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
19 * along with this program. If not, see <https://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
36
37#include <gal/color4d.h>
38
39#include <layer_ids.h>
40#include <eda_item.h>
41
42namespace PNS {
43
44class ITEM;
45class ROUTER;
46class ROUTER_IFACE;
47
48}
49
50#define PNS_HEAD_TRACE 1
51#define PNS_HOVER_ITEM 2
52#define PNS_SEMI_SOLID 4
53#define PNS_COLLISION 8
54
55
57{
58public:
65
75
87 static constexpr double LayerDepthFactor = 0.001;
88 static constexpr double PathOverlayDepth = LayerDepthFactor * static_cast<double>( LAYER_ZONE_END );
89
90 ROUTER_PREVIEW_ITEM( const SHAPE& aShape, PNS::ROUTER_IFACE* aIface, KIGFX::VIEW* aView );
91 ROUTER_PREVIEW_ITEM( const PNS::ITEM* aItem, PNS::ROUTER_IFACE* aIface, KIGFX::VIEW* aView,
92 int aFlags = 0, DISPLAY_MODE aMode = DM_SHAPE );
94
95 void Update( const PNS::ITEM* aItem );
96
97 void SetColor( const KIGFX::COLOR4D& aColor ) { m_color = aColor; }
98 void SetDepth( double aDepth ) { m_depth = aDepth; }
99 void SetWidth( int aWidth ) { m_width = aWidth; }
100
101 void SetClearance( int aClearance ) { m_clearance = aClearance; }
102
103 bool IsCollisionFlagged() const { return ( m_flags & PNS_COLLISION ) != 0; }
104
105 double GetOriginDepth() const { return m_originDepth; }
106
107#if defined(DEBUG)
108 void Show( int aA, std::ostream& aB ) const override {}
109#endif
110
114 virtual wxString GetClass() const override
115 {
116 return wxT( "ROUTER_PREVIEW_ITEM" );
117 }
118
119 const BOX2I ViewBBox() const override;
120
121 virtual void ViewDraw( int aLayer, KIGFX::VIEW* aView ) const override;
122
123 virtual std::vector<int> ViewGetLayers() const override
124 {
125 return { m_layer };
126 }
127
128 void drawLineChain( const SHAPE_LINE_CHAIN_BASE* aL, KIGFX::GAL* aGal ) const;
129
130 void drawShape( const SHAPE* aShape, KIGFX::GAL* aGal ) const;
131
132 void drawClearanceHalo( const SHAPE* aShape, KIGFX::GAL* aGal ) const;
133
134private:
135 const KIGFX::COLOR4D getLayerColor( int aLayer, const PNS::ITEM* aItem = nullptr ) const;
136
137 int chooseLayer() const;
138
139private:
141
143
146
148
155
157 double m_depth;
158
161};
162
163#endif
BOX2< VECTOR2I > BOX2I
Definition box2.h:914
EDA_ITEM(EDA_ITEM *parent, KICAD_T idType, bool isSCH_ITEM=false, bool isBOARD_ITEM=false)
Definition eda_item.cpp:84
A color representation with 4 components: red, green, blue, alpha.
Definition color4d.h:101
Abstract interface for drawing on a 2D-surface.
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition view.h:68
Base class for PNS router board items.
Definition pns_item.h:98
DISPLAY_MODE
An element with a visible clearance is drawn as two items on separate view layers,...
@ DM_SHAPE
Shape body only, in the normal or collision color.
@ DM_SHADOW
Clearance halo only, drawn behind board items.
ROUTER_PREVIEW_ITEM(const SHAPE &aShape, PNS::ROUTER_IFACE *aIface, KIGFX::VIEW *aView)
void SetWidth(int aWidth)
void SetClearance(int aClearance)
static constexpr double PathOverlayDepth
void SetColor(const KIGFX::COLOR4D &aColor)
virtual wxString GetClass() const override
Get class name.
static constexpr double LayerDepthFactor
We draw this item on a single layer, but we stack up all the layers from the various components that ...
void Update(const PNS::ITEM *aItem)
double GetOriginDepth() const
virtual void ViewDraw(int aLayer, KIGFX::VIEW *aView) const override
Draw the parts of the object belonging to layer aLayer.
virtual std::vector< int > ViewGetLayers() const override
Return the all the layers within the VIEW the object is painted on.
const KIGFX::COLOR4D getLayerColor(int aLayer, const PNS::ITEM *aItem=nullptr) const
void drawLineChain(const SHAPE_LINE_CHAIN_BASE *aL, KIGFX::GAL *aGal) const
const BOX2I ViewBBox() const override
Return the bounding box of the item covering all its layers.
void SetDepth(double aDepth)
void drawShape(const SHAPE *aShape, KIGFX::GAL *aGal) const
PNS::ROUTER_IFACE * m_iface
void drawClearanceHalo(const SHAPE *aShape, KIGFX::GAL *aGal) const
An abstract shape on 2D plane.
Definition shape.h:124
@ LAYER_ZONE_END
Definition layer_ids.h:352
Push and Shove diff pair dimensions (gap) settings dialog.
#define PNS_COLLISION
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:708