Commit 64e9e168 authored by dickelbeck's avatar dickelbeck
Browse files

virtual BOARD_ITEM::Save()

parent a67a4f7e
Loading
Loading
Loading
Loading
+18 −4
Original line number Diff line number Diff line
@@ -4,17 +4,33 @@ Started 2007-June-11
Please add newer entries at the top, list the date and your name with 
email address.

2007-Oct-30 UPDATE   Dick Hollenbeck <dick@softplc.com>
================================================================================
+ pcbnew
    added BOARD_ITEM::Save() and to all derived classes as well.  Made virtual
    and removed all UI code from these utility functions.
    removed WriteDesc() functions from all BOARD_ITEM derived classes, although
    Keeping old ones in commented out form for a while for reference.  
    @todo: delete these from *.cpp files eventually.
    zones.cpp, clean up in prep for enhancements.
+ gerbview
    fixed bug which came about when BOARD::~BOARD() started deleting the objects
    that a BOARD owns.  export_to_pcbnew.cpp was not consistent with this 
    design and was crashing.  Also, export_to_pcbnew.cpp now uses the simple
    BOARD::Save() function.  It was another place to maintain the PCB file format,
    rather than simply putting that knowledge into one place like BOARD::Save().


2007-Oct-30 UPDATE  Jean-Pierre Charras <jean-pierre.charras@inpg.fr>
================================================================================
+cvpcb: listboxes.cpp problem solved: exists only under windows
	now apply to windows only, because this Workaround creates a problem undex linux 

+others:
	some very minor problems solved
	
+eeschema:
	in B.O.M.: the footprint field can be added to the field list

    
2007-Oct-29 UPDATE  Jean-Pierre Charras <jean-pierre.charras@inpg.fr>
================================================================================
+cvpcb: listboxes.cpp problem solved: Workaround for a curious bug in wxWidgets:
@@ -33,12 +49,10 @@ email address.
+ all:
	remove unused files.
	some translations

+cvpcb:
	set flag wxFRAME_FLOAT_ON_PARENT when create the footprint 3D frame and the
	display frame
	minor other changes

+ pcbnew:
	Use collector class to locate items in modedit.
	This is a big enhancement,
+1 −1
Original line number Diff line number Diff line
@@ -58,7 +58,7 @@ void EDA_BaseStruct::InitVars()


/* Gestion de l'etat (status) de la structure (active, deleted..) */
int EDA_BaseStruct::GetState( int type )
int EDA_BaseStruct::GetState( int type ) const
{
    return m_Status & type;
}
+24 −64
Original line number Diff line number Diff line
@@ -125,7 +125,7 @@ static bool WriteGeneralDescrPcb( BOARD* Pcb, FILE* File )


