KiCad PCB EDA Suite
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, jean-pierre.charras@ujf-grenoble.fr
5  * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
6  * Copyright (C) 1992-2021 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>
30 #include <netinfo.h>
31 #include <reporter.h>
32 
33 class NETCLASS;
34 class TRACK;
35 class PAD;
36 
42 {
43 public:
44  BOARD_CONNECTED_ITEM( BOARD_ITEM* aParent, KICAD_T idtype );
45 
46  // Do not create a copy constructor & operator=.
47  // The ones generated by the compiler are adequate.
48 
49  static inline bool ClassOf( const EDA_ITEM* aItem )
50  {
51  if( aItem == NULL )
52  return false;
53 
54  switch( aItem->Type() )
55  {
56  case PCB_PAD_T:
57  case PCB_TRACE_T:
58  case PCB_ARC_T:
59  case PCB_VIA_T:
60  case PCB_ZONE_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  {
95  return m_netinfo ? m_netinfo->GetNetCode() : -1;
96  }
97 
109  bool SetNetCode( int aNetCode, bool aNoAssert );
110 
111  void SetNetCode( int aNetCode )
112  {
113  SetNetCode( aNetCode, false );
114  }
115 
119  wxString GetNetname() const
120  {
121  return m_netinfo ? m_netinfo->GetNetname() : wxString();
122  }
123 
128  wxString GetNetnameMsg() const;
129 
133  wxString GetShortNetname() const
134  {
135  return m_netinfo->GetShortNetname();
136  }
137 
145  virtual int GetOwnClearance( PCB_LAYER_ID aLayer, wxString* aSource = nullptr ) const;
146 
153  virtual int GetLocalClearanceOverrides( wxString* aSource ) const { return 0; }
154 
162  virtual int GetLocalClearance( wxString* aSource ) const { return 0; }
163 
170  virtual NETCLASS* GetNetClass() const;
171 
178  virtual NETCLASS* GetEffectiveNetclass() const;
179 
188  virtual wxString GetNetClassName() const;
189 
190  void SetLocalRatsnestVisible( bool aVisible )
191  {
192  m_localRatsnestVisible = aVisible;
193  }
194 
196  {
197  return m_localRatsnestVisible;
198  }
199 
200 protected:
203 
204 private:
206 };
207 
208 #endif // BOARD_CONNECTED_ITEM_H
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:82
NETINFO_ITEM * GetNet() const
Return #NET_INFO object for a given item.
virtual NETCLASS * GetNetClass() const
Return the NETCLASS for this item.
BOARD_CONNECTED_ITEM(BOARD_ITEM *aParent, KICAD_T idtype)
bool SetNetCode(int aNetCode, bool aNoAssert)
Set net using a net code.
class ARC, an arc track segment on a copper layer
Definition: typeinfo.h:97
bool GetLocalRatsnestVisible() const
wxString GetNetname() const
class PAD, a pad in a footprint
Definition: typeinfo.h:89
void SetLocalRatsnestVisible(bool aVisible)
virtual int GetLocalClearanceOverrides(wxString *aSource) const
Return any local clearance overrides set in the "classic" (ie: pre-rule) system.
bool IsConnected() const override
Returns information if the object is derived from BOARD_CONNECTED_ITEM.
A base class derived from BOARD_ITEM for items that can be connected and have a net,...
const wxString & GetShortNetname() const
Definition: netinfo.h:124
virtual wxString GetNetClassName() const
Returns the netclass of the zone.
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:77
class TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:95
PCB_LAYER_ID
A quick note on layer IDs:
wxString GetShortNetname() const
#define NULL
A collection of nets and the parameters used to route or test these nets.
Definition: netclass.h:46
const wxString & GetNetname() const
Definition: netinfo.h:119
class ZONE, a copper pour area
Definition: typeinfo.h:105
static bool ClassOf(const EDA_ITEM *aItem)
Returns information if the object is derived from BOARD_CONNECTED_ITEM.
wxString GetNetnameMsg() const
Handle the data for a net.
Definition: netinfo.h:64
void SetNet(NETINFO_ITEM *aNetInfo)
Set a NET_INFO object for the item.
NETINFO_ITEM * m_netinfo
Store all information about the net that item belongs to.
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:149
virtual int GetOwnClearance(PCB_LAYER_ID aLayer, wxString *aSource=nullptr) const
Return an item's "own" clearance in internal units.
class VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:96
virtual NETCLASS * GetEffectiveNetclass() const
Return the NETCLASS for this item, or the default netclass if none is defined.
Definition: pad.h:60
virtual int GetLocalClearance(wxString *aSource) const
Return any local clearances set in the "classic" (ie: pre-rule) system.
Definition: track.h:83
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:162
int GetNetCode() const
Definition: netinfo.h:113
void SetNetCode(int aNetCode)