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  // (i.e. shorter timestamp path because paths are /<timestamp1>/<timestamp2>/...
316  // and timestamp = 8 letters.
317  // Note: the final net name uses human sheetpath name, not timestamp sheetpath name
318  // They are equivalent, but not for human readers.
319  if( ! aLabel1->IsLabelGlobal() && ! aLabel2->IsLabelGlobal() )
320  {
321  if( aLabel1->m_SheetPath.Path().Length() != aLabel2->m_SheetPath.Path().Length() )
322  return aLabel1->m_SheetPath.Path().Length() < aLabel2->m_SheetPath.Path().Length();
323  }
324 
325  int priority1 = getPriority( aLabel1 );
326  int priority2 = getPriority( aLabel2 );
327 
328  if( priority1 != priority2 )
329  return priority1 > priority2;
330 
331  // Objects have here the same priority, therefore they have the same type.
332  // for global labels, we select the best candidate by alphabetic order
333  // because they have no sheetpath as prefix name
334  // for other labels, we select them before by sheet deep order
335  // because the actual name is /sheetpath/label
336  // and for a given path length, by alphabetic order
337  if( aLabel1->IsLabelGlobal() )
338  return aLabel1->m_Label.Cmp( aLabel2->m_Label ) < 0;
339 
340  // Sheet paths have here the same length: use alphabetic label name order
341  // For labels on sheets having an equivalent deep in hierarchy, use
342  // alphabetic label name order:
343  if( aLabel1->m_Label.Cmp( aLabel2->m_Label ) != 0 )
344  return aLabel1->m_Label.Cmp( aLabel2->m_Label ) < 0;
345 
346  // For identical labels having the same priority: choose the
347  // alphabetic label full name order
348  return aLabel1->m_SheetPath.PathHumanReadable().Cmp(
349  aLabel2->m_SheetPath.PathHumanReadable() ) < 0;
350 }
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 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().