Commit 11d9edfe authored by charras's avatar charras

beautify files

parent daeb1901
This diff is collapsed.
......@@ -22,8 +22,8 @@
/********************************************************************************/
void WinEDA_BasePcbFrame::Genere_GERBER( const wxString& FullFileName, int Layer,
bool PlotOriginIsAuxAxis,
GRTraceMode trace_mode )
bool PlotOriginIsAuxAxis,
GRTraceMode trace_mode )
/********************************************************************************/
/* Creates the output files, one per board layer:
......@@ -43,13 +43,13 @@ void WinEDA_BasePcbFrame::Genere_GERBER( const wxString& FullFileName, int Layer
if( PlotOriginIsAuxAxis )
offset = m_Auxiliary_Axis_Position;
else
else
{
offset.x = 0;
offset.y = 0;
offset.x = 0;
offset.y = 0;
}
FILE *output_file = wxFopen( FullFileName, wxT( "wt" ) );
FILE* output_file = wxFopen( FullFileName, wxT( "wt" ) );
if( output_file == NULL )
{
wxString msg = _( "unable to create file " ) + FullFileName;
......@@ -58,23 +58,23 @@ void WinEDA_BasePcbFrame::Genere_GERBER( const wxString& FullFileName, int Layer
}
SetLocaleTo_C_standard();
Plotter *plotter = new Gerber_Plotter();
Plotter* plotter = new Gerber_Plotter();
/* No mirror and scaling for gerbers! */
plotter->set_viewport(offset, scale, 0);
plotter->set_viewport( offset, scale, 0 );
plotter->set_default_line_width( g_pcb_plot_options.PlotLine_Width );
plotter->set_creator(wxT("PCBNEW-RS274X"));
plotter->set_filename(FullFileName);
plotter->set_creator( wxT( "PCBNEW-RS274X" ) );
plotter->set_filename( FullFileName );
Affiche_1_Parametre( this, 0, _( "File" ), FullFileName, CYAN );
plotter->start_plot(output_file);
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);
PlotWorkSheet( plotter, GetScreen() );
Plot_Layer( plotter, Layer, trace_mode );
plotter->end_plot();
delete plotter;
SetLocaleTo_Default();
}
......@@ -13,36 +13,38 @@
#include "protos.h"
/*****************************************************************************/
void WinEDA_BasePcbFrame::Genere_HPGL( const wxString& FullFileName, int Layer,
GRTraceMode trace_mode)
void WinEDA_BasePcbFrame::Genere_HPGL( const wxString& FullFileName, int Layer,
GRTraceMode trace_mode )
/*****************************************************************************/
{
wxSize SheetSize;
wxSize BoardSize;
wxPoint BoardCenter;
bool Center = FALSE;
wxSize SheetSize;
wxSize BoardSize;
wxPoint BoardCenter;
bool Center = FALSE;
Ki_PageDescr* currentsheet = GetScreen()->m_CurrentSheetDesc;
double scale;
wxPoint offset;
double scale;
wxPoint offset;
MsgPanel->EraseMsgBox();
// Compute pen_dim (from g_HPGL_Pen_Diam in mils) in pcb units,
// with plot scale (if Scale is 2, pen diametre is always g_HPGL_Pen_Diam
// so apparent pen diam is real pen diam / Scale
int pen_diam = wxRound( (g_pcb_plot_options.HPGL_Pen_Diam * U_PCB) / g_pcb_plot_options.Scale );
int pen_diam = wxRound( (g_pcb_plot_options.HPGL_Pen_Diam * U_PCB) / g_pcb_plot_options.Scale );
// compute pen_recouvrement (from g_HPGL_Pen_Recouvrement in mils)
// with plot scale
if( g_pcb_plot_options.HPGL_Pen_Recouvrement < 0 )
g_pcb_plot_options.HPGL_Pen_Recouvrement = 0;
g_pcb_plot_options.HPGL_Pen_Recouvrement = 0;
if( g_pcb_plot_options.HPGL_Pen_Recouvrement >= g_pcb_plot_options.HPGL_Pen_Diam )
g_pcb_plot_options.HPGL_Pen_Recouvrement = g_pcb_plot_options.HPGL_Pen_Diam - 1;
int pen_recouvrement = wxRound( g_pcb_plot_options.HPGL_Pen_Recouvrement * 10.0 / g_pcb_plot_options.Scale );
g_pcb_plot_options.HPGL_Pen_Recouvrement = g_pcb_plot_options.HPGL_Pen_Diam - 1;
int pen_recouvrement = wxRound(
g_pcb_plot_options.HPGL_Pen_Recouvrement * 10.0 / g_pcb_plot_options.Scale );
FILE *output_file = wxFopen( FullFileName, wxT( "wt" ) );
FILE* output_file = wxFopen( FullFileName, wxT( "wt" ) );
if( output_file == NULL )
{
wxString msg = _( "Unable to create file " ) + FullFileName;
wxString msg = _( "Unable to create file " ) + FullFileName;
DisplayError( this, msg );
return;
}
......@@ -51,7 +53,7 @@ void WinEDA_BasePcbFrame::Genere_HPGL( const wxString& FullFileName, int Layer,
Affiche_1_Parametre( this, 0, _( "File" ), FullFileName, CYAN );
if( g_pcb_plot_options.PlotScaleOpt != 1 )
Center = TRUE; // Echelle != 1 donc trace centree du PCB
Center = TRUE; // Echelle != 1 donc trace centree du PCB
// calcul en unites internes des dimensions des feuilles ( connues en 1/1000 pouce )
......@@ -65,48 +67,48 @@ void WinEDA_BasePcbFrame::Genere_HPGL( const wxString& FullFileName, int Layer,
if( g_pcb_plot_options.PlotScaleOpt == 0 ) // Optimum scale
{
double Xscale, Yscale;
// Fit to 80% of the page
Xscale = ( (SheetSize.x*0.8) / BoardSize.x);
Yscale = ( (SheetSize.y*0.8) / BoardSize.y);
scale = MIN( Xscale, Yscale );
double Xscale, Yscale;
// Fit to 80% of the page
Xscale = ( (SheetSize.x * 0.8) / BoardSize.x );
Yscale = ( (SheetSize.y * 0.8) / BoardSize.y );
scale = MIN( Xscale, Yscale );
}
else
scale = g_pcb_plot_options.Scale;
scale = g_pcb_plot_options.Scale;
// Calcul du cadrage (echelle != 1 donc recadrage du trace)
if( Center )
{
offset.x = BoardCenter.x-(SheetSize.x/2)/scale;
offset.y = BoardCenter.y-(SheetSize.y/2)/scale;
}
else
if( Center )
{
offset.x = BoardCenter.x - (SheetSize.x / 2) / scale;
offset.y = BoardCenter.y - (SheetSize.y / 2) / scale;
}
else
{
offset.x = 0;
offset.y = 0;
offset.x = 0;
offset.y = 0;
}
HPGL_Plotter *plotter = new HPGL_Plotter();
plotter->set_paper_size(currentsheet);
plotter->set_viewport(offset, scale,
g_pcb_plot_options.PlotOrient);
HPGL_Plotter* plotter = new HPGL_Plotter();
plotter->set_paper_size( currentsheet );
plotter->set_viewport( offset, scale,
g_pcb_plot_options.PlotOrient );
plotter->set_default_line_width( g_pcb_plot_options.PlotLine_Width );
plotter->set_creator(wxT("PCBNEW-HPGL"));
plotter->set_filename(FullFileName);
plotter->set_pen_speed(g_pcb_plot_options.HPGL_Pen_Speed);
plotter->set_pen_number(g_pcb_plot_options.HPGL_Pen_Num);
plotter->set_pen_overlap(pen_recouvrement);
plotter->set_pen_diameter(pen_diam);
plotter->start_plot(output_file);
plotter->set_creator( wxT( "PCBNEW-HPGL" ) );
plotter->set_filename( FullFileName );
plotter->set_pen_speed( g_pcb_plot_options.HPGL_Pen_Speed );
plotter->set_pen_number( g_pcb_plot_options.HPGL_Pen_Num );
plotter->set_pen_overlap( pen_recouvrement );
plotter->set_pen_diameter( pen_diam );
plotter->start_plot( output_file );
/* The worksheet is not significant with scale!=1... It is with
* paperscale!=1, anyway */
if( g_pcb_plot_options.Plot_Frame_Ref && !Center)
PlotWorkSheet( plotter, GetScreen() );
if( g_pcb_plot_options.Plot_Frame_Ref && !Center )
PlotWorkSheet( plotter, GetScreen() );
Plot_Layer(plotter, Layer, trace_mode);
Plot_Layer( plotter, Layer, trace_mode );
plotter->end_plot();
delete plotter;
SetLocaleTo_Default();
}
......@@ -13,27 +13,27 @@
#include "protos.h"
/****************************************************************************/
void WinEDA_BasePcbFrame::Genere_PS( const wxString& FullFileName, int Layer,
bool useA4, GRTraceMode trace_mode)
void WinEDA_BasePcbFrame::Genere_PS( const wxString& FullFileName, int Layer,
bool useA4, GRTraceMode trace_mode )
/****************************************************************************/
/* Genere un fichier POSTSCRIPT (*.ps) de trace du circuit, couche layer
* if layer < 0: all layers
*/
{
wxSize SheetSize;
wxSize SheetSize;
wxSize PaperSize;
wxSize BoardSize;
wxPoint BoardCenter;
bool Center = FALSE;
Ki_PageDescr* currentsheet = GetScreen()->m_CurrentSheetDesc;
double scale, paperscale;
double scale, paperscale;
Ki_PageDescr* SheetPS;
wxPoint offset;
wxPoint offset;
MsgPanel->EraseMsgBox();
FILE *output_file = wxFopen( FullFileName, wxT( "wt" ) );
FILE* output_file = wxFopen( FullFileName, wxT( "wt" ) );
if( output_file == NULL )
{
wxString msg = _( "Unable to create file " ) + FullFileName;
......@@ -49,7 +49,7 @@ void WinEDA_BasePcbFrame::Genere_PS( const wxString& FullFileName, int Layer,
// Set default line width
if( g_pcb_plot_options.PlotLine_Width < 1 )
g_pcb_plot_options.PlotLine_Width = 1;
g_pcb_plot_options.PlotLine_Width = 1;
// calcul en unites internes des dimensions des feuilles ( connues en 1/1000 pouce )
SheetSize.x = currentsheet->m_Size.x * U_PCB;
......@@ -57,16 +57,16 @@ void WinEDA_BasePcbFrame::Genere_PS( const wxString& FullFileName, int Layer,
if( useA4 )
{
SheetPS = &g_Sheet_A4;
PaperSize.x = g_Sheet_A4.m_Size.x * U_PCB;
PaperSize.y = g_Sheet_A4.m_Size.y * U_PCB;
paperscale = (float) PaperSize.x / SheetSize.x;
SheetPS = &g_Sheet_A4;
PaperSize.x = g_Sheet_A4.m_Size.x * U_PCB;
PaperSize.y = g_Sheet_A4.m_Size.y * U_PCB;
paperscale = (float) PaperSize.x / SheetSize.x;
}
else
{
SheetPS = currentsheet;
PaperSize = SheetSize;
paperscale = 1;
SheetPS = currentsheet;
PaperSize = SheetSize;
paperscale = 1;
}
/* calcul des dimensions et centre du PCB */
......@@ -76,62 +76,62 @@ void WinEDA_BasePcbFrame::Genere_PS( const wxString& FullFileName, int Layer,
if( g_pcb_plot_options.PlotScaleOpt == 0 ) // Optimum scale
{
double Xscale, Yscale;
// Fit to 80% of the page
Xscale = (PaperSize.x*0.8) / BoardSize.x;
Yscale = (PaperSize.y*0.8) / BoardSize.y;
scale = MIN( Xscale, Yscale );
double Xscale, Yscale;
// Fit to 80% of the page
Xscale = (PaperSize.x * 0.8) / BoardSize.x;
Yscale = (PaperSize.y * 0.8) / BoardSize.y;
scale = MIN( Xscale, Yscale );
}
else
scale = g_pcb_plot_options.Scale * paperscale;
scale = g_pcb_plot_options.Scale * paperscale;
// Calcul du cadrage (echelle != 1 donc recadrage du trace)
if( Center )
{
offset.x = BoardCenter.x-(PaperSize.x/2)/scale;
offset.y = BoardCenter.y-(PaperSize.y/2)/scale;
offset.x = BoardCenter.x - (PaperSize.x / 2) / scale;
offset.y = BoardCenter.y - (PaperSize.y / 2) / scale;
}
else
else
{
offset.x = 0;
offset.y = 0;
offset.x = 0;
offset.y = 0;
}
PS_Plotter *plotter = new PS_Plotter();
plotter->set_paper_size(SheetPS);
plotter->set_scale_adjust(g_pcb_plot_options.ScaleAdjX,
g_pcb_plot_options.ScaleAdjY);
plotter->set_viewport(offset, scale,
g_pcb_plot_options.PlotOrient);
PS_Plotter* plotter = new PS_Plotter();
plotter->set_paper_size( SheetPS );
plotter->set_scale_adjust( g_pcb_plot_options.ScaleAdjX,
g_pcb_plot_options.ScaleAdjY );
plotter->set_viewport( offset, scale,
g_pcb_plot_options.PlotOrient );
plotter->set_default_line_width( g_pcb_plot_options.PlotLine_Width );
plotter->set_creator(wxT("PCBNEW-PS"));
plotter->set_filename(FullFileName);
plotter->start_plot(output_file);
plotter->set_creator( wxT( "PCBNEW-PS" ) );
plotter->set_filename( FullFileName );
plotter->start_plot( output_file );
/* The worksheet is not significant with scale!=1... It is with
* paperscale!=1, anyway */
if( g_pcb_plot_options.Plot_Frame_Ref && !Center)
PlotWorkSheet( plotter, GetScreen() );
if( g_pcb_plot_options.Plot_Frame_Ref && !Center )
PlotWorkSheet( plotter, GetScreen() );
// If plot a negative board:
// Draw a black rectangle (background for plot board in white)
// and switch the current color to WHITE
if( g_pcb_plot_options.Plot_PS_Negative )
{
int margin = 500; // Add a 0.5 inch margin around the board
plotter->set_negative(true);
plotter->set_color( WHITE ); // Which will be plotted as black
plotter->rect(wxPoint(m_Pcb->m_BoundaryBox.GetX() - margin,
m_Pcb->m_BoundaryBox.GetY() - margin),
wxPoint(m_Pcb->m_BoundaryBox.GetRight() + margin,
m_Pcb->m_BoundaryBox.GetBottom() + margin),
FILLED_SHAPE);
plotter->set_color( BLACK );
int margin = 500; // Add a 0.5 inch margin around the board
plotter->set_negative( true );
plotter->set_color( WHITE ); // Which will be plotted as black
plotter->rect( wxPoint( m_Pcb->m_BoundaryBox.GetX() - margin,
m_Pcb->m_BoundaryBox.GetY() - margin ),
wxPoint( m_Pcb->m_BoundaryBox.GetRight() + margin,
m_Pcb->m_BoundaryBox.GetBottom() + margin ),
FILLED_SHAPE );
plotter->set_color( BLACK );
}
Plot_Layer(plotter, Layer, trace_mode);
Plot_Layer( plotter, Layer, trace_mode );
plotter->end_plot();
delete plotter;
SetLocaleTo_Default();
}
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