KiCad PCB EDA Suite
pns_solid.h
Go to the documentation of this file.
1 /*
2  * KiRouter - a push-and-(sometimes-)shove PCB router
3  *
4  * Copyright (C) 2013 CERN
5  * Copyright (C) 2016-2020 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_SOLID_H
23 #define __PNS_SOLID_H
24 
25 #include <math/vector2d.h>
26 
27 #include <geometry/seg.h>
28 #include <geometry/shape.h>
30 
31 #include "pns_item.h"
32 
33 namespace PNS {
34 
35 class SOLID : public ITEM
36 {
37 public:
38  SOLID() :
39  ITEM( SOLID_T ),
40  m_shape( NULL ),
41  m_hole( NULL )
42  {
43  m_movable = false;
44  m_padToDie = 0;
45  m_orientation = 0;
46  }
47 
49  {
50  delete m_shape;
51  delete m_hole;
52  }
53 
54  SOLID( const SOLID& aSolid ) :
55  ITEM( aSolid )
56  {
57  if( aSolid.m_shape )
58  m_shape = aSolid.m_shape->Clone();
59  else
60  m_shape = nullptr;
61 
62  if( aSolid.m_hole )
63  m_hole = aSolid.m_hole->Clone();
64  else
65  m_hole = nullptr;
66 
67  m_pos = aSolid.m_pos;
68  m_padToDie = aSolid.m_padToDie;
70  }
71 
72  static inline bool ClassOf( const ITEM* aItem )
73  {
74  return aItem && SOLID_T == aItem->Kind();
75  }
76 
77  ITEM* Clone() const override;
78 
79  const SHAPE* Shape() const override { return m_shape; }
80 
81  const SHAPE* Hole() const override { return m_hole; }
82 
83  const SHAPE_LINE_CHAIN Hull( int aClearance = 0, int aWalkaroundThickness = 0,
84  int aLayer = -1 ) const override;
85 
86  const SHAPE_LINE_CHAIN HoleHull( int aClearance, int aWalkaroundThickness,
87  int aLayer ) const override;
88 
89  void SetShape( SHAPE* shape )
90  {
91  delete m_shape;
92  m_shape = shape;
93  }
94 
95  void SetHole( SHAPE* shape )
96  {
97  delete m_hole;
98  m_hole = shape;
99  }
100 
101  const VECTOR2I& Pos() const { return m_pos; }
102  void SetPos( const VECTOR2I& aCenter );
103 
104  int GetPadToDie() const { return m_padToDie; }
105  void SetPadToDie( int aLen ) { m_padToDie = aLen; }
106 
107  virtual VECTOR2I Anchor( int aN ) const override
108  {
109  return m_pos;
110  }
111 
112  virtual int AnchorCount() const override
113  {
114  return 1;
115  }
116 
117  VECTOR2I Offset() const { return m_offset; }
118  void SetOffset( const VECTOR2I& aOffset ) { m_offset = aOffset; }
119 
120  double GetOrientation() const { return m_orientation; }
121  void SetOrientation( double aOrientation ) { m_orientation = aOrientation; }
122 
123 private:
129  double m_orientation; // in 1/10 degrees, matching PAD
130 };
131 
132 }
133 
134 #endif
Base class for PNS router board items.
Definition: pns_item.h:55
const SHAPE * Shape() const override
Return the geometrical shape of the item.
Definition: pns_solid.h:79
VECTOR2I Offset() const
Definition: pns_solid.h:117
void SetPos(const VECTOR2I &aCenter)
Definition: pns_solid.cpp:151
const SHAPE_LINE_CHAIN HoleHull(int aClearance, int aWalkaroundThickness, int aLayer) const override
Definition: pns_solid.cpp:117
double GetOrientation() const
Definition: pns_solid.h:120
double m_orientation
Definition: pns_solid.h:129
bool m_movable
Definition: pns_item.h:241
void SetOffset(const VECTOR2I &aOffset)
Definition: pns_solid.h:118
SHAPE * m_shape
Definition: pns_solid.h:125
void SetHole(SHAPE *shape)
Definition: pns_solid.h:95
int m_padToDie
Definition: pns_solid.h:128
SOLID(const SOLID &aSolid)
Definition: pns_solid.h:54
#define NULL
ITEM * Clone() const override
Return a deep copy of the item.
Definition: pns_solid.cpp:145
int GetPadToDie() const
Definition: pns_solid.h:104
void SetPadToDie(int aLen)
Definition: pns_solid.h:105
void SetShape(SHAPE *shape)
Definition: pns_solid.h:89
virtual SHAPE * Clone() const
Return a dynamically allocated copy of the shape.
Definition: shape.h:139
An abstract shape on 2D plane.
Definition: shape.h:116
const SHAPE * Hole() const override
Definition: pns_solid.h:81
virtual int AnchorCount() const override
Definition: pns_solid.h:112
static bool ClassOf(const ITEM *aItem)
Definition: pns_solid.h:72
SHAPE * m_hole
Definition: pns_solid.h:126
const VECTOR2I & Pos() const
Definition: pns_solid.h:101
VECTOR2I m_offset
Definition: pns_solid.h:127
SHAPE_LINE_CHAIN.
virtual VECTOR2I Anchor(int aN) const override
Definition: pns_solid.h:107
PnsKind Kind() const
Return the type (kind) of the item.
Definition: pns_item.h:126
void SetOrientation(double aOrientation)
Definition: pns_solid.h:121
Push and Shove diff pair dimensions (gap) settings dialog.
const SHAPE_LINE_CHAIN Hull(int aClearance=0, int aWalkaroundThickness=0, int aLayer=-1) const override
Definition: pns_solid.cpp:86
VECTOR2I m_pos
Definition: pns_solid.h:124