Commit 4451dd3a authored by Marco Mattila's avatar Marco Mattila Committed by Dick Hollenbeck

This patch adds an output directory field into the plot dialog in

pcbnew and directs gerber/hpgl etc. output into that directory.
There's a browse button that opens a dialog for browsing. If the
directory does not exist, it is created. Tested in linux, not in
windows. Wxwidgets methods are used for file (name) manipulations, so
things are probably ok in windows, too.

marco
parent f6c80664
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Apr 16 2008)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#ifndef __dialog_plot_base__
#define __dialog_plot_base__
#include <wx/intl.h>
#include <wx/string.h>
#include <wx/sizer.h>
#include <wx/statbox.h>
#include <wx/gdicmn.h>
#include <wx/checkbox.h>
#include <wx/font.h>
#include <wx/colour.h>
#include <wx/settings.h>
#include <wx/radiobox.h>
#include <wx/stattext.h>
#include <wx/textctrl.h>
#include <wx/button.h>
#include <wx/dialog.h>
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
/// Class DIALOG_PLOT_BASE
///////////////////////////////////////////////////////////////////////////////
class DIALOG_PLOT_BASE : public wxDialog
{
private:
protected:
enum
{
ID_USE_GERBER_EXTENSIONS = 1000,
ID_ALLOW_PRINT_PAD_ON_SILKSCREEN,
ID_PRINT_VALUE,
ID_PRINT_REF,
ID_PRINT_MODULE_TEXTS,
ID_FORCE_PRINT_INVISIBLE_TEXT,
ID_DRILL_SHAPE_OPT,
ID_MIROR_OPT,
ID_MASKVIA_OPT,
ID_EXEC_PLOT,
ID_SAVE_OPT_PLOT,
ID_CREATE_DRILL_FILE,
};
wxStaticBoxSizer* m_CopperLayersBoxSizer;
wxStaticBoxSizer* m_TechnicalLayersBoxSizer;
wxCheckBox* m_Use_Gerber_Extensions;
wxCheckBox* m_Exclude_Edges_Pcb;
wxCheckBox* m_Plot_Sheet_Ref;
wxCheckBox* m_Plot_Pads_on_Silkscreen;
wxCheckBox* m_Plot_Text_Value;
wxCheckBox* m_Plot_Text_Ref;
wxCheckBox* m_Plot_Text_Div;
wxCheckBox* m_Plot_Invisible_Text;
wxRadioBox* m_Drill_Shape_Opt;
wxRadioBox* m_Scale_Opt;
wxRadioBox* m_PlotModeOpt;
wxRadioBox* m_Choice_Plot_Offset;
wxRadioBox* m_PlotFormatOpt;
wxStaticText* m_textPenSize;
wxTextCtrl* m_HPGLPenSizeOpt;
wxStaticText* m_staticText3;
wxTextCtrl* m_HPGLPenSpeedOpt;
wxStaticText* m_textPenOvr;
wxTextCtrl* m_HPGLPenOverlayOpt;
wxCheckBox* m_Plot_PS_Negative;
wxCheckBox* m_PlotMirorOpt;
wxCheckBox* m_PlotNoViaOnMaskOpt;
wxStaticText* m_staticText6;
wxTextCtrl* m_LinesWidth;
wxStaticText* m_staticText7;
wxTextCtrl* m_FineAdjustXscaleOpt;
wxStaticText* m_staticText8;
wxTextCtrl* m_FineAdjustYscaleOpt;
wxButton* m_PlotButton;
wxButton* m_buttonSaveOpt;
wxButton* m_buttonDrill;
wxButton* m_buttonQuit;
wxStaticText* m_staticText2;
wxTextCtrl* m_MessagesBox;
// Virtual event handlers, overide them in your derived class
virtual void OnCloseWindow( wxCloseEvent& event ){ event.Skip(); }
virtual void OnInitDialog( wxInitDialogEvent& event ){ event.Skip(); }
virtual void SetPlotFormat( wxCommandEvent& event ){ event.Skip(); }
virtual void Plot( wxCommandEvent& event ){ event.Skip(); }
virtual void SaveOptPlot( wxCommandEvent& event ){ event.Skip(); }
virtual void CreateDrillFile( wxCommandEvent& event ){ event.Skip(); }
virtual void OnQuit( wxCommandEvent& event ){ event.Skip(); }
public:
DIALOG_PLOT_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Plot"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 575,590 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
~DIALOG_PLOT_BASE();
};
#endif //__dialog_plot_base__
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Dec 21 2009)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#ifndef __dialog_plot_base__
#define __dialog_plot_base__
#include <wx/intl.h>
#include <wx/string.h>
#include <wx/sizer.h>
#include <wx/statbox.h>
#include <wx/gdicmn.h>
#include <wx/checkbox.h>
#include <wx/font.h>
#include <wx/colour.h>
#include <wx/settings.h>
#include <wx/radiobox.h>
#include <wx/stattext.h>
#include <wx/textctrl.h>
#include <wx/button.h>
#include <wx/dialog.h>
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
/// Class DIALOG_PLOT_BASE
///////////////////////////////////////////////////////////////////////////////
class DIALOG_PLOT_BASE : public wxDialog
{
private:
protected:
enum
{
ID_USE_GERBER_EXTENSIONS = 1000,
ID_ALLOW_PRINT_PAD_ON_SILKSCREEN,
ID_PRINT_VALUE,
ID_PRINT_REF,
ID_PRINT_MODULE_TEXTS,
ID_FORCE_PRINT_INVISIBLE_TEXT,
ID_DRILL_SHAPE_OPT,
ID_BROWSE_OUTPUT_DIRECTORY,
ID_MIROR_OPT,
ID_MASKVIA_OPT,
ID_EXEC_PLOT,
ID_SAVE_OPT_PLOT,
ID_CREATE_DRILL_FILE,
};
wxStaticBoxSizer* m_CopperLayersBoxSizer;
wxStaticBoxSizer* m_TechnicalLayersBoxSizer;
wxCheckBox* m_Use_Gerber_Extensions;
wxCheckBox* m_Exclude_Edges_Pcb;
wxCheckBox* m_Plot_Sheet_Ref;
wxCheckBox* m_Plot_Pads_on_Silkscreen;
wxCheckBox* m_Plot_Text_Value;
wxCheckBox* m_Plot_Text_Ref;
wxCheckBox* m_Plot_Text_Div;
wxCheckBox* m_Plot_Invisible_Text;
wxRadioBox* m_Drill_Shape_Opt;
wxRadioBox* m_Scale_Opt;
wxRadioBox* m_PlotModeOpt;
wxRadioBox* m_Choice_Plot_Offset;
wxRadioBox* m_PlotFormatOpt;
wxStaticText* m_textPenSize;
wxTextCtrl* m_HPGLPenSizeOpt;
wxStaticText* m_staticText3;
wxTextCtrl* m_HPGLPenSpeedOpt;
wxStaticText* m_textPenOvr;
wxTextCtrl* m_HPGLPenOverlayOpt;
wxCheckBox* m_Plot_PS_Negative;
wxTextCtrl* m_OutputDirectory;
wxButton* m_BrowseButton;
wxCheckBox* m_PlotMirorOpt;
wxCheckBox* m_PlotNoViaOnMaskOpt;
wxStaticText* m_staticText6;
wxTextCtrl* m_LinesWidth;
wxStaticText* m_staticText7;
wxTextCtrl* m_FineAdjustXscaleOpt;
wxStaticText* m_staticText8;
wxTextCtrl* m_FineAdjustYscaleOpt;
wxButton* m_PlotButton;
wxButton* m_buttonSaveOpt;
wxButton* m_buttonDrill;
wxButton* m_buttonQuit;
wxStaticText* m_staticText2;
wxTextCtrl* m_MessagesBox;
// Virtual event handlers, overide them in your derived class
virtual void OnCloseWindow( wxCloseEvent& event ) { event.Skip(); }
virtual void OnInitDialog( wxInitDialogEvent& event ) { event.Skip(); }
virtual void SetPlotFormat( wxCommandEvent& event ) { event.Skip(); }
virtual void OnOutputDirectoryBrowseClicked( wxCommandEvent& event ) { event.Skip(); }
virtual void Plot( wxCommandEvent& event ) { event.Skip(); }
virtual void SaveOptPlot( wxCommandEvent& event ) { event.Skip(); }
virtual void CreateDrillFile( wxCommandEvent& event ) { event.Skip(); }
virtual void OnQuit( wxCommandEvent& event ) { event.Skip(); }
public:
DIALOG_PLOT_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Plot"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 575,590 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
~DIALOG_PLOT_BASE();
};
#endif //__dialog_plot_base__
......@@ -44,6 +44,7 @@ PCB_Plot_Options::PCB_Plot_Options()
ScaleAdjX = 1.0;
ScaleAdjY = 1.0;
PlotScaleOpt = 1;
outputDirectory = wxT( "" );
}
......@@ -111,6 +112,7 @@ private:
void Plot( wxCommandEvent& event );
void OnQuit( wxCommandEvent& event );
void OnClose( wxCloseEvent& event );
void OnOutputDirectoryBrowseClicked( wxCommandEvent& event );
void SetPlotFormat( wxCommandEvent& event );
void OnSetScaleOpt( wxCommandEvent& event );
void SaveOptPlot( wxCommandEvent& event );
......@@ -138,6 +140,7 @@ DIALOG_PLOT::DIALOG_PLOT( WinEDA_PcbFrame* parent ) :
void DIALOG_PLOT::Init_Dialog()
{
wxString msg;
wxFileName fileName;
BOARD* board = m_Parent->GetBoard();
......@@ -283,6 +286,17 @@ void DIALOG_PLOT::Init_Dialog()
// Put vias on mask layer
m_PlotNoViaOnMaskOpt->SetValue( g_pcb_plot_options.DrawViaOnMaskLayer );
// Output directory
if( g_pcb_plot_options.GetOutputDirectory().IsEmpty() )
{
fileName = m_Parent->GetScreen()->m_FileName;
m_OutputDirectory->SetValue( fileName.GetPath() );
}
else
{
m_OutputDirectory->SetValue( g_pcb_plot_options.GetOutputDirectory() );
}
// Update options values:
wxCommandEvent cmd_event;
SetPlotFormat( cmd_event );
......@@ -322,6 +336,15 @@ void DIALOG_PLOT::OnSetScaleOpt( wxCommandEvent& event )
m_Plot_Sheet_Ref->SetValue( false );
}
void DIALOG_PLOT::OnOutputDirectoryBrowseClicked( wxCommandEvent& event )
{
wxString currentDir;
currentDir = m_OutputDirectory->GetValue();
wxDirDialog dirDialog( this, _( "Select Output Directory" ), currentDir );
if( dirDialog.ShowModal() == wxID_CANCEL )
return;
m_OutputDirectory->SetValue( dirDialog.GetPath() );
}
void DIALOG_PLOT::SetPlotFormat( wxCommandEvent& event )
{
......@@ -487,6 +510,8 @@ void DIALOG_PLOT::SaveOptPlot( wxCommandEvent& event )
}
g_pcb_plot_options.Plot_PS_Negative = m_Plot_PS_Negative->GetValue();
g_pcb_plot_options.SetOutputDirectory( m_OutputDirectory->GetValue() );
}
......@@ -500,6 +525,22 @@ void DIALOG_PLOT::Plot( wxCommandEvent& event )
SaveOptPlot( event );
// Create output directory if it does not exist
if( !wxFileName::DirExists( m_OutputDirectory->GetValue() ) )
{
if( wxMkdir( m_OutputDirectory->GetValue() ) )
{
wxString msg;
msg.Printf( _( "Directory %s created.\n" ), GetChars( m_OutputDirectory->GetValue() ) );
m_MessagesBox->AppendText( msg );
}
else
{
wxMessageBox( _( "Cannot create output directory!" ), _( "Plot" ), wxICON_INFORMATION );
return;
}
}
switch( g_pcb_plot_options.PlotScaleOpt )
{
default:
......@@ -574,6 +615,7 @@ void DIALOG_PLOT::Plot( wxCommandEvent& event )
s_SelectedLayers |= mask;
fn = m_Parent->GetScreen()->m_FileName;
fn.SetPath( m_OutputDirectory->GetValue() );
// Create file name.
wxString layername = board->GetLayerName( layer );
......
......@@ -64,8 +64,12 @@ public:
double ScaleAdjX;
double ScaleAdjY;
wxString outputDirectory;
public:
PCB_Plot_Options();
void SetOutputDirectory( wxString aDir ) { outputDirectory = aDir; };
wxString GetOutputDirectory() { return outputDirectory; };
};
extern PCB_Plot_Options g_pcb_plot_options;
......
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