KiCad PCB EDA Suite
pns_segment.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_SEGMENT_H
23 #define __PNS_SEGMENT_H
24 
25 #include <math/vector2d.h>
26 
27 #include <geometry/seg.h>
28 #include <geometry/shape_segment.h>
30 
31 #include "pns_line.h"
32 #include "pns_linked_item.h"
33 
34 namespace PNS {
35 
36 class NODE;
37 
38 class SEGMENT : public LINKED_ITEM
39 {
40 public:
41  SEGMENT() :
43  {}
44 
45  SEGMENT( const SEG& aSeg, int aNet ) :
46  LINKED_ITEM( SEGMENT_T ), m_seg( aSeg, 0 )
47  {
48  m_net = aNet;
49  }
50 
51  SEGMENT( const LINE& aParentLine, const SEG& aSeg ) :
53  m_seg( aSeg, aParentLine.Width() )
54  {
55  m_net = aParentLine.Net();
56  m_layers = aParentLine.Layers();
57  m_marker = aParentLine.Marker();
58  m_rank = aParentLine.Rank();
59  }
60 
61  static inline bool ClassOf( const ITEM* aItem )
62  {
63  return aItem && SEGMENT_T == aItem->Kind();
64  }
65 
66  SEGMENT* Clone() const override;
67 
68  const SHAPE* Shape() const override
69  {
70  return static_cast<const SHAPE*>( &m_seg );
71  }
72 
73  void SetWidth( int aWidth ) override
74  {
75  m_seg.SetWidth(aWidth);
76  }
77 
78  int Width() const override
79  {
80  return m_seg.GetWidth();
81  }
82 
83  const SEG& Seg() const
84  {
85  return m_seg.GetSeg();
86  }
87 
88  const SHAPE_LINE_CHAIN CLine() const
89  {
90  return SHAPE_LINE_CHAIN( { m_seg.GetSeg().A, m_seg.GetSeg().B } );
91  }
92 
93  void SetEnds( const VECTOR2I& a, const VECTOR2I& b )
94  {
95  m_seg.SetSeg( SEG ( a, b ) );
96  }
97 
98  void SwapEnds()
99  {
100  SEG tmp = m_seg.GetSeg();
101  m_seg.SetSeg( SEG (tmp.B , tmp.A ) );
102  }
103 
104  const SHAPE_LINE_CHAIN Hull( int aClearance, int aWalkaroundThickness ) const override;
105 
106  virtual VECTOR2I Anchor( int n ) const override
107  {
108  if( n == 0 )
109  return m_seg.GetSeg().A;
110  else
111  return m_seg.GetSeg().B;
112  }
113 
114  virtual int AnchorCount() const override
115  {
116  return 2;
117  }
118 
119 private:
121 };
122 
123 }
124 
125 #endif
ITEM.
Definition: pns_item.h:53
const SHAPE_LINE_CHAIN Hull(int aClearance, int aWalkaroundThickness) const override
Definition: pns_line.cpp:402
virtual int AnchorCount() const override
Definition: pns_segment.h:114
SHAPE_SEGMENT m_seg
Definition: pns_segment.h:120
void SetSeg(const SEG &aSeg)
int Rank() const override
Definition: pns_line.cpp:882
int Width() const override
Definition: pns_segment.h:78
SEGMENT * Clone() const override
Function Clone()
Definition: pns_line.cpp:126
const SHAPE_LINE_CHAIN CLine() const
Definition: pns_segment.h:88
static bool ClassOf(const ITEM *aItem)
Definition: pns_segment.h:61
LAYER_RANGE m_layers
Definition: pns_item.h:253
int m_rank
Definition: pns_item.h:258
const SEG & Seg() const
Definition: pns_segment.h:83
const SEG & GetSeg() const
int m_marker
Definition: pns_item.h:257
SEGMENT(const LINE &aParentLine, const SEG &aSeg)
Definition: pns_segment.h:51
virtual VECTOR2I Anchor(int n) const override
Definition: pns_segment.h:106
void SetWidth(int aWidth) override
Definition: pns_segment.h:73
int Net() const
Definition: pns_item.h:149
SHAPE.
Definition: shape.h:74
SEGMENT(const SEG &aSeg, int aNet)
Definition: pns_segment.h:45
int m_net
Definition: pns_item.h:256
Definition: seg.h:39
virtual int Marker() const override
Definition: pns_line.cpp:107
SHAPE_LINE_CHAIN.
VECTOR2I A
Definition: seg.h:47
void SwapEnds()
Definition: pns_segment.h:98
void SetEnds(const VECTOR2I &a, const VECTOR2I &b)
Definition: pns_segment.h:93
PnsKind Kind() const
Function Kind()
Definition: pns_item.h:123
const SHAPE * Shape() const override
Function Shape()
Definition: pns_segment.h:68
Push and Shove diff pair dimensions (gap) settings dialog.
int GetWidth() const
const LAYER_RANGE & Layers() const
Definition: pns_item.h:151
void SetWidth(int aWidth)
VECTOR2I B
Definition: seg.h:48