KiCad PCB EDA Suite
netlist_object_list.cpp File Reference
#include <netlist_object.h>
#include <class_library.h>
#include <sch_junction.h>
#include <sch_component.h>
#include <sch_line.h>
#include <sch_text.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 36 of file netlist_object_list.cpp.

◆ IS_WIRE

#define IS_WIRE   false

Definition at line 35 of file netlist_object_list.cpp.

Function Documentation

◆ evalLabelsPriority()

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

Definition at line 310 of file netlist_object_list.cpp.

311 {
312  // Global labels have the highest prioriy.
313  // For local labels: names are prefixed by their sheetpath
314  // use name defined in the more top level hierarchical sheet
315  // Note: the final net name uses human sheetpath name, not timestamp sheetpath name
316  // They are equivalent, but not for human readers.
317  if( ! aLabel1->IsLabelGlobal() && ! aLabel2->IsLabelGlobal() )
318  {
319  if( aLabel1->m_SheetPath.size() != aLabel2->m_SheetPath.size() )
320  return aLabel1->m_SheetPath.size() < aLabel2->m_SheetPath.size();
321  }
322 
323  int priority1 = getPriority( aLabel1 );
324  int priority2 = getPriority( aLabel2 );
325 
326  if( priority1 != priority2 )
327  return priority1 > priority2;
328 
329  // Objects have here the same priority, therefore they have the same type.
330  // for global labels, we select the best candidate by alphabetic order
331  // because they have no sheetpath as prefix name
332  // for other labels, we select them before by sheet deep order
333  // because the actual name is /sheetpath/label
334  // and for a given path length, by alphabetic order
335  if( aLabel1->IsLabelGlobal() )
336  return aLabel1->m_Label.Cmp( aLabel2->m_Label ) < 0;
337 
338  // Sheet paths have here the same length: use alphabetic label name order
339  // For labels on sheets having an equivalent deep in hierarchy, use
340  // alphabetic label name order:
341  if( aLabel1->m_Label.Cmp( aLabel2->m_Label ) != 0 )
342  return aLabel1->m_Label.Cmp( aLabel2->m_Label ) < 0;
343 
344  // For identical labels having the same priority: choose the
345  // alphabetic label full name order
346  return aLabel1->m_SheetPath.PathHumanReadable().Cmp(
347  aLabel2->m_SheetPath.PathHumanReadable() ) < 0;
348 }
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 282 of file netlist_object_list.cpp.

283 {
284  switch( Objet->m_Type )
285  {
286  case NETLIST_ITEM::PIN:
287  return 1;
288  case NETLIST_ITEM::LABEL:
289  return 2;
291  return 3;
293  return 4;
295  return 5;
297  return 6;
298  default:
299  break;
300  }
301 
302  return 0;
303 }
NETLIST_ITEM m_Type

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

Referenced by evalLabelsPriority().