Commit b080f860 authored by jean-pierre charras's avatar jean-pierre charras

Pcbnew: enhanced dialog for SVG export

parent e435a104
This diff is collapsed.
...@@ -14,11 +14,14 @@ class wxConfig; ...@@ -14,11 +14,14 @@ class wxConfig;
class DIALOG_SVG_PRINT : public DIALOG_SVG_PRINT_base class DIALOG_SVG_PRINT : public DIALOG_SVG_PRINT_base
{ {
private: private:
PCB_BASE_FRAME* m_Parent; PCB_BASE_FRAME* m_parent;
wxConfig* m_Config; BOARD* m_board;
long m_PrintMaskLayer; wxConfig* m_config;
wxCheckBox* m_BoxSelectLayer[32]; long m_printMaskLayer;
bool m_printBW; wxCheckBox* m_boxSelectLayer[32];
bool m_printBW;
wxString m_outputDirectory;
// Static member to store options // Static member to store options
static bool m_printMirror; static bool m_printMirror;
static bool m_oneFileOnly; static bool m_oneFileOnly;
...@@ -32,6 +35,7 @@ private: ...@@ -32,6 +35,7 @@ private:
void initDialog( ); void initDialog( );
void OnButtonPlot( wxCommandEvent& event ); void OnButtonPlot( wxCommandEvent& event );
void OnButtonCancelClick( wxCommandEvent& event ); void OnButtonCancelClick( wxCommandEvent& event );
void OnOutputDirectoryBrowseClicked( wxCommandEvent& event );
void SetPenWidth(); void SetPenWidth();
void ExportSVGFile( bool aOnlyOneFile ); void ExportSVGFile( bool aOnlyOneFile );
bool PageIsBoardBoundarySize() bool PageIsBoardBoundarySize()
......
...@@ -16,6 +16,25 @@ DIALOG_SVG_PRINT_base::DIALOG_SVG_PRINT_base( wxWindow* parent, wxWindowID id, c ...@@ -16,6 +16,25 @@ DIALOG_SVG_PRINT_base::DIALOG_SVG_PRINT_base( wxWindow* parent, wxWindowID id, c
wxBoxSizer* bMainSizer; wxBoxSizer* bMainSizer;
bMainSizer = new wxBoxSizer( wxVERTICAL ); bMainSizer = new wxBoxSizer( wxVERTICAL );
m_staticTextDir = new wxStaticText( this, wxID_ANY, _("Output directory:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextDir->Wrap( -1 );
bMainSizer->Add( m_staticTextDir, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
wxBoxSizer* bSizer4;
bSizer4 = new wxBoxSizer( wxHORIZONTAL );
m_outputDirectoryName = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
m_outputDirectoryName->SetToolTip( _("Enter a filename if you do not want to use default file names\nCan be used only when printing the current sheet") );
m_outputDirectoryName->SetMinSize( wxSize( 450,-1 ) );
bSizer4->Add( m_outputDirectoryName, 1, wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 5 );
m_browseButton = new wxButton( this, wxID_ANY, _("Browse..."), wxDefaultPosition, wxDefaultSize, 0 );
bSizer4->Add( m_browseButton, 0, wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 5 );
bMainSizer->Add( bSizer4, 0, wxEXPAND|wxBOTTOM, 5 );
wxBoxSizer* bUpperSizer; wxBoxSizer* bUpperSizer;
bUpperSizer = new wxBoxSizer( wxHORIZONTAL ); bUpperSizer = new wxBoxSizer( wxHORIZONTAL );
...@@ -94,24 +113,14 @@ DIALOG_SVG_PRINT_base::DIALOG_SVG_PRINT_base( wxWindow* parent, wxWindowID id, c ...@@ -94,24 +113,14 @@ DIALOG_SVG_PRINT_base::DIALOG_SVG_PRINT_base( wxWindow* parent, wxWindowID id, c
bMainSizer->Add( bUpperSizer, 0, wxEXPAND, 5 ); bMainSizer->Add( bUpperSizer, 0, wxEXPAND, 5 );
m_staticText1 = new wxStaticText( this, wxID_ANY, _("Filename:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText1->Wrap( -1 );
bMainSizer->Add( m_staticText1, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
m_FileNameCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
m_FileNameCtrl->SetToolTip( _("Enter a filename if you do not want to use default file names\nCan be used only when printing the current sheet") );
m_FileNameCtrl->SetMinSize( wxSize( 450,-1 ) );
bMainSizer->Add( m_FileNameCtrl, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
m_staticText2 = new wxStaticText( this, wxID_ANY, _("Messages:"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticText2 = new wxStaticText( this, wxID_ANY, _("Messages:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText2->Wrap( -1 ); m_staticText2->Wrap( -1 );
bMainSizer->Add( m_staticText2, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); bMainSizer->Add( m_staticText2, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
m_MessagesBox = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE ); m_messagesBox = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE );
m_MessagesBox->SetMinSize( wxSize( -1,100 ) ); m_messagesBox->SetMinSize( wxSize( -1,100 ) );
bMainSizer->Add( m_MessagesBox, 1, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 ); bMainSizer->Add( m_messagesBox, 1, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 );
this->SetSizer( bMainSizer ); this->SetSizer( bMainSizer );
...@@ -119,6 +128,7 @@ DIALOG_SVG_PRINT_base::DIALOG_SVG_PRINT_base( wxWindow* parent, wxWindowID id, c ...@@ -119,6 +128,7 @@ DIALOG_SVG_PRINT_base::DIALOG_SVG_PRINT_base( wxWindow* parent, wxWindowID id, c
// Connect Events // Connect Events
this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_SVG_PRINT_base::OnCloseWindow ) ); this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_SVG_PRINT_base::OnCloseWindow ) );
m_browseButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SVG_PRINT_base::OnOutputDirectoryBrowseClicked ), NULL, this );
m_buttonCreateFile->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SVG_PRINT_base::OnButtonPlot ), NULL, this ); m_buttonCreateFile->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SVG_PRINT_base::OnButtonPlot ), NULL, this );
m_buttonQuit->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SVG_PRINT_base::OnButtonCancelClick ), NULL, this ); m_buttonQuit->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SVG_PRINT_base::OnButtonCancelClick ), NULL, this );
} }
...@@ -127,6 +137,7 @@ DIALOG_SVG_PRINT_base::~DIALOG_SVG_PRINT_base() ...@@ -127,6 +137,7 @@ DIALOG_SVG_PRINT_base::~DIALOG_SVG_PRINT_base()
{ {
// Disconnect Events // Disconnect Events
this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_SVG_PRINT_base::OnCloseWindow ) ); this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_SVG_PRINT_base::OnCloseWindow ) );
m_browseButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SVG_PRINT_base::OnOutputDirectoryBrowseClicked ), NULL, this );
m_buttonCreateFile->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SVG_PRINT_base::OnButtonPlot ), NULL, this ); m_buttonCreateFile->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SVG_PRINT_base::OnButtonPlot ), NULL, this );
m_buttonQuit->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SVG_PRINT_base::OnButtonCancelClick ), NULL, this ); m_buttonQuit->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SVG_PRINT_base::OnButtonCancelClick ), NULL, this );
......
This diff is collapsed.
...@@ -13,17 +13,17 @@ ...@@ -13,17 +13,17 @@
#include <wx/intl.h> #include <wx/intl.h>
#include "dialog_shim.h" #include "dialog_shim.h"
#include <wx/string.h> #include <wx/string.h>
#include <wx/sizer.h>
#include <wx/statbox.h>
#include <wx/gdicmn.h>
#include <wx/stattext.h> #include <wx/stattext.h>
#include <wx/gdicmn.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/textctrl.h> #include <wx/textctrl.h>
#include <wx/button.h>
#include <wx/sizer.h>
#include <wx/statbox.h>
#include <wx/radiobox.h> #include <wx/radiobox.h>
#include <wx/checkbox.h> #include <wx/checkbox.h>
#include <wx/button.h>
#include <wx/dialog.h> #include <wx/dialog.h>
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
...@@ -41,6 +41,9 @@ class DIALOG_SVG_PRINT_base : public DIALOG_SHIM ...@@ -41,6 +41,9 @@ class DIALOG_SVG_PRINT_base : public DIALOG_SHIM
wxID_PRINT_BOARD = 1000 wxID_PRINT_BOARD = 1000
}; };
wxStaticText* m_staticTextDir;
wxTextCtrl* m_outputDirectoryName;
wxButton* m_browseButton;
wxStaticBoxSizer* m_CopperLayersBoxSizer; wxStaticBoxSizer* m_CopperLayersBoxSizer;
wxStaticBoxSizer* m_TechnicalBoxSizer; wxStaticBoxSizer* m_TechnicalBoxSizer;
wxStaticText* m_TextPenWidth; wxStaticText* m_TextPenWidth;
...@@ -52,13 +55,12 @@ class DIALOG_SVG_PRINT_base : public DIALOG_SHIM ...@@ -52,13 +55,12 @@ class DIALOG_SVG_PRINT_base : public DIALOG_SHIM
wxRadioBox* m_rbFileOpt; wxRadioBox* m_rbFileOpt;
wxButton* m_buttonCreateFile; wxButton* m_buttonCreateFile;
wxButton* m_buttonQuit; wxButton* m_buttonQuit;
wxStaticText* m_staticText1;
wxTextCtrl* m_FileNameCtrl;
wxStaticText* m_staticText2; wxStaticText* m_staticText2;
wxTextCtrl* m_MessagesBox; wxTextCtrl* m_messagesBox;
// Virtual event handlers, overide them in your derived class // Virtual event handlers, overide them in your derived class
virtual void OnCloseWindow( wxCloseEvent& event ) { event.Skip(); } virtual void OnCloseWindow( wxCloseEvent& event ) { event.Skip(); }
virtual void OnOutputDirectoryBrowseClicked( wxCommandEvent& event ) { event.Skip(); }
virtual void OnButtonPlot( wxCommandEvent& event ) { event.Skip(); } virtual void OnButtonPlot( wxCommandEvent& event ) { event.Skip(); }
virtual void OnButtonCancelClick( wxCommandEvent& event ) { event.Skip(); } virtual void OnButtonCancelClick( wxCommandEvent& event ) { event.Skip(); }
......
...@@ -271,7 +271,7 @@ void DIALOG_PLOT::OnOutputDirectoryBrowseClicked( wxCommandEvent& event ) ...@@ -271,7 +271,7 @@ void DIALOG_PLOT::OnOutputDirectoryBrowseClicked( wxCommandEvent& event )
if( !dirName.MakeRelativeTo( boardFilePath ) ) if( !dirName.MakeRelativeTo( boardFilePath ) )
wxMessageBox( _( wxMessageBox( _(
"Cannot make path relative (target volume different from board file volume)!" ), "Cannot make path relative (target volume different from board file volume)!" ),
_( "Plot Output Directory" ), wxOK | wxICON_ERROR ); _( "Plot Output Directory" ), wxOK | wxICON_ERROR );
} }
......
...@@ -111,8 +111,9 @@ static wxString GetGerberExtension( int layer )/*{{{*/ ...@@ -111,8 +111,9 @@ static wxString GetGerberExtension( int layer )/*{{{*/
/* Complete a plot filename: forces the output directory, /* Complete a plot filename: forces the output directory,
* add a suffix to the name and sets the specified extension * add a suffix to the name and sets the specified extension
* the suffix is usually the layer name * the suffix is usually the layer name
* replaces not allowed chars in suffix by '_'
*/ */
static void BuildPlotFileName( wxFileName *aFilename, void BuildPlotFileName( wxFileName *aFilename,
const wxString& aOutputDir, const wxString& aOutputDir,
const wxString& aSuffix, const wxString& aSuffix,
const wxString& aExtension ) const wxString& aExtension )
...@@ -139,10 +140,13 @@ static void BuildPlotFileName( wxFileName *aFilename, ...@@ -139,10 +140,13 @@ static void BuildPlotFileName( wxFileName *aFilename,
aFilename->SetName( aFilename->GetName() + wxT( "-" ) + suffix ); aFilename->SetName( aFilename->GetName() + wxT( "-" ) + suffix );
} }
/** Fix the output directory pathname to absolute and ensure it exists */ /*
static bool EnsureOutputDirectory( wxFileName *aOutputDir, /*{{{*/ * Fix the output directory pathname to absolute and ensure it exists
const wxString& aBoardFilename, * (Creates it if not exists)
wxTextCtrl* aMessageBox ) */
bool EnsureOutputDirectory( wxFileName *aOutputDir,
const wxString& aBoardFilename,
wxTextCtrl* aMessageBox )
{ {
wxString boardFilePath = wxFileName( aBoardFilename ).GetPath(); wxString boardFilePath = wxFileName( aBoardFilename ).GetPath();
...@@ -171,13 +175,14 @@ static bool EnsureOutputDirectory( wxFileName *aOutputDir, /*{{{*/ ...@@ -171,13 +175,14 @@ static bool EnsureOutputDirectory( wxFileName *aOutputDir, /*{{{*/
} }
else else
{ {
wxMessageBox( _( "Cannot create output directory!" ), if( aMessageBox )
_( "Plot" ), wxOK | wxICON_ERROR ); wxMessageBox( _( "Cannot create output directory!" ),
_( "Plot" ), wxOK | wxICON_ERROR );
return false; return false;
} }
} }
return true; return true;
}/*}}}*/ }
/* /*
* DIALOG_PLOT:Plot * DIALOG_PLOT:Plot
......
...@@ -187,6 +187,36 @@ void PlotSilkScreen( BOARD *aBoard, PLOTTER* aPlotter, long aLayerMask, ...@@ -187,6 +187,36 @@ void PlotSilkScreen( BOARD *aBoard, PLOTTER* aPlotter, long aLayerMask,
const PCB_PLOT_PARAMS& aPlotOpt ); const PCB_PLOT_PARAMS& aPlotOpt );
/**
* Function EnsureOutputDirectory (helper function)
* Fix the output directory pathname to absolute and ensure it exists
* (Creates it if not exists)
* @param aOutputDir = the wxFileName to modify
* (contains the absolute or relative to the board path
* @param aBoardFilename = the board full filename
* @param aMessageBox = a wxMessageBox to show meesage (can be NULL)
*/
bool EnsureOutputDirectory( wxFileName *aOutputDir,
const wxString& aBoardFilename,
wxTextCtrl* aMessageBox );
/**
* Function BuildPlotFileName (helper function)
* Complete a plot filename: forces the output directory,
* add a suffix to the name and sets the specified extension
* the suffix is usually the layer name
* replaces not allowed chars in suffix by '_'
* @param aFilename = the wxFileName to initialize
* Contians the base filename
* @param aOutputDir = the path
* @param aSuffix = the suffix to add to the base filename
* @param aExtension = the file extension
*/
void BuildPlotFileName( wxFileName *aFilename,
const wxString& aOutputDir,
const wxString& aSuffix,
const wxString& aExtension );
// PLOTGERB.CPP // PLOTGERB.CPP
void SelectD_CODE_For_LineDraw( PLOTTER* plotter, int aSize ); void SelectD_CODE_For_LineDraw( PLOTTER* plotter, int aSize );
......
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