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" ) );
......
This diff is collapsed.
......@@ -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