KiCad PCB EDA Suite
RN_DATA Class Reference

Class RN_DATA. More...

#include <ratsnest_data.h>

Public Member Functions

 RN_DATA (const BOARD *aBoard)
 Default constructor. More...
 
bool Add (const BOARD_ITEM *aItem)
 Function Add() Adds an item to the ratsnest data. More...
 
bool Remove (const BOARD_ITEM *aItem)
 Function Remove() Removes an item from the ratsnest data. More...
 
bool Update (const BOARD_ITEM *aItem)
 Function Update() Updates the ratsnest data for an item. More...
 
void AddSimple (const BOARD_ITEM *aItem)
 Function AddSimple() Sets an item to be drawn in simple mode (i.e. More...
 
void AddBlocked (const BOARD_ITEM *aItem)
 Function AddBlocked() Specifies an item as not suitable as a ratsnest line target (i.e. More...
 
void ClearSimple ()
 Function ClearSimple() Clears the list of nodes for which ratsnest is drawn in simple mode (one line per node). More...
 
void ProcessBoard ()
 Function ProcessBoard() Prepares data for computing (computes a list of current nodes and connections). More...
 
void Recalculate (int aNet=-1)
 Function Recalculate() Recomputes ratsnest for selected net number or all nets that need updating. More...
 
int GetNetCount () const
 Function GetNetCount() Returns the number of nets handled by the ratsnest. More...
 
RN_NETGetNet (int aNetCode)
 Function GetNet() Returns ratsnest grouped by net numbers. More...
 
void GetConnectedItems (const BOARD_CONNECTED_ITEM *aItem, std::list< BOARD_CONNECTED_ITEM * > &aOutput, RN_ITEM_TYPE aTypes=RN_ALL) const
 Function GetConnectedItems() Adds items that are connected together to a list. More...
 
void GetNetItems (int aNetCode, std::list< BOARD_CONNECTED_ITEM * > &aOutput, RN_ITEM_TYPE aTypes=RN_ALL) const
 Function GetNetItems() Adds all items that belong to a certain net to a list. More...
 
bool AreConnected (const BOARD_CONNECTED_ITEM *aItem, const BOARD_CONNECTED_ITEM *aOther)
 Function AreConnected() Checks if two items are connected with copper. More...
 
int GetUnconnectedCount () const
 Function GetUnconnectedCount() Returns the number of missing connections. More...
 

Protected Member Functions

void updateNet (int aNetCode)
 Function updateNet() Recomputes ratsnest for a single net. More...
 

Protected Attributes

const BOARDm_board
 

Board to be processed.

More...
 
std::vector< RN_NETm_nets
 

Stores information about ratsnest grouped by net numbers.

More...
 

Detailed Description

Class RN_DATA.

Stores information about unconnected items for a board.

Definition at line 651 of file ratsnest_data.h.

Constructor & Destructor Documentation

RN_DATA::RN_DATA ( const BOARD aBoard)
inline

Default constructor.

Parameters
aBoardis the board to be processed in order to look for unconnected items.

Definition at line 658 of file ratsnest_data.h.

658 : m_board( aBoard ) {}
const BOARD * m_board
Board to be processed.

Member Function Documentation

bool RN_DATA::Add ( const BOARD_ITEM aItem)

Function Add() Adds an item to the ratsnest data.

Parameters
aItemis an item to be added.
Returns
True if operation succeeded.

Definition at line 1064 of file ratsnest_data.cpp.

References DLIST< T >::GetFirst(), BOARD::GetNetCount(), BOARD_ITEM::IsConnected(), m_board, m_nets, D_PAD::Next(), NETINFO_LIST::ORPHANED, MODULE::Pads(), PCB_MODULE_T, PCB_NETINFO_T, PCB_PAD_T, PCB_TRACE_T, PCB_VIA_T, PCB_ZONE_AREA_T, and EDA_ITEM::Type().

Referenced by BOARD::Add(), PCB_BASE_EDIT_FRAME::PutDataInPreviousState(), BOARD_COMMIT::Revert(), BOARD_CONNECTED_ITEM::SetNetCode(), and Update().

1065 {
1066  int net = NETINFO_LIST::ORPHANED;
1067 
1068  if( aItem->IsConnected() )
1069  {
1070  net = static_cast<const BOARD_CONNECTED_ITEM*>( aItem )->GetNetCode();
1071  }
1072  else if( aItem->Type() == PCB_MODULE_T )
1073  {
1074  const MODULE* module = static_cast<const MODULE*>( aItem );
1075 
1076  for( const D_PAD* pad = module->Pads().GetFirst(); pad; pad = pad->Next() )
1077  {
1078  net = pad->GetNetCode();
1079 
1080  // Do not process orphaned items
1081  if( net <= NETINFO_LIST::ORPHANED )
1082  continue;
1083 
1084  Add( pad );
1085  }
1086 
1087  return true;
1088  }
1089  else if( aItem->Type() == PCB_NETINFO_T )
1090  {
1091  int netCount = m_board->GetNetCount();
1092 
1093  if( (unsigned) netCount > m_nets.size() )
1094  m_nets.resize( netCount );
1095 
1096  return true;
1097  }
1098  else
1099  {
1100  return false;
1101  }
1102 
1103  if( net < 0 )
1104  return false;
1105 
1106  // Autoresize is necessary e.g. for module editor
1107  if( net >= (int) m_nets.size() )
1108  m_nets.resize( net + 1 );
1109 
1110  switch( aItem->Type() )
1111  {
1112  case PCB_PAD_T:
1113  return m_nets[net].AddItem( static_cast<const D_PAD*>( aItem ) );
1114  break;
1115 
1116  case PCB_TRACE_T:
1117  return m_nets[net].AddItem( static_cast<const TRACK*>( aItem ) );
1118  break;
1119 
1120  case PCB_VIA_T:
1121  return m_nets[net].AddItem( static_cast<const VIA*>( aItem ) );
1122  break;
1123 
1124  case PCB_ZONE_AREA_T:
1125  return m_nets[net].AddItem( static_cast<const ZONE_CONTAINER*>( aItem ) );
1126  break;
1127 
1128  default:
1129  break;
1130  }
1131 
1132  return false;
1133 }
KICAD_T Type() const
Function Type()
Definition: base_struct.h:198
class ZONE_CONTAINER, a zone area
Definition: typeinfo.h:114
class D_PAD, a pad in a footprint
Definition: typeinfo.h:102
Class BOARD_CONNECTED_ITEM is a base class derived from BOARD_ITEM for items that can be connected an...
class TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:107
const BOARD * m_board
Board to be processed.
class MODULE, a footprint
Definition: typeinfo.h:101
T * GetFirst() const
Function GetFirst returns the first T* in the list without removing it, or NULL if the list is empty...
Definition: dlist.h:163
D_PAD * Next() const
Definition: class_pad.h:106
std::vector< RN_NET > m_nets
Stores information about ratsnest grouped by net numbers.
static const int ORPHANED
Constant that forces initialization of a netinfo item to the NETINFO_ITEM ORPHANED (typically -1) whe...
virtual bool IsConnected() const
Function IsConnected() Returns information if the object is derived from BOARD_CONNECTED_ITEM.
class NETINFO_ITEM, a description of a net
Definition: typeinfo.h:116
bool Add(const BOARD_ITEM *aItem)
Function Add() Adds an item to the ratsnest data.
class VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:108
DLIST< D_PAD > & Pads()
Definition: class_module.h:133
unsigned GetNetCount() const
Function GetNetCount.
Definition: class_board.h:814
void RN_DATA::AddBlocked ( const BOARD_ITEM aItem)

Function AddBlocked() Specifies an item as not suitable as a ratsnest line target (i.e.

ratsnest lines will not target its node(s)). The status is cleared after calling ClearSimple().

Parameters
aItemis the item of which node(s) are not going to be used as a ratsnest line target.

Definition at line 886 of file ratsnest_data.cpp.

References DLIST< T >::GetFirst(), BOARD_CONNECTED_ITEM::GetNetCode(), BOARD_ITEM::IsConnected(), m_nets, D_PAD::Next(), MODULE::Pads(), PCB_MODULE_T, EDA_ITEM::Type(), and NETINFO_LIST::UNCONNECTED.

887 {
888  if( aItem->IsConnected() )
889  {
890  const BOARD_CONNECTED_ITEM* item = static_cast<const BOARD_CONNECTED_ITEM*>( aItem );
891  int net = item->GetNetCode();
892 
893  // Do not process orphaned & unconnected items
894  if( net <= NETINFO_LIST::UNCONNECTED )
895  return;
896 
897  // Block all nodes belonging to the item
898  for( RN_NODE_PTR node : m_nets[net].GetNodes( item ) )
899  m_nets[net].AddBlockedNode( node );
900  }
901  else if( aItem->Type() == PCB_MODULE_T )
902  {
903  const MODULE* module = static_cast<const MODULE*>( aItem );
904 
905  for( const D_PAD* pad = module->Pads().GetFirst(); pad; pad = pad->Next() )
906  AddBlocked( pad );
907  }
908 }
KICAD_T Type() const
Function Type()
Definition: base_struct.h:198
hed::NODE_PTR RN_NODE_PTR
Definition: ratsnest_data.h:64
Class BOARD_CONNECTED_ITEM is a base class derived from BOARD_ITEM for items that can be connected an...
class MODULE, a footprint
Definition: typeinfo.h:101
T * GetFirst() const
Function GetFirst returns the first T* in the list without removing it, or NULL if the list is empty...
Definition: dlist.h:163
D_PAD * Next() const
Definition: class_pad.h:106
std::vector< RN_NET > m_nets
Stores information about ratsnest grouped by net numbers.
int GetNetCode() const
Function GetNetCode.
virtual bool IsConnected() const
Function IsConnected() Returns information if the object is derived from BOARD_CONNECTED_ITEM.
DLIST< D_PAD > & Pads()
Definition: class_module.h:133
void AddBlocked(const BOARD_ITEM *aItem)
Function AddBlocked() Specifies an item as not suitable as a ratsnest line target (i...
static const int UNCONNECTED
Constant that holds the "unconnected net" number (typically 0) all items "connected" to this net are ...
void RN_DATA::AddSimple ( const BOARD_ITEM aItem)

Function AddSimple() Sets an item to be drawn in simple mode (i.e.

one line per node, instead of full ratsnest). It is used for drawing quick, temporary ratsnest, eg. while moving an item.

Parameters
aItemis an item to be drawn in simple node.

Definition at line 863 of file ratsnest_data.cpp.

References DLIST< T >::GetFirst(), BOARD_CONNECTED_ITEM::GetNetCode(), BOARD_ITEM::IsConnected(), m_nets, D_PAD::Next(), MODULE::Pads(), PCB_MODULE_T, EDA_ITEM::Type(), and NETINFO_LIST::UNCONNECTED.

Referenced by EDIT_TOOL::updateRatsnest().

864 {
865  if( aItem->IsConnected() )
866  {
867  const BOARD_CONNECTED_ITEM* item = static_cast<const BOARD_CONNECTED_ITEM*>( aItem );
868  int net = item->GetNetCode();
869 
870  // Do not process orphaned & unconnected items
871  if( net <= NETINFO_LIST::UNCONNECTED )
872  return;
873 
874  m_nets[net].AddSimple( item );
875  }
876  else if( aItem->Type() == PCB_MODULE_T )
877  {
878  const MODULE* module = static_cast<const MODULE*>( aItem );
879 
880  for( const D_PAD* pad = module->Pads().GetFirst(); pad; pad = pad->Next() )
881  AddSimple( pad );
882  }
883 }
KICAD_T Type() const
Function Type()
Definition: base_struct.h:198
Class BOARD_CONNECTED_ITEM is a base class derived from BOARD_ITEM for items that can be connected an...
class MODULE, a footprint
Definition: typeinfo.h:101
T * GetFirst() const
Function GetFirst returns the first T* in the list without removing it, or NULL if the list is empty...
Definition: dlist.h:163
D_PAD * Next() const
Definition: class_pad.h:106
std::vector< RN_NET > m_nets
Stores information about ratsnest grouped by net numbers.
int GetNetCode() const
Function GetNetCode.
virtual bool IsConnected() const
Function IsConnected() Returns information if the object is derived from BOARD_CONNECTED_ITEM.
DLIST< D_PAD > & Pads()
Definition: class_module.h:133
void AddSimple(const BOARD_ITEM *aItem)
Function AddSimple() Sets an item to be drawn in simple mode (i.e.
static const int UNCONNECTED
Constant that holds the "unconnected net" number (typically 0) all items "connected" to this net are ...
bool RN_DATA::AreConnected ( const BOARD_CONNECTED_ITEM aItem,
const BOARD_CONNECTED_ITEM aOther 
)

Function AreConnected() Checks if two items are connected with copper.

Parameters
aThisis the first item.
aOtheris the second item.
Returns
True if they are connected, false otherwise.

Definition at line 938 of file ratsnest_data.cpp.

References BOARD_CONNECTED_ITEM::GetNetCode(), and m_nets.

939 {
940  int net1 = aItem->GetNetCode();
941  int net2 = aOther->GetNetCode();
942 
943  if( net1 < 1 || net2 < 1 || net1 != net2 )
944  return false;
945 
946  assert( net1 < (int) m_nets.size() && net2 < (int) m_nets.size() );
947 
948  // net1 == net2
949  std::list<RN_NODE_PTR> items1 = m_nets[net1].GetNodes( aItem );
950  std::list<RN_NODE_PTR> items2 = m_nets[net1].GetNodes( aOther );
951 
952  assert( !items1.empty() && !items2.empty() );
953 
954  return ( items1.front()->GetTag() == items2.front()->GetTag() );
955 }
std::vector< RN_NET > m_nets
Stores information about ratsnest grouped by net numbers.
int GetNetCode() const
Function GetNetCode.
void RN_DATA::ClearSimple ( )
inline

Function ClearSimple() Clears the list of nodes for which ratsnest is drawn in simple mode (one line per node).

Definition at line 705 of file ratsnest_data.h.

References m_nets.

Referenced by EDIT_TOOL::updateRatsnest().

706  {
707  for( RN_NET& net : m_nets )
708  net.ClearSimple();
709  }
std::vector< RN_NET > m_nets
Stores information about ratsnest grouped by net numbers.
Class RN_NET Describes ratsnest for a single net.
void RN_DATA::GetConnectedItems ( const BOARD_CONNECTED_ITEM aItem,
std::list< BOARD_CONNECTED_ITEM * > &  aOutput,
RN_ITEM_TYPE  aTypes = RN_ALL 
) const

Function GetConnectedItems() Adds items that are connected together to a list.

Parameters
aItemis the reference item to find other connected items.
aOutputis the list that will contain found items.
aTypesallows to filter by item types.

Definition at line 911 of file ratsnest_data.cpp.

References BOARD_CONNECTED_ITEM::GetNetCode(), and m_nets.

Referenced by SELECTION_TOOL::selectAllItemsConnectedToItem().

914 {
915  int net = aItem->GetNetCode();
916 
917  if( net < 1 )
918  return;
919 
920  assert( net < (int) m_nets.size() );
921 
922  m_nets[net].GetConnectedItems( aItem, aOutput, aTypes );
923 }
std::vector< RN_NET > m_nets
Stores information about ratsnest grouped by net numbers.
int GetNetCode() const
Function GetNetCode.
RN_NET& RN_DATA::GetNet ( int  aNetCode)
inline

Function GetNet() Returns ratsnest grouped by net numbers.

Parameters
aNetCodeis the net code.
Returns
Ratsnest data for a specified net.

Definition at line 741 of file ratsnest_data.h.

References m_nets.

Referenced by KIGFX::RATSNEST_VIEWITEM::ViewDraw().

742  {
743  assert( aNetCode > 0 ); // ratsnest does not handle the unconnected net
744 
745  return m_nets[aNetCode];
746  }
std::vector< RN_NET > m_nets
Stores information about ratsnest grouped by net numbers.
int RN_DATA::GetNetCount ( ) const
inline

Function GetNetCount() Returns the number of nets handled by the ratsnest.

Returns
Number of the nets.

Definition at line 730 of file ratsnest_data.h.

References m_nets.

Referenced by KIGFX::RATSNEST_VIEWITEM::ViewDraw().

731  {
732  return m_nets.size();
733  }
std::vector< RN_NET > m_nets
Stores information about ratsnest grouped by net numbers.
void RN_DATA::GetNetItems ( int  aNetCode,
std::list< BOARD_CONNECTED_ITEM * > &  aOutput,
RN_ITEM_TYPE  aTypes = RN_ALL 
) const

Function GetNetItems() Adds all items that belong to a certain net to a list.

Parameters
aNetCodeis the net code.
aOutputis the list that will have items added.
aTypesallows to filter by item types.

Definition at line 926 of file ratsnest_data.cpp.

References m_nets.

Referenced by SELECTION_TOOL::selectAllItemsOnNet(), and SELECTION_TOOL::selectAllItemsOnSheet().

928 {
929  if( aNetCode < 1 )
930  return;
931 
932  assert( aNetCode < (int) m_nets.size() );
933 
934  m_nets[aNetCode].GetAllItems( aOutput, aTypes );
935 }
std::vector< RN_NET > m_nets
Stores information about ratsnest grouped by net numbers.
int RN_DATA::GetUnconnectedCount ( ) const

Function GetUnconnectedCount() Returns the number of missing connections.

Returns
Number of missing connections.

Definition at line 958 of file ratsnest_data.cpp.

References m_nets.

Referenced by PCB_DRAW_PANEL_GAL::GetMsgPanelInfo().

959 {
960  int count = 0;
961 
962  for( unsigned i = 0; i < m_nets.size(); ++i )
963  {
964  const std::vector<RN_EDGE_MST_PTR>* unconnected = m_nets[i].GetUnconnected();
965 
966  if( unconnected )
967  count += unconnected->size();
968  }
969 
970  return count;
971 }
std::vector< RN_NET > m_nets
Stores information about ratsnest grouped by net numbers.
void RN_DATA::ProcessBoard ( )

Function ProcessBoard() Prepares data for computing (computes a list of current nodes and connections).

It is required to run only once after loading a board.

Definition at line 1216 of file ratsnest_data.cpp.

References BOARD::GetArea(), BOARD::GetAreaCount(), BOARD_CONNECTED_ITEM::GetNetCode(), BOARD::GetNetCount(), m_board, BOARD::m_Modules, m_nets, BOARD::m_Track, TRACK::Next(), MODULE::Next(), D_PAD::Next(), PCB_TRACE_T, PCB_VIA_T, and Recalculate().

Referenced by DIALOG_GLOBAL_DELETION::AcceptPcbDelete(), PCBNEW_CONTROL::AppendBoard(), PCB_EDIT_FRAME::ImportSpecctraSession(), DIALOG_NETLIST::OnCompileRatsnestClick(), PCB_EDIT_FRAME::OpenProjectFiles(), PCB_BASE_EDIT_FRAME::PutDataInPreviousState(), PCB_EDIT_FRAME::ReadPcbNetlist(), DRC::RunTests(), PCB_EDIT_FRAME::SetBoard(), and BOARD_NETLIST_UPDATER::UpdateNetlist().

1217 {
1218  int netCount = m_board->GetNetCount();
1219  m_nets.clear();
1220  m_nets.resize( netCount );
1221  int netCode;
1222 
1223  // Iterate over all items that may need to be connected
1224  for( MODULE* module = m_board->m_Modules; module; module = module->Next() )
1225  {
1226  for( D_PAD* pad = module->Pads().GetFirst(); pad; pad = pad->Next() )
1227  {
1228  netCode = pad->GetNetCode();
1229 
1230  assert( netCode >= 0 && netCode < netCount );
1231 
1232  if( netCode >= 0 && netCode < netCount )
1233  m_nets[netCode].AddItem( pad );
1234  }
1235  }
1236 
1237  for( TRACK* track = m_board->m_Track; track; track = track->Next() )
1238  {
1239  netCode = track->GetNetCode();
1240 
1241  assert( netCode >= 0 && netCode < netCount );
1242 
1243  if( netCode >= 0 && netCode < netCount )
1244  {
1245  if( track->Type() == PCB_VIA_T )
1246  m_nets[netCode].AddItem( static_cast<VIA*>( track ) );
1247  else if( track->Type() == PCB_TRACE_T )
1248  m_nets[netCode].AddItem( track );
1249  }
1250  }
1251 
1252  for( int i = 0; i < m_board->GetAreaCount(); ++i )
1253  {
1254  ZONE_CONTAINER* zone = m_board->GetArea( i );
1255 
1256  netCode = zone->GetNetCode();
1257 
1258  assert( netCode >= 0 && netCode < netCount );
1259 
1260  if( netCode >= 0 && netCode < netCount )
1261  m_nets[netCode].AddItem( zone );
1262  }
1263 
1264  Recalculate();
1265 }
Class ZONE_CONTAINER handles a list of polygons defining a copper zone.
Definition: class_zone.h:78
MODULE * Next() const
Definition: class_module.h:99
class TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:107
const BOARD * m_board
Board to be processed.
D_PAD * Next() const
Definition: class_pad.h:106
int GetAreaCount() const
Function GetAreaCount.
Definition: class_board.h:1051
std::vector< RN_NET > m_nets
Stores information about ratsnest grouped by net numbers.
void Recalculate(int aNet=-1)
Function Recalculate() Recomputes ratsnest for selected net number or all nets that need updating...
int GetNetCode() const
Function GetNetCode.
TRACK * Next() const
Definition: class_track.h:97
ZONE_CONTAINER * GetArea(int index) const
Function GetArea returns the Area (Zone Container) at a given index.
Definition: class_board.h:1022
DLIST< MODULE > m_Modules
Definition: class_board.h:243
class VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:108
DLIST< TRACK > m_Track
Definition: class_board.h:244
unsigned GetNetCount() const
Function GetNetCount.
Definition: class_board.h:814
void RN_DATA::Recalculate ( int  aNet = -1)

Function Recalculate() Recomputes ratsnest for selected net number or all nets that need updating.

Parameters
aNetis a net number. If it is negative, all nets that need updating are recomputed.

Definition at line 1268 of file ratsnest_data.cpp.

References BOARD::GetNetCount(), m_board, m_nets, PROF_COUNTER::msecs(), PROF_COUNTER::Stop(), and updateNet().

Referenced by PCB_EDIT_FRAME::Edit_Zone_Params(), POINT_EDITOR::finishItem(), ProcessBoard(), BOARD_COMMIT::Push(), PCB_BASE_EDIT_FRAME::PutDataInPreviousState(), BOARD_COMMIT::Revert(), PCB_EDITOR_CONTROL::ZoneFill(), and PCB_EDITOR_CONTROL::ZoneUnfill().

1269 {
1270  unsigned int netCount = m_board->GetNetCount();
1271 
1272  if( aNet <= 0 && netCount > 1 ) // Recompute everything
1273  {
1274 #ifdef PROFILE
1275  PROF_COUNTER totalRealTime;
1276 #endif
1277 
1278  unsigned int i;
1279 
1280 #ifdef USE_OPENMP
1281  #pragma omp parallel shared(netCount) private(i)
1282  {
1283  #pragma omp for schedule(guided, 1)
1284 #else /* USE_OPENMP */
1285  {
1286 #endif
1287  // Start with net number 1, as 0 stands for not connected
1288  for( i = 1; i < netCount; ++i )
1289  {
1290  if( m_nets[i].IsDirty() )
1291  updateNet( i );
1292  }
1293  } /* end of parallel section */
1294 #ifdef PROFILE
1295  totalRealTime.Stop();
1296  wxLogDebug( "Recalculate all nets: %.1f ms", totalRealTime.msecs() );
1297 #endif /* PROFILE */
1298  }
1299  else if( aNet > 0 ) // Recompute only specific net
1300  {
1301  updateNet( aNet );
1302  }
1303 }
void Stop()
save the time when this function was called, and set the counter stane to stop
Definition: profile.h:82
The class PROF_COUNTER is a small class to help profiling.
Definition: profile.h:45
const BOARD * m_board
Board to be processed.
void updateNet(int aNetCode)
Function updateNet() Recomputes ratsnest for a single net.
std::vector< RN_NET > m_nets
Stores information about ratsnest grouped by net numbers.
double msecs() const
Definition: profile.h:121
unsigned GetNetCount() const
Function GetNetCount.
Definition: class_board.h:814
bool RN_DATA::Remove ( const BOARD_ITEM aItem)

Function Remove() Removes an item from the ratsnest data.

Parameters
aItemis an item to be updated.
Returns
True if operation succeeded.

Definition at line 1136 of file ratsnest_data.cpp.

References DLIST< T >::GetFirst(), BOARD_ITEM::IsConnected(), m_nets, D_PAD::Next(), NETINFO_LIST::ORPHANED, MODULE::Pads(), PCB_MODULE_T, PCB_PAD_T, PCB_TRACE_T, PCB_VIA_T, PCB_ZONE_AREA_T, and EDA_ITEM::Type().

Referenced by PCB_EDIT_FRAME::Delete_net(), PCB_EDIT_FRAME::Delete_Segment(), PCB_BASE_EDIT_FRAME::PutDataInPreviousState(), BOARD::Remove(), PCB_EDIT_FRAME::Remove_One_Track(), BOARD_COMMIT::Revert(), BOARD_CONNECTED_ITEM::SetNetCode(), and Update().

1137 {
1138  int net = NETINFO_LIST::ORPHANED;
1139 
1140  if( aItem->IsConnected() )
1141  {
1142  net = static_cast<const BOARD_CONNECTED_ITEM*>( aItem )->GetNetCode();
1143  }
1144  else if( aItem->Type() == PCB_MODULE_T )
1145  {
1146  const MODULE* module = static_cast<const MODULE*>( aItem );
1147 
1148  for( const D_PAD* pad = module->Pads().GetFirst(); pad; pad = pad->Next() )
1149  {
1150  net = pad->GetNetCode();
1151 
1152  // Do not process orphaned items
1153  if( net <= NETINFO_LIST::ORPHANED )
1154  continue;
1155 
1156  Remove( pad );
1157  }
1158 
1159  return true;
1160  }
1161  else
1162  {
1163  return false;
1164  }
1165 
1166  if( net < 0 )
1167  return false;
1168 
1169  // Autoresize is necessary e.g. for module editor
1170  if( net >= (int) m_nets.size() )
1171  {
1172  m_nets.resize( net + 1 );
1173  return false; // if it was resized, then surely the item had not been added before
1174  }
1175 
1176  switch( aItem->Type() )
1177  {
1178  case PCB_PAD_T:
1179  return m_nets[net].RemoveItem( static_cast<const D_PAD*>( aItem ) );
1180  break;
1181 
1182  case PCB_TRACE_T:
1183  return m_nets[net].RemoveItem( static_cast<const TRACK*>( aItem ) );
1184  break;
1185 
1186  case PCB_VIA_T:
1187  return m_nets[net].RemoveItem( static_cast<const VIA*>( aItem ) );
1188  break;
1189 
1190  case PCB_ZONE_AREA_T:
1191  return m_nets[net].RemoveItem( static_cast<const ZONE_CONTAINER*>( aItem ) );
1192  break;
1193 
1194  default:
1195  break;
1196  }
1197 
1198  return false;
1199 }
KICAD_T Type() const
Function Type()
Definition: base_struct.h:198
class ZONE_CONTAINER, a zone area
Definition: typeinfo.h:114
class D_PAD, a pad in a footprint
Definition: typeinfo.h:102
Class BOARD_CONNECTED_ITEM is a base class derived from BOARD_ITEM for items that can be connected an...
class TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:107
bool Remove(const BOARD_ITEM *aItem)
Function Remove() Removes an item from the ratsnest data.
class MODULE, a footprint
Definition: typeinfo.h:101
T * GetFirst() const
Function GetFirst returns the first T* in the list without removing it, or NULL if the list is empty...
Definition: dlist.h:163
D_PAD * Next() const
Definition: class_pad.h:106
std::vector< RN_NET > m_nets
Stores information about ratsnest grouped by net numbers.
static const int ORPHANED
Constant that forces initialization of a netinfo item to the NETINFO_ITEM ORPHANED (typically -1) whe...
virtual bool IsConnected() const
Function IsConnected() Returns information if the object is derived from BOARD_CONNECTED_ITEM.
class VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:108
DLIST< D_PAD > & Pads()
Definition: class_module.h:133
bool RN_DATA::Update ( const BOARD_ITEM aItem)

Function Update() Updates the ratsnest data for an item.

Parameters
aItemis an item to be updated.
Returns
True if operation succeeded. The item will not be updated if it was not previously added to the ratsnest.

Definition at line 1202 of file ratsnest_data.cpp.

References Add(), and Remove().

Referenced by PCB_EDIT_FRAME::Fill_Zone(), BOARD_COMMIT::Push(), PCB_BASE_EDIT_FRAME::PutDataInPreviousState(), EDIT_TOOL::updateRatsnest(), PCB_EDITOR_CONTROL::ZoneFill(), and PCB_EDITOR_CONTROL::ZoneUnfill().

1203 {
1204  if( Remove( aItem ) )
1205  {
1206  bool res = Add( aItem );
1207  assert( res );
1208  (void) res;
1209  return true;
1210  }
1211 
1212  return false;
1213 }
bool Remove(const BOARD_ITEM *aItem)
Function Remove() Removes an item from the ratsnest data.
bool Add(const BOARD_ITEM *aItem)
Function Add() Adds an item to the ratsnest data.
void RN_DATA::updateNet ( int  aNetCode)
protected

Function updateNet() Recomputes ratsnest for a single net.

Parameters
aNetCodeis the net number to be recomputed.

Definition at line 1306 of file ratsnest_data.cpp.

References m_nets.

Referenced by Recalculate().

1307 {
1308  assert( aNetCode < (int) m_nets.size() );
1309 
1310  if( aNetCode < 1 || aNetCode > (int) m_nets.size() )
1311  return;
1312 
1313  m_nets[aNetCode].ClearSimple();
1314  m_nets[aNetCode].Update();
1315 }
std::vector< RN_NET > m_nets
Stores information about ratsnest grouped by net numbers.

Member Data Documentation

const BOARD* RN_DATA::m_board
protected

Board to be processed.

Definition at line 794 of file ratsnest_data.h.

Referenced by Add(), ProcessBoard(), and Recalculate().

std::vector<RN_NET> RN_DATA::m_nets
protected

Stores information about ratsnest grouped by net numbers.

Definition at line 797 of file ratsnest_data.h.

Referenced by Add(), AddBlocked(), AddSimple(), AreConnected(), ClearSimple(), GetConnectedItems(), GetNet(), GetNetCount(), GetNetItems(), GetUnconnectedCount(), ProcessBoard(), Recalculate(), Remove(), and updateNet().


The documentation for this class was generated from the following files: