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, 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
37{
38class Net;
39}
40
46{
47public:
48 BOARD_CONNECTED_ITEM( BOARD_ITEM* aParent, KICAD_T idtype );
49
50 // Do not create a copy constructor & operator=.
51 // The ones generated by the compiler are adequate.
52
53 static inline bool ClassOf( const EDA_ITEM* aItem )
54 {
55 if( aItem == nullptr )
56 return false;
57
58 switch( aItem->Type() )
59 {
60 case PCB_PAD_T:
61 case PCB_TRACE_T:
62 case PCB_ARC_T:
63 case PCB_VIA_T:
64 case PCB_ZONE_T:
65 case PCB_SHAPE_T:
66 return true;
67
68 default:
69 return false;
70 }
71 }
72
74 bool IsConnected() const override
75 {
76 return true;
77 }
78
83 {
84 return m_netinfo;
85 }
86
90 void SetNet( NETINFO_ITEM* aNetInfo )
91 {
92 m_netinfo = aNetInfo;
93 }
94
99 void UnpackNet( const kiapi::board::types::Net& aProto );
100 void PackNet( kiapi::board::types::Net* aProto ) const;
101
105 int GetNetCode() const;
106
118 bool SetNetCode( int aNetCode, bool aNoAssert );
119
120 void SetNetCode( int aNetCode )
121 {
122 SetNetCode( aNetCode, false );
123 }
124
128 wxString GetNetname() const;
129
134 wxString GetNetnameMsg() const;
135
139 const wxString& GetShortNetname() const;
140
144 const wxString& GetDisplayNetname() const;
145
153 virtual int GetOwnClearance( PCB_LAYER_ID aLayer, wxString* aSource = nullptr ) const;
154
161 virtual std::optional<int> GetClearanceOverrides( wxString* aSource ) const
162 {
163 return std::optional<int>();
164 }
165
171 virtual std::optional<int> GetLocalClearance() const
172 {
173 return std::optional<int>();
174 }
175
182 virtual std::optional<int> GetLocalClearance( wxString* aSource ) const
183 {
184 return std::optional<int>();
185 }
186
193 virtual NETCLASS* GetEffectiveNetClass() const;
194
198 wxString GetNetClassName() const;
199
200 void SetLocalRatsnestVisible( bool aVisible ) { m_localRatsnestVisible = aVisible; }
202
205
206 void SetTeardropsEnabled( bool aEnable ) { m_teardropParams.m_Enabled = aEnable; }
208
211
212 void SetTeardropMaxLength( int aMaxLength ) { m_teardropParams.m_TdMaxLen = aMaxLength; }
214
217
218 void SetTeardropMaxWidth( int aMaxWidth ) { m_teardropParams.m_TdMaxWidth = aMaxWidth; }
220
221 void SetTeardropCurved( bool aCurve ) { m_teardropParams.m_CurvedEdges = aCurve; }
223
226
229
232
233protected:
236
240
241private:
243
244};
245
246#endif // BOARD_CONNECTED_ITEM_H
A base class derived from BOARD_ITEM for items that can be connected and have a net,...
virtual std::optional< int > GetClearanceOverrides(wxString *aSource) const
Return any clearance overrides set in the "classic" (ie: pre-rule) system.
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.
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)
bool GetLocalRatsnestVisible() const
void SetLocalRatsnestVisible(bool aVisible)
void SetNetCode(int aNetCode)
void PackNet(kiapi::board::types::Net *aProto) const
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)
const wxString & GetDisplayNetname() const
const wxString & GetShortNetname() const
void SetNet(NETINFO_ITEM *aNetInfo)
Set a NET_INFO object for the item.
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)
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:79
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:98
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:110
A collection of nets and the parameters used to route or test these nets.
Definition: netclass.h:45
Handle the data for a net.
Definition: netinfo.h:56
Definition: pad.h:54
TEARDROP_PARAMETARS is a helper class to handle parameters needed to build teardrops for a board thes...
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.
bool m_Enabled
Flag to enable teardrops.
bool m_CurvedEdges
True if the teardrop should be curved.
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:97
@ PCB_ZONE_T
class ZONE, a copper pour area
Definition: typeinfo.h:107
@ 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:98
@ PCB_TRACE_T
class PCB_TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:96