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 
31 class NETCLASS;
32 class NETINFO_ITEM;
33 class PAD;
34 
40 {
41 public:
42  BOARD_CONNECTED_ITEM( BOARD_ITEM* aParent, KICAD_T idtype );
43 
44  // Do not create a copy constructor & operator=.
45  // The ones generated by the compiler are adequate.
46 
47  static inline bool ClassOf( const EDA_ITEM* aItem )
48  {
49  if( aItem == nullptr )
50  return false;
51 
52  switch( aItem->Type() )
53  {
54  case PCB_PAD_T:
55  case PCB_TRACE_T:
56  case PCB_ARC_T:
57  case PCB_VIA_T:
58  case PCB_ZONE_T:
59  return true;
60 
61  default:
62  return false;
63  }
64  }
65 
67  bool IsConnected() const override
68  {
69  return true;
70  }
71 
76  {
77  return m_netinfo;
78  }
79 
83  void SetNet( NETINFO_ITEM* aNetInfo )
84  {
85  m_netinfo = aNetInfo;
86  }
87 
91  int GetNetCode() const;
92 
104  bool SetNetCode( int aNetCode, bool aNoAssert );
105 
106  void SetNetCode( int aNetCode )
107  {
108  SetNetCode( aNetCode, false );
109  }
110 
114  wxString GetNetname() const;
115 
120  wxString GetNetnameMsg() const;
121 
125  wxString GetShortNetname() const;
126 
134  virtual int GetOwnClearance( PCB_LAYER_ID aLayer, wxString* aSource = nullptr ) const;
135 
142  virtual int GetLocalClearanceOverrides( wxString* aSource ) const { return 0; }
143 
151  virtual int GetLocalClearance( wxString* aSource ) const { return 0; }
152 
159  virtual NETCLASS* GetNetClass() const;
160 
167  virtual NETCLASS* GetEffectiveNetclass() const;
168 
177  virtual wxString GetNetClassName() const;
178 
179  void SetLocalRatsnestVisible( bool aVisible )
180  {
181  m_localRatsnestVisible = aVisible;
182  }
183 
185  {
186  return m_localRatsnestVisible;
187  }
188 
189 protected:
192 
193 private:
195 };
196 
197 #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:49
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 PCB_ARC, an arc track segment on a copper layer
Definition: typeinfo.h:97
bool GetLocalRatsnestVisible() 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,...
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 PCB_TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:95
wxString GetShortNetname() const
A collection of nets and the parameters used to route or test these nets.
Definition: netclass.h:46
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.
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:65
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:100
virtual int GetOwnClearance(PCB_LAYER_ID aLayer, wxString *aSource=nullptr) const
Return an item's "own" clearance in internal units.
class PCB_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:57
virtual int GetLocalClearance(wxString *aSource) const
Return any local clearances set in the "classic" (ie: pre-rule) system.
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:113
void SetNetCode(int aNetCode)