Commit 2213a347 authored by Dick Hollenbeck's avatar Dick Hollenbeck

netlist export speed optimizations, bug fix in...

netlist export speed optimizations, bug fix in NETLIST_HELP::FindAllInstancesOfComponent that I put in there yesterday.
parent 5d7410c9
...@@ -4,6 +4,14 @@ KiCad ChangeLog 2010 ...@@ -4,6 +4,14 @@ KiCad ChangeLog 2010
Please add newer entries at the top, list the date and your name with Please add newer entries at the top, list the date and your name with
email address. email address.
2010-Aug-3 UPDATE Dick Hollenbeck <dick@softplc.com>
================================================================================
++eeschema netlist.cpp and netform.cpp:
* Found several speed optimizations in the netlist export code.
* Now sort the pins properly if they have pin numbers like A1 and A10,
i.e. alphanumerics in them.
2010-Jul-30 & 31 UPDATE Dick Hollenbeck <dick@softplc.com> 2010-Jul-30 & 31 UPDATE Dick Hollenbeck <dick@softplc.com>
================================================================================ ================================================================================
++eeschema: ++eeschema:
......
...@@ -83,10 +83,28 @@ void NETLIST_OBJECT::Show( std::ostream& out, int ndx ) ...@@ -83,10 +83,28 @@ void NETLIST_OBJECT::Show( std::ostream& out, int ndx )
if( !m_Label.IsEmpty() ) if( !m_Label.IsEmpty() )
out << " <label>" << m_Label.mb_str() << "</label>\n"; out << " <label>" << m_Label.mb_str() << "</label>\n";
out << " <sheetpath>" << m_SheetList.PathHumanReadable().mb_str() << "</sheetpath>\n";
switch( m_Type )
{
case NET_PIN:
out << " <refOfComp>" << ((SCH_COMPONENT*)m_Link)->GetRef(&m_SheetList).mb_str() << "</refOfComp>\n";
if( m_Comp )
m_Comp->Show( 1, out );
break;
default:
// not all the m_Comp classes have working Show functions.
;
}
/* was segfault-ing
if( m_Comp ) if( m_Comp )
m_Comp->Show( 1, out ); m_Comp->Show( 1, out ); // labels may not have good Show() funcs?
else else
out << " m_Comp==NULL\n"; out << " m_Comp==NULL\n";
*/
out << "</netItem>\n"; out << "</netItem>\n";
} }
......
...@@ -1766,3 +1766,16 @@ const char*** LIB_PIN::GetStyleSymbols() ...@@ -1766,3 +1766,16 @@ const char*** LIB_PIN::GetStyleSymbols()
return s_icons_Pins_Shapes; return s_icons_Pins_Shapes;
} }
#if defined(DEBUG)
void LIB_PIN::Show( int nestLevel, std::ostream& os )
{
NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str()
<< " num=\"" << GetNumber().mb_str()
<< '"' << "/>\n";
// NestedSpace( nestLevel, os ) << "</" << GetClass().Lower().mb_str() << ">\n";
}
#endif
...@@ -115,6 +115,10 @@ public: ...@@ -115,6 +115,10 @@ public:
return wxT( "LIB_PIN" ); return wxT( "LIB_PIN" );
} }
#if defined(DEBUG)
void Show( int nestLevel, std::ostream& os ); // virtual override
#endif
/** /**
* Write pin object to a FILE in "*.lib" format. * Write pin object to a FILE in "*.lib" format.
......
...@@ -934,7 +934,7 @@ void SCH_COMPONENT::Show( int nestLevel, std::ostream& os ) ...@@ -934,7 +934,7 @@ void SCH_COMPONENT::Show( int nestLevel, std::ostream& os )
<< '"' << " chipName=\"" << '"' << " chipName=\""
<< CONV_TO_UTF8( m_ChipName ) << '"' << m_Pos << CONV_TO_UTF8( m_ChipName ) << '"' << m_Pos
<< " layer=\"" << m_Layer << " layer=\"" << m_Layer
<< '"' << "/>\n"; << '"' << ">\n";
// skip the reference, it's been output already. // skip the reference, it's been output already.
for( int i = 1; i < GetFieldCount(); ++i ) for( int i = 1; i < GetFieldCount(); ++i )
......
...@@ -343,11 +343,6 @@ SCH_COMPONENT* NETLIST_HELP::findNextComponentAndCreatPinList( EDA_BaseStruct* a ...@@ -343,11 +343,6 @@ SCH_COMPONENT* NETLIST_HELP::findNextComponentAndCreatPinList( EDA_BaseStruct* a
// Collect all parts and pins for this first occurance of reference. // Collect all parts and pins for this first occurance of reference.
// This is only done once, it would be too expensive otherwise. // This is only done once, it would be too expensive otherwise.
FindAllInstancesOfComponent( comp, entry, aSheetPath ); FindAllInstancesOfComponent( comp, entry, aSheetPath );
if( ref == wxString( wxT("U1") ) )
{
printf("U1 m_SortedComponentPinList.size():%zu\n", m_SortedComponentPinList.size() );
}
} }
else // entry->GetPartCount() <= 1 means one part per package else // entry->GetPartCount() <= 1 means one part per package
...@@ -867,9 +862,6 @@ bool NETLIST_HELP::WriteNetListPCBNEW( WinEDA_SchematicFrame* frame, FILE* f, bo ...@@ -867,9 +862,6 @@ bool NETLIST_HELP::WriteNetListPCBNEW( WinEDA_SchematicFrame* frame, FILE* f, bo
} }
ret |= fprintf( f, "\n" ); ret |= fprintf( f, "\n" );
printf( "%-10s pincount:%zu\n", CONV_TO_UTF8( comp->GetRef( path ) ),
m_SortedComponentPinList.size() );
// Write pin list: // Write pin list:
for( unsigned ii = 0; ii < m_SortedComponentPinList.size(); ii++ ) for( unsigned ii = 0; ii < m_SortedComponentPinList.size(); ii++ )
{ {
...@@ -1086,32 +1078,8 @@ void NETLIST_HELP::FindAllInstancesOfComponent( SCH_COMPONENT* aComponent, ...@@ -1086,32 +1078,8 @@ void NETLIST_HELP::FindAllInstancesOfComponent( SCH_COMPONENT* aComponent,
if( pin->m_Convert && pin->m_Convert != comp2->m_Convert ) if( pin->m_Convert && pin->m_Convert != comp2->m_Convert )
continue; continue;
#if defined(DEBUG)
printf( "AddPin %s %s\n", CONV_TO_UTF8(ref), CONV_TO_UTF8( pin->GetNumber() ) );
if( ref == wxString( wxT("U1") ) && pin->GetNumber() == wxString( wxT("A1") ) )
{
int debug = 1;
}
bool rc =
#endif
// A suitable pin is found: add it to the current list // A suitable pin is found: add it to the current list
AddPinToComponentPinList( comp2, aSheetPath, pin ); AddPinToComponentPinList( comp2, sheet, pin );
#if defined(DEBUG)
if( !rc )
{
printf("skipped pin %s %s\n",
CONV_TO_UTF8(ref),
CONV_TO_UTF8( pin->GetNumber() ) );
printf( "g_NetObjectslist.size():%zu\n",
g_NetObjectslist.size() );
}
#endif
} }
} }
} }
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
// Buffer to build the list of items used in netlist and erc calculations // Buffer to build the list of items used in netlist and erc calculations
NETLIST_OBJECT_LIST g_NetObjectslist; NETLIST_OBJECT_LIST g_NetObjectslist;
#define NETLIST_DEBUG //#define NETLIST_DEBUG
static void PropageNetCode( int OldNetCode, int NewNetCode, int IsBus ); static void PropageNetCode( int OldNetCode, int NewNetCode, int IsBus );
static void SheetLabelConnect( NETLIST_OBJECT* SheetLabel ); static void SheetLabelConnect( NETLIST_OBJECT* SheetLabel );
...@@ -273,7 +273,7 @@ void WinEDA_SchematicFrame::BuildNetListBase() ...@@ -273,7 +273,7 @@ void WinEDA_SchematicFrame::BuildNetListBase()
sort( g_NetObjectslist.begin(), g_NetObjectslist.end(), SortItemsbyNetcode ); sort( g_NetObjectslist.begin(), g_NetObjectslist.end(), SortItemsbyNetcode );
#if defined(NETLIST_DEBUG) && defined(DEBUG) #if defined(NETLIST_DEBUG) && defined(DEBUG)
std::cout << "after qsort()\n"; std::cout << "\n\nafter qsort()\n";
dumpNetTable(); dumpNetTable();
#endif #endif
...@@ -467,7 +467,6 @@ static void AddConnectedObjects( SCH_SHEET_PATH* sheetlist, ...@@ -467,7 +467,6 @@ static void AddConnectedObjects( SCH_SHEET_PATH* sheetlist,
NETLIST_OBJECT* new_item; NETLIST_OBJECT* new_item;
SCH_COMPONENT* DrawLibItem; SCH_COMPONENT* DrawLibItem;
LIB_COMPONENT* Entry; LIB_COMPONENT* Entry;
LIB_PIN* pin;
SCH_SHEET_PATH list; SCH_SHEET_PATH list;
DrawList = sheetlist->LastScreen()->EEDrawList; DrawList = sheetlist->LastScreen()->EEDrawList;
...@@ -587,24 +586,20 @@ static void AddConnectedObjects( SCH_SHEET_PATH* sheetlist, ...@@ -587,24 +586,20 @@ static void AddConnectedObjects( SCH_SHEET_PATH* sheetlist,
case TYPE_SCH_COMPONENT: case TYPE_SCH_COMPONENT:
DrawLibItem = (SCH_COMPONENT*) DrawList; DrawLibItem = (SCH_COMPONENT*) DrawList;
Entry = Entry = CMP_LIBRARY::FindLibraryComponent( DrawLibItem->m_ChipName );
CMP_LIBRARY::FindLibraryComponent( DrawLibItem->m_ChipName );
if( Entry == NULL ) if( Entry == NULL )
break; break;
for( pin = Entry->GetNextPin(); pin != NULL; for( LIB_PIN* pin = Entry->GetNextPin(); pin; pin = Entry->GetNextPin( pin ) )
pin = Entry->GetNextPin( pin ) )
{ {
wxASSERT( pin->Type() == COMPONENT_PIN_DRAW_TYPE ); wxASSERT( pin->Type() == COMPONENT_PIN_DRAW_TYPE );
if( pin->m_Unit if( pin->m_Unit &&
&& ( pin->m_Unit != ( pin->m_Unit != DrawLibItem->GetUnitSelection( sheetlist ) ) )
DrawLibItem->GetUnitSelection( sheetlist ) ) )
continue; continue;
if( pin->m_Convert if( pin->m_Convert &&
&& ( pin->m_Convert != DrawLibItem->m_Convert ) ) ( pin->m_Convert != DrawLibItem->m_Convert ) )
continue; continue;
wxPoint pos2 = wxPoint pos2 =
...@@ -640,7 +635,6 @@ static void AddConnectedObjects( SCH_SHEET_PATH* sheetlist, ...@@ -640,7 +635,6 @@ static void AddConnectedObjects( SCH_SHEET_PATH* sheetlist,
aNetItemBuffer.push_back( new_item ); aNetItemBuffer.push_back( new_item );
} }
} }
break; break;
case DRAW_POLYLINE_STRUCT_TYPE: case DRAW_POLYLINE_STRUCT_TYPE:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment