Commit 5f5620a1 authored by charras's avatar charras
Browse files

++Pcbnew

Pcbnew: Fixed an issue in GERBER file creation, under Vista and W7 only for non administrator users
Plot files were 0 byte length.
This was due to use of function tmpfile() in a GERBER function to create a temporary file that seems not working using mingw.
Replaced by more usual files functions.
parent 7816b717
Loading
Loading
Loading
Loading
+8 −0
Original line number Original line Diff line number Diff line
@@ -4,6 +4,14 @@ KiCad ChangeLog 2010
Please add newer entries at the top, list the date and your name with
Please add newer entries at the top, list the date and your name with
email address.
email address.


2010-mar-31, UPDATE Jean-Pierre Charras <jean-pierre.charras@gipsa-lab.inpg.fr>
================================================================================
++Pcbnew
    Fixed an issue in GERBER file creation, under Vista and W7 only for non administrator users
    Plot files were 0 byte length.
    This was due to use of function tmpfile() in a GERBER function
    to create a temporary file that seems not working using mingw.
    Replaced by more usual files functions.


2010-mar-29, UPDATE Jean-Pierre Charras <jean-pierre.charras@gipsa-lab.inpg.fr>
2010-mar-29, UPDATE Jean-Pierre Charras <jean-pierre.charras@gipsa-lab.inpg.fr>
================================================================================
================================================================================
+7 −3
Original line number Original line Diff line number Diff line
@@ -27,7 +27,7 @@ void DXF_PLOTTER::set_viewport( wxPoint offset,
}
}




void DXF_PLOTTER::start_plot( FILE* fout )
bool DXF_PLOTTER::start_plot( FILE* fout )
{
{
    wxASSERT( !output_file );
    wxASSERT( !output_file );
    output_file = fout;
    output_file = fout;
@@ -45,16 +45,20 @@ void DXF_PLOTTER::start_plot( FILE* fout )


    /* End of layer table, begin entities */
    /* End of layer table, begin entities */
    fputs( "0\nENDTAB\n0\nENDSEC\n0\nSECTION\n2\nENTITIES\n", output_file );
    fputs( "0\nENDTAB\n0\nENDSEC\n0\nSECTION\n2\nENTITIES\n", output_file );

    return true;
}
}




void DXF_PLOTTER::end_plot()
bool DXF_PLOTTER::end_plot()
{
{
    wxASSERT( output_file );
    wxASSERT( output_file );
    /* DXF FOOTER */
    /* DXF FOOTER */
    fputs( "0\nENDSEC\n0\nEOF\n", output_file );
    fputs( "0\nENDSEC\n0\nEOF\n", output_file );
    fclose( output_file );
    fclose( output_file );
    output_file = 0;
    output_file = NULL;

    return true;
}
}




