Commit ab58dbfc authored by jean-pierre charras's avatar jean-pierre charras
Browse files

Pcbnew: Rework on Gerber ouput: allows choice between format 4.5 and 4.6. Fix...

Pcbnew: Rework on Gerber ouput: allows choice between format 4.5 and 4.6. Fix a minor issue in Gerber layers attributes.
fix print issue when printing each layer on a separate page.
parent 5a4c16dc
Loading
Loading
Loading
Loading
+35 −22
Original line number Diff line number Diff line
@@ -15,6 +15,22 @@

#include <build_version.h>

GERBER_PLOTTER::GERBER_PLOTTER()
{
    workFile  = 0;
    finalFile = 0;
    currentAperture = apertures.end();

    // number of digits after the point (number of digits of the mantissa
    // Be carefull: the Gerber coordinates are stored in an integer
    // so 6 digits (inches) or 5 digits (mm) is a good value
    // To avoid overflow, 7 digits (inches) or 6 digits is a max.
    // with lower values than 6 digits (inches) or 5 digits (mm),
    // Creating self-intersecting polygons from non-intersecting polygons
    // happen easily.
    m_gerberUnitInch = false;
    m_gerberUnitFmt = 6;
}

void GERBER_PLOTTER::SetViewport( const wxPoint& aOffset, double aIusPerDecimil,
				  double aScale, bool aMirror )
@@ -26,40 +42,37 @@ void GERBER_PLOTTER::SetViewport( const wxPoint& aOffset, double aIusPerDecimil,
    wxASSERT( aScale == 1 );    // aScale parameter is not used in Gerber
    plotScale = 1;              // Plot scale is *always* 1.0

    m_gerberUnitInch = false;    // Currently fixed, but could be an option

    // number of digits after the point (number of digits of the mantissa
    // Be carefull: the Gerber coordinates are stored in an integer
    // so 6 digits (inches) or 5 digits (mm) is a good value
    // To avoid overflow, 7 digits (inches) or 6 digits is a max.
    // with lower values than 6 digits (inches) or 5 digits (mm),
    // Creating self-intersecting polygons from non-intersecting polygons
    // happen easily.
    m_gerberUnitFmt = m_gerberUnitInch ? 7 : 6;

    m_IUsPerDecimil = aIusPerDecimil;
    iuPerDeviceUnit = pow( 10.0, m_gerberUnitFmt ) / ( aIusPerDecimil * 10000.0 );

    if( ! m_gerberUnitInch )
        iuPerDeviceUnit *= 25.4;     // gerber output in mm

    /* We don't handle the filmbox, and it's more useful to keep the
     * origin at the origin */
    // We don't handle the filmbox, and it's more useful to keep the
    // origin at the origin
    paperSize.x = 0;
    paperSize.y = 0;
    SetDefaultLineWidth( 100 * aIusPerDecimil ); // Arbitrary default
}

void GERBER_PLOTTER::SetGerberCoordinatesFormat( int aResolution, bool aUseInches )
{
    m_gerberUnitInch = aUseInches;
    m_gerberUnitFmt = aResolution;

    iuPerDeviceUnit = pow( 10.0, m_gerberUnitFmt ) / ( m_IUsPerDecimil * 10000.0 );

    if( ! m_gerberUnitInch )
        iuPerDeviceUnit *= 25.4;     // gerber output in mm
}


/**
 * Emit a D-Code record, using proper conversions
 * to format a leading zero omitted gerber coordinate
 * (for 4 decimal positions, see header generation in start_plot
 * (for n decimal positions, see header generation in start_plot
 */
void GERBER_PLOTTER::emitDcode( const DPOINT& pt, int dcode )
{

    fprintf( outputFile, "X%dY%dD%02d*\n",
	    int( pt.x ), int( pt.y ), dcode );
	    KiROUND( pt.x ), KiROUND( pt.y ), dcode );
}

/**
@@ -357,7 +370,7 @@ void GERBER_PLOTTER::Arc( const wxPoint& aCenter, double aStAngle, double aEndAn

/**
 * Gerber polygon: they can (and *should*) be filled with the
 * appropriate G36/G37 sequence (raster fills are deprecated)
 * appropriate G36/G37 sequence
 */
