From 9c66afb6fe9fec02e18e94f10e677e3345e2dcae Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Fri, 16 Nov 2012 15:13:31 +0100 Subject: [PATCH] Pcbnew: enhanced dialog for SVG export --- pcbnew/dialogs/dialog_SVG_print.cpp | 174 ++++++--- pcbnew/dialogs/dialog_SVG_print.h | 14 +- pcbnew/dialogs/dialog_SVG_print_base.cpp | 37 +- pcbnew/dialogs/dialog_SVG_print_base.fbp | 449 ++++++++++++++--------- pcbnew/dialogs/dialog_SVG_print_base.h | 16 +- pcbnew/dialogs/dialog_plot.cpp | 2 +- pcbnew/pcbplot.cpp | 21 +- pcbnew/pcbplot.h | 30 ++ 8 files changed, 474 insertions(+), 269 deletions(-) diff --git a/pcbnew/dialogs/dialog_SVG_print.cpp b/pcbnew/dialogs/dialog_SVG_print.cpp index 55e2101525..ae77c86018 100644 --- a/pcbnew/dialogs/dialog_SVG_print.cpp +++ b/pcbnew/dialogs/dialog_SVG_print.cpp @@ -36,6 +36,7 @@ #include #include #include +#include #include #include @@ -56,15 +57,14 @@ static long s_SelectedLayers = LAYER_BACK | LAYER_FRONT | SILKSCREEN_LAYER_FRONT | SILKSCREEN_LAYER_BACK; - -/*! +/* * DIALOG_SVG_PRINT functions */ DIALOG_SVG_PRINT::DIALOG_SVG_PRINT( EDA_DRAW_FRAME* parent ) : DIALOG_SVG_PRINT_base( parent ) { - m_Parent = (PCB_BASE_FRAME*) parent; - m_Config = wxGetApp().GetSettings(); + m_parent = (PCB_BASE_FRAME*) parent; + m_config = wxGetApp().GetSettings(); initDialog(); GetSizer()->SetSizeHints( this ); Centre(); @@ -75,16 +75,21 @@ bool DIALOG_SVG_PRINT::m_oneFileOnly = false; void DIALOG_SVG_PRINT::initDialog() { - if( m_Config ) + m_board = m_parent->GetBoard(); + + if( m_config ) { - m_Config->Read( PLOTSVGMODECOLOR_KEY, &m_printBW, false ); + m_config->Read( PLOTSVGMODECOLOR_KEY, &m_printBW, false ); long ltmp; - m_Config->Read( PLOTSVGPAGESIZEOPT_KEY, <mp, 0 ); + m_config->Read( PLOTSVGPAGESIZEOPT_KEY, <mp, 0 ); m_rbSvgPageSizeOpt->SetSelection( ltmp ); - m_Config->Read( PLOTSVGPLOT_BRD_EDGE_KEY, <mp, 1 ); + m_config->Read( PLOTSVGPLOT_BRD_EDGE_KEY, <mp, 1 ); m_PrintBoardEdgesCtrl->SetValue( ltmp ); } + m_outputDirectory = m_parent->GetPlotSettings().GetOutputDirectory(); + m_outputDirectoryName->SetValue( m_outputDirectory ); + if( m_printBW ) m_ModeColorOption->SetSelection( 1 ); else @@ -99,16 +104,14 @@ void DIALOG_SVG_PRINT::initDialog() ReturnStringFromValue( g_UserUnit, g_DrawDefaultLineThickness ) ); // Create layers list - BOARD* board = m_Parent->GetBoard(); int layer; - for( layer = 0; layer < NB_LAYERS; ++layer ) { - if( !board->IsLayerEnabled( layer ) ) - m_BoxSelectLayer[layer] = NULL; + if( !m_board->IsLayerEnabled( layer ) ) + m_boxSelectLayer[layer] = NULL; else - m_BoxSelectLayer[layer] = - new wxCheckBox( this, -1, board->GetLayerName( layer ) ); + m_boxSelectLayer[layer] = + new wxCheckBox( this, -1, m_board->GetLayerName( layer ) ); } // Add wxCheckBoxes in layers lists dialog @@ -122,27 +125,27 @@ void DIALOG_SVG_PRINT::initDialog() wxASSERT( layer < NB_LAYERS ); - if( m_BoxSelectLayer[layer] == NULL ) + if( m_boxSelectLayer[layer] == NULL ) continue; long mask = 1 << layer; if( mask & s_SelectedLayers ) - m_BoxSelectLayer[layer]->SetValue( true ); + m_boxSelectLayer[layer]->SetValue( true ); if( layer < 16 ) - m_CopperLayersBoxSizer->Add( m_BoxSelectLayer[layer], + m_CopperLayersBoxSizer->Add( m_boxSelectLayer[layer], 0, wxGROW | wxALL, 1 ); else - m_TechnicalBoxSizer->Add( m_BoxSelectLayer[layer], + m_TechnicalBoxSizer->Add( m_boxSelectLayer[layer], 0, wxGROW | wxALL, 1 ); } - if( m_Config ) + if( m_config ) { wxString layerKey; @@ -150,17 +153,53 @@ void DIALOG_SVG_PRINT::initDialog() { bool option; - if( m_BoxSelectLayer[layer] == NULL ) + if( m_boxSelectLayer[layer] == NULL ) continue; layerKey.Printf( OPTKEY_LAYERBASE, layer ); - if( m_Config->Read( layerKey, &option ) ) - m_BoxSelectLayer[layer]->SetValue( option ); + if( m_config->Read( layerKey, &option ) ) + m_boxSelectLayer[layer]->SetValue( option ); } } } +void DIALOG_SVG_PRINT::OnOutputDirectoryBrowseClicked( wxCommandEvent& event ) +{ + // Build the absolute path of current output plot directory + // to preselect it when opening the dialog. + wxFileName fn( m_outputDirectoryName->GetValue() ); + wxString path; + + if( fn.IsRelative() ) + path = wxGetCwd() + fn.GetPathSeparator() + m_outputDirectoryName->GetValue(); + else + path = m_outputDirectoryName->GetValue(); + + wxDirDialog dirDialog( this, _( "Select Output Directory" ), path ); + + if( dirDialog.ShowModal() == wxID_CANCEL ) + return; + + wxFileName dirName = wxFileName::DirName( dirDialog.GetPath() ); + + wxMessageDialog dialog( this, _( "Use a relative path? " ), + _( "Plot Output Directory" ), + wxYES_NO | wxICON_QUESTION | wxYES_DEFAULT ); + + if( dialog.ShowModal() == wxID_YES ) + { + wxString boardFilePath = ( (wxFileName) m_board->GetFileName() ).GetPath(); + + if( !dirName.MakeRelativeTo( boardFilePath ) ) + wxMessageBox( _( + "Cannot make path relative (target volume different from board file volume)!" ), + _( "Plot Output Directory" ), wxOK | wxICON_ERROR ); + } + + m_outputDirectoryName->SetValue( dirName.GetFullPath() ); + m_outputDirectory = m_outputDirectoryName->GetValue(); +} void DIALOG_SVG_PRINT::SetPenWidth() { @@ -182,8 +221,15 @@ void DIALOG_SVG_PRINT::SetPenWidth() void DIALOG_SVG_PRINT::ExportSVGFile( bool aOnlyOneFile ) { - wxFileName fn; - wxString msg; + m_outputDirectory = m_outputDirectoryName->GetValue(); + + // Create output directory if it does not exist (also transform it in + // absolute form). Bail if it fails + wxFileName outputDir = wxFileName::DirName( m_outputDirectory ); + wxString boardFilename = m_board->GetFileName(); + + if( !EnsureOutputDirectory( &outputDir, boardFilename, m_messagesBox ) ) + return; m_printMirror = m_printMirrorOpt->GetValue(); m_printBW = m_ModeColorOption->GetSelection(); @@ -194,45 +240,41 @@ void DIALOG_SVG_PRINT::ExportSVGFile( bool aOnlyOneFile ) for( int layer = 0; layerGetValue() ) + if( m_boxSelectLayer[layer] && m_boxSelectLayer[layer]->GetValue() ) printMaskLayer |= 1 << layer; } + wxString msg; for( int layer = 0; layerGetValue(); - - if( !fn.IsOk() ) - fn = m_Parent->GetBoard()->GetFileName(); + wxString suffix = m_board->GetLayerName( layer, false ); if( aOnlyOneFile ) { - m_PrintMaskLayer = printMaskLayer; - fn.SetName( fn.GetName() + wxT( "-brd" ) ); - } + m_printMaskLayer = printMaskLayer; + suffix = wxT( "-brd" ); + } else { - m_PrintMaskLayer = currlayer_mask; - wxString suffix = m_Parent->GetBoard()->GetLayerName( layer, false ); - suffix.Trim(); // remove leading and trailing spaces if any - suffix.Trim( false ); - fn.SetName( fn.GetName() + wxT( "-" ) + suffix ); + m_printMaskLayer = currlayer_mask; + suffix = m_board->GetLayerName( layer, false ); } - fn.SetExt( wxT( "svg" ) ); + wxFileName fn(boardFilename); + BuildPlotFileName( &fn, outputDir.GetPath(), suffix, SVGFileExtension ); if( m_PrintBoardEdgesCtrl->IsChecked() ) - m_PrintMaskLayer |= EDGE_LAYER; + m_printMaskLayer |= EDGE_LAYER; if( CreateSVGFile( fn.GetFullPath() ) ) msg.Printf( _( "Plot: %s OK\n" ), GetChars( fn.GetFullPath() ) ); else // Error msg.Printf( _( "** Unable to create %s **\n" ), GetChars( fn.GetFullPath() ) ); - m_MessagesBox->AppendText( msg ); + m_messagesBox->AppendText( msg ); if( aOnlyOneFile ) break; @@ -243,14 +285,12 @@ void DIALOG_SVG_PRINT::ExportSVGFile( bool aOnlyOneFile ) // Actual SVG file export function. bool DIALOG_SVG_PRINT::CreateSVGFile( const wxString& aFullFileName ) { - BOARD* brd = m_Parent->GetBoard(); - PCB_PLOT_PARAMS m_plotOpts; m_plotOpts.SetPlotFrameRef( PrintPageRef() ); // Adding drill marks, for copper layers - if( (m_PrintMaskLayer & ALL_CU_LAYERS) ) + if( (m_printMaskLayer & ALL_CU_LAYERS) ) m_plotOpts.SetDrillMarksType( PCB_PLOT_PARAMS::FULL_DRILL_SHAPE ); else m_plotOpts.SetDrillMarksType( PCB_PLOT_PARAMS::NO_DRILL_SHAPE ); @@ -263,36 +303,36 @@ bool DIALOG_SVG_PRINT::CreateSVGFile( const wxString& aFullFileName ) m_plotOpts.SetReferenceColor( color ); m_plotOpts.SetValueColor( color ); - PAGE_INFO pageInfo = brd->GetPageSettings(); - wxPoint axisorigin = brd->GetOriginAxisPosition(); + PAGE_INFO pageInfo = m_board->GetPageSettings(); + wxPoint axisorigin = m_board->GetOriginAxisPosition(); if( PageIsBoardBoundarySize() ) { - EDA_RECT bbox = brd->ComputeBoundingBox(); - PAGE_INFO currpageInfo = brd->GetPageSettings(); + EDA_RECT bbox = m_board->ComputeBoundingBox(); + PAGE_INFO currpageInfo = m_board->GetPageSettings(); currpageInfo.SetWidthMils( bbox.GetWidth() / IU_PER_MILS ); currpageInfo.SetHeightMils( bbox.GetHeight() / IU_PER_MILS ); - brd->SetPageSettings( currpageInfo ); + m_board->SetPageSettings( currpageInfo ); m_plotOpts.SetUseAuxOrigin( true ); wxPoint origin = bbox.GetOrigin(); - brd->SetOriginAxisPosition( origin ); + m_board->SetOriginAxisPosition( origin ); } LOCALE_IO toggle; - SVG_PLOTTER* plotter = (SVG_PLOTTER*) StartPlotBoard( brd, + SVG_PLOTTER* plotter = (SVG_PLOTTER*) StartPlotBoard( m_board, &m_plotOpts, aFullFileName, wxEmptyString ); if( plotter ) { plotter->SetColorMode( m_ModeColorOption->GetSelection() == 0 ); - PlotStandardLayer( brd, plotter, m_PrintMaskLayer, m_plotOpts ); + PlotStandardLayer( m_board, plotter, m_printMaskLayer, m_plotOpts ); + plotter->EndPlot(); } - plotter->EndPlot(); delete plotter; - brd->SetOriginAxisPosition( axisorigin ); - brd->SetPageSettings( pageInfo ); + m_board->SetOriginAxisPosition( axisorigin ); + m_board->SetPageSettings( pageInfo ); return true; } @@ -316,23 +356,37 @@ void DIALOG_SVG_PRINT::OnCloseWindow( wxCloseEvent& event ) m_printBW = m_ModeColorOption->GetSelection(); m_oneFileOnly = m_rbFileOpt->GetSelection() == 1; - if( m_Config ) + if( m_config ) { - m_Config->Write( PLOTSVGMODECOLOR_KEY, m_printBW ); - m_Config->Write( PLOTSVGPAGESIZEOPT_KEY, m_rbSvgPageSizeOpt->GetSelection() ); - m_Config->Write( PLOTSVGPLOT_BRD_EDGE_KEY, m_PrintBoardEdgesCtrl->GetValue() ); + m_config->Write( PLOTSVGMODECOLOR_KEY, m_printBW ); + m_config->Write( PLOTSVGPAGESIZEOPT_KEY, m_rbSvgPageSizeOpt->GetSelection() ); + m_config->Write( PLOTSVGPLOT_BRD_EDGE_KEY, m_PrintBoardEdgesCtrl->GetValue() ); wxString layerKey; for( int layer = 0; layerWrite( layerKey, m_BoxSelectLayer[layer]->IsChecked() ); + m_config->Write( layerKey, m_boxSelectLayer[layer]->IsChecked() ); } } + // Set output directory and replace backslashes with forward ones + wxString dirStr; + dirStr = m_outputDirectoryName->GetValue(); + dirStr.Replace( wxT( "\\" ), wxT( "/" ) ); + + if( dirStr != m_parent->GetPlotSettings().GetOutputDirectory() ) + { + PCB_PLOT_PARAMS tempOptions( m_parent->GetPlotSettings() ); + tempOptions.SetOutputDirectory( dirStr ); + m_parent->SetPlotSettings( tempOptions ); + m_parent->OnModify(); + } + + EndModal( 0 ); } diff --git a/pcbnew/dialogs/dialog_SVG_print.h b/pcbnew/dialogs/dialog_SVG_print.h index ac0b20d4a5..e919d0e178 100644 --- a/pcbnew/dialogs/dialog_SVG_print.h +++ b/pcbnew/dialogs/dialog_SVG_print.h @@ -14,11 +14,14 @@ class wxConfig; class DIALOG_SVG_PRINT : public DIALOG_SVG_PRINT_base { private: - PCB_BASE_FRAME* m_Parent; - wxConfig* m_Config; - long m_PrintMaskLayer; - wxCheckBox* m_BoxSelectLayer[32]; - bool m_printBW; + PCB_BASE_FRAME* m_parent; + BOARD* m_board; + wxConfig* m_config; + long m_printMaskLayer; + wxCheckBox* m_boxSelectLayer[32]; + bool m_printBW; + wxString m_outputDirectory; + // Static member to store options static bool m_printMirror; static bool m_oneFileOnly; @@ -32,6 +35,7 @@ private: void initDialog( ); void OnButtonPlot( wxCommandEvent& event ); void OnButtonCancelClick( wxCommandEvent& event ); + void OnOutputDirectoryBrowseClicked( wxCommandEvent& event ); void SetPenWidth(); void ExportSVGFile( bool aOnlyOneFile ); bool PageIsBoardBoundarySize() diff --git a/pcbnew/dialogs/dialog_SVG_print_base.cpp b/pcbnew/dialogs/dialog_SVG_print_base.cpp index ea8185194d..e32f2f96e2 100644 --- a/pcbnew/dialogs/dialog_SVG_print_base.cpp +++ b/pcbnew/dialogs/dialog_SVG_print_base.cpp @@ -16,6 +16,25 @@ DIALOG_SVG_PRINT_base::DIALOG_SVG_PRINT_base( wxWindow* parent, wxWindowID id, c wxBoxSizer* bMainSizer; 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; bUpperSizer = new wxBoxSizer( wxHORIZONTAL ); @@ -94,24 +113,14 @@ DIALOG_SVG_PRINT_base::DIALOG_SVG_PRINT_base( wxWindow* parent, wxWindowID id, c 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->Wrap( -1 ); bMainSizer->Add( m_staticText2, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); - m_MessagesBox = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE ); - m_MessagesBox->SetMinSize( wxSize( -1,100 ) ); + m_messagesBox = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE ); + 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 ); @@ -119,6 +128,7 @@ DIALOG_SVG_PRINT_base::DIALOG_SVG_PRINT_base( wxWindow* parent, wxWindowID id, c // Connect Events 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_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() { // Disconnect Events 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_buttonQuit->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SVG_PRINT_base::OnButtonCancelClick ), NULL, this ); diff --git a/pcbnew/dialogs/dialog_SVG_print_base.fbp b/pcbnew/dialogs/dialog_SVG_print_base.fbp index adf328e778..4d89e9dee5 100644 --- a/pcbnew/dialogs/dialog_SVG_print_base.fbp +++ b/pcbnew/dialogs/dialog_SVG_print_base.fbp @@ -91,6 +91,279 @@ bMainSizer wxVERTICAL none + + 5 + wxTOP|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Output directory: + + 0 + + + 0 + + 1 + m_staticTextDir + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND|wxBOTTOM + 0 + + + bSizer4 + wxHORIZONTAL + none + + 5 + wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + 0 + + 0 + 450,-1 + 1 + m_outputDirectoryName + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + Enter a filename if you do not want to use default file names Can be used only when printing the current sheet + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Browse... + + 0 + + + 0 + + 1 + m_browseButton + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + OnOutputDirectoryBrowseClicked + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 wxEXPAND @@ -965,180 +1238,6 @@ - - 5 - wxTOP|wxRIGHT|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Filename: - - 0 - - - 0 - - 1 - m_staticText1 - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - 0 - - 0 - 450,-1 - 1 - m_FileNameCtrl - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - Enter a filename if you do not want to use default file names Can be used only when printing the current sheet - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 wxTOP|wxRIGHT|wxLEFT @@ -1262,7 +1361,7 @@ 0 -1,100 1 - m_MessagesBox + m_messagesBox 1 diff --git a/pcbnew/dialogs/dialog_SVG_print_base.h b/pcbnew/dialogs/dialog_SVG_print_base.h index 4fc5db85fe..bc56d76fb2 100644 --- a/pcbnew/dialogs/dialog_SVG_print_base.h +++ b/pcbnew/dialogs/dialog_SVG_print_base.h @@ -13,17 +13,17 @@ #include #include "dialog_shim.h" #include -#include -#include -#include #include +#include #include #include #include #include +#include +#include +#include #include #include -#include #include /////////////////////////////////////////////////////////////////////////// @@ -41,6 +41,9 @@ class DIALOG_SVG_PRINT_base : public DIALOG_SHIM wxID_PRINT_BOARD = 1000 }; + wxStaticText* m_staticTextDir; + wxTextCtrl* m_outputDirectoryName; + wxButton* m_browseButton; wxStaticBoxSizer* m_CopperLayersBoxSizer; wxStaticBoxSizer* m_TechnicalBoxSizer; wxStaticText* m_TextPenWidth; @@ -52,13 +55,12 @@ class DIALOG_SVG_PRINT_base : public DIALOG_SHIM wxRadioBox* m_rbFileOpt; wxButton* m_buttonCreateFile; wxButton* m_buttonQuit; - wxStaticText* m_staticText1; - wxTextCtrl* m_FileNameCtrl; wxStaticText* m_staticText2; - wxTextCtrl* m_MessagesBox; + wxTextCtrl* m_messagesBox; // Virtual event handlers, overide them in your derived class virtual void OnCloseWindow( wxCloseEvent& event ) { event.Skip(); } + virtual void OnOutputDirectoryBrowseClicked( wxCommandEvent& event ) { event.Skip(); } virtual void OnButtonPlot( wxCommandEvent& event ) { event.Skip(); } virtual void OnButtonCancelClick( wxCommandEvent& event ) { event.Skip(); } diff --git a/pcbnew/dialogs/dialog_plot.cpp b/pcbnew/dialogs/dialog_plot.cpp index 44fa211144..2d7988500c 100644 --- a/pcbnew/dialogs/dialog_plot.cpp +++ b/pcbnew/dialogs/dialog_plot.cpp @@ -271,7 +271,7 @@ void DIALOG_PLOT::OnOutputDirectoryBrowseClicked( wxCommandEvent& event ) if( !dirName.MakeRelativeTo( boardFilePath ) ) 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 ); } diff --git a/pcbnew/pcbplot.cpp b/pcbnew/pcbplot.cpp index a45fa8f0df..12ff548cf2 100644 --- a/pcbnew/pcbplot.cpp +++ b/pcbnew/pcbplot.cpp @@ -111,8 +111,9 @@ static wxString GetGerberExtension( int layer )/*{{{*/ /* 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 '_' */ -static void BuildPlotFileName( wxFileName *aFilename, +void BuildPlotFileName( wxFileName *aFilename, const wxString& aOutputDir, const wxString& aSuffix, const wxString& aExtension ) @@ -139,10 +140,13 @@ static void BuildPlotFileName( wxFileName *aFilename, aFilename->SetName( aFilename->GetName() + wxT( "-" ) + suffix ); } -/** Fix the output directory pathname to absolute and ensure it exists */ -static bool EnsureOutputDirectory( wxFileName *aOutputDir, /*{{{*/ - const wxString& aBoardFilename, - wxTextCtrl* aMessageBox ) +/* + * Fix the output directory pathname to absolute and ensure it exists + * (Creates it if not exists) + */ +bool EnsureOutputDirectory( wxFileName *aOutputDir, + const wxString& aBoardFilename, + wxTextCtrl* aMessageBox ) { wxString boardFilePath = wxFileName( aBoardFilename ).GetPath(); @@ -171,13 +175,14 @@ static bool EnsureOutputDirectory( wxFileName *aOutputDir, /*{{{*/ } else { - wxMessageBox( _( "Cannot create output directory!" ), - _( "Plot" ), wxOK | wxICON_ERROR ); + if( aMessageBox ) + wxMessageBox( _( "Cannot create output directory!" ), + _( "Plot" ), wxOK | wxICON_ERROR ); return false; } } return true; -}/*}}}*/ +} /* * DIALOG_PLOT:Plot diff --git a/pcbnew/pcbplot.h b/pcbnew/pcbplot.h index 7de7fe5850..bcc0f0ff56 100644 --- a/pcbnew/pcbplot.h +++ b/pcbnew/pcbplot.h @@ -187,6 +187,36 @@ void PlotSilkScreen( BOARD *aBoard, PLOTTER* aPlotter, long aLayerMask, 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 void SelectD_CODE_For_LineDraw( PLOTTER* plotter, int aSize );