KiCad PCB EDA Suite
pns_via.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 __PNS_VIA_H
23 #define __PNS_VIA_H
24 
26 #include <geometry/shape_circle.h>
27 
28 #include "../class_track.h"
29 
30 #include "pns_item.h"
31 
32 namespace PNS {
33 
34 class NODE;
35 
36 class VIA : public ITEM
37 {
38 public:
39  VIA() :
40  ITEM( VIA_T )
41  {
42  m_diameter = 2; // Dummy value
43  m_drill = 0;
45  }
46 
47  VIA( const VECTOR2I& aPos, const LAYER_RANGE& aLayers,
48  int aDiameter, int aDrill, int aNet = -1, VIATYPE_T aViaType = VIA_THROUGH ) :
49  ITEM( VIA_T )
50  {
51  SetNet( aNet );
52  SetLayers( aLayers );
53  m_pos = aPos;
54  m_diameter = aDiameter;
55  m_drill = aDrill;
56  m_shape = SHAPE_CIRCLE( aPos, aDiameter / 2 );
57  m_viaType = aViaType;
58 
59  //If we're a through-board via, use all layers regardless of the set passed
60  if( aViaType == VIA_THROUGH )
61  {
62  LAYER_RANGE allLayers( 0, MAX_CU_LAYERS - 1 );
63  SetLayers( allLayers );
64  }
65  }
66 
67 
68  VIA( const VIA& aB ) :
69  ITEM( VIA_T )
70  {
71  SetNet( aB.Net() );
72  SetLayers( aB.Layers() );
73  m_pos = aB.m_pos;
75  m_shape = SHAPE_CIRCLE( m_pos, m_diameter / 2 );
76  m_marker = aB.m_marker;
77  m_rank = aB.m_rank;
78  m_drill = aB.m_drill;
79  m_viaType = aB.m_viaType;
80  }
81 
82  static inline bool ClassOf( const ITEM* aItem )
83  {
84  return aItem && VIA_T == aItem->Kind();
85  }
86 
87 
88  const VECTOR2I& Pos() const
89  {
90  return m_pos;
91  }
92 
93  void SetPos( const VECTOR2I& aPos )
94  {
95  m_pos = aPos;
96  m_shape.SetCenter( aPos );
97  }
98 
100  {
101  return m_viaType;
102  }
103 
104  void SetViaType( VIATYPE_T aViaType )
105  {
106  m_viaType = aViaType;
107  }
108 
109  int Diameter() const
110  {
111  return m_diameter;
112  }
113 
114  void SetDiameter( int aDiameter )
115  {
116  m_diameter = aDiameter;
118  }
119 
120  int Drill() const
121  {
122  return m_drill;
123  }
124 
125  void SetDrill( int aDrill )
126  {
127  m_drill = aDrill;
128  }
129 
130  bool PushoutForce( NODE* aNode,
131  const VECTOR2I& aDirection,
132  VECTOR2I& aForce,
133  bool aSolidsOnly = true,
134  int aMaxIterations = 10 );
135 
136  const SHAPE* Shape() const override
137  {
138  return &m_shape;
139  }
140 
141  VIA* Clone() const override;
142 
143  const SHAPE_LINE_CHAIN Hull( int aClearance = 0, int aWalkaroundThickness = 0 ) const override;
144 
145  virtual VECTOR2I Anchor( int n ) const override
146  {
147  return m_pos;
148  }
149 
150  virtual int AnchorCount() const override
151  {
152  return 1;
153  }
154 
155  OPT_BOX2I ChangedArea( const VIA* aOther ) const;
156 
157 private:
159  int m_drill;
163 };
164 
165 }
166 
167 #endif
Class ITEM.
Definition: pns_item.h:53
VIA(const VIA &aB)
Definition: pns_via.h:68
void SetCenter(const VECTOR2I &aCenter)
Definition: shape_circle.h:74
VIA()
Definition: pns_via.h:39
Class NODE.
Definition: pns_node.h:137
virtual int AnchorCount() const override
Definition: pns_via.h:150
const LAYER_RANGE & Layers() const
Function Layers()
Definition: pns_item.h:207
VIATYPE_T m_viaType
Definition: pns_via.h:162
int Drill() const
Definition: pns_via.h:120
int Diameter() const
Definition: pns_via.h:109
VIA * Clone() const override
Function Clone()
Definition: pns_via.cpp:84
bool PushoutForce(NODE *aNode, const VECTOR2I &aDirection, VECTOR2I &aForce, bool aSolidsOnly=true, int aMaxIterations=10)
Definition: pns_via.cpp:31
int m_rank
Definition: pns_item.h:355
const VECTOR2I & Pos() const
Definition: pns_via.h:88
VIATYPE_T
Definition: class_track.h:49
const SHAPE * Shape() const override
Function Shape()
Definition: pns_via.h:136
int m_drill
Definition: pns_via.h:159
int m_marker
Definition: pns_item.h:354
void SetNet(int aNet)
Function SetNet()
Definition: pns_item.h:167
static bool ClassOf(const ITEM *aItem)
Definition: pns_via.h:82
VECTOR2I m_pos
Definition: pns_via.h:160
void SetDiameter(int aDiameter)
Definition: pns_via.h:114
VIATYPE_T ViaType() const
Definition: pns_via.h:99
VIA(const VECTOR2I &aPos, const LAYER_RANGE &aLayers, int aDiameter, int aDrill, int aNet=-1, VIATYPE_T aViaType=VIA_THROUGH)
Definition: pns_via.h:47
int m_diameter
Definition: pns_via.h:158
const SHAPE_LINE_CHAIN Hull(int aClearance=0, int aWalkaroundThickness=0) const override
Definition: pns_via.cpp:74
SHAPE_CIRCLE m_shape
Definition: pns_via.h:161
Class SHAPE.
Definition: shape.h:57
void SetLayers(const LAYER_RANGE &aLayers)
Function SetLayers()
Definition: pns_item.h:187
PnsKind Kind() const
Function Kind()
Definition: pns_item.h:120
void SetPos(const VECTOR2I &aPos)
Definition: pns_via.h:93
void SetRadius(int aRadius)
Definition: shape_circle.h:69
Class SHAPE_LINE_CHAIN.
int Net() const
Function Net()
Definition: pns_item.h:177
void SetDrill(int aDrill)
Definition: pns_via.h:125
Push and Shove diff pair dimensions (gap) settings dialog.
void SetViaType(VIATYPE_T aViaType)
Definition: pns_via.h:104
Class LAYER_RANGE.
Definition: pns_layerset.h:32
virtual VECTOR2I Anchor(int n) const override
Definition: pns_via.h:145
OPT_BOX2I ChangedArea(const VIA *aOther) const
Definition: pns_via.cpp:102