~bidulock/kicad/kicad-brian

« back to all changes in this revision

Viewing changes to eeschema/build_BOM.cpp

  • Committer: Brian F. G. Bidulock
  • Date: 2010-06-30 12:43:10 UTC
  • mfrom: (2360.3.47 testing)
  • Revision ID: brian@habeascorpus-20100630124310-9p4sig3zj1gqnlqd
mergedĀ upstreamĀ changes

Show diffs side-by-side

added added

removed removed

Lines of Context:
340
340
{
341
341
    EDA_BaseStruct* SchItem;
342
342
    SCH_COMPONENT*  DrawLibItem;
343
 
    SCH_SHEET_PATH* sheet;
 
343
    SCH_SHEET_PATH* sheetPath;
344
344
 
345
345
    /* Build the sheet (not screen) list */
346
346
    SCH_SHEET_LIST  SheetList;
347
347
 
348
 
    for( sheet = SheetList.GetFirst();
349
 
        sheet != NULL;
350
 
        sheet = SheetList.GetNext() )
 
348
    for( sheetPath = SheetList.GetFirst();  sheetPath != NULL;  sheetPath = SheetList.GetNext() )
351
349
    {
352
 
        for( SchItem = sheet->LastDrawList(); SchItem;
353
 
            SchItem = SchItem->Next() )
 
350
        for( SchItem = sheetPath->LastDrawList();  SchItem;  SchItem = SchItem->Next() )
354
351
        {
355
352
            if( SchItem->Type() != TYPE_SCH_COMPONENT )
356
353
                continue;
357
354
 
358
355
            DrawLibItem = (SCH_COMPONENT*) SchItem;
359
 
            DrawLibItem->SetParent( sheet->LastScreen() );
 
356
            DrawLibItem->SetParent( sheetPath->LastScreen() );
360
357
            OBJ_CMP_TO_LIST item;
361
358
            item.m_RootCmp   = DrawLibItem;
362
 
            item.m_SheetPath = *sheet;
363
 
            item.m_Unit = DrawLibItem->GetUnitSelection( sheet );
 
359
            item.m_SheetPath = *sheetPath;
 
360
            item.m_Unit = DrawLibItem->GetUnitSelection( sheetPath );
364
361
 
365
362
            strncpy( item.m_Reference,
366
 
                    CONV_TO_UTF8( DrawLibItem->GetRef( sheet ) ),
367
 
                    sizeof( item.m_Reference ) );
 
363
                     CONV_TO_UTF8( DrawLibItem->GetRef( sheetPath ) ),
 
364
                     sizeof( item.m_Reference ) );
368
365
 
369
366
            // Ensure always null terminate m_Ref.
370
367
            item.m_Reference[sizeof( item.m_Reference ) - 1 ] = 0;
384
381
static void GenListeGLabels( std::vector <LABEL_OBJECT>& aList )
385
382
{
386
383
    SCH_ITEM*       DrawList;
387
 
    SCH_SHEET_PIN*  PinLabel;
388
 
    SCH_SHEET_PATH* sheet;
 
384
    SCH_SHEET_PATH* sheetPath;
389
385
 
390
386
    /* Build the sheet list */
391
387
    SCH_SHEET_LIST  SheetList;
392
388
 
393
389
    LABEL_OBJECT    labet_object;
394
390
 
395
 
    for( sheet = SheetList.GetFirst();
396
 
        sheet != NULL;
397
 
        sheet = SheetList.GetNext() )
 
391
    for( sheetPath = SheetList.GetFirst();  sheetPath != NULL;  sheetPath = SheetList.GetNext() )
398
392
    {
399
 
        DrawList = (SCH_ITEM*) sheet->LastDrawList();
 
393
        DrawList = (SCH_ITEM*) sheetPath->LastDrawList();
 
394
 
400
395
        while( DrawList )
401
396
        {
402
397
            switch( DrawList->Type() )
404
399
            case TYPE_SCH_HIERLABEL:
405
400
            case TYPE_SCH_GLOBALLABEL:
406
401
                labet_object.m_LabelType = DrawList->Type();
407
 
                labet_object.m_SheetPath = *sheet;
 
402
                labet_object.m_SheetPath = *sheetPath;
408
403
                labet_object.m_Label     = DrawList;
409
404
                aList.push_back( labet_object );
410
405
                break;
411
406
 
412
407
            case DRAW_SHEET_STRUCT_TYPE:
413
408
            {
414
 
                PinLabel = ( (SCH_SHEET*) DrawList )->m_Label;
415
 
                while( PinLabel != NULL )
 
409
                SCH_SHEET* sheet = (SCH_SHEET*) DrawList;
 
410
 
 
411
                BOOST_FOREACH( SCH_SHEET_PIN sheetLabel, sheet->GetSheetPins() )
416
412
                {
417
 
                    labet_object.m_LabelType =
418
 
                        DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE;
419
 
                    labet_object.m_SheetPath = *sheet;
420
 
                    labet_object.m_Label     = PinLabel;
 
413
                    labet_object.m_LabelType = DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE;
 
414
                    labet_object.m_SheetPath = *sheetPath;
 
415
                    labet_object.m_Label     = &sheetLabel;
421
416
                    aList.push_back( labet_object );
422
 
                    PinLabel = PinLabel->Next();
423
417
                }
424
418
            }
425
419
            break;
797
791
        // Store fields. Store non empty fields only.
798
792
        for( int jj = FOOTPRINT; jj < currCmp->GetFieldCount(); jj++ )
799
793
        {
 
794
            //Ensure fields exists in dummy component
 
795
            if( dummyCmp.GetFieldCount() <= jj )
 
796
                dummyCmp.AddField( *currCmp->GetField( jj ) );
 
797
            // store useful data
800
798
            if( !currCmp->GetField( jj )->m_Text.IsEmpty() )
801
799
                dummyCmp.GetField( jj )->m_Text = currCmp->GetField( jj )->m_Text;
802
800
        }
845
843
                    CONV_TO_UTF8( currCmp->GetField( DATASHEET) ->m_Text ) );
846
844
#endif
847
845
 
 
846
        fprintf( f, "%c%s", s_ExportSeparatorSymbol,
 
847
                CONV_TO_UTF8( RNames ) );
 
848
 
848
849
        // print fields, on demand
849
 
        for( int jj = FIELD1; jj <= FIELD8 ; jj++ )
 
850
        int last_nonempty_field_idx = 0;
 
851
        for( int jj = FOOTPRINT; jj < dummyCmp.GetFieldCount(); jj++ )
 
852
            if ( !dummyCmp.GetField( jj )->m_Text.IsEmpty() )
 
853
                last_nonempty_field_idx = jj;
 
854
        for( int jj = FIELD1; jj <= last_nonempty_field_idx ; jj++ )
850
855
        {
851
856
            if ( IsFieldChecked( jj ) )
852
857
                fprintf( f, "%c%4s", s_ExportSeparatorSymbol,
853
858
                        CONV_TO_UTF8( dummyCmp.GetField( jj )->m_Text ) );
854
859
        }
855
860
 
856
 
        fprintf( f, "%c%s\n", s_ExportSeparatorSymbol,
857
 
                CONV_TO_UTF8( RNames ) );
 
861
        fprintf( f, "\n" );
858
862
 
859
863
        // Clear strings and values, to prepare next component
860
864
        qty = 0;
861
865
        RNames.Empty();
862
 
        for( int jj = FOOTPRINT; jj < currCmp->GetFieldCount(); jj++ )
 
866
        for( int jj = FOOTPRINT; jj < dummyCmp.GetFieldCount(); jj++ )
863
867
            dummyCmp.GetField( jj )->m_Text.Empty();
864
868
    }
865
869