Commit 7cef5395 authored by Lorenzo Marcantonio's avatar Lorenzo Marcantonio

Minor plot driver enhancements

parent 715af961
......@@ -29,13 +29,20 @@ void DXF_PLOTTER::SetViewport( const wxPoint& aOffset, double aIusPerDecimil,
wxASSERT( !outputFile );
plotOffset = aOffset;
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 *= 0.00254; // DXF in mm (I like it best)
// Compute the paper size in IUs
paperSize = pageInfo.GetSizeMils();
paperSize.x *= 10.0 * aIusPerDecimil;
paperSize.y *= 10.0 * aIusPerDecimil;
iuPerDeviceUnit *= 0.00254; // ... now in mm
SetDefaultLineWidth( 0 ); // No line width on DXF
plotMirror = false; // No mirroring on DXF
currentColor = BLACK;
......
......@@ -25,6 +25,7 @@ void GERBER_PLOTTER::SetViewport( const wxPoint& aOffset, double aIusPerDecimil,
plotOffset = aOffset;
wxASSERT( aScale == 1 );
plotScale = 1;
m_IUsPerDecimil = aIusPerDecimil;
iuPerDeviceUnit = 1.0 / aIusPerDecimil;
/* We don't handle the filmbox, and it's more useful to keep the
* origin at the origin */
......
......@@ -26,6 +26,7 @@ void HPGL_PLOTTER::SetViewport( const wxPoint& aOffset, double aIusPerDecimil,
wxASSERT( !outputFile );
plotOffset = aOffset;
plotScale = aScale;
m_IUsPerDecimil = aIusPerDecimil;
iuPerDeviceUnit = PLUsPERDECIMIL / aIusPerDecimil;
/* Compute the paper size in IUs */
paperSize = pageInfo.GetSizeMils();
......
......@@ -52,6 +52,7 @@ void PDF_PLOTTER::SetViewport( const wxPoint& aOffset, double aIusPerDecimil,
plotMirror = aMirror;
plotOffset = aOffset;
plotScale = aScale;
m_IUsPerDecimil = aIusPerDecimil;
// The CTM is set to 1 user unit per decimil
iuPerDeviceUnit = 1.0 / aIusPerDecimil;
......@@ -425,10 +426,6 @@ int PDF_PLOTTER::startPdfStream(int handle)
/**
* 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()
{
......@@ -730,7 +727,7 @@ void PDF_PLOTTER::Text( const wxPoint& aPos,
bool aBold )
{
// Emit native PDF text (if requested)
if( psTextMode != PSTEXTMODE_STROKE )
if( m_textMode != PLOTTEXTMODE_STROKE )
{
const char *fontname = aItalic ? (aBold ? "/KicadFontBI" : "/KicadFontI")
: (aBold ? "/KicadFontB" : "/KicadFont");
......@@ -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 ",
ctm_a, ctm_b, ctm_c, ctm_d, ctm_e, ctm_f,
fontname, heightFactor,
(psTextMode == PSTEXTMODE_NATIVE) ? 0 : 3,
(m_textMode == PLOTTEXTMODE_NATIVE) ? 0 : 3,
wideningFactor * 100 );
// The text must be escaped correctly
......@@ -763,7 +760,7 @@ void PDF_PLOTTER::Text( const wxPoint& aPos,
/* We are still in text coordinates, plot the overbars (if we're
* not doing phantom text) */
if( psTextMode == PSTEXTMODE_NATIVE )
if( m_textMode == PLOTTEXTMODE_NATIVE )
{
std::vector<int> pos_pairs;
postscriptOverlinePositions( aText, aSize.x, aItalic, aBold, &pos_pairs );
......@@ -786,7 +783,7 @@ void PDF_PLOTTER::Text( const wxPoint& aPos,
}
// 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,
aWidth, aItalic, aBold );
......
......@@ -308,6 +308,7 @@ void PS_PLOTTER::SetViewport( const wxPoint& aOffset, double aIusPerDecimil,
plotMirror = aMirror;
plotOffset = aOffset;
plotScale = aScale;
m_IUsPerDecimil = aIusPerDecimil;
iuPerDeviceUnit = 1.0 / aIusPerDecimil;
/* Compute the paper size in IUs */
paperSize = pageInfo.GetSizeMils();
......@@ -818,7 +819,7 @@ void PS_PLOTTER::Text( const wxPoint& aPos,
SetColor( aColor );
// Draw the native postscript text (if requested)
if( psTextMode == PSTEXTMODE_NATIVE )
if( m_textMode == PLOTTEXTMODE_NATIVE )
{
const char *fontname = aItalic ? (aBold ? "/KicadFont-BoldOblique"
: "/KicadFont-Oblique")
......@@ -862,7 +863,7 @@ void PS_PLOTTER::Text( const wxPoint& aPos,
}
// Draw the hidden postscript text (if requested)
if( psTextMode == PSTEXTMODE_PHANTOM )
if( m_textMode == PLOTTEXTMODE_PHANTOM )
{
fputsPostscriptString( outputFile, aText );
DPOINT pos_dev = userToDeviceCoordinates( aPos );
......@@ -871,7 +872,7 @@ void PS_PLOTTER::Text( const wxPoint& aPos,
}
// 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,
aWidth, aItalic, aBold );
......
......@@ -16,6 +16,32 @@
#include <drawtxt.h>
#include <class_title_block.h>
wxString GetDefaultPlotExtension( PlotFormat aFormat )
{
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();
case PLOT_FORMAT_GERBER:
return GERBER_PLOTTER::GetDefaultFileExtension();
default:
wxASSERT( false );
return wxEmptyString;
}
}
/* Plot sheet references
* margin is in mils (1/1000 inch)
*/
......
......@@ -188,7 +188,8 @@ void DIALOG_PLOT_SCHEMATIC_DXF::CreateDXFFile( )
plot_offset.x = 0;
plot_offset.y = 0;
plotFileName = schframe->GetUniqueFilenameForCurrentSheet() + wxT( ".dxf" );
plotFileName = schframe->GetUniqueFilenameForCurrentSheet() + '.'
+ DXF_PLOTTER::GetDefaultFileExtension();
PlotOneSheetDXF( plotFileName, screen, plot_offset, 1 );
......@@ -229,9 +230,8 @@ void DIALOG_PLOT_SCHEMATIC_DXF::PlotOneSheetDXF( const wxString& FileName,
const PAGE_INFO& pageInfo = screen->GetPageSettings();
plotter->SetPageSettings( pageInfo );
plotter->SetViewport( plot_offset, IU_PER_DECIMILS, scale, 0 );
plotter->SetColorMode( m_plotColorOpt );
plotter->SetViewport( plot_offset, IU_PER_DECIMILS, scale, false );
// Init :
plotter->SetCreator( wxT( "Eeschema-DXF" ) );
......
......@@ -336,7 +336,8 @@ void DIALOG_PLOT_SCHEMATIC_HPGL::Plot_Schematic_HPGL( bool aPlotAll )
plotOffset.x = -s_Offset.x;
plotOffset.y = -s_Offset.y;
plotFileName = m_Parent->GetUniqueFilenameForCurrentSheet() + wxT( ".plt" );
plotFileName = m_Parent->GetUniqueFilenameForCurrentSheet() + '.'
+ HPGL_PLOTTER::GetDefaultFileExtension();
LOCALE_IO toggle;
......@@ -379,9 +380,7 @@ void DIALOG_PLOT_SCHEMATIC_HPGL::Plot_1_Page_HPGL( const wxString& FileName,
HPGL_PLOTTER* plotter = new HPGL_PLOTTER();
plotter->SetPageSettings( pageInfo );
plotter->SetViewport( offset, IU_PER_DECIMILS, plot_scale, 0 );
plotter->SetDefaultLineWidth( g_DrawDefaultLineThickness );
plotter->SetViewport( offset, IU_PER_DECIMILS, plot_scale, false );
// Init :
plotter->SetCreator( wxT( "Eeschema-HPGL" ) );
......
......@@ -193,8 +193,6 @@ void DIALOG_PLOT_SCHEMATIC_PDF::createPDFFile()
plotter->SetDefaultLineWidth( g_DrawDefaultLineThickness );
plotter->SetColorMode( m_plotColorOpt );
plotter->SetCreator( wxT( "Eeschema-PDF" ) );
plotter->SetPsTextMode( PSTEXTMODE_PHANTOM );
// First page handling is different
bool first_page = true;
......@@ -220,8 +218,8 @@ void DIALOG_PLOT_SCHEMATIC_PDF::createPDFFile()
if( first_page ) {
wxString msg;
wxString plotFileName = m_Parent->GetUniqueFilenameForCurrentSheet()
+ wxT( ".pdf" );
wxString plotFileName = m_Parent->GetUniqueFilenameForCurrentSheet() + '.'
+ PDF_PLOTTER::GetDefaultFileExtension();
msg.Printf( _( "Plot: %s " ), GetChars( plotFileName ) );
m_MsgBox->AppendText( msg );
......@@ -291,8 +289,8 @@ void DIALOG_PLOT_SCHEMATIC_PDF::plotSetupPage( PDF_PLOTTER* plotter,
double scalex = (double) plotPage.GetWidthMils() / actualPage.GetWidthMils();
double scaley = (double) plotPage.GetHeightMils() / actualPage.GetHeightMils();
double scale = MIN( scalex, scaley );
plotter->SetViewport( wxPoint( 0, 0 ), IU_PER_DECIMILS, scale, 0 );
plotter->SetPageSettings( plotPage );
plotter->SetViewport( wxPoint( 0, 0 ), IU_PER_DECIMILS, scale, false );
}
void DIALOG_PLOT_SCHEMATIC_PDF::plotOneSheet( PDF_PLOTTER* plotter,
......
......@@ -242,7 +242,8 @@ void DIALOG_PLOT_SCHEMATIC_PS::createPSFile()
plot_offset.x = 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 );
......@@ -281,10 +282,9 @@ void DIALOG_PLOT_SCHEMATIC_PS::plotOneSheetPS( const wxString& FileName,
PS_PLOTTER* plotter = new PS_PLOTTER();
plotter->SetPageSettings( pageInfo );
plotter->SetViewport( plot_offset, IU_PER_DECIMILS, scale, 0 );
plotter->SetDefaultLineWidth( g_DrawDefaultLineThickness );
plotter->SetColorMode( m_plotColorOpt );
plotter->SetPsTextMode( PSTEXTMODE_STROKE );
plotter->SetViewport( plot_offset, IU_PER_DECIMILS, scale, false );
// Init :
plotter->SetCreator( wxT( "Eeschema-PS" ) );
......
......@@ -34,11 +34,14 @@ enum PlotFormat {
* 2) only use native postscript fonts
* 3) use the internal vector font and add 'phantom' text to aid
* searching
*
* This is recognized by the DXF driver too, where NATIVE emits
* TEXT entities instead of stroking the text
*/
enum PostscriptTextMode {
PSTEXTMODE_STROKE,
PSTEXTMODE_NATIVE,
PSTEXTMODE_PHANTOM
enum PlotTextMode {
PLOTTEXTMODE_STROKE,
PLOTTEXTMODE_NATIVE,
PLOTTEXTMODE_PHANTOM
};
......@@ -51,6 +54,8 @@ enum PostscriptTextMode {
class PLOTTER
{
public:
static const int DEFAULT_LINE_WIDTH = -1;
PLOTTER( );
virtual ~PLOTTER()
......@@ -97,7 +102,7 @@ public:
/**
* 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
*/
virtual void SetDefaultLineWidth( int width ) = 0;
......@@ -148,13 +153,20 @@ public:
virtual void SetViewport( const wxPoint& aOffset, double aIusPerDecimil,
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
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,
int width = -1 ) = 0;
int width = DEFAULT_LINE_WIDTH ) = 0;
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
......@@ -195,7 +207,7 @@ public:
* @param aWidth = line width
*/
virtual void PlotPoly( const std::vector< wxPoint >& aCornerList, FILL_T aFill,
int aWidth = -1 ) = 0;
int aWidth = DEFAULT_LINE_WIDTH ) = 0;
/**
* Function PlotImage
......@@ -274,6 +286,15 @@ public:
// 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:
// These are marker subcomponents
void markerCircle( const wxPoint& pos, int radius );
......@@ -298,6 +319,12 @@ protected:
/// Plot scale - chosen by the user (even implicitly with 'fit in a4')
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)
double iuPerDeviceUnit;
......@@ -336,6 +363,11 @@ public:
return PLOT_FORMAT_HPGL;
}
static wxString GetDefaultFileExtension()
{
return wxString( wxT( "plt" ) );
}
virtual bool StartPlot( FILE* fout );
virtual bool EndPlot();
......@@ -378,16 +410,16 @@ public:
virtual void SetViewport( const wxPoint& aOffset, double aIusPerDecimil,
double aScale, bool aMirror );
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,
int width = -1 );
int width = DEFAULT_LINE_WIDTH );
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,
EDA_DRAW_MODE_T tracemode );
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 FlashPadCircle( const wxPoint& pos, int diametre,
EDA_DRAW_MODE_T trace_mode );
......@@ -416,16 +448,16 @@ class PSLIKE_PLOTTER : public PLOTTER
{
public:
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 );
......@@ -510,7 +542,7 @@ protected:
double plotWidthAdj;
/// How to draw text
PostscriptTextMode psTextMode;
PlotTextMode m_textMode;
};
......@@ -521,6 +553,11 @@ public:
{
}
static wxString GetDefaultFileExtension()
{
return wxString( wxT( "ps" ) );
}
virtual PlotFormat GetPlotterType() const
{
return PLOT_FORMAT_POST;
......@@ -534,14 +571,14 @@ public:
virtual void SetViewport( const wxPoint& aOffset, double aIusPerDecimil,
double aScale, bool aMirror );
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,
int width = -1 );
int width = DEFAULT_LINE_WIDTH );
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,
FILL_T aFill, int aWidth = -1);
FILL_T aFill, int aWidth = DEFAULT_LINE_WIDTH );
virtual void PlotImage( const wxImage& aImage, const wxPoint& aPos,
double aScaleFactor );
......@@ -573,6 +610,11 @@ public:
return PLOT_FORMAT_PDF;
}
static wxString GetDefaultFileExtension()
{
return wxString( wxT( "pdf" ) );
}
virtual bool StartPlot( FILE* fout );
virtual bool EndPlot();
virtual void StartPage();
......@@ -586,14 +628,14 @@ public:
virtual void SetViewport( const wxPoint& aOffset, double aIusPerDecimil,
double aScale, bool aMirror );
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,
int width = -1 );
int width = DEFAULT_LINE_WIDTH );
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,
FILL_T aFill, int aWidth = -1);
FILL_T aFill, int aWidth = DEFAULT_LINE_WIDTH);
virtual void PenTo( const wxPoint& pos, char plume );
......@@ -665,6 +707,11 @@ public:
return PLOT_FORMAT_GERBER;
}
static wxString GetDefaultFileExtension()
{
return wxString( wxT( "pho" ) );
}
virtual bool StartPlot( FILE* fout );
virtual bool EndPlot();
virtual void SetCurrentLineWidth( int width );
......@@ -676,13 +723,13 @@ public:
virtual void SetViewport( const wxPoint& aOffset, double aIusPerDecimil,
double aScale, bool aMirror );
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,
int width = -1 );
int width = DEFAULT_LINE_WIDTH );
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,
FILL_T aFill, int aWidth = -1);
FILL_T aFill, int aWidth = DEFAULT_LINE_WIDTH );
virtual void PenTo( const wxPoint& pos, char plume );
virtual void FlashPadCircle( const wxPoint& pos, int diametre,
......@@ -727,10 +774,17 @@ public:
return PLOT_FORMAT_DXF;
}
/// We can plot text as strokes or as TEXT entities
void SetDXFTextMode( bool aTextAsLines )
static wxString GetDefaultFileExtension()
{
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 );
......@@ -755,15 +809,15 @@ public:
virtual void SetViewport( const wxPoint& aOffset, double aIusPerDecimil,
double aScale, bool aMirror );
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,
int width = -1 );
int width = DEFAULT_LINE_WIDTH );
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,
EDA_DRAW_MODE_T tracemode );
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 FlashPadCircle( const wxPoint& pos, int diametre,
EDA_DRAW_MODE_T trace_mode );
......@@ -790,4 +844,9 @@ protected:
int currentColor;
};
/** Returns the default plot extension for a format
*/
wxString GetDefaultPlotExtension( PlotFormat aFormat );
#endif // PLOT_COMMON_H_
......@@ -55,7 +55,7 @@ void GenDrillMapFile( BOARD* aPcb, FILE* aFile, const wxString& aFullFileName,
case PLOT_FORMAT_GERBER:
offset = auxoffset;
plotter = new GERBER_PLOTTER();
plotter->SetViewport( offset, IU_PER_DECIMILS, scale, 0 );
plotter->SetViewport( offset, IU_PER_DECIMILS, scale, false );
break;
case PLOT_FORMAT_HPGL: // Scale for HPGL format.
......@@ -66,7 +66,7 @@ void GenDrillMapFile( BOARD* aPcb, FILE* aFile, const wxString& aFullFileName,
hpgl_plotter->SetPenSpeed( plot_opts.m_HPGLPenSpeed );
hpgl_plotter->SetPenOverlap( 0 );
plotter->SetPageSettings( aSheet );
plotter->SetViewport( offset, IU_PER_DECIMILS, scale, 0 );
plotter->SetViewport( offset, IU_PER_DECIMILS, scale, false );
}
break;
......@@ -100,7 +100,7 @@ void GenDrillMapFile( BOARD* aPcb, FILE* aFile, const wxString& aFullFileName,
PS_PLOTTER* ps_plotter = new PS_PLOTTER;
plotter = ps_plotter;
ps_plotter->SetPageSettings( pageA4 );
plotter->SetViewport( offset, IU_PER_DECIMILS, scale, 0 );
plotter->SetViewport( offset, IU_PER_DECIMILS, scale, false );
}
break;
......@@ -109,7 +109,7 @@ void GenDrillMapFile( BOARD* aPcb, FILE* aFile, const wxString& aFullFileName,
DXF_PLOTTER* dxf_plotter = new DXF_PLOTTER;
plotter = dxf_plotter;
plotter->SetPageSettings( aSheet );
plotter->SetViewport( offset, IU_PER_DECIMILS, scale, 0 );
plotter->SetViewport( offset, IU_PER_DECIMILS, scale, false );
}
break;
......
......@@ -607,22 +607,22 @@ void DIALOG_GENDRILL::GenDrillMap( const wxString aFileName,
switch( format )
{
case PLOT_FORMAT_HPGL:
ext = wxT( "plt" );
ext = HPGL_PLOTTER::GetDefaultFileExtension();
wildcard = _( "HPGL plot files (.plt)|*.plt" );
break;
case PLOT_FORMAT_POST:
ext = wxT( "ps" );
ext = PS_PLOTTER::GetDefaultFileExtension();
wildcard = _( "PostScript files (.ps)|*.ps" );
break;
case PLOT_FORMAT_GERBER:
ext = wxT( "pho" );
ext = GERBER_PLOTTER::GetDefaultFileExtension();
wildcard = _( "Gerber files (.pho)|*.pho" );
break;
case PLOT_FORMAT_DXF:
ext = wxT( "dxf" );
ext = DXF_PLOTTER::GetDefaultFileExtension();
wildcard = _( "DXF files (.dxf)|*.dxf" );
break;
......
......@@ -373,7 +373,7 @@ void PCB_PLOT_PARAMS_PARSER::Parse( PCB_PLOT_PARAMS* aPcbPlotParams ) throw( IO_
aPcbPlotParams->subtractMaskFromSilk = ParseBool();
break;
case T_outputformat:
aPcbPlotParams->m_PlotFormat = ParseInt( 0, 3 );
aPcbPlotParams->m_PlotFormat = static_cast<PlotFormat>(ParseInt( 0, 3 ));
break;
case T_mirror:
aPcbPlotParams->m_PlotMirror = ParseBool();
......
......@@ -26,6 +26,7 @@
#include <wx/wx.h>
#include <pcb_plot_params_lexer.h>
#include <eda_text.h> // EDA_DRAW_MODE_T
#include <plot_common.h>
class PCB_PLOT_PARAMS_PARSER;
class LINE_READER;
......@@ -64,7 +65,7 @@ public:
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) */
PlotFormat m_PlotFormat; ///< id for plot format
bool m_PlotMirror;
enum DrillShapeOptT {
......@@ -107,8 +108,8 @@ public:
bool operator==( const PCB_PLOT_PARAMS &aPcbPlotParams ) const;
bool operator!=( const PCB_PLOT_PARAMS &aPcbPlotParams ) const;
void SetPlotFormat( int aFormat ) { m_PlotFormat = aFormat; };
int GetPlotFormat() const { return m_PlotFormat; };
void SetPlotFormat( PlotFormat aFormat ) { m_PlotFormat = aFormat; };
PlotFormat GetPlotFormat() const { return m_PlotFormat; };
void SetOutputDirectory( wxString aDir ) { outputDirectory = aDir; };
wxString GetOutputDirectory() const { return outputDirectory; };
void SetUseGerberExtensions( bool aUse ) { useGerberExtensions = aUse; };
......
......@@ -56,7 +56,6 @@
#define MIN_SCALE 0.01
#define MAX_SCALE 100.0
static bool setDouble( double* aDouble, double aValue, double aMin, double aMax )
{
if( aValue < aMin )
......@@ -111,8 +110,6 @@ private:
};
//const int UNITS_MILS = 1000;
DIALOG_PLOT::DIALOG_PLOT( PCB_EDIT_FRAME* aParent ) :
DIALOG_PLOT_BASE( aParent ),
m_parent( aParent ),
......@@ -567,7 +564,7 @@ void DIALOG_PLOT::applyPlotSettings()
tempOptions.SetUseGerberExtensions( m_useGerberExtensions->GetValue() );
tempOptions.SetPlotFormat( m_plotFormatOpt->GetSelection() );
tempOptions.SetPlotFormat( static_cast<PlotFormat>(m_plotFormatOpt->GetSelection()) );
long selectedLayers = 0;
unsigned int i;
......@@ -601,7 +598,6 @@ void DIALOG_PLOT::Plot( wxCommandEvent& event )
{
int layer;
wxFileName fn;
wxString ext;
applyPlotSettings();
......@@ -676,25 +672,16 @@ void DIALOG_PLOT::Plot( wxCommandEvent& event )
switch( m_plotOpts.GetPlotFormat() )
{
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" );
m_plotOpts.m_PlotScale = 1.0; // No scaling for these
break;
default:
break;
}
wxString file_ext( GetDefaultPlotExtension( m_plotOpts.GetPlotFormat() ) );
// Test for a reasonable scale value
if( m_plotOpts.m_PlotScale < MIN_SCALE )
DisplayInfoMessage( this,
......@@ -704,6 +691,7 @@ void DIALOG_PLOT::Plot( wxCommandEvent& event )
DisplayInfoMessage( this,
_( "Warning: Scale option set to a very large value" ) );
// Save the current plot options in the board
m_parent->SetPlotSettings( m_plotOpts );
long layerMask = 1;
......@@ -803,7 +791,7 @@ void DIALOG_PLOT::Plot( wxCommandEvent& event )
}
else
{
fn.SetExt( ext );
fn.SetExt( file_ext );
}
switch( m_plotOpts.GetPlotFormat() )
......
......@@ -116,7 +116,6 @@ bool PCB_BASE_FRAME::ExportToPostScriptFile( const wxString& aFullFileName, int
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 */
......
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