Tune pcbnew plot dialog. Make actual plotting code independent of dialog widgets and get settings from PCB_PLOT_PARAMS instead.

This commit is contained in:
Marco Mattila 2011-02-17 00:54:44 +02:00
parent e30ceb0a7f
commit ac0979fa99
6 changed files with 4475 additions and 3242 deletions

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Sep 8 2010)
// C++ code generated with wxFormBuilder (version Nov 18 2010)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
@ -28,7 +28,7 @@ DIALOG_PLOT_BASE::DIALOG_PLOT_BASE( wxWindow* parent, wxWindowID id, const wxStr
m_staticText121->Wrap( -1 );
bSizer27->Add( m_staticText121, 0, wxTOP, 5 );
wxString m_plotFormatOptChoices[] = { _("HPGL"), _("Gerber"), _("Postscript"), _("Postscript A4"), _("DXF") };
wxString m_plotFormatOptChoices[] = { _("HPGL"), _("Gerber"), _("Postscript"), _("DXF") };
int m_plotFormatOptNChoices = sizeof( m_plotFormatOptChoices ) / sizeof( wxString );
m_plotFormatOpt = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_plotFormatOptNChoices, m_plotFormatOptChoices, 0 );
m_plotFormatOpt->SetSelection( 0 );
@ -272,6 +272,9 @@ DIALOG_PLOT_BASE::DIALOG_PLOT_BASE( wxWindow* parent, wxWindowID id, const wxStr
m_plotPSNegativeOpt = new wxCheckBox( this, wxID_ANY, _("Negative plot"), wxDefaultPosition, wxDefaultSize, 0 );
m_PSOptionsSizer->Add( m_plotPSNegativeOpt, 0, wxALL, 2 );
m_usePsA4Opt = new wxCheckBox( this, wxID_ANY, _("Force A4 paper size"), wxDefaultPosition, wxDefaultSize, 0 );
m_PSOptionsSizer->Add( m_usePsA4Opt, 0, wxALL, 2 );
m_PlotOptionsSizer->Add( m_PSOptionsSizer, 0, wxALL|wxEXPAND, 3 );
bUpperSizer->Add( m_PlotOptionsSizer, 0, 0, 5 );

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Sep 8 2010)
// C++ code generated with wxFormBuilder (version Nov 18 2010)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
@ -84,6 +84,7 @@ class DIALOG_PLOT_BASE : public wxDialog
wxStaticText* m_staticText8;
wxTextCtrl* m_fineAdjustYscaleOpt;
wxCheckBox* m_plotPSNegativeOpt;
wxCheckBox* m_usePsA4Opt;
wxStaticText* m_staticText2;
wxTextCtrl* m_messagesBox;

View File

@ -356,7 +356,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, 4 );
aPcbPlotParams->m_PlotFormat = ParseInt( 0, 3 );
break;
case T_mirror:
aPcbPlotParams->m_PlotMirror = ParseBool();

View File

@ -102,6 +102,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 SetOutputDirectory( wxString aDir ) { outputDirectory = aDir; };
wxString GetOutputDirectory() const { return outputDirectory; };
void SetUseGerberExtensions( bool aUse ) { useGerberExtensions = aUse; };

View File

