KiCad PCB EDA Suite
Loading...
Searching...
No Matches
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-2023 KiCad Developers, see AUTHORS.txt for contributors.
6 * Author: Tomasz Wlostowski <[email protected]>
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
33namespace PNS {
34
35class SOLID : public ITEM
36{
37public:
39 ITEM( SOLID_T ),
40 m_shape( nullptr ),
41 m_hole( nullptr )
42 {
43 m_movable = false;
44 m_padToDie = 0;
45 }
46
48 {
49 delete m_hole;
50 delete m_shape;
51 }
52
53 SOLID( const SOLID& aSolid ) :
54 ITEM( aSolid ),
55 m_shape( nullptr ),
56 m_hole( nullptr )
57 {
58 if( aSolid.m_shape )
59 SetShape( aSolid.m_shape->Clone() );
60
61 if( aSolid.m_hole )
62 SetHole( aSolid.m_hole->Clone() );
63
64 m_pos = aSolid.m_pos;
65 m_padToDie = aSolid.m_padToDie;
68 }
69
70 SOLID& operator=( const SOLID& aB )
71 {
72 if( aB.m_shape )
73 SetShape( aB.m_shape->Clone() );
74
75 if( aB.m_hole )
76 SetHole( new PNS::HOLE( aB.m_hole->Shape()->Clone() ) );
77
78 m_pos = aB.m_pos;
82 return *this;
83 }
84
85 static inline bool ClassOf( const ITEM* aItem )
86 {
87 return aItem && SOLID_T == aItem->Kind();
88 }
89
90 ITEM* Clone() const override;
91
92 const SHAPE* Shape() const override { return m_shape; }
93
94
95 const SHAPE_LINE_CHAIN Hull( int aClearance = 0, int aWalkaroundThickness = 0,
96 int aLayer = -1 ) const override;
97
98 void SetShape( SHAPE* shape )
99 {
100 delete m_shape;
101 m_shape = shape;
102 }
103
104 const VECTOR2I& Pos() const { return m_pos; }
105 void SetPos( const VECTOR2I& aCenter );
106
107 int GetPadToDie() const { return m_padToDie; }
108 void SetPadToDie( int aLen ) { m_padToDie = aLen; }
109
110 virtual VECTOR2I Anchor( int aN ) const override;
111
112 virtual int AnchorCount() const override;
113
114 const std::vector<VECTOR2I>& AnchorPoints() const { return m_anchorPoints; }
115 void SetAnchorPoints( const std::vector<VECTOR2I>& aPoints ) { m_anchorPoints = aPoints; }
116
117 VECTOR2I Offset() const { return m_offset; }
118 void SetOffset( const VECTOR2I& aOffset ) { m_offset = aOffset; }
119
121 void SetOrientation( const EDA_ANGLE& aOrientation ) { m_orientation = aOrientation; }
122
123 virtual void SetHole( HOLE* aHole ) override
124 {
125 if( m_hole && m_hole->BelongsTo( this ) )
126 delete m_hole;
127
128 m_hole = aHole;
129 m_hole->SetParentPadVia( this );
130 m_hole->SetOwner( this );
131 m_hole->SetLayers( m_layers ); // fixme: backdrill vias can have hole layer set different
132 // than copper layer set
133 }
134
135 virtual bool HasHole() const override { return m_hole != nullptr; }
136 virtual HOLE *Hole() const override { return m_hole; }
137
138private:
145 std::vector<VECTOR2I> m_anchorPoints;
146};
147
148}
149
150#endif
const SHAPE * Shape() const override
Return the geometrical shape of the item.
Definition: pns_hole.h:69
virtual HOLE * Clone() const override
Return a deep copy of the item.
Definition: pns_hole.cpp:41
void SetParentPadVia(ITEM *aParent)
Definition: pns_hole.h:71
Base class for PNS router board items.
Definition: pns_item.h:97
void SetLayers(const PNS_LAYER_RANGE &aLayers)
Definition: pns_item.h:197
bool m_movable
Definition: pns_item.h:290
PNS_LAYER_RANGE m_layers
Definition: pns_item.h:288
PnsKind Kind() const
Return the type (kind) of the item.
Definition: pns_item.h:167
void SetOwner(const ITEM_OWNER *aOwner)
Set the node that owns this item.
Definition: pns_item.h:76
bool BelongsTo(const ITEM_OWNER *aNode) const
Definition: pns_item.h:81
const SHAPE_LINE_CHAIN Hull(int aClearance=0, int aWalkaroundThickness=0, int aLayer=-1) const override
Definition: pns_solid.cpp:39
int GetPadToDie() const
Definition: pns_solid.h:107
virtual bool HasHole() const override
Definition: pns_solid.h:135
virtual HOLE * Hole() const override
Definition: pns_solid.h:136
const std::vector< VECTOR2I > & AnchorPoints() const
Definition: pns_solid.h:114
VECTOR2I m_pos
Definition: pns_solid.h:139
SOLID(const SOLID &aSolid)
Definition: pns_solid.h:53
void SetPos(const VECTOR2I &aCenter)
Definition: pns_solid.cpp:81
SHAPE * m_shape
Definition: pns_solid.h:140
int m_padToDie
Definition: pns_solid.h:142
const SHAPE * Shape() const override
Return the geometrical shape of the item.
Definition: pns_solid.h:92
void SetPadToDie(int aLen)
Definition: pns_solid.h:108
VECTOR2I Offset() const
Definition: pns_solid.h:117
const VECTOR2I & Pos() const
Definition: pns_solid.h:104
VECTOR2I m_offset
Definition: pns_solid.h:141
void SetOffset(const VECTOR2I &aOffset)
Definition: pns_solid.h:118
EDA_ANGLE m_orientation
Definition: pns_solid.h:143
void SetShape(SHAPE *shape)
Definition: pns_solid.h:98
virtual void SetHole(HOLE *aHole) override
Definition: pns_solid.h:123
SOLID & operator=(const SOLID &aB)
Definition: pns_solid.h:70
ITEM * Clone() const override
Return a deep copy of the item.
Definition: pns_solid.cpp:74
std::vector< VECTOR2I > m_anchorPoints
Definition: pns_solid.h:145
void SetOrientation(const EDA_ANGLE &aOrientation)
Definition: pns_solid.h:121
virtual VECTOR2I Anchor(int aN) const override
Definition: pns_solid.cpp:95
virtual int AnchorCount() const override
Definition: pns_solid.cpp:100
HOLE * m_hole
Definition: pns_solid.h:144
static bool ClassOf(const ITEM *aItem)
Definition: pns_solid.h:85
EDA_ANGLE GetOrientation() const
Definition: pns_solid.h:120
void SetAnchorPoints(const std::vector< VECTOR2I > &aPoints)
Definition: pns_solid.h:115
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
An abstract shape on 2D plane.
Definition: shape.h:126
virtual SHAPE * Clone() const
Return a dynamically allocated copy of the shape.
Definition: shape.h:148
Push and Shove diff pair dimensions (gap) settings dialog.