KiCad PCB EDA Suite
netlist_object_list.cpp File Reference
#include <netlist.h>
#include <netlist_object.h>
#include <class_library.h>
#include <lib_pin.h>
#include <sch_junction.h>
#include <sch_component.h>
#include <sch_line.h>
#include <sch_no_connect.h>
#include <sch_text.h>
#include <sch_sheet.h>
#include <sch_screen.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

#define IS_BUS   true

Function Documentation

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

Definition at line 309 of file netlist_object_list.cpp.

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().

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 }
bool IsLabelGlobal() const
Function IsLabelGlobal.
SCH_SHEET_PATH m_SheetPath
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)
static int getPriority ( const NETLIST_OBJECT Objet)
static

Definition at line 288 of file netlist_object_list.cpp.

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

Referenced by evalLabelsPriority().

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 }
NETLIST_ITEM_T m_Type