+20 −4
Original line number Original line Diff line number Diff line
@@ -39,14 +39,22 @@ void GERBER_PLOTTER::set_viewport( wxPoint offset,
 * initialize global variable g_Plot_PlotOutputFile
 * initialize global variable g_Plot_PlotOutputFile
 * @param aFile: an opened file to write to
 * @param aFile: an opened file to write to
 */
 */
void GERBER_PLOTTER::start_plot( FILE* aFile )
bool GERBER_PLOTTER::start_plot( FILE* aFile )
{
{
    char Line[1024];
    char Line[1024];


    wxASSERT( !output_file );
    wxASSERT( !output_file );
    final_file  = aFile;
    final_file  = aFile;
    work_file   = tmpfile();

    // Create a temporary filename to store gerber file
    // note tmpfile() does not work under Vista and W7 un user mode
    m_workFilename = filename + wxT(".tmp");
    work_file   = wxFopen( m_workFilename, wxT( "wt" ));
    output_file = work_file;
    output_file = work_file;
    wxASSERT( output_file );
    if( output_file == NULL )
        return false;

    DateAndTime( Line );
    DateAndTime( Line );
    wxString Title = creator + wxT( " " ) + GetBuildVersion();
    wxString Title = creator + wxT( " " ) + GetBuildVersion();
    fprintf( output_file, "G04 (created by %s) date %s*\n",
    fprintf( output_file, "G04 (created by %s) date %s*\n",
@@ -63,10 +71,12 @@ void GERBER_PLOTTER::start_plot( FILE* aFile )
    fputs( "G04 APERTURE LIST*\n", output_file );
    fputs( "G04 APERTURE LIST*\n", output_file );
    /* Select the default aperture */
    /* Select the default aperture */
    set_current_line_width( -1 );
    set_current_line_width( -1 );

    return true;
}
}




void GERBER_PLOTTER::end_plot()
bool GERBER_PLOTTER::end_plot()
{
{
    char     line[1024];
    char     line[1024];
    wxString msg;
    wxString msg;
@@ -75,7 +85,10 @@ void GERBER_PLOTTER::end_plot()
    /* Outfile is actually a temporary file! */
    /* Outfile is actually a temporary file! */
    fputs( "M02*\n", output_file );
    fputs( "M02*\n", output_file );
    fflush( output_file );
    fflush( output_file );
    rewind( work_file ); // work_file == output_file !!!
//    rewind( work_file ); // work_file == output_file !!!
    fclose( work_file );
    work_file   = wxFopen( m_workFilename, wxT( "rt" ));
    wxASSERT( work_file );
    output_file = final_file;
    output_file = final_file;




@@ -92,7 +105,10 @@ void GERBER_PLOTTER::end_plot()


    fclose( work_file );
    fclose( work_file );
    fclose( final_file );
    fclose( final_file );
    ::wxRemoveFile( m_workFilename );
    output_file = 0;
    output_file = 0;

    return true;
}
}




+5 −3
Original line number Original line Diff line number Diff line
@@ -28,20 +28,22 @@ void HPGL_PLOTTER::set_viewport( wxPoint offset, double aScale, int orient )
}
}




void HPGL_PLOTTER::start_plot( FILE* fout )
bool HPGL_PLOTTER::start_plot( FILE* fout )
{
{
    wxASSERT( !output_file );
    wxASSERT( !output_file );
    output_file = fout;
    output_file = fout;
    fprintf( output_file, "IN;VS%d;PU;PA;SP%d;\n", pen_speed, pen_number );
    fprintf( output_file, "IN;VS%d;PU;PA;SP%d;\n", pen_speed, pen_number );
    return true;
}
}




void HPGL_PLOTTER::end_plot()
bool HPGL_PLOTTER::end_plot()
{
{
    wxASSERT( output_file );
    wxASSERT( output_file );
    fputs( "PU;PA;SP0;\n", output_file );
    fputs( "PU;PA;SP0;\n", output_file );
    fclose( output_file );
    fclose( output_file );
    output_file = 0;
    output_file = NULL;
    return true;
}
}




+7 −3
Original line number Original line Diff line number Diff line
@@ -249,7 +249,7 @@ void PS_PLOTTER::pen_to( wxPoint pos, char plume )
 * BBox is the boundary box (position and size of the "client rectangle"
 * BBox is the boundary box (position and size of the "client rectangle"
 * for drawings (page - margins) in mils (0.001 inch)
 * for drawings (page - margins) in mils (0.001 inch)
 */
 */
void PS_PLOTTER::start_plot( FILE* fout )
bool PS_PLOTTER::start_plot( FILE* fout )
{
{
    wxASSERT( !output_file );
    wxASSERT( !output_file );
    wxString           msg;
    wxString           msg;
@@ -366,15 +366,19 @@ void PS_PLOTTER::start_plot( FILE* fout )
    // Set default line width ( g_Plot_DefaultPenWidth is in user units )
    // Set default line width ( g_Plot_DefaultPenWidth is in user units )
    fprintf( output_file, "%g setlinewidth\n",
    fprintf( output_file, "%g setlinewidth\n",
             user_to_device_size( default_pen_width ) );
             user_to_device_size( default_pen_width ) );

    return true;
}
}




void PS_PLOTTER::end_plot()
bool PS_PLOTTER::end_plot()
{
{
    wxASSERT( output_file );
    wxASSERT( output_file );
    fputs( "showpage\ngrestore\n%%EOF\n", output_file );
    fputs( "showpage\ngrestore\n%%EOF\n", output_file );
    fclose( output_file );
    fclose( output_file );
    output_file = 0;
    output_file = NULL;

    return true;
}
}




Loading