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) // C++ code generated with wxFormBuilder (version Dec 21 2009)
// http://www.wxformbuilder.org/ // http://www.wxformbuilder.org/
// //
// PLEASE DO "NOT" EDIT THIS FILE! // PLEASE DO "NOT" EDIT THIS FILE!
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
#ifndef __dialog_plot_base__ #ifndef __dialog_plot_base__
#define __dialog_plot_base__ #define __dialog_plot_base__
#include <wx/intl.h> #include <wx/intl.h>
#include <wx/string.h> #include <wx/string.h>
#include <wx/sizer.h> #include <wx/sizer.h>
#include <wx/statbox.h> #include <wx/statbox.h>
#include <wx/gdicmn.h> #include <wx/gdicmn.h>
#include <wx/checkbox.h> #include <wx/checkbox.h>
#include <wx/font.h> #include <wx/font.h>
#include <wx/colour.h> #include <wx/colour.h>
#include <wx/settings.h> #include <wx/settings.h>
#include <wx/radiobox.h> #include <wx/radiobox.h>
#include <wx/stattext.h> #include <wx/stattext.h>
#include <wx/textctrl.h> #include <wx/textctrl.h>
#include <wx/button.h> #include <wx/button.h>
#include <wx/dialog.h> #include <wx/dialog.h>
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
/// Class DIALOG_PLOT_BASE /// Class DIALOG_PLOT_BASE
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
class DIALOG_PLOT_BASE : public wxDialog class DIALOG_PLOT_BASE : public wxDialog
{ {
private: private:
protected: protected:
enum enum
{ {
ID_USE_GERBER_EXTENSIONS = 1000, ID_USE_GERBER_EXTENSIONS = 1000,
ID_ALLOW_PRINT_PAD_ON_SILKSCREEN, ID_ALLOW_PRINT_PAD_ON_SILKSCREEN,
ID_PRINT_VALUE, ID_PRINT_VALUE,
ID_PRINT_REF, ID_PRINT_REF,
ID_PRINT_MODULE_TEXTS, ID_PRINT_MODULE_TEXTS,
ID_FORCE_PRINT_INVISIBLE_TEXT, ID_FORCE_PRINT_INVISIBLE_TEXT,
ID_DRILL_SHAPE_OPT, ID_DRILL_SHAPE_OPT,
ID_MIROR_OPT, ID_BROWSE_OUTPUT_DIRECTORY,
ID_MASKVIA_OPT, ID_MIROR_OPT,
ID_EXEC_PLOT, ID_MASKVIA_OPT,
ID_SAVE_OPT_PLOT, ID_EXEC_PLOT,
ID_CREATE_DRILL_FILE, ID_SAVE_OPT_PLOT,
}; ID_CREATE_DRILL_FILE,
};
wxStaticBoxSizer* m_CopperLayersBoxSizer;
wxStaticBoxSizer* m_TechnicalLayersBoxSizer; wxStaticBoxSizer* m_CopperLayersBoxSizer;
wxCheckBox* m_Use_Gerber_Extensions; wxStaticBoxSizer* m_TechnicalLayersBoxSizer;
wxCheckBox* m_Exclude_Edges_Pcb; wxCheckBox* m_Use_Gerber_Extensions;
wxCheckBox* m_Plot_Sheet_Ref; wxCheckBox* m_Exclude_Edges_Pcb;
wxCheckBox* m_Plot_Pads_on_Silkscreen; wxCheckBox* m_Plot_Sheet_Ref;
wxCheckBox* m_Plot_Text_Value; wxCheckBox* m_Plot_Pads_on_Silkscreen;
wxCheckBox* m_Plot_Text_Ref; wxCheckBox* m_Plot_Text_Value;
wxCheckBox* m_Plot_Text_Div; wxCheckBox* m_Plot_Text_Ref;
wxCheckBox* m_Plot_Invisible_Text; wxCheckBox* m_Plot_Text_Div;
wxRadioBox* m_Drill_Shape_Opt; wxCheckBox* m_Plot_Invisible_Text;
wxRadioBox* m_Scale_Opt; wxRadioBox* m_Drill_Shape_Opt;
wxRadioBox* m_PlotModeOpt; wxRadioBox* m_Scale_Opt;
wxRadioBox* m_Choice_Plot_Offset; wxRadioBox* m_PlotModeOpt;
wxRadioBox* m_PlotFormatOpt; wxRadioBox* m_Choice_Plot_Offset;
wxStaticText* m_textPenSize; wxRadioBox* m_PlotFormatOpt;
wxTextCtrl* m_HPGLPenSizeOpt; wxStaticText* m_textPenSize;
wxStaticText* m_staticText3; wxTextCtrl* m_HPGLPenSizeOpt;
wxTextCtrl* m_HPGLPenSpeedOpt; wxStaticText* m_staticText3;
wxStaticText* m_textPenOvr; wxTextCtrl* m_HPGLPenSpeedOpt;
wxTextCtrl* m_HPGLPenOverlayOpt; wxStaticText* m_textPenOvr;
wxCheckBox* m_Plot_PS_Negative; wxTextCtrl* m_HPGLPenOverlayOpt;
wxCheckBox* m_PlotMirorOpt; wxCheckBox* m_Plot_PS_Negative;
wxCheckBox* m_PlotNoViaOnMaskOpt; wxTextCtrl* m_OutputDirectory;
wxStaticText* m_staticText6; wxButton* m_BrowseButton;
wxTextCtrl* m_LinesWidth; wxCheckBox* m_PlotMirorOpt;
wxCheckBox* m_PlotNoViaOnMaskOpt;
wxStaticText* m_staticText7; wxStaticText* m_staticText6;
wxTextCtrl* m_FineAdjustXscaleOpt; wxTextCtrl* m_LinesWidth;
wxStaticText* m_staticText8;
wxTextCtrl* m_FineAdjustYscaleOpt; wxStaticText* m_staticText7;
wxTextCtrl* m_FineAdjustXscaleOpt;
wxButton* m_PlotButton; wxStaticText* m_staticText8;
wxButton* m_buttonSaveOpt; wxTextCtrl* m_FineAdjustYscaleOpt;
wxButton* m_buttonDrill;
wxButton* m_buttonQuit; wxButton* m_PlotButton;
wxStaticText* m_staticText2; wxButton* m_buttonSaveOpt;
wxTextCtrl* m_MessagesBox; wxButton* m_buttonDrill;
wxButton* m_buttonQuit;
// Virtual event handlers, overide them in your derived class wxStaticText* m_staticText2;
virtual void OnCloseWindow( wxCloseEvent& event ){ event.Skip(); } wxTextCtrl* m_MessagesBox;
virtual void OnInitDialog( wxInitDialogEvent& event ){ event.Skip(); }
virtual void SetPlotFormat( wxCommandEvent& event ){ event.Skip(); } // Virtual event handlers, overide them in your derived class
virtual void Plot( wxCommandEvent& event ){ event.Skip(); } virtual void OnCloseWindow( wxCloseEvent& event ) { event.Skip(); }
virtual void SaveOptPlot( wxCommandEvent& event ){ event.Skip(); } virtual void OnInitDialog( wxInitDialogEvent& event ) { event.Skip(); }
virtual void CreateDrillFile( wxCommandEvent& event ){ event.Skip(); } virtual void SetPlotFormat( wxCommandEvent& event ) { event.Skip(); }
virtual void OnQuit( 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(); }
public: virtual void CreateDrillFile( wxCommandEvent& event ) { event.Skip(); }
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 ); virtual void OnQuit( wxCommandEvent& event ) { event.Skip(); }
~DIALOG_PLOT_BASE();
}; public:
#endif //__dialog_plot_base__ 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() ...@@ -44,6 +44,7 @@ PCB_Plot_Options::PCB_Plot_Options()
ScaleAdjX = 1.0; ScaleAdjX = 1.0;
ScaleAdjY = 1.0; ScaleAdjY = 1.0;
PlotScaleOpt = 1; PlotScaleOpt = 1;
outputDirectory = wxT( "" );
} }
...@@ -111,6 +112,7 @@ private: ...@@ -111,6 +112,7 @@ private:
void Plot( wxCommandEvent& event ); void Plot( wxCommandEvent& event );
void OnQuit( wxCommandEvent& event ); void OnQuit( wxCommandEvent& event );
void OnClose( wxCloseEvent& event ); void OnClose( wxCloseEvent& event );
void OnOutputDirectoryBrowseClicked( wxCommandEvent& event );
void SetPlotFormat( wxCommandEvent& event ); void SetPlotFormat( wxCommandEvent& event );
void OnSetScaleOpt( wxCommandEvent& event ); void OnSetScaleOpt( wxCommandEvent& event );
void SaveOptPlot( wxCommandEvent& event ); void SaveOptPlot( wxCommandEvent& event );
...@@ -138,6 +140,7 @@ DIALOG_PLOT::DIALOG_PLOT( WinEDA_PcbFrame* parent ) : ...@@ -138,6 +140,7 @@ DIALOG_PLOT::DIALOG_PLOT( WinEDA_PcbFrame* parent ) :
void DIALOG_PLOT::Init_Dialog() void DIALOG_PLOT::Init_Dialog()
{ {
wxString msg; wxString msg;
wxFileName fileName;
BOARD* board = m_Parent->GetBoard(); BOARD* board = m_Parent->GetBoard();
...@@ -283,6 +286,17 @@ void DIALOG_PLOT::Init_Dialog() ...@@ -283,6 +286,17 @@ void DIALOG_PLOT::Init_Dialog()
// Put vias on mask layer // Put vias on mask layer
m_PlotNoViaOnMaskOpt->SetValue( g_pcb_plot_options.DrawViaOnMaskLayer ); 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: // Update options values:
wxCommandEvent cmd_event; wxCommandEvent cmd_event;
SetPlotFormat( cmd_event ); SetPlotFormat( cmd_event );
...@@ -322,6 +336,15 @@ void DIALOG_PLOT::OnSetScaleOpt( wxCommandEvent& event ) ...@@ -322,6 +336,15 @@ void DIALOG_PLOT::OnSetScaleOpt( wxCommandEvent& event )
m_Plot_Sheet_Ref->SetValue( false ); 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 ) void DIALOG_PLOT::SetPlotFormat( wxCommandEvent& event )
{ {
...@@ -487,6 +510,8 @@ void DIALOG_PLOT::SaveOptPlot( 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.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 ) ...@@ -500,6 +525,22 @@ void DIALOG_PLOT::Plot( wxCommandEvent& event )
SaveOptPlot( 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 ) switch( g_pcb_plot_options.PlotScaleOpt )
{ {
default: default:
...@@ -574,6 +615,7 @@ void DIALOG_PLOT::Plot( wxCommandEvent& event ) ...@@ -574,6 +615,7 @@ void DIALOG_PLOT::Plot( wxCommandEvent& event )
s_SelectedLayers |= mask; s_SelectedLayers |= mask;
fn = m_Parent->GetScreen()->m_FileName; fn = m_Parent->GetScreen()->m_FileName;
fn.SetPath( m_OutputDirectory->GetValue() );
// Create file name. // Create file name.
wxString layername = board->GetLayerName( layer ); wxString layername = board->GetLayerName( layer );
......
...@@ -64,8 +64,12 @@ public: ...@@ -64,8 +64,12 @@ public:
double ScaleAdjX; double ScaleAdjX;
double ScaleAdjY; double ScaleAdjY;
wxString outputDirectory;
public: public:
PCB_Plot_Options(); PCB_Plot_Options();
void SetOutputDirectory( wxString aDir ) { outputDirectory = aDir; };
wxString GetOutputDirectory() { return outputDirectory; };
}; };
extern PCB_Plot_Options g_pcb_plot_options; 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