From 74b675c1c0964fb425a9e010aaf74fedb44ec0dc Mon Sep 17 00:00:00 2001 From: Dick Hollenbeck Date: Sun, 1 Aug 2010 09:30:11 -0500 Subject: [PATCH 1/3] changelog --- CHANGELOG.txt | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 3a6f0df390..03b807a1da 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -4,18 +4,17 @@ KiCad ChangeLog 2010 Please add newer entries at the top, list the date and your name with email address. -2010-Jul-30 UPDATE Dick Hollenbeck +2010-Jul-30 & 31 UPDATE Dick Hollenbeck ================================================================================ ++eeschema: * Now link with XML support within wxWidgets. - * Start of export the generic netlist in XML. Still need to rework the chain - loaded netlist plugin. + * Export the generic netlist in XML. Only the libpart elements are missing now. + Still need to rework the chain loaded netlist plugin, but may do that in XSL. * OBJ_CMP_TO_LIST class now uses a std::string to hold the 8 bit string m_Ref, but hides this behind accessors which provide for both Unicode and 8 bit set and get functions. * build_BOM.cpp retains the selected filename on subsequent runs as a default. * Code cleaning, especially in build_BOM.cpp. - * Will work tomorrow also. 2010-jul-27, UPDATE Jean-Pierre Charras From 2213a347e91024b00e8bc15c9995fa2d5724f419 Mon Sep 17 00:00:00 2001 From: Dick Hollenbeck Date: Tue, 3 Aug 2010 00:11:05 -0500 Subject: [PATCH 2/3] netlist export speed optimizations, bug fix in NETLIST_HELP::FindAllInstancesOfComponent that I put in there yesterday. --- CHANGELOG.txt | 8 ++++++++ eeschema/class_netlist_object.cpp | 20 +++++++++++++++++- eeschema/class_pin.cpp | 13 ++++++++++++ eeschema/class_pin.h | 4 ++++ eeschema/class_sch_component.cpp | 2 +- eeschema/netform.cpp | 34 +------------------------------ eeschema/netlist.cpp | 22 ++++++++------------ 7 files changed, 54 insertions(+), 49 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 03b807a1da..2639735834 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -4,6 +4,14 @@ KiCad ChangeLog 2010 Please add newer entries at the top, list the date and your name with email address. +2010-Aug-3 UPDATE Dick Hollenbeck +================================================================================ +++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 ================================================================================ ++eeschema: diff --git a/eeschema/class_netlist_object.cpp b/eeschema/class_netlist_object.cpp index e710ff07ef..7fa0c7a2bf 100644 --- a/eeschema/class_netlist_object.cpp +++ b/eeschema/class_netlist_object.cpp @@ -83,10 +83,28 @@ void NETLIST_OBJECT::Show( std::ostream& out, int ndx ) if( !m_Label.IsEmpty() ) out << " \n"; + out << " " << m_SheetList.PathHumanReadable().mb_str() << "\n"; + + switch( m_Type ) + { + case NET_PIN: + out << " " << ((SCH_COMPONENT*)m_Link)->GetRef(&m_SheetList).mb_str() << "\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 ) - m_Comp->Show( 1, out ); + m_Comp->Show( 1, out ); // labels may not have good Show() funcs? else out << " m_Comp==NULL\n"; +*/ out << "\n"; } diff --git a/eeschema/class_pin.cpp b/eeschema/class_pin.cpp index ed0ee68029..629abd6fa1 100644 --- a/eeschema/class_pin.cpp +++ b/eeschema/class_pin.cpp @@ -1766,3 +1766,16 @@ const char*** LIB_PIN::GetStyleSymbols() 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 ) << "\n"; +} + +#endif diff --git a/eeschema/class_pin.h b/eeschema/class_pin.h index ee9aee4196..810eb96215 100644 --- a/eeschema/class_pin.h +++ b/eeschema/class_pin.h @@ -115,6 +115,10 @@ public: 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. diff --git a/eeschema/class_sch_component.cpp b/eeschema/class_sch_component.cpp index 8b4792ebaa..c7aa40a25a 100644 --- a/eeschema/class_sch_component.cpp +++ b/eeschema/class_sch_component.cpp @@ -934,7 +934,7 @@ void SCH_COMPONENT::Show( int nestLevel, std::ostream& os ) << '"' << " chipName=\"" << CONV_TO_UTF8( m_ChipName ) << '"' << m_Pos << " layer=\"" << m_Layer - << '"' << "/>\n"; + << '"' << ">\n"; // skip the reference, it's been output already. for( int i = 1; i < GetFieldCount(); ++i ) diff --git a/eeschema/netform.cpp b/eeschema/netform.cpp index 517fcf31c0..81da6d43dd 100644 --- a/eeschema/netform.cpp +++ b/eeschema/netform.cpp @@ -343,11 +343,6 @@ SCH_COMPONENT* NETLIST_HELP::findNextComponentAndCreatPinList( EDA_BaseStruct* a // Collect all parts and pins for this first occurance of reference. // This is only done once, it would be too expensive otherwise. 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 @@ -867,9 +862,6 @@ bool NETLIST_HELP::WriteNetListPCBNEW( WinEDA_SchematicFrame* frame, FILE* f, bo } ret |= fprintf( f, "\n" ); - printf( "%-10s pincount:%zu\n", CONV_TO_UTF8( comp->GetRef( path ) ), - m_SortedComponentPinList.size() ); - // Write pin list: for( unsigned ii = 0; ii < m_SortedComponentPinList.size(); ii++ ) { @@ -1086,32 +1078,8 @@ void NETLIST_HELP::FindAllInstancesOfComponent( SCH_COMPONENT* aComponent, if( pin->m_Convert && pin->m_Convert != comp2->m_Convert ) 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 - AddPinToComponentPinList( comp2, aSheetPath, 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 - + AddPinToComponentPinList( comp2, sheet, pin ); } } } diff --git a/eeschema/netlist.cpp b/eeschema/netlist.cpp index f9a1dc7b0c..52270a8ecf 100644 --- a/eeschema/netlist.cpp +++ b/eeschema/netlist.cpp @@ -18,7 +18,7 @@ // Buffer to build the list of items used in netlist and erc calculations NETLIST_OBJECT_LIST g_NetObjectslist; -#define NETLIST_DEBUG +//#define NETLIST_DEBUG static void PropageNetCode( int OldNetCode, int NewNetCode, int IsBus ); static void SheetLabelConnect( NETLIST_OBJECT* SheetLabel ); @@ -273,7 +273,7 @@ void WinEDA_SchematicFrame::BuildNetListBase() sort( g_NetObjectslist.begin(), g_NetObjectslist.end(), SortItemsbyNetcode ); #if defined(NETLIST_DEBUG) && defined(DEBUG) - std::cout << "after qsort()\n"; + std::cout << "\n\nafter qsort()\n"; dumpNetTable(); #endif @@ -467,7 +467,6 @@ static void AddConnectedObjects( SCH_SHEET_PATH* sheetlist, NETLIST_OBJECT* new_item; SCH_COMPONENT* DrawLibItem; LIB_COMPONENT* Entry; - LIB_PIN* pin; SCH_SHEET_PATH list; DrawList = sheetlist->LastScreen()->EEDrawList; @@ -587,24 +586,20 @@ static void AddConnectedObjects( SCH_SHEET_PATH* sheetlist, case TYPE_SCH_COMPONENT: DrawLibItem = (SCH_COMPONENT*) DrawList; - Entry = - CMP_LIBRARY::FindLibraryComponent( DrawLibItem->m_ChipName ); - + Entry = CMP_LIBRARY::FindLibraryComponent( DrawLibItem->m_ChipName ); if( Entry == NULL ) break; - for( pin = Entry->GetNextPin(); pin != NULL; - pin = Entry->GetNextPin( pin ) ) + for( LIB_PIN* pin = Entry->GetNextPin(); pin; pin = Entry->GetNextPin( pin ) ) { wxASSERT( pin->Type() == COMPONENT_PIN_DRAW_TYPE ); - if( pin->m_Unit - && ( pin->m_Unit != - DrawLibItem->GetUnitSelection( sheetlist ) ) ) + if( pin->m_Unit && + ( pin->m_Unit != DrawLibItem->GetUnitSelection( sheetlist ) ) ) continue; - if( pin->m_Convert - && ( pin->m_Convert != DrawLibItem->m_Convert ) ) + if( pin->m_Convert && + ( pin->m_Convert != DrawLibItem->m_Convert ) ) continue; wxPoint pos2 = @@ -640,7 +635,6 @@ static void AddConnectedObjects( SCH_SHEET_PATH* sheetlist, aNetItemBuffer.push_back( new_item ); } } - break; case DRAW_POLYLINE_STRUCT_TYPE: From df9dae6d8e9437e3166df2bde552732c637d28a6 Mon Sep 17 00:00:00 2001 From: Dick Hollenbeck Date: Tue, 3 Aug 2010 00:16:13 -0500 Subject: [PATCH 3/3] rename NETLIST_HELP to EXPORT_HELP to generalize it a bit --- eeschema/netform.cpp | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/eeschema/netform.cpp b/eeschema/netform.cpp index 81da6d43dd..67f98b9afc 100644 --- a/eeschema/netform.cpp +++ b/eeschema/netform.cpp @@ -92,12 +92,12 @@ bool UNIQUE_STRINGS::Lookup( const wxString& aString ) /** - * Class NETLIST_HELP + * Class EXPORT_HELP * is a private implementation class used in this source file to keep track * of and recycle datastructures used in the generation of various exported netlist * files. Since it is private it is not in a header file. */ -class NETLIST_HELP +class EXPORT_HELP { NETLIST_OBJECT_LIST m_SortedComponentPinList; @@ -178,7 +178,7 @@ bool WinEDA_SchematicFrame::WriteNetListFile( int aFormat, const wxString& aFull { bool ret = true; FILE* f = NULL; - NETLIST_HELP helper; + EXPORT_HELP helper; if( aFormat < NET_TYPE_CUSTOM1 ) { @@ -261,7 +261,7 @@ static bool sortPinsByNum( NETLIST_OBJECT* Pin1, NETLIST_OBJECT* Pin2 ) } -void NETLIST_HELP::sprintPinNetName( wxString* aResult, +void EXPORT_HELP::sprintPinNetName( wxString* aResult, const wxString& aNetNameFormat, NETLIST_OBJECT* aPin ) { int netcode = aPin->GetNet(); @@ -301,7 +301,7 @@ void NETLIST_HELP::sprintPinNetName( wxString* aResult, } -SCH_COMPONENT* NETLIST_HELP::findNextComponentAndCreatPinList( EDA_BaseStruct* aItem, +SCH_COMPONENT* EXPORT_HELP::findNextComponentAndCreatPinList( EDA_BaseStruct* aItem, SCH_SHEET_PATH* aSheetPath ) { wxString ref; @@ -398,7 +398,7 @@ static wxXmlNode* Node( const wxString& aName, const wxString& aTextualContent = * creates a generic netlist, now in XML. * @return bool - true if there were no errors, else false. */ -bool NETLIST_HELP::Write_GENERIC_NetList( WinEDA_SchematicFrame* frame, const wxString& aOutFileName ) +bool EXPORT_HELP::Write_GENERIC_NetList( WinEDA_SchematicFrame* frame, const wxString& aOutFileName ) { #if 1 // output the XML format netlist. @@ -631,7 +631,7 @@ bool NETLIST_HELP::Write_GENERIC_NetList( WinEDA_SchematicFrame* frame, const wx * [.-] Or PSpice gnucap are beginning * + + Gnucap and PSpice are ultimately NetList */ -void NETLIST_HELP::WriteNetListPspice( WinEDA_SchematicFrame* frame, FILE* f, bool use_netnames ) +void EXPORT_HELP::WriteNetListPspice( WinEDA_SchematicFrame* frame, FILE* f, bool use_netnames ) { char Line[1024]; SCH_SHEET_PATH* sheet; @@ -785,7 +785,7 @@ void NETLIST_HELP::WriteNetListPspice( WinEDA_SchematicFrame* frame, FILE* f, bo } -bool NETLIST_HELP::WriteNetListPCBNEW( WinEDA_SchematicFrame* frame, FILE* f, bool with_pcbnew ) +bool EXPORT_HELP::WriteNetListPCBNEW( WinEDA_SchematicFrame* frame, FILE* f, bool with_pcbnew ) { wxString field; wxString footprint; @@ -938,7 +938,7 @@ bool NETLIST_HELP::WriteNetListPCBNEW( WinEDA_SchematicFrame* frame, FILE* f, bo * a pin description is a pointer to the corresponding structure * created by BuildNetList() in the table g_NetObjectslist */ -bool NETLIST_HELP::AddPinToComponentPinList( SCH_COMPONENT* aComponent, +bool EXPORT_HELP::AddPinToComponentPinList( SCH_COMPONENT* aComponent, SCH_SHEET_PATH* aSheetPath, LIB_PIN* aPin ) { // Search the PIN description for Pin in g_NetObjectslist @@ -988,7 +988,7 @@ bool NETLIST_HELP::AddPinToComponentPinList( SCH_COMPONENT* aComponent, * given component. * Note: this list *MUST* be sorted by pin number (.m_PinNum member value) */ -void NETLIST_HELP::EraseDuplicatePins( NETLIST_OBJECT_LIST& aPinList ) +void EXPORT_HELP::EraseDuplicatePins( NETLIST_OBJECT_LIST& aPinList ) { if( aPinList.size() == 0 ) // Trivial case: component with no pin return; @@ -1043,7 +1043,7 @@ void NETLIST_HELP::EraseDuplicatePins( NETLIST_OBJECT_LIST& aPinList ) * Calls AddPinToComponentPinList() to and pins founds to the current * component pin list */ -void NETLIST_HELP::FindAllInstancesOfComponent( SCH_COMPONENT* aComponent, +void EXPORT_HELP::FindAllInstancesOfComponent( SCH_COMPONENT* aComponent, LIB_COMPONENT* aEntry, SCH_SHEET_PATH* aSheetPath ) { @@ -1089,7 +1089,7 @@ void NETLIST_HELP::FindAllInstancesOfComponent( SCH_COMPONENT* aComponent, /* Written in the file / net list (ranked by Netcode), and elements that are * connected */ -bool NETLIST_HELP::WriteGENERICListOfNetsTxt( FILE* f, NETLIST_OBJECT_LIST& aObjectsList ) +bool EXPORT_HELP::WriteGENERICListOfNetsTxt( FILE* f, NETLIST_OBJECT_LIST& aObjectsList ) { int ret = 0; int netCode; @@ -1179,7 +1179,7 @@ bool NETLIST_HELP::WriteGENERICListOfNetsTxt( FILE* f, NETLIST_OBJECT_LIST& aObj * Function WriteGENERICListOfNets * saves a netlist in xml format. */ -bool NETLIST_HELP::WriteGENERICListOfNets( wxXmlNode* aNode, NETLIST_OBJECT_LIST& aObjectsList ) +bool EXPORT_HELP::WriteGENERICListOfNets( wxXmlNode* aNode, NETLIST_OBJECT_LIST& aObjectsList ) { wxString netCodeTxt; wxString netName; @@ -1193,7 +1193,7 @@ bool NETLIST_HELP::WriteGENERICListOfNets( wxXmlNode* aNode, NETLIST_OBJECT_LIST wxString sNode = wxT( "node" ); wxString sFmtd = wxT( "%d" ); - wxXmlNode* xnet; + wxXmlNode* xnet = 0; int netCode; int lastNetCode = -1; int sameNetcodeCount = 0; @@ -1290,7 +1290,7 @@ wxString StartLine( wxT( "." ) ); * .. B * T3 1 *U1 * 14 */ -void NETLIST_HELP::WriteNetListCADSTAR( WinEDA_SchematicFrame* frame, FILE* f ) +void EXPORT_HELP::WriteNetListCADSTAR( WinEDA_SchematicFrame* frame, FILE* f ) { wxString StartCmpDesc = StartLine + wxT( "ADD_COM" ); wxString msg; @@ -1361,7 +1361,7 @@ void NETLIST_HELP::WriteNetListCADSTAR( WinEDA_SchematicFrame* frame, FILE* f ) *. B U1 100 * 6 CA */ -void NETLIST_HELP::WriteListOfNetsCADSTAR( FILE* f, NETLIST_OBJECT_LIST& aObjectsList ) +void EXPORT_HELP::WriteListOfNetsCADSTAR( FILE* f, NETLIST_OBJECT_LIST& aObjectsList ) { wxString InitNetDesc = StartLine + wxT( "ADD_TER" ); wxString StartNetDesc = StartLine + wxT( "TER" );