KiCad PCB EDA Suite
netlist_object_list.cpp
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) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr
5  * Copyright (C) 2013 Wayne Stambaugh <stambaughw@gmail.com>
6  * Copyright (C) 1992-2018 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 
30 #include <netlist.h>
31 #include <netlist_object.h>
32 #include <class_library.h>
33 #include <lib_pin.h>
34 #include <sch_junction.h>
35 #include <sch_component.h>
36 #include <sch_line.h>
37 #include <sch_no_connect.h>
38 #include <sch_text.h>
39 #include <sch_sheet.h>
40 #include <sch_screen.h>
41 #include <algorithm>
42 
43 #define IS_WIRE false
44 #define IS_BUS true
45 
46 //#define NETLIST_DEBUG
47 
49 {
50  Clear();
51 }
52 
53 
55 {
56  NETLIST_OBJECTS::iterator iter;
57 
58  for( iter = begin(); iter != end(); iter++ )
59  {
60  NETLIST_OBJECT* item = *iter;
61  delete item;
62  }
63 
64  clear();
65 }
66 
67 
69 {
70  sort( this->begin(), this->end(), NETLIST_OBJECT_LIST::sortItemsbyNetcode );
71 }
72 
73 
75 {
76  sort( this->begin(), this->end(), NETLIST_OBJECT_LIST::sortItemsBySheet );
77 }
78 
79 
81 {
82  SCH_SHEET_PATH* sheet;
83 
84  // Fill list with connected items from the flattened sheet list
85  for( unsigned i = 0; i < aSheets.size(); i++ )
86  {
87  sheet = &aSheets[i];
88 
89  for( SCH_ITEM* item = sheet->LastScreen()->GetDrawItems(); item; item = item->Next() )
90  {
91  item->GetNetListItem( *this, sheet );
92  }
93  }
94 
95  if( size() == 0 )
96  return false;
97 
98  // Sort objects by Sheet
100 
101  sheet = &(GetItem( 0 )->m_SheetPath);
103 
104  for( unsigned ii = 0, istart = 0; ii < size(); ii++ )
105  {
106  NETLIST_OBJECT* net_item = GetItem( ii );
107 
108  if( net_item->m_SheetPath != *sheet ) // Sheet change
109  {
110  sheet = &(net_item->m_SheetPath);
111  istart = ii;
112  }
113 
114  switch( net_item->m_Type )
115  {
117  wxMessageBox( wxT( "BuildNetListInfo() error" ) );
118  break;
119 
120  case NET_PIN:
121  case NET_PINLABEL:
122  case NET_SHEETLABEL:
123  case NET_NOCONNECT:
124  if( net_item->GetNet() != 0 )
125  break;
126 
127  case NET_SEGMENT:
128  // Test connections point to point type without bus.
129  if( net_item->GetNet() == 0 )
130  {
131  net_item->SetNet( m_lastNetCode );
132  m_lastNetCode++;
133  }
134 
135  pointToPointConnect( net_item, IS_WIRE, istart );
136  break;
137 
138  case NET_JUNCTION:
139  // Control of the junction outside BUS.
140  if( net_item->GetNet() == 0 )
141  {
142  net_item->SetNet( m_lastNetCode );
143  m_lastNetCode++;
144  }
145 
146  segmentToPointConnect( net_item, IS_WIRE, istart );
147 
148  // Control of the junction, on BUS.
149  if( net_item->m_BusNetCode == 0 )
150  {
151  net_item->m_BusNetCode = m_lastBusNetCode;
153  }
154 
155  segmentToPointConnect( net_item, IS_BUS, istart );
156  break;
157 
158  case NET_LABEL:
159  case NET_HIERLABEL:
160  case NET_GLOBLABEL:
161  // Test connections type junction without bus.
162  if( net_item->GetNet() == 0 )
163  {
164  net_item->SetNet( m_lastNetCode );
165  m_lastNetCode++;
166  }
167 
168  segmentToPointConnect( net_item, IS_WIRE, istart );
169  break;
170 
172  if( net_item->m_BusNetCode != 0 )
173  break;
174 
175  case NET_BUS:
176  // Control type connections point to point mode bus
177  if( net_item->m_BusNetCode == 0 )
178  {
179  net_item->m_BusNetCode = m_lastBusNetCode;
181  }
182 
183  pointToPointConnect( net_item, IS_BUS, istart );
184  break;
185 
186  case NET_BUSLABELMEMBER:
189  // Control connections similar has on BUS
190  if( net_item->GetNet() == 0 )
191  {
192  net_item->m_BusNetCode = m_lastBusNetCode;
194  }
195 
196  segmentToPointConnect( net_item, IS_BUS, istart );
197  break;
198  }
199  }
200 
201 #if defined(NETLIST_DEBUG) && defined(DEBUG)
202  std::cout << "\n\nafter sheet local\n\n";
203  DumpNetTable();
204 #endif
205 
206  // Updating the Bus Labels Netcode connected by Bus
208 
209  // Group objects by label.
210  for( unsigned ii = 0; ii < size(); ii++ )
211  {
212  switch( GetItem( ii )->m_Type )
213  {
214  case NET_PIN:
215  case NET_SHEETLABEL:
216  case NET_SEGMENT:
217  case NET_JUNCTION:
218  case NET_BUS:
219  case NET_NOCONNECT:
220  break;
221 
222  case NET_LABEL:
223  case NET_GLOBLABEL:
224  case NET_PINLABEL:
225  case NET_BUSLABELMEMBER:
227  labelConnect( GetItem( ii ) );
228  break;
229 
231  case NET_HIERLABEL:
233  break;
234 
236  break;
237  }
238  }
239 
240 #if defined(NETLIST_DEBUG) && defined(DEBUG)
241  std::cout << "\n\nafter sheet global\n\n";
242  DumpNetTable();
243 #endif
244 
245  // Connection between hierarchy sheets
246  for( unsigned ii = 0; ii < size(); ii++ )
247  {
248  if( GetItem( ii )->m_Type == NET_SHEETLABEL
249  || GetItem( ii )->m_Type == NET_SHEETBUSLABELMEMBER )
250  sheetLabelConnect( GetItem( ii ) );
251  }
252 
253  // Sort objects by NetCode
255 
256 #if defined(NETLIST_DEBUG) && defined(DEBUG)
257  std::cout << "\n\nafter qsort()\n";
258  DumpNetTable();
259 #endif
260 
261  // Compress numbers of Netcode having consecutive values.
262  int NetCode = 0;
263  m_lastNetCode = 0;
264 
265  for( unsigned ii = 0; ii < size(); ii++ )
266  {
267  if( GetItem( ii )->GetNet() != m_lastNetCode )
268  {
269  NetCode++;
270  m_lastNetCode = GetItem( ii )->GetNet();
271  }
272 
273  GetItem( ii )->SetNet( NetCode );
274  }
275 
276  // Set the minimal connection info:
278 
279  // find the best label object to give the best net name to each net
281 
282  return true;
283 }
284 
285 // Helper function to give a priority to sort labels:
286 // NET_PINLABEL, NET_GLOBBUSLABELMEMBER and NET_GLOBLABEL are global labels
287 // and the priority is high
288 static int getPriority( const NETLIST_OBJECT* Objet )
289 {
290  switch( Objet->m_Type )
291  {
292  case NET_PIN: return 1;
293  case NET_LABEL: return 2;
294  case NET_HIERLABEL: return 3;
295  case NET_PINLABEL: return 4;
296  case NET_GLOBBUSLABELMEMBER: return 5;
297  case NET_GLOBLABEL: return 6;
298  default: break;
299  }
300 
301  return 0;
302 }
303 
304 
305 /* function evalLabelsPriority used by findBestNetNameForEachNet()
306  * evalLabelsPriority calculates the priority of alabel1 and aLabel2
307  * return true if alabel1 has a higher priority than aLabel2
308  */
309 static bool evalLabelsPriority( const NETLIST_OBJECT* aLabel1, const NETLIST_OBJECT* aLabel2 )
310 {
311  // Global labels have the highest prioriy.
312  // For local labels: names are prefixed by their sheetpath
313  // use name defined in the more top level hierarchical sheet
314  // (i.e. shorter timestamp path because paths are /<timestamp1>/<timestamp2>/...
315  // and timestamp = 8 letters.
316  // Note: the final net name uses human sheetpath name, not timestamp sheetpath name
317  // They are equivalent, but not for human readers.
318  if( ! aLabel1->IsLabelGlobal() && ! aLabel2->IsLabelGlobal() )
319  {
320  if( aLabel1->m_SheetPath.Path().Length() != aLabel2->m_SheetPath.Path().Length() )
321  return aLabel1->m_SheetPath.Path().Length() < aLabel2->m_SheetPath.Path().Length();
322  }
323 
324  int priority1 = getPriority( aLabel1 );
325  int priority2 = getPriority( aLabel2 );
326 
327  if( priority1 != priority2 )
328  return priority1 > priority2;
329 
330  // Objects have here the same priority, therefore they have the same type.
331  // for global labels, we select the best candidate by alphabetic order
332  // because they have no sheetpath as prefix name
333  // for other labels, we select them before by sheet deep order
334  // because the actual name is /sheetpath/label
335  // and for a given path length, by alphabetic order
336  if( aLabel1->IsLabelGlobal() )
337  return aLabel1->m_Label.Cmp( aLabel2->m_Label ) < 0;
338 
339  // Sheet paths have here the same length: use alphabetic label name order
340  // For labels on sheets having an equivalent deep in hierarchy, use
341  // alphabetic label name order:
342  if( aLabel1->m_Label.Cmp( aLabel2->m_Label ) != 0 )
343  return aLabel1->m_Label.Cmp( aLabel2->m_Label ) < 0;
344 
345  // For identical labels having the same priority: choose the
346  // alphabetic label full name order
347  return aLabel1->m_SheetPath.PathHumanReadable().Cmp(
348  aLabel2->m_SheetPath.PathHumanReadable() ) < 0;
349 }
350 
351 
353 {
354  // Important note: NET_SHEETLABEL items of sheet items should *NOT* be considered,
355  // because they live in a sheet but their names are actually used in the subsheet.
356  // Moreover, in the parent sheet, the name of NET_SHEETLABEL can be not unique,
357  // ( for instance when 2 different sheets share the same schematic in complex hierarchies
358  // and 2 identical NET_SHEETLABEL labels can be connected to 2 different nets
359 
360  int netcode = 0; // current netcode for tested items
361  unsigned idxstart = 0; // index of the first item of this net
362  NETLIST_OBJECT* item;
363  NETLIST_OBJECT* candidate;
364 
365  // Pass 1: find the best name for labelled nets:
366  candidate = NULL;
367  for( unsigned ii = 0; ii <= size(); ii++ )
368  {
369  if( ii == size() ) // last item already tested
370  item = NULL;
371  else
372  item = GetItem( ii );
373 
374  if( !item || netcode != item->GetNet() ) // End of net found
375  {
376  if( candidate ) // One or more labels exists, find the best
377  {
378  for (unsigned jj = idxstart; jj < ii; jj++ )
379  GetItem( jj )->SetNetNameCandidate( candidate );
380  }
381 
382  if( item == NULL ) // End of list
383  break;
384 
385  // Prepare next net analysis:
386  netcode = item->GetNet();
387  candidate = NULL;
388  idxstart = ii;
389  }
390 
391  switch( item->m_Type )
392  {
393  case NET_HIERLABEL:
394  case NET_LABEL:
395  case NET_PINLABEL:
396  case NET_GLOBLABEL:
398  // A candidate is found: select the better between the previous
399  // and this one
400  if( candidate == NULL )
401  candidate = item;
402  else
403  {
404  if( evalLabelsPriority( item, candidate ) )
405  // item has a highter priority than candidate
406  // so update the best candidate
407  candidate = item;
408  }
409  break;
410 
411  default:
412  break;
413  }
414  }
415 
416  // Pass 2: find the best name for not labelled nets:
417  // The "default" net name is Net-<<Ref cmp>_Pad<num pad>>
418  // (see NETLIST_OBJECT::GetShortNetName())
419  // therefore the "best" is the short net name alphabetically classed first
420  // (to avoid net names changes when the net is not modified,
421  // even if components are moved or deleted and undelete or replaced, as long
422  // the reference is kept)
423 
424  // Build a list of items with no net names
425  NETLIST_OBJECTS list; // no ownership of elements being pointed at
426 
427  for( unsigned ii = 0; ii < size(); ii++ )
428  {
429  item = GetItem( ii );
430 
431  if( !item->HasNetNameCandidate() )
432  list.push_back( item );
433  }
434 
435  if( list.size() == 0 )
436  return;
437 
438  idxstart = 0;
439  candidate = NULL;
440  netcode = list[0]->GetNet();
441 
442  for( unsigned ii = 0; ii <= list.size(); ii++ )
443  {
444  if( ii < list.size() )
445  item = list[ii];
446  else
447  item = NULL;
448 
449  if( !item || netcode != item->GetNet() ) // End of net found
450  {
451  if( candidate )
452  {
453  for (unsigned jj = idxstart; jj < ii; jj++ )
454  {
455  NETLIST_OBJECT* obj = list[jj];
456  obj->SetNetNameCandidate( candidate );
457  }
458  }
459 
460  if( !item )
461  break;
462 
463  netcode = item->GetNet();
464  candidate = NULL;
465  idxstart = ii;
466  }
467 
468  // Examine all pins of the net to find the best candidate,
469  // i.e. the first net name candidate, by alphabetic order
470  // the net names are built by GetShortNetName
471  // (Net-<{reference}-Pad{pad number}> like Net-<U3-Pad5>
472  // Not named nets do not have usually a lot of members.
473  // Many have only 2 members(a pad and a non connection symbol)
474  if( item->m_Type == NET_PIN )
475  {
476  // A candidate is found, however components which are not in
477  // netlist are not candidate because some have their reference
478  // changed each time the netlist is built (power components)
479  // and anyway obviously they are not a good candidate
480  SCH_COMPONENT* link = item->GetComponentParent();
481 
482  if( link && link->IsInNetlist() )
483  {
484  // select the better between the previous and this one
485  item->SetNetNameCandidate( item ); // Needed to calculate GetShortNetName
486 
487  if( candidate == NULL )
488  candidate = item;
489  else
490  {
491  if( item->GetShortNetName().Cmp( candidate->GetShortNetName() ) < 0 )
492  candidate = item;
493  }
494  }
495  }
496  }
497 }
498 
499 
501 {
502  if( SheetLabel->GetNet() == 0 )
503  return;
504 
505  for( unsigned ii = 0; ii < size(); ii++ )
506  {
507  NETLIST_OBJECT* ObjetNet = GetItem( ii );
508 
509  if( ObjetNet->m_SheetPath != SheetLabel->m_SheetPathInclude )
510  continue; //use SheetInclude, not the sheet!!
511 
512  if( (ObjetNet->m_Type != NET_HIERLABEL ) && (ObjetNet->m_Type != NET_HIERBUSLABELMEMBER ) )
513  continue;
514 
515  if( ObjetNet->GetNet() == SheetLabel->GetNet() )
516  continue; //already connected.
517 
518  if( ObjetNet->m_Label != SheetLabel->m_Label )
519  continue; //different names.
520 
521  // Propagate Netcode having all the objects of the same Netcode.
522  if( ObjetNet->GetNet() )
523  propagateNetCode( ObjetNet->GetNet(), SheetLabel->GetNet(), IS_WIRE );
524  else
525  ObjetNet->SetNet( SheetLabel->GetNet() );
526  }
527 }
528 
529 
531 {
532  // Propagate the net code between all bus label member objects connected by they name.
533  // If the net code is not yet existing, a new one is created
534  // Search is done in the entire list
535  for( unsigned ii = 0; ii < size(); ii++ )
536  {
537  NETLIST_OBJECT* Label = GetItem( ii );
538 
539  if( Label->IsLabelBusMemberType() )
540  {
541  if( Label->GetNet() == 0 )
542  {
543  // Not yet existiing net code: create a new one.
544  Label->SetNet( m_lastNetCode );
545  m_lastNetCode++;
546  }
547 
548  for( unsigned jj = ii + 1; jj < size(); jj++ )
549  {
550  NETLIST_OBJECT* LabelInTst = GetItem( jj );
551 
552  if( LabelInTst->IsLabelBusMemberType() )
553  {
554  if( LabelInTst->m_BusNetCode != Label->m_BusNetCode )
555  continue;
556 
557  if( LabelInTst->m_Member != Label->m_Member )
558  continue;
559 
560  if( LabelInTst->GetNet() == 0 )
561  // Append this object to the current net
562  LabelInTst->SetNet( Label->GetNet() );
563  else
564  // Merge the 2 net codes, they are connected.
565  propagateNetCode( LabelInTst->GetNet(), Label->GetNet(), IS_WIRE );
566  }
567  }
568  }
569  }
570 }
571 
572 
573 void NETLIST_OBJECT_LIST::propagateNetCode( int aOldNetCode, int aNewNetCode, bool aIsBus )
574 {
575  if( aOldNetCode == aNewNetCode )
576  return;
577 
578  if( aIsBus == false ) // Propagate NetCode
579  {
580  for( unsigned jj = 0; jj < size(); jj++ )
581  {
582  NETLIST_OBJECT* object = GetItem( jj );
583 
584  if( object->GetNet() == aOldNetCode )
585  object->SetNet( aNewNetCode );
586  }
587  }
588  else // Propagate BusNetCode
589  {
590  for( unsigned jj = 0; jj < size(); jj++ )
591  {
592  NETLIST_OBJECT* object = GetItem( jj );
593 
594  if( object->m_BusNetCode == aOldNetCode )
595  object->m_BusNetCode = aNewNetCode;
596  }
597  }
598 }
599 
600 
601 void NETLIST_OBJECT_LIST::pointToPointConnect( NETLIST_OBJECT* aRef, bool aIsBus, int start )
602 {
603  int netCode;
604 
605  if( aIsBus == false ) // Objects other than BUS and BUSLABELS
606  {
607  netCode = aRef->GetNet();
608 
609  for( unsigned i = start; i < size(); i++ )
610  {
611  NETLIST_OBJECT* item = GetItem( i );
612 
613  if( item->m_SheetPath != aRef->m_SheetPath ) //used to be > (why?)
614  continue;
615 
616  switch( item->m_Type )
617  {
618  case NET_SEGMENT:
619  case NET_PIN:
620  case NET_LABEL:
621  case NET_HIERLABEL:
622  case NET_GLOBLABEL:
623  case NET_SHEETLABEL:
624  case NET_PINLABEL:
625  case NET_JUNCTION:
626  case NET_NOCONNECT:
627  if( aRef->m_Start == item->m_Start
628  || aRef->m_Start == item->m_End
629  || aRef->m_End == item->m_Start
630  || aRef->m_End == item->m_End )
631  {
632  if( item->GetNet() == 0 )
633  item->SetNet( netCode );
634  else
635  propagateNetCode( item->GetNet(), netCode, IS_WIRE );
636  }
637  break;
638 
639  case NET_BUS:
640  case NET_BUSLABELMEMBER:
645  break;
646  }
647  }
648  }
649  else // Object type BUS, BUSLABELS, and junctions.
650  {
651  netCode = aRef->m_BusNetCode;
652 
653  for( unsigned i = start; i < size(); i++ )
654  {
655  NETLIST_OBJECT* item = GetItem( i );
656 
657  if( item->m_SheetPath != aRef->m_SheetPath )
658  continue;
659 
660  switch( item->m_Type )
661  {
663  case NET_SEGMENT:
664  case NET_PIN:
665  case NET_LABEL:
666  case NET_HIERLABEL:
667  case NET_GLOBLABEL:
668  case NET_SHEETLABEL:
669  case NET_PINLABEL:
670  case NET_NOCONNECT:
671  break;
672 
673  case NET_BUS:
674  case NET_BUSLABELMEMBER:
678  case NET_JUNCTION:
679  if( aRef->m_Start == item->m_Start
680  || aRef->m_Start == item->m_End
681  || aRef->m_End == item->m_Start
682  || aRef->m_End == item->m_End )
683  {
684  if( item->m_BusNetCode == 0 )
685  item->m_BusNetCode = netCode;
686  else
687  propagateNetCode( item->m_BusNetCode, netCode, IS_BUS );
688  }
689  break;
690  }
691  }
692  }
693 }
694 
695 
697  bool aIsBus, int aIdxStart )
698 {
699  for( unsigned i = aIdxStart; i < size(); i++ )
700  {
701  NETLIST_OBJECT* segment = GetItem( i );
702 
703  // if different sheets, obviously no physical connection between elements.
704  if( segment->m_SheetPath != aJonction->m_SheetPath )
705  continue;
706 
707  if( aIsBus == IS_WIRE )
708  {
709  if( segment->m_Type != NET_SEGMENT )
710  continue;
711  }
712  else
713  {
714  if( segment->m_Type != NET_BUS )
715  continue;
716  }
717 
718  if( IsPointOnSegment( segment->m_Start, segment->m_End, aJonction->m_Start ) )
719  {
720  // Propagation Netcode has all the objects of the same Netcode.
721  if( aIsBus == IS_WIRE )
722  {
723  if( segment->GetNet() )
724  propagateNetCode( segment->GetNet(), aJonction->GetNet(), aIsBus );
725  else
726  segment->SetNet( aJonction->GetNet() );
727  }
728  else
729  {
730  if( segment->m_BusNetCode )
731  propagateNetCode( segment->m_BusNetCode, aJonction->m_BusNetCode, aIsBus );
732  else
733  segment->m_BusNetCode = aJonction->m_BusNetCode;
734  }
735  }
736  }
737 }
738 
739 
741 {
742  if( aLabelRef->GetNet() == 0 )
743  return;
744 
745  for( unsigned i = 0; i < size(); i++ )
746  {
747  NETLIST_OBJECT* item = GetItem( i );
748 
749  if( item->GetNet() == aLabelRef->GetNet() )
750  continue;
751 
752  if( item->m_SheetPath != aLabelRef->m_SheetPath )
753  {
754  if( item->m_Type != NET_PINLABEL && item->m_Type != NET_GLOBLABEL
755  && item->m_Type != NET_GLOBBUSLABELMEMBER )
756  continue;
757 
758  if( (item->m_Type == NET_GLOBLABEL
759  || item->m_Type == NET_GLOBBUSLABELMEMBER)
760  && item->m_Type != aLabelRef->m_Type )
761  //global labels only connect other global labels.
762  continue;
763  }
764 
765  // NET_HIERLABEL are used to connect sheets.
766  // NET_LABEL are local to a sheet
767  // NET_GLOBLABEL are global.
768  // NET_PINLABEL is a kind of global label (generated by a power pin invisible)
769  if( item->IsLabelType() )
770  {
771  if( item->m_Label != aLabelRef->m_Label )
772  continue;
773 
774  if( item->GetNet() )
775  propagateNetCode( item->GetNet(), aLabelRef->GetNet(), IS_WIRE );
776  else
777  item->SetNet( aLabelRef->GetNet() );
778  }
779  }
780 }
781 
782 
784 {
785  NETLIST_OBJECT* NetItemRef;
786  unsigned NetStart, NetEnd;
787  NET_CONNECTION_T StateFlag;
788 
789  NetStart = NetEnd = 0;
790  StateFlag = UNCONNECTED;
791  for( unsigned ii = 0; ii < size(); ii++ )
792  {
793  NetItemRef = GetItem( ii );
794  if( NetItemRef->m_Type == NET_NOCONNECT && StateFlag != PAD_CONNECT )
795  StateFlag = NOCONNECT_SYMBOL_PRESENT;
796 
797  // Analysis of current net.
798  unsigned idxtoTest = ii + 1;
799 
800  if( ( idxtoTest >= size() )
801  || ( NetItemRef->GetNet() != GetItem( idxtoTest )->GetNet() ) )
802  {
803  // Net analysis to update m_ConnectionType
804  NetEnd = idxtoTest;
805 
806  /* set m_ConnectionType member to StateFlag for all items of
807  * this net: */
808  for( unsigned kk = NetStart; kk < NetEnd; kk++ )
809  GetItem( kk )->m_ConnectionType = StateFlag;
810 
811  if( idxtoTest >= size() )
812  return;
813 
814  // Start Analysis next Net
815  StateFlag = UNCONNECTED;
816  NetStart = idxtoTest;
817  continue;
818  }
819 
820  /* test the current item: if this is a pin and if the reference item
821  * is also a pin, then 2 pins are connected, so set StateFlag to
822  * PAD_CONNECT (can be already done) Of course, if the current
823  * item is a no connect symbol, set StateFlag to
824  * NOCONNECT_SYMBOL_PRESENT to inhibit error diags. However if
825  * StateFlag is already set to PAD_CONNECT this state is kept (the
826  * no connect symbol was surely an error and an ERC will report this)
827  */
828  for( ; ; idxtoTest++ )
829  {
830  if( ( idxtoTest >= size() )
831  || ( NetItemRef->GetNet() != GetItem( idxtoTest )->GetNet() ) )
832  break;
833 
834  switch( GetItem( idxtoTest )->m_Type )
835  {
837  wxMessageBox( wxT( "BuildNetListBase() error" ) );
838  break;
839 
840  case NET_SEGMENT:
841  case NET_LABEL:
842  case NET_HIERLABEL:
843  case NET_GLOBLABEL:
844  case NET_SHEETLABEL:
845  case NET_PINLABEL:
846  case NET_BUS:
847  case NET_BUSLABELMEMBER:
851  case NET_JUNCTION:
852  break;
853 
854  case NET_PIN:
855  if( NetItemRef->m_Type == NET_PIN )
856  StateFlag = PAD_CONNECT;
857 
858  break;
859 
860  case NET_NOCONNECT:
861  if( StateFlag != PAD_CONNECT )
862  StateFlag = NOCONNECT_SYMBOL_PRESENT;
863 
864  break;
865  }
866  }
867  }
868 }
Definition of the SCH_SHEET class for Eeschema.
Class SCH_SHEET_LIST.
void setUnconnectedFlag()
Set the m_FlagOfConnection member of items in list depending on the connection type: UNCONNECTED...
bool IsLabelGlobal() const
Function IsLabelGlobal.
bool IsPointOnSegment(const wxPoint &aSegStart, const wxPoint &aSegEnd, const wxPoint &aTestPoint)
Function IsPointOnSegment.
Definition: trigo.cpp:39
void connectBusLabels()
Function connectBusLabels Propagate the net code (and create it, if not yet existing) between all bus...
static bool evalLabelsPriority(const NETLIST_OBJECT *aLabel1, const NETLIST_OBJECT *aLabel2)
NETLIST_OBJECT * GetItem(unsigned aIdx) const
Acces to an item in list.
SCH_SHEET_PATH m_SheetPathInclude
NET_CONNECTION_T
std::vector< NETLIST_OBJECT * > NETLIST_OBJECTS
Type NETLIST_OBJECTS is a container referring to (not owning) NETLIST_OBJECTs, which are connected it...
bool BuildNetListInfo(SCH_SHEET_LIST &aSheets)
Function BuildNetListInfo the master function of tgis class.
NET_CONNECTION_T m_ConnectionType
#define IS_BUS
SCH_SHEET_PATH m_SheetPath
void findBestNetNameForEachNet()
Function findBestNetNameForEachNet fill the .m_NetNameCandidate member of each item of aNetItemBuffer...
SCH_SCREEN * LastScreen() const
Function LastScreen.
NETLIST_ITEM_T m_Type
void labelConnect(NETLIST_OBJECT *aLabelRef)
SCH_ITEM * Next() const
void Clear()
Delete all objects in list and clear list.
void sheetLabelConnect(NETLIST_OBJECT *aSheetLabel)
Propagate net codes from a parent sheet to an include sheet, from a pin sheet connection.
wxString Path() const
Function Path the path uses the time stamps which do not changes even when editing sheet parameters a...
void segmentToPointConnect(NETLIST_OBJECT *aJonction, bool aIsBus, int aIdxStart)
Search connections between a junction and segments Propagate the junction net code to objects connect...
bool IsLabelType() const
Function IsLabelType.
static bool sortItemsBySheet(const NETLIST_OBJECT *Objet1, const NETLIST_OBJECT *Objet2)
int GetNet() const
bool IsLabelBusMemberType() const
Function IsLabelBusMemberType.
wxString PathHumanReadable() const
Function PathHumanReadable returns the sheet path in a human readable form, i.e.
static bool sortItemsbyNetcode(const NETLIST_OBJECT *Objet1, const NETLIST_OBJECT *Objet2)
void propagateNetCode(int aOldNetCode, int aNewNetCode, bool aIsBus)
#define IS_WIRE
Class SCH_SHEET_PATH.
bool IsInNetlist() const
SCH_COMPONENT * GetComponentParent() const
For Pins (NET_PINS):
Definitions for the Eeschema program SCH_SCREEN class.
SCH_ITEM * GetDrawItems() const
Definition: sch_screen.h:160
Definition the SCH_COMPONENT class for Eeschema.
size_t i
Definition: json11.cpp:597
void SetNet(int aNetCode)
void SetNetNameCandidate(NETLIST_OBJECT *aCandidate)
Set m_netNameCandidate to a connected item which will be used to calcule the net name of the item Obv...
Class SCH_COMPONENT describes a real schematic component.
Definition: sch_component.h:69
wxString GetShortNetName(bool adoptTimestamp=false) const
Function GetShortNetName.
void pointToPointConnect(NETLIST_OBJECT *aRef, bool aIsBus, int start)
bool HasNetNameCandidate()
Definition for part library class.
Definition of the NETLIST_OBJECT class.
Class SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container clas...
Implementation of the label properties dialog.
static int getPriority(const NETLIST_OBJECT *Objet)