Commit 5f5620a1 authored by charras's avatar charras

++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
......@@ -4,6 +4,14 @@ KiCad ChangeLog 2010
Please add newer entries at the top, list the date and your name with
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>
================================================================================
......
......@@ -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 );
output_file = fout;
......@@ -45,16 +45,20 @@ void DXF_PLOTTER::start_plot( FILE* fout )
/* End of layer table, begin entities */
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 );
/* DXF FOOTER */
fputs( "0\nENDSEC\n0\nEOF\n", output_file );
fclose( output_file );
output_file = 0;
output_file = NULL;
return true;
}
......
......@@ -39,14 +39,22 @@ void GERBER_PLOTTER::set_viewport( wxPoint offset,
* initialize global variable g_Plot_PlotOutputFile
* @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];
wxASSERT( !output_file );
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;
wxASSERT( output_file );
if( output_file == NULL )
return false;
DateAndTime( Line );
wxString Title = creator + wxT( " " ) + GetBuildVersion();
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 );
/* Select the default aperture */
set_current_line_width( -1 );
return true;
}
void GERBER_PLOTTER::end_plot()
bool GERBER_PLOTTER::end_plot()
{
char line[1024];
wxString msg;
......@@ -75,7 +85,10 @@ void GERBER_PLOTTER::end_plot()
/* Outfile is actually a temporary file! */
fputs( "M02*\n", 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;
......@@ -92,7 +105,10 @@ void GERBER_PLOTTER::end_plot()
fclose( work_file );
fclose( final_file );
::wxRemoveFile( m_workFilename );
output_file = 0;
return true;
}
......
......@@ -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 );
output_file = fout;
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 );
fputs( "PU;PA;SP0;\n", output_file );
fclose( output_file );
output_file = 0;
output_file = NULL;
return true;
}
......
......@@ -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"
* 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 );
wxString msg;
......@@ -366,15 +366,19 @@ void PS_PLOTTER::start_plot( FILE* fout )
// Set default line width ( g_Plot_DefaultPenWidth is in user units )
fprintf( output_file, "%g setlinewidth\n",
user_to_device_size( default_pen_width ) );
return true;
}
void PS_PLOTTER::end_plot()
bool PS_PLOTTER::end_plot()
{
wxASSERT( output_file );
fputs( "showpage\ngrestore\n%%EOF\n", output_file );
fclose( output_file );
output_file = 0;
output_file = NULL;
return true;
}
......
......@@ -47,8 +47,8 @@ public:
PlotFormat GetPlotterType()
{ return m_PlotType; }
virtual void start_plot( FILE* fout ) = 0;
virtual void end_plot() = 0;
virtual bool start_plot( FILE* fout ) = 0;
virtual bool end_plot() = 0;
virtual void set_negative( bool _negative )
{
......@@ -200,8 +200,8 @@ public:
{
}
virtual void start_plot( FILE* fout );
virtual void end_plot();
virtual bool start_plot( FILE* fout );
virtual bool end_plot();
/* HPGL doesn't handle line thickness or color */
virtual void set_current_line_width( int width )
......@@ -278,8 +278,8 @@ public:
plot_scale_adjY = 1;
}
virtual void start_plot( FILE* fout );
virtual void end_plot();
virtual bool start_plot( FILE* fout );
virtual bool end_plot();
virtual void set_current_line_width( int width );
virtual void set_default_line_width( int width );
virtual void set_dash( bool dashed );
......@@ -344,8 +344,8 @@ public:
}
virtual void start_plot( FILE* fout );
virtual void end_plot();
virtual bool start_plot( FILE* fout );
virtual bool end_plot();
virtual void set_current_line_width( int width );
virtual void set_default_line_width( int width );
......@@ -375,6 +375,8 @@ protected:
APERTURE::Aperture_Type type );
FILE* work_file, * final_file;
wxString m_workFilename;
void write_aperture_list();
std::vector<APERTURE> apertures;
......@@ -388,8 +390,8 @@ public:
{
}
virtual void start_plot( FILE* fout );
virtual void end_plot();
virtual bool start_plot( FILE* fout );
virtual bool end_plot();
/* For now we don't use 'thick' primitives, so no line width */
virtual void set_current_line_width( int width )
......
......@@ -60,14 +60,20 @@ bool WinEDA_BasePcbFrame::Genere_GERBER( const wxString& FullFileName, int Layer
plotter->set_creator( wxT( "PCBNEW-RS274X" ) );
plotter->set_filename( FullFileName );
plotter->start_plot( output_file );
if( plotter->start_plot( output_file ) )
{
// Sheet refs on gerber CAN be useful... and they're always 1:1
if( g_pcb_plot_options.Plot_Frame_Ref )
PlotWorkSheet( plotter, GetScreen() );
Plot_Layer( plotter, Layer, trace_mode );
// Sheet refs on gerber CAN be useful... and they're always 1:1
if( g_pcb_plot_options.Plot_Frame_Ref )
PlotWorkSheet( plotter, GetScreen() );
Plot_Layer( plotter, Layer, trace_mode );
plotter->end_plot();
}
plotter->end_plot();
else // error in start_plot( ): failed opening a temporary file
{
wxMessageBox( _("Error when creating %s file: unable to create a temporary file"));
}
delete plotter;
SetLocaleTo_Default();
......
release version:
2010 mar 30 (SVN 2479)
2010 apr 01
files (.zip,.tgz):
kicad-2010-03-30-final
kicad-2010-04-01-final
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment