KiCad PCB EDA Suite
Loading...
Searching...
No Matches
board_connected_item.h
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2012 Jean-Pierre Charras, [email protected]
5 * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <[email protected]>
6 * Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors.
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, you may find one here:
20 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21 * or you may search the http://www.gnu.org website for the version 2 license,
22 * or you may write to the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24 */
25
26#ifndef BOARD_CONNECTED_ITEM_H
27#define BOARD_CONNECTED_ITEM_H
28
29#include <board_item.h>
31
32class NETCLASS;
33class NETINFO_ITEM;
34class PAD;
35
41{
42public:
43 BOARD_CONNECTED_ITEM( BOARD_ITEM* aParent, KICAD_T idtype );
44
45 // Do not create a copy constructor & operator=.
46 // The ones generated by the compiler are adequate.
47
48 static inline bool ClassOf( const EDA_ITEM* aItem )
49 {
50 if( aItem == nullptr )
51 return false;
52
53 switch( aItem->Type() )
54 {
55 case PCB_PAD_T:
56 case PCB_TRACE_T:
57 case PCB_ARC_T:
58 case PCB_VIA_T:
59 case PCB_ZONE_T:
60 case PCB_SHAPE_T:
61 return true;
62
63 default:
64 return false;
65 }
66 }
67
69 bool IsConnected() const override
70 {
71 return true;
72 }
73
78 {
79 return m_netinfo;
80 }
81
85 void SetNet( NETINFO_ITEM* aNetInfo )
86 {
87 m_netinfo = aNetInfo;
88 }
89
93 int GetNetCode() const;
94
106 bool SetNetCode( int aNetCode, bool aNoAssert );
107
108 void SetNetCode( int aNetCode )
109 {
110 SetNetCode( aNetCode, false );
111 }
112
116 wxString GetNetname() const;
117
122 wxString GetNetnameMsg() const;
123
127 wxString GetShortNetname() const;
128
132 wxString GetUnescapedShortNetname() const;
133
141 virtual int GetOwnClearance( PCB_LAYER_ID aLayer, wxString* aSource = nullptr ) const;
142
149 virtual int GetLocalClearanceOverrides( wxString* aSource ) const { return 0; }
150
158 virtual int GetLocalClearance( wxString* aSource ) const { return 0; }
159
166 virtual NETCLASS* GetEffectiveNetClass() const;
167
171 wxString GetNetClassName() const;
172
173 void SetLocalRatsnestVisible( bool aVisible ) { m_localRatsnestVisible = aVisible; }
175
178
179 void SetTeardropsEnabled( bool aEnable ) { m_teardropParams.m_Enabled = aEnable; }
181
184
185 void SetTeardropMaxLength( int aMaxLength ) { m_teardropParams.m_TdMaxLen = aMaxLength; }
187
190
191 void SetTeardropMaxWidth( int aMaxWidth ) { m_teardropParams.m_TdMaxWidth = aMaxWidth; }
193
194 void SetTeardropCurvePts( int aPointCount ) { m_teardropParams.m_CurveSegCount = aPointCount; }
196
199
202
205
206protected:
209
213
214private:
216
217};
218
219#endif // BOARD_CONNECTED_ITEM_H
A base class derived from BOARD_ITEM for items that can be connected and have a net,...
wxString GetNetnameMsg() const
bool GetTeardropPreferZoneConnections() const
virtual NETCLASS * GetEffectiveNetClass() const
Return the NETCLASS for this item.
double GetTeardropBestLengthRatio() const
const TEARDROP_PARAMETERS & GetTeardropParams() const
bool SetNetCode(int aNetCode, bool aNoAssert)
Set net using a net code.
void SetTeardropBestWidthRatio(double aRatio)
void SetTeardropMaxTrackWidth(double aRatio)
bool GetLocalRatsnestVisible() const
void SetLocalRatsnestVisible(bool aVisible)
void SetNetCode(int aNetCode)
virtual int GetLocalClearanceOverrides(wxString *aSource) const
Return any local clearance overrides set in the "classic" (ie: pre-rule) system.
double GetTeardropMaxTrackWidth() const
static bool ClassOf(const EDA_ITEM *aItem)
Returns information if the object is derived from BOARD_CONNECTED_ITEM.
TEARDROP_PARAMETERS m_teardropParams
Not all BOARD_CONNECTED_ITEMs support teardrops, but we want those that do to share a single section ...
NETINFO_ITEM * GetNet() const
Return #NET_INFO object for a given item.
void SetTeardropAllowSpanTwoTracks(bool aAllow)
void SetNet(NETINFO_ITEM *aNetInfo)
Set a NET_INFO object for the item.
bool IsConnected() const override
Returns information if the object is derived from BOARD_CONNECTED_ITEM.
double GetTeardropBestWidthRatio() const
wxString GetNetClassName() const
Returns the name of the effective netclass.
NETINFO_ITEM * m_netinfo
Store all information about the net that item belongs to.
virtual int GetOwnClearance(PCB_LAYER_ID aLayer, wxString *aSource=nullptr) const
Return an item's "own" clearance in internal units.
void SetTeardropCurvePts(int aPointCount)
void SetTeardropMaxWidth(int aMaxWidth)
wxString GetShortNetname() const
void SetTeardropPreferZoneConnections(bool aPrefer)
void SetTeardropBestLengthRatio(double aRatio)
void SetTeardropMaxLength(int aMaxLength)
bool GetTeardropAllowSpanTwoTracks() const
TEARDROP_PARAMETERS & GetTeardropParams()
wxString GetUnescapedShortNetname() const
virtual int GetLocalClearance(wxString *aSource) const
Return any local clearances set in the "classic" (ie: pre-rule) system.
void SetTeardropsEnabled(bool aEnable)
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:77
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:85
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:97
A collection of nets and the parameters used to route or test these nets.
Definition: netclass.h:47
Handle the data for a net.
Definition: netinfo.h:67
Definition: pad.h:58
TEARDROP_PARAMETARS is a helper class to handle parameters needed to build teardrops for a board thes...
int m_CurveSegCount
number of segments to build the curved sides of a teardrop area must be > 2.
double m_BestWidthRatio
The height of a teardrop as ratio between height and size of pad/via.
int m_TdMaxLen
max allowed length for teardrops in IU. <= 0 to disable
bool m_AllowUseTwoTracks
True to create teardrops using 2 track segments if the first in too small.
int m_TdMaxWidth
max allowed height for teardrops in IU. <= 0 to disable
double m_BestLengthRatio
The length of a teardrop as ratio between length and size of pad/via.
double m_WidthtoSizeFilterRatio
The ratio (H/D) between the via/pad size and the track width max value to create a teardrop 1....
bool m_TdOnPadsInZones
A filter to exclude pads inside zone fills.
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:60
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:78
@ PCB_SHAPE_T
class PCB_SHAPE, a segment not on copper layers
Definition: typeinfo.h:88
@ PCB_VIA_T
class PCB_VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:94
@ PCB_ZONE_T
class ZONE, a copper pour area
Definition: typeinfo.h:104
@ PCB_PAD_T
class PAD, a pad in a footprint
Definition: typeinfo.h:87
@ PCB_ARC_T
class PCB_ARC, an arc track segment on a copper layer
Definition: typeinfo.h:95
@ PCB_TRACE_T
class PCB_TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:93