Loading eeschema/build_BOM.cpp +127 −79 Original line number Diff line number Diff line ///////////////////////////////////////////////////////////////////////////// // Name: build_BOM.cpp // Purpose: // Author: jean-pierre Charras Loading Loading @@ -111,13 +112,16 @@ void DIALOG_BUILD_BOM::Create_BOM_Lists( int aTypeFile, /* Close dialog, then show the list (if so requested) */ switch( aTypeFile ) { switch( aTypeFile ) { case 0: // list GenereListeOfItems( m_ListFileName, aIncludeSubComponents ); break; case 1: // speadsheet CreateExportList( m_ListFileName, aIncludeSubComponents ); break; case 2: // Single Part per line CreatePartsList( m_ListFileName ); break; Loading @@ -134,6 +138,12 @@ void DIALOG_BUILD_BOM::Create_BOM_Lists( int aTypeFile, } } /* * Print a list of components, in a form which can be imported by a spreadsheet * form is: * cmp value; number of components; <footprint>; field1; field2; field3; list of references having the same value */ void DIALOG_BUILD_BOM::CreatePartsList( const wxString& aFullFileName ) { FILE* f; Loading @@ -157,6 +167,7 @@ void DIALOG_BUILD_BOM::CreatePartsList( const wxString& aFullFileName ) fclose( f ); } /* * Print a list of components, in a form which can be imported by a spreadsheet * form is: Loading Loading @@ -250,7 +261,8 @@ void DIALOG_BUILD_BOM::GenereListeOfItems( const wxString& aFullFileName, if( m_GenListLabelsbySheet->GetValue() ) { sort( listOfLabels.begin(), listOfLabels.end(), SortLabelsBySheet ); msg.Printf( _( "\n#Global, Hierarchical Labels and PinSheets \ msg.Printf( _( "\n#Global, Hierarchical Labels and PinSheets \ ( order = Sheet Number ) count = %d\n" ), itemCount ); fprintf( f, "%s", CONV_TO_UTF8( msg ) ); Loading @@ -261,7 +273,8 @@ void DIALOG_BUILD_BOM::GenereListeOfItems( const wxString& aFullFileName, { sort( listOfLabels.begin(), listOfLabels.end(), SortLabelsByValue ); msg.Printf( _( "\n#Global, Hierarchical Labels and PinSheets ( \ msg.Printf( _( "\n#Global, Hierarchical Labels and PinSheets ( \ order = Alphab. ) count = %d\n\n" ), itemCount ); fprintf( f, "%s", CONV_TO_UTF8( msg ) ); Loading Loading @@ -588,6 +601,7 @@ void DIALOG_BUILD_BOM::PrintFieldData( FILE* f, SCH_COMPONENT* DrawLibItem, } } /* Print the B.O.M sorted by reference */ int DIALOG_BUILD_BOM::PrintComponentsListByRef( Loading Loading @@ -681,8 +695,12 @@ int DIALOG_BUILD_BOM::PrintComponentsListByRef( if( ( Multi > 1 ) && aIncludeSubComponents ) #if defined(KICAD_GOST) Unit = aList[ii].m_Unit + '1' - 1; #else Unit = aList[ii].m_Unit + 'A' - 1; #endif Loading @@ -692,19 +710,29 @@ int DIALOG_BUILD_BOM::PrintComponentsListByRef( if( CompactForm ) #if defined(KICAD_GOST) fprintf( f, "%s%c%s%c%s", CmpName, s_ExportSeparatorSymbol, CONV_TO_UTF8( DrawLibItem->GetField( VALUE )->m_Text ), s_ExportSeparatorSymbol, CONV_TO_UTF8( DrawLibItem->GetField( VALUE )->m_Text ), s_ExportSeparatorSymbol, CONV_TO_UTF8( DrawLibItem->GetField( DATASHEET )->m_Text ) ); #else fprintf( f, "%s%c%s", CmpName, s_ExportSeparatorSymbol, CONV_TO_UTF8( DrawLibItem->GetField( VALUE )->m_Text ) ); #endif else #if defined(KICAD_GOST) fprintf( f, "| %-10s %-12s %-20s", CmpName, CONV_TO_UTF8( DrawLibItem->GetField( VALUE )->m_Text ), CONV_TO_UTF8( DrawLibItem->GetField( DATASHEET )->m_Text ) ); CONV_TO_UTF8( DrawLibItem->GetField( VALUE )->m_Text ), CONV_TO_UTF8( DrawLibItem->GetField( DATASHEET )->m_Text ) ); #else fprintf( f, "| %-10s %-12s", CmpName, CONV_TO_UTF8( DrawLibItem->GetField( VALUE )->m_Text ) ); #endif Loading Loading @@ -748,6 +776,17 @@ int DIALOG_BUILD_BOM::PrintComponentsListByRef( } /* Bom Output format option - single part per line * a common part being defined as have a common value. * This is true for most designs but will produce an * incorrect output if two or more parts with the same * value have different footprints, tolerances, voltage * rating, etc. Also usefull if the following fields * are edited: * FIELD1 - manufacture * FIELD2 - manufacture part number * FIELD3 - distributor part number */ int DIALOG_BUILD_BOM::PrintComponentsListByPart( FILE* f, std::vector <OBJ_CMP_TO_LIST>& aList ) Loading @@ -757,7 +796,7 @@ int DIALOG_BUILD_BOM::PrintComponentsListByPart( char ValName[80]; char NxtName[80]; char RNames[1000]; const char * Field[15]; wxArrayString cmpFields; EDA_BaseStruct* DrawList; EDA_BaseStruct* NxtList; SCH_COMPONENT* DrawLibItem; Loading @@ -766,8 +805,6 @@ int DIALOG_BUILD_BOM::PrintComponentsListByPart( strcpy( NxtName, "" ); strcpy( RNames, "" ); for( jj=0; jj<15; jj++ ) Field[jj] = NULL; for( unsigned ii = 0; ii < aList.size(); ii++ ) { Loading @@ -780,7 +817,9 @@ int DIALOG_BUILD_BOM::PrintComponentsListByPart( continue; DrawLibItem = (SCH_COMPONENT*) DrawList; for( unsigned ij = ii+1 ; ij < aList.size(); ij++ ){ NxtLibItem = NULL; for( unsigned ij = ii + 1; ij < aList.size(); ij++ ) { NxtList = aList[ij].m_RootCmp; if( NxtList == NULL ) continue; Loading @@ -794,13 +833,20 @@ int DIALOG_BUILD_BOM::PrintComponentsListByPart( sprintf( RefName, "%s", aList[ii].m_Reference ); sprintf( ValName, "%s", CONV_TO_UTF8( DrawLibItem->GetField( VALUE )->m_Text ) ); if( NxtLibItem ) sprintf( NxtName, "%s", CONV_TO_UTF8( NxtLibItem->GetField( VALUE )->m_Text ) ); for( jj = FIELD1; jj < DrawLibItem->GetFieldCount(); jj++ ) { if( Field[jj] == NULL || *Field[jj] == 0 ) Field[jj] = CONV_TO_UTF8( DrawLibItem->GetField( jj )->m_Text ); // Store fields. try to store non empty fields. if( cmpFields.GetCount() < DrawLibItem->GetFieldCount() ) cmpFields.Alloc(DrawLibItem->GetFieldCount()); for( jj = FIELD1; jj < DrawLibItem->GetFieldCount(); jj++ ) { if( cmpFields[jj].IsEmpty() ) cmpFields[jj] = DrawLibItem->GetField( jj )->m_Text; } if( !strcmp( NxtName, ValName ) ) { if( !strcmp( NxtName, ValName ) ) { qty++; strcat( RNames, ", " ); strcat( RNames, RefName ); Loading @@ -814,20 +860,22 @@ int DIALOG_BUILD_BOM::PrintComponentsListByPart( fprintf( f, "%c%-16s", s_ExportSeparatorSymbol, CONV_TO_UTF8( DrawLibItem->GetField( FOOTPRINT )->m_Text ) ); fprintf( f, "%c%-20s", s_ExportSeparatorSymbol, Field[FIELD1] ); fprintf( f, "%c%-20s", s_ExportSeparatorSymbol, Field[FIELD2] ); fprintf( f, "%c%-20s", s_ExportSeparatorSymbol, Field[FIELD3] ); for( jj = FIELD1; jj < DrawLibItem->GetFieldCount(); jj++ ) Field[jj] = NULL; fprintf( f, "%c%-20s", s_ExportSeparatorSymbol, CONV_TO_UTF8( cmpFields[FIELD1]) ); fprintf( f, "%c%-20s", s_ExportSeparatorSymbol, CONV_TO_UTF8( cmpFields[FIELD2]) ); fprintf( f, "%c%-20s", s_ExportSeparatorSymbol, CONV_TO_UTF8( cmpFields[FIELD3]) ); cmpFields.Clear(); fprintf( f, "%c%s%s", s_ExportSeparatorSymbol, RefName, RNames ); strcpy( RNames, "" ); fputs( "\n", f ); } return 0; } int DIALOG_BUILD_BOM::PrintComponentsListByVal( FILE* f, std::vector <OBJ_CMP_TO_LIST>& aList, Loading Loading
eeschema/build_BOM.cpp +127 −79 Original line number Diff line number Diff line ///////////////////////////////////////////////////////////////////////////// // Name: build_BOM.cpp // Purpose: // Author: jean-pierre Charras Loading Loading @@ -111,13 +112,16 @@ void DIALOG_BUILD_BOM::Create_BOM_Lists( int aTypeFile, /* Close dialog, then show the list (if so requested) */ switch( aTypeFile ) { switch( aTypeFile ) { case 0: // list GenereListeOfItems( m_ListFileName, aIncludeSubComponents ); break; case 1: // speadsheet CreateExportList( m_ListFileName, aIncludeSubComponents ); break; case 2: // Single Part per line CreatePartsList( m_ListFileName ); break; Loading @@ -134,6 +138,12 @@ void DIALOG_BUILD_BOM::Create_BOM_Lists( int aTypeFile, } } /* * Print a list of components, in a form which can be imported by a spreadsheet * form is: * cmp value; number of components; <footprint>; field1; field2; field3; list of references having the same value */ void DIALOG_BUILD_BOM::CreatePartsList( const wxString& aFullFileName ) { FILE* f; Loading @@ -157,6 +167,7 @@ void DIALOG_BUILD_BOM::CreatePartsList( const wxString& aFullFileName ) fclose( f ); } /* * Print a list of components, in a form which can be imported by a spreadsheet * form is: Loading Loading @@ -250,7 +261,8 @@ void DIALOG_BUILD_BOM::GenereListeOfItems( const wxString& aFullFileName, if( m_GenListLabelsbySheet->GetValue() ) { sort( listOfLabels.begin(), listOfLabels.end(), SortLabelsBySheet ); msg.Printf( _( "\n#Global, Hierarchical Labels and PinSheets \ msg.Printf( _( "\n#Global, Hierarchical Labels and PinSheets \ ( order = Sheet Number ) count = %d\n" ), itemCount ); fprintf( f, "%s", CONV_TO_UTF8( msg ) ); Loading @@ -261,7 +273,8 @@ void DIALOG_BUILD_BOM::GenereListeOfItems( const wxString& aFullFileName, { sort( listOfLabels.begin(), listOfLabels.end(), SortLabelsByValue ); msg.Printf( _( "\n#Global, Hierarchical Labels and PinSheets ( \ msg.Printf( _( "\n#Global, Hierarchical Labels and PinSheets ( \ order = Alphab. ) count = %d\n\n" ), itemCount ); fprintf( f, "%s", CONV_TO_UTF8( msg ) ); Loading Loading @@ -588,6 +601,7 @@ void DIALOG_BUILD_BOM::PrintFieldData( FILE* f, SCH_COMPONENT* DrawLibItem, } } /* Print the B.O.M sorted by reference */ int DIALOG_BUILD_BOM::PrintComponentsListByRef( Loading Loading @@ -681,8 +695,12 @@ int DIALOG_BUILD_BOM::PrintComponentsListByRef( if( ( Multi > 1 ) && aIncludeSubComponents ) #if defined(KICAD_GOST) Unit = aList[ii].m_Unit + '1' - 1; #else Unit = aList[ii].m_Unit + 'A' - 1; #endif Loading @@ -692,19 +710,29 @@ int DIALOG_BUILD_BOM::PrintComponentsListByRef( if( CompactForm ) #if defined(KICAD_GOST) fprintf( f, "%s%c%s%c%s", CmpName, s_ExportSeparatorSymbol, CONV_TO_UTF8( DrawLibItem->GetField( VALUE )->m_Text ), s_ExportSeparatorSymbol, CONV_TO_UTF8( DrawLibItem->GetField( VALUE )->m_Text ), s_ExportSeparatorSymbol, CONV_TO_UTF8( DrawLibItem->GetField( DATASHEET )->m_Text ) ); #else fprintf( f, "%s%c%s", CmpName, s_ExportSeparatorSymbol, CONV_TO_UTF8( DrawLibItem->GetField( VALUE )->m_Text ) ); #endif else #if defined(KICAD_GOST) fprintf( f, "| %-10s %-12s %-20s", CmpName, CONV_TO_UTF8( DrawLibItem->GetField( VALUE )->m_Text ), CONV_TO_UTF8( DrawLibItem->GetField( DATASHEET )->m_Text ) ); CONV_TO_UTF8( DrawLibItem->GetField( VALUE )->m_Text ), CONV_TO_UTF8( DrawLibItem->GetField( DATASHEET )->m_Text ) ); #else fprintf( f, "| %-10s %-12s", CmpName, CONV_TO_UTF8( DrawLibItem->GetField( VALUE )->m_Text ) ); #endif Loading Loading @@ -748,6 +776,17 @@ int DIALOG_BUILD_BOM::PrintComponentsListByRef( } /* Bom Output format option - single part per line * a common part being defined as have a common value. * This is true for most designs but will produce an * incorrect output if two or more parts with the same * value have different footprints, tolerances, voltage * rating, etc. Also usefull if the following fields * are edited: * FIELD1 - manufacture * FIELD2 - manufacture part number * FIELD3 - distributor part number */ int DIALOG_BUILD_BOM::PrintComponentsListByPart( FILE* f, std::vector <OBJ_CMP_TO_LIST>& aList ) Loading @@ -757,7 +796,7 @@ int DIALOG_BUILD_BOM::PrintComponentsListByPart( char ValName[80]; char NxtName[80]; char RNames[1000]; const char * Field[15]; wxArrayString cmpFields; EDA_BaseStruct* DrawList; EDA_BaseStruct* NxtList; SCH_COMPONENT* DrawLibItem; Loading @@ -766,8 +805,6 @@ int DIALOG_BUILD_BOM::PrintComponentsListByPart( strcpy( NxtName, "" ); strcpy( RNames, "" ); for( jj=0; jj<15; jj++ ) Field[jj] = NULL; for( unsigned ii = 0; ii < aList.size(); ii++ ) { Loading @@ -780,7 +817,9 @@ int DIALOG_BUILD_BOM::PrintComponentsListByPart( continue; DrawLibItem = (SCH_COMPONENT*) DrawList; for( unsigned ij = ii+1 ; ij < aList.size(); ij++ ){ NxtLibItem = NULL; for( unsigned ij = ii + 1; ij < aList.size(); ij++ ) { NxtList = aList[ij].m_RootCmp; if( NxtList == NULL ) continue; Loading @@ -794,13 +833,20 @@ int DIALOG_BUILD_BOM::PrintComponentsListByPart( sprintf( RefName, "%s", aList[ii].m_Reference ); sprintf( ValName, "%s", CONV_TO_UTF8( DrawLibItem->GetField( VALUE )->m_Text ) ); if( NxtLibItem ) sprintf( NxtName, "%s", CONV_TO_UTF8( NxtLibItem->GetField( VALUE )->m_Text ) ); for( jj = FIELD1; jj < DrawLibItem->GetFieldCount(); jj++ ) { if( Field[jj] == NULL || *Field[jj] == 0 ) Field[jj] = CONV_TO_UTF8( DrawLibItem->GetField( jj )->m_Text ); // Store fields. try to store non empty fields. if( cmpFields.GetCount() < DrawLibItem->GetFieldCount() ) cmpFields.Alloc(DrawLibItem->GetFieldCount()); for( jj = FIELD1; jj < DrawLibItem->GetFieldCount(); jj++ ) { if( cmpFields[jj].IsEmpty() ) cmpFields[jj] = DrawLibItem->GetField( jj )->m_Text; } if( !strcmp( NxtName, ValName ) ) { if( !strcmp( NxtName, ValName ) ) { qty++; strcat( RNames, ", " ); strcat( RNames, RefName ); Loading @@ -814,20 +860,22 @@ int DIALOG_BUILD_BOM::PrintComponentsListByPart( fprintf( f, "%c%-16s", s_ExportSeparatorSymbol, CONV_TO_UTF8( DrawLibItem->GetField( FOOTPRINT )->m_Text ) ); fprintf( f, "%c%-20s", s_ExportSeparatorSymbol, Field[FIELD1] ); fprintf( f, "%c%-20s", s_ExportSeparatorSymbol, Field[FIELD2] ); fprintf( f, "%c%-20s", s_ExportSeparatorSymbol, Field[FIELD3] ); for( jj = FIELD1; jj < DrawLibItem->GetFieldCount(); jj++ ) Field[jj] = NULL; fprintf( f, "%c%-20s", s_ExportSeparatorSymbol, CONV_TO_UTF8( cmpFields[FIELD1]) ); fprintf( f, "%c%-20s", s_ExportSeparatorSymbol, CONV_TO_UTF8( cmpFields[FIELD2]) ); fprintf( f, "%c%-20s", s_ExportSeparatorSymbol, CONV_TO_UTF8( cmpFields[FIELD3]) ); cmpFields.Clear(); fprintf( f, "%c%s%s", s_ExportSeparatorSymbol, RefName, RNames ); strcpy( RNames, "" ); fputs( "\n", f ); } return 0; } int DIALOG_BUILD_BOM::PrintComponentsListByVal( FILE* f, std::vector <OBJ_CMP_TO_LIST>& aList, Loading