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 The 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, see <https://www.gnu.org/licenses/>.
20 */
21
22#ifndef BOARD_CONNECTED_ITEM_H
23#define BOARD_CONNECTED_ITEM_H
24
25#include <board_item.h>
27
28class NETCLASS;
29class NETINFO_ITEM;
30class PAD;
31
33{
34class Net;
35}
36
42{
43public:
44 BOARD_CONNECTED_ITEM( BOARD_ITEM* aParent, KICAD_T idtype );
45
46 void SetLayer( PCB_LAYER_ID aLayer ) override;
47 PCB_LAYER_ID GetLayer() const override { return BOARD_ITEM::GetLayer(); }
48
49 // Do not create a copy constructor & operator=.
50 // The ones generated by the compiler are adequate.
51
52 static inline bool ClassOf( const EDA_ITEM* aItem )
53 {
54 if( aItem == nullptr )
55 return false;
56
57 switch( aItem->Type() )
58 {
59 case PCB_PAD_T:
60 case PCB_TRACE_T:
61 case PCB_ARC_T:
62 case PCB_VIA_T:
63 case PCB_ZONE_T:
64 case PCB_SHAPE_T:
65 return true;
66
67 default:
68 return false;
69 }
70 }
71
73 bool IsConnected() const override
74 {
75 return true;
76 }
77
82 {
83 return m_netinfo;
84 }
85
93 virtual void SetNet( NETINFO_ITEM* aNetInfo )
94 {
95 m_netinfo = aNetInfo;
96 }
97
102 void UnpackNet( const kiapi::board::types::Net& aProto );
103 void PackNet( kiapi::board::types::Net* aProto ) const;
104
108 int GetNetCode() const;
109
126 virtual bool SetNetCode( int aNetCode, bool aNoAssert );
127
128 void SetNetCode( int aNetCode )
129 {
130 SetNetCode( aNetCode, false );
131 }
132
136 wxString GetNetname() const;
137
142 wxString GetNetnameMsg() const;
143
147 const wxString& GetShortNetname() const;
148
152 const wxString& GetDisplayNetname() const;
153
161 virtual int GetOwnClearance( PCB_LAYER_ID aLayer, wxString* aSource = nullptr ) const;
162
169 virtual std::optional<int> GetClearanceOverrides( wxString* aSource ) const
170 {
171 return std::optional<int>();
172 }
173
179 virtual std::optional<int> GetLocalClearance() const
180 {
181 return std::optional<int>();
182 }
183
190 virtual std::optional<int> GetLocalClearance( wxString* aSource ) const
191 {
192 return std::optional<int>();
193 }
194
201 virtual NETCLASS* GetEffectiveNetClass() const;
202
206 wxString GetNetClassName() const;
207
208 void SetLocalRatsnestVisible( bool aVisible ) { m_localRatsnestVisible = aVisible; }
210
213
214 void SetTeardropsEnabled( bool aEnable ) { m_teardropParams.m_Enabled = aEnable; }
215 bool GetTeardropsEnabled() const { return m_teardropParams.m_Enabled; }
216
217 void SetTeardropBestLengthRatio( double aRatio ) { m_teardropParams.m_BestLengthRatio = aRatio; }
218 double GetTeardropBestLengthRatio() const { return m_teardropParams.m_BestLengthRatio; }
219
220 void SetTeardropMaxLength( int aMaxLength ) { m_teardropParams.m_TdMaxLen = aMaxLength; }
221 int GetTeardropMaxLength() const { return m_teardropParams.m_TdMaxLen; }
222
223 void SetTeardropBestWidthRatio( double aRatio ) { m_teardropParams.m_BestWidthRatio = aRatio; }
224 double GetTeardropBestWidthRatio() const { return m_teardropParams.m_BestWidthRatio; }
225
226 void SetTeardropMaxWidth( int aMaxWidth ) { m_teardropParams.m_TdMaxWidth = aMaxWidth; }
227 int GetTeardropMaxWidth() const { return m_teardropParams.m_TdMaxWidth; }
228
229 void SetTeardropCurved( bool aCurve ) { m_teardropParams.m_CurvedEdges = aCurve; }
230 bool GetTeardropCurved() const { return m_teardropParams.m_CurvedEdges; }
231
232 void SetTeardropPreferZoneConnections( bool aPrefer ) { m_teardropParams.m_TdOnPadsInZones = !aPrefer; }
233 bool GetTeardropPreferZoneConnections() const { return !m_teardropParams.m_TdOnPadsInZones; }
234
235 void SetTeardropAllowSpanTwoTracks( bool aAllow ) { m_teardropParams.m_AllowUseTwoTracks = aAllow; }
236 bool GetTeardropAllowSpanTwoTracks() const { return m_teardropParams.m_AllowUseTwoTracks; }
237
238 void SetTeardropMaxTrackWidth( double aRatio ) { m_teardropParams.m_WidthtoSizeFilterRatio = aRatio; }
239 double GetTeardropMaxTrackWidth() const { return m_teardropParams.m_WidthtoSizeFilterRatio; }
240
241protected:
244
248
249private:
251
252};
253
254#endif // BOARD_CONNECTED_ITEM_H
virtual std::optional< int > GetClearanceOverrides(wxString *aSource) const
Return any clearance overrides set in the "classic" (ie: pre-rule) system.
bool GetTeardropPreferZoneConnections() const
virtual NETCLASS * GetEffectiveNetClass() const
Return the NETCLASS for this item.
double GetTeardropBestLengthRatio() const
const TEARDROP_PARAMETERS & GetTeardropParams() const
virtual bool SetNetCode(int aNetCode, bool aNoAssert)
Set net using a net code.
virtual std::optional< int > GetLocalClearance() const
Return any local clearances set in the "classic" (ie: pre-rule) system.
void SetTeardropBestWidthRatio(double aRatio)
void SetTeardropMaxTrackWidth(double aRatio)
PCB_LAYER_ID GetLayer() const override
Return the primary layer this item is on.
BOARD_CONNECTED_ITEM(BOARD_ITEM *aParent, KICAD_T idtype)
void SetLocalRatsnestVisible(bool aVisible)
void SetNetCode(int aNetCode)
void PackNet(kiapi::board::types::Net *aProto) const
double GetTeardropMaxTrackWidth() const
virtual void SetNet(NETINFO_ITEM *aNetInfo)
Set a NET_INFO object for the item.
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 ...
void SetLayer(PCB_LAYER_ID aLayer) override
Set the layer this item is on.
NETINFO_ITEM * GetNet() const
Return #NET_INFO object for a given item.
void SetTeardropAllowSpanTwoTracks(bool aAllow)
const wxString & GetDisplayNetname() const
const wxString & GetShortNetname() const
virtual std::optional< int > GetLocalClearance(wxString *aSource) const
Return any local clearances set in the "classic" (ie: pre-rule) system.
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.
void SetTeardropCurved(bool aCurve)
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 SetTeardropMaxWidth(int aMaxWidth)
void SetTeardropPreferZoneConnections(bool aPrefer)
void SetTeardropBestLengthRatio(double aRatio)
void SetTeardropMaxLength(int aMaxLength)
void UnpackNet(const kiapi::board::types::Net &aProto)
Assigns a net to this item from an API message.
bool GetTeardropAllowSpanTwoTracks() const
TEARDROP_PARAMETERS & GetTeardropParams()
void SetTeardropsEnabled(bool aEnable)
BOARD_ITEM(BOARD_ITEM *aParent, KICAD_T idtype, PCB_LAYER_ID aLayer=F_Cu)
Definition board_item.h:83
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
Definition board_item.h:265
KICAD_T Type() const
Returns the type of object.
Definition eda_item.h:108
EDA_ITEM(EDA_ITEM *parent, KICAD_T idType, bool isSCH_ITEM=false, bool isBOARD_ITEM=false)
Definition eda_item.cpp:37
A collection of nets and the parameters used to route or test these nets.
Definition netclass.h:38
Handle the data for a net.
Definition netinfo.h:46
Definition pad.h:61
TEARDROP_PARAMETARS is a helper class to handle parameters needed to build teardrops for a board thes...
PCB_LAYER_ID
A quick note on layer IDs:
Definition layer_ids.h:56
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition typeinfo.h:71
@ PCB_SHAPE_T
class PCB_SHAPE, a segment not on copper layers
Definition typeinfo.h:81
@ PCB_VIA_T
class PCB_VIA, a via (like a track segment on a copper layer)
Definition typeinfo.h:90
@ PCB_ZONE_T
class ZONE, a copper pour area
Definition typeinfo.h:101
@ PCB_PAD_T
class PAD, a pad in a footprint
Definition typeinfo.h:80
@ PCB_ARC_T
class PCB_ARC, an arc track segment on a copper layer
Definition typeinfo.h:91
@ PCB_TRACE_T
class PCB_TRACK, a track segment (segment on a copper layer)
Definition typeinfo.h:89