diff --git a/CMakeLists.txt b/CMakeLists.txt index 6b40156f87..740f68d6ed 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -239,6 +239,7 @@ add_subdirectory(polygon) add_subdirectory(polygon/kbool/src) add_subdirectory(potrace) add_subdirectory(bitmap2component) +add_subdirectory(pcb_calculator) #add_subdirectory(new) ############# diff --git a/eeschema/backanno.cpp b/eeschema/backanno.cpp index c65c894b4c..8585ae6981 100644 --- a/eeschema/backanno.cpp +++ b/eeschema/backanno.cpp @@ -15,18 +15,25 @@ #include "general.h" #include "sch_sheet_path.h" #include "sch_component.h" +#include "netlist.h" const wxString BackAnnotateFileWildcard( wxT( "EESchema Back Annotation File (*.stf)|*.stf" ) ); -bool SCH_EDIT_FRAME::ProcessStuffFile( FILE* aFilename, bool aSetFieldAttributeToVisible ) +bool SCH_EDIT_FRAME::ProcessStuffFile( FILE* aFile, bool aSetFieldAttributeToVisible ) { int LineNum = 0; char* cp, Ref[256], FootPrint[256], Line[1024]; SCH_SHEET_LIST SheetList; + wxString reference; + wxString footprint; - while( GetLine( aFilename, Line, &LineNum, sizeof(Line) ) ) + // Build a flat list of components in schematic: + SCH_REFERENCE_LIST referencesList; + SheetList.GetComponents( referencesList, false ); + + while( GetLine( aFile, Line, &LineNum, sizeof(Line) ) ) { if( sscanf( Line, "comp = \"%s module = \"%s", Ref, FootPrint ) == 2 ) { @@ -38,12 +45,39 @@ bool SCH_EDIT_FRAME::ProcessStuffFile( FILE* aFilename, bool aSetFieldAttributeT if( *cp == '"' ) *cp = 0; - wxString reference = FROM_UTF8( Ref ); - wxString Footprint = FROM_UTF8( FootPrint ); - SheetList.SetComponentFootprint( reference, Footprint, aSetFieldAttributeToVisible ); + reference = FROM_UTF8( Ref ); + footprint = FROM_UTF8( FootPrint ); + + // Search the component in the flat list + for( unsigned ii = 0; ii < referencesList.GetCount(); ii++ ) + { + if( reference.CmpNoCase( referencesList[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 = referencesList[ii].GetComponent(); + SCH_FIELD * fpfield = component->GetField( FOOTPRINT ); + if( fpfield->m_Text.IsEmpty() + && ( fpfield->m_Pos == wxPoint( 0, 0 ) ) ) + { + fpfield->m_Orient = component->GetField( VALUE )->m_Orient; + fpfield->m_Pos = component->GetField( VALUE )->m_Pos; + fpfield->m_Pos.y -= 100; + } + + fpfield->m_Text = footprint; + + if( aSetFieldAttributeToVisible ) + component->GetField( FOOTPRINT )->m_Attributs &= ~TEXT_NO_VISIBLE; + else + component->GetField( FOOTPRINT )->m_Attributs |= TEXT_NO_VISIBLE; + } + } } } + fclose( aFile ); return true; } diff --git a/eeschema/dialog_erc_listbox.h b/eeschema/dialog_erc_listbox.h index 4d45b1de76..e3c828253f 100644 --- a/eeschema/dialog_erc_listbox.h +++ b/eeschema/dialog_erc_listbox.h @@ -43,12 +43,14 @@ public: * Function AppendToList * @param aItem The SCH_MARKER* to add to the current list which will be * displayed in the wxHtmlListBox + * @param aRefresh = true to refresh the display */ - void AppendToList( SCH_MARKER* aItem ) + void AppendToList( SCH_MARKER* aItem, bool aRefresh = true ) { m_MarkerList.push_back( aItem); SetItemCount( m_MarkerList.size() ); - Refresh(); + if( aRefresh ) + Refresh(); } diff --git a/eeschema/dialogs/dialog_erc.cpp b/eeschema/dialogs/dialog_erc.cpp index 61f2d179b4..3b543f1aa4 100644 --- a/eeschema/dialogs/dialog_erc.cpp +++ b/eeschema/dialogs/dialog_erc.cpp @@ -325,17 +325,11 @@ void DIALOG_ERC::DisplayERC_MarkersList() SCH_MARKER* Marker = (SCH_MARKER*) DrawStruct; if( Marker->GetMarkerType() != MARK_ERC ) continue; - - /* Display diag */ - -// wxString msg; -// msg.Printf( _( "sheet %s