@ -62,38 +62,6 @@ public:
double m_XScaleAdjust;
double m_YScaleAdjust;
bool useA4()
{
return m_plotFormatOpt->GetSelection() == 3;
}
/**
* Function getFormat
* returns one of the values from the m_PlotFormat enum. If the 4th
* radio button is selected, map this back to postscript.
*/
PlotFormat getFormat()
{
int radioNdx = m_plotFormatOpt->GetSelection();
// change the A4 to the simple postscript, according to the
// m_PlotFormat enum
switch( radioNdx )
{
case 3:
radioNdx = PLOT_FORMAT_POST;
break;
case 4:
radioNdx = PLOT_FORMAT_DXF;
break;
}
return PlotFormat( radioNdx );
}
public: DIALOG_PLOT( WinEDA_PcbFrame* parent );
private:
void Init_Dialog();
@ -138,7 +106,7 @@ void DIALOG_PLOT::Init_Dialog()
m_Config->Read( CONFIG_XFINESCALE_ADJ, &m_XScaleAdjust );
m_Config->Read( CONFIG_YFINESCALE_ADJ, &m_YScaleAdjust );
m_plotFormatOpt->SetSelection( g_PcbPlotOptions.m_PlotFormat );
m_plotFormatOpt->SetSelection( g_PcbPlotOptions.GetPlotFormat() );
// Set units and value for HPGL pen size.
AddUnitSymbol( *m_textPenSize, g_UserUnit );
@ -317,9 +285,7 @@ void DIALOG_PLOT::OnOutputDirectoryBrowseClicked( wxCommandEvent& event )
void DIALOG_PLOT::SetPlotFormat( wxCommandEvent& event )
{
int format = getFormat();
switch( format )
switch( m_plotFormatOpt->GetSelection() )
{
case PLOT_FORMAT_POST:
default:
@ -536,7 +502,7 @@ void DIALOG_PLOT::applyPlotSettings()
tempOptions.SetUseGerberExtensions( m_useGerberExtensions->GetValue() );
tempOptions.m_PlotFormat = m_plotFormatOpt->GetSelection();
tempOptions.SetPlotFormat( m_plotFormatOpt->GetSelection() );
long selectedLayers = 0;
unsigned int i;
@ -574,7 +540,7 @@ void DIALOG_PLOT::Plot( wxCommandEvent& event )
applyPlotSettings();
// Create output directory if it does not exist
wxFileName outputDir = wxFileName::DirName( m_outputDirectoryName->GetValue() );
wxFileName outputDir = wxFileName::DirName( g_PcbPlotOptions.GetOutputDirectory() );
wxString boardFilePath = ( (wxFileName) m_Parent->GetScreen()->GetFileName()).GetPath();
if( !outputDir.MakeAbsolute( boardFilePath ) )
@ -636,9 +602,7 @@ void DIALOG_PLOT::Plot( wxCommandEvent& event )
if( m_fineAdjustYscaleOpt->IsEnabled() && m_YScaleAdjust != 0.0 )
g_PcbPlotOptions.m_FineScaleAdjustY = m_YScaleAdjust;
int format = getFormat();
switch( format )
switch( g_PcbPlotOptions.GetPlotFormat() )
{
case PLOT_FORMAT_POST:
ext = wxT( "ps" );
@ -667,13 +631,12 @@ void DIALOG_PLOT::Plot( wxCommandEvent& event )
DisplayInfoMessage( this,
_( "Warning: Scale option set to a very large value" ) );
unsigned int i;
for( i = 0; i < layerList.size(); i++ )
long layerMask = 1;
for( layer = 0; layer < NB_LAYERS; layer++, layerMask <<= 1 )
{
bool success = false;
if( layerCheckListBox->IsChecked( i ) )
if( g_PcbPlotOptions.GetLayerSelection() & layerMask )
{
layer = layerList[i];
fn = m_Parent->GetScreen()->GetFileName();
fn.SetPath( outputDir.GetPath() );
@ -684,7 +647,8 @@ void DIALOG_PLOT::Plot( wxCommandEvent& event )
// Use Gerber Extensions based on layer number
// (See http://en.wikipedia.org/wiki/Gerber_File)
if( (format == PLOT_FORMAT_GERBER) && m_useGerberExtensions->GetValue() )
if( ( g_PcbPlotOptions.GetPlotFormat() == PLOT_FORMAT_GERBER )
&& m_useGerberExtensions->GetValue() )
{
switch( layer )
{
@ -764,10 +728,11 @@ void DIALOG_PLOT::Plot( wxCommandEvent& event )
fn.SetExt( ext );
}
switch( format )
switch( g_PcbPlotOptions.GetPlotFormat() )
{
case PLOT_FORMAT_POST:
success = m_Parent->Genere_PS( fn.GetFullPath(), layer, useA4(),
success = m_Parent->Genere_PS( fn.GetFullPath(), layer,
m_usePsA4Opt->GetValue(),
g_PcbPlotOptions.m_PlotMode );
break;