Commit fef83471 authored by Lorenzo Marcantonio's avatar Lorenzo Marcantonio

Script plotting patch

parent 79d55c04
...@@ -586,7 +586,7 @@ void EDA_3D_CANVAS::SetLights() ...@@ -586,7 +586,7 @@ void EDA_3D_CANVAS::SetLights()
*/ */
void EDA_3D_CANVAS::TakeScreenshot( wxCommandEvent& event ) void EDA_3D_CANVAS::TakeScreenshot( wxCommandEvent& event )
{ {
wxFileName fn( Parent()->Parent()->GetScreen()->GetFileName() ); wxFileName fn( Parent()->GetDefaultFileName() );
wxString FullFileName; wxString FullFileName;
wxString file_ext, mask; wxString file_ext, mask;
bool fmt_is_jpeg = false; bool fmt_is_jpeg = false;
...@@ -598,7 +598,7 @@ void EDA_3D_CANVAS::TakeScreenshot( wxCommandEvent& event ) ...@@ -598,7 +598,7 @@ void EDA_3D_CANVAS::TakeScreenshot( wxCommandEvent& event )
{ {
file_ext = fmt_is_jpeg ? wxT( "jpg" ) : wxT( "png" ); file_ext = fmt_is_jpeg ? wxT( "jpg" ) : wxT( "png" );
mask = wxT( "*." ) + file_ext; mask = wxT( "*." ) + file_ext;
FullFileName = Parent()->Parent()->GetScreen()->GetFileName(); FullFileName = Parent()->GetDefaultFileName();
fn.SetExt( file_ext ); fn.SetExt( file_ext );
FullFileName = EDA_FileSelector( _( "3D Image filename:" ), wxEmptyString, FullFileName = EDA_FileSelector( _( "3D Image filename:" ), wxEmptyString,
......
...@@ -187,6 +187,7 @@ private: ...@@ -187,6 +187,7 @@ private:
wxSize m_FrameSize; wxSize m_FrameSize;
wxAuiManager m_auimgr; wxAuiManager m_auimgr;
bool m_reloadRequest; bool m_reloadRequest;
wxString m_defaultFileName; /// Filename to propose for screenshot
public: public:
EDA_3D_FRAME( PCB_BASE_FRAME* parent, const wxString& title, EDA_3D_FRAME( PCB_BASE_FRAME* parent, const wxString& title,
...@@ -216,6 +217,8 @@ public: ...@@ -216,6 +217,8 @@ public:
*/ */
void NewDisplay(); void NewDisplay();
void SetDefaultFileName(const wxString &aFn) { m_defaultFileName = aFn; }
const wxString &GetDefaultFileName() const { return m_defaultFileName; }
private: private:
void Exit3DFrame( wxCommandEvent& event ); void Exit3DFrame( wxCommandEvent& event );
void OnCloseWindow( wxCloseEvent& Event ); void OnCloseWindow( wxCloseEvent& Event );
......
...@@ -29,15 +29,22 @@ void DXF_PLOTTER::SetViewport( const wxPoint& aOffset, double aIusPerDecimil, ...@@ -29,15 +29,22 @@ void DXF_PLOTTER::SetViewport( const wxPoint& aOffset, double aIusPerDecimil,
wxASSERT( !outputFile ); wxASSERT( !outputFile );
plotOffset = aOffset; plotOffset = aOffset;
plotScale = aScale; plotScale = aScale;
// XXX Need to think about this: what is the 'native' unit used for DXF?
/* DXF paper is 'virtual' so there is no need of a paper size.
Also this way we can handle the aux origin which can be useful
(for example when aligning to a mechanical drawing) */
paperSize.x = 0;
paperSize.y = 0;
/* Like paper size DXF units are abstract too. Anyway there is a
* system variable (MEASUREMENT) which will be set to 1 to indicate
* metric units */
m_IUsPerDecimil = aIusPerDecimil;
iuPerDeviceUnit = 1.0 / aIusPerDecimil; // Gives a DXF in decimils iuPerDeviceUnit = 1.0 / aIusPerDecimil; // Gives a DXF in decimils
iuPerDeviceUnit *= 0.00254; // DXF in mm (I like it best) iuPerDeviceUnit *= 0.00254; // ... now in mm
// Compute the paper size in IUs
paperSize = pageInfo.GetSizeMils(); SetDefaultLineWidth( 0 ); // No line width on DXF
paperSize.x *= 10.0 * aIusPerDecimil; plotMirror = false; // No mirroring on DXF
paperSize.y *= 10.0 * aIusPerDecimil;
SetDefaultLineWidth( 0 ); // No line width on DXF
plotMirror = false; // No mirroring on DXF
currentColor = BLACK; currentColor = BLACK;
} }
...@@ -63,8 +70,12 @@ bool DXF_PLOTTER::StartPlot( FILE* fout ) ...@@ -63,8 +70,12 @@ bool DXF_PLOTTER::StartPlot( FILE* fout )
" 9\n" " 9\n"
"$ANGDIR\n" "$ANGDIR\n"
" 70\n" " 70\n"
" 1\n"
" 9\n"
"$MEASUREMENT\n"
" 70\n"
"0\n" "0\n"
" 0\n" " 0\n" // This means 'metric units'
"ENDSEC\n" "ENDSEC\n"
" 0\n" " 0\n"
"SECTION\n" "SECTION\n"
......
...@@ -25,6 +25,7 @@ void GERBER_PLOTTER::SetViewport( const wxPoint& aOffset, double aIusPerDecimil, ...@@ -25,6 +25,7 @@ void GERBER_PLOTTER::SetViewport( const wxPoint& aOffset, double aIusPerDecimil,
plotOffset = aOffset; plotOffset = aOffset;
wxASSERT( aScale == 1 ); wxASSERT( aScale == 1 );
plotScale = 1; plotScale = 1;
m_IUsPerDecimil = aIusPerDecimil;
iuPerDeviceUnit = 1.0 / aIusPerDecimil; iuPerDeviceUnit = 1.0 / aIusPerDecimil;
/* We don't handle the filmbox, and it's more useful to keep the /* We don't handle the filmbox, and it's more useful to keep the
* origin at the origin */ * origin at the origin */
......
...@@ -26,6 +26,7 @@ void HPGL_PLOTTER::SetViewport( const wxPoint& aOffset, double aIusPerDecimil, ...@@ -26,6 +26,7 @@ void HPGL_PLOTTER::SetViewport( const wxPoint& aOffset, double aIusPerDecimil,
wxASSERT( !outputFile ); wxASSERT( !outputFile );
plotOffset = aOffset; plotOffset = aOffset;
plotScale = aScale; plotScale = aScale;
m_IUsPerDecimil = aIusPerDecimil;
iuPerDeviceUnit = PLUsPERDECIMIL / aIusPerDecimil; iuPerDeviceUnit = PLUsPERDECIMIL / aIusPerDecimil;
/* Compute the paper size in IUs */ /* Compute the paper size in IUs */
paperSize = pageInfo.GetSizeMils(); paperSize = pageInfo.GetSizeMils();
...@@ -161,7 +162,7 @@ void HPGL_PLOTTER::PenTo( const wxPoint& pos, char plume ) ...@@ -161,7 +162,7 @@ void HPGL_PLOTTER::PenTo( const wxPoint& pos, char plume )
DPOINT pos_dev = userToDeviceCoordinates( pos ); DPOINT pos_dev = userToDeviceCoordinates( pos );
if( penLastpos != pos ) if( penLastpos != pos )
fprintf( outputFile, "PA %.0f,%.0fd;\n", pos_dev.x, pos_dev.y ); fprintf( outputFile, "PA %.0f,%.0f;\n", pos_dev.x, pos_dev.y );
penLastpos = pos; penLastpos = pos;
} }
......
...@@ -52,6 +52,7 @@ void PDF_PLOTTER::SetViewport( const wxPoint& aOffset, double aIusPerDecimil, ...@@ -52,6 +52,7 @@ void PDF_PLOTTER::SetViewport( const wxPoint& aOffset, double aIusPerDecimil,
plotMirror = aMirror; plotMirror = aMirror;
plotOffset = aOffset; plotOffset = aOffset;
plotScale = aScale; plotScale = aScale;
m_IUsPerDecimil = aIusPerDecimil;
// The CTM is set to 1 user unit per decimil // The CTM is set to 1 user unit per decimil
iuPerDeviceUnit = 1.0 / aIusPerDecimil; iuPerDeviceUnit = 1.0 / aIusPerDecimil;
...@@ -425,10 +426,6 @@ int PDF_PLOTTER::startPdfStream(int handle) ...@@ -425,10 +426,6 @@ int PDF_PLOTTER::startPdfStream(int handle)
/** /**
* Finish the current PDF stream (writes the deferred length, too) * Finish the current PDF stream (writes the deferred length, too)
* XXX the compression code is not very elegant... is slurps the
* whole stream in RAM, allocates an output buffer of the same size
* and try to FLATE it. Asserts if it couldn't... enhancements are
* welcome but for now it simply works
*/ */
void PDF_PLOTTER::closePdfStream() void PDF_PLOTTER::closePdfStream()
{ {
...@@ -730,7 +727,7 @@ void PDF_PLOTTER::Text( const wxPoint& aPos, ...@@ -730,7 +727,7 @@ void PDF_PLOTTER::Text( const wxPoint& aPos,
bool aBold ) bool aBold )
{ {
// Emit native PDF text (if requested) // Emit native PDF text (if requested)
if( psTextMode != PSTEXTMODE_STROKE ) if( m_textMode != PLOTTEXTMODE_STROKE )
{ {
const char *fontname = aItalic ? (aBold ? "/KicadFontBI" : "/KicadFontI") const char *fontname = aItalic ? (aBold ? "/KicadFontBI" : "/KicadFontI")
: (aBold ? "/KicadFontB" : "/KicadFont"); : (aBold ? "/KicadFontB" : "/KicadFont");
...@@ -754,7 +751,7 @@ void PDF_PLOTTER::Text( const wxPoint& aPos, ...@@ -754,7 +751,7 @@ void PDF_PLOTTER::Text( const wxPoint& aPos,
fprintf( workFile, "q %f %f %f %f %g %g cm BT %s %g Tf %d Tr %g Tz ", fprintf( workFile, "q %f %f %f %f %g %g cm BT %s %g Tf %d Tr %g Tz ",
ctm_a, ctm_b, ctm_c, ctm_d, ctm_e, ctm_f, ctm_a, ctm_b, ctm_c, ctm_d, ctm_e, ctm_f,
fontname, heightFactor, fontname, heightFactor,
(psTextMode == PSTEXTMODE_NATIVE) ? 0 : 3, (m_textMode == PLOTTEXTMODE_NATIVE) ? 0 : 3,
wideningFactor * 100 ); wideningFactor * 100 );
// The text must be escaped correctly // The text must be escaped correctly
...@@ -763,7 +760,7 @@ void PDF_PLOTTER::Text( const wxPoint& aPos, ...@@ -763,7 +760,7 @@ void PDF_PLOTTER::Text( const wxPoint& aPos,
/* We are still in text coordinates, plot the overbars (if we're /* We are still in text coordinates, plot the overbars (if we're
* not doing phantom text) */ * not doing phantom text) */
if( psTextMode == PSTEXTMODE_NATIVE ) if( m_textMode == PLOTTEXTMODE_NATIVE )
{ {
std::vector<int> pos_pairs; std::vector<int> pos_pairs;
postscriptOverlinePositions( aText, aSize.x, aItalic, aBold, &pos_pairs ); postscriptOverlinePositions( aText, aSize.x, aItalic, aBold, &pos_pairs );
...@@ -786,7 +783,7 @@ void PDF_PLOTTER::Text( const wxPoint& aPos, ...@@ -786,7 +783,7 @@ void PDF_PLOTTER::Text( const wxPoint& aPos,
} }
// Plot the stroked text (if requested) // Plot the stroked text (if requested)
if( psTextMode != PSTEXTMODE_NATIVE ) if( m_textMode != PLOTTEXTMODE_NATIVE )
{ {
PLOTTER::Text( aPos, aColor, aText, aOrient, aSize, aH_justify, aV_justify, PLOTTER::Text( aPos, aColor, aText, aOrient, aSize, aH_justify, aV_justify,
aWidth, aItalic, aBold ); aWidth, aItalic, aBold );
......
...@@ -308,6 +308,7 @@ void PS_PLOTTER::SetViewport( const wxPoint& aOffset, double aIusPerDecimil, ...@@ -308,6 +308,7 @@ void PS_PLOTTER::SetViewport( const wxPoint& aOffset, double aIusPerDecimil,
plotMirror = aMirror; plotMirror = aMirror;
plotOffset = aOffset; plotOffset = aOffset;
plotScale = aScale; plotScale = aScale;
m_IUsPerDecimil = aIusPerDecimil;
iuPerDeviceUnit = 1.0 / aIusPerDecimil; iuPerDeviceUnit = 1.0 / aIusPerDecimil;
/* Compute the paper size in IUs */ /* Compute the paper size in IUs */
paperSize = pageInfo.GetSizeMils(); paperSize = pageInfo.GetSizeMils();
...@@ -818,7 +819,7 @@ void PS_PLOTTER::Text( const wxPoint& aPos, ...@@ -818,7 +819,7 @@ void PS_PLOTTER::Text( const wxPoint& aPos,
SetColor( aColor ); SetColor( aColor );
// Draw the native postscript text (if requested) // Draw the native postscript text (if requested)
if( psTextMode == PSTEXTMODE_NATIVE ) if( m_textMode == PLOTTEXTMODE_NATIVE )
{ {
const char *fontname = aItalic ? (aBold ? "/KicadFont-BoldOblique" const char *fontname = aItalic ? (aBold ? "/KicadFont-BoldOblique"
: "/KicadFont-Oblique") : "/KicadFont-Oblique")
...@@ -862,7 +863,7 @@ void PS_PLOTTER::Text( const wxPoint& aPos, ...@@ -862,7 +863,7 @@ void PS_PLOTTER::Text( const wxPoint& aPos,
} }
// Draw the hidden postscript text (if requested) // Draw the hidden postscript text (if requested)
if( psTextMode == PSTEXTMODE_PHANTOM ) if( m_textMode == PLOTTEXTMODE_PHANTOM )
{ {
fputsPostscriptString( outputFile, aText ); fputsPostscriptString( outputFile, aText );
DPOINT pos_dev = userToDeviceCoordinates( aPos ); DPOINT pos_dev = userToDeviceCoordinates( aPos );
...@@ -871,7 +872,7 @@ void PS_PLOTTER::Text( const wxPoint& aPos, ...@@ -871,7 +872,7 @@ void PS_PLOTTER::Text( const wxPoint& aPos,
} }
// Draw the stroked text (if requested) // Draw the stroked text (if requested)
if( psTextMode != PSTEXTMODE_NATIVE ) if( m_textMode != PLOTTEXTMODE_NATIVE )
{ {
PLOTTER::Text( aPos, aColor, aText, aOrient, aSize, aH_justify, aV_justify, PLOTTER::Text( aPos, aColor, aText, aOrient, aSize, aH_justify, aV_justify,
aWidth, aItalic, aBold ); aWidth, aItalic, aBold );
......
...@@ -16,23 +16,47 @@ ...@@ -16,23 +16,47 @@
#include <drawtxt.h> #include <drawtxt.h>
#include <class_title_block.h> #include <class_title_block.h>
/* Plot sheet references
* margin is in mils (1/1000 inch) wxString GetDefaultPlotExtension( PlotFormat aFormat )
*/
void EDA_DRAW_FRAME::PlotWorkSheet( PLOTTER* plotter, BASE_SCREEN* screen, int aLineWidth )
{ {
#define WSTEXTSIZE 50 // Text size in mils switch( aFormat )
{
case PLOT_FORMAT_DXF:
return DXF_PLOTTER::GetDefaultFileExtension();
case PLOT_FORMAT_POST:
return PS_PLOTTER::GetDefaultFileExtension();
case PLOT_FORMAT_PDF:
return PDF_PLOTTER::GetDefaultFileExtension();
case PLOT_FORMAT_HPGL:
return HPGL_PLOTTER::GetDefaultFileExtension();
const PAGE_INFO& pageInfo = GetPageSettings(); case PLOT_FORMAT_GERBER:
wxSize pageSize = pageInfo.GetSizeMils(); // mils return GERBER_PLOTTER::GetDefaultFileExtension();
int xg, yg;
wxPoint pos, ref; default:
EDA_COLOR_T color; wxASSERT( false );
return wxEmptyString;
}
}
// Paper is sized in mils. Here is a conversion factor to scale mils to internal units. /* Plot sheet references
int iusPerMil = screen->MilsToIuScalar(); * margin is in mils (1/1000 inch)
*/
void PlotWorkSheet( PLOTTER* plotter, const TITLE_BLOCK& aTitleBlock,
const PAGE_INFO& aPageInfo,
int aSheetNumber, int aNumberOfSheets,
const wxString &aSheetDesc,
const wxString &aFilename )
{
static const int WSTEXTSIZE = 50; // Text size in mils
int iusPerMil = plotter->GetIUsPerDecimil() * 10;
wxSize pageSize = aPageInfo.GetSizeMils(); // in mils
int xg, yg;
wxPoint pos, ref;
wxString msg; wxString msg;
wxSize text_size; wxSize text_size;
...@@ -42,22 +66,17 @@ void EDA_DRAW_FRAME::PlotWorkSheet( PLOTTER* plotter, BASE_SCREEN* screen, int a ...@@ -42,22 +66,17 @@ void EDA_DRAW_FRAME::PlotWorkSheet( PLOTTER* plotter, BASE_SCREEN* screen, int a
wxSize text_size1_5; wxSize text_size1_5;
#else #else
int UpperLimit = VARIABLE_BLOCK_START_POSITION; int UpperLimit = VARIABLE_BLOCK_START_POSITION;
bool bold = false;
#endif #endif
bool italic = false; plotter->SetColor( BLACK );
int thickness = aLineWidth; plotter->SetCurrentLineWidth( PLOTTER::DEFAULT_LINE_WIDTH );
color = BLACK;
plotter->SetColor( color );
plotter->SetCurrentLineWidth( thickness );
// Plot edge. // Plot edge.
ref.x = pageInfo.GetLeftMarginMils() * iusPerMil; ref.x = aPageInfo.GetLeftMarginMils() * iusPerMil;
ref.y = pageInfo.GetTopMarginMils() * iusPerMil; ref.y = aPageInfo.GetTopMarginMils() * iusPerMil;
xg = ( pageSize.x - pageInfo.GetRightMarginMils() ) * iusPerMil; xg = ( pageSize.x - aPageInfo.GetRightMarginMils() ) * iusPerMil;
yg = ( pageSize.y - pageInfo.GetBottomMarginMils() ) * iusPerMil; yg = ( pageSize.y - aPageInfo.GetBottomMarginMils() ) * iusPerMil;
#if defined(KICAD_GOST) #if defined(KICAD_GOST)
plotter->MoveTo( ref ); plotter->MoveTo( ref );
...@@ -105,12 +124,12 @@ void EDA_DRAW_FRAME::PlotWorkSheet( PLOTTER* plotter, BASE_SCREEN* screen, int a ...@@ -105,12 +124,12 @@ void EDA_DRAW_FRAME::PlotWorkSheet( PLOTTER* plotter, BASE_SCREEN* screen, int a
text_size.y = WSTEXTSIZE * iusPerMil; text_size.y = WSTEXTSIZE * iusPerMil;
// upper left corner in mils // upper left corner in mils
ref.x = pageInfo.GetLeftMarginMils(); ref.x = aPageInfo.GetLeftMarginMils();
ref.y = pageInfo.GetTopMarginMils(); ref.y = aPageInfo.GetTopMarginMils();
// lower right corner in mils // lower right corner in mils
xg = ( pageSize.x - pageInfo.GetRightMarginMils() ); xg = ( pageSize.x - aPageInfo.GetRightMarginMils() );
yg = ( pageSize.y - pageInfo.GetBottomMarginMils() ); yg = ( pageSize.y - aPageInfo.GetBottomMarginMils() );
#if defined(KICAD_GOST) #if defined(KICAD_GOST)
for( Ki_WorkSheetData* WsItem = &WS_Segm1_LU; for( Ki_WorkSheetData* WsItem = &WS_Segm1_LU;
...@@ -128,10 +147,10 @@ void EDA_DRAW_FRAME::PlotWorkSheet( PLOTTER* plotter, BASE_SCREEN* screen, int a ...@@ -128,10 +147,10 @@ void EDA_DRAW_FRAME::PlotWorkSheet( PLOTTER* plotter, BASE_SCREEN* screen, int a
case WS_PODPIS_LU: case WS_PODPIS_LU:
if( WsItem->m_Legende ) if( WsItem->m_Legende )
msg = WsItem->m_Legende; msg = WsItem->m_Legende;
plotter->Text( pos, color, plotter->Text( pos, BLACK,
msg, TEXT_ORIENT_VERT, text_size, msg, TEXT_ORIENT_VERT, text_size,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_BOTTOM, GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_BOTTOM,
thickness, italic, false ); PLOTTER::DEFAULT_LINE_WIDTH, false, false );
break; break;
case WS_SEGMENT_LU: case WS_SEGMENT_LU:
...@@ -183,10 +202,10 @@ void EDA_DRAW_FRAME::PlotWorkSheet( PLOTTER* plotter, BASE_SCREEN* screen, int a ...@@ -183,10 +202,10 @@ void EDA_DRAW_FRAME::PlotWorkSheet( PLOTTER* plotter, BASE_SCREEN* screen, int a
pos.x = ( ii - gxpas / 2 ) * iusPerMil; pos.x = ( ii - gxpas / 2 ) * iusPerMil;
pos.y = ( ref.y + GRID_REF_W / 2 ) * iusPerMil; pos.y = ( ref.y + GRID_REF_W / 2 ) * iusPerMil;
plotter->Text( pos, color, plotter->Text( pos, BLACK,
msg, TEXT_ORIENT_HORIZ, text_size, msg, TEXT_ORIENT_HORIZ, text_size,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER,
thickness, italic, false ); PLOTTER::DEFAULT_LINE_WIDTH, false, false );
if( ii < xg - PAS_REF / 2 ) if( ii < xg - PAS_REF / 2 )
{ {
...@@ -199,10 +218,10 @@ void EDA_DRAW_FRAME::PlotWorkSheet( PLOTTER* plotter, BASE_SCREEN* screen, int a ...@@ -199,10 +218,10 @@ void EDA_DRAW_FRAME::PlotWorkSheet( PLOTTER* plotter, BASE_SCREEN* screen, int a
} }
pos.x = ( ii - gxpas / 2 ) * iusPerMil; pos.x = ( ii - gxpas / 2 ) * iusPerMil;
pos.y = ( yg - GRID_REF_W / 2 ) * iusPerMil; pos.y = ( yg - GRID_REF_W / 2 ) * iusPerMil;
plotter->Text( pos, color, plotter->Text( pos, BLACK,
msg, TEXT_ORIENT_HORIZ, text_size, msg, TEXT_ORIENT_HORIZ, text_size,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER,
thickness, italic, false ); PLOTTER::DEFAULT_LINE_WIDTH, false, false );
} }
// Plot legend along the Y axis. // Plot legend along the Y axis.
...@@ -225,10 +244,10 @@ void EDA_DRAW_FRAME::PlotWorkSheet( PLOTTER* plotter, BASE_SCREEN* screen, int a ...@@ -225,10 +244,10 @@ void EDA_DRAW_FRAME::PlotWorkSheet( PLOTTER* plotter, BASE_SCREEN* screen, int a
} }
pos.x = ( ref.x + GRID_REF_W / 2 ) * iusPerMil; pos.x = ( ref.x + GRID_REF_W / 2 ) * iusPerMil;
pos.y = ( ii - gypas / 2 ) * iusPerMil; pos.y = ( ii - gypas / 2 ) * iusPerMil;
plotter->Text( pos, color, plotter->Text( pos, BLACK,
msg, TEXT_ORIENT_HORIZ, text_size, msg, TEXT_ORIENT_HORIZ, text_size,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER,
thickness, italic, false ); PLOTTER::DEFAULT_LINE_WIDTH, false, false );
if( ii < yg - PAS_REF / 2 ) if( ii < yg - PAS_REF / 2 )
{ {
...@@ -242,9 +261,9 @@ void EDA_DRAW_FRAME::PlotWorkSheet( PLOTTER* plotter, BASE_SCREEN* screen, int a ...@@ -242,9 +261,9 @@ void EDA_DRAW_FRAME::PlotWorkSheet( PLOTTER* plotter, BASE_SCREEN* screen, int a
pos.x = ( xg - GRID_REF_W / 2 ) * iusPerMil; pos.x = ( xg - GRID_REF_W / 2 ) * iusPerMil;
pos.y = ( ii - gypas / 2 ) * iusPerMil; pos.y = ( ii - gypas / 2 ) * iusPerMil;
plotter->Text( pos, color, msg, TEXT_ORIENT_HORIZ, text_size, plotter->Text( pos, BLACK, msg, TEXT_ORIENT_HORIZ, text_size,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER,
thickness, italic, false ); PLOTTER::DEFAULT_LINE_WIDTH, false, false );
} }
#endif #endif
...@@ -261,10 +280,10 @@ void EDA_DRAW_FRAME::PlotWorkSheet( PLOTTER* plotter, BASE_SCREEN* screen, int a ...@@ -261,10 +280,10 @@ void EDA_DRAW_FRAME::PlotWorkSheet( PLOTTER* plotter, BASE_SCREEN* screen, int a
text_size1_5.x = SIZETEXT * iusPerMil * 1.5; text_size1_5.x = SIZETEXT * iusPerMil * 1.5;
text_size1_5.y = SIZETEXT * iusPerMil * 1.5; text_size1_5.y = SIZETEXT * iusPerMil * 1.5;
ref.x = pageSize.x - pageInfo.GetRightMarginMils(); ref.x = pageSize.x - aPageInfo.GetRightMarginMils();
ref.y = pageSize.y - pageInfo.GetBottomMarginMils(); ref.y = pageSize.y - aPageInfo.GetBottomMarginMils();
if( screen->m_ScreenNumber == 1 ) if( aSheetNumber == 1 )
{ {
for( Ki_WorkSheetData* WsItem = &WS_Date; for( Ki_WorkSheetData* WsItem = &WS_Date;
WsItem != NULL; WsItem != NULL;
...@@ -288,10 +307,10 @@ void EDA_DRAW_FRAME::PlotWorkSheet( PLOTTER* plotter, BASE_SCREEN* screen, int a ...@@ -288,10 +307,10 @@ void EDA_DRAW_FRAME::PlotWorkSheet( PLOTTER* plotter, BASE_SCREEN* screen, int a
case WS_PODPIS: case WS_PODPIS:
if( WsItem->m_Legende ) if( WsItem->m_Legende )
msg = WsItem->m_Legende; msg = WsItem->m_Legende;
plotter->Text( pos, color, plotter->Text( pos, BLACK,
msg, TEXT_ORIENT_HORIZ, text_size, msg, TEXT_ORIENT_HORIZ, text_size,
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER,
thickness, italic, false ); PLOTTER::DEFAULT_LINE_WIDTH, false, false );
break; break;
case WS_SIZESHEET: case WS_SIZESHEET:
...@@ -300,93 +319,93 @@ void EDA_DRAW_FRAME::PlotWorkSheet( PLOTTER* plotter, BASE_SCREEN* screen, int a ...@@ -300,93 +319,93 @@ void EDA_DRAW_FRAME::PlotWorkSheet( PLOTTER* plotter, BASE_SCREEN* screen, int a
case WS_IDENTSHEET: case WS_IDENTSHEET:
if( WsItem->m_Legende ) if( WsItem->m_Legende )
msg = WsItem->m_Legende; msg = WsItem->m_Legende;
if( screen->m_NumberOfScreens > 1 ) if( aNumberOfSheets > 1 )
msg << screen->m_ScreenNumber; msg << aSheetNumber;
plotter->Text( pos, color, plotter->Text( pos, BLACK,
msg, TEXT_ORIENT_HORIZ, text_size, msg, TEXT_ORIENT_HORIZ, text_size,
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER,
thickness, italic, false ); PLOTTER::DEFAULT_LINE_WIDTH, false, false );
break; break;
case WS_SHEETS: case WS_SHEETS:
if( WsItem->m_Legende ) if( WsItem->m_Legende )
msg = WsItem->m_Legende; msg = WsItem->m_Legende;
msg << screen->m_NumberOfScreens; msg << aNumberOfSheets;
plotter->Text( pos, color, plotter->Text( pos, BLACK,
msg, TEXT_ORIENT_HORIZ, text_size, msg, TEXT_ORIENT_HORIZ, text_size,
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER,
thickness, italic, false ); PLOTTER::DEFAULT_LINE_WIDTH, false, false );
break; break;
case WS_COMPANY_NAME: case WS_COMPANY_NAME:
msg = GetTitleBlock().GetCompany(); msg = aTitleBlock.GetCompany();
if( !msg.IsEmpty() ) if( !msg.IsEmpty() )
{ {
plotter->Text( pos, color, plotter->Text( pos, BLACK,
msg, TEXT_ORIENT_HORIZ, text_size1_5, msg, TEXT_ORIENT_HORIZ, text_size1_5,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER,
thickness, italic, false ); PLOTTER::DEFAULT_LINE_WIDTH, false, false );
} }
break; break;
case WS_TITLE: case WS_TITLE:
msg = GetTitleBlock().GetTitle(); msg = aTitleBlock.GetTitle();
if( !msg.IsEmpty() ) if( !msg.IsEmpty() )
{ {
plotter->Text( pos, color, plotter->Text( pos, BLACK,
msg, TEXT_ORIENT_HORIZ, text_size1_5, msg, TEXT_ORIENT_HORIZ, text_size1_5,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER,
thickness, italic, false ); PLOTTER::DEFAULT_LINE_WIDTH, false, false );
} }
break; break;
case WS_COMMENT1: case WS_COMMENT1:
msg = GetTitleBlock().GetComment1(); msg = aTitleBlock.GetComment1();
if( !msg.IsEmpty() ) if( !msg.IsEmpty() )
{ {
plotter->Text( pos, color, plotter->Text( pos, BLACK,
msg, TEXT_ORIENT_HORIZ, text_size3, msg, TEXT_ORIENT_HORIZ, text_size3,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER,
thickness, italic, false ); PLOTTER::DEFAULT_LINE_WIDTH, false, false );
pos.x = (pageInfo.GetLeftMarginMils() + 1260) * iusPerMil; pos.x = (aPageInfo.GetLeftMarginMils() + 1260) * iusPerMil;
pos.y = (pageInfo.GetTopMarginMils() + 270) * iusPerMil; pos.y = (aPageInfo.GetTopMarginMils() + 270) * iusPerMil;
plotter->Text( pos, color, plotter->Text( pos, BLACK,
msg.GetData(), 1800, text_size2, msg.GetData(), 1800, text_size2,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER,
thickness, italic, false ); PLOTTER::DEFAULT_LINE_WIDTH, false, false );
} }
break; break;
case WS_COMMENT2: case WS_COMMENT2:
msg = GetTitleBlock().GetComment2(); msg = aTitleBlock.GetComment2();
if( !msg.IsEmpty() ) if( !msg.IsEmpty() )
{ {
plotter->Text( pos, color, plotter->Text( pos, BLACK,
msg, TEXT_ORIENT_HORIZ, text_size, msg, TEXT_ORIENT_HORIZ, text_size,
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER,
thickness, italic, false ); PLOTTER::DEFAULT_LINE_WIDTH, false, false );
} }
break; break;
case WS_COMMENT3: case WS_COMMENT3:
msg = GetTitleBlock().GetComment3(); msg = aTitleBlock.GetComment3();
if( !msg.IsEmpty() ) if( !msg.IsEmpty() )
{ {
plotter->Text( pos, color, plotter->Text( pos, BLACK,
msg, TEXT_ORIENT_HORIZ, text_size, msg, TEXT_ORIENT_HORIZ, text_size,
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER,
thickness, italic, false ); PLOTTER::DEFAULT_LINE_WIDTH, false, false );
} }
break; break;
case WS_COMMENT4: case WS_COMMENT4:
msg = GetTitleBlock().GetComment4(); msg = aTitleBlock.GetComment4();
if( !msg.IsEmpty() ) if( !msg.IsEmpty() )
{ {
plotter->Text( pos, color, plotter->Text( pos, BLACK,
msg, TEXT_ORIENT_HORIZ, text_size, msg, TEXT_ORIENT_HORIZ, text_size,
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER,
thickness, italic, false ); PLOTTER::DEFAULT_LINE_WIDTH, false, false );
} }
break; break;
...@@ -415,37 +434,37 @@ void EDA_DRAW_FRAME::PlotWorkSheet( PLOTTER* plotter, BASE_SCREEN* screen, int a ...@@ -415,37 +434,37 @@ void EDA_DRAW_FRAME::PlotWorkSheet( PLOTTER* plotter, BASE_SCREEN* screen, int a
{ {
case WS_CADRE: case WS_CADRE:
// Begin list number > 1 // Begin list number > 1
msg = GetTitleBlock().GetComment1(); msg = aTitleBlock.GetComment1();
if( !msg.IsEmpty() ) if( !msg.IsEmpty() )
{ {
plotter->Text( pos, color, plotter->Text( pos, BLACK,
msg, TEXT_ORIENT_HORIZ, text_size3, msg, TEXT_ORIENT_HORIZ, text_size3,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER,
thickness, italic, false ); PLOTTER::DEFAULT_LINE_WIDTH, false, false );
pos.x = (pageInfo.GetLeftMarginMils() + 1260) * iusPerMil; pos.x = (aPageInfo.GetLeftMarginMils() + 1260) * iusPerMil;
pos.y = (pageInfo.GetTopMarginMils() + 270) * iusPerMil; pos.y = (aPageInfo.GetTopMarginMils() + 270) * iusPerMil;
plotter->Text( pos, color, plotter->Text( pos, BLACK,
msg, 1800, text_size2, msg, 1800, text_size2,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER,
thickness, italic, false ); PLOTTER::DEFAULT_LINE_WIDTH, false, false );
} }
break; break;
case WS_PODPIS_D: case WS_PODPIS_D:
if( WsItem->m_Legende ) if( WsItem->m_Legende )
msg = WsItem->m_Legende; msg = WsItem->m_Legende;
plotter->Text( pos, color, msg, TEXT_ORIENT_HORIZ, text_size, plotter->Text( pos, BLACK, msg, TEXT_ORIENT_HORIZ, text_size,
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER,
thickness, italic, false ); PLOTTER::DEFAULT_LINE_WIDTH, false, false );
break; break;
case WS_IDENTSHEET_D: case WS_IDENTSHEET_D:
if( WsItem->m_Legende ) if( WsItem->m_Legende )
msg = WsItem->m_Legende; msg = WsItem->m_Legende;
msg << screen->m_ScreenNumber; msg << aSheetNumber;
plotter->Text( pos, color, msg, TEXT_ORIENT_HORIZ, text_size, plotter->Text( pos, BLACK, msg, TEXT_ORIENT_HORIZ, text_size,
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER,
thickness, italic, false ); PLOTTER::DEFAULT_LINE_WIDTH, false, false );
break; break;
case WS_LEFT_SEGMENT_D: case WS_LEFT_SEGMENT_D:
...@@ -461,16 +480,17 @@ void EDA_DRAW_FRAME::PlotWorkSheet( PLOTTER* plotter, BASE_SCREEN* screen, int a ...@@ -461,16 +480,17 @@ void EDA_DRAW_FRAME::PlotWorkSheet( PLOTTER* plotter, BASE_SCREEN* screen, int a
#else #else
ref.x = pageSize.x - GRID_REF_W - pageInfo.GetRightMarginMils(); ref.x = pageSize.x - GRID_REF_W - aPageInfo.GetRightMarginMils();
ref.y = pageSize.y - GRID_REF_W - pageInfo.GetBottomMarginMils(); ref.y = pageSize.y - GRID_REF_W - aPageInfo.GetBottomMarginMils();
for( Ki_WorkSheetData* WsItem = &WS_Date; for( Ki_WorkSheetData* WsItem = &WS_Date;
WsItem != NULL; WsItem != NULL;
WsItem = WsItem->Pnext ) WsItem = WsItem->Pnext )
{ {
bool bold = false;
pos.x = ( ref.x - WsItem->m_Posx ) * iusPerMil; pos.x = ( ref.x - WsItem->m_Posx ) * iusPerMil;
pos.y = ( ref.y - WsItem->m_Posy ) * iusPerMil; pos.y = ( ref.y - WsItem->m_Posy ) * iusPerMil;
bold = false;
if( WsItem->m_Legende ) if( WsItem->m_Legende )
msg = WsItem->m_Legende; msg = WsItem->m_Legende;
else else
...@@ -479,12 +499,12 @@ void EDA_DRAW_FRAME::PlotWorkSheet( PLOTTER* plotter, BASE_SCREEN* screen, int a ...@@ -479,12 +499,12 @@ void EDA_DRAW_FRAME::PlotWorkSheet( PLOTTER* plotter, BASE_SCREEN* screen, int a
switch( WsItem->m_Type ) switch( WsItem->m_Type )
{ {
case WS_DATE: case WS_DATE:
msg += GetTitleBlock().GetDate(); msg += aTitleBlock.GetDate();
bold = true; bold = true;
break; break;
case WS_REV: case WS_REV:
msg += GetTitleBlock().GetRevision(); msg += aTitleBlock.GetRevision();
bold = true; bold = true;
break; break;
...@@ -493,61 +513,57 @@ void EDA_DRAW_FRAME::PlotWorkSheet( PLOTTER* plotter, BASE_SCREEN* screen, int a ...@@ -493,61 +513,57 @@ void EDA_DRAW_FRAME::PlotWorkSheet( PLOTTER* plotter, BASE_SCREEN* screen, int a
break; break;
case WS_SIZESHEET: case WS_SIZESHEET:
msg += pageInfo.GetType(); msg += aPageInfo.GetType();
break; break;
case WS_IDENTSHEET: case WS_IDENTSHEET:
msg << screen->m_ScreenNumber << wxT( "/" ) << msg << aSheetNumber << wxT( "/" ) << aNumberOfSheets;
screen->m_NumberOfScreens;
break; break;
case WS_FILENAME: case WS_FILENAME:
{ {
wxString fname, fext; wxString fname, fext;
wxFileName::SplitPath( screen->GetFileName(), wxFileName::SplitPath( aFilename, NULL, &fname, &fext );
(wxString*) NULL,
&fname,
&fext );
msg << fname << wxT( "." ) << fext; msg << fname << wxT( "." ) << fext;
} }
break; break;
case WS_FULLSHEETNAME: case WS_FULLSHEETNAME:
msg += GetScreenDesc(); msg += aSheetDesc;
break; break;
case WS_COMPANY_NAME: case WS_COMPANY_NAME:
msg += GetTitleBlock().GetCompany(); msg += aTitleBlock.GetCompany();
if( !msg.IsEmpty() ) if( !msg.IsEmpty() )
UpperLimit = MAX( UpperLimit, WsItem->m_Posy + SIZETEXT ); UpperLimit = MAX( UpperLimit, WsItem->m_Posy + SIZETEXT );
bold = true; bold = true;
break; break;
case WS_TITLE: case WS_TITLE:
msg += GetTitleBlock().GetTitle(); msg += aTitleBlock.GetTitle();
bold = true; bold = true;
break; break;
case WS_COMMENT1: case WS_COMMENT1:
msg += GetTitleBlock().GetComment1(); msg += aTitleBlock.GetComment1();
if( !msg.IsEmpty() ) if( !msg.IsEmpty() )
UpperLimit = MAX( UpperLimit, WsItem->m_Posy + SIZETEXT ); UpperLimit = MAX( UpperLimit, WsItem->m_Posy + SIZETEXT );
break; break;
case WS_COMMENT2: case WS_COMMENT2:
msg += GetTitleBlock().GetComment2(); msg += aTitleBlock.GetComment2();
if( !msg.IsEmpty() ) if( !msg.IsEmpty() )
UpperLimit = MAX( UpperLimit, WsItem->m_Posy + SIZETEXT ); UpperLimit = MAX( UpperLimit, WsItem->m_Posy + SIZETEXT );
break; break;
case WS_COMMENT3: case WS_COMMENT3:
msg += GetTitleBlock().GetComment3(); msg += aTitleBlock.GetComment3();
if( !msg.IsEmpty() ) if( !msg.IsEmpty() )
UpperLimit = MAX( UpperLimit, WsItem->m_Posy + SIZETEXT ); UpperLimit = MAX( UpperLimit, WsItem->m_Posy + SIZETEXT );
break; break;
case WS_COMMENT4: case WS_COMMENT4:
msg += GetTitleBlock().GetComment4(); msg += aTitleBlock.GetComment4();
if( !msg.IsEmpty() ) if( !msg.IsEmpty() )
UpperLimit = MAX( UpperLimit, WsItem->m_Posy + SIZETEXT ); UpperLimit = MAX( UpperLimit, WsItem->m_Posy + SIZETEXT );
break; break;
...@@ -574,10 +590,10 @@ void EDA_DRAW_FRAME::PlotWorkSheet( PLOTTER* plotter, BASE_SCREEN* screen, int a ...@@ -574,10 +590,10 @@ void EDA_DRAW_FRAME::PlotWorkSheet( PLOTTER* plotter, BASE_SCREEN* screen, int a
if( !msg.IsEmpty() ) if( !msg.IsEmpty() )
{ {
plotter->Text( pos, color, plotter->Text( pos, BLACK,
msg, TEXT_ORIENT_HORIZ, text_size, msg, TEXT_ORIENT_HORIZ, text_size,
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER,
thickness, italic, bold ); PLOTTER::DEFAULT_LINE_WIDTH, bold, false );
} }
} }
......
...@@ -1004,7 +1004,7 @@ Ki_WorkSheetData WS_Segm5_LT = ...@@ -1004,7 +1004,7 @@ Ki_WorkSheetData WS_Segm5_LT =
void EDA_DRAW_FRAME::TraceWorkSheet( wxDC* aDC, BASE_SCREEN* aScreen, int aLineWidth, void EDA_DRAW_FRAME::TraceWorkSheet( wxDC* aDC, BASE_SCREEN* aScreen, int aLineWidth,
double aScalar ) double aScalar, const wxString &aFilename )
{ {
if( !m_showBorderAndTitleBlock ) if( !m_showBorderAndTitleBlock )
return; return;
...@@ -1024,7 +1024,7 @@ void EDA_DRAW_FRAME::TraceWorkSheet( wxDC* aDC, BASE_SCREEN* aScreen, int aLineW ...@@ -1024,7 +1024,7 @@ void EDA_DRAW_FRAME::TraceWorkSheet( wxDC* aDC, BASE_SCREEN* aScreen, int aLineW
wxPoint margin_left_top( pageInfo.GetLeftMarginMils(), pageInfo.GetTopMarginMils() ); wxPoint margin_left_top( pageInfo.GetLeftMarginMils(), pageInfo.GetTopMarginMils() );
wxPoint margin_right_bottom( pageInfo.GetRightMarginMils(), pageInfo.GetBottomMarginMils() ); wxPoint margin_right_bottom( pageInfo.GetRightMarginMils(), pageInfo.GetBottomMarginMils() );
wxString paper = pageInfo.GetType(); wxString paper = pageInfo.GetType();
wxString file = aScreen->GetFileName(); wxString file = aFilename;
TITLE_BLOCK t_block = GetTitleBlock(); TITLE_BLOCK t_block = GetTitleBlock();
int number_of_screens = aScreen->m_NumberOfScreens; int number_of_screens = aScreen->m_NumberOfScreens;
int screen_to_draw = aScreen->m_ScreenNumber; int screen_to_draw = aScreen->m_ScreenNumber;
......
...@@ -237,7 +237,8 @@ bool DIALOG_SVG_PRINT::DrawSVGPage( EDA_DRAW_FRAME* frame, ...@@ -237,7 +237,8 @@ bool DIALOG_SVG_PRINT::DrawSVGPage( EDA_DRAW_FRAME* frame,
sheetSize.y/2) ); sheetSize.y/2) );
if( aPrint_Sheet_Ref ) if( aPrint_Sheet_Ref )
frame->TraceWorkSheet( &dc, screen, g_DrawDefaultLineThickness, IU_PER_MILS ); frame->TraceWorkSheet( &dc, screen, g_DrawDefaultLineThickness,
IU_PER_MILS, frame->GetScreenDesc() );
screen->m_IsPrinting = false; screen->m_IsPrinting = false;
panel->SetClipBox( tmp ); panel->SetClipBox( tmp );
......
...@@ -188,7 +188,8 @@ void DIALOG_PLOT_SCHEMATIC_DXF::CreateDXFFile( ) ...@@ -188,7 +188,8 @@ void DIALOG_PLOT_SCHEMATIC_DXF::CreateDXFFile( )
plot_offset.x = 0; plot_offset.x = 0;
plot_offset.y = 0; plot_offset.y = 0;
plotFileName = schframe->GetUniqueFilenameForCurrentSheet() + wxT( ".dxf" ); plotFileName = schframe->GetUniqueFilenameForCurrentSheet() + '.'
+ DXF_PLOTTER::GetDefaultFileExtension();
PlotOneSheetDXF( plotFileName, screen, plot_offset, 1 ); PlotOneSheetDXF( plotFileName, screen, plot_offset, 1 );
...@@ -229,9 +230,8 @@ void DIALOG_PLOT_SCHEMATIC_DXF::PlotOneSheetDXF( const wxString& FileName, ...@@ -229,9 +230,8 @@ void DIALOG_PLOT_SCHEMATIC_DXF::PlotOneSheetDXF( const wxString& FileName,
const PAGE_INFO& pageInfo = screen->GetPageSettings(); const PAGE_INFO& pageInfo = screen->GetPageSettings();
plotter->SetPageSettings( pageInfo ); plotter->SetPageSettings( pageInfo );
plotter->SetViewport( plot_offset, IU_PER_DECIMILS, scale, 0 );
plotter->SetColorMode( m_plotColorOpt ); plotter->SetColorMode( m_plotColorOpt );
plotter->SetViewport( plot_offset, IU_PER_DECIMILS, scale, false );
// Init : // Init :
plotter->SetCreator( wxT( "Eeschema-DXF" ) ); plotter->SetCreator( wxT( "Eeschema-DXF" ) );
...@@ -241,7 +241,11 @@ void DIALOG_PLOT_SCHEMATIC_DXF::PlotOneSheetDXF( const wxString& FileName, ...@@ -241,7 +241,11 @@ void DIALOG_PLOT_SCHEMATIC_DXF::PlotOneSheetDXF( const wxString& FileName,
if( m_plot_Sheet_Ref ) if( m_plot_Sheet_Ref )
{ {
plotter->SetColor( BLACK ); plotter->SetColor( BLACK );
m_Parent->PlotWorkSheet( plotter, screen, g_DrawDefaultLineThickness ); PlotWorkSheet( plotter, m_Parent->GetTitleBlock(),
m_Parent->GetPageSettings(),
screen->m_ScreenNumber, screen->m_NumberOfScreens,
m_Parent->GetScreenDesc(),
screen->GetFileName() );
} }
screen->Plot( plotter ); screen->Plot( plotter );
......
...@@ -336,7 +336,8 @@ void DIALOG_PLOT_SCHEMATIC_HPGL::Plot_Schematic_HPGL( bool aPlotAll ) ...@@ -336,7 +336,8 @@ void DIALOG_PLOT_SCHEMATIC_HPGL::Plot_Schematic_HPGL( bool aPlotAll )
plotOffset.x = -s_Offset.x; plotOffset.x = -s_Offset.x;
plotOffset.y = -s_Offset.y; plotOffset.y = -s_Offset.y;
plotFileName = m_Parent->GetUniqueFilenameForCurrentSheet() + wxT( ".plt" ); plotFileName = m_Parent->GetUniqueFilenameForCurrentSheet() + '.'
+ HPGL_PLOTTER::GetDefaultFileExtension();
LOCALE_IO toggle; LOCALE_IO toggle;
...@@ -379,9 +380,7 @@ void DIALOG_PLOT_SCHEMATIC_HPGL::Plot_1_Page_HPGL( const wxString& FileName, ...@@ -379,9 +380,7 @@ void DIALOG_PLOT_SCHEMATIC_HPGL::Plot_1_Page_HPGL( const wxString& FileName,
HPGL_PLOTTER* plotter = new HPGL_PLOTTER(); HPGL_PLOTTER* plotter = new HPGL_PLOTTER();
plotter->SetPageSettings( pageInfo ); plotter->SetPageSettings( pageInfo );
plotter->SetViewport( offset, IU_PER_DECIMILS, plot_scale, false );
plotter->SetViewport( offset, IU_PER_DECIMILS, plot_scale, 0 );
plotter->SetDefaultLineWidth( g_DrawDefaultLineThickness );
// Init : // Init :
plotter->SetCreator( wxT( "Eeschema-HPGL" ) ); plotter->SetCreator( wxT( "Eeschema-HPGL" ) );
...@@ -395,7 +394,11 @@ void DIALOG_PLOT_SCHEMATIC_HPGL::Plot_1_Page_HPGL( const wxString& FileName, ...@@ -395,7 +394,11 @@ void DIALOG_PLOT_SCHEMATIC_HPGL::Plot_1_Page_HPGL( const wxString& FileName,
plotter->SetColor( BLACK ); plotter->SetColor( BLACK );
if( s_plot_Sheet_Ref ) if( s_plot_Sheet_Ref )
m_Parent->PlotWorkSheet( plotter, screen, g_DrawDefaultLineThickness ); PlotWorkSheet( plotter, m_Parent->GetTitleBlock(),
m_Parent->GetPageSettings(),
screen->m_ScreenNumber, screen->m_NumberOfScreens,
m_Parent->GetScreenDesc(),
screen->GetFileName() );
screen->Plot( plotter ); screen->Plot( plotter );
......
...@@ -193,8 +193,6 @@ void DIALOG_PLOT_SCHEMATIC_PDF::createPDFFile() ...@@ -193,8 +193,6 @@ void DIALOG_PLOT_SCHEMATIC_PDF::createPDFFile()
plotter->SetDefaultLineWidth( g_DrawDefaultLineThickness ); plotter->SetDefaultLineWidth( g_DrawDefaultLineThickness );
plotter->SetColorMode( m_plotColorOpt ); plotter->SetColorMode( m_plotColorOpt );
plotter->SetCreator( wxT( "Eeschema-PDF" ) ); plotter->SetCreator( wxT( "Eeschema-PDF" ) );
plotter->SetPsTextMode( PSTEXTMODE_PHANTOM );
// First page handling is different // First page handling is different
bool first_page = true; bool first_page = true;
...@@ -220,8 +218,8 @@ void DIALOG_PLOT_SCHEMATIC_PDF::createPDFFile() ...@@ -220,8 +218,8 @@ void DIALOG_PLOT_SCHEMATIC_PDF::createPDFFile()
if( first_page ) { if( first_page ) {
wxString msg; wxString msg;
wxString plotFileName = m_Parent->GetUniqueFilenameForCurrentSheet() wxString plotFileName = m_Parent->GetUniqueFilenameForCurrentSheet() + '.'
+ wxT( ".pdf" ); + PDF_PLOTTER::GetDefaultFileExtension();
msg.Printf( _( "Plot: %s " ), GetChars( plotFileName ) ); msg.Printf( _( "Plot: %s " ), GetChars( plotFileName ) );
m_MsgBox->AppendText( msg ); m_MsgBox->AppendText( msg );
...@@ -291,8 +289,8 @@ void DIALOG_PLOT_SCHEMATIC_PDF::plotSetupPage( PDF_PLOTTER* plotter, ...@@ -291,8 +289,8 @@ void DIALOG_PLOT_SCHEMATIC_PDF::plotSetupPage( PDF_PLOTTER* plotter,
double scalex = (double) plotPage.GetWidthMils() / actualPage.GetWidthMils(); double scalex = (double) plotPage.GetWidthMils() / actualPage.GetWidthMils();
double scaley = (double) plotPage.GetHeightMils() / actualPage.GetHeightMils(); double scaley = (double) plotPage.GetHeightMils() / actualPage.GetHeightMils();
double scale = MIN( scalex, scaley ); double scale = MIN( scalex, scaley );
plotter->SetViewport( wxPoint( 0, 0 ), IU_PER_DECIMILS, scale, 0 );
plotter->SetPageSettings( plotPage ); plotter->SetPageSettings( plotPage );
plotter->SetViewport( wxPoint( 0, 0 ), IU_PER_DECIMILS, scale, false );
} }
void DIALOG_PLOT_SCHEMATIC_PDF::plotOneSheet( PDF_PLOTTER* plotter, void DIALOG_PLOT_SCHEMATIC_PDF::plotOneSheet( PDF_PLOTTER* plotter,
...@@ -300,8 +298,12 @@ void DIALOG_PLOT_SCHEMATIC_PDF::plotOneSheet( PDF_PLOTTER* plotter, ...@@ -300,8 +298,12 @@ void DIALOG_PLOT_SCHEMATIC_PDF::plotOneSheet( PDF_PLOTTER* plotter,
{ {
if( m_plot_Sheet_Ref ) if( m_plot_Sheet_Ref )
{ {
plotter->SetColor( BLACK ); plotter->SetColor( BLACK );
m_Parent->PlotWorkSheet( plotter, screen, g_DrawDefaultLineThickness ); PlotWorkSheet( plotter, m_Parent->GetTitleBlock(),
m_Parent->GetPageSettings(),
screen->m_ScreenNumber, screen->m_NumberOfScreens,
m_Parent->GetScreenDesc(),
screen->GetFileName() );
} }
screen->Plot( plotter ); screen->Plot( plotter );
......
...@@ -242,7 +242,8 @@ void DIALOG_PLOT_SCHEMATIC_PS::createPSFile() ...@@ -242,7 +242,8 @@ void DIALOG_PLOT_SCHEMATIC_PS::createPSFile()
plot_offset.x = 0; plot_offset.x = 0;
plot_offset.y = 0; plot_offset.y = 0;
plotFileName = m_Parent->GetUniqueFilenameForCurrentSheet() + wxT( ".ps" ); plotFileName = m_Parent->GetUniqueFilenameForCurrentSheet() + '.'
+ PS_PLOTTER::GetDefaultFileExtension();
plotOneSheetPS( plotFileName, screen, plotPage, plot_offset, scale ); plotOneSheetPS( plotFileName, screen, plotPage, plot_offset, scale );
...@@ -281,10 +282,9 @@ void DIALOG_PLOT_SCHEMATIC_PS::plotOneSheetPS( const wxString& FileName, ...@@ -281,10 +282,9 @@ void DIALOG_PLOT_SCHEMATIC_PS::plotOneSheetPS( const wxString& FileName,
PS_PLOTTER* plotter = new PS_PLOTTER(); PS_PLOTTER* plotter = new PS_PLOTTER();
plotter->SetPageSettings( pageInfo ); plotter->SetPageSettings( pageInfo );
plotter->SetViewport( plot_offset, IU_PER_DECIMILS, scale, 0 );
plotter->SetDefaultLineWidth( g_DrawDefaultLineThickness ); plotter->SetDefaultLineWidth( g_DrawDefaultLineThickness );
plotter->SetColorMode( m_plotColorOpt ); plotter->SetColorMode( m_plotColorOpt );
plotter->SetPsTextMode( PSTEXTMODE_STROKE ); plotter->SetViewport( plot_offset, IU_PER_DECIMILS, scale, false );
// Init : // Init :
plotter->SetCreator( wxT( "Eeschema-PS" ) ); plotter->SetCreator( wxT( "Eeschema-PS" ) );
...@@ -294,7 +294,11 @@ void DIALOG_PLOT_SCHEMATIC_PS::plotOneSheetPS( const wxString& FileName, ...@@ -294,7 +294,11 @@ void DIALOG_PLOT_SCHEMATIC_PS::plotOneSheetPS( const wxString& FileName,
if( m_plot_Sheet_Ref ) if( m_plot_Sheet_Ref )
{ {
plotter->SetColor( BLACK ); plotter->SetColor( BLACK );
m_Parent->PlotWorkSheet( plotter, screen, g_DrawDefaultLineThickness ); PlotWorkSheet( plotter, m_Parent->GetTitleBlock(),
m_Parent->GetPageSettings(),
screen->m_ScreenNumber, screen->m_NumberOfScreens,
m_Parent->GetScreenDesc(),
screen->GetFileName() );
} }
screen->Plot( plotter ); screen->Plot( plotter );
......
...@@ -420,7 +420,8 @@ void SCH_PRINTOUT::DrawPage( SCH_SCREEN* aScreen ) ...@@ -420,7 +420,8 @@ void SCH_PRINTOUT::DrawPage( SCH_SCREEN* aScreen )
aScreen->Draw( panel, dc, GR_DEFAULT_DRAWMODE ); aScreen->Draw( panel, dc, GR_DEFAULT_DRAWMODE );
if( printReference ) if( printReference )
parent->TraceWorkSheet( dc, aScreen, g_DrawDefaultLineThickness, IU_PER_MILS ); parent->TraceWorkSheet( dc, aScreen, g_DrawDefaultLineThickness,
IU_PER_MILS, parent->GetScreenDesc() );
g_DrawBgColor = bg_color; g_DrawBgColor = bg_color;
aScreen->m_IsPrinting = false; aScreen->m_IsPrinting = false;
......
...@@ -71,7 +71,8 @@ void SCH_EDIT_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg ) ...@@ -71,7 +71,8 @@ void SCH_EDIT_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg )
GetScreen()->Draw( m_canvas, DC, GR_DEFAULT_DRAWMODE ); GetScreen()->Draw( m_canvas, DC, GR_DEFAULT_DRAWMODE );
TraceWorkSheet( DC, GetScreen(), g_DrawDefaultLineThickness, IU_PER_MILS ); TraceWorkSheet( DC, GetScreen(), g_DrawDefaultLineThickness, IU_PER_MILS,
GetScreenDesc() );
#ifdef USE_WX_OVERLAY #ifdef USE_WX_OVERLAY
if( IsShown() ) if( IsShown() )
......
...@@ -861,7 +861,8 @@ void SCH_EDIT_FRAME::SVG_Print( wxCommandEvent& event ) ...@@ -861,7 +861,8 @@ void SCH_EDIT_FRAME::SVG_Print( wxCommandEvent& event )
void SCH_EDIT_FRAME::PrintPage( wxDC* aDC, int aPrintMask, bool aPrintMirrorMode, void* aData ) void SCH_EDIT_FRAME::PrintPage( wxDC* aDC, int aPrintMask, bool aPrintMirrorMode, void* aData )
{ {
GetScreen()->Draw( m_canvas, aDC, GR_DEFAULT_DRAWMODE ); GetScreen()->Draw( m_canvas, aDC, GR_DEFAULT_DRAWMODE );
TraceWorkSheet( aDC, GetScreen(), g_DrawDefaultLineThickness, IU_PER_MILS ); TraceWorkSheet( aDC, GetScreen(), g_DrawDefaultLineThickness, IU_PER_MILS,
GetScreenDesc() );
} }
......
...@@ -318,7 +318,6 @@ void DIALOG_PRINT_USING_PRINTER::SetPrintParameters( ) ...@@ -318,7 +318,6 @@ void DIALOG_PRINT_USING_PRINTER::SetPrintParameters( )
int idx = m_ScaleOption->GetSelection(); int idx = m_ScaleOption->GetSelection();
s_Parameters.m_PrintScale = s_ScaleList[idx]; s_Parameters.m_PrintScale = s_ScaleList[idx];
g_pcb_plot_options.Scale = s_Parameters.m_PrintScale;
if( m_FineAdjustXscaleOpt ) if( m_FineAdjustXscaleOpt )
{ {
...@@ -335,8 +334,6 @@ void DIALOG_PRINT_USING_PRINTER::SetPrintParameters( ) ...@@ -335,8 +334,6 @@ void DIALOG_PRINT_USING_PRINTER::SetPrintParameters( )
DisplayInfoMessage( NULL, _( "Warning: Scale option set to a very small value" ) ); DisplayInfoMessage( NULL, _( "Warning: Scale option set to a very small value" ) );
m_FineAdjustYscaleOpt->GetValue().ToDouble( &s_Parameters.m_YScaleAdjust ); m_FineAdjustYscaleOpt->GetValue().ToDouble( &s_Parameters.m_YScaleAdjust );
} }
g_pcb_plot_options.ScaleAdjX = s_Parameters.m_XScaleAdjust;
g_pcb_plot_options.ScaleAdjX = s_Parameters.m_YScaleAdjust;
} }
void DIALOG_PRINT_USING_PRINTER::OnScaleSelectionClick( wxCommandEvent& event ) void DIALOG_PRINT_USING_PRINTER::OnScaleSelectionClick( wxCommandEvent& event )
......
...@@ -105,7 +105,7 @@ void GERBVIEW_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg ) ...@@ -105,7 +105,7 @@ void GERBVIEW_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg )
if( IsElementVisible( DCODES_VISIBLE ) ) if( IsElementVisible( DCODES_VISIBLE ) )
DrawItemsDCodeID( DC, GR_COPY ); DrawItemsDCodeID( DC, GR_COPY );
TraceWorkSheet( DC, screen, 0, IU_PER_MILS ); TraceWorkSheet( DC, screen, 0, IU_PER_MILS, wxEmptyString );
if( m_canvas->IsMouseCaptured() ) if( m_canvas->IsMouseCaptured() )
m_canvas->CallMouseCapture( DC, wxDefaultPosition, false ); m_canvas->CallMouseCapture( DC, wxDefaultPosition, false );
......
...@@ -177,13 +177,13 @@ bool GERBVIEW_FRAME::LoadGerberFiles( const wxString& aFullFileName ) ...@@ -177,13 +177,13 @@ bool GERBVIEW_FRAME::LoadGerberFiles( const wxString& aFullFileName )
if( !filename.IsAbsolute() ) if( !filename.IsAbsolute() )
filename.SetPath( currentPath ); filename.SetPath( currentPath );
GetScreen()->SetFileName( filename.GetFullPath() ); m_lastFileName = filename.GetFullPath();
setActiveLayer( layer, false ); setActiveLayer( layer, false );
if( Read_GERBER_File( filename.GetFullPath(), filename.GetFullPath() ) ) if( Read_GERBER_File( filename.GetFullPath(), filename.GetFullPath() ) )
{ {
UpdateFileHistory( GetScreen()->GetFileName() ); UpdateFileHistory( m_lastFileName );
layer = getNextAvailableLayer( layer ); layer = getNextAvailableLayer( layer );
...@@ -258,7 +258,7 @@ bool GERBVIEW_FRAME::LoadExcellonFiles( const wxString& aFullFileName ) ...@@ -258,7 +258,7 @@ bool GERBVIEW_FRAME::LoadExcellonFiles( const wxString& aFullFileName )
if( !filename.IsAbsolute() ) if( !filename.IsAbsolute() )
filename.SetPath( currentPath ); filename.SetPath( currentPath );
GetScreen()->SetFileName( filename.GetFullPath() ); m_lastFileName = filename.GetFullPath();
setActiveLayer( layer, false ); setActiveLayer( layer, false );
...@@ -301,7 +301,7 @@ bool GERBVIEW_FRAME::LoadDCodeFile( const wxString& aFullFileName ) ...@@ -301,7 +301,7 @@ bool GERBVIEW_FRAME::LoadDCodeFile( const wxString& aFullFileName )
{ {
wildcard = _( "Gerber DCODE files" ); wildcard = _( "Gerber DCODE files" );
wildcard += wxT(" ") + AllFilesWildcard; wildcard += wxT(" ") + AllFilesWildcard;
fn = GetScreen()->GetFileName(); fn = m_lastFileName;
wxFileDialog dlg( this, _( "Load GERBER DCODE File" ), wxFileDialog dlg( this, _( "Load GERBER DCODE File" ),
fn.GetPath(), fn.GetFullName(), wildcard, fn.GetPath(), fn.GetFullName(), wildcard,
wxFD_OPEN | wxFD_FILE_MUST_EXIST ); wxFD_OPEN | wxFD_FILE_MUST_EXIST );
......
...@@ -162,6 +162,8 @@ protected: ...@@ -162,6 +162,8 @@ protected:
// Auxiliary file history used to store drill files history. // Auxiliary file history used to store drill files history.
wxFileHistory m_drillFileHistory; wxFileHistory m_drillFileHistory;
/// The last filename chosen to be proposed to the user
wxString m_lastFileName;
public: public:
GBR_LAYER_BOX_SELECTOR* m_SelLayerBox; GBR_LAYER_BOX_SELECTOR* m_SelLayerBox;
DCODE_SELECTION_BOX* m_DCodeSelector; // a list box to select the dcode Id to highlight. DCODE_SELECTION_BOX* m_DCodeSelector; // a list box to select the dcode Id to highlight.
......
...@@ -9,10 +9,6 @@ ...@@ -9,10 +9,6 @@
#include <pcbplot.h> #include <pcbplot.h>
/* The group of plot options - sadly global XXX */
PCB_Plot_Options g_pcb_plot_options;
/**************************************************************/ /**************************************************************/
/* void PCB_BASE_FRAME::ToPlotter(wxCommandEvent& event) */ /* void PCB_BASE_FRAME::ToPlotter(wxCommandEvent& event) */
/***************************************************************/ /***************************************************************/
......
...@@ -37,32 +37,4 @@ ...@@ -37,32 +37,4 @@
#define OPTKEY_PRINT_PAGE_FRAME wxT( "PrintPageFrame" ) #define OPTKEY_PRINT_PAGE_FRAME wxT( "PrintPageFrame" )
#define OPTKEY_PRINT_MONOCHROME_MODE wxT( "PrintMonochrome" ) #define OPTKEY_PRINT_MONOCHROME_MODE wxT( "PrintMonochrome" )
/* Plot Options : */
struct PCB_Plot_Options
{
bool Exclude_Edges_Pcb;
int PlotLine_Width;
bool Plot_Frame_Ref; // True to plot/print frame references
int Plot_Mode;
bool Plot_Set_MIROIR;
bool Sel_Rotate_Window;
int HPGL_Pen_Num;
int HPGL_Pen_Speed;
int HPGL_Pen_Diam;
int HPGL_Pen_Recouvrement;
bool HPGL_Org_Centre; // true if, HPGL originally the center of the node
int PlotPSColorOpt; // True for color Postscript output
bool Plot_PS_Negative; // True to create a negative board ps plot
/* id for plot format (see enum PlotFormat in plot_common.h) */
int PlotFormat;
int PlotOrient;
int PlotScaleOpt;
int DrillShapeOpt;
double Scale;
double ScaleAdjX;
double ScaleAdjY;
};
extern PCB_Plot_Options g_pcb_plot_options;
#endif // ifndef PCBPLOT_H #endif // ifndef PCBPLOT_H
...@@ -215,7 +215,7 @@ public: ...@@ -215,7 +215,7 @@ public:
m_Size( aSize ) m_Size( aSize )
{ } { }
wxPoint Centre() wxPoint Centre() const
{ {
return wxPoint( m_Pos.x + ( m_Size.x >> 1 ), return wxPoint( m_Pos.x + ( m_Size.x >> 1 ),
m_Pos.y + ( m_Size.y >> 1 ) ); m_Pos.y + ( m_Size.y >> 1 ) );
......
...@@ -76,7 +76,6 @@ class BASE_SCREEN : public EDA_ITEM ...@@ -76,7 +76,6 @@ class BASE_SCREEN : public EDA_ITEM
{ {
private: private:
GRIDS m_grids; ///< List of valid grid sizes. GRIDS m_grids; ///< List of valid grid sizes.
wxString m_fileName; ///< File used to load the screen.
bool m_FlagModified; ///< Indicates current drawing has been modified. bool m_FlagModified; ///< Indicates current drawing has been modified.
bool m_FlagSave; ///< Indicates automatic file save. bool m_FlagSave; ///< Indicates automatic file save.
EDA_ITEM* m_CurrentItem; ///< Currently selected object EDA_ITEM* m_CurrentItem; ///< Currently selected object
...@@ -153,10 +152,6 @@ public: ...@@ -153,10 +152,6 @@ public:
void InitDataPoints( const wxSize& aPageSizeInternalUnits ); void InitDataPoints( const wxSize& aPageSizeInternalUnits );
void SetFileName( const wxString& aFileName ) { m_fileName = aFileName; }
wxString GetFileName() const { return m_fileName; }
/** /**
* Function MilsToIuScalar * Function MilsToIuScalar
* returns the scalar required to convert mils to internal units. * returns the scalar required to convert mils to internal units.
......
...@@ -62,6 +62,9 @@ enum SCH_LINE_TEST_T ...@@ -62,6 +62,9 @@ enum SCH_LINE_TEST_T
class SCH_SCREEN : public BASE_SCREEN class SCH_SCREEN : public BASE_SCREEN
{ {
private:
wxString m_fileName; ///< File used to load the screen.
int m_refCount; ///< Number of sheets referencing this screen. int m_refCount; ///< Number of sheets referencing this screen.
///< Delete when it goes to zero. ///< Delete when it goes to zero.
...@@ -105,6 +108,10 @@ public: ...@@ -105,6 +108,10 @@ public:
const PAGE_INFO& GetPageSettings() const { return m_paper; } const PAGE_INFO& GetPageSettings() const { return m_paper; }
void SetPageSettings( const PAGE_INFO& aPageSettings ) { m_paper = aPageSettings; } void SetPageSettings( const PAGE_INFO& aPageSettings ) { m_paper = aPageSettings; }
void SetFileName( const wxString& aFileName ) { m_fileName = aFileName; }
const wxString& GetFileName() const { return m_fileName; }
const wxPoint& GetOriginAxisPosition() const { return m_originAxisPosition; } const wxPoint& GetOriginAxisPosition() const { return m_originAxisPosition; }
void SetOriginAxisPosition( const wxPoint& aPosition ) { m_originAxisPosition = aPosition; } void SetOriginAxisPosition( const wxPoint& aPosition ) { m_originAxisPosition = aPosition; }
......
...@@ -34,11 +34,14 @@ enum PlotFormat { ...@@ -34,11 +34,14 @@ enum PlotFormat {
* 2) only use native postscript fonts * 2) only use native postscript fonts
* 3) use the internal vector font and add 'phantom' text to aid * 3) use the internal vector font and add 'phantom' text to aid
* searching * searching
*
* This is recognized by the DXF driver too, where NATIVE emits
* TEXT entities instead of stroking the text
*/ */
enum PostscriptTextMode { enum PlotTextMode {
PSTEXTMODE_STROKE, PLOTTEXTMODE_STROKE,
PSTEXTMODE_NATIVE, PLOTTEXTMODE_NATIVE,
PSTEXTMODE_PHANTOM PLOTTEXTMODE_PHANTOM
}; };
...@@ -51,6 +54,8 @@ enum PostscriptTextMode { ...@@ -51,6 +54,8 @@ enum PostscriptTextMode {
class PLOTTER class PLOTTER
{ {
public: public:
static const int DEFAULT_LINE_WIDTH = -1;
PLOTTER( ); PLOTTER( );
virtual ~PLOTTER() virtual ~PLOTTER()
...@@ -97,7 +102,7 @@ public: ...@@ -97,7 +102,7 @@ public:
/** /**
* Set the default line width. Used at the beginning and when a width * Set the default line width. Used at the beginning and when a width
* of -1 is requested. * of -1 (DEFAULT_LINE_WIDTH) is requested.
* @param width is specified in IUs * @param width is specified in IUs
*/ */
virtual void SetDefaultLineWidth( int width ) = 0; virtual void SetDefaultLineWidth( int width ) = 0;
...@@ -148,13 +153,20 @@ public: ...@@ -148,13 +153,20 @@ public:
virtual void SetViewport( const wxPoint& aOffset, double aIusPerDecimil, virtual void SetViewport( const wxPoint& aOffset, double aIusPerDecimil,
double aScale, bool aMirror ) = 0; double aScale, bool aMirror ) = 0;
/**
* The IUs per decimil are an essential scaling factor when
* plotting; they are set and saved when establishing the viewport.
* Here they can be get back again
*/
double GetIUsPerDecimil() const { return m_IUsPerDecimil; }
// Low level primitives // Low level primitives
virtual void Rect( const wxPoint& p1, const wxPoint& p2, FILL_T fill, virtual void Rect( const wxPoint& p1, const wxPoint& p2, FILL_T fill,
int width = -1 ) = 0; int width = DEFAULT_LINE_WIDTH ) = 0;
virtual void Circle( const wxPoint& pos, int diametre, FILL_T fill, virtual void Circle( const wxPoint& pos, int diametre, FILL_T fill,
int width = -1 ) = 0; int width = DEFAULT_LINE_WIDTH ) = 0;
virtual void Arc( const wxPoint& centre, int StAngle, int EndAngle, int rayon, virtual void Arc( const wxPoint& centre, int StAngle, int EndAngle, int rayon,
FILL_T fill, int width = -1 ); FILL_T fill, int width = DEFAULT_LINE_WIDTH );
/** /**
* moveto/lineto primitive, moves the 'pen' to the specified direction * moveto/lineto primitive, moves the 'pen' to the specified direction
...@@ -195,7 +207,7 @@ public: ...@@ -195,7 +207,7 @@ public:
* @param aWidth = line width * @param aWidth = line width
*/ */
virtual void PlotPoly( const std::vector< wxPoint >& aCornerList, FILL_T aFill, virtual void PlotPoly( const std::vector< wxPoint >& aCornerList, FILL_T aFill,
int aWidth = -1 ) = 0; int aWidth = DEFAULT_LINE_WIDTH ) = 0;
/** /**
* Function PlotImage * Function PlotImage
...@@ -274,6 +286,15 @@ public: ...@@ -274,6 +286,15 @@ public:
// NOP for most plotters // NOP for most plotters
} }
/**
* Change the current text mode. See the PlotTextMode
* explanation at the beginning of the file
*/
virtual void SetTextMode( PlotTextMode mode )
{
// NOP for most plotters
}
protected: protected:
// These are marker subcomponents // These are marker subcomponents
void markerCircle( const wxPoint& pos, int radius ); void markerCircle( const wxPoint& pos, int radius );
...@@ -298,6 +319,12 @@ protected: ...@@ -298,6 +319,12 @@ protected:
/// Plot scale - chosen by the user (even implicitly with 'fit in a4') /// Plot scale - chosen by the user (even implicitly with 'fit in a4')
double plotScale; double plotScale;
/* Device scale (how many IUs in a decimil - always); it's a double
* because in eeschema there are 0.1 IUs in a decimil (eeschema
* always works in mils internally) while pcbnew can work in decimil
* or nanometers, so this value would be >= 1 */
double m_IUsPerDecimil;
/// Device scale (from IUs to device units - usually decimils) /// Device scale (from IUs to device units - usually decimils)
double iuPerDeviceUnit; double iuPerDeviceUnit;
...@@ -336,6 +363,11 @@ public: ...@@ -336,6 +363,11 @@ public:
return PLOT_FORMAT_HPGL; return PLOT_FORMAT_HPGL;
} }
static wxString GetDefaultFileExtension()
{
return wxString( wxT( "plt" ) );
}
virtual bool StartPlot( FILE* fout ); virtual bool StartPlot( FILE* fout );
virtual bool EndPlot(); virtual bool EndPlot();
...@@ -378,16 +410,16 @@ public: ...@@ -378,16 +410,16 @@ public:
virtual void SetViewport( const wxPoint& aOffset, double aIusPerDecimil, virtual void SetViewport( const wxPoint& aOffset, double aIusPerDecimil,
double aScale, bool aMirror ); double aScale, bool aMirror );
virtual void Rect( const wxPoint& p1, const wxPoint& p2, FILL_T fill, virtual void Rect( const wxPoint& p1, const wxPoint& p2, FILL_T fill,
int width = -1 ); int width = DEFAULT_LINE_WIDTH );
virtual void Circle( const wxPoint& pos, int diametre, FILL_T fill, virtual void Circle( const wxPoint& pos, int diametre, FILL_T fill,
int width = -1 ); int width = DEFAULT_LINE_WIDTH );
virtual void PlotPoly( const std::vector< wxPoint >& aCornerList, virtual void PlotPoly( const std::vector< wxPoint >& aCornerList,
FILL_T aFill, int aWidth = -1); FILL_T aFill, int aWidth = DEFAULT_LINE_WIDTH);
virtual void ThickSegment( const wxPoint& start, const wxPoint& end, int width, virtual void ThickSegment( const wxPoint& start, const wxPoint& end, int width,
EDA_DRAW_MODE_T tracemode ); EDA_DRAW_MODE_T tracemode );
virtual void Arc( const wxPoint& centre, int StAngle, int EndAngle, int rayon, virtual void Arc( const wxPoint& centre, int StAngle, int EndAngle, int rayon,
FILL_T fill, int width = -1 ); FILL_T fill, int width = DEFAULT_LINE_WIDTH );
virtual void PenTo( const wxPoint& pos, char plume ); virtual void PenTo( const wxPoint& pos, char plume );
virtual void FlashPadCircle( const wxPoint& pos, int diametre, virtual void FlashPadCircle( const wxPoint& pos, int diametre,
EDA_DRAW_MODE_T trace_mode ); EDA_DRAW_MODE_T trace_mode );
...@@ -416,16 +448,16 @@ class PSLIKE_PLOTTER : public PLOTTER ...@@ -416,16 +448,16 @@ class PSLIKE_PLOTTER : public PLOTTER
{ {
public: public:
PSLIKE_PLOTTER() : plotScaleAdjX( 1 ), plotScaleAdjY( 1 ), plotWidthAdj( 0 ), PSLIKE_PLOTTER() : plotScaleAdjX( 1 ), plotScaleAdjY( 1 ), plotWidthAdj( 0 ),
psTextMode( PSTEXTMODE_PHANTOM ) m_textMode( PLOTTEXTMODE_PHANTOM )
{ {
} }
/** /**
* Change the current postscript text mode * PS and PDF fully implement native text (for the Latin-1 subset)
*/ */
void SetPsTextMode( PostscriptTextMode mode ) virtual void SetTextMode( PlotTextMode mode )
{ {
psTextMode = mode; m_textMode = mode;
} }
virtual void SetDefaultLineWidth( int width ); virtual void SetDefaultLineWidth( int width );
...@@ -510,7 +542,7 @@ protected: ...@@ -510,7 +542,7 @@ protected:
double plotWidthAdj; double plotWidthAdj;
/// How to draw text /// How to draw text
PostscriptTextMode psTextMode; PlotTextMode m_textMode;
}; };
...@@ -521,6 +553,11 @@ public: ...@@ -521,6 +553,11 @@ public:
{ {
} }
static wxString GetDefaultFileExtension()
{
return wxString( wxT( "ps" ) );
}
virtual PlotFormat GetPlotterType() const virtual PlotFormat GetPlotterType() const
{ {
return PLOT_FORMAT_POST; return PLOT_FORMAT_POST;
...@@ -534,14 +571,14 @@ public: ...@@ -534,14 +571,14 @@ public:
virtual void SetViewport( const wxPoint& aOffset, double aIusPerDecimil, virtual void SetViewport( const wxPoint& aOffset, double aIusPerDecimil,
double aScale, bool aMirror ); double aScale, bool aMirror );
virtual void Rect( const wxPoint& p1, const wxPoint& p2, FILL_T fill, virtual void Rect( const wxPoint& p1, const wxPoint& p2, FILL_T fill,
int width = -1 ); int width = DEFAULT_LINE_WIDTH );
virtual void Circle( const wxPoint& pos, int diametre, FILL_T fill, virtual void Circle( const wxPoint& pos, int diametre, FILL_T fill,
int width = -1 ); int width = DEFAULT_LINE_WIDTH );
virtual void Arc( const wxPoint& centre, int StAngle, int EndAngle, virtual void Arc( const wxPoint& centre, int StAngle, int EndAngle,
int rayon, FILL_T fill, int width = -1 ); int rayon, FILL_T fill, int width = DEFAULT_LINE_WIDTH );
virtual void PlotPoly( const std::vector< wxPoint >& aCornerList, virtual void PlotPoly( const std::vector< wxPoint >& aCornerList,
FILL_T aFill, int aWidth = -1); FILL_T aFill, int aWidth = DEFAULT_LINE_WIDTH );
virtual void PlotImage( const wxImage& aImage, const wxPoint& aPos, virtual void PlotImage( const wxImage& aImage, const wxPoint& aPos,
double aScaleFactor ); double aScaleFactor );
...@@ -573,6 +610,11 @@ public: ...@@ -573,6 +610,11 @@ public:
return PLOT_FORMAT_PDF; return PLOT_FORMAT_PDF;
} }
static wxString GetDefaultFileExtension()
{
return wxString( wxT( "pdf" ) );
}
virtual bool StartPlot( FILE* fout ); virtual bool StartPlot( FILE* fout );
virtual bool EndPlot(); virtual bool EndPlot();
virtual void StartPage(); virtual void StartPage();
...@@ -586,14 +628,14 @@ public: ...@@ -586,14 +628,14 @@ public:
virtual void SetViewport( const wxPoint& aOffset, double aIusPerDecimil, virtual void SetViewport( const wxPoint& aOffset, double aIusPerDecimil,
double aScale, bool aMirror ); double aScale, bool aMirror );
virtual void Rect( const wxPoint& p1, const wxPoint& p2, FILL_T fill, virtual void Rect( const wxPoint& p1, const wxPoint& p2, FILL_T fill,
int width = -1 ); int width = DEFAULT_LINE_WIDTH );
virtual void Circle( const wxPoint& pos, int diametre, FILL_T fill, virtual void Circle( const wxPoint& pos, int diametre, FILL_T fill,
int width = -1 ); int width = DEFAULT_LINE_WIDTH );
virtual void Arc( const wxPoint& centre, int StAngle, int EndAngle, virtual void Arc( const wxPoint& centre, int StAngle, int EndAngle,
int rayon, FILL_T fill, int width = -1 ); int rayon, FILL_T fill, int width = DEFAULT_LINE_WIDTH );
virtual void PlotPoly( const std::vector< wxPoint >& aCornerList, virtual void PlotPoly( const std::vector< wxPoint >& aCornerList,
FILL_T aFill, int aWidth = -1); FILL_T aFill, int aWidth = DEFAULT_LINE_WIDTH);
virtual void PenTo( const wxPoint& pos, char plume ); virtual void PenTo( const wxPoint& pos, char plume );
...@@ -665,6 +707,11 @@ public: ...@@ -665,6 +707,11 @@ public:
return PLOT_FORMAT_GERBER; return PLOT_FORMAT_GERBER;
} }
static wxString GetDefaultFileExtension()
{
return wxString( wxT( "pho" ) );
}
virtual bool StartPlot( FILE* fout ); virtual bool StartPlot( FILE* fout );
virtual bool EndPlot(); virtual bool EndPlot();
virtual void SetCurrentLineWidth( int width ); virtual void SetCurrentLineWidth( int width );
...@@ -676,13 +723,13 @@ public: ...@@ -676,13 +723,13 @@ public:
virtual void SetViewport( const wxPoint& aOffset, double aIusPerDecimil, virtual void SetViewport( const wxPoint& aOffset, double aIusPerDecimil,
double aScale, bool aMirror ); double aScale, bool aMirror );
virtual void Rect( const wxPoint& p1, const wxPoint& p2, FILL_T fill, virtual void Rect( const wxPoint& p1, const wxPoint& p2, FILL_T fill,
int width = -1 ); int width = DEFAULT_LINE_WIDTH );
virtual void Circle( const wxPoint& pos, int diametre, FILL_T fill, virtual void Circle( const wxPoint& pos, int diametre, FILL_T fill,
int width = -1 ); int width = DEFAULT_LINE_WIDTH );
virtual void Arc( const wxPoint& aCenter, int aStAngle, int aEndAngle, int aRadius, virtual void Arc( const wxPoint& aCenter, int aStAngle, int aEndAngle, int aRadius,
FILL_T aFill, int aWidth = -1 ); FILL_T aFill, int aWidth = DEFAULT_LINE_WIDTH );
virtual void PlotPoly( const std::vector< wxPoint >& aCornerList, virtual void PlotPoly( const std::vector< wxPoint >& aCornerList,
FILL_T aFill, int aWidth = -1); FILL_T aFill, int aWidth = DEFAULT_LINE_WIDTH );
virtual void PenTo( const wxPoint& pos, char plume ); virtual void PenTo( const wxPoint& pos, char plume );
virtual void FlashPadCircle( const wxPoint& pos, int diametre, virtual void FlashPadCircle( const wxPoint& pos, int diametre,
...@@ -727,10 +774,17 @@ public: ...@@ -727,10 +774,17 @@ public:
return PLOT_FORMAT_DXF; return PLOT_FORMAT_DXF;
} }
/// We can plot text as strokes or as TEXT entities static wxString GetDefaultFileExtension()
void SetDXFTextMode( bool aTextAsLines )
{ {
textAsLines = aTextAsLines; return wxString( wxT( "dxf" ) );
}
/**
* DXF handles NATIVE text emitting TEXT entities
*/
virtual void SetTextMode( PlotTextMode mode )
{
textAsLines = ( mode != PLOTTEXTMODE_NATIVE );
} }
virtual bool StartPlot( FILE* fout ); virtual bool StartPlot( FILE* fout );
...@@ -755,15 +809,15 @@ public: ...@@ -755,15 +809,15 @@ public:
virtual void SetViewport( const wxPoint& aOffset, double aIusPerDecimil, virtual void SetViewport( const wxPoint& aOffset, double aIusPerDecimil,
double aScale, bool aMirror ); double aScale, bool aMirror );
virtual void Rect( const wxPoint& p1, const wxPoint& p2, FILL_T fill, virtual void Rect( const wxPoint& p1, const wxPoint& p2, FILL_T fill,
int width = -1 ); int width = DEFAULT_LINE_WIDTH );
virtual void Circle( const wxPoint& pos, int diametre, FILL_T fill, virtual void Circle( const wxPoint& pos, int diametre, FILL_T fill,
int width = -1 ); int width = DEFAULT_LINE_WIDTH );
virtual void PlotPoly( const std::vector< wxPoint >& aCornerList, virtual void PlotPoly( const std::vector< wxPoint >& aCornerList,
FILL_T aFill, int aWidth = -1 ); FILL_T aFill, int aWidth = DEFAULT_LINE_WIDTH );
virtual void ThickSegment( const wxPoint& start, const wxPoint& end, int width, virtual void ThickSegment( const wxPoint& start, const wxPoint& end, int width,
EDA_DRAW_MODE_T tracemode ); EDA_DRAW_MODE_T tracemode );
virtual void Arc( const wxPoint& centre, int StAngle, int EndAngle, int rayon, virtual void Arc( const wxPoint& centre, int StAngle, int EndAngle, int rayon,
FILL_T fill, int width = -1 ); FILL_T fill, int width = DEFAULT_LINE_WIDTH );
virtual void PenTo( const wxPoint& pos, char plume ); virtual void PenTo( const wxPoint& pos, char plume );
virtual void FlashPadCircle( const wxPoint& pos, int diametre, virtual void FlashPadCircle( const wxPoint& pos, int diametre,
EDA_DRAW_MODE_T trace_mode ); EDA_DRAW_MODE_T trace_mode );
...@@ -790,4 +844,16 @@ protected: ...@@ -790,4 +844,16 @@ protected:
int currentColor; int currentColor;
}; };
class TITLE_BLOCK;
void PlotWorkSheet( PLOTTER* plotter, const TITLE_BLOCK& aTitleBlock,
const PAGE_INFO& aPageInfo,
int aSheetNumber, int aNumberOfSheets,
const wxString &aSheetDesc,
const wxString &aFilename );
/** Returns the default plot extension for a format
*/
wxString GetDefaultPlotExtension( PlotFormat aFormat );
#endif // PLOT_COMMON_H_ #endif // PLOT_COMMON_H_
...@@ -91,9 +91,6 @@ protected: ...@@ -91,9 +91,6 @@ protected:
/// main window. /// main window.
wxAuiToolBar* m_auxiliaryToolBar; wxAuiToolBar* m_auxiliaryToolBar;
/// True prints or plots the drawing border and title block.
bool m_printBorderAndTitleBlock;
void updateGridSelectBox(); void updateGridSelectBox();
void updateZoomSelectBox(); void updateZoomSelectBox();
virtual void unitsChangeRefresh(); virtual void unitsChangeRefresh();
...@@ -105,8 +102,6 @@ public: ...@@ -105,8 +102,6 @@ public:
~PCB_BASE_FRAME(); ~PCB_BASE_FRAME();
bool GetPrintBorderAndTitleBlock() const { return m_printBorderAndTitleBlock; }
/** /**
* Function GetBoardBoundingBox * Function GetBoardBoundingBox
* calculates the bounding box containing all board items (or board edge segments). * calculates the bounding box containing all board items (or board edge segments).
...@@ -569,73 +564,6 @@ public: ...@@ -569,73 +564,6 @@ public:
*/ */
void RecalculateAllTracksNetcode(); void RecalculateAllTracksNetcode();
/* Plotting functions:
* Return true if OK, false if the file is not created (or has a problem)
*/
/**
* Function ExportToGerberFile
* create one output files one per board layer in the RS274X format.
* <p>
* The units are in inches and in the format 3.4 with the leading zeros omitted.
* Coordinates are absolute value. The 3.4 format is used because the native Pcbnew
* units are 1/10000 inch.
* </p>
*/
bool ExportToGerberFile( const wxString& aFullFileName,
int aLayer,
bool aPlotOriginIsAuxAxis,
EDA_DRAW_MODE_T aTraceMode );
bool ExportToHpglFile( const wxString& aFullFileName,
int aLayer,
EDA_DRAW_MODE_T aTraceMode );
bool ExportToPostScriptFile( const wxString& aFullFileName,
int aLayer,
bool aUseA4,
EDA_DRAW_MODE_T aTraceMode );
bool ExportToDxfFile( const wxString& aFullFileName,
int aLayer,
EDA_DRAW_MODE_T aTraceMode );
void Plot_Layer( PLOTTER* plotter,
int Layer,
EDA_DRAW_MODE_T trace_mode );
/**
* Function Plot_Standard_Layer
* plot copper or technical layers.
* not used for silk screen layers, because these layers have specific
* requirements, mainly for pads
* @param aPlotter = the plotter to use
* @param aLayerMask = the mask to define the layers to plot
* @param aPlotVia = true to plot vias, false to skip vias (has meaning
* only for solder mask layers).
* @param aPlotMode = the plot mode (files, sketch). Has meaning for some formats only
* @param aSkipNPTH_Pads = true to skip NPTH Pads, when the pad size and the pad hole
* have the same size. Used in GERBER format only.
*/
void Plot_Standard_Layer( PLOTTER* aPlotter, int aLayerMask,
bool aPlotVia, EDA_DRAW_MODE_T aPlotMode,
bool aSkipNPTH_Pads = false );
void PlotSilkScreen( PLOTTER* plotter, int masque_layer, EDA_DRAW_MODE_T trace_mode );
/**
* Function PlotDrillMark
* Draw a drill mark for pads and vias.
* Must be called after all drawings, because it
* redraw the drill mark on a pad or via, as a negative (i.e. white) shape
* in FILLED plot mode
* @param aPlotter = the PLOTTER
* @param aTraceMode = the mode of plot (FILLED, SKETCH)
* @param aSmallDrillShape = true to plot a small drill shape, false to
* plot the actual drill shape
*/
void PlotDrillMark( PLOTTER* aPlotter, EDA_DRAW_MODE_T aTraceMode, bool aSmallDrillShape );
/* Functions relative to Undo/redo commands: /* Functions relative to Undo/redo commands:
*/ */
......
...@@ -662,7 +662,8 @@ public: ...@@ -662,7 +662,8 @@ public:
*/ */
double GetZoom(); double GetZoom();
void TraceWorkSheet( wxDC* aDC, BASE_SCREEN* aScreen, int aLineWidth, double aScalar ); void TraceWorkSheet( wxDC* aDC, BASE_SCREEN* aScreen, int aLineWidth,
double aScale, const wxString &aFilename );
/** /**
* Function TraceWorkSheet is a core function for drawing of the page layout with * Function TraceWorkSheet is a core function for drawing of the page layout with
...@@ -686,8 +687,6 @@ public: ...@@ -686,8 +687,6 @@ public:
int aNScr, int aScr, int aLnW, double aScalar, int aNScr, int aScr, int aLnW, double aScalar,
EDA_COLOR_T aClr1 = RED, EDA_COLOR_T aClr2 = RED ); EDA_COLOR_T aClr1 = RED, EDA_COLOR_T aClr2 = RED );
void PlotWorkSheet( PLOTTER* aPlotter, BASE_SCREEN* aScreen, int aLineWidth );
/** /**
* Function GetXYSheetReferences * Function GetXYSheetReferences
* returns the X,Y sheet references where the point position is located * returns the X,Y sheet references where the point position is located
......
...@@ -187,10 +187,6 @@ set(PCBNEW_CLASS_SRCS ...@@ -187,10 +187,6 @@ set(PCBNEW_CLASS_SRCS
pcbnew.cpp pcbnew.cpp
pcbnew_config.cpp pcbnew_config.cpp
pcbplot.cpp pcbplot.cpp
plotgerb.cpp
plothpgl.cpp
plotps.cpp
plotdxf.cpp
plot_rtn.cpp plot_rtn.cpp
print_board_functions.cpp print_board_functions.cpp
printout_controler.cpp printout_controler.cpp
......
...@@ -64,7 +64,7 @@ void PCB_EDIT_FRAME::RecreateBOMFileFromBoard( wxCommandEvent& aEvent ) ...@@ -64,7 +64,7 @@ void PCB_EDIT_FRAME::RecreateBOMFileFromBoard( wxCommandEvent& aEvent )
} }
/* Set the file extension: */ /* Set the file extension: */
fn = GetScreen()->GetFileName(); fn = GetBoard()->GetFileName();
fn.SetExt( CsvFileExtension ); fn.SetExt( CsvFileExtension );
wxFileDialog dlg( this, _( "Save Bill of Materials" ), wxGetCwd(), wxFileDialog dlg( this, _( "Save Bill of Materials" ), wxGetCwd(),
......
...@@ -187,6 +187,9 @@ class BOARD : public BOARD_ITEM ...@@ -187,6 +187,9 @@ class BOARD : public BOARD_ITEM
friend class PCB_EDIT_FRAME; friend class PCB_EDIT_FRAME;
private: private:
/// the board filename
wxString m_fileName;
// @todo: switch to boost:ptr_vector, and change ~BOARD() // @todo: switch to boost:ptr_vector, and change ~BOARD()
typedef std::vector<MARKER_PCB*> MARKERS; typedef std::vector<MARKER_PCB*> MARKERS;
...@@ -237,6 +240,10 @@ private: ...@@ -237,6 +240,10 @@ private:
public: public:
void SetFileName( const wxString& aFileName ) { m_fileName = aFileName; }
const wxString &GetFileName() const { return m_fileName; }
/// Flags used in ratsnest calculation and update. /// Flags used in ratsnest calculation and update.
int m_Status_Pcb; int m_Status_Pcb;
......
...@@ -183,7 +183,7 @@ void DIALOG_SVG_PRINT::PrintSVGDoc( bool aPrintAll, bool aPrint_Frame_Ref ) ...@@ -183,7 +183,7 @@ void DIALOG_SVG_PRINT::PrintSVGDoc( bool aPrintAll, bool aPrint_Frame_Ref )
fn = m_FileNameCtrl->GetValue(); fn = m_FileNameCtrl->GetValue();
if( !fn.IsOk() ) if( !fn.IsOk() )
{ {
fn = screen->GetFileName(); fn = m_Parent->GetBoard()->GetFileName();
} }
if( aPrintAll ) if( aPrintAll )
...@@ -271,7 +271,8 @@ bool DIALOG_SVG_PRINT::DrawPage( const wxString& FullFileName, ...@@ -271,7 +271,8 @@ bool DIALOG_SVG_PRINT::DrawPage( const wxString& FullFileName,
g_DrawBgColor = WHITE; g_DrawBgColor = WHITE;
if( aPrint_Frame_Ref ) if( aPrint_Frame_Ref )
m_Parent->TraceWorkSheet( &dc, screen, s_Parameters.m_PenDefaultSize, IU_PER_MILS ); m_Parent->TraceWorkSheet( &dc, screen, s_Parameters.m_PenDefaultSize,
IU_PER_MILS, wxT( "" ) );
m_Parent->PrintPage( &dc, m_PrintMaskLayer, false, &s_Parameters); m_Parent->PrintPage( &dc, m_PrintMaskLayer, false, &s_Parameters);
g_DrawBgColor = bg_color; g_DrawBgColor = bg_color;
......
...@@ -293,7 +293,7 @@ void DIALOG_DRC_CONTROL::OnButtonBrowseRptFileClick( wxCommandEvent& event ) ...@@ -293,7 +293,7 @@ void DIALOG_DRC_CONTROL::OnButtonBrowseRptFileClick( wxCommandEvent& event )
wxString wildcard( _( "DRC report files (.rpt)|*.rpt" ) ); wxString wildcard( _( "DRC report files (.rpt)|*.rpt" ) );
wxString Ext( wxT( "rpt" ) ); wxString Ext( wxT( "rpt" ) );
fn = m_Parent->GetScreen()->GetFileName() + wxT( "-drc" ); fn = m_Parent->GetBoard()->GetFileName() + wxT( "-drc" );
fn.SetExt( Ext ); fn.SetExt( Ext );
wxFileDialog dlg( this, _( "Save DRC Report File" ), wxEmptyString, wxFileDialog dlg( this, _( "Save DRC Report File" ), wxEmptyString,
...@@ -574,7 +574,7 @@ void DIALOG_DRC_CONTROL::writeReport( FILE* fp ) ...@@ -574,7 +574,7 @@ void DIALOG_DRC_CONTROL::writeReport( FILE* fp )
int count; int count;
fprintf( fp, "** Drc report for %s **\n", fprintf( fp, "** Drc report for %s **\n",
TO_UTF8( m_Parent->GetScreen()->GetFileName() ) ); TO_UTF8( m_Parent->GetBoard()->GetFileName() ) );
wxDateTime now = wxDateTime::Now(); wxDateTime now = wxDateTime::Now();
......
...@@ -138,11 +138,11 @@ void DIALOG_GENDRILL::InitDisplayParams() ...@@ -138,11 +138,11 @@ void DIALOG_GENDRILL::InitDisplayParams()
m_MicroViaDrillValue->SetLabel( _( "Use Netclasses values" ) ); m_MicroViaDrillValue->SetLabel( _( "Use Netclasses values" ) );
msg.Empty(); msg.Empty();
msg << plot_opts.m_HPGLPenNum; msg << plot_opts.GetHPGLPenNum();
m_PenNum->SetValue( msg ); m_PenNum->SetValue( msg );
msg.Empty(); msg.Empty();
msg << plot_opts.m_HPGLPenSpeed; msg << plot_opts.GetHPGLPenSpeed();
m_PenSpeed->SetValue( msg ); m_PenSpeed->SetValue( msg );
// See if we have some buried vias or/and microvias, and display // See if we have some buried vias or/and microvias, and display
...@@ -308,12 +308,12 @@ void DIALOG_GENDRILL::SetParams() ...@@ -308,12 +308,12 @@ void DIALOG_GENDRILL::SetParams()
msg = m_PenSpeed->GetValue(); msg = m_PenSpeed->GetValue();
if( msg.ToLong( &ltmp ) ) if( msg.ToLong( &ltmp ) )
plot_opts.m_HPGLPenSpeed = ltmp; plot_opts.SetHPGLPenSpeed( ltmp );
msg = m_PenNum->GetValue(); msg = m_PenNum->GetValue();
if( msg.ToLong( &ltmp ) ) if( msg.ToLong( &ltmp ) )
plot_opts.m_HPGLPenNum = ltmp; plot_opts.SetHPGLPenNum( ltmp );
if( m_Choice_Drill_Offset->GetSelection() == 0 ) if( m_Choice_Drill_Offset->GetSelection() == 0 )
m_FileDrillOffset = wxPoint( 0, 0 ); m_FileDrillOffset = wxPoint( 0, 0 );
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include <pcbnew_config.h> #include <pcbnew_config.h>
#include <class_board_design_settings.h> #include <class_board_design_settings.h>
#include <class_board.h>
#include <wildcards_and_files_ext.h> #include <wildcards_and_files_ext.h>
#include <dialog_netlist.h> #include <dialog_netlist.h>
...@@ -28,7 +29,7 @@ void PCB_EDIT_FRAME::InstallNetlistFrame( wxDC* DC ) ...@@ -28,7 +29,7 @@ void PCB_EDIT_FRAME::InstallNetlistFrame( wxDC* DC )
if( !fn.FileExists() ) if( !fn.FileExists() )
{ {
fn = GetScreen()->GetFileName(); fn = GetBoard()->GetFileName();
fn.SetExt( NetlistFileExtension ); fn.SetExt( NetlistFileExtension );
lastNetlistName = fn.GetFullPath(); lastNetlistName = fn.GetFullPath();
} }
...@@ -40,10 +41,10 @@ void PCB_EDIT_FRAME::InstallNetlistFrame( wxDC* DC ) ...@@ -40,10 +41,10 @@ void PCB_EDIT_FRAME::InstallNetlistFrame( wxDC* DC )
// Save project settings if needed. // Save project settings if needed.
// Project settings are saved in the corresponding <board name>.pro file // Project settings are saved in the corresponding <board name>.pro file
if( lastNetlistName != GetLastNetListRead() && if( lastNetlistName != GetLastNetListRead() &&
!GetScreen()->GetFileName().IsEmpty() && !GetBoard()->GetFileName().IsEmpty() &&
IsOK(NULL, _("Project config has changed. Save it ?") ) ) IsOK(NULL, _("Project config has changed. Save it ?") ) )
{ {
wxFileName fn = GetScreen()->GetFileName(); wxFileName fn = GetBoard()->GetFileName();
fn.SetExt( ProjectFileExtension ); fn.SetExt( ProjectFileExtension );
wxGetApp().WriteProjectConfig( fn.GetFullPath(), GROUP, wxGetApp().WriteProjectConfig( fn.GetFullPath(), GROUP,
GetProjectFileParameters() ); GetProjectFileParameters() );
......
...@@ -191,9 +191,9 @@ void DIALOG_PRINT_FOR_MODEDIT::OnPrintButtonClick( wxCommandEvent& event ) ...@@ -191,9 +191,9 @@ void DIALOG_PRINT_FOR_MODEDIT::OnPrintButtonClick( wxCommandEvent& event )
s_Parameters.m_Print_Black_and_White = m_ModeColorOption->GetSelection(); s_Parameters.m_Print_Black_and_White = m_ModeColorOption->GetSelection();
s_Parameters.m_PrintScale = s_ScaleList[m_ScaleOption->GetSelection()]; s_Parameters.m_PrintScale = s_ScaleList[m_ScaleOption->GetSelection()];
plot_opts.m_FineScaleAdjustX = s_Parameters.m_XScaleAdjust; plot_opts.SetFineScaleAdjustX( s_Parameters.m_XScaleAdjust );
plot_opts.m_FineScaleAdjustY = s_Parameters.m_YScaleAdjust; plot_opts.SetFineScaleAdjustY( s_Parameters.m_YScaleAdjust );
plot_opts.m_PlotScale = s_Parameters.m_PrintScale; plot_opts.SetScale( s_Parameters.m_PrintScale );
m_parent->SetPlotSettings( plot_opts ); m_parent->SetPlotSettings( plot_opts );
......
...@@ -353,7 +353,7 @@ void DIALOG_PRINT_USING_PRINTER::SetPrintParameters( ) ...@@ -353,7 +353,7 @@ void DIALOG_PRINT_USING_PRINTER::SetPrintParameters( )
int idx = m_ScaleOption->GetSelection(); int idx = m_ScaleOption->GetSelection();
s_Parameters.m_PrintScale = s_ScaleList[idx]; s_Parameters.m_PrintScale = s_ScaleList[idx];
plot_opts.m_PlotScale = s_Parameters.m_PrintScale; plot_opts.SetScale( s_Parameters.m_PrintScale );
if( m_FineAdjustXscaleOpt ) if( m_FineAdjustXscaleOpt )
{ {
...@@ -371,8 +371,8 @@ void DIALOG_PRINT_USING_PRINTER::SetPrintParameters( ) ...@@ -371,8 +371,8 @@ void DIALOG_PRINT_USING_PRINTER::SetPrintParameters( )
m_FineAdjustYscaleOpt->GetValue().ToDouble( &s_Parameters.m_YScaleAdjust ); m_FineAdjustYscaleOpt->GetValue().ToDouble( &s_Parameters.m_YScaleAdjust );
} }
plot_opts.m_FineScaleAdjustX = s_Parameters.m_XScaleAdjust; plot_opts.SetFineScaleAdjustX( s_Parameters.m_XScaleAdjust );
plot_opts.m_FineScaleAdjustY = s_Parameters.m_YScaleAdjust; plot_opts.SetFineScaleAdjustY( s_Parameters.m_YScaleAdjust );
m_parent->SetPlotSettings( plot_opts ); m_parent->SetPlotSettings( plot_opts );
......
...@@ -1101,6 +1101,10 @@ BOARD* EAGLE_PLUGIN::Load( const wxString& aFileName, BOARD* aAppendToMe, PROPE ...@@ -1101,6 +1101,10 @@ BOARD* EAGLE_PLUGIN::Load( const wxString& aFileName, BOARD* aAppendToMe, PROPE
m_board = aAppendToMe ? aAppendToMe : new BOARD(); m_board = aAppendToMe ? aAppendToMe : new BOARD();
// Give the filename to the board if it's new
if( !aAppendToMe )
m_board->SetFileName( aFileName );
// delete on exception, iff I own m_board, according to aAppendToMe // delete on exception, iff I own m_board, according to aAppendToMe
auto_ptr<BOARD> deleter( aAppendToMe ? NULL : m_board ); auto_ptr<BOARD> deleter( aAppendToMe ? NULL : m_board );
......
...@@ -119,7 +119,7 @@ static double MapYTo( int aY ) ...@@ -119,7 +119,7 @@ static double MapYTo( int aY )
/* Driver function: processing starts here */ /* Driver function: processing starts here */
void PCB_EDIT_FRAME::ExportToGenCAD( wxCommandEvent& aEvent ) void PCB_EDIT_FRAME::ExportToGenCAD( wxCommandEvent& aEvent )
{ {
wxFileName fn = GetScreen()->GetFileName(); wxFileName fn = GetBoard()->GetFileName();
wxString msg, ext, wildcard; wxString msg, ext, wildcard;
FILE* file; FILE* file;
...@@ -688,7 +688,7 @@ static void CreateSignalsSection( FILE* aFile, BOARD* aPcb ) ...@@ -688,7 +688,7 @@ static void CreateSignalsSection( FILE* aFile, BOARD* aPcb )
static bool CreateHeaderInfoData( FILE* aFile, PCB_EDIT_FRAME* aFrame ) static bool CreateHeaderInfoData( FILE* aFile, PCB_EDIT_FRAME* aFrame )
{ {
wxString msg; wxString msg;
PCB_SCREEN* screen = (PCB_SCREEN*) aFrame->GetScreen(); BOARD *board = aFrame->GetBoard();
fputs( "$HEADER\n", aFile ); fputs( "$HEADER\n", aFile );
fputs( "GENCAD 1.4\n", aFile ); fputs( "GENCAD 1.4\n", aFile );
...@@ -699,7 +699,7 @@ static bool CreateHeaderInfoData( FILE* aFile, PCB_EDIT_FRAME* aFrame ) ...@@ -699,7 +699,7 @@ static bool CreateHeaderInfoData( FILE* aFile, PCB_EDIT_FRAME* aFrame )
GetChars( GetBuildVersion() ) ); GetChars( GetBuildVersion() ) );
fputs( TO_UTF8( msg ), aFile ); fputs( TO_UTF8( msg ), aFile );
msg = wxT( "DRAWING \"" ) + screen->GetFileName() + wxT( "\"\n" ); msg = wxT( "DRAWING \"" ) + board->GetFileName() + wxT( "\"\n" );
fputs( TO_UTF8( msg ), aFile ); fputs( TO_UTF8( msg ), aFile );
const TITLE_BLOCK& tb = aFrame->GetTitleBlock(); const TITLE_BLOCK& tb = aFrame->GetTitleBlock();
......
...@@ -1197,7 +1197,7 @@ void PCB_EDIT_FRAME::OnExportVRML( wxCommandEvent& event ) ...@@ -1197,7 +1197,7 @@ void PCB_EDIT_FRAME::OnExportVRML( wxCommandEvent& event )
// Build default file name // Build default file name
wxString ext = wxT( "wrl" ); wxString ext = wxT( "wrl" );
fn = GetScreen()->GetFileName(); fn = GetBoard()->GetFileName();
fn.SetExt( ext ); fn.SetExt( ext );
DIALOG_EXPORT_3DFILE dlg( this ); DIALOG_EXPORT_3DFILE dlg( this );
......
...@@ -85,7 +85,7 @@ void PCB_EDIT_FRAME::Files_io( wxCommandEvent& event ) ...@@ -85,7 +85,7 @@ void PCB_EDIT_FRAME::Files_io( wxCommandEvent& event )
switch( id ) switch( id )
{ {
case ID_LOAD_FILE: case ID_LOAD_FILE:
LoadOnePcbFile( GetScreen()->GetFileName(), false, true ); LoadOnePcbFile( GetBoard()->GetFileName(), false, true );
break; break;
case ID_MENU_READ_LAST_SAVED_VERSION_BOARD: case ID_MENU_READ_LAST_SAVED_VERSION_BOARD:
...@@ -99,7 +99,7 @@ void PCB_EDIT_FRAME::Files_io( wxCommandEvent& event ) ...@@ -99,7 +99,7 @@ void PCB_EDIT_FRAME::Files_io( wxCommandEvent& event )
} }
else else
{ {
fn = GetScreen()->GetFileName(); fn = GetBoard()->GetFileName();
fn.SetExt( pcbBackupFileExtension ); fn.SetExt( pcbBackupFileExtension );
} }
...@@ -119,7 +119,9 @@ void PCB_EDIT_FRAME::Files_io( wxCommandEvent& event ) ...@@ -119,7 +119,9 @@ void PCB_EDIT_FRAME::Files_io( wxCommandEvent& event )
LoadOnePcbFile( fn.GetFullPath(), false ); LoadOnePcbFile( fn.GetFullPath(), false );
fn.SetExt( PcbFileExtension ); fn.SetExt( PcbFileExtension );
GetScreen()->SetFileName( fn.GetFullPath() );
// Re-set the name since extension changed
GetBoard()->SetFileName( fn.GetFullPath() );
UpdateTitle(); UpdateTitle();
} }
break; break;
...@@ -129,16 +131,20 @@ void PCB_EDIT_FRAME::Files_io( wxCommandEvent& event ) ...@@ -129,16 +131,20 @@ void PCB_EDIT_FRAME::Files_io( wxCommandEvent& event )
break; break;
case ID_NEW_BOARD: case ID_NEW_BOARD:
Clear_Pcb( true ); {
GetScreen()->GetFileName().Printf( wxT( "%s%cnoname%s" ), Clear_Pcb( true );
GetChars( wxGetCwd() ), DIR_SEP, wxString newFilename;
GetChars( PcbFileExtension ) ); newFilename.Printf( wxT( "%s%cnoname%s" ),
UpdateTitle(); GetChars( wxGetCwd() ), DIR_SEP,
ReCreateLayerBox( NULL ); GetChars( PcbFileExtension ) );
GetBoard()->SetFileName( newFilename );
UpdateTitle();
ReCreateLayerBox( NULL );
}
break; break;
case ID_SAVE_BOARD: case ID_SAVE_BOARD:
SavePcbFile( GetScreen()->GetFileName() ); SavePcbFile( GetBoard()->GetFileName() );
break; break;
case ID_SAVE_BOARD_AS: case ID_SAVE_BOARD_AS:
...@@ -163,7 +169,7 @@ the changes?" ) ) ) ...@@ -163,7 +169,7 @@ the changes?" ) ) )
if( aAppend ) if( aAppend )
{ {
GetScreen()->SetFileName( wxEmptyString ); GetBoard()->SetFileName( wxEmptyString );
OnModify(); OnModify();
GetBoard()->m_Status_Pcb = 0; GetBoard()->m_Status_Pcb = 0;
} }
...@@ -235,7 +241,7 @@ the changes?" ) ) ) ...@@ -235,7 +241,7 @@ the changes?" ) ) )
CheckForAutoSaveFile( fileName, pcbBackupFileExtension ); CheckForAutoSaveFile( fileName, pcbBackupFileExtension );
GetScreen()->SetFileName( fileName.GetFullPath() ); GetBoard()->SetFileName( fileName.GetFullPath() );
if( !aAppend ) if( !aAppend )
{ {
...@@ -247,7 +253,7 @@ the changes?" ) ) ) ...@@ -247,7 +253,7 @@ the changes?" ) ) )
m_DisplayViaFill = DisplayOpt.DisplayViaFill; m_DisplayViaFill = DisplayOpt.DisplayViaFill;
// load project settings before BOARD, in case BOARD file has overrides. // load project settings before BOARD, in case BOARD file has overrides.
LoadProjectSettings( GetScreen()->GetFileName() ); LoadProjectSettings( GetBoard()->GetFileName() );
} }
else else
{ {
...@@ -264,7 +270,11 @@ the changes?" ) ) ) ...@@ -264,7 +270,11 @@ the changes?" ) ) )
props["page_height"] = wxString::Format( wxT( "%d" ), GetPageSizeIU().y ); props["page_height"] = wxString::Format( wxT( "%d" ), GetPageSizeIU().y );
// load or append either: // load or append either:
loadedBoard = pi->Load( GetScreen()->GetFileName(), aAppend ? GetBoard() : NULL, &props ); loadedBoard = pi->Load( GetBoard()->GetFileName(), aAppend ? GetBoard() : NULL, &props );
// the Load plugin method makes a 'fresh' board, so we need to
// set its own name
GetBoard()->SetFileName( fileName.GetFullPath() );
if( !aAppend ) if( !aAppend )
{ {
...@@ -301,7 +311,7 @@ this file again." ) ); ...@@ -301,7 +311,7 @@ this file again." ) );
// If append option: change the initial board name to <oldname>-append.brd // If append option: change the initial board name to <oldname>-append.brd
if( aAppend ) if( aAppend )
{ {
wxString new_filename = GetScreen()->GetFileName().BeforeLast( '.' ); wxString new_filename = GetBoard()->GetFileName().BeforeLast( '.' );
if ( ! new_filename.EndsWith( wxT( "-append" ) ) ) if ( ! new_filename.EndsWith( wxT( "-append" ) ) )
new_filename += wxT( "-append" ); new_filename += wxT( "-append" );
...@@ -309,13 +319,16 @@ this file again." ) ); ...@@ -309,13 +319,16 @@ this file again." ) );
new_filename += wxT( "." ) + PcbFileExtension; new_filename += wxT( "." ) + PcbFileExtension;
OnModify(); OnModify();
GetScreen()->SetFileName( new_filename ); GetBoard()->SetFileName( new_filename );
} }
GetScreen()->GetFileName().Replace( WIN_STRING_DIR_SEP, UNIX_STRING_DIR_SEP ); // Fix the directory separator on Windows
wxString fn( GetBoard()->GetFileName() );
fn.Replace( WIN_STRING_DIR_SEP, UNIX_STRING_DIR_SEP );
GetBoard()->SetFileName( fn );
UpdateTitle(); UpdateTitle();
UpdateFileHistory( GetScreen()->GetFileName() ); UpdateFileHistory( GetBoard()->GetFileName() );
// Rebuild the new pad list (for drc and ratsnet control ...) // Rebuild the new pad list (for drc and ratsnet control ...)
GetBoard()->m_Status_Pcb = 0; GetBoard()->m_Status_Pcb = 0;
...@@ -404,18 +417,18 @@ bool PCB_EDIT_FRAME::SavePcbFile( const wxString& aFileName, bool aCreateBackupF ...@@ -404,18 +417,18 @@ bool PCB_EDIT_FRAME::SavePcbFile( const wxString& aFileName, bool aCreateBackupF
if( aFileName == wxEmptyString ) if( aFileName == wxEmptyString )
{ {
wxFileDialog dlg( this, _( "Save Board File" ), wxEmptyString, GetScreen()->GetFileName(), wxFileDialog dlg( this, _( "Save Board File" ), wxEmptyString, GetBoard()->GetFileName(),
wildcard, wxFD_SAVE | wxFD_OVERWRITE_PROMPT ); wildcard, wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
if( dlg.ShowModal() != wxID_OK ) if( dlg.ShowModal() != wxID_OK )
return false; return false;
GetScreen()->SetFileName( dlg.GetPath() ); GetBoard()->SetFileName( dlg.GetPath() );
wildcardIndex = dlg.GetFilterIndex(); // Legacy or s-expression file format. wildcardIndex = dlg.GetFilterIndex(); // Legacy or s-expression file format.
} }
else else
{ {
GetScreen()->SetFileName( aFileName ); GetBoard()->SetFileName( aFileName );
} }
// If changes are made, update the board date // If changes are made, update the board date
...@@ -427,7 +440,7 @@ bool PCB_EDIT_FRAME::SavePcbFile( const wxString& aFileName, bool aCreateBackupF ...@@ -427,7 +440,7 @@ bool PCB_EDIT_FRAME::SavePcbFile( const wxString& aFileName, bool aCreateBackupF
SetTitleBlock( tb ); SetTitleBlock( tb );
} }
pcbFileName = GetScreen()->GetFileName(); pcbFileName = GetBoard()->GetFileName();
if( pcbFileName.GetExt().IsEmpty() ) if( pcbFileName.GetExt().IsEmpty() )
pcbFileName.SetExt( IO_MGR::GetFileExtension( (IO_MGR::PCB_FILE_T) wildcardIndex ) ); pcbFileName.SetExt( IO_MGR::GetFileExtension( (IO_MGR::PCB_FILE_T) wildcardIndex ) );
...@@ -500,7 +513,7 @@ bool PCB_EDIT_FRAME::SavePcbFile( const wxString& aFileName, bool aCreateBackupF ...@@ -500,7 +513,7 @@ bool PCB_EDIT_FRAME::SavePcbFile( const wxString& aFileName, bool aCreateBackupF
if( saveok ) if( saveok )
{ {
GetScreen()->SetFileName( pcbFileName.GetFullPath() ); GetBoard()->SetFileName( pcbFileName.GetFullPath() );
UpdateTitle(); UpdateTitle();
} }
...@@ -537,7 +550,7 @@ bool PCB_EDIT_FRAME::SavePcbFile( const wxString& aFileName, bool aCreateBackupF ...@@ -537,7 +550,7 @@ bool PCB_EDIT_FRAME::SavePcbFile( const wxString& aFileName, bool aCreateBackupF
bool PCB_EDIT_FRAME::doAutoSave() bool PCB_EDIT_FRAME::doAutoSave()
{ {
wxFileName tmpFileName = GetScreen()->GetFileName(); wxFileName tmpFileName = GetBoard()->GetFileName();
wxFileName fn = tmpFileName; wxFileName fn = tmpFileName;
// Auto save file name is the normal file name prepended with $. // Auto save file name is the normal file name prepended with $.
...@@ -549,13 +562,13 @@ bool PCB_EDIT_FRAME::doAutoSave() ...@@ -549,13 +562,13 @@ bool PCB_EDIT_FRAME::doAutoSave()
if( SavePcbFile( fn.GetFullPath(), NO_BACKUP_FILE ) ) if( SavePcbFile( fn.GetFullPath(), NO_BACKUP_FILE ) )
{ {
GetScreen()->SetModify(); GetScreen()->SetModify();
GetScreen()->SetFileName( tmpFileName.GetFullPath() ); GetBoard()->SetFileName( tmpFileName.GetFullPath() );
UpdateTitle(); UpdateTitle();
m_autoSaveState = false; m_autoSaveState = false;
return true; return true;
} }
GetScreen()->SetFileName( tmpFileName.GetFullPath() ); GetBoard()->SetFileName( tmpFileName.GetFullPath() );
return false; return false;
} }
...@@ -55,18 +55,18 @@ void GenDrillMapFile( BOARD* aPcb, FILE* aFile, const wxString& aFullFileName, ...@@ -55,18 +55,18 @@ void GenDrillMapFile( BOARD* aPcb, FILE* aFile, const wxString& aFullFileName,
case PLOT_FORMAT_GERBER: case PLOT_FORMAT_GERBER:
offset = auxoffset; offset = auxoffset;
plotter = new GERBER_PLOTTER(); plotter = new GERBER_PLOTTER();
plotter->SetViewport( offset, IU_PER_DECIMILS, scale, 0 ); plotter->SetViewport( offset, IU_PER_DECIMILS, scale, false );
break; break;
case PLOT_FORMAT_HPGL: // Scale for HPGL format. case PLOT_FORMAT_HPGL: // Scale for HPGL format.
{ {
HPGL_PLOTTER* hpgl_plotter = new HPGL_PLOTTER; HPGL_PLOTTER* hpgl_plotter = new HPGL_PLOTTER;
plotter = hpgl_plotter; plotter = hpgl_plotter;
hpgl_plotter->SetPenNumber( plot_opts.m_HPGLPenNum ); hpgl_plotter->SetPenNumber( plot_opts.GetHPGLPenNum() );
hpgl_plotter->SetPenSpeed( plot_opts.m_HPGLPenSpeed ); hpgl_plotter->SetPenSpeed( plot_opts.GetHPGLPenSpeed() );
hpgl_plotter->SetPenOverlap( 0 ); hpgl_plotter->SetPenOverlap( 0 );
plotter->SetPageSettings( aSheet ); plotter->SetPageSettings( aSheet );
plotter->SetViewport( offset, IU_PER_DECIMILS, scale, 0 ); plotter->SetViewport( offset, IU_PER_DECIMILS, scale, false );
} }
break; break;
...@@ -100,7 +100,7 @@ void GenDrillMapFile( BOARD* aPcb, FILE* aFile, const wxString& aFullFileName, ...@@ -100,7 +100,7 @@ void GenDrillMapFile( BOARD* aPcb, FILE* aFile, const wxString& aFullFileName,
PS_PLOTTER* ps_plotter = new PS_PLOTTER; PS_PLOTTER* ps_plotter = new PS_PLOTTER;
plotter = ps_plotter; plotter = ps_plotter;
ps_plotter->SetPageSettings( pageA4 ); ps_plotter->SetPageSettings( pageA4 );
plotter->SetViewport( offset, IU_PER_DECIMILS, scale, 0 ); plotter->SetViewport( offset, IU_PER_DECIMILS, scale, false );
} }
break; break;
...@@ -109,7 +109,7 @@ void GenDrillMapFile( BOARD* aPcb, FILE* aFile, const wxString& aFullFileName, ...@@ -109,7 +109,7 @@ void GenDrillMapFile( BOARD* aPcb, FILE* aFile, const wxString& aFullFileName,
DXF_PLOTTER* dxf_plotter = new DXF_PLOTTER; DXF_PLOTTER* dxf_plotter = new DXF_PLOTTER;
plotter = dxf_plotter; plotter = dxf_plotter;
plotter->SetPageSettings( aSheet ); plotter->SetPageSettings( aSheet );
plotter->SetViewport( offset, IU_PER_DECIMILS, scale, 0 ); plotter->SetViewport( offset, IU_PER_DECIMILS, scale, false );
} }
break; break;
...@@ -180,7 +180,7 @@ void GenDrillMapFile( BOARD* aPcb, FILE* aFile, const wxString& aFullFileName, ...@@ -180,7 +180,7 @@ void GenDrillMapFile( BOARD* aPcb, FILE* aFile, const wxString& aFullFileName,
// Plot title "Info" // Plot title "Info"
wxString Text = wxT( "Drill Map:" ); wxString Text = wxT( "Drill Map:" );
plotter->Text( wxPoint( plotX, plotY ), BLACK, Text, 0, plotter->Text( wxPoint( plotX, plotY ), UNSPECIFIED, Text, 0,
wxSize( (int) ( charSize * charScale ), wxSize( (int) ( charSize * charScale ),
(int) ( charSize * charScale ) ), (int) ( charSize * charScale ) ),
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER,
...@@ -232,7 +232,7 @@ void GenDrillMapFile( BOARD* aPcb, FILE* aFile, const wxString& aFullFileName, ...@@ -232,7 +232,7 @@ void GenDrillMapFile( BOARD* aPcb, FILE* aFile, const wxString& aFullFileName,
aToolListBuffer[ii].m_OvalCount ); aToolListBuffer[ii].m_OvalCount );
msg += FROM_UTF8( line ); msg += FROM_UTF8( line );
plotter->Text( wxPoint( plotX, y ), BLACK, plotter->Text( wxPoint( plotX, y ), UNSPECIFIED,
msg, msg,
0, wxSize( (int) ( charSize * charScale ), (int) ( charSize * charScale ) ), 0, wxSize( (int) ( charSize * charScale ), (int) ( charSize * charScale ) ),
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER,
......
...@@ -161,7 +161,7 @@ void DIALOG_GEN_MODULE_POSITION::OnOutputDirectoryBrowseClicked( wxCommandEvent& ...@@ -161,7 +161,7 @@ void DIALOG_GEN_MODULE_POSITION::OnOutputDirectoryBrowseClicked( wxCommandEvent&
if( dialog.ShowModal() == wxID_YES ) if( dialog.ShowModal() == wxID_YES )
{ {
wxString boardFilePath = ( (wxFileName) m_parent->GetScreen()->GetFileName()).GetPath(); wxString boardFilePath = ( (wxFileName) m_parent->GetBoard()->GetFileName()).GetPath();
if( !dirName.MakeRelativeTo( boardFilePath ) ) if( !dirName.MakeRelativeTo( boardFilePath ) )
wxMessageBox( _( "Cannot make path relative (target volume different from board file volume)!" ), wxMessageBox( _( "Cannot make path relative (target volume different from board file volume)!" ),
...@@ -193,7 +193,6 @@ void DIALOG_GEN_MODULE_POSITION::OnOKButton( wxCommandEvent& event ) ...@@ -193,7 +193,6 @@ void DIALOG_GEN_MODULE_POSITION::OnOKButton( wxCommandEvent& event )
bool DIALOG_GEN_MODULE_POSITION::CreateFiles() bool DIALOG_GEN_MODULE_POSITION::CreateFiles()
{ {
BOARD * brd = m_parent->GetBoard(); BOARD * brd = m_parent->GetBoard();
PCB_SCREEN * screen = m_parent->GetScreen();
wxFileName fn; wxFileName fn;
wxString msg; wxString msg;
wxString frontLayerName; wxString frontLayerName;
...@@ -201,7 +200,7 @@ bool DIALOG_GEN_MODULE_POSITION::CreateFiles() ...@@ -201,7 +200,7 @@ bool DIALOG_GEN_MODULE_POSITION::CreateFiles()
bool singleFile = OneFileOnly(); bool singleFile = OneFileOnly();
int fullcount = 0; int fullcount = 0;
fn = screen->GetFileName(); fn = m_parent->GetBoard()->GetFileName();
fn.SetPath( GetOutputDirectory() ); fn.SetPath( GetOutputDirectory() );
frontLayerName = brd->GetLayerName( LAYER_N_FRONT ); frontLayerName = brd->GetLayerName( LAYER_N_FRONT );
backLayerName = brd->GetLayerName( LAYER_N_BACK ); backLayerName = brd->GetLayerName( LAYER_N_BACK );
...@@ -250,7 +249,7 @@ bool DIALOG_GEN_MODULE_POSITION::CreateFiles() ...@@ -250,7 +249,7 @@ bool DIALOG_GEN_MODULE_POSITION::CreateFiles()
// Create the Back or Bottom side placement file // Create the Back or Bottom side placement file
fullcount = fpcount; fullcount = fpcount;
side = 0; side = 0;
fn = screen->GetFileName(); fn = brd->GetFileName();
fn.SetPath( GetOutputDirectory() ); fn.SetPath( GetOutputDirectory() );
fn.SetName( fn.GetName() + wxT( "-" ) + backLayerName ); fn.SetName( fn.GetName() + wxT( "-" ) + backLayerName );
fn.SetExt( wxT( "pos" ) ); fn.SetExt( wxT( "pos" ) );
...@@ -506,13 +505,13 @@ void PCB_EDIT_FRAME::GenFootprintsReport( wxCommandEvent& event ) ...@@ -506,13 +505,13 @@ void PCB_EDIT_FRAME::GenFootprintsReport( wxCommandEvent& event )
{ {
wxFileName fn; wxFileName fn;
wxString boardFilePath = ( (wxFileName) GetScreen()->GetFileName()).GetPath(); wxString boardFilePath = ( (wxFileName) GetBoard()->GetFileName()).GetPath();
wxDirDialog dirDialog( this, _( "Select Output Directory" ), boardFilePath ); wxDirDialog dirDialog( this, _( "Select Output Directory" ), boardFilePath );
if( dirDialog.ShowModal() == wxID_CANCEL ) if( dirDialog.ShowModal() == wxID_CANCEL )
return; return;
fn = GetScreen()->GetFileName(); fn = GetBoard()->GetFileName();
fn.SetPath( dirDialog.GetPath() ); fn.SetPath( dirDialog.GetPath() );
fn.SetExt( wxT( "rpt" ) ); fn.SetExt( wxT( "rpt" ) );
......
...@@ -129,7 +129,7 @@ void DIALOG_GENDRILL::GenDrillAndReportFiles() ...@@ -129,7 +129,7 @@ void DIALOG_GENDRILL::GenDrillAndReportFiles()
if( s_ToolListBuffer.size() > 0 ) // holes? if( s_ToolListBuffer.size() > 0 ) // holes?
{ {
fn = m_parent->GetScreen()->GetFileName(); fn = m_parent->GetBoard()->GetFileName();
layer_extend.Empty(); layer_extend.Empty();
if( gen_NPTH_holes ) if( gen_NPTH_holes )
...@@ -240,7 +240,7 @@ void DIALOG_GENDRILL::GenDrillAndReportFiles() ...@@ -240,7 +240,7 @@ void DIALOG_GENDRILL::GenDrillAndReportFiles()
if( m_Choice_Drill_Report->GetSelection() > 0 ) if( m_Choice_Drill_Report->GetSelection() > 0 )
{ {
fn = m_parent->GetScreen()->GetFileName(); fn = m_parent->GetBoard()->GetFileName();
GenDrillReport( fn.GetFullName() ); GenDrillReport( fn.GetFullName() );
} }
...@@ -607,22 +607,22 @@ void DIALOG_GENDRILL::GenDrillMap( const wxString aFileName, ...@@ -607,22 +607,22 @@ void DIALOG_GENDRILL::GenDrillMap( const wxString aFileName,
switch( format ) switch( format )
{ {
case PLOT_FORMAT_HPGL: case PLOT_FORMAT_HPGL:
ext = wxT( "plt" ); ext = HPGL_PLOTTER::GetDefaultFileExtension();
wildcard = _( "HPGL plot files (.plt)|*.plt" ); wildcard = _( "HPGL plot files (.plt)|*.plt" );
break; break;
case PLOT_FORMAT_POST: case PLOT_FORMAT_POST:
ext = wxT( "ps" ); ext = PS_PLOTTER::GetDefaultFileExtension();
wildcard = _( "PostScript files (.ps)|*.ps" ); wildcard = _( "PostScript files (.ps)|*.ps" );
break; break;
case PLOT_FORMAT_GERBER: case PLOT_FORMAT_GERBER:
ext = wxT( "pho" ); ext = GERBER_PLOTTER::GetDefaultFileExtension();
wildcard = _( "Gerber files (.pho)|*.pho" ); wildcard = _( "Gerber files (.pho)|*.pho" );
break; break;
case PLOT_FORMAT_DXF: case PLOT_FORMAT_DXF:
ext = wxT( "dxf" ); ext = DXF_PLOTTER::GetDefaultFileExtension();
wildcard = _( "DXF files (.dxf)|*.dxf" ); wildcard = _( "DXF files (.dxf)|*.dxf" );
break; break;
...@@ -693,7 +693,7 @@ void DIALOG_GENDRILL::GenDrillReport( const wxString aFileName ) ...@@ -693,7 +693,7 @@ void DIALOG_GENDRILL::GenDrillReport( const wxString aFileName )
} }
GenDrillReportFile( report_dest, m_parent->GetBoard(), GenDrillReportFile( report_dest, m_parent->GetBoard(),
m_parent->GetScreen()->GetFileName(), m_parent->GetBoard()->GetFileName(),
m_UnitDrillIsInch, m_UnitDrillIsInch,
s_HoleListBuffer, s_HoleListBuffer,
s_ToolListBuffer ); s_ToolListBuffer );
......
...@@ -51,7 +51,7 @@ bool PCB_EDIT_FRAME::Clear_Pcb( bool aQuery ) ...@@ -51,7 +51,7 @@ bool PCB_EDIT_FRAME::Clear_Pcb( bool aQuery )
SetCurItem( NULL ); SetCurItem( NULL );
// clear filename, to avoid overwriting an old file // clear filename, to avoid overwriting an old file
GetScreen()->GetFileName().Empty(); GetBoard()->SetFileName( wxEmptyString );
// preserve grid size accross call to InitDataPoints() // preserve grid size accross call to InitDataPoints()
...@@ -101,7 +101,7 @@ bool FOOTPRINT_EDIT_FRAME::Clear_Pcb( bool aQuery ) ...@@ -101,7 +101,7 @@ bool FOOTPRINT_EDIT_FRAME::Clear_Pcb( bool aQuery )
GetBoard()->m_Modules.DeleteAll(); GetBoard()->m_Modules.DeleteAll();
// init pointeurs et variables // init pointeurs et variables
GetScreen()->GetFileName().Empty(); GetBoard()->SetFileName( wxEmptyString );
SetCurItem( NULL ); SetCurItem( NULL );
......
...@@ -1204,5 +1204,11 @@ BOARD* PCB_IO::Load( const wxString& aFileName, BOARD* aAppendToMe, PROPERTIES* ...@@ -1204,5 +1204,11 @@ BOARD* PCB_IO::Load( const wxString& aFileName, BOARD* aAppendToMe, PROPERTIES*
PCB_PARSER parser( new FILE_LINE_READER( file.fp(), aFileName ), aAppendToMe ); PCB_PARSER parser( new FILE_LINE_READER( file.fp(), aFileName ), aAppendToMe );
return (BOARD*) parser.Parse(); BOARD* board = dynamic_cast<BOARD*>( parser.Parse() );
wxASSERT( board );
// Give the filename to the board if it's new
if( !aAppendToMe )
board->SetFileName( aFileName );
return board;
} }
...@@ -232,6 +232,10 @@ BOARD* LEGACY_PLUGIN::Load( const wxString& aFileName, BOARD* aAppendToMe, PROPE ...@@ -232,6 +232,10 @@ BOARD* LEGACY_PLUGIN::Load( const wxString& aFileName, BOARD* aAppendToMe, PROPE
m_board = aAppendToMe ? aAppendToMe : new BOARD(); m_board = aAppendToMe ? aAppendToMe : new BOARD();
// Give the filename to the board if it's new
if( !aAppendToMe )
m_board->SetFileName( aFileName );
// delete on exception, iff I own m_board, according to aAppendToMe // delete on exception, iff I own m_board, according to aAppendToMe
auto_ptr<BOARD> deleter( aAppendToMe ? NULL : m_board ); auto_ptr<BOARD> deleter( aAppendToMe ? NULL : m_board );
......
...@@ -472,7 +472,7 @@ void PCB_PARSER::parseGeneralSection() throw( IO_ERROR, PARSE_ERROR ) ...@@ -472,7 +472,7 @@ void PCB_PARSER::parseGeneralSection() throw( IO_ERROR, PARSE_ERROR )
break; break;
default: // Skip everything but the board thickness. default: // Skip everything but the board thickness.
wxLogDebug( wxT( "Skipping general section token %s " ), GetTokenString( token ) ); wxLogDebug( wxT( "Skipping general section token %s " ), GetChars( GetTokenString( token ) ) );
while( ( token = NextTok() ) != T_RIGHT ) while( ( token = NextTok() ) != T_RIGHT )
{ {
...@@ -1676,7 +1676,7 @@ TEXTE_MODULE* PCB_PARSER::parseTEXTE_MODULE() throw( IO_ERROR, PARSE_ERROR ) ...@@ -1676,7 +1676,7 @@ TEXTE_MODULE* PCB_PARSER::parseTEXTE_MODULE() throw( IO_ERROR, PARSE_ERROR )
{ {
wxCHECK_MSG( CurTok() == T_fp_text, NULL, wxCHECK_MSG( CurTok() == T_fp_text, NULL,
wxString::Format( wxT( "Cannot parse %s as TEXTE_MODULE at line %d, offset %d." ), wxString::Format( wxT( "Cannot parse %s as TEXTE_MODULE at line %d, offset %d." ),
GetTokenString( CurTok() ), CurLineNumber(), CurOffset() ) ); GetChars( GetTokenString( CurTok() ) ), CurLineNumber(), CurOffset() ) );
T token = NextTok(); T token = NextTok();
......
...@@ -73,47 +73,49 @@ static bool setInt( int* aInt, int aValue, int aMin, int aMax ) ...@@ -73,47 +73,49 @@ static bool setInt( int* aInt, int aValue, int aMin, int aMax )
return (temp == aValue); return (temp == aValue);
} }
// PCB_PLOT_PARAMS // PCB_PLOT_PARAMS
PCB_PLOT_PARAMS::PCB_PLOT_PARAMS() PCB_PLOT_PARAMS::PCB_PLOT_PARAMS()
{ {
layerSelection = LAYER_BACK | LAYER_FRONT m_layerSelection = LAYER_BACK | LAYER_FRONT
| SILKSCREEN_LAYER_FRONT | SILKSCREEN_LAYER_BACK; | SILKSCREEN_LAYER_FRONT | SILKSCREEN_LAYER_BACK;
useGerberExtensions = true; m_useGerberExtensions = true;
m_SkipNPTH_Pads = false; m_excludeEdgeLayer = true;
m_ExcludeEdgeLayer = true; m_lineWidth = g_DrawDefaultLineThickness;
m_PlotLineWidth = g_DrawDefaultLineThickness; m_plotFrameRef = false;
m_PlotFrameRef = false; m_plotViaOnMaskLayer = false;
m_PlotViaOnMaskLayer = false; m_mode = FILLED;
m_PlotMode = FILLED; m_useAuxOrigin = false;
useAuxOrigin = false;
m_HPGLPenNum = 1; m_HPGLPenNum = 1;
m_HPGLPenSpeed = 20; // this param is always in cm/s m_HPGLPenSpeed = 20; // this param is always in cm/s
m_HPGLPenDiam = 15; // in mils m_HPGLPenDiam = 15; // in mils
m_HPGLPenOvr = 2; // in mils m_HPGLPenOvr = 2; // in mils
m_PlotPSColorOpt = true; m_negative = false;
m_PlotPSNegative = false; m_A4Output = false;
psA4Output = false; m_plotReference = true;
m_PlotReference = true; m_plotValue = true;
m_PlotValue = true; m_plotOtherText = true;
m_PlotTextOther = true; m_plotInvisibleText = false;
m_PlotInvisibleTexts = false; m_plotPadsOnSilkLayer = false;
m_PlotPadsOnSilkLayer = false; m_subtractMaskFromSilk = false;
subtractMaskFromSilk = false; m_format = PLOT_FORMAT_GERBER;
m_PlotFormat = PLOT_FORMAT_GERBER; m_mirror = false;
m_PlotMirror = false; m_drillMarks = SMALL_DRILL_SHAPE;
m_DrillShapeOpt = SMALL_DRILL_SHAPE; m_autoScale = false;
m_AutoScale = false; m_scale = 1.0;
m_PlotScale = 1.0; m_scaleSelection = 1;
scaleSelection = 1; m_fineScaleAdjustX = 1.0;
m_FineScaleAdjustX = 1.0; m_fineScaleAdjustY = 1.0;
m_FineScaleAdjustY = 1.0; m_widthAdjust = 0.;
m_FineWidthAdjust = 0.; m_outputDirectory.clear();
outputDirectory = wxT( "" ); m_color = BLACK;
m_referenceColor = BLACK;
m_valueColor = BLACK;
m_textMode = PLOTTEXTMODE_PHANTOM;
} }
// PLEASE NOTE: only plot dialog options are processed
void PCB_PLOT_PARAMS::Format( OUTPUTFORMATTER* aFormatter, void PCB_PLOT_PARAMS::Format( OUTPUTFORMATTER* aFormatter,
int aNestLevel, int aControl ) const throw( IO_ERROR ) int aNestLevel, int aControl ) const throw( IO_ERROR )
{ {
...@@ -122,21 +124,21 @@ void PCB_PLOT_PARAMS::Format( OUTPUTFORMATTER* aFormatter, ...@@ -122,21 +124,21 @@ void PCB_PLOT_PARAMS::Format( OUTPUTFORMATTER* aFormatter,
aFormatter->Print( aNestLevel, "(%s\n", getTokenName( T_pcbplotparams ) ); aFormatter->Print( aNestLevel, "(%s\n", getTokenName( T_pcbplotparams ) );
aFormatter->Print( aNestLevel+1, "(%s %ld)\n", getTokenName( T_layerselection ), aFormatter->Print( aNestLevel+1, "(%s %ld)\n", getTokenName( T_layerselection ),
layerSelection ); long(m_layerSelection) );
aFormatter->Print( aNestLevel+1, "(%s %s)\n", getTokenName( T_usegerberextensions ), aFormatter->Print( aNestLevel+1, "(%s %s)\n", getTokenName( T_usegerberextensions ),
useGerberExtensions ? trueStr : falseStr ); m_useGerberExtensions ? trueStr : falseStr );
aFormatter->Print( aNestLevel+1, "(%s %s)\n", getTokenName( T_excludeedgelayer ), aFormatter->Print( aNestLevel+1, "(%s %s)\n", getTokenName( T_excludeedgelayer ),
m_ExcludeEdgeLayer ? trueStr : falseStr ); m_excludeEdgeLayer ? trueStr : falseStr );
aFormatter->Print( aNestLevel+1, "(%s %d)\n", getTokenName( T_linewidth ), aFormatter->Print( aNestLevel+1, "(%s %d)\n", getTokenName( T_linewidth ),
m_PlotLineWidth ); m_lineWidth );
aFormatter->Print( aNestLevel+1, "(%s %s)\n", getTokenName( T_plotframeref ), aFormatter->Print( aNestLevel+1, "(%s %s)\n", getTokenName( T_plotframeref ),
m_PlotFrameRef ? trueStr : falseStr ); m_plotFrameRef ? trueStr : falseStr );
aFormatter->Print( aNestLevel+1, "(%s %s)\n", getTokenName( T_viasonmask ), aFormatter->Print( aNestLevel+1, "(%s %s)\n", getTokenName( T_viasonmask ),
m_PlotViaOnMaskLayer ? trueStr : falseStr ); m_plotViaOnMaskLayer ? trueStr : falseStr );
aFormatter->Print( aNestLevel+1, "(%s %d)\n", getTokenName( T_mode ), aFormatter->Print( aNestLevel+1, "(%s %d)\n", getTokenName( T_mode ),
m_PlotMode ); m_mode );
aFormatter->Print( aNestLevel+1, "(%s %s)\n", getTokenName( T_useauxorigin ), aFormatter->Print( aNestLevel+1, "(%s %s)\n", getTokenName( T_useauxorigin ),
useAuxOrigin ? trueStr : falseStr ); m_useAuxOrigin ? trueStr : falseStr );
aFormatter->Print( aNestLevel+1, "(%s %d)\n", getTokenName( T_hpglpennumber ), aFormatter->Print( aNestLevel+1, "(%s %d)\n", getTokenName( T_hpglpennumber ),
m_HPGLPenNum ); m_HPGLPenNum );
aFormatter->Print( aNestLevel+1, "(%s %d)\n", getTokenName( T_hpglpenspeed ), aFormatter->Print( aNestLevel+1, "(%s %d)\n", getTokenName( T_hpglpenspeed ),
...@@ -145,34 +147,32 @@ void PCB_PLOT_PARAMS::Format( OUTPUTFORMATTER* aFormatter, ...@@ -145,34 +147,32 @@ void PCB_PLOT_PARAMS::Format( OUTPUTFORMATTER* aFormatter,
m_HPGLPenDiam ); m_HPGLPenDiam );
aFormatter->Print( aNestLevel+1, "(%s %d)\n", getTokenName( T_hpglpenoverlay ), aFormatter->Print( aNestLevel+1, "(%s %d)\n", getTokenName( T_hpglpenoverlay ),
m_HPGLPenOvr ); m_HPGLPenOvr );
aFormatter->Print( aNestLevel+1, "(%s %s)\n", getTokenName( T_pscolor ),
m_PlotPSColorOpt ? trueStr : falseStr );
aFormatter->Print( aNestLevel+1, "(%s %s)\n", getTokenName( T_psnegative ), aFormatter->Print( aNestLevel+1, "(%s %s)\n", getTokenName( T_psnegative ),
m_PlotPSNegative ? trueStr : falseStr ); m_negative ? trueStr : falseStr );
aFormatter->Print( aNestLevel+1, "(%s %s)\n", getTokenName( T_psa4output ), aFormatter->Print( aNestLevel+1, "(%s %s)\n", getTokenName( T_psa4output ),
psA4Output ? trueStr : falseStr ); m_A4Output ? trueStr : falseStr );
aFormatter->Print( aNestLevel+1, "(%s %s)\n", getTokenName( T_plotreference ), aFormatter->Print( aNestLevel+1, "(%s %s)\n", getTokenName( T_plotreference ),
m_PlotReference ? trueStr : falseStr ); m_plotReference ? trueStr : falseStr );
aFormatter->Print( aNestLevel+1, "(%s %s)\n", getTokenName( T_plotvalue ), aFormatter->Print( aNestLevel+1, "(%s %s)\n", getTokenName( T_plotvalue ),
m_PlotValue ? trueStr : falseStr ); m_plotValue ? trueStr : falseStr );
aFormatter->Print( aNestLevel+1, "(%s %s)\n", getTokenName( T_plotothertext ), aFormatter->Print( aNestLevel+1, "(%s %s)\n", getTokenName( T_plotothertext ),
m_PlotTextOther ? trueStr : falseStr ); m_plotOtherText ? trueStr : falseStr );
aFormatter->Print( aNestLevel+1, "(%s %s)\n", getTokenName( T_plotinvisibletext ), aFormatter->Print( aNestLevel+1, "(%s %s)\n", getTokenName( T_plotinvisibletext ),
m_PlotInvisibleTexts ? trueStr : falseStr ); m_plotInvisibleText ? trueStr : falseStr );
aFormatter->Print( aNestLevel+1, "(%s %s)\n", getTokenName( T_padsonsilk ), aFormatter->Print( aNestLevel+1, "(%s %s)\n", getTokenName( T_padsonsilk ),
m_PlotPadsOnSilkLayer ? trueStr : falseStr ); m_plotPadsOnSilkLayer ? trueStr : falseStr );
aFormatter->Print( aNestLevel+1, "(%s %s)\n", getTokenName( T_subtractmaskfromsilk ), aFormatter->Print( aNestLevel+1, "(%s %s)\n", getTokenName( T_subtractmaskfromsilk ),
subtractMaskFromSilk ? trueStr : falseStr ); m_subtractMaskFromSilk ? trueStr : falseStr );
aFormatter->Print( aNestLevel+1, "(%s %d)\n", getTokenName( T_outputformat ), aFormatter->Print( aNestLevel+1, "(%s %d)\n", getTokenName( T_outputformat ),
m_PlotFormat ); m_format );
aFormatter->Print( aNestLevel+1, "(%s %s)\n", getTokenName( T_mirror ), aFormatter->Print( aNestLevel+1, "(%s %s)\n", getTokenName( T_mirror ),
m_PlotMirror ? trueStr : falseStr ); m_mirror ? trueStr : falseStr );
aFormatter->Print( aNestLevel+1, "(%s %d)\n", getTokenName( T_drillshape ), aFormatter->Print( aNestLevel+1, "(%s %d)\n", getTokenName( T_drillshape ),
m_DrillShapeOpt ); m_drillMarks );
aFormatter->Print( aNestLevel+1, "(%s %d)\n", getTokenName( T_scaleselection ), aFormatter->Print( aNestLevel+1, "(%s %d)\n", getTokenName( T_scaleselection ),
scaleSelection ); m_scaleSelection );
aFormatter->Print( aNestLevel+1, "(%s %s)", getTokenName( T_outputdirectory ), aFormatter->Print( aNestLevel+1, "(%s %s)", getTokenName( T_outputdirectory ),
aFormatter->Quotew( outputDirectory ).c_str() ); aFormatter->Quotew( m_outputDirectory ).c_str() );
aFormatter->Print( 0, ")\n" ); aFormatter->Print( 0, ")\n" );
} }
...@@ -185,21 +185,21 @@ void PCB_PLOT_PARAMS::Parse( PCB_PLOT_PARAMS_PARSER* aParser ) throw( IO_ERROR, ...@@ -185,21 +185,21 @@ void PCB_PLOT_PARAMS::Parse( PCB_PLOT_PARAMS_PARSER* aParser ) throw( IO_ERROR,
bool PCB_PLOT_PARAMS::operator==( const PCB_PLOT_PARAMS &aPcbPlotParams ) const bool PCB_PLOT_PARAMS::operator==( const PCB_PLOT_PARAMS &aPcbPlotParams ) const
{ {
if( layerSelection != aPcbPlotParams.layerSelection ) if( m_layerSelection != aPcbPlotParams.m_layerSelection )
return false; return false;
if( useGerberExtensions != aPcbPlotParams.useGerberExtensions ) if( m_useGerberExtensions != aPcbPlotParams.m_useGerberExtensions )
return false; return false;
if( m_ExcludeEdgeLayer != aPcbPlotParams.m_ExcludeEdgeLayer ) if( m_excludeEdgeLayer != aPcbPlotParams.m_excludeEdgeLayer )
return false; return false;
if( m_PlotLineWidth != aPcbPlotParams.m_PlotLineWidth ) if( m_lineWidth != aPcbPlotParams.m_lineWidth )
return false; return false;
if( m_PlotFrameRef != aPcbPlotParams.m_PlotFrameRef ) if( m_plotFrameRef != aPcbPlotParams.m_plotFrameRef )
return false; return false;
if( m_PlotViaOnMaskLayer != aPcbPlotParams.m_PlotViaOnMaskLayer ) if( m_plotViaOnMaskLayer != aPcbPlotParams.m_plotViaOnMaskLayer )
return false; return false;
if( m_PlotMode != aPcbPlotParams.m_PlotMode ) if( m_mode != aPcbPlotParams.m_mode )
return false; return false;
if( useAuxOrigin != aPcbPlotParams.useAuxOrigin ) if( m_useAuxOrigin != aPcbPlotParams.m_useAuxOrigin )
return false; return false;
if( m_HPGLPenNum != aPcbPlotParams.m_HPGLPenNum ) if( m_HPGLPenNum != aPcbPlotParams.m_HPGLPenNum )
return false; return false;
...@@ -209,33 +209,49 @@ bool PCB_PLOT_PARAMS::operator==( const PCB_PLOT_PARAMS &aPcbPlotParams ) const ...@@ -209,33 +209,49 @@ bool PCB_PLOT_PARAMS::operator==( const PCB_PLOT_PARAMS &aPcbPlotParams ) const
return false; return false;
if( m_HPGLPenOvr != aPcbPlotParams.m_HPGLPenOvr ) if( m_HPGLPenOvr != aPcbPlotParams.m_HPGLPenOvr )
return false; return false;
if( m_PlotPSColorOpt != aPcbPlotParams.m_PlotPSColorOpt ) if( m_negative != aPcbPlotParams.m_negative )
return false;
if( m_A4Output != aPcbPlotParams.m_A4Output )
return false;
if( m_plotReference != aPcbPlotParams.m_plotReference )
return false;
if( m_plotValue != aPcbPlotParams.m_plotValue )
return false;
if( m_plotOtherText != aPcbPlotParams.m_plotOtherText )
return false; return false;
if( m_PlotPSNegative != aPcbPlotParams.m_PlotPSNegative ) if( m_plotInvisibleText != aPcbPlotParams.m_plotInvisibleText )
return false; return false;
if( psA4Output != aPcbPlotParams.psA4Output ) if( m_plotPadsOnSilkLayer != aPcbPlotParams.m_plotPadsOnSilkLayer )
return false; return false;
if( m_PlotReference != aPcbPlotParams.m_PlotReference ) if( m_subtractMaskFromSilk != aPcbPlotParams.m_subtractMaskFromSilk )
return false; return false;
if( m_PlotValue != aPcbPlotParams.m_PlotValue ) if( m_format != aPcbPlotParams.m_format )
return false; return false;
if( m_PlotTextOther != aPcbPlotParams.m_PlotTextOther ) if( m_mirror != aPcbPlotParams.m_mirror )
return false; return false;
if( m_PlotInvisibleTexts != aPcbPlotParams.m_PlotInvisibleTexts ) if( m_drillMarks != aPcbPlotParams.m_drillMarks )
return false; return false;
if( m_PlotPadsOnSilkLayer != aPcbPlotParams.m_PlotPadsOnSilkLayer ) if( m_scaleSelection != aPcbPlotParams.m_scaleSelection )
return false; return false;
if( subtractMaskFromSilk != aPcbPlotParams.subtractMaskFromSilk ) if( m_autoScale != aPcbPlotParams.m_autoScale )
return false; return false;
if( m_PlotFormat != aPcbPlotParams.m_PlotFormat ) if( m_scale != aPcbPlotParams.m_scale )
return false; return false;
if( m_PlotMirror != aPcbPlotParams.m_PlotMirror ) if( m_fineScaleAdjustX != aPcbPlotParams.m_fineScaleAdjustX )
return false; return false;
if( m_DrillShapeOpt != aPcbPlotParams.m_DrillShapeOpt ) if( m_fineScaleAdjustY != aPcbPlotParams.m_fineScaleAdjustY )
return false; return false;
if( scaleSelection != aPcbPlotParams.scaleSelection ) if( m_widthAdjust != aPcbPlotParams.m_widthAdjust )
return false; return false;
if( !outputDirectory.IsSameAs( aPcbPlotParams.outputDirectory ) ) if( m_color != aPcbPlotParams.m_color )
return false;
if( m_referenceColor != aPcbPlotParams.m_referenceColor )
return false;
if( m_valueColor != aPcbPlotParams.m_valueColor )
return false;
if( m_textMode != aPcbPlotParams.m_textMode )
return false;
if( !m_outputDirectory.IsSameAs( aPcbPlotParams.m_outputDirectory ) )
return false; return false;
return true; return true;
} }
...@@ -247,30 +263,29 @@ bool PCB_PLOT_PARAMS::operator!=( const PCB_PLOT_PARAMS &aPcbPlotParams ) const ...@@ -247,30 +263,29 @@ bool PCB_PLOT_PARAMS::operator!=( const PCB_PLOT_PARAMS &aPcbPlotParams ) const
} }
bool PCB_PLOT_PARAMS::SetHpglPenDiameter( int aValue ) bool PCB_PLOT_PARAMS::SetHPGLPenDiameter( int aValue )
{ {
return setInt( &m_HPGLPenDiam, aValue, HPGL_PEN_DIAMETER_MIN, HPGL_PEN_DIAMETER_MAX ); return setInt( &m_HPGLPenDiam, aValue, HPGL_PEN_DIAMETER_MIN, HPGL_PEN_DIAMETER_MAX );
} }
bool PCB_PLOT_PARAMS::SetHpglPenSpeed( int aValue ) bool PCB_PLOT_PARAMS::SetHPGLPenSpeed( int aValue )
{ {
return setInt( &m_HPGLPenSpeed, aValue, HPGL_PEN_SPEED_MIN, HPGL_PEN_SPEED_MAX ); return setInt( &m_HPGLPenSpeed, aValue, HPGL_PEN_SPEED_MIN, HPGL_PEN_SPEED_MAX );
} }
bool PCB_PLOT_PARAMS::SetHpglPenOverlay( int aValue ) bool PCB_PLOT_PARAMS::SetHPGLPenOverlay( int aValue )
{ {
return setInt( &m_HPGLPenOvr, aValue, HPGL_PEN_OVERLAP_MIN, HPGL_PEN_OVERLAP_MAX ); return setInt( &m_HPGLPenOvr, aValue, HPGL_PEN_OVERLAP_MIN, HPGL_PEN_OVERLAP_MAX );
} }
bool PCB_PLOT_PARAMS::SetPlotLineWidth( int aValue ) bool PCB_PLOT_PARAMS::SetLineWidth( int aValue )
{ {
return setInt( &m_PlotLineWidth, aValue, PLOT_LINEWIDTH_MIN, PLOT_LINEWIDTH_MAX ); return setInt( &m_lineWidth, aValue, PLOT_LINEWIDTH_MIN, PLOT_LINEWIDTH_MAX );
} }
// PCB_PLOT_PARAMS_PARSER // PCB_PLOT_PARAMS_PARSER
PCB_PLOT_PARAMS_PARSER::PCB_PLOT_PARAMS_PARSER( LINE_READER* aReader ) : PCB_PLOT_PARAMS_PARSER::PCB_PLOT_PARAMS_PARSER( LINE_READER* aReader ) :
...@@ -305,32 +320,32 @@ void PCB_PLOT_PARAMS_PARSER::Parse( PCB_PLOT_PARAMS* aPcbPlotParams ) throw( IO_ ...@@ -305,32 +320,32 @@ void PCB_PLOT_PARAMS_PARSER::Parse( PCB_PLOT_PARAMS* aPcbPlotParams ) throw( IO_
token = NextTok(); token = NextTok();
if( token != T_NUMBER ) if( token != T_NUMBER )
Expecting( T_NUMBER ); Expecting( T_NUMBER );
aPcbPlotParams->layerSelection = atol( CurText() ); aPcbPlotParams->m_layerSelection = atol( CurText() );
break; break;
case T_usegerberextensions: case T_usegerberextensions:
aPcbPlotParams->useGerberExtensions = ParseBool(); aPcbPlotParams->m_useGerberExtensions = ParseBool();
break; break;
case T_psa4output: case T_psa4output:
aPcbPlotParams->psA4Output = ParseBool(); aPcbPlotParams->m_A4Output = ParseBool();
break; break;
case T_excludeedgelayer: case T_excludeedgelayer:
aPcbPlotParams->m_ExcludeEdgeLayer = ParseBool(); aPcbPlotParams->m_excludeEdgeLayer = ParseBool();
break; break;
case T_linewidth: case T_linewidth:
aPcbPlotParams->m_PlotLineWidth = ParseInt( PLOT_LINEWIDTH_MIN, aPcbPlotParams->m_lineWidth = ParseInt( PLOT_LINEWIDTH_MIN,
PLOT_LINEWIDTH_MAX ); PLOT_LINEWIDTH_MAX );
break; break;
case T_plotframeref: case T_plotframeref:
aPcbPlotParams->m_PlotFrameRef = ParseBool(); aPcbPlotParams->m_plotFrameRef = ParseBool();
break; break;
case T_viasonmask: case T_viasonmask:
aPcbPlotParams->m_PlotViaOnMaskLayer = ParseBool(); aPcbPlotParams->m_plotViaOnMaskLayer = ParseBool();
break; break;
case T_mode: case T_mode:
aPcbPlotParams->m_PlotMode = (EDA_DRAW_MODE_T)ParseInt( 0, 2 ); aPcbPlotParams->m_mode = static_cast<EDA_DRAW_MODE_T>( ParseInt( 0, 2 ) );
break; break;
case T_useauxorigin: case T_useauxorigin:
aPcbPlotParams->useAuxOrigin = ParseBool(); aPcbPlotParams->m_useAuxOrigin = ParseBool();
break; break;
case T_hpglpennumber: case T_hpglpennumber:
aPcbPlotParams->m_HPGLPenNum = ParseInt( HPGL_PEN_NUMBER_MIN, aPcbPlotParams->m_HPGLPenNum = ParseInt( HPGL_PEN_NUMBER_MIN,
...@@ -349,44 +364,44 @@ void PCB_PLOT_PARAMS_PARSER::Parse( PCB_PLOT_PARAMS* aPcbPlotParams ) throw( IO_ ...@@ -349,44 +364,44 @@ void PCB_PLOT_PARAMS_PARSER::Parse( PCB_PLOT_PARAMS* aPcbPlotParams ) throw( IO_
HPGL_PEN_OVERLAP_MAX ); HPGL_PEN_OVERLAP_MAX );
break; break;
case T_pscolor: case T_pscolor:
aPcbPlotParams->m_PlotPSColorOpt = ParseBool(); NeedSYMBOL(); // This actually was never used...
break; break;
case T_psnegative: case T_psnegative:
aPcbPlotParams->m_PlotPSNegative = ParseBool(); aPcbPlotParams->m_negative = ParseBool();
break; break;
case T_plotreference: case T_plotreference:
aPcbPlotParams->m_PlotReference = ParseBool(); aPcbPlotParams->m_plotReference = ParseBool();
break; break;
case T_plotvalue: case T_plotvalue:
aPcbPlotParams->m_PlotValue = ParseBool(); aPcbPlotParams->m_plotValue = ParseBool();
break; break;
case T_plotothertext: case T_plotothertext:
aPcbPlotParams->m_PlotTextOther = ParseBool(); aPcbPlotParams->m_plotOtherText = ParseBool();
break; break;
case T_plotinvisibletext: case T_plotinvisibletext:
aPcbPlotParams->m_PlotInvisibleTexts = ParseBool(); aPcbPlotParams->m_plotInvisibleText = ParseBool();
break; break;
case T_padsonsilk: case T_padsonsilk:
aPcbPlotParams->m_PlotPadsOnSilkLayer= ParseBool(); aPcbPlotParams->m_plotPadsOnSilkLayer= ParseBool();
break; break;
case T_subtractmaskfromsilk: case T_subtractmaskfromsilk:
aPcbPlotParams->subtractMaskFromSilk = ParseBool(); aPcbPlotParams->m_subtractMaskFromSilk = ParseBool();
break; break;
case T_outputformat: case T_outputformat:
aPcbPlotParams->m_PlotFormat = ParseInt( 0, 3 ); aPcbPlotParams->m_format = static_cast<PlotFormat>( ParseInt( 0, 3 ) );
break; break;
case T_mirror: case T_mirror:
aPcbPlotParams->m_PlotMirror = ParseBool(); aPcbPlotParams->m_mirror = ParseBool();
break; break;
case T_drillshape: case T_drillshape:
aPcbPlotParams->m_DrillShapeOpt = (PCB_PLOT_PARAMS::DrillShapeOptT) ParseInt( 0, 2 ); aPcbPlotParams->m_drillMarks = static_cast<PCB_PLOT_PARAMS::DrillMarksType>( ParseInt( 0, 2 ) );
break; break;
case T_scaleselection: case T_scaleselection:
aPcbPlotParams->scaleSelection = ParseInt( 0, 4 ); aPcbPlotParams->m_scaleSelection = ParseInt( 0, 4 );
break; break;
case T_outputdirectory: case T_outputdirectory:
NeedSYMBOL(); NeedSYMBOL();
aPcbPlotParams->outputDirectory = FROM_UTF8( CurText() ); aPcbPlotParams->m_outputDirectory = FROM_UTF8( CurText() );
break; break;
default: default:
Unexpected( CurText() ); Unexpected( CurText() );
......
...@@ -26,6 +26,8 @@ ...@@ -26,6 +26,8 @@
#include <wx/wx.h> #include <wx/wx.h>
#include <pcb_plot_params_lexer.h> #include <pcb_plot_params_lexer.h>
#include <eda_text.h> // EDA_DRAW_MODE_T #include <eda_text.h> // EDA_DRAW_MODE_T
#include <plot_common.h>
#include <layers_id_colors_and_visibility.h>
class PCB_PLOT_PARAMS_PARSER; class PCB_PLOT_PARAMS_PARSER;
class LINE_READER; class LINE_READER;
...@@ -39,64 +41,110 @@ class PCB_PLOT_PARAMS ...@@ -39,64 +41,110 @@ class PCB_PLOT_PARAMS
{ {
friend class PCB_PLOT_PARAMS_PARSER; friend class PCB_PLOT_PARAMS_PARSER;
public: public:
bool m_ExcludeEdgeLayer; ///< True: do not plot edge layer when plotting other layers enum DrillMarksType {
///< False: Edge layer always plotted (merged) when plotting other layers
int m_PlotLineWidth;
bool m_PlotFrameRef; ///< True to plot/print frame references
bool m_PlotViaOnMaskLayer; ///< True if vias are drawn on Mask layer
///< (ie protected by mask)
EDA_DRAW_MODE_T m_PlotMode; ///< LINE, FILLED or SKETCH: select how to plot filled objects.
///< depending on plot format or layers, all options are not always allowed
int m_HPGLPenNum; ///< HPGL only: pen number selection(1 to 9)
int m_HPGLPenSpeed; ///< HPGL only: pen speed, always in cm/s (1 to 99 cm/s)
int m_HPGLPenDiam; ///< HPGL only: pen diameter in MILS, usefull to fill areas
int m_HPGLPenOvr; ///< HPGL only: pen overlay in MILS, usefull only to fill areas
int m_PlotPSColorOpt; ///< True for color Postscript output
bool m_PlotPSNegative; ///< True to create a negative board ps plot
// Flags to enable or disable ploting of various PCB elements.
bool m_SkipNPTH_Pads; ///< true to disable plot NPTH pads if hole and size have same value
///< GERBER only
bool m_PlotReference;
bool m_PlotValue;
bool m_PlotTextOther;
bool m_PlotInvisibleTexts;
bool m_PlotPadsOnSilkLayer; ///< allows pads outlines on silkscreen layer (when pads are also o, silk screen
int m_PlotFormat; ///< id for plot format (see enum PlotFormat in plot_common.h) */
bool m_PlotMirror;
enum DrillShapeOptT {
NO_DRILL_SHAPE = 0, NO_DRILL_SHAPE = 0,
SMALL_DRILL_SHAPE = 1, SMALL_DRILL_SHAPE = 1,
FULL_DRILL_SHAPE = 2 FULL_DRILL_SHAPE = 2
}; };
DrillShapeOptT m_DrillShapeOpt; ///< For postscript output: holes can be not plotted,
///< or have a small size or plotted with their actual size
bool m_AutoScale; ///< If true, use the better scale to fit in page
double m_PlotScale; ///< The global scale factor. a 1.0 scale factor plot a board
///< with its actual size.
// These next two scale factors are intended to compensable plotters (and mainly printers) X and Y scale error. private:
// Therefore they are expected very near 1.0 /** LINE, FILLED or SKETCH selects how to plot filled objects.
// Only X and Y dimensions are adjusted: circles are plotted as circle, even if X and Y fine scale differ. * FILLED is not available with all drivers */
EDA_DRAW_MODE_T m_mode;
/// Plot format type (chooses the driver to be used)
PlotFormat m_format;
double m_FineScaleAdjustX; ///< fine scale adjust X axis /// Holes can be not plotted, have a small mark or plotted in actual size
double m_FineScaleAdjustY; ///< dine scale adjust Y axis DrillMarksType m_drillMarks;
/// This width factor is intended to compensate printers and plotters that do /// Choose how represent text with PS, PDF and DXF drivers
/// not strictly obey line width settings. PlotTextMode m_textMode;
double m_FineWidthAdjust;
private: /// The default line width (used for the frame and in LINE mode)
long layerSelection; int m_lineWidth;
bool useGerberExtensions;
bool useAuxOrigin; /// When true set the scale to fit the board in the page
bool subtractMaskFromSilk; bool m_autoScale;
bool psA4Output;
int scaleSelection; /// Global scale factor, 1.0 plots a board with its actual size.
wxString outputDirectory; double m_scale;
/// Mirror the plot around the X axis
bool m_mirror;
/// Plot in negative color (supported only by some drivers)
bool m_negative;
/// True if vias are drawn on Mask layer (ie untented, *exposed* by mask)
bool m_plotViaOnMaskLayer;
/// True to plot/print frame references
bool m_plotFrameRef;
/// If false always plot (merge) the pcb edge layer on other layers
bool m_excludeEdgeLayer;
/// Set of layers to plot
long m_layerSelection;
/** When plotting gerbers use a conventional set of extensions instead of
* appending a suffix to the board name */
bool m_useGerberExtensions;
/// Plot gerbers using auxiliary (drill) origin instead of page coordinates
bool m_useAuxOrigin;
/// On gerbers 'scrape' away the solder mask from silkscreen (trim silks)
bool m_subtractMaskFromSilk;
/// Autoscale the plot to fit an A4 (landscape?) sheet
bool m_A4Output;
/// Scale ratio index (UI only)
int m_scaleSelection;
/// Output directory for plot files (usually relative to the board file)
wxString m_outputDirectory;
/// Enable plotting of part references
bool m_plotReference;
/// Enable plotting of part values
bool m_plotValue;
/// Enable plotting of other fields
bool m_plotOtherText;
/// Force plotting of fields marked invisible
bool m_plotInvisibleText;
/// Allows pads outlines on silkscreen layer
/// (when pads are also on silk screen)
bool m_plotPadsOnSilkLayer;
/* These next two scale factors are intended to compensate plotters
* (mainly printers) X and Y scale error. Therefore they are expected very
* near 1.0; only X and Y dimensions are adjusted: circles are plotted as
* circles, even if X and Y fine scale differ; because of this it is mostly
* useful for printers: postscript plots would be best adjusted using
* the prologue (that would change the whole output matrix */
double m_fineScaleAdjustX; ///< fine scale adjust X axis
double m_fineScaleAdjustY; ///< fine scale adjust Y axis
/** This width factor is intended to compensate printers and plotters that do
* not strictly obey line width settings. Only used for pads and zone
* filling AFAIK */
double m_widthAdjust;
int m_HPGLPenNum; ///< HPGL only: pen number selection(1 to 9)
int m_HPGLPenSpeed; ///< HPGL only: pen speed, always in cm/s (1 to 99 cm/s)
int m_HPGLPenDiam; ///< HPGL only: pen diameter in MILS, useful to fill areas
int m_HPGLPenOvr; ///< HPGL only: pen overlay in MILS, useful only to fill areas
EDA_COLOR_T m_color; ///< Color for plotting the current layer
EDA_COLOR_T m_referenceColor; ///< Color for plotting references
EDA_COLOR_T m_valueColor; ///< Color for plotting values
public: public:
PCB_PLOT_PARAMS(); PCB_PLOT_PARAMS();
...@@ -107,31 +155,76 @@ public: ...@@ -107,31 +155,76 @@ public:
bool operator==( const PCB_PLOT_PARAMS &aPcbPlotParams ) const; bool operator==( const PCB_PLOT_PARAMS &aPcbPlotParams ) const;
bool operator!=( const PCB_PLOT_PARAMS &aPcbPlotParams ) const; bool operator!=( const PCB_PLOT_PARAMS &aPcbPlotParams ) const;
void SetPlotFormat( int aFormat ) { m_PlotFormat = aFormat; }; void SetColor( EDA_COLOR_T aVal ) { m_color = aVal; }
int GetPlotFormat() const { return m_PlotFormat; }; EDA_COLOR_T GetColor() const { return m_color; }
void SetOutputDirectory( wxString aDir ) { outputDirectory = aDir; }; void SetReferenceColor( EDA_COLOR_T aVal ) { m_referenceColor = aVal; }
wxString GetOutputDirectory() const { return outputDirectory; }; EDA_COLOR_T GetReferenceColor() const { return m_referenceColor; }
void SetUseGerberExtensions( bool aUse ) { useGerberExtensions = aUse; }; void SetValueColor( EDA_COLOR_T aVal ) { m_valueColor = aVal; }
bool GetUseGerberExtensions() const { return useGerberExtensions; }; EDA_COLOR_T GetValueColor() const { return m_valueColor; }
void SetSubtractMaskFromSilk( bool aSubtract ) { subtractMaskFromSilk = aSubtract; }; void SetTextMode( PlotTextMode aVal ) { m_textMode = aVal; }
bool GetSubtractMaskFromSilk() const { return subtractMaskFromSilk; }; PlotTextMode GetTextMode() const { return m_textMode; }
void SetLayerSelection( long aSelection ) { layerSelection = aSelection; }; void SetMode( EDA_DRAW_MODE_T aVal ) { m_mode = aVal; }
long GetLayerSelection() const { return layerSelection; }; EDA_DRAW_MODE_T GetMode() const { return m_mode; }
void SetUseAuxOrigin( bool aAux ) { useAuxOrigin = aAux; }; void SetDrillMarksType( DrillMarksType aVal ) { m_drillMarks = aVal; }
bool GetUseAuxOrigin() const { return useAuxOrigin; }; DrillMarksType GetDrillMarksType() const { return m_drillMarks; }
void SetScaleSelection( int aSelection ) { scaleSelection = aSelection; }; void SetScale( double aVal ) { m_scale = aVal; }
int GetScaleSelection() const { return scaleSelection; }; double GetScale() const { return m_scale; }
void SetPsA4Output( int aForce ) { psA4Output = aForce; }; void SetFineScaleAdjustX( double aVal ) { m_fineScaleAdjustX = aVal; }
bool GetPsA4Output() const { return psA4Output; }; double GetFineScaleAdjustX() const { return m_fineScaleAdjustX; }
void SetFineScaleAdjustY( double aVal ) { m_fineScaleAdjustY = aVal; }
int GetHpglPenDiameter() const { return m_HPGLPenDiam; }; double GetFineScaleAdjustY() const { return m_fineScaleAdjustY; }
bool SetHpglPenDiameter( int aValue ); void SetWidthAdjust( double aVal ) { m_widthAdjust = aVal; }
int GetHpglPenSpeed() const { return m_HPGLPenSpeed; }; double GetWidthAdjust() const { return m_widthAdjust; }
bool SetHpglPenSpeed( int aValue ); void SetAutoScale( bool aFlag ) { m_autoScale = aFlag; }
int GetHpglPenOverlay() const { return m_HPGLPenOvr; }; bool GetAutoScale() const { return m_autoScale; }
bool SetHpglPenOverlay( int aValue ); void SetMirror( bool aFlag ) { m_mirror = aFlag; }
int GetPlotLineWidth() const { return m_PlotLineWidth; }; bool GetMirror() const { return m_mirror; }
bool SetPlotLineWidth( int aValue ); void SetPlotPadsOnSilkLayer( bool aFlag ) { m_plotPadsOnSilkLayer = aFlag; }
bool GetPlotPadsOnSilkLayer() const { return m_plotPadsOnSilkLayer; }
void SetPlotInvisibleText( bool aFlag ) { m_plotInvisibleText = aFlag; }
bool GetPlotInvisibleText() const { return m_plotInvisibleText; }
void SetPlotOtherText( bool aFlag ) { m_plotOtherText = aFlag; }
bool GetPlotOtherText() const { return m_plotOtherText; }
void SetPlotValue( bool aFlag ) { m_plotValue = aFlag; }
bool GetPlotValue() const { return m_plotValue; }
void SetPlotReference( bool aFlag ) { m_plotReference = aFlag; }
bool GetPlotReference() const { return m_plotReference; }
void SetNegative( bool aFlag ) { m_negative = aFlag; }
bool GetNegative() const { return m_negative; }
void SetPlotViaOnMaskLayer( bool aFlag ) { m_plotViaOnMaskLayer = aFlag; }
bool GetPlotViaOnMaskLayer() const { return m_plotViaOnMaskLayer; }
void SetPlotFrameRef( bool aFlag ) { m_plotFrameRef = aFlag; }
bool GetPlotFrameRef() const { return m_plotFrameRef; }
void SetExcludeEdgeLayer( bool aFlag ) { m_excludeEdgeLayer = aFlag; }
bool GetExcludeEdgeLayer() const { return m_excludeEdgeLayer; }
void SetFormat( PlotFormat aFormat ) { m_format = aFormat; };
PlotFormat GetFormat() const { return m_format; };
void SetOutputDirectory( wxString aDir ) { m_outputDirectory = aDir; };
wxString GetOutputDirectory() const { return m_outputDirectory; };
void SetUseGerberExtensions( bool aUse ) { m_useGerberExtensions = aUse; };
bool GetUseGerberExtensions() const { return m_useGerberExtensions; };
void SetSubtractMaskFromSilk( bool aSubtract ) { m_subtractMaskFromSilk = aSubtract; };
bool GetSubtractMaskFromSilk() const { return m_subtractMaskFromSilk; };
void SetLayerSelection( long aSelection )
{ m_layerSelection = aSelection; };
long GetLayerSelection() const { return m_layerSelection; };
void SetUseAuxOrigin( bool aAux ) { m_useAuxOrigin = aAux; };
bool GetUseAuxOrigin() const { return m_useAuxOrigin; };
void SetScaleSelection( int aSelection ) { m_scaleSelection = aSelection; };
int GetScaleSelection() const { return m_scaleSelection; };
void SetA4Output( int aForce ) { m_A4Output = aForce; };
bool GetA4Output() const { return m_A4Output; };
int GetHPGLPenDiameter() const { return m_HPGLPenDiam; };
bool SetHPGLPenDiameter( int aValue );
int GetHPGLPenSpeed() const { return m_HPGLPenSpeed; };
bool SetHPGLPenSpeed( int aValue );
int GetHPGLPenOverlay() const { return m_HPGLPenOvr; };
bool SetHPGLPenOverlay( int aValue );
void SetHPGLPenNum( int aVal ) { m_HPGLPenNum = aVal; }
int GetHPGLPenNum() const { return m_HPGLPenNum; }
int GetLineWidth() const { return m_lineWidth; };
bool SetLineWidth( int aValue );
}; };
......
...@@ -482,7 +482,7 @@ void PCB_EDIT_FRAME::OnCloseWindow( wxCloseEvent& Event ) ...@@ -482,7 +482,7 @@ void PCB_EDIT_FRAME::OnCloseWindow( wxCloseEvent& Event )
{ {
wxString msg; wxString msg;
msg.Printf( _("Save the changes in\n<%s>\nbefore closing?"), msg.Printf( _("Save the changes in\n<%s>\nbefore closing?"),
GetChars( GetScreen()->GetFileName() ) ); GetChars( GetBoard()->GetFileName() ) );
int ii = DisplayExitDialog( this, msg ); int ii = DisplayExitDialog( this, msg );
switch( ii ) switch( ii )
...@@ -496,13 +496,13 @@ void PCB_EDIT_FRAME::OnCloseWindow( wxCloseEvent& Event ) ...@@ -496,13 +496,13 @@ void PCB_EDIT_FRAME::OnCloseWindow( wxCloseEvent& Event )
case wxID_OK: case wxID_OK:
case wxID_YES: case wxID_YES:
SavePcbFile( GetScreen()->GetFileName() ); SavePcbFile( GetBoard()->GetFileName() );
break; break;
} }
} }
// Delete the auto save file if it exists. // Delete the auto save file if it exists.
wxFileName fn = GetScreen()->GetFileName(); wxFileName fn = GetBoard()->GetFileName();
// Auto save file name is the normal file name prefixed with a '$'. // Auto save file name is the normal file name prefixed with a '$'.
fn.SetName( wxT( "$" ) + fn.GetName() ); fn.SetName( wxT( "$" ) + fn.GetName() );
...@@ -546,6 +546,7 @@ void PCB_EDIT_FRAME::Show3D_Frame( wxCommandEvent& event ) ...@@ -546,6 +546,7 @@ void PCB_EDIT_FRAME::Show3D_Frame( wxCommandEvent& event )
} }
m_Draw3DFrame = new EDA_3D_FRAME( this, _( "3D Viewer" ) ); m_Draw3DFrame = new EDA_3D_FRAME( this, _( "3D Viewer" ) );
m_Draw3DFrame->SetDefaultFileName( GetBoard()->GetFileName() );
m_Draw3DFrame->Show( true ); m_Draw3DFrame->Show( true );
} }
...@@ -726,7 +727,7 @@ void PCB_EDIT_FRAME::SetLanguage( wxCommandEvent& event ) ...@@ -726,7 +727,7 @@ void PCB_EDIT_FRAME::SetLanguage( wxCommandEvent& event )
wxString PCB_EDIT_FRAME::GetLastNetListRead() wxString PCB_EDIT_FRAME::GetLastNetListRead()
{ {
wxFileName absoluteFileName = m_lastNetListRead; wxFileName absoluteFileName = m_lastNetListRead;
wxFileName pcbFileName = GetScreen()->GetFileName(); wxFileName pcbFileName = GetBoard()->GetFileName();
if( !absoluteFileName.MakeAbsolute( pcbFileName.GetPath() ) || !absoluteFileName.FileExists() ) if( !absoluteFileName.MakeAbsolute( pcbFileName.GetPath() ) || !absoluteFileName.FileExists() )
{ {
...@@ -741,7 +742,7 @@ wxString PCB_EDIT_FRAME::GetLastNetListRead() ...@@ -741,7 +742,7 @@ wxString PCB_EDIT_FRAME::GetLastNetListRead()
void PCB_EDIT_FRAME::SetLastNetListRead( const wxString& aLastNetListRead ) void PCB_EDIT_FRAME::SetLastNetListRead( const wxString& aLastNetListRead )
{ {
wxFileName relativeFileName = aLastNetListRead; wxFileName relativeFileName = aLastNetListRead;
wxFileName pcbFileName = GetScreen()->GetFileName(); wxFileName pcbFileName = GetBoard()->GetFileName();
if( relativeFileName.MakeRelativeTo( pcbFileName.GetPath() ) if( relativeFileName.MakeRelativeTo( pcbFileName.GetPath() )
&& relativeFileName.GetFullPath() != aLastNetListRead ) && relativeFileName.GetFullPath() != aLastNetListRead )
...@@ -771,7 +772,7 @@ void PCB_EDIT_FRAME::SVG_Print( wxCommandEvent& event ) ...@@ -771,7 +772,7 @@ void PCB_EDIT_FRAME::SVG_Print( wxCommandEvent& event )
void PCB_EDIT_FRAME::UpdateTitle() void PCB_EDIT_FRAME::UpdateTitle()
{ {
wxString title; wxString title;
wxFileName fileName = GetScreen()->GetFileName(); wxFileName fileName = GetBoard()->GetFileName();
if( fileName.IsOk() && fileName.FileExists() ) if( fileName.IsOk() && fileName.FileExists() )
{ {
......
...@@ -182,14 +182,14 @@ Changing extension to .brd." ), GetChars( fn.GetFullPath() ) ); ...@@ -182,14 +182,14 @@ Changing extension to .brd." ), GetChars( fn.GetFullPath() ) );
else else
{ // File does not exists: prepare an empty board { // File does not exists: prepare an empty board
wxSetWorkingDirectory( fn.GetPath() ); wxSetWorkingDirectory( fn.GetPath() );
frame->GetScreen()->SetFileName( fn.GetFullPath( wxPATH_UNIX ) ); frame->GetBoard()->SetFileName( fn.GetFullPath( wxPATH_UNIX ) );
frame->UpdateTitle(); frame->UpdateTitle();
frame->UpdateFileHistory( frame->GetScreen()->GetFileName() ); frame->UpdateFileHistory( frame->GetBoard()->GetFileName() );
frame->OnModify(); // Ready to save the new empty board frame->OnModify(); // Ready to save the new empty board
wxString msg; wxString msg;
msg.Printf( _( "File <%s> does not exist.\nThis is normal for a new project" ), msg.Printf( _( "File <%s> does not exist.\nThis is normal for a new project" ),
GetChars( frame->GetScreen()->GetFileName() ) ); GetChars( frame->GetBoard()->GetFileName() ) );
wxMessageBox( msg ); wxMessageBox( msg );
} }
} }
......
...@@ -105,7 +105,7 @@ void PCB_EDIT_FRAME::Process_Config( wxCommandEvent& event ) ...@@ -105,7 +105,7 @@ void PCB_EDIT_FRAME::Process_Config( wxCommandEvent& event )
case ID_CONFIG_READ: case ID_CONFIG_READ:
{ {
fn = GetScreen()->GetFileName(); fn = GetBoard()->GetFileName();
fn.SetExt( ProjectFileExtension ); fn.SetExt( ProjectFileExtension );
wxFileDialog dlg( this, _( "Read Project File" ), fn.GetPath(), wxFileDialog dlg( this, _( "Read Project File" ), fn.GetPath(),
...@@ -204,7 +204,7 @@ void PCB_EDIT_FRAME::SaveProjectSettings() ...@@ -204,7 +204,7 @@ void PCB_EDIT_FRAME::SaveProjectSettings()
{ {
wxFileName fn; wxFileName fn;
fn = GetScreen()->GetFileName(); fn = GetBoard()->GetFileName();
fn.SetExt( ProjectFileExtension ); fn.SetExt( ProjectFileExtension );
wxFileDialog dlg( this, _( "Save Project File" ), fn.GetPath(), fn.GetFullName(), wxFileDialog dlg( this, _( "Save Project File" ), fn.GetPath(), fn.GetFullName(),
...@@ -391,7 +391,7 @@ void PCB_EDIT_FRAME::SaveMacros() ...@@ -391,7 +391,7 @@ void PCB_EDIT_FRAME::SaveMacros()
wxXmlProperty *macrosProp, *hkProp, *xProp, *yProp; wxXmlProperty *macrosProp, *hkProp, *xProp, *yProp;
wxString str, hkStr, xStr, yStr; wxString str, hkStr, xStr, yStr;
fn = GetScreen()->GetFileName(); fn = GetBoard()->GetFileName();
fn.SetExt( MacrosFileExtension ); fn.SetExt( MacrosFileExtension );
wxFileDialog dlg( this, _( "Save Macros File" ), fn.GetPath(), fn.GetFullName(), wxFileDialog dlg( this, _( "Save Macros File" ), fn.GetPath(), fn.GetFullName(),
...@@ -437,7 +437,7 @@ void PCB_EDIT_FRAME::ReadMacros() ...@@ -437,7 +437,7 @@ void PCB_EDIT_FRAME::ReadMacros()
wxString str; wxString str;
wxFileName fn; wxFileName fn;
fn = GetScreen()->GetFileName(); fn = GetBoard()->GetFileName();
fn.SetExt( MacrosFileExtension ); fn.SetExt( MacrosFileExtension );
wxFileDialog dlg( this, _( "Read Macros File" ), fn.GetPath(), wxFileDialog dlg( this, _( "Read Macros File" ), fn.GetPath(),
......
...@@ -46,6 +46,9 @@ ...@@ -46,6 +46,9 @@
#include <protos.h> #include <protos.h>
#include <dialog_plot_base.h> #include <dialog_plot_base.h>
#include <pcb_plot_params.h> #include <pcb_plot_params.h>
#include <pcb_plot_params_lexer.h>
#include <plotcontroller.h>
#include <wx/ffile.h>
/* Keywords to r/w options in m_config */ /* Keywords to r/w options in m_config */
#define CONFIG_XFINESCALE_ADJ wxT( "PlotXFineScaleAdj" ) #define CONFIG_XFINESCALE_ADJ wxT( "PlotXFineScaleAdj" )
...@@ -56,7 +59,6 @@ ...@@ -56,7 +59,6 @@
#define MIN_SCALE 0.01 #define MIN_SCALE 0.01
#define MAX_SCALE 100.0 #define MAX_SCALE 100.0
static bool setDouble( double* aDouble, double aValue, double aMin, double aMax ) static bool setDouble( double* aDouble, double aValue, double aMin, double aMax )
{ {
if( aValue < aMin ) if( aValue < aMin )
...@@ -74,7 +76,135 @@ static bool setDouble( double* aDouble, double aValue, double aMin, double aMax ...@@ -74,7 +76,135 @@ static bool setDouble( double* aDouble, double aValue, double aMin, double aMax
return true; return true;
} }
/** Get the 'traditional' gerber extension depending on the layer */
static wxString GetGerberExtension( int layer )/*{{{*/
{
switch( layer )
{
case LAYER_N_FRONT:
return wxString( wxT( "gtl" ) );
case LAYER_N_2:
case LAYER_N_3:
case LAYER_N_4:
case LAYER_N_5:
case LAYER_N_6:
case LAYER_N_7:
case LAYER_N_8:
case LAYER_N_9:
case LAYER_N_10:
case LAYER_N_11:
case LAYER_N_12:
case LAYER_N_13:
case LAYER_N_14:
case LAYER_N_15:
// TODO: see if we use .gbr or a layer identifier (gb1 .. gbnn ?)
// according to the new internal layers designation
// (1 is the first internal layer from the front layer)
return wxString( wxT( "gbr" ) );
case LAYER_N_BACK:
return wxString( wxT( "gbl" ) );
case ADHESIVE_N_BACK:
return wxString( wxT( "gba" ) );
case ADHESIVE_N_FRONT:
return wxString( wxT( "gta" ) );
case SOLDERPASTE_N_BACK:
return wxString( wxT( "gbp" ) );
case SOLDERPASTE_N_FRONT:
return wxString( wxT( "gtp" ) );
case SILKSCREEN_N_BACK:
return wxString( wxT( "gbo" ) );
case SILKSCREEN_N_FRONT:
return wxString( wxT( "gto" ) );
case SOLDERMASK_N_BACK:
return wxString( wxT( "gbs" ) );
case SOLDERMASK_N_FRONT:
return wxString( wxT( "gts" ) );
case DRAW_N:
case COMMENT_N:
case ECO1_N:
case ECO2_N:
case EDGE_N:
default:
return wxString( wxT( "gbr" ) );
}
}/*}}}*/
/** Complete a plot filename: forces the output directory, add a suffix to the name
and sets the extension if specified */
static void BuildPlotFileName( wxFileName *aFilename, /*{{{*/
const wxString& aOutputDir,
wxString aSuffix,
const wxString& aExtension )
{
aFilename->SetPath( aOutputDir );
// Set the file extension
aFilename->SetExt( aExtension );
/* remove leading and trailing spaces if any from the suffix, if
something survives add it to the name; also the suffix can contain
an extension: if that's the case, apply it */
aSuffix.Trim( true ); aSuffix.Trim( false );
wxFileName suffix_fn( aSuffix );
if( suffix_fn.HasName() )
aFilename->SetName( aFilename->GetName() + wxT( "-" ) + suffix_fn.GetName() );
if( suffix_fn.HasExt() )
aFilename->SetExt( suffix_fn.GetExt() );
}/*}}}*/
/** Fix the output directory pathname to absolute and ensure it exists */
static bool EnsureOutputDirectory( wxFileName *aOutputDir, /*{{{*/
const wxString& aBoardFilename,
wxTextCtrl* aMessageBox )
{
wxString boardFilePath = wxFileName( aBoardFilename ).GetPath();
if( !aOutputDir->MakeAbsolute( boardFilePath ) )
{
wxString msg;
msg.Printf( _( "Cannot make %s absolute with respect to %s!" ),
GetChars( aOutputDir->GetPath() ),
GetChars( boardFilePath ) );
wxMessageBox( msg, _( "Plot" ), wxOK | wxICON_ERROR );
return false;
}
wxString outputPath( aOutputDir->GetPath() );
if( !wxFileName::DirExists( outputPath ) )
{
if( wxMkdir( outputPath ) )
{
if( aMessageBox )
{
wxString msg;
msg.Printf( _( "Directory %s created.\n" ), GetChars( outputPath ) );
aMessageBox->AppendText( msg );
return true;
}
}
else
{
wxMessageBox( _( "Cannot create output directory!" ),
_( "Plot" ), wxOK | wxICON_ERROR );
return false;
}
}
return true;
}/*}}}*/
/** /**
* Class DIALOG_PLOT * Class DIALOG_PLOT
...@@ -111,8 +241,6 @@ private: ...@@ -111,8 +241,6 @@ private:
}; };
//const int UNITS_MILS = 1000;
DIALOG_PLOT::DIALOG_PLOT( PCB_EDIT_FRAME* aParent ) : DIALOG_PLOT::DIALOG_PLOT( PCB_EDIT_FRAME* aParent ) :
DIALOG_PLOT_BASE( aParent ), DIALOG_PLOT_BASE( aParent ),
m_parent( aParent ), m_parent( aParent ),
...@@ -142,26 +270,26 @@ void DIALOG_PLOT::Init_Dialog() ...@@ -142,26 +270,26 @@ void DIALOG_PLOT::Init_Dialog()
m_WidthAdjustMinValue = -(m_board->GetDesignSettings().m_TrackMinWidth - 1); m_WidthAdjustMinValue = -(m_board->GetDesignSettings().m_TrackMinWidth - 1);
m_WidthAdjustMaxValue = m_board->GetSmallestClearanceValue() - 1; m_WidthAdjustMaxValue = m_board->GetSmallestClearanceValue() - 1;
m_plotFormatOpt->SetSelection( m_plotOpts.GetPlotFormat() ); m_plotFormatOpt->SetSelection( m_plotOpts.GetFormat() );
// Set units and value for HPGL pen size (this param in in mils). // Set units and value for HPGL pen size (this param in in mils).
AddUnitSymbol( *m_textPenSize, g_UserUnit ); AddUnitSymbol( *m_textPenSize, g_UserUnit );
msg = ReturnStringFromValue( g_UserUnit, msg = ReturnStringFromValue( g_UserUnit,
m_plotOpts.GetHpglPenDiameter() * IU_PER_MILS ); m_plotOpts.GetHPGLPenDiameter() * IU_PER_MILS );
m_HPGLPenSizeOpt->AppendText( msg ); m_HPGLPenSizeOpt->AppendText( msg );
// Units are *always* cm/s for HPGL pen speed, from 1 to 99. // Units are *always* cm/s for HPGL pen speed, from 1 to 99.
msg = ReturnStringFromValue( UNSCALED_UNITS, m_plotOpts.GetHpglPenSpeed() ); msg = ReturnStringFromValue( UNSCALED_UNITS, m_plotOpts.GetHPGLPenSpeed() );
m_HPGLPenSpeedOpt->AppendText( msg ); m_HPGLPenSpeedOpt->AppendText( msg );
// Set units and value for HPGL pen overlay (this param in in mils). // Set units and value for HPGL pen overlay (this param in in mils).
AddUnitSymbol( *m_textPenOvr, g_UserUnit ); AddUnitSymbol( *m_textPenOvr, g_UserUnit );
msg = ReturnStringFromValue( g_UserUnit, msg = ReturnStringFromValue( g_UserUnit,
m_plotOpts.GetHpglPenOverlay() * IU_PER_MILS ); m_plotOpts.GetHPGLPenOverlay() * IU_PER_MILS );
m_HPGLPenOverlayOpt->AppendText( msg ); m_HPGLPenOverlayOpt->AppendText( msg );
AddUnitSymbol( *m_textDefaultPenSize, g_UserUnit ); AddUnitSymbol( *m_textDefaultPenSize, g_UserUnit );
msg = ReturnStringFromValue( g_UserUnit, m_plotOpts.GetPlotLineWidth() ); msg = ReturnStringFromValue( g_UserUnit, m_plotOpts.GetLineWidth() );
m_linesWidth->AppendText( msg ); m_linesWidth->AppendText( msg );
// Set units for PS global width correction. // Set units for PS global width correction.
...@@ -187,8 +315,8 @@ void DIALOG_PLOT::Init_Dialog() ...@@ -187,8 +315,8 @@ void DIALOG_PLOT::Init_Dialog()
msg.Printf( wxT( "%f" ), To_User_Unit( g_UserUnit, m_PSWidthAdjust ) ); msg.Printf( wxT( "%f" ), To_User_Unit( g_UserUnit, m_PSWidthAdjust ) );
m_PSFineAdjustWidthOpt->AppendText( msg ); m_PSFineAdjustWidthOpt->AppendText( msg );
m_plotPSNegativeOpt->SetValue( m_plotOpts.m_PlotPSNegative ); m_plotPSNegativeOpt->SetValue( m_plotOpts.GetNegative() );
m_forcePSA4OutputOpt->SetValue( m_plotOpts.GetPsA4Output() ); m_forcePSA4OutputOpt->SetValue( m_plotOpts.GetA4Output() );
// List layers in same order than in setup layers dialog // List layers in same order than in setup layers dialog
// (Front or Top to Back or Bottom) // (Front or Top to Back or Bottom)
...@@ -215,44 +343,36 @@ void DIALOG_PLOT::Init_Dialog() ...@@ -215,44 +343,36 @@ void DIALOG_PLOT::Init_Dialog()
m_useGerberExtensions->SetValue( m_plotOpts.GetUseGerberExtensions() ); m_useGerberExtensions->SetValue( m_plotOpts.GetUseGerberExtensions() );
// Option for excluding contents of "Edges Pcb" layer // Option for excluding contents of "Edges Pcb" layer
m_excludeEdgeLayerOpt->SetValue( m_plotOpts.m_ExcludeEdgeLayer ); m_excludeEdgeLayerOpt->SetValue( m_plotOpts.GetExcludeEdgeLayer() );
m_subtractMaskFromSilk->SetValue( m_plotOpts.GetSubtractMaskFromSilk() ); m_subtractMaskFromSilk->SetValue( m_plotOpts.GetSubtractMaskFromSilk() );
// Option to plot page references: // Option to plot page references:
if( m_parent->GetPrintBorderAndTitleBlock() ) m_plotSheetRef->SetValue( m_plotOpts.GetPlotFrameRef() );
{
m_plotSheetRef->SetValue( m_plotOpts.m_PlotFrameRef );
}
else
{
m_plotSheetRef->Enable( false );
m_plotSheetRef->SetValue( false );
}
// Option to plot pads on silkscreen layers or all layers // Option to allow pads on silkscreen layers
m_plotPads_on_Silkscreen->SetValue( m_plotOpts.m_PlotPadsOnSilkLayer ); m_plotPads_on_Silkscreen->SetValue( m_plotOpts.GetPlotPadsOnSilkLayer() );
// Options to plot texts on footprints // Options to plot texts on footprints
m_plotModuleValueOpt->SetValue( m_plotOpts.m_PlotValue ); m_plotModuleValueOpt->SetValue( m_plotOpts.GetPlotValue() );
m_plotModuleRefOpt->SetValue( m_plotOpts.m_PlotReference ); m_plotModuleRefOpt->SetValue( m_plotOpts.GetPlotReference() );
m_plotTextOther->SetValue( m_plotOpts.m_PlotTextOther ); m_plotTextOther->SetValue( m_plotOpts.GetPlotOtherText() );
m_plotInvisibleText->SetValue( m_plotOpts.m_PlotInvisibleTexts ); m_plotInvisibleText->SetValue( m_plotOpts.GetPlotInvisibleText() );
// Options to plot pads and vias holes // Options to plot pads and vias holes
m_drillShapeOpt->SetSelection( m_plotOpts.m_DrillShapeOpt ); m_drillShapeOpt->SetSelection( m_plotOpts.GetDrillMarksType() );
// Scale option // Scale option
m_scaleOpt->SetSelection( m_plotOpts.GetScaleSelection() ); m_scaleOpt->SetSelection( m_plotOpts.GetScaleSelection() );
// Plot mode // Plot mode
m_plotModeOpt->SetSelection( m_plotOpts.m_PlotMode ); m_plotModeOpt->SetSelection( m_plotOpts.GetMode() );
// Plot mirror option // Plot mirror option
m_plotMirrorOpt->SetValue( m_plotOpts.m_PlotMirror ); m_plotMirrorOpt->SetValue( m_plotOpts.GetMirror() );
// Put vias on mask layer // Put vias on mask layer
m_plotNoViaOnMaskOpt->SetValue( m_plotOpts.m_PlotViaOnMaskLayer ); m_plotNoViaOnMaskOpt->SetValue( m_plotOpts.GetPlotViaOnMaskLayer() );
// Output directory // Output directory
m_outputDirectoryName->SetValue( m_plotOpts.GetOutputDirectory() ); m_outputDirectoryName->SetValue( m_plotOpts.GetOutputDirectory() );
...@@ -319,7 +439,7 @@ void DIALOG_PLOT::OnOutputDirectoryBrowseClicked( wxCommandEvent& event ) ...@@ -319,7 +439,7 @@ void DIALOG_PLOT::OnOutputDirectoryBrowseClicked( wxCommandEvent& event )
wxYES_NO | wxICON_QUESTION | wxYES_DEFAULT ); wxYES_NO | wxICON_QUESTION | wxYES_DEFAULT );
if( dialog.ShowModal() == wxID_YES ) { if( dialog.ShowModal() == wxID_YES ) {
wxString boardFilePath = ( (wxFileName) m_parent->GetScreen()->GetFileName()).GetPath(); wxString boardFilePath = ( (wxFileName) m_parent->GetBoard()->GetFileName()).GetPath();
if( !dirName.MakeRelativeTo( boardFilePath ) ) if( !dirName.MakeRelativeTo( boardFilePath ) )
wxMessageBox( _( "Cannot make path relative (target volume different from board file volume)!" ), wxMessageBox( _( "Cannot make path relative (target volume different from board file volume)!" ),
...@@ -335,37 +455,39 @@ void DIALOG_PLOT::SetPlotFormat( wxCommandEvent& event ) ...@@ -335,37 +455,39 @@ void DIALOG_PLOT::SetPlotFormat( wxCommandEvent& event )
switch( m_plotFormatOpt->GetSelection() ) switch( m_plotFormatOpt->GetSelection() )
{ {
case PLOT_FORMAT_POST: case PLOT_FORMAT_POST:
default:
m_drillShapeOpt->Enable( true ); m_drillShapeOpt->Enable( true );
m_plotModeOpt->Enable( true ); m_plotModeOpt->Enable( true );
m_plotMirrorOpt->Enable( true ); m_plotMirrorOpt->Enable( true );
m_useAuxOriginCheckBox->Enable( false ); m_useAuxOriginCheckBox->Enable( false );
m_useAuxOriginCheckBox->SetValue( false );
m_linesWidth->Enable( true ); m_linesWidth->Enable( true );
m_HPGLPenSizeOpt->Enable( false ); m_HPGLPenSizeOpt->Enable( false );
m_HPGLPenSpeedOpt->Enable( false ); m_HPGLPenSpeedOpt->Enable( false );
m_HPGLPenOverlayOpt->Enable( false ); m_HPGLPenOverlayOpt->Enable( false );
m_excludeEdgeLayerOpt->SetValue( false ); m_excludeEdgeLayerOpt->Enable( true );
m_excludeEdgeLayerOpt->Enable( false );
m_subtractMaskFromSilk->Enable( false ); m_subtractMaskFromSilk->Enable( false );
m_subtractMaskFromSilk->SetValue( false );
m_useGerberExtensions->Enable( false ); m_useGerberExtensions->Enable( false );
m_useGerberExtensions->SetValue( false );
m_scaleOpt->Enable( true ); m_scaleOpt->Enable( true );
m_fineAdjustXscaleOpt->Enable( true ); m_fineAdjustXscaleOpt->Enable( true );
m_fineAdjustYscaleOpt->Enable( true ); m_fineAdjustYscaleOpt->Enable( true );
m_PSFineAdjustWidthOpt->Enable( true ); m_PSFineAdjustWidthOpt->Enable( true );
m_plotPSNegativeOpt->Enable( true ); m_plotPSNegativeOpt->Enable( true );
m_forcePSA4OutputOpt->Enable( true );
m_PlotOptionsSizer->Hide( m_GerberOptionsSizer ); m_PlotOptionsSizer->Hide( m_GerberOptionsSizer );
m_PlotOptionsSizer->Hide( m_HPGLOptionsSizer ); m_PlotOptionsSizer->Hide( m_HPGLOptionsSizer );
m_PlotOptionsSizer->Show( m_PSOptionsSizer ); m_PlotOptionsSizer->Show( m_PSOptionsSizer );
Layout();
m_MainSizer->SetSizeHints( this );
break; break;
case PLOT_FORMAT_GERBER: case PLOT_FORMAT_GERBER:
m_drillShapeOpt->Enable( false ); m_drillShapeOpt->Enable( false );
m_plotModeOpt->SetSelection( 1 ); m_drillShapeOpt->SetSelection( 0 );
m_plotModeOpt->Enable( false ); m_plotModeOpt->Enable( false );
m_plotMirrorOpt->SetValue( false ); m_plotModeOpt->SetSelection( 1 );
m_plotMirrorOpt->Enable( false ); m_plotMirrorOpt->Enable( false );
m_plotMirrorOpt->SetValue( false );
m_useAuxOriginCheckBox->Enable( true ); m_useAuxOriginCheckBox->Enable( true );
m_linesWidth->Enable( true ); m_linesWidth->Enable( true );
m_HPGLPenSizeOpt->Enable( false ); m_HPGLPenSizeOpt->Enable( false );
...@@ -374,74 +496,89 @@ void DIALOG_PLOT::SetPlotFormat( wxCommandEvent& event ) ...@@ -374,74 +496,89 @@ void DIALOG_PLOT::SetPlotFormat( wxCommandEvent& event )
m_excludeEdgeLayerOpt->Enable( true ); m_excludeEdgeLayerOpt->Enable( true );
m_subtractMaskFromSilk->Enable( true ); m_subtractMaskFromSilk->Enable( true );
m_useGerberExtensions->Enable( true ); m_useGerberExtensions->Enable( true );
m_scaleOpt->SetSelection( 1 );
m_scaleOpt->Enable( false ); m_scaleOpt->Enable( false );
m_scaleOpt->SetSelection( 1 );
m_fineAdjustXscaleOpt->Enable( false ); m_fineAdjustXscaleOpt->Enable( false );
m_fineAdjustYscaleOpt->Enable( false ); m_fineAdjustYscaleOpt->Enable( false );
m_PSFineAdjustWidthOpt->Enable( false ); m_PSFineAdjustWidthOpt->Enable( false );
m_plotPSNegativeOpt->SetValue( false );
m_plotPSNegativeOpt->Enable( false ); m_plotPSNegativeOpt->Enable( false );
m_plotPSNegativeOpt->SetValue( false );
m_forcePSA4OutputOpt->Enable( false );
m_forcePSA4OutputOpt->SetValue( false );
m_PlotOptionsSizer->Show( m_GerberOptionsSizer ); m_PlotOptionsSizer->Show( m_GerberOptionsSizer );
m_PlotOptionsSizer->Hide( m_HPGLOptionsSizer ); m_PlotOptionsSizer->Hide( m_HPGLOptionsSizer );
m_PlotOptionsSizer->Hide( m_PSOptionsSizer ); m_PlotOptionsSizer->Hide( m_PSOptionsSizer );
Layout();
m_MainSizer->SetSizeHints( this );
break; break;
case PLOT_FORMAT_HPGL: case PLOT_FORMAT_HPGL:
m_plotMirrorOpt->Enable( true ); m_drillShapeOpt->Enable( true );
m_drillShapeOpt->Enable( false );
m_plotModeOpt->Enable( true ); m_plotModeOpt->Enable( true );
m_plotMirrorOpt->Enable( true );
m_useAuxOriginCheckBox->Enable( false ); m_useAuxOriginCheckBox->Enable( false );
m_useAuxOriginCheckBox->SetValue( false );
m_linesWidth->Enable( false ); m_linesWidth->Enable( false );
m_HPGLPenSizeOpt->Enable( true ); m_HPGLPenSizeOpt->Enable( true );
m_HPGLPenSpeedOpt->Enable( true ); m_HPGLPenSpeedOpt->Enable( true );
m_HPGLPenOverlayOpt->Enable( true ); m_HPGLPenOverlayOpt->Enable( true );
m_excludeEdgeLayerOpt->SetValue( false ); m_excludeEdgeLayerOpt->Enable( true );
m_excludeEdgeLayerOpt->Enable( false );
m_subtractMaskFromSilk->Enable( false ); m_subtractMaskFromSilk->Enable( false );
m_subtractMaskFromSilk->SetValue( false );
m_useGerberExtensions->Enable( false ); m_useGerberExtensions->Enable( false );
m_useGerberExtensions->SetValue( false );
m_scaleOpt->Enable( true ); m_scaleOpt->Enable( true );
m_fineAdjustXscaleOpt->Enable( false ); m_fineAdjustXscaleOpt->Enable( false );
m_fineAdjustYscaleOpt->Enable( false ); m_fineAdjustYscaleOpt->Enable( false );
m_PSFineAdjustWidthOpt->Enable( false ); m_PSFineAdjustWidthOpt->Enable( false );
m_plotPSNegativeOpt->SetValue( false ); m_plotPSNegativeOpt->SetValue( false );
m_plotPSNegativeOpt->Enable( false ); m_plotPSNegativeOpt->Enable( false );
m_forcePSA4OutputOpt->Enable( true );
m_PlotOptionsSizer->Hide( m_GerberOptionsSizer ); m_PlotOptionsSizer->Hide( m_GerberOptionsSizer );
m_PlotOptionsSizer->Show( m_HPGLOptionsSizer ); m_PlotOptionsSizer->Show( m_HPGLOptionsSizer );
m_PlotOptionsSizer->Hide( m_PSOptionsSizer ); m_PlotOptionsSizer->Hide( m_PSOptionsSizer );
Layout();
m_MainSizer->SetSizeHints( this );
break; break;
case PLOT_FORMAT_DXF: case PLOT_FORMAT_DXF:
m_drillShapeOpt->Enable( true );
m_plotModeOpt->Enable( true );
m_plotMirrorOpt->Enable( false ); m_plotMirrorOpt->Enable( false );
m_plotMirrorOpt->SetValue( false ); m_plotMirrorOpt->SetValue( false );
m_drillShapeOpt->Enable( false ); m_useAuxOriginCheckBox->Enable( true );
m_plotModeOpt->Enable( true );
m_useAuxOriginCheckBox->Enable( false );
m_linesWidth->Enable( false ); m_linesWidth->Enable( false );
m_HPGLPenSizeOpt->Enable( false ); m_HPGLPenSizeOpt->Enable( false );
m_HPGLPenSpeedOpt->Enable( false ); m_HPGLPenSpeedOpt->Enable( false );
m_HPGLPenOverlayOpt->Enable( false ); m_HPGLPenOverlayOpt->Enable( false );
m_excludeEdgeLayerOpt->SetValue( false ); m_excludeEdgeLayerOpt->Enable( true );
m_excludeEdgeLayerOpt->Enable( false );
m_subtractMaskFromSilk->Enable( false ); m_subtractMaskFromSilk->Enable( false );
m_subtractMaskFromSilk->SetValue( false );
m_useGerberExtensions->Enable( false ); m_useGerberExtensions->Enable( false );
m_useGerberExtensions->SetValue( false );
m_scaleOpt->Enable( false ); m_scaleOpt->Enable( false );
m_scaleOpt->SetSelection( 1 ); m_scaleOpt->SetSelection( 1 );
m_fineAdjustXscaleOpt->Enable( false ); m_fineAdjustXscaleOpt->Enable( false );
m_fineAdjustYscaleOpt->Enable( false ); m_fineAdjustYscaleOpt->Enable( false );
m_PSFineAdjustWidthOpt->Enable( false ); m_PSFineAdjustWidthOpt->Enable( false );
m_plotPSNegativeOpt->SetValue( false );
m_plotPSNegativeOpt->Enable( false ); m_plotPSNegativeOpt->Enable( false );
m_PlotOptionsSizer->Hide( m_GerberOptionsSizer ); m_plotPSNegativeOpt->SetValue( false );
m_forcePSA4OutputOpt->Enable( false );
m_forcePSA4OutputOpt->SetValue( false );
m_PlotOptionsSizer->Show( m_GerberOptionsSizer );
m_PlotOptionsSizer->Hide( m_HPGLOptionsSizer ); m_PlotOptionsSizer->Hide( m_HPGLOptionsSizer );
m_PlotOptionsSizer->Hide( m_PSOptionsSizer ); m_PlotOptionsSizer->Hide( m_PSOptionsSizer );
Layout();
m_MainSizer->SetSizeHints( this );
break; break;
default:
wxASSERT( false );
} }
/* Update the interlock between scale and frame reference
* (scaling would mess up the frame border...) */
OnSetScaleOpt( event );
Layout();
m_MainSizer->SetSizeHints( this );
} }
...@@ -449,29 +586,28 @@ void DIALOG_PLOT::applyPlotSettings() ...@@ -449,29 +586,28 @@ void DIALOG_PLOT::applyPlotSettings()
{ {
PCB_PLOT_PARAMS tempOptions; PCB_PLOT_PARAMS tempOptions;
tempOptions.m_ExcludeEdgeLayer = m_excludeEdgeLayerOpt->GetValue(); tempOptions.SetExcludeEdgeLayer( m_excludeEdgeLayerOpt->GetValue() );
tempOptions.SetSubtractMaskFromSilk( m_subtractMaskFromSilk->GetValue() ); tempOptions.SetSubtractMaskFromSilk( m_subtractMaskFromSilk->GetValue() );
if( m_plotSheetRef ) tempOptions.SetPlotFrameRef( m_plotSheetRef->GetValue() );
tempOptions.m_PlotFrameRef = m_plotSheetRef->GetValue();
tempOptions.m_PlotPadsOnSilkLayer = m_plotPads_on_Silkscreen->GetValue(); tempOptions.SetPlotPadsOnSilkLayer( m_plotPads_on_Silkscreen->GetValue() );
tempOptions.SetUseAuxOrigin( m_useAuxOriginCheckBox->GetValue() ); tempOptions.SetUseAuxOrigin( m_useAuxOriginCheckBox->GetValue() );
tempOptions.m_PlotValue = m_plotModuleValueOpt->GetValue(); tempOptions.SetPlotValue( m_plotModuleValueOpt->GetValue() );
tempOptions.m_PlotReference = m_plotModuleRefOpt->GetValue(); tempOptions.SetPlotReference( m_plotModuleRefOpt->GetValue() );
tempOptions.m_PlotTextOther = m_plotTextOther->GetValue(); tempOptions.SetPlotOtherText( m_plotTextOther->GetValue() );
tempOptions.m_PlotInvisibleTexts = m_plotInvisibleText->GetValue(); tempOptions.SetPlotInvisibleText( m_plotInvisibleText->GetValue() );
tempOptions.SetScaleSelection( m_scaleOpt->GetSelection() ); tempOptions.SetScaleSelection( m_scaleOpt->GetSelection() );
tempOptions.m_DrillShapeOpt = tempOptions.SetDrillMarksType( static_cast<PCB_PLOT_PARAMS::DrillMarksType>
(PCB_PLOT_PARAMS::DrillShapeOptT) m_drillShapeOpt->GetSelection(); ( m_drillShapeOpt->GetSelection() ) );
tempOptions.m_PlotMirror = m_plotMirrorOpt->GetValue(); tempOptions.SetMirror( m_plotMirrorOpt->GetValue() );
tempOptions.m_PlotMode = (EDA_DRAW_MODE_T) m_plotModeOpt->GetSelection(); tempOptions.SetMode( static_cast<EDA_DRAW_MODE_T>( m_plotModeOpt->GetSelection() ) );
tempOptions.m_PlotViaOnMaskLayer = m_plotNoViaOnMaskOpt->GetValue(); tempOptions.SetPlotViaOnMaskLayer( m_plotNoViaOnMaskOpt->GetValue() );
// Update settings from text fields. Rewrite values back to the fields, // Update settings from text fields. Rewrite values back to the fields,
// since the values may have been constrained by the setters. // since the values may have been constrained by the setters.
...@@ -480,9 +616,9 @@ void DIALOG_PLOT::applyPlotSettings() ...@@ -480,9 +616,9 @@ void DIALOG_PLOT::applyPlotSettings()
wxString msg = m_HPGLPenSizeOpt->GetValue(); wxString msg = m_HPGLPenSizeOpt->GetValue();
int tmp = ReturnValueFromString( g_UserUnit, msg ) / IU_PER_MILS; int tmp = ReturnValueFromString( g_UserUnit, msg ) / IU_PER_MILS;
if( !tempOptions.SetHpglPenDiameter( tmp ) ) if( !tempOptions.SetHPGLPenDiameter( tmp ) )
{ {
msg = ReturnStringFromValue( g_UserUnit, tempOptions.GetHpglPenDiameter() * IU_PER_MILS ); msg = ReturnStringFromValue( g_UserUnit, tempOptions.GetHPGLPenDiameter() * IU_PER_MILS );
m_HPGLPenSizeOpt->SetValue( msg ); m_HPGLPenSizeOpt->SetValue( msg );
msg.Printf( _( "HPGL pen size constrained!\n" ) ); msg.Printf( _( "HPGL pen size constrained!\n" ) );
m_messagesBox->AppendText( msg ); m_messagesBox->AppendText( msg );
...@@ -492,9 +628,9 @@ void DIALOG_PLOT::applyPlotSettings() ...@@ -492,9 +628,9 @@ void DIALOG_PLOT::applyPlotSettings()
msg = m_HPGLPenSpeedOpt->GetValue(); msg = m_HPGLPenSpeedOpt->GetValue();
tmp = ReturnValueFromString( UNSCALED_UNITS, msg ); tmp = ReturnValueFromString( UNSCALED_UNITS, msg );
if( !tempOptions.SetHpglPenSpeed( tmp ) ) if( !tempOptions.SetHPGLPenSpeed( tmp ) )
{ {
msg = ReturnStringFromValue( UNSCALED_UNITS, tempOptions.GetHpglPenSpeed() ); msg = ReturnStringFromValue( UNSCALED_UNITS, tempOptions.GetHPGLPenSpeed() );
m_HPGLPenSpeedOpt->SetValue( msg ); m_HPGLPenSpeedOpt->SetValue( msg );
msg.Printf( _( "HPGL pen speed constrained!\n" ) ); msg.Printf( _( "HPGL pen speed constrained!\n" ) );
m_messagesBox->AppendText( msg ); m_messagesBox->AppendText( msg );
...@@ -504,10 +640,10 @@ void DIALOG_PLOT::applyPlotSettings() ...@@ -504,10 +640,10 @@ void DIALOG_PLOT::applyPlotSettings()
msg = m_HPGLPenOverlayOpt->GetValue(); msg = m_HPGLPenOverlayOpt->GetValue();
tmp = ReturnValueFromString( g_UserUnit, msg ) / IU_PER_MILS; tmp = ReturnValueFromString( g_UserUnit, msg ) / IU_PER_MILS;
if( !tempOptions.SetHpglPenOverlay( tmp ) ) if( !tempOptions.SetHPGLPenOverlay( tmp ) )
{ {
msg = ReturnStringFromValue( g_UserUnit, msg = ReturnStringFromValue( g_UserUnit,
tempOptions.GetHpglPenOverlay() * IU_PER_MILS ); tempOptions.GetHPGLPenOverlay() * IU_PER_MILS );
m_HPGLPenOverlayOpt->SetValue( msg ); m_HPGLPenOverlayOpt->SetValue( msg );
msg.Printf( _( "HPGL pen overlay constrained!\n" ) ); msg.Printf( _( "HPGL pen overlay constrained!\n" ) );
m_messagesBox->AppendText( msg ); m_messagesBox->AppendText( msg );
...@@ -517,9 +653,9 @@ void DIALOG_PLOT::applyPlotSettings() ...@@ -517,9 +653,9 @@ void DIALOG_PLOT::applyPlotSettings()
msg = m_linesWidth->GetValue(); msg = m_linesWidth->GetValue();
tmp = ReturnValueFromString( g_UserUnit, msg ); tmp = ReturnValueFromString( g_UserUnit, msg );
if( !tempOptions.SetPlotLineWidth( tmp ) ) if( !tempOptions.SetLineWidth( tmp ) )
{ {
msg = ReturnStringFromValue( g_UserUnit, tempOptions.GetPlotLineWidth() ); msg = ReturnStringFromValue( g_UserUnit, tempOptions.GetLineWidth() );
m_linesWidth->SetValue( msg ); m_linesWidth->SetValue( msg );
msg.Printf( _( "Default linewidth constrained!\n" ) ); msg.Printf( _( "Default linewidth constrained!\n" ) );
m_messagesBox->AppendText( msg ); m_messagesBox->AppendText( msg );
...@@ -575,7 +711,7 @@ void DIALOG_PLOT::applyPlotSettings() ...@@ -575,7 +711,7 @@ void DIALOG_PLOT::applyPlotSettings()
tempOptions.SetUseGerberExtensions( m_useGerberExtensions->GetValue() ); tempOptions.SetUseGerberExtensions( m_useGerberExtensions->GetValue() );
tempOptions.SetPlotFormat( m_plotFormatOpt->GetSelection() ); tempOptions.SetFormat( static_cast<PlotFormat>( m_plotFormatOpt->GetSelection() ) );
long selectedLayers = 0; long selectedLayers = 0;
unsigned int i; unsigned int i;
...@@ -587,8 +723,8 @@ void DIALOG_PLOT::applyPlotSettings() ...@@ -587,8 +723,8 @@ void DIALOG_PLOT::applyPlotSettings()
} }
tempOptions.SetLayerSelection( selectedLayers ); tempOptions.SetLayerSelection( selectedLayers );
tempOptions.m_PlotPSNegative = m_plotPSNegativeOpt->GetValue(); tempOptions.SetNegative( m_plotPSNegativeOpt->GetValue() );
tempOptions.SetPsA4Output( m_forcePSA4OutputOpt->GetValue() ); tempOptions.SetA4Output( m_forcePSA4OutputOpt->GetValue() );
// Set output directory and replace backslashes with forward ones // Set output directory and replace backslashes with forward ones
wxString dirStr; wxString dirStr;
...@@ -608,63 +744,37 @@ void DIALOG_PLOT::applyPlotSettings() ...@@ -608,63 +744,37 @@ void DIALOG_PLOT::applyPlotSettings()
void DIALOG_PLOT::Plot( wxCommandEvent& event ) void DIALOG_PLOT::Plot( wxCommandEvent& event )
{ {
int layer; int layer;
wxFileName fn;
wxString ext;
applyPlotSettings(); applyPlotSettings();
// Create output directory if it does not exist // Create output directory if it does not exist (also transform it in
// absolute form). Bail if it fails
wxFileName outputDir = wxFileName::DirName( m_plotOpts.GetOutputDirectory() ); wxFileName outputDir = wxFileName::DirName( m_plotOpts.GetOutputDirectory() );
wxString boardFilePath = ( (wxFileName) m_parent->GetScreen()->GetFileName()).GetPath(); wxString boardFilename = m_parent->GetBoard()->GetFileName();
if( !EnsureOutputDirectory( &outputDir, boardFilename, m_messagesBox ) )
if( !outputDir.MakeAbsolute( boardFilePath ) )
{
wxString msg;
msg.Printf( _( " Cannot make %s absolute with respect to %s!" ),
GetChars( outputDir.GetPath() ),
GetChars( boardFilePath ) );
wxMessageBox( msg, _( "Plot" ), wxOK | wxICON_ERROR );
return; return;
}
if( !wxFileName::DirExists( outputDir.GetPath() ) )
{
if( wxMkdir( outputDir.GetPath() ) )
{
wxString msg;
msg.Printf( _( "Directory %s created.\n" ), GetChars( outputDir.GetPath() ) );
m_messagesBox->AppendText( msg );
}
else
{
wxMessageBox( _( "Cannot create output directory!" ),
_( "Plot" ), wxOK | wxICON_ERROR );
return;
}
}
m_plotOpts.m_AutoScale = false;
m_plotOpts.m_PlotScale = 1;
m_plotOpts.SetAutoScale( false );
m_plotOpts.SetScale( 1 );
switch( m_plotOpts.GetScaleSelection() ) switch( m_plotOpts.GetScaleSelection() )
{ {
default: default:
break; break;
case 0: case 0: // Autoscale option
m_plotOpts.m_AutoScale = true; m_plotOpts.SetAutoScale( true );
break; break;
case 2: case 2: // 3:2 option
m_plotOpts.m_PlotScale = 1.5; m_plotOpts.SetScale( 1.5 );
break; break;
case 3: case 3: // 2:1 option
m_plotOpts.m_PlotScale = 2; m_plotOpts.SetScale( 2 );
break; break;
case 4: case 4: // 3:1 option
m_plotOpts.m_PlotScale = 3; m_plotOpts.SetScale( 3 );
break; break;
} }
...@@ -674,176 +784,66 @@ void DIALOG_PLOT::Plot( wxCommandEvent& event ) ...@@ -674,176 +784,66 @@ void DIALOG_PLOT::Plot( wxCommandEvent& event )
* settings resulting in a divide by zero fault. * settings resulting in a divide by zero fault.
*/ */
if( m_fineAdjustXscaleOpt->IsEnabled() && m_XScaleAdjust != 0.0 ) if( m_fineAdjustXscaleOpt->IsEnabled() && m_XScaleAdjust != 0.0 )
m_plotOpts.m_FineScaleAdjustX = m_XScaleAdjust; m_plotOpts.SetFineScaleAdjustX( m_XScaleAdjust );
if( m_fineAdjustYscaleOpt->IsEnabled() && m_YScaleAdjust != 0.0 ) if( m_fineAdjustYscaleOpt->IsEnabled() && m_YScaleAdjust != 0.0 )
m_plotOpts.m_FineScaleAdjustY = m_YScaleAdjust; m_plotOpts.SetFineScaleAdjustY( m_YScaleAdjust );
if( m_PSFineAdjustWidthOpt->IsEnabled() ) if( m_PSFineAdjustWidthOpt->IsEnabled() )
m_plotOpts.m_FineWidthAdjust = m_PSWidthAdjust; m_plotOpts.SetWidthAdjust( m_PSWidthAdjust );
switch( m_plotOpts.GetPlotFormat() ) wxString file_ext( GetDefaultPlotExtension( m_plotOpts.GetFormat() ) );
{
case PLOT_FORMAT_POST:
ext = wxT( "ps" );
break;
case PLOT_FORMAT_GERBER:
m_plotOpts.m_PlotScale = 1.0; // No scale option allowed in gerber format
ext = wxT( "pho" );
break;
case PLOT_FORMAT_HPGL:
ext = wxT( "plt" );
break;
case PLOT_FORMAT_DXF:
m_plotOpts.m_PlotScale = 1.0;
ext = wxT( "dxf" );
break;
}
// Test for a reasonable scale value // Test for a reasonable scale value
if( m_plotOpts.m_PlotScale < MIN_SCALE ) // XXX could this actually happen? isn't it constrained in the apply
// function?
if( m_plotOpts.GetScale() < MIN_SCALE )
DisplayInfoMessage( this, DisplayInfoMessage( this,
_( "Warning: Scale option set to a very small value" ) ); _( "Warning: Scale option set to a very small value" ) );
if( m_plotOpts.m_PlotScale > MAX_SCALE ) if( m_plotOpts.GetScale() > MAX_SCALE )
DisplayInfoMessage( this, DisplayInfoMessage( this,
_( "Warning: Scale option set to a very large value" ) ); _( "Warning: Scale option set to a very large value" ) );
// Save the current plot options in the board
m_parent->SetPlotSettings( m_plotOpts ); m_parent->SetPlotSettings( m_plotOpts );
long layerMask = 1; long layerMask = 1;
for( layer = 0; layer < NB_LAYERS; layer++, layerMask <<= 1 ) for( layer = 0; layer < NB_LAYERS; layer++, layerMask <<= 1 )
{ {
bool success = false;
if( m_plotOpts.GetLayerSelection() & layerMask ) if( m_plotOpts.GetLayerSelection() & layerMask )
{ {
fn = m_parent->GetScreen()->GetFileName(); // Pick the basename from the board file
fn.SetPath( outputDir.GetPath() ); wxFileName fn( boardFilename );
// Create file name (from the English layer name for non copper layers).
wxString layername = m_board->GetLayerName( layer, false );
// remove leading and trailing spaces if any
layername.Trim( true ); layername.Trim( false );
fn.SetName( fn.GetName() + wxT( "-" ) + layername );
// Use Gerber Extensions based on layer number // Use Gerber Extensions based on layer number
// (See http://en.wikipedia.org/wiki/Gerber_File) // (See http://en.wikipedia.org/wiki/Gerber_File)
if( ( m_plotOpts.GetPlotFormat() == PLOT_FORMAT_GERBER ) if( ( m_plotOpts.GetFormat() == PLOT_FORMAT_GERBER )
&& m_useGerberExtensions->GetValue() ) && m_useGerberExtensions->GetValue() )
{ file_ext = GetGerberExtension( layer );
switch( layer )
{
case LAYER_N_FRONT:
fn.SetExt( wxT( "gtl" ) );
break;
case LAYER_N_2:
case LAYER_N_3:
case LAYER_N_4:
case LAYER_N_5:
case LAYER_N_6:
case LAYER_N_7:
case LAYER_N_8:
case LAYER_N_9:
case LAYER_N_10:
case LAYER_N_11:
case LAYER_N_12:
case LAYER_N_13:
case LAYER_N_14:
case LAYER_N_15:
// TODO: see if we use .gbr or a layer identifier (gb1 .. gbnn ?)
// according to the new internal layers designation
// (1 is the first internal layer from the front layer)
fn.SetExt( wxT( "gbr" ) );
break;
case LAYER_N_BACK:
fn.SetExt( wxT( "gbl" ) );
break;
case ADHESIVE_N_BACK:
fn.SetExt( wxT( "gba" ) );
break;
case ADHESIVE_N_FRONT:
fn.SetExt( wxT( "gta" ) );
break;
case SOLDERPASTE_N_BACK:
fn.SetExt( wxT( "gbp" ) );
break;
case SOLDERPASTE_N_FRONT:
fn.SetExt( wxT( "gtp" ) );
break;
case SILKSCREEN_N_BACK:
fn.SetExt( wxT( "gbo" ) );
break;
case SILKSCREEN_N_FRONT:
fn.SetExt( wxT( "gto" ) );
break;
case SOLDERMASK_N_BACK:
fn.SetExt( wxT( "gbs" ) );
break;
case SOLDERMASK_N_FRONT:
fn.SetExt( wxT( "gts" ) );
break;
case DRAW_N:
case COMMENT_N:
case ECO1_N:
case ECO2_N:
case EDGE_N:
default:
fn.SetExt( wxT( "gbr" ) );
break;
}
}
else
{
fn.SetExt( ext );
}
switch( m_plotOpts.GetPlotFormat() ) // Create file name (from the English layer name for non copper layers).
{ BuildPlotFileName( &fn, outputDir.GetPath(),
case PLOT_FORMAT_POST: m_board->GetLayerName( layer, false ),
success = m_parent->ExportToPostScriptFile( fn.GetFullPath(), layer, file_ext );
m_plotOpts.GetPsA4Output(),
m_plotOpts.m_PlotMode ); LOCALE_IO toggle;
break; BOARD *board = m_parent->GetBoard();
PLOTTER *plotter = StartPlotBoard(board, &m_plotOpts,
case PLOT_FORMAT_GERBER: fn.GetFullPath(),
success = m_parent->ExportToGerberFile( fn.GetFullPath(), layer, wxEmptyString );
m_plotOpts.GetUseAuxOrigin(),
m_plotOpts.m_PlotMode );
break;
case PLOT_FORMAT_HPGL:
success = m_parent->ExportToHpglFile( fn.GetFullPath(), layer,
m_plotOpts.m_PlotMode );
break;
case PLOT_FORMAT_DXF:
success = m_parent->ExportToDxfFile( fn.GetFullPath(), layer,
m_plotOpts.m_PlotMode );
break;
}
// Print diags in messages box: // Print diags in messages box:
wxString msg; wxString msg;
if( plotter )
{
PlotBoardLayer( board, plotter, layer, m_plotOpts );
plotter->EndPlot();
delete plotter;
if( success )
msg.Printf( _( "Plot file <%s> created" ), GetChars( fn.GetFullPath() ) ); msg.Printf( _( "Plot file <%s> created" ), GetChars( fn.GetFullPath() ) );
}
else else
msg.Printf( _( "Unable to create <%s>" ), GetChars( fn.GetFullPath() ) ); msg.Printf( _( "Unable to create <%s>" ), GetChars( fn.GetFullPath() ) );
...@@ -864,3 +864,81 @@ void PCB_EDIT_FRAME::ToPlotter( wxCommandEvent& event ) ...@@ -864,3 +864,81 @@ void PCB_EDIT_FRAME::ToPlotter( wxCommandEvent& event )
DIALOG_PLOT dlg( this ); DIALOG_PLOT dlg( this );
dlg.ShowModal(); dlg.ShowModal();
} }
/** Batch plotter constructor, nothing interesting here */
PLOT_CONTROLLER::PLOT_CONTROLLER( BOARD *aBoard )
: m_plotter( NULL ), m_board( aBoard )
{
}
/** Batch plotter destructor, ensures that the last plot is closed */
PLOT_CONTROLLER::~PLOT_CONTROLLER()
{
ClosePlot();
}
/* IMPORTANT THING TO KNOW: the locale during plots *MUST* be kept as
* C/POSIX using a LOCALE_IO object on the stack. This even when
* opening/closing the plotfile, since some drivers do I/O even then */
/** Close the current plot, nothing happens if it isn't open */
void PLOT_CONTROLLER::ClosePlot()
{
LOCALE_IO toggle;
if( m_plotter )
{
m_plotter->EndPlot();
delete m_plotter;
m_plotter = NULL;
}
}
/** Open a new plotfile; works as a factory for plotter objects
*/
bool PLOT_CONTROLLER::OpenPlotfile( const wxString &aSuffix, /*{{{*/
PlotFormat aFormat,
const wxString &aSheetDesc )
{
LOCALE_IO toggle;
/* Save the current format: sadly some plot routines depends on this
but the main reason is that the StartPlot method uses it to
dispatch the plotter creation */
m_plotOpts.SetFormat( aFormat );
// Ensure that the previous plot is closed
ClosePlot();
// Now compute the full filename for the output and start the plot
// (after ensuring the output directory is OK)
wxString outputDirName = m_plotOpts.GetOutputDirectory() ;
wxFileName outputDir = wxFileName::DirName( outputDirName );
wxString boardFilename = m_board->GetFileName();
if( EnsureOutputDirectory( &outputDir, boardFilename, NULL ) )
{
wxFileName fn( boardFilename );
BuildPlotFileName( &fn, outputDirName,
aSuffix, GetDefaultPlotExtension( aFormat ) );
m_plotter = StartPlotBoard( m_board, &m_plotOpts, fn.GetFullPath(),
aSheetDesc );
}
return( m_plotter != NULL );
}/*}}}*/
/** Plot a single layer on the current plotfile */
bool PLOT_CONTROLLER::PlotLayer( int aLayer )/*{{{*/
{
LOCALE_IO toggle;
// No plot open, nothing to do...
if( !m_plotter )
return false;
// Fully delegated to the parent
PlotBoardLayer( m_board, m_plotter, aLayer, m_plotOpts );
return true;
}/*}}}*/
...@@ -56,6 +56,46 @@ void Plot_1_EdgeModule( PLOTTER* plotter, const PCB_PLOT_PARAMS& aPlotOpts, EDGE ...@@ -56,6 +56,46 @@ void Plot_1_EdgeModule( PLOTTER* plotter, const PCB_PLOT_PARAMS& aPlotOpts, EDGE
void PlotFilledAreas( PLOTTER* plotter, const PCB_PLOT_PARAMS& aPlotOpts, ZONE_CONTAINER* aZone, void PlotFilledAreas( PLOTTER* plotter, const PCB_PLOT_PARAMS& aPlotOpts, ZONE_CONTAINER* aZone,
EDA_DRAW_MODE_T trace_mode ); EDA_DRAW_MODE_T trace_mode );
PLOTTER *StartPlotBoard( BOARD *aBoard,
PCB_PLOT_PARAMS *aPlotOpts,
const wxString& aFullFileName,
const wxString& aSheetDesc );
void PlotBoardLayer( BOARD *aBoard, PLOTTER* aPlotter, int Layer,
const PCB_PLOT_PARAMS& plot_opts );
/**
* Function Plot_Standard_Layer
* plot copper or technical layers.
* not used for silk screen layers, because these layers have specific
* requirements, mainly for pads
* @param aPlotter = the plotter to use
* @param aLayerMask = the mask to define the layers to plot
* @param aPlotVia = true to plot vias, false to skip vias (has meaning
* only for solder mask layers).
* @param aPlotMode = the plot mode (files, sketch). Has meaning for some formats only
* @param aSkipNPTH_Pads = true to skip NPTH Pads, when the pad size and the pad hole
* have the same size. Used in GERBER format only.
*/
void PlotStandardLayer( BOARD *aBoard, PLOTTER* aPlotter, long aLayerMask,
const PCB_PLOT_PARAMS& plot_opts,
bool aPlotVia, bool aSkipNPTH_Pads );
void PlotSilkScreen( BOARD *aBoard, PLOTTER* aPlotter, long aLayerMask,
const PCB_PLOT_PARAMS& plot_opts );
/**
* Function PlotDrillMarks
* Draw a drill mark for pads and vias.
* Must be called after all drawings, because it
* redraw the drill mark on a pad or via, as a negative (i.e. white) shape
* in FILLED plot mode
* @param aPlotter = the PLOTTER
* @param aPlotOpts = plot options
*/
void PlotDrillMarks( BOARD *aBoard, PLOTTER* aPlotter, const PCB_PLOT_PARAMS& aPlotOpts );
// PLOTGERB.CPP // PLOTGERB.CPP
void SelectD_CODE_For_LineDraw( PLOTTER* plotter, int aSize ); void SelectD_CODE_For_LineDraw( PLOTTER* plotter, int aSize );
......
...@@ -30,21 +30,22 @@ ...@@ -30,21 +30,22 @@
static void Plot_Edges_Modules( PLOTTER* aPlotter, const PCB_PLOT_PARAMS& aPlotOpts, static void Plot_Edges_Modules( PLOTTER* aPlotter, const PCB_PLOT_PARAMS& aPlotOpts,
BOARD* pcb, int aLayerMask, EDA_DRAW_MODE_T trace_mode ); BOARD* pcb, int aLayerMask, EDA_DRAW_MODE_T trace_mode );
static void PlotTextModule( PLOTTER* aPlotter, TEXTE_MODULE* pt_texte, EDA_DRAW_MODE_T trace_mode ); static void PlotTextModule( PLOTTER* aPlotter, TEXTE_MODULE* pt_texte,
EDA_DRAW_MODE_T trace_mode, EDA_COLOR_T aColor );
/* Creates the plot for silkscreen layers /* Creates the plot for silkscreen layers
*/ */
void PCB_BASE_FRAME::PlotSilkScreen( PLOTTER* aPlotter, int aLayerMask, EDA_DRAW_MODE_T trace_mode ) void PlotSilkScreen( BOARD *aBoard, PLOTTER* aPlotter, long aLayerMask,
const PCB_PLOT_PARAMS& plot_opts )
{ {
bool trace_val, trace_ref;
TEXTE_MODULE* pt_texte; TEXTE_MODULE* pt_texte;
const PCB_PLOT_PARAMS& plot_opts = GetPlotSettings(); EDA_DRAW_MODE_T trace_mode = plot_opts.GetMode();
// Plot edge layer and graphic items // Plot edge layer and graphic items
for( EDA_ITEM* item = m_Pcb->m_Drawings; item; item = item->Next() ) for( EDA_ITEM* item = aBoard->m_Drawings; item; item = item->Next() )
{ {
switch( item->Type() ) switch( item->Type() )
{ {
...@@ -68,24 +69,24 @@ void PCB_BASE_FRAME::PlotSilkScreen( PLOTTER* aPlotter, int aLayerMask, EDA_DRAW ...@@ -68,24 +69,24 @@ void PCB_BASE_FRAME::PlotSilkScreen( PLOTTER* aPlotter, int aLayerMask, EDA_DRAW
break; break;
default: default:
DisplayError( this, wxT( "PlotSilkScreen() error: unexpected Type()" ) ); DisplayError( NULL, wxT( "PlotSilkScreen() error: unexpected Type()" ) );
break; break;
} }
} }
// Plot footprint outlines : // Plot footprint outlines :
Plot_Edges_Modules( aPlotter, plot_opts, m_Pcb, aLayerMask, trace_mode ); Plot_Edges_Modules( aPlotter, plot_opts, aBoard, aLayerMask, trace_mode );
// Plot pads (creates pads outlines, for pads on silkscreen layers) // Plot pads (creates pads outlines, for pads on silkscreen layers)
int layersmask_plotpads = aLayerMask; int layersmask_plotpads = aLayerMask;
// Calculate the mask layers of allowed layers for pads // Calculate the mask layers of allowed layers for pads
if( !plot_opts.m_PlotPadsOnSilkLayer ) // Do not plot pads on silk screen layers if( !plot_opts.GetPlotPadsOnSilkLayer() ) // Do not plot pads on silk screen layers
layersmask_plotpads &= ~(SILKSCREEN_LAYER_BACK | SILKSCREEN_LAYER_FRONT ); layersmask_plotpads &= ~(SILKSCREEN_LAYER_BACK | SILKSCREEN_LAYER_FRONT );
if( layersmask_plotpads ) if( layersmask_plotpads )
{ {
for( MODULE* Module = m_Pcb->m_Modules; Module; Module = Module->Next() ) for( MODULE* Module = aBoard->m_Modules; Module; Module = Module->Next() )
{ {
for( D_PAD * pad = Module->m_Pads; pad != NULL; pad = pad->Next() ) for( D_PAD * pad = Module->m_Pads; pad != NULL; pad = pad->Next() )
{ {
...@@ -126,11 +127,11 @@ void PCB_BASE_FRAME::PlotSilkScreen( PLOTTER* aPlotter, int aLayerMask, EDA_DRAW ...@@ -126,11 +127,11 @@ void PCB_BASE_FRAME::PlotSilkScreen( PLOTTER* aPlotter, int aLayerMask, EDA_DRAW
} }
// Plot footprints fields (ref, value ...) // Plot footprints fields (ref, value ...)
for( MODULE* module = m_Pcb->m_Modules; module; module = module->Next() ) for( MODULE* module = aBoard->m_Modules; module; module = module->Next() )
{ {
// see if we want to plot VALUE and REF fields // see if we want to plot VALUE and REF fields
trace_val = plot_opts.m_PlotValue; bool trace_val = plot_opts.GetPlotValue();
trace_ref = plot_opts.m_PlotReference; bool trace_ref = plot_opts.GetPlotReference();
TEXTE_MODULE* text = module->m_Reference; TEXTE_MODULE* text = module->m_Reference;
unsigned textLayer = text->GetLayer(); unsigned textLayer = text->GetLayer();
...@@ -142,14 +143,14 @@ void PCB_BASE_FRAME::PlotSilkScreen( PLOTTER* aPlotter, int aLayerMask, EDA_DRAW ...@@ -142,14 +143,14 @@ void PCB_BASE_FRAME::PlotSilkScreen( PLOTTER* aPlotter, int aLayerMask, EDA_DRAW
errMsg.Printf( _( "Your BOARD has a bad layer number of %u for \ errMsg.Printf( _( "Your BOARD has a bad layer number of %u for \
module\n %s's \"reference\" text." ), module\n %s's \"reference\" text." ),
textLayer, GetChars( module->GetReference() ) ); textLayer, GetChars( module->GetReference() ) );
DisplayError( this, errMsg ); DisplayError( NULL, errMsg );
return; return;
} }
if( ( ( 1 << textLayer ) & aLayerMask ) == 0 ) if( ( ( 1 << textLayer ) & aLayerMask ) == 0 )
trace_ref = false; trace_ref = false;
if( !text->IsVisible() && !plot_opts.m_PlotInvisibleTexts ) if( !text->IsVisible() && !plot_opts.GetPlotInvisibleText() )
trace_ref = false; trace_ref = false;
text = module->m_Value; text = module->m_Value;
...@@ -162,22 +163,24 @@ module\n %s's \"reference\" text." ), ...@@ -162,22 +163,24 @@ module\n %s's \"reference\" text." ),
errMsg.Printf( _( "Your BOARD has a bad layer number of %u for \ errMsg.Printf( _( "Your BOARD has a bad layer number of %u for \
module\n %s's \"value\" text." ), module\n %s's \"value\" text." ),
textLayer, GetChars( module->GetReference() ) ); textLayer, GetChars( module->GetReference() ) );
DisplayError( this, errMsg ); DisplayError( NULL, errMsg );
return; return;
} }
if( ( (1 << textLayer) & aLayerMask ) == 0 ) if( ( (1 << textLayer) & aLayerMask ) == 0 )
trace_val = false; trace_val = false;
if( !text->IsVisible() && !plot_opts.m_PlotInvisibleTexts ) if( !text->IsVisible() && !plot_opts.GetPlotInvisibleText() )
trace_val = false; trace_val = false;
// Plot text fields, if allowed // Plot text fields, if allowed
if( trace_ref ) if( trace_ref )
PlotTextModule( aPlotter, module->m_Reference, trace_mode ); PlotTextModule( aPlotter, module->m_Reference,
trace_mode, plot_opts.GetReferenceColor() );
if( trace_val ) if( trace_val )
PlotTextModule( aPlotter, module->m_Value, trace_mode ); PlotTextModule( aPlotter, module->m_Value,
trace_mode, plot_opts.GetValueColor() );
for( pt_texte = (TEXTE_MODULE*) module->m_Drawings.GetFirst(); for( pt_texte = (TEXTE_MODULE*) module->m_Drawings.GetFirst();
pt_texte != NULL; pt_texte != NULL;
...@@ -186,10 +189,10 @@ module\n %s's \"value\" text." ), ...@@ -186,10 +189,10 @@ module\n %s's \"value\" text." ),
if( pt_texte->Type() != PCB_MODULE_TEXT_T ) if( pt_texte->Type() != PCB_MODULE_TEXT_T )
continue; continue;
if( !plot_opts.m_PlotTextOther ) if( !plot_opts.GetPlotOtherText() )
continue; continue;
if( !pt_texte->IsVisible() && !plot_opts.m_PlotInvisibleTexts ) if( !pt_texte->IsVisible() && !plot_opts.GetPlotInvisibleText() )
continue; continue;
textLayer = pt_texte->GetLayer(); textLayer = pt_texte->GetLayer();
...@@ -202,21 +205,22 @@ module\n %s's \"value\" text." ), ...@@ -202,21 +205,22 @@ module\n %s's \"value\" text." ),
for module\n %s's \"module text\" text of %s." ), for module\n %s's \"module text\" text of %s." ),
textLayer, GetChars( module->GetReference() ), textLayer, GetChars( module->GetReference() ),
GetChars( pt_texte->m_Text ) ); GetChars( pt_texte->m_Text ) );
DisplayError( this, errMsg ); DisplayError( NULL, errMsg );
return; return;
} }
if( !( ( 1 << textLayer ) & aLayerMask ) ) if( !( ( 1 << textLayer ) & aLayerMask ) )
continue; continue;
PlotTextModule( aPlotter, pt_texte, trace_mode ); PlotTextModule( aPlotter, pt_texte,
trace_mode, plot_opts.GetColor() );
} }
} }
// Plot filled areas // Plot filled areas
for( int ii = 0; ii < m_Pcb->GetAreaCount(); ii++ ) for( int ii = 0; ii < aBoard->GetAreaCount(); ii++ )
{ {
ZONE_CONTAINER* edge_zone = m_Pcb->GetArea( ii ); ZONE_CONTAINER* edge_zone = aBoard->GetArea( ii );
if( ( ( 1 << edge_zone->GetLayer() ) & aLayerMask ) == 0 ) if( ( ( 1 << edge_zone->GetLayer() ) & aLayerMask ) == 0 )
continue; continue;
...@@ -226,7 +230,7 @@ for module\n %s's \"module text\" text of %s." ), ...@@ -226,7 +230,7 @@ for module\n %s's \"module text\" text of %s." ),
// Plot segments used to fill zone areas (outdated, but here for old boards // Plot segments used to fill zone areas (outdated, but here for old boards
// compatibility): // compatibility):
for( SEGZONE* seg = m_Pcb->m_Zone; seg != NULL; seg = seg->Next() ) for( SEGZONE* seg = aBoard->m_Zone; seg != NULL; seg = seg->Next() )
{ {
if( ( ( 1 << seg->GetLayer() ) & aLayerMask ) == 0 ) if( ( ( 1 << seg->GetLayer() ) & aLayerMask ) == 0 )
continue; continue;
...@@ -236,7 +240,8 @@ for module\n %s's \"module text\" text of %s." ), ...@@ -236,7 +240,8 @@ for module\n %s's \"module text\" text of %s." ),
} }
static void PlotTextModule( PLOTTER* aPlotter, TEXTE_MODULE* pt_texte, EDA_DRAW_MODE_T trace_mode ) static void PlotTextModule( PLOTTER* aPlotter, TEXTE_MODULE* pt_texte,
EDA_DRAW_MODE_T trace_mode, EDA_COLOR_T aColor )
{ {
wxSize size; wxSize size;
wxPoint pos; wxPoint pos;
...@@ -262,7 +267,7 @@ static void PlotTextModule( PLOTTER* aPlotter, TEXTE_MODULE* pt_texte, EDA_DRAW_ ...@@ -262,7 +267,7 @@ static void PlotTextModule( PLOTTER* aPlotter, TEXTE_MODULE* pt_texte, EDA_DRAW_
// So we set bold flag to true // So we set bold flag to true
bool allow_bold = pt_texte->m_Bold || thickness; bool allow_bold = pt_texte->m_Bold || thickness;
aPlotter->Text( pos, BLACK, aPlotter->Text( pos, aColor,
pt_texte->m_Text, pt_texte->m_Text,
orient, size, orient, size,
pt_texte->m_HJustify, pt_texte->m_VJustify, pt_texte->m_HJustify, pt_texte->m_VJustify,
...@@ -270,7 +275,8 @@ static void PlotTextModule( PLOTTER* aPlotter, TEXTE_MODULE* pt_texte, EDA_DRAW_ ...@@ -270,7 +275,8 @@ static void PlotTextModule( PLOTTER* aPlotter, TEXTE_MODULE* pt_texte, EDA_DRAW_
} }
void PlotDimension( PLOTTER* aPlotter, const PCB_PLOT_PARAMS& aPlotOpts, DIMENSION* aDim, int aLayerMask, void PlotDimension( PLOTTER* aPlotter, const PCB_PLOT_PARAMS& aPlotOpts,
DIMENSION* aDim, int aLayerMask,
EDA_DRAW_MODE_T trace_mode ) EDA_DRAW_MODE_T trace_mode )
{ {
if( (GetLayerMask( aDim->GetLayer() ) & aLayerMask) == 0 ) if( (GetLayerMask( aDim->GetLayer() ) & aLayerMask) == 0 )
...@@ -313,7 +319,8 @@ void PlotDimension( PLOTTER* aPlotter, const PCB_PLOT_PARAMS& aPlotOpts, DIMENSI ...@@ -313,7 +319,8 @@ void PlotDimension( PLOTTER* aPlotter, const PCB_PLOT_PARAMS& aPlotOpts, DIMENSI
} }
void PlotPcbTarget( PLOTTER* aPlotter, const PCB_PLOT_PARAMS& aPlotOpts, PCB_TARGET* aMire, int aLayerMask, void PlotPcbTarget( PLOTTER* aPlotter, const PCB_PLOT_PARAMS& aPlotOpts,
PCB_TARGET* aMire, int aLayerMask,
EDA_DRAW_MODE_T trace_mode ) EDA_DRAW_MODE_T trace_mode )
{ {
int dx1, dx2, dy1, dy2, radius; int dx1, dx2, dy1, dy2, radius;
...@@ -359,7 +366,9 @@ void PlotPcbTarget( PLOTTER* aPlotter, const PCB_PLOT_PARAMS& aPlotOpts, PCB_TAR ...@@ -359,7 +366,9 @@ void PlotPcbTarget( PLOTTER* aPlotter, const PCB_PLOT_PARAMS& aPlotOpts, PCB_TAR
// Plot footprints graphic items (outlines) // Plot footprints graphic items (outlines)
void Plot_Edges_Modules( PLOTTER* aPlotter, const PCB_PLOT_PARAMS& aPlotOpts, BOARD* aPcb, int aLayerMask, EDA_DRAW_MODE_T trace_mode ) static void Plot_Edges_Modules( PLOTTER* aPlotter, const PCB_PLOT_PARAMS& aPlotOpts,
BOARD* aPcb, int aLayerMask,
EDA_DRAW_MODE_T trace_mode )
{ {
for( MODULE* module = aPcb->m_Modules; module; module = module->Next() ) for( MODULE* module = aPcb->m_Modules; module; module = module->Next() )
{ {
...@@ -381,7 +390,8 @@ void Plot_Edges_Modules( PLOTTER* aPlotter, const PCB_PLOT_PARAMS& aPlotOpts, BO ...@@ -381,7 +390,8 @@ void Plot_Edges_Modules( PLOTTER* aPlotter, const PCB_PLOT_PARAMS& aPlotOpts, BO
//* Plot a graphic item (outline) relative to a footprint //* Plot a graphic item (outline) relative to a footprint
void Plot_1_EdgeModule( PLOTTER* aPlotter, const PCB_PLOT_PARAMS& aPlotOpts, void Plot_1_EdgeModule( PLOTTER* aPlotter, const PCB_PLOT_PARAMS& aPlotOpts,
EDGE_MODULE* aEdge, EDA_DRAW_MODE_T trace_mode, int masque_layer ) EDGE_MODULE* aEdge, EDA_DRAW_MODE_T trace_mode,
int masque_layer )
{ {
int type_trace; // Type of item to plot. int type_trace; // Type of item to plot.
int thickness; // Segment thickness. int thickness; // Segment thickness.
...@@ -417,7 +427,7 @@ void Plot_1_EdgeModule( PLOTTER* aPlotter, const PCB_PLOT_PARAMS& aPlotOpts, ...@@ -417,7 +427,7 @@ void Plot_1_EdgeModule( PLOTTER* aPlotter, const PCB_PLOT_PARAMS& aPlotOpts,
double endAngle = startAngle + aEdge->GetAngle(); double endAngle = startAngle + aEdge->GetAngle();
if ( ( aPlotOpts.GetPlotFormat() == PLOT_FORMAT_DXF ) && if ( ( aPlotOpts.GetFormat() == PLOT_FORMAT_DXF ) &&
( masque_layer & ( SILKSCREEN_LAYER_BACK | DRAW_LAYER | COMMENT_LAYER ) ) ) ( masque_layer & ( SILKSCREEN_LAYER_BACK | DRAW_LAYER | COMMENT_LAYER ) ) )
aPlotter->ThickArc( pos, -startAngle, -endAngle, radius, aPlotter->ThickArc( pos, -startAngle, -endAngle, radius,
thickness, trace_mode ); thickness, trace_mode );
...@@ -502,7 +512,7 @@ void PlotTextePcb( PLOTTER* aPlotter, const PCB_PLOT_PARAMS& aPlotOpts, TEXTE_PC ...@@ -502,7 +512,7 @@ void PlotTextePcb( PLOTTER* aPlotter, const PCB_PLOT_PARAMS& aPlotOpts, TEXTE_PC
for( unsigned i = 0; i < list->Count(); i++ ) for( unsigned i = 0; i < list->Count(); i++ )
{ {
wxString txt = list->Item( i ); wxString txt = list->Item( i );
aPlotter->Text( pos, BLACK, txt, orient, size, aPlotter->Text( pos, UNSPECIFIED, txt, orient, size,
pt_texte->m_HJustify, pt_texte->m_VJustify, pt_texte->m_HJustify, pt_texte->m_VJustify,
thickness, pt_texte->m_Italic, allow_bold ); thickness, pt_texte->m_Italic, allow_bold );
pos += offset; pos += offset;
...@@ -512,7 +522,7 @@ void PlotTextePcb( PLOTTER* aPlotter, const PCB_PLOT_PARAMS& aPlotOpts, TEXTE_PC ...@@ -512,7 +522,7 @@ void PlotTextePcb( PLOTTER* aPlotter, const PCB_PLOT_PARAMS& aPlotOpts, TEXTE_PC
} }
else else
{ {
aPlotter->Text( pos, BLACK, pt_texte->m_Text, orient, size, aPlotter->Text( pos, UNSPECIFIED, pt_texte->m_Text, orient, size,
pt_texte->m_HJustify, pt_texte->m_VJustify, pt_texte->m_HJustify, pt_texte->m_VJustify,
thickness, pt_texte->m_Italic, allow_bold ); thickness, pt_texte->m_Italic, allow_bold );
} }
...@@ -597,7 +607,8 @@ void PlotFilledAreas( PLOTTER* aPlotter, const PCB_PLOT_PARAMS& aPlotOpts, ZONE_ ...@@ -597,7 +607,8 @@ void PlotFilledAreas( PLOTTER* aPlotter, const PCB_PLOT_PARAMS& aPlotOpts, ZONE_
/* Plot items type DRAWSEGMENT on layers allowed by aLayerMask /* Plot items type DRAWSEGMENT on layers allowed by aLayerMask
*/ */
void PlotDrawSegment( PLOTTER* aPlotter, const PCB_PLOT_PARAMS& aPlotOpts, DRAWSEGMENT* aSeg, int aLayerMask, void PlotDrawSegment( PLOTTER* aPlotter, const PCB_PLOT_PARAMS& aPlotOpts,
DRAWSEGMENT* aSeg, int aLayerMask,
EDA_DRAW_MODE_T trace_mode ) EDA_DRAW_MODE_T trace_mode )
{ {
int thickness; int thickness;
...@@ -607,7 +618,7 @@ void PlotDrawSegment( PLOTTER* aPlotter, const PCB_PLOT_PARAMS& aPlotOpts, DRAWS ...@@ -607,7 +618,7 @@ void PlotDrawSegment( PLOTTER* aPlotter, const PCB_PLOT_PARAMS& aPlotOpts, DRAWS
return; return;
if( trace_mode == LINE ) if( trace_mode == LINE )
thickness = aPlotOpts.m_PlotLineWidth; thickness = aPlotOpts.GetLineWidth();
else else
thickness = aSeg->GetWidth(); thickness = aSeg->GetWidth();
...@@ -650,15 +661,18 @@ void PlotDrawSegment( PLOTTER* aPlotter, const PCB_PLOT_PARAMS& aPlotOpts, DRAWS ...@@ -650,15 +661,18 @@ void PlotDrawSegment( PLOTTER* aPlotter, const PCB_PLOT_PARAMS& aPlotOpts, DRAWS
} }
void PCB_BASE_FRAME::Plot_Layer( PLOTTER* aPlotter, int Layer, EDA_DRAW_MODE_T trace_mode ) void PlotBoardLayer( BOARD *aBoard, PLOTTER* aPlotter, int Layer,
const PCB_PLOT_PARAMS& plot_opts )
{ {
const PCB_PLOT_PARAMS& plot_opts = GetPlotSettings(); // Set the color and the text mode for this layer
aPlotter->SetColor( plot_opts.GetColor() );
aPlotter->SetTextMode( plot_opts.GetTextMode() );
// Specify that the contents of the "Edges Pcb" layer are to be plotted // Specify that the contents of the "Edges Pcb" layer are to be plotted
// in addition to the contents of the currently specified layer. // in addition to the contents of the currently specified layer.
int layer_mask = GetLayerMask( Layer ); int layer_mask = GetLayerMask( Layer );
if( !plot_opts.m_ExcludeEdgeLayer ) if( !plot_opts.GetExcludeEdgeLayer() )
layer_mask |= EDGE_LAYER; layer_mask |= EDGE_LAYER;
switch( Layer ) switch( Layer )
...@@ -679,59 +693,49 @@ void PCB_BASE_FRAME::Plot_Layer( PLOTTER* aPlotter, int Layer, EDA_DRAW_MODE_T t ...@@ -679,59 +693,49 @@ void PCB_BASE_FRAME::Plot_Layer( PLOTTER* aPlotter, int Layer, EDA_DRAW_MODE_T t
case LAYER_N_14: case LAYER_N_14:
case LAYER_N_15: case LAYER_N_15:
case LAST_COPPER_LAYER: case LAST_COPPER_LAYER:
Plot_Standard_Layer( aPlotter, layer_mask, true, trace_mode, // Skip NPTH pads on copper layers ( only if hole size == pad size ):
plot_opts.m_SkipNPTH_Pads ); PlotStandardLayer( aBoard, aPlotter, layer_mask, plot_opts, true, true );
// Adding drill marks, if required and if the plotter is able to plot them: // Adding drill marks, if required and if the plotter is able to plot them:
if( plot_opts.m_DrillShapeOpt != PCB_PLOT_PARAMS::NO_DRILL_SHAPE ) if( plot_opts.GetDrillMarksType() != PCB_PLOT_PARAMS::NO_DRILL_SHAPE )
{ PlotDrillMarks( aBoard, aPlotter, plot_opts );
if( aPlotter->GetPlotterType() == PLOT_FORMAT_POST )
PlotDrillMark( aPlotter, trace_mode,
plot_opts.m_DrillShapeOpt ==
PCB_PLOT_PARAMS::SMALL_DRILL_SHAPE );
}
break; break;
case SOLDERMASK_N_BACK: case SOLDERMASK_N_BACK:
case SOLDERMASK_N_FRONT: case SOLDERMASK_N_FRONT:
Plot_Standard_Layer( aPlotter, layer_mask, PlotStandardLayer( aBoard, aPlotter, layer_mask, plot_opts,
plot_opts.m_PlotViaOnMaskLayer, trace_mode ); plot_opts.GetPlotViaOnMaskLayer(), false );
break; break;
case SOLDERPASTE_N_BACK: case SOLDERPASTE_N_BACK:
case SOLDERPASTE_N_FRONT: case SOLDERPASTE_N_FRONT:
Plot_Standard_Layer( aPlotter, layer_mask, false, trace_mode ); PlotStandardLayer( aBoard, aPlotter, layer_mask, plot_opts,
false, false );
break; break;
case SILKSCREEN_N_FRONT: case SILKSCREEN_N_FRONT:
case SILKSCREEN_N_BACK: case SILKSCREEN_N_BACK:
PlotSilkScreen( aPlotter, layer_mask, trace_mode ); PlotSilkScreen( aBoard, aPlotter, layer_mask, plot_opts );
// Gerber: Subtract soldermask from silkscreen if enabled // Gerber: Subtract soldermask from silkscreen if enabled
if( aPlotter->GetPlotterType() == PLOT_FORMAT_GERBER if( aPlotter->GetPlotterType() == PLOT_FORMAT_GERBER
&& plot_opts.GetSubtractMaskFromSilk() ) && plot_opts.GetSubtractMaskFromSilk() )
{ {
if( Layer == SILKSCREEN_N_FRONT ) if( Layer == SILKSCREEN_N_FRONT )
{
layer_mask = GetLayerMask( SOLDERMASK_N_FRONT ); layer_mask = GetLayerMask( SOLDERMASK_N_FRONT );
}
else else
{
layer_mask = GetLayerMask( SOLDERMASK_N_BACK ); layer_mask = GetLayerMask( SOLDERMASK_N_BACK );
}
// Set layer polarity to negative // Set layer polarity to negative
aPlotter->SetLayerPolarity( false ); aPlotter->SetLayerPolarity( false );
Plot_Standard_Layer( aPlotter, layer_mask, PlotStandardLayer( aBoard, aPlotter, layer_mask, plot_opts,
plot_opts.m_PlotViaOnMaskLayer, plot_opts.GetPlotViaOnMaskLayer(), false );
trace_mode );
} }
break; break;
default: default:
PlotSilkScreen( aPlotter, layer_mask, trace_mode ); PlotSilkScreen( aBoard, aPlotter, layer_mask, plot_opts );
break; break;
} }
} }
...@@ -740,20 +744,18 @@ void PCB_BASE_FRAME::Plot_Layer( PLOTTER* aPlotter, int Layer, EDA_DRAW_MODE_T t ...@@ -740,20 +744,18 @@ void PCB_BASE_FRAME::Plot_Layer( PLOTTER* aPlotter, int Layer, EDA_DRAW_MODE_T t
/* Plot a copper layer or mask. /* Plot a copper layer or mask.
* Silk screen layers are not plotted here. * Silk screen layers are not plotted here.
*/ */
void PCB_BASE_FRAME::Plot_Standard_Layer( PLOTTER* aPlotter, void PlotStandardLayer( BOARD *aBoard, PLOTTER* aPlotter,
int aLayerMask, long aLayerMask, const PCB_PLOT_PARAMS& plot_opts,
bool aPlotVia, bool aPlotVia, bool aSkipNPTH_Pads )
EDA_DRAW_MODE_T aPlotMode,
bool aSkipNPTH_Pads )
{ {
wxPoint pos; wxPoint pos;
wxSize size; wxSize size;
wxString msg; wxString msg;
const PCB_PLOT_PARAMS& plot_opts = GetPlotSettings(); EDA_DRAW_MODE_T aPlotMode = plot_opts.GetMode();
// Plot pcb draw items. // Plot pcb draw items.
for( BOARD_ITEM* item = m_Pcb->m_Drawings; item; item = item->Next() ) for( BOARD_ITEM* item = aBoard->m_Drawings; item; item = item->Next() )
{ {
switch( item->Type() ) switch( item->Type() )
{ {
...@@ -777,13 +779,13 @@ void PCB_BASE_FRAME::Plot_Standard_Layer( PLOTTER* aPlotter, ...@@ -777,13 +779,13 @@ void PCB_BASE_FRAME::Plot_Standard_Layer( PLOTTER* aPlotter,
break; break;
default: default:
wxMessageBox( wxT( "Plot_Standard_Layer() error : Unexpected Draw Type" ) ); DisplayError( NULL, wxT( "Plot_Standard_Layer() error : Unexpected Draw Type" ) );
break; break;
} }
} }
// Draw footprint shapes without pads (pads will plotted later) // Draw footprint shapes without pads (pads will plotted later)
for( MODULE* module = m_Pcb->m_Modules; module; module = module->Next() ) for( MODULE* module = aBoard->m_Modules; module; module = module->Next() )
{ {
for( BOARD_ITEM* item = module->m_Drawings; item; item = item->Next() ) for( BOARD_ITEM* item = module->m_Drawings; item; item = item->Next() )
{ {
...@@ -802,7 +804,7 @@ void PCB_BASE_FRAME::Plot_Standard_Layer( PLOTTER* aPlotter, ...@@ -802,7 +804,7 @@ void PCB_BASE_FRAME::Plot_Standard_Layer( PLOTTER* aPlotter,
} }
// Plot footprint pads // Plot footprint pads
for( MODULE* module = m_Pcb->m_Modules; module; module = module->Next() ) for( MODULE* module = aBoard->m_Modules; module; module = module->Next() )
{ {
for( D_PAD* pad = module->m_Pads; pad; pad = pad->Next() ) for( D_PAD* pad = module->m_Pads; pad; pad = pad->Next() )
{ {
...@@ -885,7 +887,7 @@ void PCB_BASE_FRAME::Plot_Standard_Layer( PLOTTER* aPlotter, ...@@ -885,7 +887,7 @@ void PCB_BASE_FRAME::Plot_Standard_Layer( PLOTTER* aPlotter,
// Plot vias : // Plot vias :
if( aPlotVia ) if( aPlotVia )
{ {
for( TRACK* track = m_Pcb->m_Track; track; track = track->Next() ) for( TRACK* track = aBoard->m_Track; track; track = track->Next() )
{ {
if( track->Type() != PCB_VIA_T ) if( track->Type() != PCB_VIA_T )
continue; continue;
...@@ -912,7 +914,7 @@ void PCB_BASE_FRAME::Plot_Standard_Layer( PLOTTER* aPlotter, ...@@ -912,7 +914,7 @@ void PCB_BASE_FRAME::Plot_Standard_Layer( PLOTTER* aPlotter,
// If the current layer is a solder mask, use the global mask // If the current layer is a solder mask, use the global mask
// clearance for vias // clearance for vias
if( ( aLayerMask & ( SOLDERMASK_LAYER_BACK | SOLDERMASK_LAYER_FRONT ) ) ) if( ( aLayerMask & ( SOLDERMASK_LAYER_BACK | SOLDERMASK_LAYER_FRONT ) ) )
via_margin = GetBoard()->GetDesignSettings().m_SolderMaskMargin; via_margin = aBoard->GetDesignSettings().m_SolderMaskMargin;
if( aLayerMask & ALL_CU_LAYERS ) if( aLayerMask & ALL_CU_LAYERS )
{ {
...@@ -931,7 +933,7 @@ void PCB_BASE_FRAME::Plot_Standard_Layer( PLOTTER* aPlotter, ...@@ -931,7 +933,7 @@ void PCB_BASE_FRAME::Plot_Standard_Layer( PLOTTER* aPlotter,
} }
// Plot tracks (not vias) : // Plot tracks (not vias) :
for( TRACK* track = m_Pcb->m_Track; track; track = track->Next() ) for( TRACK* track = aBoard->m_Track; track; track = track->Next() )
{ {
wxPoint end; wxPoint end;
...@@ -949,7 +951,7 @@ void PCB_BASE_FRAME::Plot_Standard_Layer( PLOTTER* aPlotter, ...@@ -949,7 +951,7 @@ void PCB_BASE_FRAME::Plot_Standard_Layer( PLOTTER* aPlotter,
} }
// Plot zones (outdated, for old boards compatibility): // Plot zones (outdated, for old boards compatibility):
for( TRACK* track = m_Pcb->m_Zone; track; track = track->Next() ) for( TRACK* track = aBoard->m_Zone; track; track = track->Next() )
{ {
wxPoint end; wxPoint end;
...@@ -964,9 +966,9 @@ void PCB_BASE_FRAME::Plot_Standard_Layer( PLOTTER* aPlotter, ...@@ -964,9 +966,9 @@ void PCB_BASE_FRAME::Plot_Standard_Layer( PLOTTER* aPlotter,
} }
// Plot filled ares // Plot filled ares
for( int ii = 0; ii < m_Pcb->GetAreaCount(); ii++ ) for( int ii = 0; ii < aBoard->GetAreaCount(); ii++ )
{ {
ZONE_CONTAINER* edge_zone = m_Pcb->GetArea( ii ); ZONE_CONTAINER* edge_zone = aBoard->GetArea( ii );
if( ( ( 1 << edge_zone->GetLayer() ) & aLayerMask ) == 0 ) if( ( ( 1 << edge_zone->GetLayer() ) & aLayerMask ) == 0 )
continue; continue;
...@@ -975,85 +977,316 @@ void PCB_BASE_FRAME::Plot_Standard_Layer( PLOTTER* aPlotter, ...@@ -975,85 +977,316 @@ void PCB_BASE_FRAME::Plot_Standard_Layer( PLOTTER* aPlotter,
} }
} }
/** Helper function to plot a single drill mark. It compensate and clamp
the drill mark size depending on the current plot options */
static void PlotDrillMark( PLOTTER *aPlotter, PAD_SHAPE_T aDrillShape,
const wxPoint &aDrillPos, wxSize aDrillSize,
const wxSize &aPadSize,
double aOrientation, int aSmallDrill,
EDA_DRAW_MODE_T aTraceMode )
{
// Small drill marks have no significance when applied to slots
if( aSmallDrill && aDrillShape == PAD_ROUND )
aDrillSize.x = std::min( aSmallDrill, aDrillSize.x );
// Round holes only have x diameter, slots have both
aDrillSize.x -= aPlotter->GetPlotWidthAdj();
aDrillSize.x = Clamp( 1, aDrillSize.x, aPadSize.x - 1 );
if( aDrillShape == PAD_OVAL )
{
aDrillSize.y -= aPlotter->GetPlotWidthAdj();
aDrillSize.y = Clamp( 1, aDrillSize.y, aPadSize.y - 1 );
aPlotter->FlashPadOval( aDrillPos, aDrillSize, aOrientation, aTraceMode );
}
else
aPlotter->FlashPadCircle( aDrillPos, aDrillSize.x, aTraceMode );
}
/** /**
* Function PlotDrillMark * Function PlotDrillMarks
* Draw a drill mark for pads and vias. * Draw a drill mark for pads and vias.
* Must be called after all drawings, because it * Must be called after all drawings, because it
* redraw the drill mark on a pad or via, as a negative (i.e. white) shape in * redraw the drill mark on a pad or via, as a negative (i.e. white) shape in
* FILLED plot mode * FILLED plot mode (for PS and PDF outputs)
* @param aPlotter = the PLOTTER * @param aPlotter = the PLOTTER
* @param aTraceMode = the mode of plot (FILLED, SKETCH)
* @param aSmallDrillShape = true to plot a small drill shape, false to plot * @param aSmallDrillShape = true to plot a small drill shape, false to plot
* the actual drill shape * the actual drill shape
*/ */
void PCB_BASE_FRAME::PlotDrillMark( PLOTTER* aPlotter, void PlotDrillMarks( BOARD *aBoard, PLOTTER* aPlotter,
EDA_DRAW_MODE_T aTraceMode, const PCB_PLOT_PARAMS& aPlotOpts )
bool aSmallDrillShape )
{ {
wxPoint pos; EDA_DRAW_MODE_T trace_mode = aPlotOpts.GetMode();
wxSize diam;
MODULE* Module; /* If small drills marks were requested prepare a clamp value to pass
D_PAD* pad; to the helper function */
TRACK* pts; int small_drill = (aPlotOpts.GetDrillMarksType() == PCB_PLOT_PARAMS::SMALL_DRILL_SHAPE) ?
SMALL_DRILL : 0;
const PCB_PLOT_PARAMS& plot_opts = GetPlotSettings();
/* In the filled trace mode drill marks are drawn white-on-black to scrape
if( aTraceMode == FILLED ) the underlying pad. This works only for drivers supporting color change,
obviously... it means that:
- PS and PDF output is correct (i.e. you have a 'donut' pad)
- In HPGL you can't see them
- In gerbers you can't see them, too. This is arguably the right thing to
do since having drill marks and high speed drill stations is a sure
recipe for broken tools and angry manufacturers. If you *really* want them
you could start a layer with negative polarity to scrape the film.
- In DXF they go into the 'WHITE' layer. This could be useful.
*/
if( trace_mode == FILLED )
{ {
aPlotter->SetColor( WHITE ); aPlotter->SetColor( WHITE );
} }
for( pts = m_Pcb->m_Track; pts != NULL; pts = pts->Next() ) for( TRACK *pts = aBoard->m_Track; pts != NULL; pts = pts->Next() )
{ {
if( pts->Type() != PCB_VIA_T ) if( pts->Type() != PCB_VIA_T )
continue; continue;
pos = pts->m_Start; PlotDrillMark( aPlotter, PAD_CIRCLE,
pts->m_Start, wxSize( pts->GetDrillValue(), 0 ),
// It is quite possible that the real drill value is less then small drill value. wxSize( pts->m_Width, 0 ), 0, small_drill,
if( plot_opts.m_DrillShapeOpt == PCB_PLOT_PARAMS::SMALL_DRILL_SHAPE ) trace_mode );
diam.x = diam.y = MIN( SMALL_DRILL, pts->GetDrillValue() );
else
diam.x = diam.y = pts->GetDrillValue();
diam.x -= aPlotter->GetPlotWidthAdj();
diam.x = Clamp( 1, diam.x, pts->m_Width - 1 );
aPlotter->FlashPadCircle( pos, diam.x, aTraceMode );
} }
for( Module = m_Pcb->m_Modules; Module != NULL; Module = Module->Next() ) for( MODULE *Module = aBoard->m_Modules; Module != NULL; Module = Module->Next() )
{ {
for( pad = Module->m_Pads; pad != NULL; pad = pad->Next() ) for( D_PAD *pad = Module->m_Pads; pad != NULL; pad = pad->Next() )
{ {
if( pad->GetDrillSize().x == 0 ) if( pad->GetDrillSize().x == 0 )
continue; continue;
// Output hole shapes: PlotDrillMark( aPlotter, pad->GetDrillShape(),
pos = pad->GetPosition(); pad->GetPosition(), pad->GetDrillSize(),
pad->GetSize(), pad->GetOrientation(),
if( pad->GetDrillShape() == PAD_OVAL ) small_drill, trace_mode );
{
diam = pad->GetDrillSize();
diam.x -= aPlotter->GetPlotWidthAdj();
diam.x = Clamp( 1, diam.x, pad->GetSize().x - 1 );
diam.y -= aPlotter->GetPlotWidthAdj();
diam.y = Clamp( 1, diam.y, pad->GetSize().y - 1 );
aPlotter->FlashPadOval( pos, diam, pad->GetOrientation(), aTraceMode );
}
else
{
// It is quite possible that the real pad drill value is less then small drill value.
diam.x = aSmallDrillShape ? MIN( SMALL_DRILL, pad->GetDrillSize().x ) : pad->GetDrillSize().x;
diam.x -= aPlotter->GetPlotWidthAdj();
diam.x = Clamp( 1, diam.x, pad->GetSize().x - 1 );
aPlotter->FlashPadCircle( pos, diam.x, aTraceMode );
}
} }
} }
if( aTraceMode == FILLED ) if( trace_mode == FILLED )
{ {
aPlotter->SetColor( BLACK ); aPlotter->SetColor( aPlotOpts.GetColor() );
} }
} }
/** Set up most plot options for plotting a board (especially the viewport)
* Important thing:
* page size is the 'drawing' page size,
* paper size is the physical page size
*/
static void PlotSetupPlotter( PLOTTER *aPlotter, PCB_PLOT_PARAMS *aPlotOpts,
const PAGE_INFO &aPageInfo,
const EDA_RECT &aBbbox,
const wxPoint &aOrigin,
const wxString &aFilename )
{
PAGE_INFO pageA4( wxT( "A4" ) );
const PAGE_INFO* sheet_info;
double paperscale; // Page-to-paper ratio
wxSize paperSizeIU;
wxSize pageSizeIU( aPageInfo.GetSizeIU() );
bool autocenter = false;
/* Special options: to fit the sheet to an A4 sheet replace
the paper size. However there is a difference between
the autoscale and the a4paper option:
- Autoscale fits the board to the paper size
- A4paper fits the original paper size to an A4 sheet
- Both of them fit the board to an A4 sheet
*/
if( aPlotOpts->GetA4Output() ) // Fit paper to A4
{
sheet_info = &pageA4;
paperSizeIU = pageA4.GetSizeIU();
paperscale = (double) paperSizeIU.x / pageSizeIU.x;
autocenter = true;
}
else
{
sheet_info = &aPageInfo;
paperSizeIU = pageSizeIU;
paperscale = 1;
// Need autocentering only if scale is not 1:1
autocenter = (aPlotOpts->GetScale() != 1.0);
}
wxPoint boardCenter = aBbbox.Centre();
double compound_scale;
wxSize boardSize = aBbbox.GetSize();
/* Fit to 80% of the page if asked; it could be that the board is empty,
* in this case regress to 1:1 scale */
if( aPlotOpts->GetAutoScale() && boardSize.x > 0 && boardSize.y > 0 )
{
double xscale = (paperSizeIU.x * 0.8) / boardSize.x;
double yscale = (paperSizeIU.y * 0.8) / boardSize.y;
compound_scale = std::min( xscale, yscale ) * paperscale;
}
else
compound_scale = aPlotOpts->GetScale() * paperscale;
/* For the plot offset we have to keep in mind the auxiliary origin
too: if autoscaling is off we check that plot option (i.e. autoscaling
overrides auxiliary origin) */
wxPoint offset( 0, 0);
if( autocenter )
{
offset.x = KiROUND( boardCenter.x - ( paperSizeIU.x / 2.0 ) / compound_scale );
offset.y = KiROUND( boardCenter.y - ( paperSizeIU.y / 2.0 ) / compound_scale );
}
else
{
if( aPlotOpts->GetUseAuxOrigin() )
offset = aOrigin;
}
/* Configure the plotter object with all the stuff computed and
most of that taken from the options */
aPlotter->SetPageSettings( *sheet_info );
aPlotter->SetPlotWidthAdj( aPlotOpts->GetWidthAdjust() );
aPlotter->SetViewport( offset, IU_PER_DECIMILS, compound_scale,
aPlotOpts->GetMirror() );
aPlotter->SetDefaultLineWidth( aPlotOpts->GetLineWidth() );
aPlotter->SetCreator( wxT( "PCBNEW" ) );
aPlotter->SetColorMode( true );
aPlotter->SetFilename( aFilename );
aPlotter->SetTextMode( aPlotOpts->GetTextMode() );
}
/** Prefill in black an area a little bigger than the board to prepare for the
* negative plot */
static void FillNegativeKnockout(PLOTTER *aPlotter, const EDA_RECT &aBbbox )
{
static const int margin = 500; // Add a 0.5 inch margin around the board
aPlotter->SetNegative( true );
aPlotter->SetColor( WHITE ); // Which will be plotted as black
aPlotter->Rect( wxPoint( aBbbox.GetX() - margin, aBbbox.GetY() - margin ),
wxPoint( aBbbox.GetRight() + margin, aBbbox.GetBottom() + margin ),
FILLED_SHAPE );
aPlotter->SetColor( BLACK );
}
/** Calculate the effective size of HPGL pens and set them in the
* plotter object */
static void ConfigureHPGLPenSizes( HPGL_PLOTTER *aPlotter,
PCB_PLOT_PARAMS *aPlotOpts )
{
/* Compute pen_dim (the value is given in mils) in pcb units,
with plot scale (if Scale is 2, pen diameter value is always m_HPGLPenDiam
so apparent pen diam is real pen diam / Scale */
int pen_diam = KiROUND( aPlotOpts->GetHPGLPenDiameter() * IU_PER_MILS /
aPlotOpts->GetScale() );
// compute pen_overlay (value comes in mils) in pcb units with plot scale
if( aPlotOpts->GetHPGLPenOverlay() < 0 )
aPlotOpts->SetHPGLPenOverlay( 0 );
if( aPlotOpts->GetHPGLPenOverlay() >= aPlotOpts->GetHPGLPenDiameter() )
aPlotOpts->SetHPGLPenOverlay( aPlotOpts->GetHPGLPenDiameter() - 1 );
int pen_overlay = KiROUND( aPlotOpts->GetHPGLPenOverlay() * IU_PER_MILS /
aPlotOpts->GetScale() );
// Set HPGL-specific options and start
aPlotter->SetPenSpeed( aPlotOpts->GetHPGLPenSpeed() );
aPlotter->SetPenNumber( aPlotOpts->GetHPGLPenNum() );
aPlotter->SetPenOverlap( pen_overlay );
aPlotter->SetPenDiameter( pen_diam );
}
/** Open a new plotfile using the options (and especially the format)
* specified in the options and prepare the page for plotting.
* Return the plotter object if OK, NULL if the file is not created
* (or has a problem)
*/
PLOTTER *StartPlotBoard( BOARD *aBoard,
PCB_PLOT_PARAMS *aPlotOpts,
const wxString& aFullFileName,
const wxString& aSheetDesc )
{
const PAGE_INFO& pageInfo = aBoard->GetPageSettings();
EDA_RECT bbbox = aBoard->ComputeBoundingBox();
wxPoint auxOrigin( aBoard->GetOriginAxisPosition() );
FILE* output_file = wxFopen( aFullFileName, wxT( "wt" ) );
if( output_file == NULL )
return NULL;
// Create the plotter driver and set the few plotter specific
// options
PLOTTER *the_plotter = NULL;
switch( aPlotOpts->GetFormat() )
{
case PLOT_FORMAT_DXF:
the_plotter = new DXF_PLOTTER();
break;
case PLOT_FORMAT_POST:
PS_PLOTTER* PS_plotter;
PS_plotter = new PS_PLOTTER();
PS_plotter->SetScaleAdjust( aPlotOpts->GetFineScaleAdjustX(),
aPlotOpts->GetFineScaleAdjustY() );
the_plotter = PS_plotter;
break;
case PLOT_FORMAT_PDF:
the_plotter = new PDF_PLOTTER();
break;
case PLOT_FORMAT_HPGL:
HPGL_PLOTTER* HPGL_plotter;
HPGL_plotter = new HPGL_PLOTTER();
/* HPGL options are a little more convoluted to compute, so
they're split in an other function */
ConfigureHPGLPenSizes( HPGL_plotter, aPlotOpts );
the_plotter = HPGL_plotter;
break;
case PLOT_FORMAT_GERBER:
the_plotter = new GERBER_PLOTTER();
break;
default:
wxASSERT( false );
}
if( the_plotter )
{
// Compute the viewport and set the other options
PlotSetupPlotter( the_plotter, aPlotOpts, pageInfo, bbbox, auxOrigin,
aFullFileName );
if( the_plotter->StartPlot( output_file ) )
{
/* When plotting a negative board: draw a black rectangle
* (background for plot board in white) and switch the current
* color to WHITE; note the the color inversion is actually done
* in the driver (if supported) */
if( aPlotOpts->GetNegative() )
FillNegativeKnockout( the_plotter, bbbox );
// Plot the frame reference if requested
if( aPlotOpts->GetPlotFrameRef() )
PlotWorkSheet( the_plotter, aBoard->GetTitleBlock(),
aBoard->GetPageSettings(),
1, 1, // Only one page
aSheetDesc,
aBoard->GetFileName() );
return the_plotter;
}
}
// error in start_plot( ) or before
DisplayError( NULL, _("Error creating plot file"));
if( the_plotter )
delete the_plotter;
return NULL;
}
/**
* @file pcbnew/pcbplot.h
*/
#ifndef PLOTCONTROLLER_H_
#define PLOTCONTROLLER_H_
#include <pcb_plot_params.h>
#include <layers_id_colors_and_visibility.h>
class PLOTTER;
class BOARD;
/**
* Batch plotter state object. Keeps the plot options and handles multiple
* plot requests
*/
class PLOT_CONTROLLER
{
public:
PLOT_CONTROLLER( BOARD *aBoard );
~PLOT_CONTROLLER();
PCB_PLOT_PARAMS *AccessPlotOpts() { return &m_plotOpts; }
bool IsPlotOpen() const { return m_plotter != NULL; }
void ClosePlot();
bool OpenPlotfile( const wxString &aSuffix, PlotFormat aFormat,
const wxString &aSheetDesc );
bool PlotLayer( int layer );
private:
/// Option bank
PCB_PLOT_PARAMS m_plotOpts;
/// This is the plotter object; it starts NULL and become instantiated
// when a plotfile is requested
PLOTTER *m_plotter;
/// The board we're plotting
BOARD* m_board;
};
#endif
/**
* @file plotdxf.cpp
* @brief Plot DXF.
*/
#include <fctsys.h>
#include <common.h>
#include <plot_common.h>
#include <confirm.h>
#include <trigo.h>
#include <wxBasePcbFrame.h>
#include <pcbnew.h>
#include <protos.h>
#include <pcbplot.h>
bool PCB_BASE_FRAME::ExportToDxfFile( const wxString& aFullFileName, int aLayer,
EDA_DRAW_MODE_T aTraceMode )
{
LOCALE_IO toggle;
const PCB_PLOT_PARAMS& plot_opts = GetPlotSettings();
FILE* output_file = wxFopen( aFullFileName, wxT( "wt" ) );
if( output_file == NULL )
{
return false;
}
DXF_PLOTTER* plotter = new DXF_PLOTTER();
plotter->SetPageSettings( GetPageSettings() );
plotter->SetViewport( wxPoint( 0, 0 ), IU_PER_DECIMILS, 1, 0 );
plotter->SetCreator( wxT( "PCBNEW-DXF" ) );
plotter->SetFilename( aFullFileName );
plotter->StartPlot( output_file );
if( plot_opts.m_PlotFrameRef )
PlotWorkSheet( plotter, GetScreen(), plot_opts.GetPlotLineWidth() );
Plot_Layer( plotter, aLayer, aTraceMode );
plotter->EndPlot();
delete plotter;
return true;
}
/**
* @file plotgerb.cpp
* @brief Functions to plot a board in GERBER RS274X format.
*/
/* Creates the output files, one per board layer:
* filenames are like xxxc.PHO and use the RS274X format
* Units = inches
* format 3.4, Leading zero omitted, Abs format
* format 3.4 uses the native Pcbnew units (1/10000 inch).
*/
#include <fctsys.h>
#include <common.h>
#include <plot_common.h>
#include <confirm.h>
#include <pcbplot.h>
#include <trigo.h>
#include <wxBasePcbFrame.h>
#include <layers_id_colors_and_visibility.h>
#include <pcbnew.h>
#include <protos.h>
bool PCB_BASE_FRAME::ExportToGerberFile( const wxString& aFullFileName, int aLayer,
bool aPlotOriginIsAuxAxis, EDA_DRAW_MODE_T aTraceMode )
{
FILE* output_file = wxFopen( aFullFileName, wxT( "wt" ) );
if( output_file == NULL )
{
return false;
}
PCB_PLOT_PARAMS plot_opts = GetPlotSettings();
wxPoint offset;
// Calculate scaling from Pcbnew units (in 0.1 mil or 0.0001 inch) to gerber units
double scale = plot_opts.m_PlotScale;
if( aPlotOriginIsAuxAxis )
{
offset = GetOriginAxisPosition();
}
else
{
offset.x = 0;
offset.y = 0;
}
LOCALE_IO toggle;
PLOTTER* plotter = new GERBER_PLOTTER();
// No mirror and scaling for gerbers!
plotter->SetViewport( offset, IU_PER_DECIMILS, scale, 0 );
plotter->SetDefaultLineWidth( plot_opts.m_PlotLineWidth );
plotter->SetCreator( wxT( "PCBNEW-RS274X" ) );
plotter->SetFilename( aFullFileName );
if( plotter->StartPlot( output_file ) )
{
// Skip NPTH pads on copper layers
// ( only if hole size == pad size ):
if( (aLayer >= LAYER_N_BACK) && (aLayer <= LAYER_N_FRONT) )
plot_opts.m_SkipNPTH_Pads = true;
SetPlotSettings( plot_opts );
// Sheet refs on gerber CAN be useful... and they're always 1:1
if( plot_opts.m_PlotFrameRef )
PlotWorkSheet( plotter, GetScreen(), plot_opts.GetPlotLineWidth() );
Plot_Layer( plotter, aLayer, aTraceMode );
plotter->EndPlot();
plot_opts.m_SkipNPTH_Pads = false;
SetPlotSettings( plot_opts );
}
else // error in start_plot( ): failed opening a temporary file
{
wxMessageBox( _("Error when creating %s file: unable to create a temporary file"));
}
delete plotter;
return true;
}
/**
* @file plothpgl.cpp
*/
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2012 KiCad Developers, see change_log.txt for contributors.
* Copyright (C) 2012 Dick Hollenbeck, dick@softplc.com
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <fctsys.h>
#include <common.h>
#include <plot_common.h>
#include <wxBasePcbFrame.h>
#include <class_board.h>
#include <pcbnew.h>
#include <pcbplot.h>
#include <convert_to_biu.h>
bool PCB_BASE_FRAME::ExportToHpglFile( const wxString& aFullFileName, int aLayer,
EDA_DRAW_MODE_T aTraceMode )
{
wxSize boardSize;
wxPoint boardCenter;
bool center = false;
double scale;
wxPoint offset;
LOCALE_IO toggle;
FILE* output_file = wxFopen( aFullFileName, wxT( "wt" ) );
if( output_file == NULL )
{
return false;
}
PCB_PLOT_PARAMS plot_opts = GetPlotSettings();
// Compute pen_dim (from m_HPGLPenDiam in mils) in pcb units,
// with plot scale (if Scale is 2, pen diameter value is always m_HPGLPenDiam
// so apparent pen diam is real pen diam / Scale
int pen_diam = KiROUND( plot_opts.m_HPGLPenDiam * IU_PER_MILS /
plot_opts.m_PlotScale );
// compute pen_overlay (from m_HPGLPenOvr in mils) in pcb units
// with plot scale
if( plot_opts.m_HPGLPenOvr < 0 )
plot_opts.m_HPGLPenOvr = 0;
if( plot_opts.m_HPGLPenOvr >= plot_opts.m_HPGLPenDiam )
plot_opts.m_HPGLPenOvr = plot_opts.m_HPGLPenDiam - 1;
int pen_overlay = KiROUND( plot_opts.m_HPGLPenOvr * IU_PER_MILS /
plot_opts.m_PlotScale );
if( plot_opts.m_PlotScale != 1.0 || plot_opts.m_AutoScale )
{
// when scale != 1.0 we must calculate the position in page
// because actual position has no meaning
center = true;
}
wxSize pageSizeIU = GetPageSizeIU();
// Calculate the center of the PCB
EDA_RECT bbbox = GetBoardBoundingBox();
boardSize = bbbox.GetSize();
boardCenter = bbbox.Centre();
if( plot_opts.m_AutoScale ) // Optimum scale
{
// Fit to 80% of the page
double Xscale = ( ( pageSizeIU.x * 0.8 ) / boardSize.x );
double Yscale = ( ( pageSizeIU.y * 0.8 ) / boardSize.y );
scale = std::min( Xscale, Yscale );
}
else
{
scale = plot_opts.m_PlotScale;
}
// Calculate the page size offset.
if( center )
{
offset.x = KiROUND( (double) boardCenter.x -
( (double) pageSizeIU.x / 2.0 ) / scale );
offset.y = KiROUND( (double) boardCenter.y -
( (double) pageSizeIU.y / 2.0 ) / scale );
}
else
{
offset.x = 0;
offset.y = 0;
}
HPGL_PLOTTER* plotter = new HPGL_PLOTTER();
plotter->SetPageSettings( GetPageSettings() );
// why did we have to change these settings above?
SetPlotSettings( plot_opts );
plotter->SetViewport( offset, IU_PER_DECIMILS, scale,
plot_opts.m_PlotMirror );
plotter->SetDefaultLineWidth( plot_opts.m_PlotLineWidth );
plotter->SetCreator( wxT( "PCBNEW-HPGL" ) );
plotter->SetFilename( aFullFileName );
plotter->SetPenSpeed( plot_opts.m_HPGLPenSpeed );
plotter->SetPenNumber( plot_opts.m_HPGLPenNum );
plotter->SetPenOverlap( pen_overlay );
plotter->SetPenDiameter( pen_diam );
plotter->StartPlot( output_file );
// The worksheet is not significant with scale!=1... It is with paperscale!=1, anyway
if( plot_opts.m_PlotFrameRef && !center )
PlotWorkSheet( plotter, GetScreen(), plot_opts.GetPlotLineWidth() );
Plot_Layer( plotter, aLayer, aTraceMode );
plotter->EndPlot();
delete plotter;
return true;
}
/**
* @file plotps.cpp
* @brief Plot Postscript.
*/
#include <fctsys.h>
#include <common.h>
#include <plot_common.h>
#include <confirm.h>
#include <trigo.h>
#include <wxBasePcbFrame.h>
#include <macros.h>
#include <class_board.h>
#include <pcbnew.h>
#include <protos.h>
#include <pcbplot.h>
/* Generate a PostScript file (*. ps) of the circuit layer.
* If layer < 0: all layers are plotted.
*/
bool PCB_BASE_FRAME::ExportToPostScriptFile( const wxString& aFullFileName, int aLayer,
bool aUseA4, EDA_DRAW_MODE_T aTraceMode )
{
const PAGE_INFO& pageInfo = GetPageSettings();
PCB_PLOT_PARAMS plotOpts = GetPlotSettings();
wxSize paperSizeIU;
wxSize boardSize;
wxPoint boardCenter;
bool center = false;
double scale;
double paperscale;
wxPoint offset;
LOCALE_IO toggle;
PAGE_INFO pageA4( wxT( "A4" ) );
const PAGE_INFO* sheetPS;
FILE* output_file = wxFopen( aFullFileName, wxT( "wt" ) );
if( output_file == NULL )
{
return false;
}
if( plotOpts.m_PlotScale != 1.0 || plotOpts.m_AutoScale )
{
// when scale != 1.0 we must calculate the position in page
// because actual position has no meaning
center = true;
}
// Set default line width
if( plotOpts.m_PlotLineWidth < 1 )
plotOpts.m_PlotLineWidth = 1;
wxSize pageSizeIU = GetPageSizeIU();
if( aUseA4 )
{
sheetPS = &pageA4;
paperSizeIU = pageA4.GetSizeIU();
paperscale = (double) paperSizeIU.x / pageSizeIU.x;
}
else
{
sheetPS = &pageInfo;
paperSizeIU = pageSizeIU;
paperscale = 1;
}
EDA_RECT bbbox = GetBoardBoundingBox();
boardSize = bbbox.GetSize();
boardCenter = bbbox.Centre();
if( plotOpts.m_AutoScale ) // Optimum scale
{
// Fit to 80% of the page
double Xscale = (paperSizeIU.x * 0.8) / boardSize.x;
double Yscale = (paperSizeIU.y * 0.8) / boardSize.y;
scale = MIN( Xscale, Yscale );
}
else
{
scale = plotOpts.m_PlotScale * paperscale;
}
if( center )
{
offset.x = KiROUND( (double) boardCenter.x - ( (double) paperSizeIU.x / 2.0 ) / scale );
offset.y = KiROUND( (double) boardCenter.y - ( (double) paperSizeIU.y / 2.0 ) / scale );
}
else
{
offset.x = 0;
offset.y = 0;
}
PS_PLOTTER* plotter = new PS_PLOTTER();
plotter->SetPageSettings( *sheetPS );
// why did we have to change these settings?
SetPlotSettings( plotOpts );
plotter->SetScaleAdjust( plotOpts.m_FineScaleAdjustX,
plotOpts.m_FineScaleAdjustY );
plotter->SetPlotWidthAdj( plotOpts.m_FineWidthAdjust );
plotter->SetViewport( offset, IU_PER_DECIMILS, scale,
plotOpts.m_PlotMirror );
plotter->SetDefaultLineWidth( plotOpts.m_PlotLineWidth );
plotter->SetCreator( wxT( "PCBNEW-PS" ) );
plotter->SetFilename( aFullFileName );
plotter->SetPsTextMode( PSTEXTMODE_PHANTOM );
plotter->StartPlot( output_file );
/* The worksheet is not significant with scale!=1... It is with paperscale!=1, anyway */
if( plotOpts.m_PlotFrameRef && !center )
PlotWorkSheet( plotter, GetScreen(), plotOpts.GetPlotLineWidth() );
// If plot a negative board:
// Draw a black rectangle (background for plot board in white)
// and switch the current color to WHITE
if( plotOpts.m_PlotPSNegative )
{
int margin = 500; // Add a 0.5 inch margin around the board
plotter->SetNegative( true );
plotter->SetColor( WHITE ); // Which will be plotted as black
plotter->Rect( wxPoint( bbbox.GetX() - margin,
bbbox.GetY() - margin ),
wxPoint( bbbox.GetRight() + margin,
bbbox.GetBottom() + margin ),
FILLED_SHAPE );
plotter->SetColor( BLACK );
}
Plot_Layer( plotter, aLayer, aTraceMode );
plotter->EndPlot();
delete plotter;
return true;
}
...@@ -285,7 +285,7 @@ void BOARD_PRINTOUT_CONTROLER::DrawPage() ...@@ -285,7 +285,7 @@ void BOARD_PRINTOUT_CONTROLER::DrawPage()
if( m_PrintParams.m_Print_Sheet_Ref ) if( m_PrintParams.m_Print_Sheet_Ref )
m_Parent->TraceWorkSheet( dc, screen, m_PrintParams.m_PenDefaultSize, m_Parent->TraceWorkSheet( dc, screen, m_PrintParams.m_PenDefaultSize,
IU_PER_MILS ); IU_PER_MILS, m_Parent->GetScreenDesc() );
if( printMirror ) if( printMirror )
{ {
......
...@@ -52,8 +52,15 @@ ...@@ -52,8 +52,15 @@
{ {
char ExceptionError[256]; char ExceptionError[256];
sprintf(ExceptionError, "%s\n", TO_UTF8(e.errorText) ); sprintf(ExceptionError, "%s\n", TO_UTF8(e.errorText) );
PyErr_SetString(PyExc_IOError,ExceptionError); PyErr_SetString(PyExc_IOError,ExceptionError);
return NULL; return NULL;
}
catch( std::exception &e )
{
char ExceptionError[256];
sprintf( ExceptionError, "%s\n", e.what() );
PyErr_SetString(PyExc_IOError,ExceptionError);
return NULL;
} }
catch( ... ) catch( ... )
{ {
...@@ -88,7 +95,10 @@ ...@@ -88,7 +95,10 @@
#include <class_netclass.h> #include <class_netclass.h>
#include <class_netinfo.h> #include <class_netinfo.h>
#include <pcbnew_scripting_helpers.h> #include <pcbnew_scripting_helpers.h>
#include <plotcontroller.h>
#include <pcb_plot_params.h>
#include <colors.h>
BOARD *GetBoard(); /* get current editor board */ BOARD *GetBoard(); /* get current editor board */
%} %}
...@@ -120,6 +130,11 @@ ...@@ -120,6 +130,11 @@
%include <class_netclass.h> %include <class_netclass.h>
%include <class_netinfo.h> %include <class_netinfo.h>
%include <plotcontroller.h>
%include <pcb_plot_params.h>
%include <plot_common.h>
%include <colors.h>
%include "board_item.i" %include "board_item.i"
%include <pcbnew_scripting_helpers.h> %include <pcbnew_scripting_helpers.h>
...@@ -136,4 +151,4 @@ ...@@ -136,4 +151,4 @@
%include "plugins.i" %include "plugins.i"
%include "units.i" %include "units.i"
\ No newline at end of file
...@@ -72,7 +72,7 @@ static const double safetyMargin = 0.1; ...@@ -72,7 +72,7 @@ static const double safetyMargin = 0.1;
// see wxPcbStruct.h // see wxPcbStruct.h
void PCB_EDIT_FRAME::ExportToSpecctra( wxCommandEvent& event ) void PCB_EDIT_FRAME::ExportToSpecctra( wxCommandEvent& event )
{ {
wxString fullFileName = GetScreen()->GetFileName(); wxString fullFileName = GetBoard()->GetFileName();
wxString path; wxString path;
wxString name; wxString name;
wxString ext; wxString ext;
......
...@@ -69,7 +69,7 @@ void PCB_EDIT_FRAME::ImportSpecctraSession( wxCommandEvent& event ) ...@@ -69,7 +69,7 @@ void PCB_EDIT_FRAME::ImportSpecctraSession( wxCommandEvent& event )
} }
*/ */
wxString fullFileName = GetScreen()->GetFileName(); wxString fullFileName = GetBoard()->GetFileName();
wxString path; wxString path;
wxString name; wxString name;
wxString ext; wxString ext;
......
...@@ -68,7 +68,7 @@ void FOOTPRINT_EDIT_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg ) ...@@ -68,7 +68,7 @@ void FOOTPRINT_EDIT_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg )
GRSetDrawMode( DC, GR_COPY ); GRSetDrawMode( DC, GR_COPY );
m_canvas->DrawBackGround( DC ); m_canvas->DrawBackGround( DC );
TraceWorkSheet( DC, screen, 0, IU_PER_MILS ); TraceWorkSheet( DC, screen, 0, IU_PER_MILS, wxEmptyString );
// Redraw the footprints // Redraw the footprints
for( MODULE* module = GetBoard()->m_Modules; module; module = module->Next() ) for( MODULE* module = GetBoard()->m_Modules; module; module = module->Next() )
...@@ -106,7 +106,8 @@ void PCB_EDIT_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg ) ...@@ -106,7 +106,8 @@ void PCB_EDIT_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg )
m_canvas->DrawBackGround( DC ); m_canvas->DrawBackGround( DC );
TraceWorkSheet( DC, GetScreen(), g_DrawDefaultLineThickness, IU_PER_MILS ); TraceWorkSheet( DC, GetScreen(), g_DrawDefaultLineThickness,
IU_PER_MILS, wxEmptyString );
GetBoard()->Draw( m_canvas, DC, GR_OR | GR_ALLOW_HIGHCONTRAST); GetBoard()->Draw( m_canvas, DC, GR_OR | GR_ALLOW_HIGHCONTRAST);
......
...@@ -183,7 +183,7 @@ int DIALOG_EXCHANGE_MODULE::Maj_ListeCmp( const wxString& reference, ...@@ -183,7 +183,7 @@ int DIALOG_EXCHANGE_MODULE::Maj_ListeCmp( const wxString& reference,
return 0; return 0;
/* Build CMP file name by changing the extension of NetList filename */ /* Build CMP file name by changing the extension of NetList filename */
fn = m_Parent->GetScreen()->GetFileName(); fn = m_Parent->GetBoard()->GetFileName();
fn.SetExt( ComponentFileExtension ); fn.SetExt( ComponentFileExtension );
FichCmp = wxFopen( fn.GetFullPath(), wxT( "rt" ) ); FichCmp = wxFopen( fn.GetFullPath(), wxT( "rt" ) );
...@@ -621,7 +621,7 @@ void PCB_EDIT_FRAME::RecreateCmpFileFromBoard( wxCommandEvent& aEvent ) ...@@ -621,7 +621,7 @@ void PCB_EDIT_FRAME::RecreateCmpFileFromBoard( wxCommandEvent& aEvent )
} }
/* Calculation file name by changing the extension name to NetList */ /* Calculation file name by changing the extension name to NetList */
fn = GetScreen()->GetFileName(); fn = GetBoard()->GetFileName();
fn.SetExt( ComponentFileExtension ); fn.SetExt( ComponentFileExtension );
wildcard = wxGetTranslation( ComponentFileWildcard ); wildcard = wxGetTranslation( ComponentFileWildcard );
......
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