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 return true;
61
62 default:
63 return false;
64 }
65 }
66
68 bool IsConnected() const override
69 {
70 return true;
71 }
72
77 {
78 return m_netinfo;
79 }
80
84 void SetNet( NETINFO_ITEM* aNetInfo )
85 {
86 m_netinfo = aNetInfo;
87 }
88
92 int GetNetCode() const;
93
105 bool SetNetCode( int aNetCode, bool aNoAssert );
106
107 void SetNetCode( int aNetCode )
108 {
109 SetNetCode( aNetCode, false );
110 }
111
115 wxString GetNetname() const;
116
121 wxString GetNetnameMsg() const;
122
126 wxString GetShortNetname() const;
127
131 wxString GetUnescapedShortNetname() const;
132
140 virtual int GetOwnClearance( PCB_LAYER_ID aLayer, wxString* aSource = nullptr ) const;
141
148 virtual int GetLocalClearanceOverrides( wxString* aSource ) const { return 0; }
149
157 virtual int GetLocalClearance( wxString* aSource ) const { return 0; }
158
165 virtual NETCLASS* GetEffectiveNetClass() const;
166
170 wxString GetNetClassName() const;
171
172 void SetLocalRatsnestVisible( bool aVisible ) { m_localRatsnestVisible = aVisible; }
174
177
178 void SetTeardropsEnabled( bool aEnable ) { m_teardropParams.m_Enabled = aEnable; }
180
183
184 void SetTeardropMaxLength( int aMaxLength ) { m_teardropParams.m_TdMaxLen = aMaxLength; }
186
189
190 void SetTeardropMaxWidth( int aMaxWidth ) { m_teardropParams.m_TdMaxWidth = aMaxWidth; }
192
193 void SetTeardropCurvePts( int aPointCount ) { m_teardropParams.m_CurveSegCount = aPointCount; }
195
198
201
204
205protected:
208
212
213private:
215
216};
217
218#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:71
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:59
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:59
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:78
@ PCB_VIA_T
class PCB_VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:93
@ PCB_ZONE_T
class ZONE, a copper pour area
Definition: typeinfo.h:103
@ 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:94
@ PCB_TRACE_T
class PCB_TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:92