Loading common/ptree.cpp +5 −1 Original line number Original line Diff line number Diff line Loading @@ -83,7 +83,11 @@ inline void scanAtom( PTREE* aTree, DSNLEXER* aLexer ) //D(printf( "%s: '%s'\n", __func__, key );) //D(printf( "%s: '%s'\n", __func__, key );) #if 0 aTree->push_back( PTREE::value_type( key, PTREE() ) ); aTree->push_back( PTREE::value_type( key, PTREE() ) ); #else aTree->put_value( key ); #endif } } Loading Loading @@ -190,7 +194,7 @@ static void formatNode( OUTPUTFORMATTER* out, int aNestLevel, int aCtl, out->Print( aNestLevel, "(%s%s", out->Quotes( aKey ).c_str(), ctl & CTL_OMIT_NL ? "" : "\n" ); out->Print( aNestLevel, "(%s%s", out->Quotes( aKey ).c_str(), ctl & CTL_OMIT_NL ? "" : "\n" ); if( aTree.data().size() ) // only xml typically uses "data()", not sexpr. if( aTree.data().size() ) { { out->Print( 0, " %s%s", out->Print( 0, " %s%s", out->Quotes( aTree.data() ).c_str(), out->Quotes( aTree.data() ).c_str(), Loading cvpcb/readwrite_dlgs.cpp +18 −0 Original line number Original line Diff line number Diff line Loading @@ -28,6 +28,7 @@ */ */ #include <fctsys.h> #include <fctsys.h> #include <kiway.h> #include <common.h> #include <common.h> #include <confirm.h> #include <confirm.h> #include <build_version.h> #include <build_version.h> Loading Loading @@ -343,6 +344,11 @@ int CVPCB_MAINFRAME::SaveCmpLinkFile( const wxString& aFullFileName ) if( !fn.HasExt() ) if( !fn.HasExt() ) fn.SetExt( ComponentFileExtension ); fn.SetExt( ComponentFileExtension ); #if 0 // RHH 6-Jul-14: We did not auto generate the // footprint table. And the dialog which does suppport editing does the saving. // Besides, this is not the place to do this, it belies the name of this // function. // Save the project specific footprint library table. // Save the project specific footprint library table. if( !Prj().PcbFootprintLibs()->IsEmpty( false ) ) if( !Prj().PcbFootprintLibs()->IsEmpty( false ) ) { { Loading @@ -368,6 +374,8 @@ int CVPCB_MAINFRAME::SaveCmpLinkFile( const wxString& aFullFileName ) } } } } } } #endif } } if( !IsWritable( fn.GetFullPath() ) ) if( !IsWritable( fn.GetFullPath() ) ) Loading @@ -380,6 +388,16 @@ int CVPCB_MAINFRAME::SaveCmpLinkFile( const wxString& aFullFileName ) } } wxString msg = wxString::Format( _("File %s saved"), GetChars( fn.GetFullPath() ) ); wxString msg = wxString::Format( _("File %s saved"), GetChars( fn.GetFullPath() ) ); // Perhaps this replaces all of the above someday. { STRING_FORMATTER sf; m_netlist.FormatBackAnnotation( &sf ); Kiway().ExpressMail( FRAME_SCH, MAIL_BACKANNOTATE_FOOTPRINTS, sf.GetString() ); } SetStatusText( msg ); SetStatusText( msg ); return 1; return 1; } } eeschema/backanno.cpp +88 −17 Original line number Original line Diff line number Diff line Loading @@ -42,15 +42,84 @@ #include <sch_component.h> #include <sch_component.h> #include <netlist.h> #include <netlist.h> #include <dsnlexer.h> #include <ptree.h> #include <boost/property_tree/ptree.hpp> bool SCH_EDIT_FRAME::ProcessCmpToFootprintLinkFile( wxString& aFullFilename, void SCH_EDIT_FRAME::backAnnotateFootprints( const std::string& aChangedSetOfReferences ) throw( IO_ERROR ) { // Build a flat list of components in schematic: SCH_REFERENCE_LIST refs; SCH_SHEET_LIST sheets; bool isChanged = false; sheets.GetComponents( refs, false ); static const KEYWORD empty_keywords[1] = {}; DSNLEXER lexer( empty_keywords, 0, aChangedSetOfReferences, FROM_UTF8( __func__ ) ); PTREE doc; Scan( &doc, &lexer ); #if defined(DEBUG) && 0 STRING_FORMATTER sf; Format( &sf, 0, 0, doc ); printf( "%s: '%s'\n", __func__, sf.GetString().c_str() ); #endif CPTREE& back_anno = doc.get_child( "back_annotation" ); for( PTREE::const_iterator ref = back_anno.begin(); ref != back_anno.end(); ++ref ) { wxASSERT( ref->first == "ref" ); wxString reference = (UTF8&) ref->second.data(); wxString footprint = (UTF8) ref->second.get<std::string>( "fpid" ); // DBG( printf( "%s: ref:%s fpid:%s\n", __func__, TO_UTF8( reference ), TO_UTF8( footprint ) ); ) // Search the component in the flat list for( unsigned ii = 0; ii < refs.GetCount(); ++ii ) { if( Cmp_KEEPCASE( reference, refs[ii].GetRef() ) == 0 ) { // We have found a candidate. // Note: it can be not unique (multiple parts per package) // So we *do not* stop the search here SCH_COMPONENT* component = refs[ii].GetComponent(); SCH_FIELD* fpfield = component->GetField( FOOTPRINT ); const wxString& oldfp = fpfield->GetText(); if( !oldfp && fpfield->IsVisible() ) { fpfield->SetVisible( false ); } // DBG( printf("%s: ref:%s fpid:%s\n", __func__, TO_UTF8( refs[ii].GetRef() ), TO_UTF8( footprint ) );) fpfield->SetText( footprint ); if( oldfp != footprint ) isChanged = true; } } } if( isChanged ) OnModify(); } bool SCH_EDIT_FRAME::ProcessCmpToFootprintLinkFile( const wxString& aFullFilename, bool aForceFieldsVisibleAttribute, bool aForceFieldsVisibleAttribute, bool aFieldsVisibleAttributeState ) bool aFieldsVisibleAttributeState ) { { // Build a flat list of components in schematic: // Build a flat list of components in schematic: SCH_REFERENCE_LIST referencesList; SCH_REFERENCE_LIST referencesList; SCH_SHEET_LIST SheetList; SCH_SHEET_LIST SheetList; SheetList.GetComponents( referencesList, false ); SheetList.GetComponents( referencesList, false ); FILE* cmpFile = wxFopen( aFullFilename, wxT( "rt" ) ); FILE* cmpFile = wxFopen( aFullFilename, wxT( "rt" ) ); Loading Loading @@ -94,13 +163,10 @@ bool SCH_EDIT_FRAME::ProcessCmpToFootprintLinkFile( wxString& aFullFilename, if( buffer.StartsWith( wxT("Reference") ) ) if( buffer.StartsWith( wxT("Reference") ) ) { { reference = value; reference = value; continue; } } else if( buffer.StartsWith( wxT("IdModule =" ) ) ) if( buffer.StartsWith( wxT("IdModule =" ) ) ) { { footprint = value; footprint = value; continue; } } } } Loading @@ -108,16 +174,18 @@ bool SCH_EDIT_FRAME::ProcessCmpToFootprintLinkFile( wxString& aFullFilename, // if the footprint name is not empty // if the footprint name is not empty if( reference.IsEmpty() ) if( reference.IsEmpty() ) continue; continue; // Search the component in the flat list // Search the component in the flat list for( unsigned ii = 0; ii < referencesList.GetCount(); ii++ ) for( unsigned ii = 0; ii < referencesList.GetCount(); ii++ ) { { if( reference.CmpNoCase( referencesList[ii].GetRef() ) == 0 ) if( Cmp_KEEPCASE( reference, referencesList[ii].GetRef() ) == 0 ) { { // We have found a candidate. // We have found a candidate. // Note: it can be not unique (multiple parts per package) // Note: it can be not unique (multiple parts per package) // So we *do not* stop the search here // So we *do not* stop the search here SCH_COMPONENT* component = referencesList[ii].GetComponent(); SCH_COMPONENT* component = referencesList[ii].GetComponent(); SCH_FIELD* fpfield = component->GetField( FOOTPRINT ); SCH_FIELD* fpfield = component->GetField( FOOTPRINT ); fpfield->SetText( footprint ); fpfield->SetText( footprint ); if( aForceFieldsVisibleAttribute ) if( aForceFieldsVisibleAttribute ) Loading @@ -128,6 +196,7 @@ bool SCH_EDIT_FRAME::ProcessCmpToFootprintLinkFile( wxString& aFullFilename, } } } } } } return true; return true; } } Loading Loading @@ -172,8 +241,10 @@ bool SCH_EDIT_FRAME::LoadCmpToFootprintLinkFile() if( !ProcessCmpToFootprintLinkFile( filename, changevisibility, visible ) ) if( !ProcessCmpToFootprintLinkFile( filename, changevisibility, visible ) ) { { wxString msg; wxString msg = wxString::Format( _( msg.Printf( _( "Failed to open component-footprint link file <%s>" ), filename.GetData() ); "Failed to open component-footprint link file '%s'" ), filename.GetData() ); DisplayError( this, msg ); DisplayError( this, msg ); return false; return false; } } Loading eeschema/cross-probing.cpp +12 −0 Original line number Original line Diff line number Diff line Loading @@ -196,8 +196,20 @@ void SCH_EDIT_FRAME::KiwayMailIn( KIWAY_EXPRESS& mail ) ExecuteRemoteCommand( payload.c_str() ); ExecuteRemoteCommand( payload.c_str() ); break; break; case MAIL_BACKANNOTATE_FOOTPRINTS: try { backAnnotateFootprints( payload ); } catch( const IO_ERROR& ioe ) { DBG( printf( "%s: ioe:%s\n", __func__, TO_UTF8( ioe.errorText ) );) } break; // many many others. // many many others. } } } } include/fp_lib_table.h +0 −3 Original line number Original line Diff line number Diff line Loading @@ -39,9 +39,6 @@ class OUTPUTFORMATTER; class MODULE; class MODULE; class FP_LIB_TABLE_LEXER; class FP_LIB_TABLE_LEXER; class FPID; class FPID; class NETLIST; class REPORTER; class SEARCH_STACK; /** /** * Class FP_LIB_TABLE * Class FP_LIB_TABLE Loading Loading
common/ptree.cpp +5 −1 Original line number Original line Diff line number Diff line Loading @@ -83,7 +83,11 @@ inline void scanAtom( PTREE* aTree, DSNLEXER* aLexer ) //D(printf( "%s: '%s'\n", __func__, key );) //D(printf( "%s: '%s'\n", __func__, key );) #if 0 aTree->push_back( PTREE::value_type( key, PTREE() ) ); aTree->push_back( PTREE::value_type( key, PTREE() ) ); #else aTree->put_value( key ); #endif } } Loading Loading @@ -190,7 +194,7 @@ static void formatNode( OUTPUTFORMATTER* out, int aNestLevel, int aCtl, out->Print( aNestLevel, "(%s%s", out->Quotes( aKey ).c_str(), ctl & CTL_OMIT_NL ? "" : "\n" ); out->Print( aNestLevel, "(%s%s", out->Quotes( aKey ).c_str(), ctl & CTL_OMIT_NL ? "" : "\n" ); if( aTree.data().size() ) // only xml typically uses "data()", not sexpr. if( aTree.data().size() ) { { out->Print( 0, " %s%s", out->Print( 0, " %s%s", out->Quotes( aTree.data() ).c_str(), out->Quotes( aTree.data() ).c_str(), Loading
cvpcb/readwrite_dlgs.cpp +18 −0 Original line number Original line Diff line number Diff line Loading @@ -28,6 +28,7 @@ */ */ #include <fctsys.h> #include <fctsys.h> #include <kiway.h> #include <common.h> #include <common.h> #include <confirm.h> #include <confirm.h> #include <build_version.h> #include <build_version.h> Loading Loading @@ -343,6 +344,11 @@ int CVPCB_MAINFRAME::SaveCmpLinkFile( const wxString& aFullFileName ) if( !fn.HasExt() ) if( !fn.HasExt() ) fn.SetExt( ComponentFileExtension ); fn.SetExt( ComponentFileExtension ); #if 0 // RHH 6-Jul-14: We did not auto generate the // footprint table. And the dialog which does suppport editing does the saving. // Besides, this is not the place to do this, it belies the name of this // function. // Save the project specific footprint library table. // Save the project specific footprint library table. if( !Prj().PcbFootprintLibs()->IsEmpty( false ) ) if( !Prj().PcbFootprintLibs()->IsEmpty( false ) ) { { Loading @@ -368,6 +374,8 @@ int CVPCB_MAINFRAME::SaveCmpLinkFile( const wxString& aFullFileName ) } } } } } } #endif } } if( !IsWritable( fn.GetFullPath() ) ) if( !IsWritable( fn.GetFullPath() ) ) Loading @@ -380,6 +388,16 @@ int CVPCB_MAINFRAME::SaveCmpLinkFile( const wxString& aFullFileName ) } } wxString msg = wxString::Format( _("File %s saved"), GetChars( fn.GetFullPath() ) ); wxString msg = wxString::Format( _("File %s saved"), GetChars( fn.GetFullPath() ) ); // Perhaps this replaces all of the above someday. { STRING_FORMATTER sf; m_netlist.FormatBackAnnotation( &sf ); Kiway().ExpressMail( FRAME_SCH, MAIL_BACKANNOTATE_FOOTPRINTS, sf.GetString() ); } SetStatusText( msg ); SetStatusText( msg ); return 1; return 1; } }
eeschema/backanno.cpp +88 −17 Original line number Original line Diff line number Diff line Loading @@ -42,15 +42,84 @@ #include <sch_component.h> #include <sch_component.h> #include <netlist.h> #include <netlist.h> #include <dsnlexer.h> #include <ptree.h> #include <boost/property_tree/ptree.hpp> bool SCH_EDIT_FRAME::ProcessCmpToFootprintLinkFile( wxString& aFullFilename, void SCH_EDIT_FRAME::backAnnotateFootprints( const std::string& aChangedSetOfReferences ) throw( IO_ERROR ) { // Build a flat list of components in schematic: SCH_REFERENCE_LIST refs; SCH_SHEET_LIST sheets; bool isChanged = false; sheets.GetComponents( refs, false ); static const KEYWORD empty_keywords[1] = {}; DSNLEXER lexer( empty_keywords, 0, aChangedSetOfReferences, FROM_UTF8( __func__ ) ); PTREE doc; Scan( &doc, &lexer ); #if defined(DEBUG) && 0 STRING_FORMATTER sf; Format( &sf, 0, 0, doc ); printf( "%s: '%s'\n", __func__, sf.GetString().c_str() ); #endif CPTREE& back_anno = doc.get_child( "back_annotation" ); for( PTREE::const_iterator ref = back_anno.begin(); ref != back_anno.end(); ++ref ) { wxASSERT( ref->first == "ref" ); wxString reference = (UTF8&) ref->second.data(); wxString footprint = (UTF8) ref->second.get<std::string>( "fpid" ); // DBG( printf( "%s: ref:%s fpid:%s\n", __func__, TO_UTF8( reference ), TO_UTF8( footprint ) ); ) // Search the component in the flat list for( unsigned ii = 0; ii < refs.GetCount(); ++ii ) { if( Cmp_KEEPCASE( reference, refs[ii].GetRef() ) == 0 ) { // We have found a candidate. // Note: it can be not unique (multiple parts per package) // So we *do not* stop the search here SCH_COMPONENT* component = refs[ii].GetComponent(); SCH_FIELD* fpfield = component->GetField( FOOTPRINT ); const wxString& oldfp = fpfield->GetText(); if( !oldfp && fpfield->IsVisible() ) { fpfield->SetVisible( false ); } // DBG( printf("%s: ref:%s fpid:%s\n", __func__, TO_UTF8( refs[ii].GetRef() ), TO_UTF8( footprint ) );) fpfield->SetText( footprint ); if( oldfp != footprint ) isChanged = true; } } } if( isChanged ) OnModify(); } bool SCH_EDIT_FRAME::ProcessCmpToFootprintLinkFile( const wxString& aFullFilename, bool aForceFieldsVisibleAttribute, bool aForceFieldsVisibleAttribute, bool aFieldsVisibleAttributeState ) bool aFieldsVisibleAttributeState ) { { // Build a flat list of components in schematic: // Build a flat list of components in schematic: SCH_REFERENCE_LIST referencesList; SCH_REFERENCE_LIST referencesList; SCH_SHEET_LIST SheetList; SCH_SHEET_LIST SheetList; SheetList.GetComponents( referencesList, false ); SheetList.GetComponents( referencesList, false ); FILE* cmpFile = wxFopen( aFullFilename, wxT( "rt" ) ); FILE* cmpFile = wxFopen( aFullFilename, wxT( "rt" ) ); Loading Loading @@ -94,13 +163,10 @@ bool SCH_EDIT_FRAME::ProcessCmpToFootprintLinkFile( wxString& aFullFilename, if( buffer.StartsWith( wxT("Reference") ) ) if( buffer.StartsWith( wxT("Reference") ) ) { { reference = value; reference = value; continue; } } else if( buffer.StartsWith( wxT("IdModule =" ) ) ) if( buffer.StartsWith( wxT("IdModule =" ) ) ) { { footprint = value; footprint = value; continue; } } } } Loading @@ -108,16 +174,18 @@ bool SCH_EDIT_FRAME::ProcessCmpToFootprintLinkFile( wxString& aFullFilename, // if the footprint name is not empty // if the footprint name is not empty if( reference.IsEmpty() ) if( reference.IsEmpty() ) continue; continue; // Search the component in the flat list // Search the component in the flat list for( unsigned ii = 0; ii < referencesList.GetCount(); ii++ ) for( unsigned ii = 0; ii < referencesList.GetCount(); ii++ ) { { if( reference.CmpNoCase( referencesList[ii].GetRef() ) == 0 ) if( Cmp_KEEPCASE( reference, referencesList[ii].GetRef() ) == 0 ) { { // We have found a candidate. // We have found a candidate. // Note: it can be not unique (multiple parts per package) // Note: it can be not unique (multiple parts per package) // So we *do not* stop the search here // So we *do not* stop the search here SCH_COMPONENT* component = referencesList[ii].GetComponent(); SCH_COMPONENT* component = referencesList[ii].GetComponent(); SCH_FIELD* fpfield = component->GetField( FOOTPRINT ); SCH_FIELD* fpfield = component->GetField( FOOTPRINT ); fpfield->SetText( footprint ); fpfield->SetText( footprint ); if( aForceFieldsVisibleAttribute ) if( aForceFieldsVisibleAttribute ) Loading @@ -128,6 +196,7 @@ bool SCH_EDIT_FRAME::ProcessCmpToFootprintLinkFile( wxString& aFullFilename, } } } } } } return true; return true; } } Loading Loading @@ -172,8 +241,10 @@ bool SCH_EDIT_FRAME::LoadCmpToFootprintLinkFile() if( !ProcessCmpToFootprintLinkFile( filename, changevisibility, visible ) ) if( !ProcessCmpToFootprintLinkFile( filename, changevisibility, visible ) ) { { wxString msg; wxString msg = wxString::Format( _( msg.Printf( _( "Failed to open component-footprint link file <%s>" ), filename.GetData() ); "Failed to open component-footprint link file '%s'" ), filename.GetData() ); DisplayError( this, msg ); DisplayError( this, msg ); return false; return false; } } Loading
eeschema/cross-probing.cpp +12 −0 Original line number Original line Diff line number Diff line Loading @@ -196,8 +196,20 @@ void SCH_EDIT_FRAME::KiwayMailIn( KIWAY_EXPRESS& mail ) ExecuteRemoteCommand( payload.c_str() ); ExecuteRemoteCommand( payload.c_str() ); break; break; case MAIL_BACKANNOTATE_FOOTPRINTS: try { backAnnotateFootprints( payload ); } catch( const IO_ERROR& ioe ) { DBG( printf( "%s: ioe:%s\n", __func__, TO_UTF8( ioe.errorText ) );) } break; // many many others. // many many others. } } } }
include/fp_lib_table.h +0 −3 Original line number Original line Diff line number Diff line Loading @@ -39,9 +39,6 @@ class OUTPUTFORMATTER; class MODULE; class MODULE; class FP_LIB_TABLE_LEXER; class FP_LIB_TABLE_LEXER; class FPID; class FPID; class NETLIST; class REPORTER; class SEARCH_STACK; /** /** * Class FP_LIB_TABLE * Class FP_LIB_TABLE Loading