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-2012 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 
45 {
46 public:
47  BOARD_CONNECTED_ITEM( BOARD_ITEM* aParent, KICAD_T idtype );
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 == NULL )
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  return true;
65 
66  default:
67  return false;
68  }
69  }
70 
72  bool IsConnected() const override
73  {
74  return true;
75  }
76 
82  {
83  return m_netinfo;
84  }
85 
90  void SetNet( NETINFO_ITEM* aNetInfo )
91  {
92  m_netinfo = aNetInfo;
93  }
94 
99  int GetNetCode() const
100  {
101  return m_netinfo ? m_netinfo->GetNet() : -1;
102  }
103 
113  bool SetNetCode( int aNetCode, bool aNoAssert );
114 
115  void SetNetCode( int aNetCode )
116  {
117  SetNetCode( aNetCode, false );
118  }
119 
124  wxString GetNetname() const
125  {
126  return m_netinfo ? m_netinfo->GetNetname() : wxString();
127  }
128 
134  wxString GetNetnameMsg() const;
135 
140  wxString GetShortNetname() const
141  {
142  return m_netinfo->GetShortNetname();
143  }
144 
152  virtual int GetOwnClearance( PCB_LAYER_ID aLayer, wxString* aSource = nullptr ) const;
153 
160  virtual int GetLocalClearanceOverrides( wxString* aSource ) const { return 0; }
161 
169  virtual int GetLocalClearance( wxString* aSource ) const { return 0; }
170 
178  virtual NETCLASS* GetNetClass() const;
179 
187  virtual NETCLASS* GetEffectiveNetclass() const;
188 
197  virtual wxString GetNetClassName() const;
198 
199  void SetLocalRatsnestVisible( bool aVisible )
200  {
201  m_localRatsnestVisible = aVisible;
202  }
203 
205  {
206  return m_localRatsnestVisible;
207  }
208 
209 protected:
212 
213 private:
214 
216 };
217 
218 #endif // BOARD_CONNECTED_ITEM_H
int GetNetCode() const
Function GetNetCode.
BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class,...
Definition: board_item.h:86
NETINFO_ITEM * GetNet() const
Function GetNet Returns NET_INFO object for a given item.
virtual NETCLASS * GetNetClass() const
Function GetNetClassPtr returns the NETCLASS for this item.
BOARD_CONNECTED_ITEM(BOARD_ITEM *aParent, KICAD_T idtype)
bool SetNetCode(int aNetCode, bool aNoAssert)
Sets net using a net code.
class ARC, an arc track segment on a copper layer
Definition: typeinfo.h:98
bool GetLocalRatsnestVisible() const
wxString GetNetname() const
Function GetNetname.
class PAD, a pad in a footprint
Definition: typeinfo.h:90
void SetLocalRatsnestVisible(bool aVisible)
virtual int GetLocalClearanceOverrides(wxString *aSource) const
Function GetLocalClearanceOverrides returns any local clearance overrides set in the "classic" (ie: p...
bool IsConnected() const override
BOARD_CONNECTED_ITEM is a base class derived from BOARD_ITEM for items that can be connected and have...
const wxString & GetShortNetname() const
Function GetShortNetname.
Definition: netinfo.h:237
virtual wxString GetNetClassName() const
Function GetNetClassName returns a pointer to the netclass of the zone.
KICAD_T
Enum KICAD_T is the set of class identification values, stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:78
class TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:96
PCB_LAYER_ID
A quick note on layer IDs:
wxString GetShortNetname() const
Function GetShortNetname.
#define NULL
NETCLASS handles a collection of nets and the parameters used to route or test these nets.
Definition: netclass.h:49
const wxString & GetNetname() const
Function GetNetname.
Definition: netinfo.h:231
class ZONE, a copper pour area
Definition: typeinfo.h:106
static bool ClassOf(const EDA_ITEM *aItem)
wxString GetNetnameMsg() const
Function GetNetnameMsg.
NETINFO_ITEM handles the data for a net.
Definition: netinfo.h:65
void SetNet(NETINFO_ITEM *aNetInfo)
Function SetNet Sets a NET_INFO object for the item.
int GetNet() const
Function GetNet.
Definition: netinfo.h:223
NETINFO_ITEM * m_netinfo
Stores all informations about the net that item belongs to.
EDA_ITEM is a base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:148
virtual int GetOwnClearance(PCB_LAYER_ID aLayer, wxString *aSource=nullptr) const
Function GetClearance returns an item's "own" clearance in internal units.
class VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:97
virtual NETCLASS * GetEffectiveNetclass() const
Function GetEffectiveNetclass returns the NETCLASS for this item, or the default netclass if none is ...
Definition: pad.h:59
virtual int GetLocalClearance(wxString *aSource) const
Function GetLocalClearance returns any local clearances set in the "classic" (ie: pre-rule) system.
Definition: track.h:83
KICAD_T Type() const
Function Type()
Definition: eda_item.h:181
void SetNetCode(int aNetCode)