void GERBER_PLOTTER:: PlotPoly( const std::vector< wxPoint >& aCornerList,
                               FILL_T aFill, int aWidth )
@@ -366,7 +379,7 @@ void GERBER_PLOTTER::PlotPoly( const std::vector< wxPoint >& aCornerList,
        return;

    // Gerber format does not know filled polygons with thick outline
    // Thereore, to plot a filled polygon with outline having a thickness,
    // Therefore, to plot a filled polygon with outline having a thickness,
    // one should plot outline as thick segments

    SetCurrentLineWidth( aWidth );
+1 −1
Original line number Diff line number Diff line
drillshape
excludeedgelayer
false
gerberprecision
hpglpendiameter
hpglpennumber
hpglpenoverlay
@@ -15,7 +16,6 @@ padsonsilk
pcbplotparams
plotframeref
plotinvisibletext
plotothertext
plotreference
plotvalue
psa4output
+21 −8
Original line number Diff line number Diff line
@@ -282,12 +282,17 @@ public:
     */
    virtual void SetTextMode( PlotTextMode mode )
    {
        // NOP for most plotters
        // NOP for most plotters.
    }

    virtual void SetLayerAttribFunction( const wxString& function )
    {
        // NOP for most plotters
        // NOP for most plotters. Only for Gerber plotter
    }

    virtual void SetGerberCoordinatesFormat( int aResolution, bool aUseInches = false )
    {
        // NOP for most plotters. Only for Gerber plotter
    }

protected:
@@ -769,12 +774,7 @@ struct APERTURE
class GERBER_PLOTTER : public PLOTTER
{
public:
    GERBER_PLOTTER()
    {
        workFile  = 0;
        finalFile = 0;
        currentAperture = apertures.end();
    }
    GERBER_PLOTTER();

    virtual PlotFormat GetPlotterType() const
    {
@@ -794,6 +794,7 @@ public:
    // RS274X has no dashing, nor colours
    virtual void SetDash( bool dashed ) {};
    virtual void SetColor( EDA_COLOR_T color ) {};
    // Currently, aScale and aMirror are not used in gerber plotter
    virtual void SetViewport( const wxPoint& aOffset, double aIusPerDecimil,
                          double aScale, bool aMirror );
    virtual void Rect( const wxPoint& p1, const wxPoint& p2, FILL_T fill,
@@ -823,6 +824,18 @@ public:
        m_attribFunction = function;
    }

    /**
     * Function SetGerberCoordinatesFormat
     * selection of Gerber units and resolution (number of digits in mantissa)
     * @param aResolution = number of digits in mantissa of coordinate
     *                      use 5 or 6 for mm and 6 or 7 for inches
     *                      do not use value > 6 (mm) or > 7 (in) to avoid overflow
     * @param aUseInches = true to use inches, false to use mm (default)
     *
     * Should be called only after SetViewport() is called
     */
    virtual void SetGerberCoordinatesFormat( int aResolution, bool aUseInches = false );

protected:
    void selectAperture( const wxSize& size, APERTURE::APERTURE_TYPE type );
    void emitDcode( const DPOINT& pt, int dcode );
+6 −3
Original line number Diff line number Diff line
@@ -167,6 +167,9 @@ void DIALOG_PLOT::Init_Dialog()
    // Option for including Gerber attributes (from Gerber X2 format) in the output
    m_useGerberAttributes->SetValue( m_plotOpts.GetUseGerberAttributes() );

    // Gerber precision for coordinates
    m_rbGerberFormat->SetSelection( m_plotOpts.GetGerberPrecision() == 5 ? 0 : 1 );

    // Option for excluding contents of "Edges Pcb" layer
    m_excludeEdgeLayerOpt->SetValue( m_plotOpts.GetExcludeEdgeLayer() );

@@ -668,11 +671,11 @@ void DIALOG_PLOT::applyPlotSettings()
    ConfigBaseWriteDouble( m_config, CONFIG_PS_FINEWIDTH_ADJ,
                           (double)m_PSWidthAdjust / IU_PER_MM );

    tempOptions.SetUseGerberExtensions( m_useGerberExtensions->GetValue() );
    tempOptions.SetFormat( GetPlotFormat() );

    tempOptions.SetUseGerberExtensions( m_useGerberExtensions->GetValue() );
    tempOptions.SetUseGerberAttributes( m_useGerberAttributes->GetValue() );

    tempOptions.SetFormat( GetPlotFormat() );
    tempOptions.SetGerberPrecision( m_rbGerberFormat->GetSelection() == 0 ? 5 : 6 );

    LSET selectedLayers;

+18 −4
Original line number Diff line number Diff line
@@ -219,22 +219,36 @@ DIALOG_PLOT_BASE::DIALOG_PLOT_BASE( wxWindow* parent, wxWindowID id, const wxStr
	
	m_PlotOptionsSizer->Add( sbSizerSoldMaskLayerOpt, 1, wxEXPAND, 5 );
	
	m_GerberOptionsSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Gerber Options") ), wxVERTICAL );
	m_GerberOptionsSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Gerber Options") ), wxHORIZONTAL );
	
	wxBoxSizer* bSizerGbrOpt;
	bSizerGbrOpt = new wxBoxSizer( wxVERTICAL );
	
	m_useGerberExtensions = new wxCheckBox( this, wxID_ANY, _("Use proper filename extensions"), wxDefaultPosition, wxDefaultSize, 0 );
	m_useGerberExtensions->SetToolTip( _("Use proper Gerber extensions - .GBL, .GTL, etc...") );
	
	m_GerberOptionsSizer->Add( m_useGerberExtensions, 0, wxLEFT|wxRIGHT|wxTOP, 2 );
	bSizerGbrOpt->Add( m_useGerberExtensions, 0, wxALL, 2 );
	
	m_useGerberAttributes = new wxCheckBox( this, wxID_ANY, _("Include extended attributes"), wxDefaultPosition, wxDefaultSize, 0 );
	m_useGerberAttributes->SetToolTip( _("Include extended attributes for non-image data in the Gerber file") );
	
	m_GerberOptionsSizer->Add( m_useGerberAttributes, 0, wxTOP|wxRIGHT|wxLEFT, 2 );
	bSizerGbrOpt->Add( m_useGerberAttributes, 0, wxALL, 2 );
	
	m_subtractMaskFromSilk = new wxCheckBox( this, wxID_ANY, _("Subtract soldermask from silkscreen"), wxDefaultPosition, wxDefaultSize, 0 );
	m_subtractMaskFromSilk->SetToolTip( _("Remove silkscreen from areas without soldermask") );
	
	m_GerberOptionsSizer->Add( m_subtractMaskFromSilk, 0, wxTOP|wxRIGHT|wxLEFT, 2 );
	bSizerGbrOpt->Add( m_subtractMaskFromSilk, 0, wxALL, 2 );
	
	
	m_GerberOptionsSizer->Add( bSizerGbrOpt, 0, wxALIGN_CENTER_VERTICAL, 5 );
	
	wxString m_rbGerberFormatChoices[] = { _("4.5 (unit  mm)"), _("4.6 (unit mm)") };
	int m_rbGerberFormatNChoices = sizeof( m_rbGerberFormatChoices ) / sizeof( wxString );
	m_rbGerberFormat = new wxRadioBox( this, wxID_ANY, _("Format"), wxDefaultPosition, wxDefaultSize, m_rbGerberFormatNChoices, m_rbGerberFormatChoices, 1, wxRA_SPECIFY_COLS );
	m_rbGerberFormat->SetSelection( 1 );
	m_rbGerberFormat->SetToolTip( _("Precision of coordinates in Gerber files/\nUse the highter value if possible.") );
	
	m_GerberOptionsSizer->Add( m_rbGerberFormat, 1, wxEXPAND|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
	
	
	m_PlotOptionsSizer->Add( m_GerberOptionsSizer, 0, wxALL|wxEXPAND, 3 );
Loading