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 The 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#include "pns_hole.h"
33
34namespace PNS {
35
36class SOLID : public ITEM
37{
38public:
40 ITEM( SOLID_T ),
41 m_shape( nullptr ),
42 m_padToDie(0),
44 m_hole( nullptr )
45 {
46 m_movable = false;
47 }
48
50 {
51 if( m_hole && m_hole->BelongsTo( this ) )
52 delete m_hole;
53
54 delete m_shape;
55 }
56
57 SOLID( const SOLID& aSolid ) :
58 ITEM( aSolid ),
59 m_shape( nullptr ),
60 m_hole( nullptr )
61 {
62 if( aSolid.m_shape )
63 SetShape( aSolid.m_shape->Clone() );
64
65 if( aSolid.m_hole )
66 SetHole( aSolid.m_hole->Clone() );
67
68 m_pos = aSolid.m_pos;
69 m_padToDie = aSolid.m_padToDie;
73 }
74
75 SOLID& operator=( const SOLID& aB )
76 {
77 m_parent = aB.m_parent;
79
80 if( aB.m_shape )
81 SetShape( aB.m_shape->Clone() );
82
83 if( aB.m_hole )
84 SetHole( new PNS::HOLE( aB.m_hole->Shape( -1 )->Clone() ) );
85
86 m_pos = aB.m_pos;
91
93 m_marker = aB.m_marker;
94 m_rank = aB.m_rank;
96
97 return *this;
98 }
99
100 static inline bool ClassOf( const ITEM* aItem )
101 {
102 return aItem && SOLID_T == aItem->Kind();
103 }
104
105 ITEM* Clone() const override;
106
107 const SHAPE* Shape( int aLayer ) const override { return m_shape; }
108
109
110 const SHAPE_LINE_CHAIN Hull( int aClearance = 0, int aWalkaroundThickness = 0,
111 int aLayer = -1 ) const override;
112
113 void SetShape( SHAPE* shape )
114 {
115 delete m_shape;
116 m_shape = shape;
117 }
118
119 const VECTOR2I& Pos() const { return m_pos; }
120 void SetPos( const VECTOR2I& aCenter );
121
122 int GetPadToDie() const { return m_padToDie; }
123 void SetPadToDie( const int aLen ) { m_padToDie = aLen; }
124
125 int GetPadToDieDelay() const { return m_padToDieDelay; }
126 void SetPadToDieDelay( const int aDelay ) { m_padToDieDelay = aDelay; }
127
128 virtual VECTOR2I Anchor( int aN ) const override;
129
130 virtual int AnchorCount() const override;
131
132 const std::vector<VECTOR2I>& AnchorPoints() const { return m_anchorPoints; }
133 void SetAnchorPoints( const std::vector<VECTOR2I>& aPoints ) { m_anchorPoints = aPoints; }
134
135 VECTOR2I Offset() const { return m_offset; }
136 void SetOffset( const VECTOR2I& aOffset ) { m_offset = aOffset; }
137
139 void SetOrientation( const EDA_ANGLE& aOrientation ) { m_orientation = aOrientation; }
140
141 virtual void SetHole( HOLE* aHole ) override
142 {
143 if( m_hole && m_hole->BelongsTo( this ) )
144 delete m_hole;
145
146 m_hole = aHole;
147 m_hole->SetParentPadVia( this );
148 m_hole->SetOwner( this );
149 m_hole->SetLayers( m_layers ); // fixme: backdrill vias can have hole layer set different
150 // than copper layer set
151 }
152
153 virtual bool HasHole() const override { return m_hole != nullptr; }
154 virtual HOLE *Hole() const override { return m_hole; }
155
156private:
164 std::vector<VECTOR2I> m_anchorPoints;
165};
166
167}
168
169#endif
virtual HOLE * Clone() const override
Return a deep copy of the item.
Definition pns_hole.cpp:41
const SHAPE * Shape(int aLayer) const override
Return the geometrical shape of the item.
Definition pns_hole.h:69
Base class for PNS router board items.
Definition pns_item.h:98
BOARD_ITEM * m_sourceItem
Definition pns_item.h:319
bool m_movable
Definition pns_item.h:325
ITEM(PnsKind aKind)
Definition pns_item.h:116
PNS_LAYER_RANGE m_layers
Definition pns_item.h:323
bool m_routable
Definition pns_item.h:329
PnsKind Kind() const
Return the type (kind) of the item.
Definition pns_item.h:173
int m_marker
Definition pns_item.h:327
BOARD_ITEM * m_parent
Definition pns_item.h:317
int m_rank
Definition pns_item.h:328
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:122
virtual bool HasHole() const override
Definition pns_solid.h:153
void SetPadToDie(const int aLen)
Definition pns_solid.h:123
virtual HOLE * Hole() const override
Definition pns_solid.h:154
const std::vector< VECTOR2I > & AnchorPoints() const
Definition pns_solid.h:132
VECTOR2I m_pos
Definition pns_solid.h:157
SOLID(const SOLID &aSolid)
Definition pns_solid.h:57
int GetPadToDieDelay() const
Definition pns_solid.h:125
void SetPos(const VECTOR2I &aCenter)
Definition pns_solid.cpp:81
SHAPE * m_shape
Definition pns_solid.h:158
int m_padToDie
Definition pns_solid.h:160
int m_padToDieDelay
Definition pns_solid.h:161
void SetPadToDieDelay(const int aDelay)
Definition pns_solid.h:126
VECTOR2I Offset() const
Definition pns_solid.h:135
const VECTOR2I & Pos() const
Definition pns_solid.h:119
VECTOR2I m_offset
Definition pns_solid.h:159
void SetOffset(const VECTOR2I &aOffset)
Definition pns_solid.h:136
EDA_ANGLE m_orientation
Definition pns_solid.h:162
void SetShape(SHAPE *shape)
Definition pns_solid.h:113
virtual void SetHole(HOLE *aHole) override
Definition pns_solid.h:141
SOLID & operator=(const SOLID &aB)
Definition pns_solid.h:75
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:164
void SetOrientation(const EDA_ANGLE &aOrientation)
Definition pns_solid.h:139
virtual VECTOR2I Anchor(int aN) const override
Definition pns_solid.cpp:95
virtual int AnchorCount() const override
HOLE * m_hole
Definition pns_solid.h:163
static bool ClassOf(const ITEM *aItem)
Definition pns_solid.h:100
EDA_ANGLE GetOrientation() const
Definition pns_solid.h:138
const SHAPE * Shape(int aLayer) const override
Return the geometrical shape of the item.
Definition pns_solid.h:107
void SetAnchorPoints(const std::vector< VECTOR2I > &aPoints)
Definition pns_solid.h:133
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.
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:695