/*******************************************************************/
static int SavePcbFormatAscii( WinEDA_GerberFrame* frame, FILE* File,
static int SavePcbFormatAscii( WinEDA_GerberFrame* frame, FILE* aFile,
                               int* LayerLookUpTable )
/*******************************************************************/

@@ -136,20 +136,17 @@ static int SavePcbFormatAscii( WinEDA_GerberFrame* frame, FILE* File,
 * @return 1 if OK, 0 if fail
 */
{
    char            Line[256];
    char            line[256];
    TRACK*          track;
    TRACK*          next_track;
    BOARD_ITEM*     PtStruct;
    BOARD_ITEM*     NextStruct;
    BOARD*          GerberPcb = frame->m_Pcb;
    BOARD*          Pcb;
    BOARD*          gerberPcb = frame->m_Pcb;
    BOARD*          pcb;

    wxBeginBusyCursor();

    /* Create an image of gerber data */
    Pcb = new BOARD( NULL, frame );
    // create an image of gerber data
    pcb = new BOARD( NULL, frame );

    for( track = GerberPcb->m_Track; track != NULL; track = (TRACK*) track->Pnext )
    for( track = gerberPcb->m_Track;  track;  track = track->Next() )
    {
        int layer = track->GetLayer();
        int pcb_layer_number = LayerLookUpTable[layer];
@@ -158,23 +155,23 @@ static int SavePcbFormatAscii( WinEDA_GerberFrame* frame, FILE* File,
        
        if( pcb_layer_number > CMP_N )
        {
            DRAWSEGMENT* drawitem = new DRAWSEGMENT( NULL, TYPEDRAWSEGMENT );
            DRAWSEGMENT* drawitem = new DRAWSEGMENT( pcb, TYPEDRAWSEGMENT );

            drawitem->SetLayer( pcb_layer_number );
            drawitem->m_Start = track->m_Start;
            drawitem->m_End   = track->m_End;
            drawitem->m_Width = track->m_Width;
            drawitem->Pnext   = Pcb->m_Drawings;
            Pcb->m_Drawings   = drawitem;
            drawitem->Pnext   = pcb->m_Drawings;
            pcb->m_Drawings   = drawitem;
        }
        else
        {
            TRACK*  newtrack;
            
            // replace spots with vias when possible
            if( (track->m_Shape == S_SPOT_CIRCLE) 
             || (track->m_Shape == S_SPOT_RECT)
             || (track->m_Shape == S_SPOT_OVALE) )
            if( track->m_Shape == S_SPOT_CIRCLE 
             || track->m_Shape == S_SPOT_RECT
             || track->m_Shape == S_SPOT_OVALE )
            {
                newtrack = new SEGVIA( (const SEGVIA&) *track );

@@ -198,19 +195,20 @@ static int SavePcbFormatAscii( WinEDA_GerberFrame* frame, FILE* File,
                newtrack->SetLayer( pcb_layer_number );
            }
            
            newtrack->Insert( Pcb, NULL );
            newtrack->Insert( pcb, NULL );
        }
    }

    // delete redundant vias
    for( track = Pcb->m_Track; track != NULL; track = track->Next() )
    for( track = pcb->m_Track;  track;  track = track->Next() )
    {
        if( track->m_Shape != VIA_THROUGH )
            continue;
        
        // Search and delete others vias
        TRACK* next_track;
        TRACK* alt_track = track->Next();
        for( ; alt_track != NULL; alt_track = next_track )
        for( ;  alt_track;   alt_track = next_track )
        {
            next_track = alt_track->Next();
            if( alt_track->m_Shape != VIA_THROUGH )
@@ -229,54 +227,16 @@ static int SavePcbFormatAscii( WinEDA_GerberFrame* frame, FILE* File,
    setlocale( LC_NUMERIC, "C" );
    
    // write the PCB heading
    fprintf( File, "PCBNEW-BOARD Version %d date %s\n\n", g_CurrentVersionPCB,
            DateAndTime( Line ) );
    WriteGeneralDescrPcb( Pcb, File );
    WriteSetup( File, Pcb );
    fprintf( aFile, "PCBNEW-BOARD Version %d date %s\n\n", g_CurrentVersionPCB,
            DateAndTime( line ) );
    WriteGeneralDescrPcb( pcb, aFile );
    WriteSetup( aFile, pcb );

    // write the useful part of the pcb
    PtStruct = Pcb->m_Drawings;
    for( ; PtStruct != NULL; PtStruct = PtStruct->Next() )
    {
        switch( PtStruct->Type() )
        {
        case TYPETEXTE:
            ( (TEXTE_PCB*) PtStruct )->WriteTextePcbDescr( File );
            break;

        case TYPEDRAWSEGMENT:
            ( (DRAWSEGMENT*) PtStruct )->WriteDrawSegmentDescr( File );
            break;

        default:
            break;
        }
    }

    fprintf( File, "$TRACK\n" );
    for( track = Pcb->m_Track; track != NULL; track = (TRACK*) track->Pnext )
    {
        track->WriteTrackDescr( File );
    }

    fprintf( File, "$EndTRACK\n" );

    fprintf( File, "$EndBOARD\n" );

    // Delete the copy
    for( PtStruct = Pcb->m_Drawings; PtStruct != NULL; PtStruct = NextStruct )
    {
        NextStruct = PtStruct->Next();
        delete PtStruct;
    }

    for( track = Pcb->m_Track; track != NULL; track = next_track )
    {
        next_track = (TRACK*) track->Pnext;
        delete track;
    }
    pcb->Save( aFile );

    delete Pcb;
    // the destructor should destroy all owned sub-objects
    delete pcb;

    setlocale( LC_NUMERIC, "" );      // revert to the current locale
    wxEndBusyCursor();
+12 −1
Original line number Diff line number Diff line
@@ -191,7 +191,7 @@ public:
    
    
    /* Gestion de l'etat (status) de la structure (active, deleted..) */
    int     GetState( int type );
    int     GetState( int type ) const;
    void    SetState( int type, int state );

    int ReturnStatus() const {  return m_Status;  }
@@ -490,6 +490,17 @@ public:
     * @todo: make this virtual and split into each derived class
     */
    const char** MenuIcon() const;

    
    /**
     * Function Save
     * writes the data structures for this object out to a FILE in "*.pcb" format.
     * @param aFile The FILE to write to.
     * @return bool - true if success writing else false.
     */ 
    virtual bool Save( FILE* aFile ) const = 0;
    
    
};


+18 −1
Original line number Diff line number Diff line
@@ -289,6 +289,15 @@ public:
    EQUIPOT* FindNet( int aNetcode ) const;


    /**
     * Function Save
     * writes the data structures for this object out to a FILE in "*.pcb" format.
     * @param aFile The FILE to write to.
     * @return bool - true if success writing else false.
     */ 
    bool Save( FILE* aFile ) const;
    
    
    /**
     * Function GetClass
     * returns the class name.
@@ -370,7 +379,15 @@ public:
    ~DRAWSEGMENT();

    // Read/write data
    bool    WriteDrawSegmentDescr( FILE* File );
    
    /**
     * Function Save
     * writes the data structures for this object out to a FILE in "*.pcb" format.
     * @param aFile The FILE to write to.
     * @return bool - true if success writing else false.
     */ 
    bool Save( FILE* aFile ) const;
    
    bool    ReadDrawSegmentDescr( FILE* File, int* LineNum );

    /* remove this from the linked list */
Loading