Horizon
pns_solid.h
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>
29#include <geometry/shape_line_chain.h>
30
31#include "pns_item.h"
32
33namespace PNS {
34
35class SOLID : public ITEM
36{
37public:
38 SOLID() : ITEM( SOLID_T ), m_shape( NULL )
39 {
40 m_movable = false;
41 }
42
43 ~SOLID()
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
104private:
105 VECTOR2I m_pos;
106 SHAPE* m_shape;
107 VECTOR2I m_offset;
108};
109
110}
111
112#endif
Class ITEM.
Definition: pns_item.h:55
PnsKind Kind() const
Function Kind()
Definition: pns_item.h:123
Definition: pns_solid.h:36
const SHAPE * Shape() const override
Function Shape()
Definition: pns_solid.h:62
ITEM * Clone() const override
Function Clone()
Definition: pns_solid.cpp:76
Class SHAPE_LINE_CHAIN.
Definition: shape_line_chain.h:50
Class SHAPE.
Definition: shape.h:59
virtual SHAPE * Clone() const
Function Clone()
Definition: shape.h:94