KiCad PCB EDA Suite
netlist_object_list.cpp File Reference
#include <netlist_object.h>
#include <class_library.h>
#include <macros.h>
#include <sch_junction.h>
#include <sch_component.h>
#include <sch_line.h>
#include <sch_text.h>
#include <sch_screen.h>
#include <sch_sheet.h>
#include <algorithm>

Go to the source code of this file.

Macros

#define IS_WIRE   false
 
#define IS_BUS   true
 

Functions

static int getPriority (const NETLIST_OBJECT *Objet)
 
static bool evalLabelsPriority (const NETLIST_OBJECT *aLabel1, const NETLIST_OBJECT *aLabel2)
 

Macro Definition Documentation

◆ IS_BUS

#define IS_BUS   true

Definition at line 38 of file netlist_object_list.cpp.

◆ IS_WIRE

#define IS_WIRE   false

Definition at line 37 of file netlist_object_list.cpp.

Function Documentation

◆ evalLabelsPriority()

static bool evalLabelsPriority ( const NETLIST_OBJECT aLabel1,
const NETLIST_OBJECT aLabel2 
)
static

Definition at line 314 of file netlist_object_list.cpp.

315 {
316  // Global labels have the highest prioriy.
317  // For local labels: names are prefixed by their sheetpath
318  // use name defined in the more top level hierarchical sheet
319  // Note: the final net name uses human sheetpath name, not timestamp sheetpath name
320  // They are equivalent, but not for human readers.
321  if( ! aLabel1->IsLabelGlobal() && ! aLabel2->IsLabelGlobal() )
322  {
323  if( aLabel1->m_SheetPath.size() != aLabel2->m_SheetPath.size() )
324  return aLabel1->m_SheetPath.size() < aLabel2->m_SheetPath.size();
325  }
326 
327  int priority1 = getPriority( aLabel1 );
328  int priority2 = getPriority( aLabel2 );
329 
330  if( priority1 != priority2 )
331  return priority1 > priority2;
332 
333  // Objects have here the same priority, therefore they have the same type.
334  // for global labels, we select the best candidate by alphabetic order
335  // because they have no sheetpath as prefix name
336  // for other labels, we select them before by sheet deep order
337  // because the actual name is /sheetpath/label
338  // and for a given path length, by alphabetic order
339  if( aLabel1->IsLabelGlobal() )
340  return aLabel1->m_Label.Cmp( aLabel2->m_Label ) < 0;
341 
342  // Sheet paths have here the same length: use alphabetic label name order
343  // For labels on sheets having an equivalent deep in hierarchy, use
344  // alphabetic label name order:
345  if( aLabel1->m_Label.Cmp( aLabel2->m_Label ) != 0 )
346  return aLabel1->m_Label.Cmp( aLabel2->m_Label ) < 0;
347 
348  // For identical labels having the same priority: choose the
349  // alphabetic label full name order
350  return aLabel1->m_SheetPath.PathHumanReadable().Cmp(
351  aLabel2->m_SheetPath.PathHumanReadable() ) < 0;
352 }
SCH_SHEET_PATH m_SheetPath
bool IsLabelGlobal() const
Function IsLabelGlobal.
size_t size() const
Forwarded method from std::vector.
wxString PathHumanReadable() const
Function PathHumanReadable returns the sheet path in a human readable form, i.e.
static int getPriority(const NETLIST_OBJECT *Objet)

References getPriority(), NETLIST_OBJECT::IsLabelGlobal(), NETLIST_OBJECT::m_Label, NETLIST_OBJECT::m_SheetPath, SCH_SHEET_PATH::PathHumanReadable(), and SCH_SHEET_PATH::size().

Referenced by NETLIST_OBJECT_LIST::findBestNetNameForEachNet().

◆ getPriority()

static int getPriority ( const NETLIST_OBJECT Objet)
static

Definition at line 286 of file netlist_object_list.cpp.

287 {
288  switch( Objet->m_Type )
289  {
290  case NETLIST_ITEM::PIN:
291  return 1;
292  case NETLIST_ITEM::LABEL:
293  return 2;
295  return 3;
297  return 4;
299  return 5;
301  return 6;
302  default:
303  break;
304  }
305 
306  return 0;
307 }
NETLIST_ITEM m_Type

References GLOBBUSLABELMEMBER, GLOBLABEL, HIERLABEL, LABEL, NETLIST_OBJECT::m_Type, PIN, and PINLABEL.

Referenced by evalLabelsPriority().