diff --git a/eeschema/BOM_lister.h b/eeschema/BOM_lister.h new file mode 100644 index 0000000000..939fa7f06f --- /dev/null +++ b/eeschema/BOM_lister.h @@ -0,0 +1,189 @@ +/** + * @file BOM_lister.h + */ + +/* This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2012 Jean-Pierre Charras jp.charras at wanadoo.fr + * Copyright (C) 1992-2012 KiCad Developers, see AUTHORS.txt for contributors. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, you may find one here: + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * or you may search the http://www.gnu.org website for the version 2 license, + * or you may write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#ifndef _BOM_LISTER_H_ +#define _BOM_LISTER_H_ + +#include + + +// A helper class to build item lists for BOM, +// and write lists on files +class BOM_LISTER +{ +private: + BOM_LABEL_LIST m_labelList; // a list of global and hierarchical labels + SCH_REFERENCE_LIST m_cmplist; // a flat list of components in the full hierarchy + FILE* m_outFile; // the output file for BOM generation + char m_separatorSymbol; // the separator used for csv files ( usually \t ; or , ) + bool m_outputFmtCsv; // true to create Csv files, false to create text lists + bool m_includeSubComponents; // true to list each part + // of a multiple part per package component + // false to list only once this kind of component + bool m_csvForm; // true to print less verbose component list + // false to print more verbose component list + bool m_groupReferences; // true to group in list by reference (when possible, + // i.e. when other fields have the same value + // false to list one reference per line + bool m_printLocation; // true to print component location in list by reference + std::vector m_fieldIDactive; // list of field IDs to print + +public: + BOM_LISTER() + { + m_outFile = NULL; + m_separatorSymbol = '\t'; + m_outputFmtCsv = false; + m_includeSubComponents = false; + m_csvForm = true; + m_printLocation = false; + m_groupReferences = false; + } + + // Accessors: + void SetGroupReferences( bool aGroupRef ) + { + m_groupReferences = aGroupRef; + } + + void SetPrintLocation( bool aPrintLoc ) + { + m_printLocation = aPrintLoc; + } + + void SetIncludeSubCmp( bool aIncludeSubCmp ) + { + m_includeSubComponents = aIncludeSubCmp; + } + + /** + * Function SetCvsFormOn + * prepare parameters to create a BOM list in comma separated value (cvs) + * @param aSeparator = the character used as "csv" separator + * @param aFile = the file to write to (will be closed) + */ + void SetCvsFormOn( char aSeparator ) + { + m_csvForm = true; + m_separatorSymbol = aSeparator; + } + + /** + * Function SetCvsFormOff + * prepare parameters to create a BOM list in full text readable mode + * (not csv format) + */ + void SetCvsFormOff() + { + m_csvForm = false; + } + + void AddFieldIdToPrintList( int aFieldId ); + + void ClearFieldIdPrintList() { m_fieldIDactive.clear(); } + + /** + * Function CreateCsvBOMListByValues + * print the list of components, grouped by values: + * One line by value. The format is something like: + * value;quantity;references;other fields + * 18pF;2;"C404 C405";SM0402 + * 22nF/25V;4;"C128 C168 C228 C268";SM0402 + * @param aFile = the file to write to (will be closed) + */ + void CreateCsvBOMListByValues( FILE* aFile ); + + /** + * Function PrintGlobalAndHierarchicalLabelsList + * print the list of global and hierarchical labels by sheet or by name + * @param aSortBySheet = true to print by sheet name order + * false to print by label name order + * @param aFile = the file to write to (will be NOT closed) + */ + void PrintGlobalAndHierarchicalLabelsList( FILE* aFile, bool aSortBySheet ); + + /** + * Function PrintComponentsListByReferenceHumanReadable + * print a BOM list in human readable form + * @param aFile = the file to write to (will be NOT closed) + */ + bool PrintComponentsListByReferenceHumanReadable( FILE* aFile ); + + /** + * Function PrintComponentsListByReferenceCsvForm + * print the list of components ordered by references. Generate 2 formats: + * - full component list in csv form + * - "short" component list in csv form, grouped by common fields values + * (mainly component value) + * @param aFile = the file to write to (will be NOT closed) + */ + bool PrintComponentsListByReferenceCsvForm( FILE* aFile ); + + /** + * Function PrintComponentsListByValue + * print the list of components, sorted by value, one line per component + * not useable for csv format (use CreateCsvBOMListByValues instead) + * @param aFile = the file to write to (will be NOT closed) + */ + int PrintComponentsListByValue( FILE* aFile ); + +private: + + /** + * Helper function isFieldPrintable + * @return true if the field aFieldId should be printed. + * @param aFieldId = the field Id (FOOTPRIN, FIELD4 ...) + */ + bool isFieldPrintable( int aFieldId ); + + /** + * Helper function buildGlobalAndHierarchicalLabelsList + * Populate m_labelList with global and hierarchical labels + * and sheet pins labels + */ + void buildGlobalAndHierarchicalLabelsList(); + + /** + * Helper function returnFieldsString + * @return a string containing all selected fields texts, + * @param aComponent = the schematic component + * separated by the csv separator symbol + */ + const wxString returnFieldsString( SCH_COMPONENT* aComponent ); + + /** + * Helper function returnURLItemLocation + * @param aPathName = the full sheet name of item + * @param aPosition = a position (in internal units) to print + * @return a formated string to print the full location: + * /sheet name/( X Y position) + */ + const wxString returnURLItemLocation( const wxString& aPathName, + wxPoint aPosition ); +}; + +#endif // _BOM_LISTER_H_ diff --git a/eeschema/build_BOM.cpp b/eeschema/build_BOM.cpp index e78fe8ae06..a20521828d 100644 --- a/eeschema/build_BOM.cpp +++ b/eeschema/build_BOM.cpp @@ -1,9 +1,9 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2009 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com - * Copyright (C) 2011 Wayne Stambaugh - * Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2012 Jean-Pierre Charras, jp.charras at wanadoo.fr + * Copyright (C) 2012 Wayne Stambaugh + * Copyright (C) 1992-2012 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -28,156 +28,244 @@ * @brief Code used to generate bill of materials. */ -#include // to use sort vector +#include // to use sort vector #include #include -#include -#include - -#include #include #include #include -#include +#include +#include +#include -/* Fill aList with labels +/* Creates the list of components, grouped by values: + * One line by value. The format is something like: + * value;quantity;references;other fields + * 18pF;2;"C404 C405";SM0402 + * 22nF/25V;4;"C128 C168 C228 C268";SM0402 + * param aFile = the file to write to (will be closed) */ -void GenListeGLabels( BOM_LABEL_LIST& aList ) +void BOM_LISTER::CreateCsvBOMListByValues( FILE* aFile ) { - // Build the sheet list + m_outFile = aFile; + + SCH_SHEET_LIST sheetList; + + sheetList.GetComponents( m_cmplist, false ); + + // sort component list by ref and remove sub components + m_cmplist.RemoveSubComponentsFromList(); + + // sort component list by value + m_cmplist.SortByValueOnly(); + + unsigned int index = 0; + + while( index < m_cmplist.GetCount() ) + { + SCH_COMPONENT* component = m_cmplist[index].GetComponent(); + wxString referenceListStr; + int qty = 1; + referenceListStr.append( m_cmplist[index].GetRef() ); + + for( unsigned int ii = index + 1; ii < m_cmplist.GetCount(); ) + { + if( *( m_cmplist[ii].GetComponent() ) == *component ) + { + referenceListStr.append( wxT( " " ) + m_cmplist[ii].GetRef() ); + m_cmplist.RemoveItem( ii ); + qty++; + } + else + ii++; // Increment index only when current item is not removed from the list + } + + // Write value, quantity and list of references + fprintf( m_outFile, "%s%c%d%c\"%s\"", + TO_UTF8( component->GetField( VALUE )->GetText() ), + m_separatorSymbol, qty, + m_separatorSymbol, TO_UTF8( referenceListStr ) ); + + for( int ii = FOOTPRINT; ii < component->GetFieldCount(); ii++ ) + { + if( isFieldPrintable( ii ) ) + fprintf( m_outFile, "%c%s", m_separatorSymbol, + TO_UTF8( component->GetField( ii )->GetText() ) ); + } + + fprintf( m_outFile, "\n" ); + index++; + } + + fclose( m_outFile ); + m_outFile = NULL; +} + + +bool BOM_LISTER::isFieldPrintable( int aFieldId ) +{ + for( unsigned ii = 0; ii < m_fieldIDactive.size(); ii++ ) + if( m_fieldIDactive[ii] == aFieldId ) + return true; + + + + + return false; +} + + +void BOM_LISTER::AddFieldIdToPrintList( int aFieldId ) +{ + for( unsigned ii = 0; ii < m_fieldIDactive.size(); ii++ ) + if( m_fieldIDactive[ii] == aFieldId ) + return; + + + + + m_fieldIDactive.push_back( aFieldId ); +} + + +/* compare function for sorting labels by value, then by sheet + */ +static bool SortLabelsByValue( const BOM_LABEL& obj1, const BOM_LABEL& obj2 ) +{ + int ii = obj1.GetText().CmpNoCase( obj2.GetText() ); + + if( ii == 0 ) + ii = obj1.GetSheetPath().Cmp( obj2.GetSheetPath() ); + + return ii < 0; +} + + +/* compare function for sorting labels by sheet, then by alphabetic order + */ +static bool SortLabelsBySheet( const BOM_LABEL& obj1, const BOM_LABEL& obj2 ) +{ + int ii = obj1.GetSheetPath().Cmp( obj2.GetSheetPath() ); + + if( ii == 0 ) + ii = obj1.GetText().CmpNoCase( obj2.GetText() ); + + return ii < 0; +} + + +// Creates the flat list of global, hierachycal labels and pin sheets +// and populate m_labelList +void BOM_LISTER::buildGlobalAndHierarchicalLabelsList() +{ + m_labelList.clear(); + + // Explore the flat sheet list SCH_SHEET_LIST sheetList; - BOM_LABEL label; for( SCH_SHEET_PATH* path = sheetList.GetFirst(); path; path = sheetList.GetNext() ) { SCH_ITEM* schItem = (SCH_ITEM*) path->LastDrawList(); - while( schItem ) + for( ; schItem; schItem = schItem->Next() ) { switch( schItem->Type() ) { case SCH_HIERARCHICAL_LABEL_T: case SCH_GLOBAL_LABEL_T: - aList.push_back( BOM_LABEL( schItem->Type(), schItem, *path ) ); + m_labelList.push_back( BOM_LABEL( schItem->Type(), schItem, *path ) ); break; case SCH_SHEET_T: - { - SCH_SHEET* sheet = (SCH_SHEET*) schItem; - - BOOST_FOREACH( SCH_SHEET_PIN& sheetPin, sheet->GetPins() ) { - aList.push_back( BOM_LABEL( SCH_SHEET_PIN_T, &sheetPin, *path ) ); + SCH_SHEET* sheet = (SCH_SHEET*) schItem; + + BOOST_FOREACH( SCH_SHEET_PIN & sheetPin, sheet->GetPins() ) { + m_labelList.push_back( BOM_LABEL( SCH_SHEET_PIN_T, + &sheetPin, *path ) ); + } } - } - break; + break; default: break; } - - schItem = schItem->Next(); } } } -/* compare function for sorting labels - * sort by - * value - * if same value: by sheet - */ -bool SortLabelsByValue( const BOM_LABEL& obj1, const BOM_LABEL& obj2 ) +// Print the flat list of global, hierachycal labels and pin sheets +// contained by m_labelList +void BOM_LISTER::PrintGlobalAndHierarchicalLabelsList( FILE* aFile, bool aSortBySheet ) { - int ii; + m_outFile = aFile; - ii = obj1.GetText().CmpNoCase( obj2.GetText() ); + buildGlobalAndHierarchicalLabelsList(); - if( ii == 0 ) + wxString msg; + + if( aSortBySheet ) { - ii = obj1.GetSheetPath().Cmp( obj2.GetSheetPath() ); + sort( m_labelList.begin(), m_labelList.end(), SortLabelsBySheet ); + msg.Printf( _( + "\n#Global, Hierarchical Labels and PinSheets \ +( order = Sheet Number ) count = %d\n" ), + m_labelList.size() ); + } + else + { + sort( m_labelList.begin(), m_labelList.end(), SortLabelsByValue ); + msg.Printf( _( + "\n#Global, Hierarchical Labels and PinSheets ( \ +order = Alphab. ) count = %d\n\n" ), + m_labelList.size() ); } - return ii < 0; -} + fprintf( m_outFile, "%s", TO_UTF8( msg ) ); + SCH_LABEL* label; + SCH_SHEET_PIN* pinsheet; + wxString sheetpath; + wxString labeltype; -/* compare function for sorting labels - * by sheet - * in a sheet, by alphabetic order - */ -bool SortLabelsBySheet( const BOM_LABEL& obj1, const BOM_LABEL& obj2 ) -{ - int ii; - - ii = obj1.GetSheetPath().Cmp( obj2.GetSheetPath() ); - - if( ii == 0 ) + for( unsigned ii = 0; ii < m_labelList.size(); ii++ ) { - ii = obj1.GetText().CmpNoCase( obj2.GetText() ); - } - - return ii < 0; -} - - -int PrintListeGLabel( FILE* f, BOM_LABEL_LIST& aList ) -{ - SCH_LABEL* label; - SCH_SHEET_PIN* pinsheet; - wxString msg, sheetpath; - wxString labeltype; - - for( unsigned ii = 0; ii < aList.size(); ii++ ) - { - switch( aList[ii].GetType() ) + switch( m_labelList[ii].GetType() ) { case SCH_HIERARCHICAL_LABEL_T: case SCH_GLOBAL_LABEL_T: - label = (SCH_LABEL*)(aList[ii].GetLabel()); + label = (SCH_LABEL*) ( m_labelList[ii].GetLabel() ); - if( aList[ii].GetType() == SCH_HIERARCHICAL_LABEL_T ) + if( m_labelList[ii].GetType() == SCH_HIERARCHICAL_LABEL_T ) labeltype = wxT( "Hierarchical" ); else labeltype = wxT( "Global " ); - sheetpath = aList[ii].GetSheetPath().PathHumanReadable(); - msg.Printf( _( "> %-28.28s %s (Sheet %s) pos: %3.3f, %3.3f\n" ), + sheetpath = m_labelList[ii].GetSheetPath().PathHumanReadable(); + msg.Printf( _( "> %-28.28s %s %s\n" ), GetChars( label->GetText() ), GetChars( labeltype ), - GetChars( sheetpath ), - (float) label->m_Pos.x / 1000, - (float) label->m_Pos.y / 1000 ); + GetChars( returnURLItemLocation( sheetpath, label->m_Pos ) ) ); - fputs( TO_UTF8( msg ), f ); + fputs( TO_UTF8( msg ), m_outFile ); break; case SCH_SHEET_PIN_T: - { - pinsheet = (SCH_SHEET_PIN*) aList[ii].GetLabel(); - int jj = pinsheet->GetShape(); + pinsheet = (SCH_SHEET_PIN*) m_labelList[ii].GetLabel(); + labeltype = FROM_UTF8( SheetLabelType[pinsheet->GetShape()] ); - if( jj < 0 ) - jj = NET_TMAX; - - if( jj > NET_TMAX ) - jj = 4; - - wxString labtype = FROM_UTF8( SheetLabelType[jj] ); - - msg.Printf( _( "> %-28.28s PinSheet %-7.7s (Sheet %s) pos: %3.3f, %3.3f\n" ), + msg.Printf( _( "> %-28.28s PinSheet %-7.7s %s\n" ), GetChars( pinsheet->GetText() ), - GetChars( labtype ), - GetChars( aList[ii].GetSheetPath().PathHumanReadable() ), - (float) pinsheet->m_Pos.x / 1000, - (float) pinsheet->m_Pos.y / 1000 ); + GetChars( labeltype ), + GetChars( returnURLItemLocation( m_labelList[ii].GetSheetPath(). + PathHumanReadable(), + pinsheet->m_Pos ) ) ); - fputs( TO_UTF8( msg ), f ); - } - - break; + fputs( TO_UTF8( msg ), m_outFile ); + break; default: break; @@ -185,6 +273,465 @@ int PrintListeGLabel( FILE* f, BOM_LABEL_LIST& aList ) } msg = _( "#End labels\n" ); - fputs( TO_UTF8( msg ), f ); + fputs( TO_UTF8( msg ), m_outFile ); +} + + +/* + * Helper function + * returns a string containing all selected fields texts, + * separated by the csv separator symbol (csv form) or a ; + */ +const wxString BOM_LISTER::returnFieldsString( SCH_COMPONENT* aComponent ) +{ + wxString outStr; + wxString tmpStr; + wxString text; + + for( int ii = FOOTPRINT; ii <= FIELD8; ii++ ) + { + if( !isFieldPrintable( ii ) ) + continue; + + if( aComponent->GetFieldCount() > ii ) + text = aComponent->GetField( ii )->m_Text; + else + text = wxEmptyString; + + if( m_csvForm ) + tmpStr.Printf( wxT( "%c%s" ), m_separatorSymbol, GetChars( text ) ); + else + tmpStr.Printf( wxT( "; %-12s" ), GetChars( text ) ); + + outStr += tmpStr; + } + + return outStr; +} + + +/* print the list of components ordered by references, + * full component list in human readable form + * param aFile = the file to write to (will be NOT closed) + */ + +/* full list in human readable form sample: + * #Cmp ( order = Reference )with sub-composants + * | C101 47pF Loc /(X=344,170 mm, Y=116,840 mm); C1 ; field1 ; + * | C102 47pF Loc /(X=364,490 mm, Y=116,840 mm); C1 ; ; + * | C103 47uF Loc /(X=66,040 mm, Y=231,140 mm); CP6 ; ; + */ + +bool BOM_LISTER::PrintComponentsListByReferenceHumanReadable( FILE* aFile ) +{ + m_outFile = aFile; + bool addDatasheet = isFieldPrintable( DATASHEET ); + + // Print component location if needed, but only when + // include sub component option is enabled, because for multiple + // parts per package there are more than one location per reference + bool printLocCmp = m_printLocation && m_includeSubComponents; + + wxString msg; + + if( m_cmplist.GetCount() == 0 ) // Build component list + { + SCH_SHEET_LIST sheetList; + sheetList.GetComponents( m_cmplist, false ); + + // sort component list + m_cmplist.SortByReferenceOnly(); + + if( !m_includeSubComponents ) + m_cmplist.RemoveSubComponentsFromList(); + } + else + m_cmplist.SortByReferenceOnly(); + + // Print comment line: + msg = _( "#Cmp ( order = Reference )" ); + + if( m_includeSubComponents ) + msg << _( " (with SubCmp)" ); + + fprintf( m_outFile, "%s\n", TO_UTF8( msg ) ); + + wxString subReference; // Unit ident, for mutiple parts per package + std::string CmpName; + + // Print list of items + for( unsigned ii = 0; ii < m_cmplist.GetCount(); ii++ ) + { + EDA_ITEM* item = m_cmplist[ii].GetComponent(); + + if( item == NULL ) + continue; + + if( item->Type() != SCH_COMPONENT_T ) + continue; + + SCH_COMPONENT* comp = (SCH_COMPONENT*) item; + + bool isMulti = false; + + LIB_COMPONENT* entry = CMP_LIBRARY::FindLibraryComponent( comp->GetLibName() ); + + if( entry ) + isMulti = entry->IsMulti(); + + CmpName = m_cmplist[ii].GetRefStr(); + + if( isMulti && m_includeSubComponents ) + { + subReference = LIB_COMPONENT::ReturnSubReference( m_cmplist[ii].GetUnit() ); + CmpName += TO_UTF8( subReference ); + } + + fprintf( m_outFile, "| %-10s %-12s", CmpName.c_str(), + TO_UTF8( comp->GetField( VALUE )->m_Text ) ); + + if( addDatasheet ) + fprintf( m_outFile, "%-20s", + TO_UTF8( comp->GetField( DATASHEET )->m_Text ) ); + + if( m_includeSubComponents ) + { + if( printLocCmp ) + { + msg = returnURLItemLocation( m_cmplist[ii].GetSheetPath().PathHumanReadable(), + comp->GetPosition() ); + fprintf( m_outFile, "%s", TO_UTF8( msg ) ); + } + } + + wxString tmpStr = returnFieldsString( comp ); + fprintf( m_outFile, "%s\n", TO_UTF8( tmpStr ) ); + } + + // Print the last line: + fputs( "#End Cmp\n", m_outFile ); + + return true; +} + + +/* print the list of components ordered by references. Generate 2 formats: + * - full component list in csv form + * - "short" component list in csv form, grouped by common fields values + * (mainly component value) + * param aFile = the file to write to (will be NOT closed) + */ + +/* full csv format sample: + * ref;value;sheet path(location);footprint;field1;field2 + * C101;47pF;Loc /(X=57,150 mm, Y=74,930 mm);Loc /(X=344,170 mm, Y=116,840 mm));C1;field1; + * C102;47pF;Loc /(X=344,170 mm, Y=116,840 mm);Loc /(X=364,490 mm, Y=116,840 mm));C1;; + * C103;47uF;Loc /(X=364,490 mm, Y=116,840 mm);Loc /(X=66,040 mm, Y=231,140 mm));CP6;; + * C104;47uF;Loc /(X=66,040 mm, Y=231,140 mm);Loc /(X=82,550 mm, Y=231,140 mm));CP6;; + */ +/* short csv format sample: + * ref;value;footprint;Champ1;Champ2 + * C101;47pF;C1;field1;;1 + * C102;47pF;C1;;;1 + * C103..C106;47uF;CP6;;;4 + */ + +bool BOM_LISTER::PrintComponentsListByReferenceCsvForm( FILE* aFile ) +{ + m_outFile = aFile; + bool addDatasheet = isFieldPrintable( DATASHEET ); + + // Set option group references, for components having same field values + // (same value, same footprint ...) + // obviously, this is possible only when print location + // and include Sub Components are not enabled. + bool groupRefs = m_groupReferences; + bool includeSubComponents = m_includeSubComponents && !groupRefs; + + // Print component location if needed, but only when + // include sub component option is enabled, because for multiple + // parts per package there are more than one location per reference + bool printLocCmp = m_printLocation && !groupRefs && m_includeSubComponents; + + wxString msg; + + if( m_cmplist.GetCount() == 0 ) // Build component list + { + SCH_SHEET_LIST sheetList; + sheetList.GetComponents( m_cmplist, false ); + + // sort component list + m_cmplist.SortByReferenceOnly(); + + if( !includeSubComponents ) + m_cmplist.RemoveSubComponentsFromList(); + } + else + m_cmplist.SortByReferenceOnly(); + + // Print comment line: + msg = wxT( "ref" ); + msg << m_separatorSymbol << wxT( "value" ); + + if( addDatasheet ) + msg << m_separatorSymbol << wxT( "datasheet" ); + + if( printLocCmp ) + msg << m_separatorSymbol << wxT( "sheet path(location)" ); + + if( isFieldPrintable( FOOTPRINT ) ) + msg << m_separatorSymbol << wxT( "footprint" ); + + for( int ii = FIELD1; ii <= FIELD8; ii++ ) + { + if( isFieldPrintable( ii ) ) + msg << m_separatorSymbol << _( "Field" ) << ii - FIELD1 + 1; + } + + if( groupRefs ) + msg << m_separatorSymbol << _( "Item count" ); + + fprintf( m_outFile, "%s\n", TO_UTF8( msg ) ); + + // Print BOM list + wxString strCur; + wxString strPred; + int amount = 0; // number of items, on the same line + wxString cmpName; + wxString cmpNameFirst; + wxString cmpNameLast; + + // Print list of items, by reference + for( unsigned ii = 0; ii < m_cmplist.GetCount(); ii++ ) + { + EDA_ITEM* item = m_cmplist[ii].GetComponent(); + + if( item == NULL ) + continue; + + if( item->Type() != SCH_COMPONENT_T ) + continue; + + SCH_COMPONENT* comp = (SCH_COMPONENT*) item; + + LIB_COMPONENT* entry = CMP_LIBRARY::FindLibraryComponent( comp->GetLibName() ); + + bool isMulti = false; + + if( entry ) + isMulti = entry->IsMulti(); + + cmpName = m_cmplist[ii].GetRef(); + + if( isMulti && includeSubComponents ) + // Add unit ident, for mutiple parts per package + cmpName += LIB_COMPONENT::ReturnSubReference( m_cmplist[ii].GetUnit() ); + + if( groupRefs ) + { + // Store value and datasheet (will be printed later) + strCur.Empty(); + strCur << m_separatorSymbol << comp->GetField( VALUE )->m_Text; + + if( addDatasheet ) + strCur << m_separatorSymbol << comp->GetField( DATASHEET )->m_Text; + } + else + { + // Print the current component reference, value and datasheet + msg = cmpName; + msg << m_separatorSymbol << comp->GetField( VALUE )->m_Text; + + if( addDatasheet ) + msg << m_separatorSymbol << comp->GetField( DATASHEET )->m_Text; + + fprintf( m_outFile, "%s", TO_UTF8( msg ) ); + } + + if( printLocCmp ) // Is allowed only for full list (not grouped) + { + msg = returnURLItemLocation( + m_cmplist[ii].GetSheetPath().PathHumanReadable(), + comp->GetPosition() ); + msg << m_separatorSymbol; + + fprintf( m_outFile, "%s", TO_UTF8( msg ) ); + } + + if( groupRefs ) + { + wxString tmpStr = returnFieldsString( comp ); + strCur += tmpStr; + + if( strPred.Len() == 0 ) + cmpNameFirst = cmpName; + else + { + // print a BOM line + msg.Empty(); + if( !strCur.IsSameAs( strPred ) ) + { + switch( amount ) + { + case 1: // One reference to print + // format C103;47uF;CP6;;;1 + msg << cmpNameFirst < + * | 10pF C16 Loc /controle/(X=68,580 mm, Y=83,820 mm); + */ +int BOM_LISTER::PrintComponentsListByValue( FILE* aFile ) +{ + m_outFile = aFile; + + if( m_cmplist.GetCount() == 0 ) // Build component list + { + SCH_SHEET_LIST sheetList; + sheetList.GetComponents( m_cmplist, false ); + + if( !m_includeSubComponents ) + { + // sort component list + m_cmplist.SortByReferenceOnly(); + m_cmplist.RemoveSubComponentsFromList(); + } + } + + m_cmplist.SortByValueOnly(); + + wxString msg; + + msg = _( "\n#Cmp ( order = Value )" ); + + if( m_includeSubComponents ) + msg << _( " (with SubCmp)" ); + + msg << wxT( "\n" ); + + fputs( TO_UTF8( msg ), m_outFile ); + + std::string cmpName; + for( unsigned ii = 0; ii < m_cmplist.GetCount(); ii++ ) + { + EDA_ITEM* schItem = m_cmplist[ii].GetComponent(); + + if( schItem == NULL ) + continue; + + if( schItem->Type() != SCH_COMPONENT_T ) + continue; + + SCH_COMPONENT* drawLibItem = (SCH_COMPONENT*) schItem; + + bool isMulti = false; + LIB_COMPONENT* entry = CMP_LIBRARY::FindLibraryComponent( drawLibItem->GetLibName() ); + + if( entry ) + isMulti = entry->IsMulti(); + + cmpName = m_cmplist[ii].GetRefStr(); + + if( isMulti && m_includeSubComponents ) + // Add unit ident, for mutiple parts per package + cmpName += TO_UTF8( LIB_COMPONENT::ReturnSubReference( m_cmplist[ii].GetUnit() ) ); + + fprintf( m_outFile, "| %-12s %-10s", + TO_UTF8( drawLibItem->GetField( VALUE )->m_Text ), + cmpName.c_str() ); + + // print the sheet path and location + if( m_includeSubComponents ) + { + msg = returnURLItemLocation( m_cmplist[ii].GetSheetPath().PathHumanReadable(), + drawLibItem->GetPosition() ); + fprintf( m_outFile, "%s", TO_UTF8( msg ) ); + } + + fprintf( m_outFile, "%s\n", TO_UTF8( returnFieldsString( drawLibItem ) ) ); + } + + msg = _( "#End Cmp\n" ); + fputs( TO_UTF8( msg ), m_outFile ); return 0; } + + +/* returnURLItemLocation + * return a formated string to print the full location: + * /( X Y position) + * param aPathName = the full sheet name of item + * param aPosition = a position (in internal units) to print + */ +const wxString BOM_LISTER::returnURLItemLocation( const wxString& aPathName, + wxPoint aPosition ) +{ + wxString text; + + text.Printf( wxT( "Loc %s(X=%s, Y=%s)" ), GetChars( aPathName ), + GetChars( ReturnStringFromValue( g_UserUnit, aPosition.x, true ) ), + GetChars( ReturnStringFromValue( g_UserUnit, aPosition.y, true ) ) ); + return text; +} diff --git a/eeschema/dialogs/dialog_build_BOM.cpp b/eeschema/dialogs/dialog_build_BOM.cpp index d67b64da44..224ba98b87 100644 --- a/eeschema/dialogs/dialog_build_BOM.cpp +++ b/eeschema/dialogs/dialog_build_BOM.cpp @@ -1,7 +1,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2008 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com + * Copyright (C) 2012 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or @@ -35,7 +35,6 @@ #include #include -#include #include #include #include @@ -45,14 +44,7 @@ #include #include - -#include - - -extern void GenListeGLabels( std::vector & aList ); -extern bool SortLabelsByValue( const BOM_LABEL& obj1, const BOM_LABEL& obj2 ); -extern bool SortLabelsBySheet( const BOM_LABEL& obj1, const BOM_LABEL& obj2 ); -extern int PrintListeGLabel( FILE* f, std::vector & aList ); +#include /* Local variables */ @@ -64,7 +56,9 @@ static bool s_ListHierarchicalPinBySheet; static bool s_BrowseCreatedList; static int s_OutputFormOpt; static int s_OutputSeparatorOpt; +static bool s_Add_Location = false; static bool s_Add_FpField_state = true; +static bool s_Add_DatasheetField_state; static bool s_Add_F1_state; static bool s_Add_F2_state; static bool s_Add_F3_state; @@ -89,6 +83,7 @@ static bool* s_AddFieldList[] = &s_Add_F7_state, &s_Add_F8_state, &s_Add_Alls_state, + &s_Add_DatasheetField_state, NULL }; @@ -104,6 +99,7 @@ const wxString OPTION_BOM_FORMAT( wxT("BomFormat") ); const wxString OPTION_BOM_LAUNCH_BROWSER( wxT("BomLaunchBrowser") ); const wxString OPTION_BOM_SEPARATOR( wxT("BomExportSeparator") ); const wxString OPTION_BOM_ADD_FIELD ( wxT("BomAddField") ); +const wxString OPTION_BOM_ADD_LOCATION ( wxT("BomAddLocation") ); /* list of separators used in bom export to spreadsheet * (selected by s_OutputSeparatorOpt, and s_OutputSeparatorOpt radiobox) @@ -118,10 +114,10 @@ static char s_ExportSeparator[] = ("\t;,."); DIALOG_BUILD_BOM::DIALOG_BUILD_BOM( EDA_DRAW_FRAME* parent ) : DIALOG_BUILD_BOM_BASE( parent ) { - m_Config = wxGetApp().GetSettings(); - wxASSERT( m_Config != NULL ); + m_config = wxGetApp().GetSettings(); + wxASSERT( m_config != NULL ); - m_Parent = parent; + m_parent = parent; Init(); @@ -142,19 +138,20 @@ void DIALOG_BUILD_BOM::Init() SetFocus(); /* Get options */ - m_Config->Read( OPTION_BOM_LIST_REF, &s_ListByRef ); - m_Config->Read( OPTION_BOM_LIST_VALUE , &s_ListByValue ); - m_Config->Read( OPTION_BOM_LIST_HPINS, &s_ListHierarchicalPinByName ); - m_Config->Read( OPTION_BOM_LIST_HPINS_BY_SHEET, &s_ListWithSubCmponents ); - m_Config->Read( OPTION_BOM_LIST_HPINS_BY_NAME_, &s_ListWithSubCmponents ); - m_Config->Read( OPTION_BOM_LIST_SUB_CMP, &s_ListWithSubCmponents ); - m_Config->Read( OPTION_BOM_LIST_HPINS_BY_SHEET, &s_ListHierarchicalPinBySheet ); - m_Config->Read( OPTION_BOM_LIST_HPINS_BY_NAME_, &s_ListHierarchicalPinByName ); - s_OutputFormOpt = m_Config->Read( OPTION_BOM_FORMAT, (long) 0 ); - m_Config->Read( OPTION_BOM_LAUNCH_BROWSER, &s_BrowseCreatedList ); - s_OutputSeparatorOpt = m_Config->Read( OPTION_BOM_SEPARATOR, (long) 0 ); - long addfields = m_Config->Read( OPTION_BOM_ADD_FIELD, (long) 0 ); + m_config->Read( OPTION_BOM_LIST_REF, &s_ListByRef ); + m_config->Read( OPTION_BOM_LIST_VALUE , &s_ListByValue ); + m_config->Read( OPTION_BOM_LIST_HPINS, &s_ListHierarchicalPinByName ); + m_config->Read( OPTION_BOM_LIST_HPINS_BY_SHEET, &s_ListWithSubCmponents ); + m_config->Read( OPTION_BOM_LIST_HPINS_BY_NAME_, &s_ListWithSubCmponents ); + m_config->Read( OPTION_BOM_LIST_SUB_CMP, &s_ListWithSubCmponents ); + m_config->Read( OPTION_BOM_LIST_HPINS_BY_SHEET, &s_ListHierarchicalPinBySheet ); + m_config->Read( OPTION_BOM_LIST_HPINS_BY_NAME_, &s_ListHierarchicalPinByName ); + s_OutputFormOpt = m_config->Read( OPTION_BOM_FORMAT, 0l ); + m_config->Read( OPTION_BOM_LAUNCH_BROWSER, &s_BrowseCreatedList ); + s_OutputSeparatorOpt = m_config->Read( OPTION_BOM_SEPARATOR, 0l ); + m_config->Read( OPTION_BOM_ADD_LOCATION, &s_Add_Location ); + long addfields = m_config->Read( OPTION_BOM_ADD_FIELD, 0l ); for( int ii = 0, bitmask = 1; s_AddFieldList[ii] != NULL; ii++ ) { if( (addfields & bitmask) ) @@ -174,7 +171,10 @@ void DIALOG_BUILD_BOM::Init() m_OutputFormCtrl->SetValidator( wxGenericValidator( &s_OutputFormOpt ) ); m_OutputSeparatorCtrl->SetValidator( wxGenericValidator( &s_OutputSeparatorOpt ) ); m_GetListBrowser->SetValidator( wxGenericValidator( &s_BrowseCreatedList ) ); + + m_AddLocationField->SetValidator( wxGenericValidator( &s_Add_Location ) ); m_AddFootprintField->SetValidator( wxGenericValidator( &s_Add_FpField_state ) ); + m_AddDatasheetField->SetValidator( wxGenericValidator( &s_Add_DatasheetField_state ) ); m_AddField1->SetValidator( wxGenericValidator( &s_Add_F1_state ) ); m_AddField2->SetValidator( wxGenericValidator( &s_Add_F2_state ) ); m_AddField3->SetValidator( wxGenericValidator( &s_Add_F3_state ) ); @@ -194,39 +194,52 @@ void DIALOG_BUILD_BOM::Init() } -/*! - * wxEVT_COMMAND_RADIOBOX_SELECTED event handler for ID_RADIOBOX_SELECT_FORMAT +/* + * Called on BOM format selection: + * Enable/disable options in dialog */ - void DIALOG_BUILD_BOM::OnRadioboxSelectFormatSelected( wxCommandEvent& event ) { switch( m_OutputFormCtrl->GetSelection() ) { - case 0: + case 0: // Human readable text full report m_OutputSeparatorCtrl->Enable( false ); m_ListCmpbyRefItems->Enable( true ); m_ListCmpbyValItems->Enable( true ); m_GenListLabelsbyVal->Enable( true ); m_GenListLabelsbySheet->Enable( true ); m_ListSubCmpItems->Enable( true ); + m_AddLocationField->Enable( true ); break; - case 1: + case 1: // Csv format, full list by reference m_OutputSeparatorCtrl->Enable( true ); m_ListCmpbyRefItems->Enable( false ); m_ListCmpbyValItems->Enable( false ); m_GenListLabelsbyVal->Enable( false ); m_GenListLabelsbySheet->Enable( false ); m_ListSubCmpItems->Enable( true ); + m_AddLocationField->Enable( true ); break; - case 2: + case 2: // Csv format, grouped list by reference m_OutputSeparatorCtrl->Enable( true ); m_ListCmpbyRefItems->Enable( false ); m_ListCmpbyValItems->Enable( false ); m_GenListLabelsbyVal->Enable( false ); m_GenListLabelsbySheet->Enable( false ); m_ListSubCmpItems->Enable( false ); + m_AddLocationField->Enable( false ); + break; + + case 3: // Csv format, short list by values + m_OutputSeparatorCtrl->Enable( true ); + m_ListCmpbyRefItems->Enable( false ); + m_ListCmpbyValItems->Enable( false ); + m_GenListLabelsbyVal->Enable( false ); + m_GenListLabelsbySheet->Enable( false ); + m_ListSubCmpItems->Enable( false ); + m_AddLocationField->Enable( false ); break; } } @@ -264,8 +277,6 @@ void DIALOG_BUILD_BOM::OnCancelClick( wxCommandEvent& event ) void DIALOG_BUILD_BOM::SavePreferences() { - wxASSERT( m_Config != NULL ); - // Determine current settings of "List items" and "Options" checkboxes s_ListByRef = m_ListCmpbyRefItems->GetValue(); s_ListWithSubCmponents = m_ListSubCmpItems->GetValue(); @@ -284,7 +295,9 @@ void DIALOG_BUILD_BOM::SavePreferences() s_OutputSeparatorOpt = 0; // Determine current settings of all "Fields to add" checkboxes + s_Add_Location = m_AddLocationField->GetValue(); s_Add_FpField_state = m_AddFootprintField->GetValue(); + s_Add_DatasheetField_state = m_AddDatasheetField->GetValue(); s_Add_F1_state = m_AddField1->GetValue(); s_Add_F2_state = m_AddField2->GetValue(); s_Add_F3_state = m_AddField3->GetValue(); @@ -296,20 +309,21 @@ void DIALOG_BUILD_BOM::SavePreferences() s_Add_Alls_state = m_AddAllFields->GetValue(); // Now save current settings of both radiobutton groups - m_Config->Write( OPTION_BOM_LIST_REF, s_ListByRef ); - m_Config->Write( OPTION_BOM_LIST_VALUE , s_ListByValue ); - m_Config->Write( OPTION_BOM_LIST_HPINS, s_ListHierarchicalPinByName ); - m_Config->Write( OPTION_BOM_LIST_HPINS_BY_SHEET, s_ListHierarchicalPinBySheet ); - m_Config->Write( OPTION_BOM_LIST_HPINS_BY_NAME_, s_ListHierarchicalPinByName ); - m_Config->Write( OPTION_BOM_LIST_SUB_CMP, s_ListWithSubCmponents ); + m_config->Write( OPTION_BOM_LIST_REF, s_ListByRef ); + m_config->Write( OPTION_BOM_LIST_VALUE , s_ListByValue ); + m_config->Write( OPTION_BOM_LIST_HPINS, s_ListHierarchicalPinByName ); + m_config->Write( OPTION_BOM_LIST_HPINS_BY_SHEET, s_ListHierarchicalPinBySheet ); + m_config->Write( OPTION_BOM_LIST_HPINS_BY_NAME_, s_ListHierarchicalPinByName ); + m_config->Write( OPTION_BOM_LIST_SUB_CMP, s_ListWithSubCmponents ); - m_Config->Write( OPTION_BOM_FORMAT, (long) s_OutputFormOpt ); - m_Config->Write( OPTION_BOM_SEPARATOR, (long) s_OutputSeparatorOpt ); - m_Config->Write( OPTION_BOM_LAUNCH_BROWSER, (long) s_BrowseCreatedList ); + m_config->Write( OPTION_BOM_FORMAT, (long) s_OutputFormOpt ); + m_config->Write( OPTION_BOM_SEPARATOR, (long) s_OutputSeparatorOpt ); + m_config->Write( OPTION_BOM_LAUNCH_BROWSER, (long) s_BrowseCreatedList ); // Now save current settings of all "Fields to add" checkboxes - long addfields = 0; + m_config->Write( OPTION_BOM_ADD_LOCATION, s_Add_Location ); + long addfields = 0; for( int ii = 0, bitmask = 1; s_AddFieldList[ii] != NULL; ii++ ) { if( *s_AddFieldList[ii] ) @@ -318,7 +332,7 @@ void DIALOG_BUILD_BOM::SavePreferences() bitmask <<= 1; } - m_Config->Write( OPTION_BOM_ADD_FIELD, addfields ); + m_config->Write( OPTION_BOM_ADD_FIELD, addfields ); } @@ -363,30 +377,33 @@ void DIALOG_BUILD_BOM::Create_BOM_Lists( int aTypeFile, } wxFileDialog dlg( this, bomDesc, fn.GetPath(), - fn.GetFullName(), wildcard, - wxFD_SAVE | wxFD_OVERWRITE_PROMPT ); + fn.GetFullName(), wildcard, wxFD_SAVE ); if( dlg.ShowModal() == wxID_CANCEL ) return; fn = dlg.GetPath(); // remember path+filename+ext for subsequent runs. - m_ListFileName = dlg.GetPath(); + m_listFileName = dlg.GetPath(); // Close dialog, then show the list (if so requested) switch( aTypeFile ) { case 0: // list - GenereListeOfItems( aIncludeSubComponents ); + CreatePartsAndLabelsFullList( aIncludeSubComponents ); break; case 1: // spreadsheet, Single Part per line - CreateExportList( aIncludeSubComponents ); + CreateSpreadSheetPartsFullList( aIncludeSubComponents, s_Add_Location, false ); break; - case 2: // spreadsheet, one value per line and no sub-component - CreatePartsList(); + case 2: // spreadsheet, group Part with same fields per line + CreateSpreadSheetPartsFullList( aIncludeSubComponents, s_Add_Location, true ); + break; + + case 3: // spreadsheet, one value per line and no sub-component + CreateSpreadSheetPartsShortList(); break; } @@ -395,7 +412,7 @@ void DIALOG_BUILD_BOM::Create_BOM_Lists( int aTypeFile, if( aRunBrowser ) { wxString editorname = wxGetApp().GetEditorName(); - wxString filename = m_ListFileName; + wxString filename = m_listFileName; AddDelimiterString( filename ); ExecuteFile( this, editorname, filename ); } @@ -403,7 +420,7 @@ void DIALOG_BUILD_BOM::Create_BOM_Lists( int aTypeFile, /** Helper function IsFieldChecked * return the state of the wxCheckbox corresponding to the - * field aFieldId (FOOTPRINT and FIELD1 to FIELD8 + * field aFieldId (FOOTPRINT, DATASHEET and FIELD1 to FIELD8 * if the option "All user fields" is checked, return always true * for fileds ids >= FIELD1 * @param aFieldId = the field id : FOOTPRINT to FIELD8 @@ -433,6 +450,8 @@ bool DIALOG_BUILD_BOM::IsFieldChecked(int aFieldId) return m_AddField8->IsChecked(); case FOOTPRINT: return m_AddFootprintField->IsChecked(); + case DATASHEET: + return m_AddDatasheetField->IsChecked(); } return false; @@ -446,32 +465,27 @@ bool DIALOG_BUILD_BOM::IsFieldChecked(int aFieldId) * value; number of components; list of references; ; ; ...; * list is sorted by values */ -void DIALOG_BUILD_BOM::CreatePartsList( ) +void DIALOG_BUILD_BOM::CreateSpreadSheetPartsShortList( ) { - FILE* f; - wxString msg; + FILE* f; - if( ( f = wxFopen( m_ListFileName, wxT( "wt" ) ) ) == NULL ) + if( ( f = wxFopen( m_listFileName, wxT( "wt" ) ) ) == NULL ) { - msg = _( "Failed to open file " ); - msg << m_ListFileName; + wxString msg; + msg.Printf( _( "Failed to open file '%s'" ), GetChars(m_listFileName) ); DisplayError( this, msg ); return; } - SCH_REFERENCE_LIST cmplist; - SCH_SHEET_LIST sheetList; + BOM_LISTER bom_lister; + bom_lister.SetCvsFormOn( s_ExportSeparatorSymbol ); - sheetList.GetComponents( cmplist, false ); - - // sort component list by ref and remove sub components - cmplist.RemoveSubComponentsFromList(); - - // sort component list by value - cmplist.SortByValueOnly( ); - PrintComponentsListByPart( f, cmplist, false ); - - fclose( f ); + // Set the list of fields to add to list + for( int ii = FOOTPRINT; ii < FIELD8; ii++ ) + if( IsFieldChecked( ii ) ) + bom_lister.AddFieldIdToPrintList( ii ); + // Write the list of components grouped by values: + bom_lister.CreateCsvBOMListByValues( f ); } @@ -480,503 +494,100 @@ void DIALOG_BUILD_BOM::CreatePartsList( ) * form is: * cmp ref; cmp val; fields; * Components are sorted by reference + * param aIncludeSubComponents = true to print sub components + * param aPrintLocation = true to print components location + * (only possible when aIncludeSubComponents == true) + * param aGroupRefs = true to group components references, when other fieds + * have the same value */ -void DIALOG_BUILD_BOM::CreateExportList( bool aIncludeSubComponents ) +void DIALOG_BUILD_BOM::CreateSpreadSheetPartsFullList( bool aIncludeSubComponents, + bool aPrintLocation, + bool aGroupRefs ) { FILE* f; wxString msg; - if( ( f = wxFopen( m_ListFileName, wxT( "wt" ) ) ) == NULL ) + if( ( f = wxFopen( m_listFileName, wxT( "wt" ) ) ) == NULL ) { msg = _( "Failed to open file " ); - msg << m_ListFileName; + msg << m_listFileName; DisplayError( this, msg ); return; } - SCH_REFERENCE_LIST cmplist; - SCH_SHEET_LIST sheetList; // uses a global + BOM_LISTER bom_lister; + bom_lister.SetCvsFormOn( s_ExportSeparatorSymbol ); - sheetList.GetComponents( cmplist, false ); + // Set group refs option (hight priority): + // Obvioulsy only useful when not including sub-components + bom_lister.SetGroupReferences( aGroupRefs ); + bom_lister.SetIncludeSubCmp( aIncludeSubComponents && !aGroupRefs ); - // sort component list - cmplist.SortByReferenceOnly( ); + // Set print location option: + // Obvioulsy only possible when including sub components + // and not grouping references + bom_lister.SetPrintLocation( aPrintLocation && !aGroupRefs && + aIncludeSubComponents ); - if( !aIncludeSubComponents ) - cmplist.RemoveSubComponentsFromList(); + // Set the list of fields to add to list + for( int ii = FOOTPRINT; ii < FIELD8; ii++ ) + if( IsFieldChecked( ii ) ) + bom_lister.AddFieldIdToPrintList( ii ); // create the file - PrintComponentsListByRef( f, cmplist, true, aIncludeSubComponents ); + bom_lister.PrintComponentsListByReferenceCsvForm( f ); fclose( f ); } /* - * GenereListeOfItems() + * CreatePartsAndLabelsFullList() * Main function to create the list of components and/or labels - * (global labels and pin sheets" ) + * (global labels, hierarchical labels and pin sheets ) */ -void DIALOG_BUILD_BOM::GenereListeOfItems( bool aIncludeSubComponents ) +void DIALOG_BUILD_BOM::CreatePartsAndLabelsFullList( bool aIncludeSubComponents ) { FILE* f; - int itemCount; wxString msg; - if( ( f = wxFopen( m_ListFileName, wxT( "wt" ) ) ) == NULL ) + if( ( f = wxFopen( m_listFileName, wxT( "wt" ) ) ) == NULL ) { msg = _( "Failed to open file " ); - msg << m_ListFileName; + msg << m_listFileName; DisplayError( this, msg ); return; } - SCH_REFERENCE_LIST cmplist; - SCH_SHEET_LIST sheetList; + BOM_LISTER bom_lister; + bom_lister.SetIncludeSubCmp( aIncludeSubComponents ); + bom_lister.SetCvsFormOff(); + bom_lister.SetPrintLocation( s_Add_Location ); + // Set the list of fields to add to list + for( int ii = FOOTPRINT; ii < FIELD8; ii++ ) + if( IsFieldChecked( ii ) ) + bom_lister.AddFieldIdToPrintList( ii ); - sheetList.GetComponents( cmplist, false ); + // creates the list file + wxString Title = wxGetApp().GetAppName() + wxT( " " ) + GetBuildVersion(); - itemCount = cmplist.GetCount(); + fprintf( f, "%s >> Creation date: %s\n", TO_UTF8( Title ), TO_UTF8( DateAndTime() ) ); - if( itemCount ) - { - // creates the list file - wxString Title = wxGetApp().GetAppName() + wxT( " " ) + GetBuildVersion(); + if( m_ListCmpbyRefItems->GetValue() ) + bom_lister.PrintComponentsListByReferenceHumanReadable( f ); - fprintf( f, "%s >> Creation date: %s\n", TO_UTF8( Title ), TO_UTF8( DateAndTime() ) ); + if( m_ListCmpbyValItems->GetValue() ) + bom_lister.PrintComponentsListByValue( f ); - // sort component list - cmplist.SortByReferenceOnly(); + // Create list of global labels, hierachical labels and pins sheets - if( !aIncludeSubComponents ) - cmplist.RemoveSubComponentsFromList(); + if( m_GenListLabelsbySheet->GetValue() ) + bom_lister.PrintGlobalAndHierarchicalLabelsList( f, true ); - if( m_ListCmpbyRefItems->GetValue() ) - PrintComponentsListByRef( f, cmplist, false, aIncludeSubComponents ); - - if( m_ListCmpbyValItems->GetValue() ) - { - cmplist.SortByValueOnly(); - PrintComponentsListByVal( f, cmplist, aIncludeSubComponents ); - } - } - - /*************************************************/ - /* Create list of global labels and pins sheets */ - /*************************************************/ - std::vector listOfLabels; - - GenListeGLabels( listOfLabels ); - - if( ( itemCount = listOfLabels.size() ) > 0 ) - { - if( m_GenListLabelsbySheet->GetValue() ) - { - sort( listOfLabels.begin(), listOfLabels.end(), SortLabelsBySheet ); - - msg.Printf( _( "\n#Global, Hierarchical Labels and PinSheets \ -( order = Sheet Number ) count = %d\n" ), - itemCount ); - - fprintf( f, "%s", TO_UTF8( msg ) ); - PrintListeGLabel( f, listOfLabels ); - } - - if( m_GenListLabelsbyVal->GetValue() ) - { - sort( listOfLabels.begin(), listOfLabels.end(), SortLabelsByValue ); - - msg.Printf( _( "\n#Global, Hierarchical Labels and PinSheets ( \ -order = Alphab. ) count = %d\n\n" ), - itemCount ); - - fprintf( f, "%s", TO_UTF8( msg ) ); - PrintListeGLabel( f, listOfLabels ); - } - } + if( m_GenListLabelsbyVal->GetValue() ) + bom_lister.PrintGlobalAndHierarchicalLabelsList( f, false ); msg = _( "\n#End List\n" ); fprintf( f, "%s", TO_UTF8( msg ) ); fclose( f ); } - -wxString DIALOG_BUILD_BOM::PrintFieldData( SCH_COMPONENT* DrawLibItem, - bool CompactForm ) -{ - wxString outStr; - wxString tmpStr; - - if( IsFieldChecked( FOOTPRINT ) ) - { - if( CompactForm ) - { - outStr.Printf( wxT( "%c%s" ), s_ExportSeparatorSymbol, - GetChars( DrawLibItem->GetField( FOOTPRINT )->m_Text ) ); - } - else - { - outStr.Printf( wxT( "; %-12s" ), - GetChars( DrawLibItem->GetField( FOOTPRINT )->m_Text ) ); - } - } - - for(int ii = FIELD1; ii < DrawLibItem->GetFieldCount(); ii++ ) - { - if( ! IsFieldChecked( ii ) ) - continue; - - if( CompactForm ) - { - tmpStr.Printf( wxT( "%c%s" ), s_ExportSeparatorSymbol, - GetChars( DrawLibItem->GetField( ii )->m_Text ) ); - outStr += tmpStr; - } - else - { - tmpStr.Printf( wxT( "; %-12s" ), - GetChars( DrawLibItem->GetField( ii )->m_Text ) ); - outStr += tmpStr; - } - } - return outStr; -} - - -/* Print the B.O.M sorted by reference - */ -int DIALOG_BUILD_BOM::PrintComponentsListByRef( FILE* f, - SCH_REFERENCE_LIST& aList, - bool CompactForm, - bool aIncludeSubComponents ) -{ - wxString msg; - - if( CompactForm ) - { - // Print comment line: -#if defined(KICAD_GOST) - fprintf( f, "ref%cvalue%cdatasheet", s_ExportSeparatorSymbol, s_ExportSeparatorSymbol ); -#else - fprintf( f, "ref%cvalue", s_ExportSeparatorSymbol ); -#endif - - if( aIncludeSubComponents ) - { - fprintf( f, "%csheet path", s_ExportSeparatorSymbol ); - fprintf( f, "%clocation", s_ExportSeparatorSymbol ); - } - - if( IsFieldChecked( FOOTPRINT ) ) - fprintf( f, "%cfootprint", s_ExportSeparatorSymbol ); - - for( int ii = FIELD1; ii <= FIELD8; ii++ ) - { - if( !IsFieldChecked( ii ) ) - continue; - - msg = _( "Field" ); - - fprintf( f, "%c%s%d", s_ExportSeparatorSymbol, TO_UTF8( msg ), ii - FIELD1 + 1 ); - } - - fprintf( f, "\n" ); - } - else - { - msg = _( "\n#Cmp ( order = Reference )" ); - - if( aIncludeSubComponents ) - msg << _( " (with SubCmp)" ); - - fprintf( f, "%s\n", TO_UTF8( msg ) ); - } - - std::string CmpName; - wxString subRef; - -#if defined(KICAD_GOST) - wxString strCur; - wxString strPred; - int amount = 0; - std::string CmpNameFirst; - std::string CmpNameLast; -#endif - - // Print list of items - for( unsigned ii = 0; ii < aList.GetCount(); ii++ ) - { - EDA_ITEM* item = aList[ii].GetComponent(); - - if( item == NULL ) - continue; - - if( item->Type() != SCH_COMPONENT_T ) - continue; - - SCH_COMPONENT* comp = (SCH_COMPONENT*) item; - - bool isMulti = false; - - LIB_COMPONENT* entry = CMP_LIBRARY::FindLibraryComponent( comp->GetLibName() ); - - if( entry ) - isMulti = entry->IsMulti(); - - if( isMulti && aIncludeSubComponents ) - subRef = LIB_COMPONENT::ReturnSubReference( aList[ii].GetUnit() ); - else - subRef.Empty(); - - CmpName = aList[ii].GetRefStr(); - - if( !CompactForm ) - CmpName += TO_UTF8(subRef); - - if( CompactForm ) -#if defined(KICAD_GOST) - strCur.Printf( wxT( "%c%s%c%s" ), s_ExportSeparatorSymbol, - GetChars( comp->GetField( VALUE )->m_Text ), s_ExportSeparatorSymbol, - GetChars( comp->GetField( DATASHEET )->m_Text ) ); -#else - fprintf( f, "%s%c%s", CmpName.c_str(), s_ExportSeparatorSymbol, - TO_UTF8( comp->GetField( VALUE )->m_Text ) ); -#endif - - else -#if defined(KICAD_GOST) - fprintf( f, "| %-10s %-12s %-20s", CmpName.c_str(), - TO_UTF8( comp->GetField( VALUE )->m_Text ), - TO_UTF8( comp->GetField( DATASHEET )->m_Text ) ); -#else - fprintf( f, "| %-10s %-12s", CmpName.c_str(), - TO_UTF8( comp->GetField( VALUE )->m_Text ) ); -#endif - - if( aIncludeSubComponents ) - { - msg = aList[ii].GetSheetPath().PathHumanReadable(); - BASE_SCREEN * screen = (BASE_SCREEN*) comp->GetParent(); - - if( screen ) - { - if( CompactForm ) - { -#if defined(KICAD_GOST) - strCur.Printf( wxT( "%c%s" ), s_ExportSeparatorSymbol, GetChars( msg ) ); - msg = m_Parent->GetXYSheetReferences( comp->GetPosition() ); - strCur.Printf( wxT( "%c%s)" ), s_ExportSeparatorSymbol, GetChars( msg ) ); -#else - fprintf( f, "%c%s", s_ExportSeparatorSymbol, TO_UTF8( msg ) ); - msg = m_Parent->GetXYSheetReferences( comp->GetPosition() ); - fprintf( f, "%c%s)", s_ExportSeparatorSymbol, - TO_UTF8( msg ) ); -#endif - } - else - { - fprintf( f, " (Sheet %s)", TO_UTF8( msg ) ); - msg = m_Parent->GetXYSheetReferences( comp->GetPosition() ); - fprintf( f, " (loc %s)", TO_UTF8( msg ) ); - } - } - } - -#if defined(KICAD_GOST) - wxString tmpStr = PrintFieldData( comp, CompactForm ); - strCur += tmpStr; - - if ( CompactForm ) - { - if ( strPred.Len() == 0 ) - { - CmpNameFirst = CmpName; - } - else - { - if ( !strCur.IsSameAs(strPred) ) - { - switch (amount) - { - case 1: - fprintf( f, "%s%s%c%d\n", CmpNameFirst.c_str(), TO_UTF8( strPred ), - s_ExportSeparatorSymbol, amount ); - break; - - case 2: - fprintf( f, "%s,%s%s%c%d\n", CmpNameFirst.c_str(), CmpNameLast.c_str(), - TO_UTF8(strPred), s_ExportSeparatorSymbol, amount ); - break; - - default: - fprintf( f, "%s..%s%s%c%d\n", CmpNameFirst.c_str(), CmpNameLast.c_str(), - TO_UTF8( strPred ), s_ExportSeparatorSymbol, amount ); - break; - } - CmpNameFirst = CmpName; - amount = 0; - } - } - strPred = strCur; - CmpNameLast = CmpName; - amount++; - } - else - { - fprintf( f, "%s", TO_UTF8( tmpStr ) ); - fprintf( f, "\n" ); - } -#else - wxString tmpStr = PrintFieldData( comp, CompactForm ); - fprintf( f, "%s\n", TO_UTF8( tmpStr ) ); -#endif - - } - - if( !CompactForm ) - { - msg = _( "#End Cmp\n" ); - fputs( TO_UTF8( msg ), f ); - } - -#if defined(KICAD_GOST) - else - { - switch (amount) - { - case 1: - fprintf( f, "%s%s%c%d\n", CmpNameFirst.c_str(), TO_UTF8( strPred ), - s_ExportSeparatorSymbol, amount ); - break; - - case 2: - fprintf( f, "%s,%s%s%c%d\n", CmpNameFirst.c_str(), CmpNameLast.c_str(), - TO_UTF8( strPred ), s_ExportSeparatorSymbol, amount ); - break; - - default: - fprintf( f, "%s..%s%s%c%d\n", CmpNameFirst.c_str(), CmpNameLast.c_str(), - TO_UTF8( strPred ), s_ExportSeparatorSymbol, amount ); - break; - } - } -#endif - - return 0; -} - - -int DIALOG_BUILD_BOM::PrintComponentsListByPart( FILE* aFile, SCH_REFERENCE_LIST& aList, - bool aIncludeSubComponents ) -{ - unsigned int index = 0; - while( index < aList.GetCount() ) - { - SCH_COMPONENT *component = aList[index].GetComponent(); - wxString referenceListStr; - int qty = 1; - referenceListStr.append( aList[index].GetRef() ); - for( unsigned int i = index+1; i < aList.GetCount(); ) - { - if( *(aList[i].GetComponent()) == *component ) - { - referenceListStr.append( wxT( " " ) + aList[i].GetRef() ); - aList.RemoveItem( i ); - qty++; - } - else - i++; // Increment index only when current item is not removed from the list - } - - // Write value, quantity and list of references - fprintf( aFile, "%15s%c%3d%c\"%s\"", TO_UTF8( component->GetField( VALUE )->GetText() ), - s_ExportSeparatorSymbol, qty, - s_ExportSeparatorSymbol, TO_UTF8( referenceListStr ) ); - - // Write the rest of the fields if required -#if defined( KICAD_GOST ) - fprintf( aFile, "%c%20s", s_ExportSeparatorSymbol, - TO_UTF8( component->GetField( DATASHEET )->GetText() ) ); -#endif - for( int i = FOOTPRINT; i < component->GetFieldCount(); i++ ) - if( IsFieldChecked( i ) ) - fprintf( aFile, "%c%15s", s_ExportSeparatorSymbol, - TO_UTF8( component->GetField( i )->GetText() ) ); - fprintf( aFile, "\n" ); - index++; - } - return 0; -} - - -int DIALOG_BUILD_BOM::PrintComponentsListByVal( FILE* f, - SCH_REFERENCE_LIST& aList, - bool aIncludeSubComponents ) -{ - EDA_ITEM* schItem; - SCH_COMPONENT* DrawLibItem; - LIB_COMPONENT* entry; - std::string CmpName; - wxString msg; - - msg = _( "\n#Cmp ( order = Value )" ); - - if( aIncludeSubComponents ) - msg << _( " (with SubCmp)" ); - - msg << wxT( "\n" ); - - fputs( TO_UTF8( msg ), f ); - - for( unsigned ii = 0; ii < aList.GetCount(); ii++ ) - { - schItem = aList[ii].GetComponent(); - - if( schItem == NULL ) - continue; - - if( schItem->Type() != SCH_COMPONENT_T ) - continue; - - DrawLibItem = (SCH_COMPONENT*) schItem; - - bool isMulti = false; - entry = CMP_LIBRARY::FindLibraryComponent( DrawLibItem->GetLibName() ); - - if( entry ) - isMulti = entry->IsMulti(); - - wxString subRef; - - if( isMulti && aIncludeSubComponents ) - subRef = LIB_COMPONENT::ReturnSubReference( aList[ii].GetUnit() ); - else - subRef.Empty(); - - CmpName = aList[ii].GetRefStr(); - CmpName += TO_UTF8(subRef); - - fprintf( f, "| %-12s %-10s", - TO_UTF8( DrawLibItem->GetField( VALUE )->m_Text ), - CmpName.c_str() ); - - // print the sheet path - if( aIncludeSubComponents ) - { - BASE_SCREEN * screen = (BASE_SCREEN*) DrawLibItem->GetParent(); - - if( screen ) - { - msg = aList[ii].GetSheetPath().PathHumanReadable(); - fprintf( f, " (Sheet %s)", TO_UTF8( msg ) ); - msg = m_Parent->GetXYSheetReferences( DrawLibItem->GetPosition() ); - fprintf( f, " (loc %s)", TO_UTF8( msg ) ); - } - } - - fprintf( f, "%s\n", TO_UTF8( PrintFieldData( DrawLibItem ) ) ); - } - - msg = _( "#End Cmp\n" ); - fputs( TO_UTF8( msg ), f ); - return 0; -} diff --git a/eeschema/dialogs/dialog_build_BOM.h b/eeschema/dialogs/dialog_build_BOM.h index ed88d4317e..ea83e5980f 100644 --- a/eeschema/dialogs/dialog_build_BOM.h +++ b/eeschema/dialogs/dialog_build_BOM.h @@ -1,8 +1,29 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: dialog_build_BOM.h -// Copyright: GNU license -// Licence: -///////////////////////////////////////////////////////////////////////////// +/** + * @file dialog_build_BOM.h + */ + +/* This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 1992-2012 KiCad Developers, see AUTHORS.txt for contributors. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, you may find one here: + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * or you may search the http://www.gnu.org website for the version 2 license, + * or you may write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + #ifndef _DIALOG_BUILD_BOM_H_ #define _DIALOG_BUILD_BOM_H_ @@ -14,13 +35,12 @@ class EDA_DRAW_FRAME; class SCH_COMPONENT; class wxConfig; - class DIALOG_BUILD_BOM : public DIALOG_BUILD_BOM_BASE { private: - EDA_DRAW_FRAME* m_Parent; - wxConfig* m_Config; - wxString m_ListFileName; // The full filename of the file report. + EDA_DRAW_FRAME* m_parent; + wxConfig* m_config; + wxString m_listFileName; // The full filename of the file report. private: void OnRadioboxSelectFormatSelected( wxCommandEvent& event ); @@ -34,19 +54,26 @@ private: char aExportSeparatorSymbol, bool aRunBrowser ); - void GenereListeOfItems( bool aIncludeSubComponents ); + void CreatePartsAndLabelsFullList( bool aIncludeSubComponents ); /** - * Function CreateExportList + * Function CreateSpreadSheetPartsFullList * prints a list of components, in a form which can be imported by a * spreadsheet. Form is: * reference; cmp value; \; \; ...; * Components are sorted by reference + * @param aIncludeSubComponents = true to print sub components + * @param aPrintLocation = true to print components location + * (only possible when aIncludeSubComponents == true) + * @param aGroupRefs = true to group components references, when other fieds + * have the same value */ - void CreateExportList( bool aIncludeSubComponents ); + void CreateSpreadSheetPartsFullList( bool aIncludeSubComponents, + bool aPrintLocation, + bool aGroupRefs ); /** - * Function CreatePartsList + * Function CreateSpreadSheetPartsShortList * prints a list of components, in a form which can be imported by a spreadsheet. * components having the same value and the same footprint * are grouped on the same line @@ -54,18 +81,7 @@ private: * value; number of components; list of references; \; \; ...; * list is sorted by values */ - void CreatePartsList(); - - int PrintComponentsListByRef( FILE* f, SCH_REFERENCE_LIST& aList, - bool CompactForm, bool aIncludeSubComponents ); - - int PrintComponentsListByVal( FILE* f, SCH_REFERENCE_LIST& aList, - bool aIncludeSubComponents ); - - int PrintComponentsListByPart( FILE* f, SCH_REFERENCE_LIST& aList, - bool aIncludeSubComponents ); - - wxString PrintFieldData( SCH_COMPONENT* DrawLibItem, bool CompactForm = false ); + void CreateSpreadSheetPartsShortList(); bool IsFieldChecked( int aFieldId ); diff --git a/eeschema/dialogs/dialog_build_BOM_base.cpp b/eeschema/dialogs/dialog_build_BOM_base.cpp index 4af3b63697..cfdb347391 100644 --- a/eeschema/dialogs/dialog_build_BOM_base.cpp +++ b/eeschema/dialogs/dialog_build_BOM_base.cpp @@ -1,155 +1,156 @@ -/////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Apr 21 2008) -// http://www.wxformbuilder.org/ -// -// PLEASE DO "NOT" EDIT THIS FILE! -/////////////////////////////////////////////////////////////////////////// - -#include "dialog_build_BOM_base.h" - -/////////////////////////////////////////////////////////////////////////// - -DIALOG_BUILD_BOM_BASE::DIALOG_BUILD_BOM_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style ) -{ - this->SetSizeHints( wxDefaultSize, wxDefaultSize ); - - wxBoxSizer* bMainSizer; - bMainSizer = new wxBoxSizer( wxHORIZONTAL ); - - wxStaticBoxSizer* sbOptionsSizer; - sbOptionsSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Options:") ), wxVERTICAL ); - - wxStaticBoxSizer* sbListOptionsSizer; - sbListOptionsSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("List items:") ), wxVERTICAL ); - - m_ListCmpbyRefItems = new wxCheckBox( this, wxID_ANY, _("Components by reference"), wxDefaultPosition, wxDefaultSize, 0 ); - - sbListOptionsSizer->Add( m_ListCmpbyRefItems, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); - - m_ListSubCmpItems = new wxCheckBox( this, wxID_ANY, _("Sub components (i.e. U2A, U2B ...)"), wxDefaultPosition, wxDefaultSize, 0 ); - - sbListOptionsSizer->Add( m_ListSubCmpItems, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); - - m_ListCmpbyValItems = new wxCheckBox( this, wxID_ANY, _("Components by value"), wxDefaultPosition, wxDefaultSize, 0 ); - - sbListOptionsSizer->Add( m_ListCmpbyValItems, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); - - m_GenListLabelsbyVal = new wxCheckBox( this, wxID_ANY, _("Hierarchy pins by name"), wxDefaultPosition, wxDefaultSize, 0 ); - - sbListOptionsSizer->Add( m_GenListLabelsbyVal, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); - - m_GenListLabelsbySheet = new wxCheckBox( this, wxID_ANY, _("Hierarchy pins by sheets"), wxDefaultPosition, wxDefaultSize, 0 ); - - sbListOptionsSizer->Add( m_GenListLabelsbySheet, 0, wxALL, 5 ); - - sbOptionsSizer->Add( sbListOptionsSizer, 0, wxEXPAND, 5 ); - - wxString m_OutputFormCtrlChoices[] = { _("List"), _("Text for spreadsheet import"), _("Single Part per line") }; - int m_OutputFormCtrlNChoices = sizeof( m_OutputFormCtrlChoices ) / sizeof( wxString ); - m_OutputFormCtrl = new wxRadioBox( this, ID_RADIOBOX_SELECT_FORMAT, _("Output format:"), wxDefaultPosition, wxDefaultSize, m_OutputFormCtrlNChoices, m_OutputFormCtrlChoices, 1, wxRA_SPECIFY_COLS ); - m_OutputFormCtrl->SetSelection( 2 ); - sbOptionsSizer->Add( m_OutputFormCtrl, 0, wxEXPAND|wxTOP, 5 ); - - wxString m_OutputSeparatorCtrlChoices[] = { _("Tab"), _(";"), _(",") }; - int m_OutputSeparatorCtrlNChoices = sizeof( m_OutputSeparatorCtrlChoices ) / sizeof( wxString ); - m_OutputSeparatorCtrl = new wxRadioBox( this, wxID_ANY, _("Field separator for spreadsheet import:"), wxDefaultPosition, wxDefaultSize, m_OutputSeparatorCtrlNChoices, m_OutputSeparatorCtrlChoices, 1, wxRA_SPECIFY_ROWS ); - m_OutputSeparatorCtrl->SetSelection( 0 ); - sbOptionsSizer->Add( m_OutputSeparatorCtrl, 0, wxEXPAND|wxTOP, 5 ); - - wxStaticBoxSizer* sbBrowseOptSizer; - sbBrowseOptSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Options:") ), wxVERTICAL ); - - m_GetListBrowser = new wxCheckBox( this, wxID_ANY, _("Launch list browser"), wxDefaultPosition, wxDefaultSize, 0 ); - - sbBrowseOptSizer->Add( m_GetListBrowser, 0, wxALL|wxEXPAND, 5 ); - - sbOptionsSizer->Add( sbBrowseOptSizer, 0, wxEXPAND|wxTOP, 5 ); - - bMainSizer->Add( sbOptionsSizer, 10, wxALL|wxEXPAND, 5 ); - - wxBoxSizer* bRightSizer; - bRightSizer = new wxBoxSizer( wxVERTICAL ); - - wxStaticBoxSizer* sbFieldsSelectionSizer; - sbFieldsSelectionSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Fields to add:") ), wxVERTICAL ); - - wxStaticBoxSizer* sbFixedFieldsSizer; - sbFixedFieldsSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("System Fields:") ), wxVERTICAL ); - - m_AddFootprintField = new wxCheckBox( this, wxID_ANY, _("Footprint"), wxDefaultPosition, wxDefaultSize, 0 ); - - sbFixedFieldsSizer->Add( m_AddFootprintField, 0, wxALL|wxEXPAND, 5 ); - - sbFieldsSelectionSizer->Add( sbFixedFieldsSizer, 0, wxEXPAND, 5 ); - - wxStaticBoxSizer* sbUsersFiledsSizer; - sbUsersFiledsSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Users Fields:") ), wxVERTICAL ); - - m_AddField1 = new wxCheckBox( this, wxID_ANY, _("Field 1"), wxDefaultPosition, wxDefaultSize, 0 ); - - sbUsersFiledsSizer->Add( m_AddField1, 0, wxEXPAND|wxALL, 5 ); - - m_AddField2 = new wxCheckBox( this, wxID_ANY, _("Field 2"), wxDefaultPosition, wxDefaultSize, 0 ); - - sbUsersFiledsSizer->Add( m_AddField2, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 ); - - m_AddField3 = new wxCheckBox( this, wxID_ANY, _("Field 3"), wxDefaultPosition, wxDefaultSize, 0 ); - - sbUsersFiledsSizer->Add( m_AddField3, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 ); - - m_AddField4 = new wxCheckBox( this, wxID_ANY, _("Field 4"), wxDefaultPosition, wxDefaultSize, 0 ); - - sbUsersFiledsSizer->Add( m_AddField4, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 ); - - m_AddField5 = new wxCheckBox( this, wxID_ANY, _("Field 5"), wxDefaultPosition, wxDefaultSize, 0 ); - - sbUsersFiledsSizer->Add( m_AddField5, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 ); - - m_AddField6 = new wxCheckBox( this, wxID_ANY, _("Field 6"), wxDefaultPosition, wxDefaultSize, 0 ); - - sbUsersFiledsSizer->Add( m_AddField6, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 ); - - m_AddField7 = new wxCheckBox( this, wxID_ANY, _("Field 7"), wxDefaultPosition, wxDefaultSize, 0 ); - - sbUsersFiledsSizer->Add( m_AddField7, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 ); - - m_AddField8 = new wxCheckBox( this, wxID_ANY, _("Field 8"), wxDefaultPosition, wxDefaultSize, 0 ); - - sbUsersFiledsSizer->Add( m_AddField8, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 ); - - m_AddAllFields = new wxCheckBox( this, wxID_ANY, _("All existing users fields"), wxDefaultPosition, wxDefaultSize, 0 ); - - sbUsersFiledsSizer->Add( m_AddAllFields, 0, wxALL, 5 ); - - sbFieldsSelectionSizer->Add( sbUsersFiledsSizer, 0, wxEXPAND|wxTOP, 5 ); - - bRightSizer->Add( sbFieldsSelectionSizer, 1, wxEXPAND, 5 ); - - - bRightSizer->Add( 10, 10, 0, 0, 5 ); - - m_buttonOK = new wxButton( this, wxID_OK, _("Ok"), wxDefaultPosition, wxDefaultSize, 0 ); - m_buttonOK->SetDefault(); - bRightSizer->Add( m_buttonOK, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_HORIZONTAL, 5 ); - - m_buttonCANCEL = new wxButton( this, wxID_CANCEL, _("Close"), wxDefaultPosition, wxDefaultSize, 0 ); - bRightSizer->Add( m_buttonCANCEL, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_HORIZONTAL, 5 ); - - bMainSizer->Add( bRightSizer, 8, wxALL|wxEXPAND, 5 ); - - this->SetSizer( bMainSizer ); - this->Layout(); - - // Connect Events - m_OutputFormCtrl->Connect( wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEventHandler( DIALOG_BUILD_BOM_BASE::OnRadioboxSelectFormatSelected ), NULL, this ); - m_buttonOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_BUILD_BOM_BASE::OnOkClick ), NULL, this ); - m_buttonCANCEL->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_BUILD_BOM_BASE::OnCancelClick ), NULL, this ); -} - -DIALOG_BUILD_BOM_BASE::~DIALOG_BUILD_BOM_BASE() -{ - // Disconnect Events - m_OutputFormCtrl->Disconnect( wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEventHandler( DIALOG_BUILD_BOM_BASE::OnRadioboxSelectFormatSelected ), NULL, this ); - m_buttonOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_BUILD_BOM_BASE::OnOkClick ), NULL, this ); - m_buttonCANCEL->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_BUILD_BOM_BASE::OnCancelClick ), NULL, this ); -} +/////////////////////////////////////////////////////////////////////////// +// C++ code generated with wxFormBuilder (version Apr 10 2012) +// http://www.wxformbuilder.org/ +// +// PLEASE DO "NOT" EDIT THIS FILE! +/////////////////////////////////////////////////////////////////////////// + +#include "dialog_build_BOM_base.h" + +/////////////////////////////////////////////////////////////////////////// + +DIALOG_BUILD_BOM_BASE::DIALOG_BUILD_BOM_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : DIALOG_SHIM( parent, id, title, pos, size, style ) +{ + this->SetSizeHints( wxDefaultSize, wxDefaultSize ); + + wxBoxSizer* bMainSizer; + bMainSizer = new wxBoxSizer( wxVERTICAL ); + + wxBoxSizer* bSizerUpper; + bSizerUpper = new wxBoxSizer( wxHORIZONTAL ); + + wxStaticBoxSizer* sbOptionsSizer; + sbOptionsSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Options:") ), wxVERTICAL ); + + wxStaticBoxSizer* sbListOptionsSizer; + sbListOptionsSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("List items:") ), wxVERTICAL ); + + m_ListCmpbyRefItems = new wxCheckBox( this, wxID_ANY, _("Components by reference"), wxDefaultPosition, wxDefaultSize, 0 ); + sbListOptionsSizer->Add( m_ListCmpbyRefItems, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); + + m_ListSubCmpItems = new wxCheckBox( this, wxID_ANY, _("Sub components (i.e. U2A, U2B ...)"), wxDefaultPosition, wxDefaultSize, 0 ); + sbListOptionsSizer->Add( m_ListSubCmpItems, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); + + m_ListCmpbyValItems = new wxCheckBox( this, wxID_ANY, _("Components by value"), wxDefaultPosition, wxDefaultSize, 0 ); + sbListOptionsSizer->Add( m_ListCmpbyValItems, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); + + m_GenListLabelsbyVal = new wxCheckBox( this, wxID_ANY, _("Hierarchy pins by name"), wxDefaultPosition, wxDefaultSize, 0 ); + sbListOptionsSizer->Add( m_GenListLabelsbyVal, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); + + m_GenListLabelsbySheet = new wxCheckBox( this, wxID_ANY, _("Hierarchy pins by sheets"), wxDefaultPosition, wxDefaultSize, 0 ); + sbListOptionsSizer->Add( m_GenListLabelsbySheet, 0, wxALL, 5 ); + + + sbOptionsSizer->Add( sbListOptionsSizer, 0, wxEXPAND, 5 ); + + wxString m_OutputFormCtrlChoices[] = { _("List"), _("List for spreadsheet import (by ref)"), _("List for spreadsheet import (by grouped ref)"), _("List for spreadsheet import (by value)") }; + int m_OutputFormCtrlNChoices = sizeof( m_OutputFormCtrlChoices ) / sizeof( wxString ); + m_OutputFormCtrl = new wxRadioBox( this, ID_RADIOBOX_SELECT_FORMAT, _("Output format:"), wxDefaultPosition, wxDefaultSize, m_OutputFormCtrlNChoices, m_OutputFormCtrlChoices, 1, wxRA_SPECIFY_COLS ); + m_OutputFormCtrl->SetSelection( 1 ); + sbOptionsSizer->Add( m_OutputFormCtrl, 0, wxEXPAND|wxTOP, 5 ); + + wxString m_OutputSeparatorCtrlChoices[] = { _("Tab"), _(";"), _(",") }; + int m_OutputSeparatorCtrlNChoices = sizeof( m_OutputSeparatorCtrlChoices ) / sizeof( wxString ); + m_OutputSeparatorCtrl = new wxRadioBox( this, wxID_ANY, _("Field separator for spreadsheet import:"), wxDefaultPosition, wxDefaultSize, m_OutputSeparatorCtrlNChoices, m_OutputSeparatorCtrlChoices, 1, wxRA_SPECIFY_ROWS ); + m_OutputSeparatorCtrl->SetSelection( 0 ); + sbOptionsSizer->Add( m_OutputSeparatorCtrl, 0, wxEXPAND|wxTOP, 5 ); + + m_GetListBrowser = new wxCheckBox( this, wxID_ANY, _("Launch list browser"), wxDefaultPosition, wxDefaultSize, 0 ); + sbOptionsSizer->Add( m_GetListBrowser, 0, wxALL|wxEXPAND, 5 ); + + + bSizerUpper->Add( sbOptionsSizer, 10, wxALL|wxEXPAND, 5 ); + + wxBoxSizer* bRightSizer; + bRightSizer = new wxBoxSizer( wxVERTICAL ); + + wxStaticBoxSizer* sbAddToListSelectionSizer; + sbAddToListSelectionSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Add to list:") ), wxVERTICAL ); + + m_AddLocationField = new wxCheckBox( this, wxID_ANY, _("Component location"), wxDefaultPosition, wxDefaultSize, 0 ); + sbAddToListSelectionSizer->Add( m_AddLocationField, 0, wxALL, 5 ); + + wxStaticBoxSizer* sbFixedFieldsSizer; + sbFixedFieldsSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("System Fields:") ), wxVERTICAL ); + + m_AddDatasheetField = new wxCheckBox( this, wxID_ANY, _("Datasheet"), wxDefaultPosition, wxDefaultSize, 0 ); + sbFixedFieldsSizer->Add( m_AddDatasheetField, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); + + m_AddFootprintField = new wxCheckBox( this, wxID_ANY, _("Footprint"), wxDefaultPosition, wxDefaultSize, 0 ); + sbFixedFieldsSizer->Add( m_AddFootprintField, 0, wxALL|wxEXPAND, 5 ); + + + sbAddToListSelectionSizer->Add( sbFixedFieldsSizer, 0, wxEXPAND, 5 ); + + wxStaticBoxSizer* sbUsersFiledsSizer; + sbUsersFiledsSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Users fields:") ), wxVERTICAL ); + + m_AddField1 = new wxCheckBox( this, wxID_ANY, _("Field 1"), wxDefaultPosition, wxDefaultSize, 0 ); + sbUsersFiledsSizer->Add( m_AddField1, 0, wxEXPAND|wxALL, 5 ); + + m_AddField2 = new wxCheckBox( this, wxID_ANY, _("Field 2"), wxDefaultPosition, wxDefaultSize, 0 ); + sbUsersFiledsSizer->Add( m_AddField2, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + + m_AddField3 = new wxCheckBox( this, wxID_ANY, _("Field 3"), wxDefaultPosition, wxDefaultSize, 0 ); + sbUsersFiledsSizer->Add( m_AddField3, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + + m_AddField4 = new wxCheckBox( this, wxID_ANY, _("Field 4"), wxDefaultPosition, wxDefaultSize, 0 ); + sbUsersFiledsSizer->Add( m_AddField4, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + + m_AddField5 = new wxCheckBox( this, wxID_ANY, _("Field 5"), wxDefaultPosition, wxDefaultSize, 0 ); + sbUsersFiledsSizer->Add( m_AddField5, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + + m_AddField6 = new wxCheckBox( this, wxID_ANY, _("Field 6"), wxDefaultPosition, wxDefaultSize, 0 ); + sbUsersFiledsSizer->Add( m_AddField6, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + + m_AddField7 = new wxCheckBox( this, wxID_ANY, _("Field 7"), wxDefaultPosition, wxDefaultSize, 0 ); + sbUsersFiledsSizer->Add( m_AddField7, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + + m_AddField8 = new wxCheckBox( this, wxID_ANY, _("Field 8"), wxDefaultPosition, wxDefaultSize, 0 ); + sbUsersFiledsSizer->Add( m_AddField8, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + + + sbAddToListSelectionSizer->Add( sbUsersFiledsSizer, 0, wxEXPAND|wxTOP, 5 ); + + m_AddAllFields = new wxCheckBox( this, wxID_ANY, _("All existing user fields"), wxDefaultPosition, wxDefaultSize, 0 ); + sbAddToListSelectionSizer->Add( m_AddAllFields, 0, wxALL, 5 ); + + + bRightSizer->Add( sbAddToListSelectionSizer, 1, wxEXPAND, 5 ); + + + bSizerUpper->Add( bRightSizer, 0, wxALL|wxEXPAND, 5 ); + + + bMainSizer->Add( bSizerUpper, 1, wxEXPAND, 5 ); + + m_staticline1 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); + bMainSizer->Add( m_staticline1, 0, wxEXPAND | wxALL, 5 ); + + m_sdbSizer = new wxStdDialogButtonSizer(); + m_sdbSizerOK = new wxButton( this, wxID_OK ); + m_sdbSizer->AddButton( m_sdbSizerOK ); + m_sdbSizerCancel = new wxButton( this, wxID_CANCEL ); + m_sdbSizer->AddButton( m_sdbSizerCancel ); + m_sdbSizer->Realize(); + + bMainSizer->Add( m_sdbSizer, 0, wxALIGN_RIGHT, 5 ); + + + this->SetSizer( bMainSizer ); + this->Layout(); + + // Connect Events + m_OutputFormCtrl->Connect( wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEventHandler( DIALOG_BUILD_BOM_BASE::OnRadioboxSelectFormatSelected ), NULL, this ); + m_sdbSizerCancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_BUILD_BOM_BASE::OnCancelClick ), NULL, this ); + m_sdbSizerOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_BUILD_BOM_BASE::OnOkClick ), NULL, this ); +} + +DIALOG_BUILD_BOM_BASE::~DIALOG_BUILD_BOM_BASE() +{ + // Disconnect Events + m_OutputFormCtrl->Disconnect( wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEventHandler( DIALOG_BUILD_BOM_BASE::OnRadioboxSelectFormatSelected ), NULL, this ); + m_sdbSizerCancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_BUILD_BOM_BASE::OnCancelClick ), NULL, this ); + m_sdbSizerOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_BUILD_BOM_BASE::OnOkClick ), NULL, this ); + +} diff --git a/eeschema/dialogs/dialog_build_BOM_base.fbp b/eeschema/dialogs/dialog_build_BOM_base.fbp index ec62a6dd58..a8717b98c0 100644 --- a/eeschema/dialogs/dialog_build_BOM_base.fbp +++ b/eeschema/dialogs/dialog_build_BOM_base.fbp @@ -1,1230 +1,2060 @@ - - - - - - C++ - 1 - UTF-8 - connect - dialog_build_BOM_base - 1000 - none - 1 - dialog_build_BOM_base - - . - - 1 - 1 - 0 - - - - - 1 - - - - 0 - wxID_ANY - - - DIALOG_BUILD_BOM_BASE - - 415,382 - wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER - - List of Material - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bMainSizer - wxHORIZONTAL - none - - 5 - wxALL|wxEXPAND - 10 - - wxID_ANY - Options: - - sbOptionsSizer - wxVERTICAL - none - - - 5 - wxEXPAND - 0 - - wxID_ANY - List items: - - sbListOptionsSizer - wxVERTICAL - none - - - 5 - wxTOP|wxRIGHT|wxLEFT - 0 - - - 0 - - 1 - - - 0 - wxID_ANY - Components by reference - - - m_ListCmpbyRefItems - protected - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxTOP|wxRIGHT|wxLEFT - 0 - - - 0 - - 1 - - - 0 - wxID_ANY - Sub components (i.e. U2A, U2B ...) - - - m_ListSubCmpItems - protected - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxTOP|wxRIGHT|wxLEFT - 0 - - - 0 - - 1 - - - 0 - wxID_ANY - Components by value - - - m_ListCmpbyValItems - protected - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxTOP|wxRIGHT|wxLEFT - 0 - - - 0 - - 1 - - - 0 - wxID_ANY - Hierarchy pins by name - - - m_GenListLabelsbyVal - protected - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALL - 0 - - - 0 - - 1 - - - 0 - wxID_ANY - Hierarchy pins by sheets - - - m_GenListLabelsbySheet - protected - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxEXPAND|wxTOP - 0 - - - "List" "Text for spreadsheet import" "Single Part per line" - - 1 - - - 0 - ID_RADIOBOX_SELECT_FORMAT - Output format: - 1 - - - m_OutputFormCtrl - protected - - 2 - - wxRA_SPECIFY_COLS - - - - - - - - - - - - - - - - - - - - - - - OnRadioboxSelectFormatSelected - - - - - - - - - - 5 - wxEXPAND|wxTOP - 0 - - - "Tab" ";" "," - - 1 - - - 0 - wxID_ANY - Field separator for spreadsheet import: - 1 - - - m_OutputSeparatorCtrl - protected - - 0 - - wxRA_SPECIFY_ROWS - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxEXPAND|wxTOP - 0 - - wxID_ANY - Options: - - sbBrowseOptSizer - wxVERTICAL - none - - - 5 - wxALL|wxEXPAND - 0 - - - 0 - - 1 - - - 0 - wxID_ANY - Launch list browser - - - m_GetListBrowser - protected - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALL|wxEXPAND - 8 - - - bRightSizer - wxVERTICAL - none - - 5 - wxEXPAND - 1 - - wxID_ANY - Fields to add: - - sbFieldsSelectionSizer - wxVERTICAL - none - - - 5 - wxEXPAND - 0 - - wxID_ANY - System Fields: - - sbFixedFieldsSizer - wxVERTICAL - none - - - 5 - wxALL|wxEXPAND - 0 - - - 0 - - 1 - - - 0 - wxID_ANY - Footprint - - - m_AddFootprintField - protected - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxEXPAND|wxTOP - 0 - - wxID_ANY - Users Fields: - - sbUsersFiledsSizer - wxVERTICAL - none - - - 5 - wxEXPAND|wxALL - 0 - - - 0 - - 1 - - - 0 - wxID_ANY - Field 1 - - - m_AddField1 - protected - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxBOTTOM|wxRIGHT|wxLEFT - 0 - - - 0 - - 1 - - - 0 - wxID_ANY - Field 2 - - - m_AddField2 - protected - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxBOTTOM|wxRIGHT|wxLEFT - 0 - - - 0 - - 1 - - - 0 - wxID_ANY - Field 3 - - - m_AddField3 - protected - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxBOTTOM|wxRIGHT|wxLEFT - 0 - - - 0 - - 1 - - - 0 - wxID_ANY - Field 4 - - - m_AddField4 - protected - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxBOTTOM|wxRIGHT|wxLEFT - 0 - - - 0 - - 1 - - - 0 - wxID_ANY - Field 5 - - - m_AddField5 - protected - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxBOTTOM|wxRIGHT|wxLEFT - 0 - - - 0 - - 1 - - - 0 - wxID_ANY - Field 6 - - - m_AddField6 - protected - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxBOTTOM|wxRIGHT|wxLEFT - 0 - - - 0 - - 1 - - - 0 - wxID_ANY - Field 7 - - - m_AddField7 - protected - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxBOTTOM|wxRIGHT|wxLEFT - 0 - - - 0 - - 1 - - - 0 - wxID_ANY - Field 8 - - - m_AddField8 - protected - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALL - 0 - - - 0 - - 1 - - - 0 - wxID_ANY - All existing users fields - - - m_AddAllFields - protected - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - - 0 - - 10 - protected - 10 - - - - 5 - wxALL|wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_HORIZONTAL - 0 - - - - 1 - 1 - - - 0 - wxID_OK - Ok - - - m_buttonOK - protected - - - - - - - - - OnOkClick - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALL|wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_HORIZONTAL - 0 - - - - 0 - 1 - - - 0 - wxID_CANCEL - Close - - - m_buttonCANCEL - protected - - - - - - - - - OnCancelClick - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + C++ + 1 + source_name + 0 + 0 + res + UTF-8 + connect + dialog_build_BOM_base + 1000 + none + 1 + dialog_build_BOM_base + + . + + 1 + 1 + 1 + 1 + 0 + + 0 + wxAUI_MGR_DEFAULT + + + + 1 + 1 + impl_virtual + + + + 0 + wxID_ANY + + + DIALOG_BUILD_BOM_BASE + + 424,388 + wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER + DIALOG_SHIM; dialog_shim.h + List of Material + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + bMainSizer + wxVERTICAL + none + + 5 + wxEXPAND + 1 + + + bSizerUpper + wxHORIZONTAL + none + + 5 + wxALL|wxEXPAND + 10 + + wxID_ANY + Options: + + sbOptionsSizer + wxVERTICAL + none + + + 5 + wxEXPAND + 0 + + wxID_ANY + List items: + + sbListOptionsSizer + wxVERTICAL + none + + + 5 + wxTOP|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Components by reference + + 0 + + + 0 + + 1 + m_ListCmpbyRefItems + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxTOP|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Sub components (i.e. U2A, U2B ...) + + 0 + + + 0 + + 1 + m_ListSubCmpItems + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxTOP|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Components by value + + 0 + + + 0 + + 1 + m_ListCmpbyValItems + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxTOP|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Hierarchy pins by name + + 0 + + + 0 + + 1 + m_GenListLabelsbyVal + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Hierarchy pins by sheets + + 0 + + + 0 + + 1 + m_GenListLabelsbySheet + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND|wxTOP + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + "List" "List for spreadsheet import (by ref)" "List for spreadsheet import (by grouped ref)" "List for spreadsheet import (by value)" + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + ID_RADIOBOX_SELECT_FORMAT + Output format: + 1 + + 0 + + + 0 + + 1 + m_OutputFormCtrl + 1 + + + protected + 1 + + Resizable + 1 + 1 + + wxRA_SPECIFY_COLS + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + OnRadioboxSelectFormatSelected + + + + + + + + + + 5 + wxEXPAND|wxTOP + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + "Tab" ";" "," + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Field separator for spreadsheet import: + 1 + + 0 + + + 0 + + 1 + m_OutputSeparatorCtrl + 1 + + + protected + 1 + + Resizable + 0 + 1 + + wxRA_SPECIFY_ROWS + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL|wxEXPAND + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Launch list browser + + 0 + + + 0 + + 1 + m_GetListBrowser + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL|wxEXPAND + 0 + + + bRightSizer + wxVERTICAL + none + + 5 + wxEXPAND + 1 + + wxID_ANY + Add to list: + + sbAddToListSelectionSizer + wxVERTICAL + none + + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Component location + + 0 + + + 0 + + 1 + m_AddLocationField + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND + 0 + + wxID_ANY + System Fields: + + sbFixedFieldsSizer + wxVERTICAL + none + + + 5 + wxTOP|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Datasheet + + 0 + + + 0 + + 1 + m_AddDatasheetField + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL|wxEXPAND + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Footprint + + 0 + + + 0 + + 1 + m_AddFootprintField + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND|wxTOP + 0 + + wxID_ANY + Users fields: + + sbUsersFiledsSizer + wxVERTICAL + none + + + 5 + wxEXPAND|wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Field 1 + + 0 + + + 0 + + 1 + m_AddField1 + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxBOTTOM|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Field 2 + + 0 + + + 0 + + 1 + m_AddField2 + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxBOTTOM|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Field 3 + + 0 + + + 0 + + 1 + m_AddField3 + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxBOTTOM|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Field 4 + + 0 + + + 0 + + 1 + m_AddField4 + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxBOTTOM|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Field 5 + + 0 + + + 0 + + 1 + m_AddField5 + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxBOTTOM|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Field 6 + + 0 + + + 0 + + 1 + m_AddField6 + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxBOTTOM|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Field 7 + + 0 + + + 0 + + 1 + m_AddField7 + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxBOTTOM|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Field 8 + + 0 + + + 0 + + 1 + m_AddField8 + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + All existing user fields + + 0 + + + 0 + + 1 + m_AddAllFields + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND | wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_staticline1 + 1 + + + protected + 1 + + Resizable + 1 + + wxLI_HORIZONTAL + + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALIGN_RIGHT + 0 + + 0 + 1 + 0 + 0 + 0 + 1 + 0 + 0 + + m_sdbSizer + protected + + OnCancelClick + + + + OnOkClick + + + + + + + + diff --git a/eeschema/dialogs/dialog_build_BOM_base.h b/eeschema/dialogs/dialog_build_BOM_base.h index 3aac87e8fe..297674b347 100644 --- a/eeschema/dialogs/dialog_build_BOM_base.h +++ b/eeschema/dialogs/dialog_build_BOM_base.h @@ -1,74 +1,81 @@ -/////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Apr 21 2008) -// http://www.wxformbuilder.org/ -// -// PLEASE DO "NOT" EDIT THIS FILE! -/////////////////////////////////////////////////////////////////////////// - -#ifndef __dialog_build_BOM_base__ -#define __dialog_build_BOM_base__ - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/////////////////////////////////////////////////////////////////////////// - -/////////////////////////////////////////////////////////////////////////////// -/// Class DIALOG_BUILD_BOM_BASE -/////////////////////////////////////////////////////////////////////////////// -class DIALOG_BUILD_BOM_BASE : public wxDialog -{ - private: - - protected: - enum - { - ID_RADIOBOX_SELECT_FORMAT = 1000, - }; - - wxCheckBox* m_ListCmpbyRefItems; - wxCheckBox* m_ListSubCmpItems; - wxCheckBox* m_ListCmpbyValItems; - wxCheckBox* m_GenListLabelsbyVal; - wxCheckBox* m_GenListLabelsbySheet; - wxRadioBox* m_OutputFormCtrl; - wxRadioBox* m_OutputSeparatorCtrl; - wxCheckBox* m_GetListBrowser; - wxCheckBox* m_AddFootprintField; - wxCheckBox* m_AddField1; - wxCheckBox* m_AddField2; - wxCheckBox* m_AddField3; - wxCheckBox* m_AddField4; - wxCheckBox* m_AddField5; - wxCheckBox* m_AddField6; - wxCheckBox* m_AddField7; - wxCheckBox* m_AddField8; - wxCheckBox* m_AddAllFields; - - wxButton* m_buttonOK; - wxButton* m_buttonCANCEL; - - // Virtual event handlers, overide them in your derived class - virtual void OnRadioboxSelectFormatSelected( wxCommandEvent& event ){ event.Skip(); } - virtual void OnOkClick( wxCommandEvent& event ){ event.Skip(); } - virtual void OnCancelClick( wxCommandEvent& event ){ event.Skip(); } - - - public: - DIALOG_BUILD_BOM_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("List of Material"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 415,382 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); - ~DIALOG_BUILD_BOM_BASE(); - -}; - -#endif //__dialog_build_BOM_base__ +/////////////////////////////////////////////////////////////////////////// +// C++ code generated with wxFormBuilder (version Apr 10 2012) +// http://www.wxformbuilder.org/ +// +// PLEASE DO "NOT" EDIT THIS FILE! +/////////////////////////////////////////////////////////////////////////// + +#ifndef __DIALOG_BUILD_BOM_BASE_H__ +#define __DIALOG_BUILD_BOM_BASE_H__ + +#include +#include +#include +#include "dialog_shim.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/////////////////////////////////////////////////////////////////////////// + +/////////////////////////////////////////////////////////////////////////////// +/// Class DIALOG_BUILD_BOM_BASE +/////////////////////////////////////////////////////////////////////////////// +class DIALOG_BUILD_BOM_BASE : public DIALOG_SHIM +{ + private: + + protected: + enum + { + ID_RADIOBOX_SELECT_FORMAT = 1000 + }; + + wxCheckBox* m_ListCmpbyRefItems; + wxCheckBox* m_ListSubCmpItems; + wxCheckBox* m_ListCmpbyValItems; + wxCheckBox* m_GenListLabelsbyVal; + wxCheckBox* m_GenListLabelsbySheet; + wxRadioBox* m_OutputFormCtrl; + wxRadioBox* m_OutputSeparatorCtrl; + wxCheckBox* m_GetListBrowser; + wxCheckBox* m_AddLocationField; + wxCheckBox* m_AddDatasheetField; + wxCheckBox* m_AddFootprintField; + wxCheckBox* m_AddField1; + wxCheckBox* m_AddField2; + wxCheckBox* m_AddField3; + wxCheckBox* m_AddField4; + wxCheckBox* m_AddField5; + wxCheckBox* m_AddField6; + wxCheckBox* m_AddField7; + wxCheckBox* m_AddField8; + wxCheckBox* m_AddAllFields; + wxStaticLine* m_staticline1; + wxStdDialogButtonSizer* m_sdbSizer; + wxButton* m_sdbSizerOK; + wxButton* m_sdbSizerCancel; + + // Virtual event handlers, overide them in your derived class + virtual void OnRadioboxSelectFormatSelected( wxCommandEvent& event ) { event.Skip(); } + virtual void OnCancelClick( wxCommandEvent& event ) { event.Skip(); } + virtual void OnOkClick( wxCommandEvent& event ) { event.Skip(); } + + + public: + + DIALOG_BUILD_BOM_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("List of Material"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 424,388 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); + ~DIALOG_BUILD_BOM_BASE(); + +}; + +#endif //__DIALOG_BUILD_BOM_BASE_H__