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 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() : ITEM( SOLID_T ), m_shape( NULL )
39  {
40  m_movable = false;
41  }
42 
44  {
45  delete m_shape;
46  }
47 
48  SOLID( const SOLID& aSolid ) :
49  ITEM( aSolid )
50  {
51  m_shape = aSolid.m_shape->Clone();
52  m_pos = aSolid.m_pos;
53  }
54 
55  static inline bool ClassOf( const ITEM* aItem )
56  {
57  return aItem && SOLID_T == aItem->Kind();
58  }
59 
60  ITEM* Clone() const override;
61 
62  const SHAPE* Shape() const override { return m_shape; }
63 
64  const SHAPE_LINE_CHAIN Hull( int aClearance = 0, int aWalkaroundThickness = 0 ) const override;
65 
66  void SetShape( SHAPE* shape )
67  {
68  if( m_shape )
69  delete m_shape;
70 
71  m_shape = shape;
72  }
73 
74  const VECTOR2I& Pos() const
75  {
76  return m_pos;
77  }
78 
79  void SetPos( const VECTOR2I& aCenter )
80  {
81  m_pos = aCenter;
82  }
83 
84  virtual VECTOR2I Anchor( int aN ) const override
85  {
86  return m_pos;
87  }
88 
89  virtual int AnchorCount() const override
90  {
91  return 1;
92  }
93 
94  VECTOR2I Offset() const
95  {
96  return m_offset;
97  }
98 
99  void SetOffset( const VECTOR2I& aOffset )
100  {
101  m_offset = aOffset;
102  }
103 
104 private:
108 };
109 
110 }
111 
112 #endif
Class ITEM.
Definition: pns_item.h:53
const SHAPE * Shape() const override
Function Shape()
Definition: pns_solid.h:62
const VECTOR2I & Pos() const
Definition: pns_solid.h:74
void SetPos(const VECTOR2I &aCenter)
Definition: pns_solid.h:79
const SHAPE_LINE_CHAIN Hull(int aClearance=0, int aWalkaroundThickness=0) const override
Definition: pns_solid.cpp:35
bool m_movable
Definition: pns_item.h:352
void SetOffset(const VECTOR2I &aOffset)
Definition: pns_solid.h:99
SHAPE * m_shape
Definition: pns_solid.h:106
virtual SHAPE * Clone() const
Function Clone()
Definition: shape.h:93
SOLID(const SOLID &aSolid)
Definition: pns_solid.h:48
ITEM * Clone() const override
Function Clone()
Definition: pns_solid.cpp:76
void SetShape(SHAPE *shape)
Definition: pns_solid.h:66
Class SHAPE.
Definition: shape.h:57
virtual int AnchorCount() const override
Definition: pns_solid.h:89
static bool ClassOf(const ITEM *aItem)
Definition: pns_solid.h:55
PnsKind Kind() const
Function Kind()
Definition: pns_item.h:120
VECTOR2I m_offset
Definition: pns_solid.h:107
Class SHAPE_LINE_CHAIN.
VECTOR2I Offset() const
Definition: pns_solid.h:94
virtual VECTOR2I Anchor(int aN) const override
Definition: pns_solid.h:84
Push and Shove diff pair dimensions (gap) settings dialog.
VECTOR2I m_pos
Definition: pns_solid.h:105