Loading eeschema/build_BOM.cpp +118 −184 Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ class LABEL_OBJECT public: int m_LabelType; SCH_ITEM* m_Label; //have to store it here since the object references will be duplicated. DrawSheetPath m_SheetPath; //composed of UIDs Loading @@ -47,20 +48,19 @@ public: // Filename extension for BOM list #define EXT_LIST wxT( ".lst" ) // Exported functions int BuildComponentsListFromSchematic( OBJ_CMP_TO_LIST * aList ); /* fonctions locales */ static int GenListeGLabels( std::vector <LABEL_OBJECT>& aList ); static int ListTriComposantByRef( OBJ_CMP_TO_LIST* obj1, OBJ_CMP_TO_LIST* obj2 ); static int ListTriComposantByVal( OBJ_CMP_TO_LIST* obj1, OBJ_CMP_TO_LIST* obj2 ); /* Local functions */ static void BuildComponentsListFromSchematic( std::vector <OBJ_CMP_TO_LIST>& aList ); static void GenListeGLabels( std::vector <LABEL_OBJECT>& aList ); static bool SortComponentsByReference( const OBJ_CMP_TO_LIST& obj1, const OBJ_CMP_TO_LIST& obj2 ); static bool SortComponentsByValue( const OBJ_CMP_TO_LIST& obj1, const OBJ_CMP_TO_LIST& obj2 ); static bool SortLabelsByValue( const LABEL_OBJECT& obj1, const LABEL_OBJECT& obj2 ); static bool SortLabelsBySheet( const LABEL_OBJECT& obj1, const LABEL_OBJECT& obj2 ); static void DeleteSubCmp( OBJ_CMP_TO_LIST* aList, int aItemCount ); static void DeleteSubCmp( std::vector <OBJ_CMP_TO_LIST>& aList ); static int PrintListeGLabel( FILE* f, std::vector <LABEL_OBJECT>& aList ); int RefDesStringCompare( char* obj1, char* obj2 ); int RefDesStringCompare( const char* obj1, const char* obj2 ); int SplitString( wxString strToSplit, wxString* strBeginning, wxString* strDigits, Loading Loading @@ -135,8 +135,6 @@ void WinEDA_Build_BOM_Frame::CreateExportList( const wxString& aFullFileName, */ { FILE* f; OBJ_CMP_TO_LIST* aList; int itemCount; wxString msg; /* Creation de la liste des elements */ Loading @@ -148,30 +146,17 @@ void WinEDA_Build_BOM_Frame::CreateExportList( const wxString& aFullFileName, return; } itemCount = BuildComponentsListFromSchematic( NULL ); if( itemCount ) { aList = (OBJ_CMP_TO_LIST*) MyZMalloc( itemCount * sizeof(OBJ_CMP_TO_LIST) ); if( aList == NULL ) { fclose( f ); return; } BuildComponentsListFromSchematic( aList ); std::vector <OBJ_CMP_TO_LIST> cmplist; BuildComponentsListFromSchematic( cmplist ); /* sort component list */ qsort( aList, itemCount, sizeof( OBJ_CMP_TO_LIST ), ( int( * ) ( const void*, const void* ) )ListTriComposantByRef ); sort( cmplist.begin(), cmplist.end(), SortComponentsByReference ); if( !aIncludeSubComponents ) DeleteSubCmp( aList, itemCount ); DeleteSubCmp( cmplist ); /* create the file */ PrintComponentsListByRef( f, aList, itemCount, TRUE, aIncludeSubComponents ); MyFree( aList ); } PrintComponentsListByRef( f, cmplist, TRUE, aIncludeSubComponents ); fclose( f ); } Loading @@ -188,7 +173,6 @@ void WinEDA_Build_BOM_Frame::GenereListeOfItems( const wxString& aFullFileName, */ { FILE* f; OBJ_CMP_TO_LIST* list; int itemCount; char Line[1024]; wxString msg; Loading @@ -201,43 +185,31 @@ void WinEDA_Build_BOM_Frame::GenereListeOfItems( const wxString& aFullFileName, return; } itemCount = BuildComponentsListFromSchematic( NULL ); std::vector <OBJ_CMP_TO_LIST> cmplist; BuildComponentsListFromSchematic( cmplist ); itemCount = cmplist.size(); if( itemCount ) { list = (OBJ_CMP_TO_LIST*) MyZMalloc( itemCount * sizeof(OBJ_CMP_TO_LIST) ); if( list == NULL ) // Error memory alloc { fclose( f ); return; } BuildComponentsListFromSchematic( list ); /* generation du fichier listing */ /* creates the list file */ DateAndTime( Line ); wxString Title = g_Main_Title + wxT( " " ) + GetBuildVersion(); fprintf( f, "%s >> Creation date: %s\n", CONV_TO_UTF8( Title ), Line ); /* Tri et impression de la liste des composants */ qsort( list, itemCount, sizeof( OBJ_CMP_TO_LIST ), ( int( * ) ( const void*, const void* ) )ListTriComposantByRef ); /* sort component list */ sort( cmplist.begin(), cmplist.end(), SortComponentsByReference ); if( !aIncludeSubComponents ) DeleteSubCmp( list, itemCount ); DeleteSubCmp( cmplist ); if( m_ListCmpbyRefItems->GetValue() ) { PrintComponentsListByRef( f, list, itemCount, false, aIncludeSubComponents ); } PrintComponentsListByRef( f, cmplist, false, aIncludeSubComponents ); if( m_ListCmpbyValItems->GetValue() ) { qsort( list, itemCount, sizeof( OBJ_CMP_TO_LIST ), ( int( * ) ( const void*, const void* ) )ListTriComposantByVal ); PrintComponentsListByVal( f, list, itemCount, aIncludeSubComponents ); sort( cmplist.begin(), cmplist.end(), SortComponentsByValue ); PrintComponentsListByVal( f, cmplist, aIncludeSubComponents ); } MyFree( list ); } /*************************************************/ Loading Loading @@ -275,9 +247,9 @@ void WinEDA_Build_BOM_Frame::GenereListeOfItems( const wxString& aFullFileName, } /*********************************************************/ int BuildComponentsListFromSchematic( OBJ_CMP_TO_LIST* aList ) /*********************************************************/ /***************************************************************************/ void BuildComponentsListFromSchematic( std::vector <OBJ_CMP_TO_LIST>& aList ) /***************************************************************************/ /* Creates the list of components found in the whole schematic * Loading @@ -287,7 +259,6 @@ int BuildComponentsListFromSchematic( OBJ_CMP_TO_LIST* aList ) * Also Initialise m_Father as pointerof the SCH_SCREN parent */ { int itemCount = 0; EDA_BaseStruct* SchItem; SCH_COMPONENT* DrawLibItem; DrawSheetPath* sheet; Loading @@ -302,38 +273,32 @@ int BuildComponentsListFromSchematic( OBJ_CMP_TO_LIST* aList ) if( SchItem->Type() != TYPE_SCH_COMPONENT ) continue; itemCount++; DrawLibItem = (SCH_COMPONENT*) SchItem; DrawLibItem->SetParent( sheet->LastScreen() ); if( aList ) { aList->m_RootCmp = DrawLibItem; aList->m_SheetPath = *sheet; aList->m_Unit = DrawLibItem->GetUnitSelection( sheet ); OBJ_CMP_TO_LIST item; item.m_RootCmp = DrawLibItem; item.m_SheetPath = *sheet; item.m_Unit = DrawLibItem->GetUnitSelection( sheet ); strncpy( aList->m_Reference, strncpy( item.m_Reference, CONV_TO_UTF8( DrawLibItem->GetRef( sheet ) ), sizeof( aList->m_Reference ) ); sizeof( item.m_Reference ) ); // Ensure always nul terminate m_Ref. aList->m_Reference[sizeof( aList->m_Reference ) - 1 ] = 0; aList++; item.m_Reference[sizeof( item.m_Reference ) - 1 ] = 0; aList.push_back( item ); } } } return itemCount; } /****************************************************************/ static int GenListeGLabels( std::vector <LABEL_OBJECT>& aList ) static void GenListeGLabels( std::vector <LABEL_OBJECT>& aList ) /****************************************************************/ /* Fill aList with Glabel info */ { int itemCount = 0; SCH_ITEM* DrawList; Hierarchical_PIN_Sheet_Struct* PinLabel; DrawSheetPath* sheet; Loading @@ -352,7 +317,6 @@ static int GenListeGLabels( std::vector <LABEL_OBJECT>& aList ) { case TYPE_SCH_HIERLABEL: case TYPE_SCH_GLOBALLABEL: itemCount++; labet_object.m_LabelType = DrawList->Type(); labet_object.m_SheetPath = *sheet; labet_object.m_Label = DrawList; Loading @@ -364,7 +328,6 @@ static int GenListeGLabels( std::vector <LABEL_OBJECT>& aList ) PinLabel = ( (DrawSheetStruct*) DrawList )->m_Label; while( PinLabel != NULL ) { itemCount++; labet_object.m_LabelType = DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE; labet_object.m_SheetPath = *sheet; labet_object.m_Label = PinLabel; Loading @@ -377,102 +340,74 @@ static int GenListeGLabels( std::vector <LABEL_OBJECT>& aList ) default: break; } DrawList = DrawList->Next(); } } return itemCount; } /**********************************************************/ static int ListTriComposantByVal( OBJ_CMP_TO_LIST* obj1, OBJ_CMP_TO_LIST* obj2 ) /**********************************************************/ /************************************************************************************/ bool SortComponentsByValue( const OBJ_CMP_TO_LIST& obj1, const OBJ_CMP_TO_LIST& obj2 ) /************************************************************************************/ /* Routine de comparaison pour le tri du Tableau par qsort() * Les composants sont tries * par valeur * si meme valeur: par reference * si meme valeur: par numero d'unite /* Compare fuinction for sort() * components are sorted * by value * if same value: by reference * if same reference: by unit number */ { int ii; const wxString* Text1, * Text2; if( ( obj1 == NULL ) && ( obj2 == NULL ) ) return 0; if( obj1 == NULL ) return -1; if( obj2 == NULL ) return 1; if( ( obj1->m_RootCmp == NULL ) && ( obj2->m_RootCmp == NULL ) ) return 0; if( obj1->m_RootCmp == NULL ) return -1; if( obj2->m_RootCmp == NULL ) return 1; Text1 = &(obj1->m_RootCmp->GetField( VALUE )->m_Text); Text2 = &(obj2->m_RootCmp->GetField( VALUE )->m_Text); Text1 = &(obj1.m_RootCmp->GetField( VALUE )->m_Text); Text2 = &(obj2.m_RootCmp->GetField( VALUE )->m_Text); ii = Text1->CmpNoCase( *Text2 ); if( ii == 0 ) { ii = RefDesStringCompare( obj1->m_Reference, obj2->m_Reference ); ii = RefDesStringCompare( obj1.m_Reference, obj2.m_Reference ); } if( ii == 0 ) { ii = obj1->m_Unit - obj2->m_Unit; ii = obj1.m_Unit - obj2.m_Unit; } return ii; return ii < 0; } /*******************************************************************/ int ListTriComposantByRef( OBJ_CMP_TO_LIST* obj1, OBJ_CMP_TO_LIST* obj2 ) /*******************************************************************/ /***************************************************************************************/ bool SortComponentsByReference( const OBJ_CMP_TO_LIST& obj1, const OBJ_CMP_TO_LIST& obj2 ) /***************************************************************************************/ /* compare function for sorting * Les composants sont tries * par reference * si meme referenece: par valeur * si meme valeur: par numero d'unite * components are sorted * by reference * if same reference: by value * if same value: by unit number */ { int ii; const wxString* Text1, * Text2; if( ( obj1 == NULL ) && ( obj2 == NULL ) ) return 0; if( obj1 == NULL ) return -1; if( obj2 == NULL ) return 1; if( ( obj1->m_RootCmp == NULL ) && ( obj2->m_RootCmp == NULL ) ) return 0; if( obj1->m_RootCmp == NULL ) return -1; if( obj2->m_RootCmp == NULL ) return 1; ii = RefDesStringCompare( obj1->m_Reference, obj2->m_Reference ); ii = RefDesStringCompare( obj1.m_Reference, obj2.m_Reference ); if( ii == 0 ) { Text1 = &( obj1->m_RootCmp->GetField( VALUE )->m_Text ); Text2 = &( obj2->m_RootCmp->GetField( VALUE )->m_Text ); Text1 = &( obj1.m_RootCmp->GetField( VALUE )->m_Text ); Text2 = &( obj2.m_RootCmp->GetField( VALUE )->m_Text ); ii = Text1->CmpNoCase( *Text2 ); } if( ii == 0 ) { ii = obj1->m_Unit - obj2->m_Unit; ii = obj1.m_Unit - obj2.m_Unit; } return ii; return ii < 0; } Loading Loading @@ -545,7 +480,7 @@ bool SortLabelsBySheet( const LABEL_OBJECT& obj1, const LABEL_OBJECT& obj2 ) /**************************************************************/ static void DeleteSubCmp( OBJ_CMP_TO_LIST* aList, int aItemCount ) static void DeleteSubCmp( std::vector <OBJ_CMP_TO_LIST>& aList ) /**************************************************************/ /* Remove sub components from the list, when multiples parts per package are found in this list Loading @@ -557,7 +492,7 @@ static void DeleteSubCmp( OBJ_CMP_TO_LIST* aList, int aItemCount ) wxString currName; for( int ii = 0; ii < aItemCount; ii++ ) for( unsigned ii = 0; ii < aList.size(); ii++ ) { libItem = aList[ii].m_RootCmp; if( libItem == NULL ) Loading @@ -569,9 +504,8 @@ static void DeleteSubCmp( OBJ_CMP_TO_LIST* aList, int aItemCount ) { if( oldName == currName ) // currName is a subpart of oldName: remove it { aList[ii].m_RootCmp = NULL; aList[ii].m_SheetPath.Clear(); aList[ii].m_Reference[0] = 0; aList.erase( aList.begin() + ii ); ii--; } } oldName = currName; Loading Loading @@ -629,17 +563,18 @@ void WinEDA_Build_BOM_Frame::PrintFieldData( FILE* f, SCH_COMPONENT* DrawLibItem /*********************************************************************************************/ int WinEDA_Build_BOM_Frame::PrintComponentsListByRef( FILE* f, OBJ_CMP_TO_LIST* aList, int aItemCount, int WinEDA_Build_BOM_Frame::PrintComponentsListByRef( FILE* f, std::vector <OBJ_CMP_TO_LIST>& aList, bool CompactForm, bool aIncludeSubComponents ) bool aIncludeSubComponents ) /*********************************************************************************************/ /* Print the B.O.M sorted by reference */ { int ii, Multi, Unit; int Multi, Unit; EDA_BaseStruct* DrawList; SCH_COMPONENT* DrawLibItem; EDA_LibComponentStruct* Entry; Loading Loading @@ -672,7 +607,7 @@ int WinEDA_Build_BOM_Frame::PrintComponentsListByRef( FILE* f, if( m_AddFootprintField->IsChecked() ) fprintf( f, "%cfootprint", s_ExportSeparatorSymbol ); for( ii = FIELD1; ii <= FIELD8; ii++ ) for( int ii = FIELD1; ii <= FIELD8; ii++ ) { const wxCheckBox* FieldCtrl = FieldListCtrl[ii - FIELD1]; if( FieldCtrl == NULL ) Loading @@ -697,7 +632,7 @@ int WinEDA_Build_BOM_Frame::PrintComponentsListByRef( FILE* f, } // Print list of items for( ii = 0; ii < aItemCount; ii++ ) for( unsigned ii = 0; ii < aList.size(); ii++ ) { DrawList = aList[ii].m_RootCmp; Loading @@ -719,11 +654,9 @@ int WinEDA_Build_BOM_Frame::PrintComponentsListByRef( FILE* f, 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 Loading @@ -772,10 +705,11 @@ int WinEDA_Build_BOM_Frame::PrintComponentsListByRef( FILE* f, /*********************************************************************************************/ int WinEDA_Build_BOM_Frame::PrintComponentsListByVal( FILE* f, OBJ_CMP_TO_LIST* aList, int aItemCount, bool aIncludeSubComponents ) int WinEDA_Build_BOM_Frame::PrintComponentsListByVal( FILE* f, std::vector <OBJ_CMP_TO_LIST>& aList, bool aIncludeSubComponents ) /**********************************************************************************************/ { int Multi; Loading @@ -793,7 +727,7 @@ int WinEDA_Build_BOM_Frame::PrintComponentsListByVal( FILE* f, msg << wxT( "\n" ); fprintf( f, CONV_TO_UTF8( msg ) ); for( int ii = 0; ii < aItemCount; ii++ ) for( unsigned ii = 0; ii < aList.size(); ii++ ) { DrawList = aList[ii].m_RootCmp; Loading Loading @@ -916,7 +850,7 @@ static int PrintListeGLabel( FILE* f, std::vector <LABEL_OBJECT>& aList ) /********************************************/ int RefDesStringCompare( char* obj1, char* obj2 ) int RefDesStringCompare( const char* obj1, const char* obj2 ) /********************************************/ /* This function will act just like the strcmp function but correctly sort Loading eeschema/dialog_build_BOM.h +2 −2 Original line number Diff line number Diff line Loading @@ -134,9 +134,9 @@ public: bool aRunBrowser); void GenereListeOfItems(const wxString & FullFileName, bool aIncludeSubComponents ); void CreateExportList(const wxString & FullFileName, bool aIncludeSubComponents); int PrintComponentsListByRef( FILE * f, OBJ_CMP_TO_LIST * List, int NbItems, int PrintComponentsListByRef( FILE * f, std::vector <OBJ_CMP_TO_LIST>& aList, bool CompactForm, bool aIncludeSubComponents ); int PrintComponentsListByVal( FILE *f, OBJ_CMP_TO_LIST * List, int NbItems, int PrintComponentsListByVal( FILE *f, std::vector <OBJ_CMP_TO_LIST>& aList, bool aIncludeSubComponents); void PrintFieldData(FILE * f, SCH_COMPONENT * DrawLibItem, bool CompactForm = FALSE); void SavePreferences(); Loading eeschema/libarch.cpp +3 −1 Original line number Diff line number Diff line Loading @@ -38,7 +38,9 @@ bool LibArchive( wxWindow* frame, const wxString& ArchFullFileName ) EDA_ScreenList s_list; // examine all screens used and build the list of components found in lib /* examine all screens (not scheets) used and build the list of components found in lib * complex hierarchies are not a problem because we just want to know used components in librarires */ for( SCH_SCREEN* screen = s_list.GetFirst(); screen != NULL; screen = s_list.GetNext() ) { for( SCH_ITEM* SchItem = screen->EEDrawList; SchItem; SchItem = SchItem->Next() ) Loading Loading
eeschema/build_BOM.cpp +118 −184 Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ class LABEL_OBJECT public: int m_LabelType; SCH_ITEM* m_Label; //have to store it here since the object references will be duplicated. DrawSheetPath m_SheetPath; //composed of UIDs Loading @@ -47,20 +48,19 @@ public: // Filename extension for BOM list #define EXT_LIST wxT( ".lst" ) // Exported functions int BuildComponentsListFromSchematic( OBJ_CMP_TO_LIST * aList ); /* fonctions locales */ static int GenListeGLabels( std::vector <LABEL_OBJECT>& aList ); static int ListTriComposantByRef( OBJ_CMP_TO_LIST* obj1, OBJ_CMP_TO_LIST* obj2 ); static int ListTriComposantByVal( OBJ_CMP_TO_LIST* obj1, OBJ_CMP_TO_LIST* obj2 ); /* Local functions */ static void BuildComponentsListFromSchematic( std::vector <OBJ_CMP_TO_LIST>& aList ); static void GenListeGLabels( std::vector <LABEL_OBJECT>& aList ); static bool SortComponentsByReference( const OBJ_CMP_TO_LIST& obj1, const OBJ_CMP_TO_LIST& obj2 ); static bool SortComponentsByValue( const OBJ_CMP_TO_LIST& obj1, const OBJ_CMP_TO_LIST& obj2 ); static bool SortLabelsByValue( const LABEL_OBJECT& obj1, const LABEL_OBJECT& obj2 ); static bool SortLabelsBySheet( const LABEL_OBJECT& obj1, const LABEL_OBJECT& obj2 ); static void DeleteSubCmp( OBJ_CMP_TO_LIST* aList, int aItemCount ); static void DeleteSubCmp( std::vector <OBJ_CMP_TO_LIST>& aList ); static int PrintListeGLabel( FILE* f, std::vector <LABEL_OBJECT>& aList ); int RefDesStringCompare( char* obj1, char* obj2 ); int RefDesStringCompare( const char* obj1, const char* obj2 ); int SplitString( wxString strToSplit, wxString* strBeginning, wxString* strDigits, Loading Loading @@ -135,8 +135,6 @@ void WinEDA_Build_BOM_Frame::CreateExportList( const wxString& aFullFileName, */ { FILE* f; OBJ_CMP_TO_LIST* aList; int itemCount; wxString msg; /* Creation de la liste des elements */ Loading @@ -148,30 +146,17 @@ void WinEDA_Build_BOM_Frame::CreateExportList( const wxString& aFullFileName, return; } itemCount = BuildComponentsListFromSchematic( NULL ); if( itemCount ) { aList = (OBJ_CMP_TO_LIST*) MyZMalloc( itemCount * sizeof(OBJ_CMP_TO_LIST) ); if( aList == NULL ) { fclose( f ); return; } BuildComponentsListFromSchematic( aList ); std::vector <OBJ_CMP_TO_LIST> cmplist; BuildComponentsListFromSchematic( cmplist ); /* sort component list */ qsort( aList, itemCount, sizeof( OBJ_CMP_TO_LIST ), ( int( * ) ( const void*, const void* ) )ListTriComposantByRef ); sort( cmplist.begin(), cmplist.end(), SortComponentsByReference ); if( !aIncludeSubComponents ) DeleteSubCmp( aList, itemCount ); DeleteSubCmp( cmplist ); /* create the file */ PrintComponentsListByRef( f, aList, itemCount, TRUE, aIncludeSubComponents ); MyFree( aList ); } PrintComponentsListByRef( f, cmplist, TRUE, aIncludeSubComponents ); fclose( f ); } Loading @@ -188,7 +173,6 @@ void WinEDA_Build_BOM_Frame::GenereListeOfItems( const wxString& aFullFileName, */ { FILE* f; OBJ_CMP_TO_LIST* list; int itemCount; char Line[1024]; wxString msg; Loading @@ -201,43 +185,31 @@ void WinEDA_Build_BOM_Frame::GenereListeOfItems( const wxString& aFullFileName, return; } itemCount = BuildComponentsListFromSchematic( NULL ); std::vector <OBJ_CMP_TO_LIST> cmplist; BuildComponentsListFromSchematic( cmplist ); itemCount = cmplist.size(); if( itemCount ) { list = (OBJ_CMP_TO_LIST*) MyZMalloc( itemCount * sizeof(OBJ_CMP_TO_LIST) ); if( list == NULL ) // Error memory alloc { fclose( f ); return; } BuildComponentsListFromSchematic( list ); /* generation du fichier listing */ /* creates the list file */ DateAndTime( Line ); wxString Title = g_Main_Title + wxT( " " ) + GetBuildVersion(); fprintf( f, "%s >> Creation date: %s\n", CONV_TO_UTF8( Title ), Line ); /* Tri et impression de la liste des composants */ qsort( list, itemCount, sizeof( OBJ_CMP_TO_LIST ), ( int( * ) ( const void*, const void* ) )ListTriComposantByRef ); /* sort component list */ sort( cmplist.begin(), cmplist.end(), SortComponentsByReference ); if( !aIncludeSubComponents ) DeleteSubCmp( list, itemCount ); DeleteSubCmp( cmplist ); if( m_ListCmpbyRefItems->GetValue() ) { PrintComponentsListByRef( f, list, itemCount, false, aIncludeSubComponents ); } PrintComponentsListByRef( f, cmplist, false, aIncludeSubComponents ); if( m_ListCmpbyValItems->GetValue() ) { qsort( list, itemCount, sizeof( OBJ_CMP_TO_LIST ), ( int( * ) ( const void*, const void* ) )ListTriComposantByVal ); PrintComponentsListByVal( f, list, itemCount, aIncludeSubComponents ); sort( cmplist.begin(), cmplist.end(), SortComponentsByValue ); PrintComponentsListByVal( f, cmplist, aIncludeSubComponents ); } MyFree( list ); } /*************************************************/ Loading Loading @@ -275,9 +247,9 @@ void WinEDA_Build_BOM_Frame::GenereListeOfItems( const wxString& aFullFileName, } /*********************************************************/ int BuildComponentsListFromSchematic( OBJ_CMP_TO_LIST* aList ) /*********************************************************/ /***************************************************************************/ void BuildComponentsListFromSchematic( std::vector <OBJ_CMP_TO_LIST>& aList ) /***************************************************************************/ /* Creates the list of components found in the whole schematic * Loading @@ -287,7 +259,6 @@ int BuildComponentsListFromSchematic( OBJ_CMP_TO_LIST* aList ) * Also Initialise m_Father as pointerof the SCH_SCREN parent */ { int itemCount = 0; EDA_BaseStruct* SchItem; SCH_COMPONENT* DrawLibItem; DrawSheetPath* sheet; Loading @@ -302,38 +273,32 @@ int BuildComponentsListFromSchematic( OBJ_CMP_TO_LIST* aList ) if( SchItem->Type() != TYPE_SCH_COMPONENT ) continue; itemCount++; DrawLibItem = (SCH_COMPONENT*) SchItem; DrawLibItem->SetParent( sheet->LastScreen() ); if( aList ) { aList->m_RootCmp = DrawLibItem; aList->m_SheetPath = *sheet; aList->m_Unit = DrawLibItem->GetUnitSelection( sheet ); OBJ_CMP_TO_LIST item; item.m_RootCmp = DrawLibItem; item.m_SheetPath = *sheet; item.m_Unit = DrawLibItem->GetUnitSelection( sheet ); strncpy( aList->m_Reference, strncpy( item.m_Reference, CONV_TO_UTF8( DrawLibItem->GetRef( sheet ) ), sizeof( aList->m_Reference ) ); sizeof( item.m_Reference ) ); // Ensure always nul terminate m_Ref. aList->m_Reference[sizeof( aList->m_Reference ) - 1 ] = 0; aList++; item.m_Reference[sizeof( item.m_Reference ) - 1 ] = 0; aList.push_back( item ); } } } return itemCount; } /****************************************************************/ static int GenListeGLabels( std::vector <LABEL_OBJECT>& aList ) static void GenListeGLabels( std::vector <LABEL_OBJECT>& aList ) /****************************************************************/ /* Fill aList with Glabel info */ { int itemCount = 0; SCH_ITEM* DrawList; Hierarchical_PIN_Sheet_Struct* PinLabel; DrawSheetPath* sheet; Loading @@ -352,7 +317,6 @@ static int GenListeGLabels( std::vector <LABEL_OBJECT>& aList ) { case TYPE_SCH_HIERLABEL: case TYPE_SCH_GLOBALLABEL: itemCount++; labet_object.m_LabelType = DrawList->Type(); labet_object.m_SheetPath = *sheet; labet_object.m_Label = DrawList; Loading @@ -364,7 +328,6 @@ static int GenListeGLabels( std::vector <LABEL_OBJECT>& aList ) PinLabel = ( (DrawSheetStruct*) DrawList )->m_Label; while( PinLabel != NULL ) { itemCount++; labet_object.m_LabelType = DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE; labet_object.m_SheetPath = *sheet; labet_object.m_Label = PinLabel; Loading @@ -377,102 +340,74 @@ static int GenListeGLabels( std::vector <LABEL_OBJECT>& aList ) default: break; } DrawList = DrawList->Next(); } } return itemCount; } /**********************************************************/ static int ListTriComposantByVal( OBJ_CMP_TO_LIST* obj1, OBJ_CMP_TO_LIST* obj2 ) /**********************************************************/ /************************************************************************************/ bool SortComponentsByValue( const OBJ_CMP_TO_LIST& obj1, const OBJ_CMP_TO_LIST& obj2 ) /************************************************************************************/ /* Routine de comparaison pour le tri du Tableau par qsort() * Les composants sont tries * par valeur * si meme valeur: par reference * si meme valeur: par numero d'unite /* Compare fuinction for sort() * components are sorted * by value * if same value: by reference * if same reference: by unit number */ { int ii; const wxString* Text1, * Text2; if( ( obj1 == NULL ) && ( obj2 == NULL ) ) return 0; if( obj1 == NULL ) return -1; if( obj2 == NULL ) return 1; if( ( obj1->m_RootCmp == NULL ) && ( obj2->m_RootCmp == NULL ) ) return 0; if( obj1->m_RootCmp == NULL ) return -1; if( obj2->m_RootCmp == NULL ) return 1; Text1 = &(obj1->m_RootCmp->GetField( VALUE )->m_Text); Text2 = &(obj2->m_RootCmp->GetField( VALUE )->m_Text); Text1 = &(obj1.m_RootCmp->GetField( VALUE )->m_Text); Text2 = &(obj2.m_RootCmp->GetField( VALUE )->m_Text); ii = Text1->CmpNoCase( *Text2 ); if( ii == 0 ) { ii = RefDesStringCompare( obj1->m_Reference, obj2->m_Reference ); ii = RefDesStringCompare( obj1.m_Reference, obj2.m_Reference ); } if( ii == 0 ) { ii = obj1->m_Unit - obj2->m_Unit; ii = obj1.m_Unit - obj2.m_Unit; } return ii; return ii < 0; } /*******************************************************************/ int ListTriComposantByRef( OBJ_CMP_TO_LIST* obj1, OBJ_CMP_TO_LIST* obj2 ) /*******************************************************************/ /***************************************************************************************/ bool SortComponentsByReference( const OBJ_CMP_TO_LIST& obj1, const OBJ_CMP_TO_LIST& obj2 ) /***************************************************************************************/ /* compare function for sorting * Les composants sont tries * par reference * si meme referenece: par valeur * si meme valeur: par numero d'unite * components are sorted * by reference * if same reference: by value * if same value: by unit number */ { int ii; const wxString* Text1, * Text2; if( ( obj1 == NULL ) && ( obj2 == NULL ) ) return 0; if( obj1 == NULL ) return -1; if( obj2 == NULL ) return 1; if( ( obj1->m_RootCmp == NULL ) && ( obj2->m_RootCmp == NULL ) ) return 0; if( obj1->m_RootCmp == NULL ) return -1; if( obj2->m_RootCmp == NULL ) return 1; ii = RefDesStringCompare( obj1->m_Reference, obj2->m_Reference ); ii = RefDesStringCompare( obj1.m_Reference, obj2.m_Reference ); if( ii == 0 ) { Text1 = &( obj1->m_RootCmp->GetField( VALUE )->m_Text ); Text2 = &( obj2->m_RootCmp->GetField( VALUE )->m_Text ); Text1 = &( obj1.m_RootCmp->GetField( VALUE )->m_Text ); Text2 = &( obj2.m_RootCmp->GetField( VALUE )->m_Text ); ii = Text1->CmpNoCase( *Text2 ); } if( ii == 0 ) { ii = obj1->m_Unit - obj2->m_Unit; ii = obj1.m_Unit - obj2.m_Unit; } return ii; return ii < 0; } Loading Loading @@ -545,7 +480,7 @@ bool SortLabelsBySheet( const LABEL_OBJECT& obj1, const LABEL_OBJECT& obj2 ) /**************************************************************/ static void DeleteSubCmp( OBJ_CMP_TO_LIST* aList, int aItemCount ) static void DeleteSubCmp( std::vector <OBJ_CMP_TO_LIST>& aList ) /**************************************************************/ /* Remove sub components from the list, when multiples parts per package are found in this list Loading @@ -557,7 +492,7 @@ static void DeleteSubCmp( OBJ_CMP_TO_LIST* aList, int aItemCount ) wxString currName; for( int ii = 0; ii < aItemCount; ii++ ) for( unsigned ii = 0; ii < aList.size(); ii++ ) { libItem = aList[ii].m_RootCmp; if( libItem == NULL ) Loading @@ -569,9 +504,8 @@ static void DeleteSubCmp( OBJ_CMP_TO_LIST* aList, int aItemCount ) { if( oldName == currName ) // currName is a subpart of oldName: remove it { aList[ii].m_RootCmp = NULL; aList[ii].m_SheetPath.Clear(); aList[ii].m_Reference[0] = 0; aList.erase( aList.begin() + ii ); ii--; } } oldName = currName; Loading Loading @@ -629,17 +563,18 @@ void WinEDA_Build_BOM_Frame::PrintFieldData( FILE* f, SCH_COMPONENT* DrawLibItem /*********************************************************************************************/ int WinEDA_Build_BOM_Frame::PrintComponentsListByRef( FILE* f, OBJ_CMP_TO_LIST* aList, int aItemCount, int WinEDA_Build_BOM_Frame::PrintComponentsListByRef( FILE* f, std::vector <OBJ_CMP_TO_LIST>& aList, bool CompactForm, bool aIncludeSubComponents ) bool aIncludeSubComponents ) /*********************************************************************************************/ /* Print the B.O.M sorted by reference */ { int ii, Multi, Unit; int Multi, Unit; EDA_BaseStruct* DrawList; SCH_COMPONENT* DrawLibItem; EDA_LibComponentStruct* Entry; Loading Loading @@ -672,7 +607,7 @@ int WinEDA_Build_BOM_Frame::PrintComponentsListByRef( FILE* f, if( m_AddFootprintField->IsChecked() ) fprintf( f, "%cfootprint", s_ExportSeparatorSymbol ); for( ii = FIELD1; ii <= FIELD8; ii++ ) for( int ii = FIELD1; ii <= FIELD8; ii++ ) { const wxCheckBox* FieldCtrl = FieldListCtrl[ii - FIELD1]; if( FieldCtrl == NULL ) Loading @@ -697,7 +632,7 @@ int WinEDA_Build_BOM_Frame::PrintComponentsListByRef( FILE* f, } // Print list of items for( ii = 0; ii < aItemCount; ii++ ) for( unsigned ii = 0; ii < aList.size(); ii++ ) { DrawList = aList[ii].m_RootCmp; Loading @@ -719,11 +654,9 @@ int WinEDA_Build_BOM_Frame::PrintComponentsListByRef( FILE* f, 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 Loading @@ -772,10 +705,11 @@ int WinEDA_Build_BOM_Frame::PrintComponentsListByRef( FILE* f, /*********************************************************************************************/ int WinEDA_Build_BOM_Frame::PrintComponentsListByVal( FILE* f, OBJ_CMP_TO_LIST* aList, int aItemCount, bool aIncludeSubComponents ) int WinEDA_Build_BOM_Frame::PrintComponentsListByVal( FILE* f, std::vector <OBJ_CMP_TO_LIST>& aList, bool aIncludeSubComponents ) /**********************************************************************************************/ { int Multi; Loading @@ -793,7 +727,7 @@ int WinEDA_Build_BOM_Frame::PrintComponentsListByVal( FILE* f, msg << wxT( "\n" ); fprintf( f, CONV_TO_UTF8( msg ) ); for( int ii = 0; ii < aItemCount; ii++ ) for( unsigned ii = 0; ii < aList.size(); ii++ ) { DrawList = aList[ii].m_RootCmp; Loading Loading @@ -916,7 +850,7 @@ static int PrintListeGLabel( FILE* f, std::vector <LABEL_OBJECT>& aList ) /********************************************/ int RefDesStringCompare( char* obj1, char* obj2 ) int RefDesStringCompare( const char* obj1, const char* obj2 ) /********************************************/ /* This function will act just like the strcmp function but correctly sort Loading
eeschema/dialog_build_BOM.h +2 −2 Original line number Diff line number Diff line Loading @@ -134,9 +134,9 @@ public: bool aRunBrowser); void GenereListeOfItems(const wxString & FullFileName, bool aIncludeSubComponents ); void CreateExportList(const wxString & FullFileName, bool aIncludeSubComponents); int PrintComponentsListByRef( FILE * f, OBJ_CMP_TO_LIST * List, int NbItems, int PrintComponentsListByRef( FILE * f, std::vector <OBJ_CMP_TO_LIST>& aList, bool CompactForm, bool aIncludeSubComponents ); int PrintComponentsListByVal( FILE *f, OBJ_CMP_TO_LIST * List, int NbItems, int PrintComponentsListByVal( FILE *f, std::vector <OBJ_CMP_TO_LIST>& aList, bool aIncludeSubComponents); void PrintFieldData(FILE * f, SCH_COMPONENT * DrawLibItem, bool CompactForm = FALSE); void SavePreferences(); Loading
eeschema/libarch.cpp +3 −1 Original line number Diff line number Diff line Loading @@ -38,7 +38,9 @@ bool LibArchive( wxWindow* frame, const wxString& ArchFullFileName ) EDA_ScreenList s_list; // examine all screens used and build the list of components found in lib /* examine all screens (not scheets) used and build the list of components found in lib * complex hierarchies are not a problem because we just want to know used components in librarires */ for( SCH_SCREEN* screen = s_list.GetFirst(); screen != NULL; screen = s_list.GetNext() ) { for( SCH_ITEM* SchItem = screen->EEDrawList; SchItem; SchItem = SchItem->Next() ) Loading