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 301 of file netlist_object_list.cpp.

302 {
303  // Global labels have the highest prioriy.
304  // For local labels: names are prefixed by their sheetpath
305  // use name defined in the more top level hierarchical sheet
306  // (i.e. shorter timestamp path because paths are /<timestamp1>/<timestamp2>/...
307  // and timestamp = 8 letters.
308  // Note: the final net name uses human sheetpath name, not timestamp sheetpath name
309  // They are equivalent, but not for human readers.
310  if( ! aLabel1->IsLabelGlobal() && ! aLabel2->IsLabelGlobal() )
311  {
312  if( aLabel1->m_SheetPath.Path().Length() != aLabel2->m_SheetPath.Path().Length() )
313  return aLabel1->m_SheetPath.Path().Length() < aLabel2->m_SheetPath.Path().Length();
314  }
315 
316  int priority1 = getPriority( aLabel1 );
317  int priority2 = getPriority( aLabel2 );
318 
319  if( priority1 != priority2 )
320  return priority1 > priority2;
321 
322  // Objects have here the same priority, therefore they have the same type.
323  // for global labels, we select the best candidate by alphabetic order
324  // because they have no sheetpath as prefix name
325  // for other labels, we select them before by sheet deep order
326  // because the actual name is /sheetpath/label
327  // and for a given path length, by alphabetic order
328  if( aLabel1->IsLabelGlobal() )
329  return aLabel1->m_Label.Cmp( aLabel2->m_Label ) < 0;
330 
331  // Sheet paths have here the same length: use alphabetic label name order
332  // For labels on sheets having an equivalent deep in hierarchy, use
333  // alphabetic label name order:
334  if( aLabel1->m_Label.Cmp( aLabel2->m_Label ) != 0 )
335  return aLabel1->m_Label.Cmp( aLabel2->m_Label ) < 0;
336 
337  // For identical labels having the same priority: choose the
338  // alphabetic label full name order
339  return aLabel1->m_SheetPath.PathHumanReadable().Cmp(
340  aLabel2->m_SheetPath.PathHumanReadable() ) < 0;
341 }
SCH_SHEET_PATH m_SheetPath
bool IsLabelGlobal() const
Function IsLabelGlobal.
wxString Path() const
Function Path the path uses the time stamps which do not changes even when editing sheet parameters a...
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::Path(), and SCH_SHEET_PATH::PathHumanReadable().

Referenced by NETLIST_OBJECT_LIST::findBestNetNameForEachNet().

◆ getPriority()

static int getPriority ( const NETLIST_OBJECT Objet)
static

Definition at line 280 of file netlist_object_list.cpp.

281 {
282  switch( Objet->m_Type )
283  {
284  case NET_PIN: return 1;
285  case NET_LABEL: return 2;
286  case NET_HIERLABEL: return 3;
287  case NET_PINLABEL: return 4;
288  case NET_GLOBBUSLABELMEMBER: return 5;
289  case NET_GLOBLABEL: return 6;
290  default: break;
291  }
292 
293  return 0;
294 }
NETLIST_ITEM_T m_Type

References NETLIST_OBJECT::m_Type, NET_GLOBBUSLABELMEMBER, NET_GLOBLABEL, NET_HIERLABEL, NET_LABEL, NET_PIN, and NET_PINLABEL.

Referenced by evalLabelsPriority().