2012-08-31 07:43:37 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2012 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
2023-01-17 16:54:08 +00:00
|
|
|
* Copyright (C) 2022-2023 KiCad Developers, see AUTHORS.txt for contributors.
|
2012-08-31 07:43:37 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
2009-01-11 19:12:18 +00:00
|
|
|
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <pcb_edit_frame.h>
|
|
|
|
#include <pcbnew_settings.h>
|
2012-11-16 14:13:31 +00:00
|
|
|
#include <wildcards_and_files_ext.h>
|
2013-05-10 19:22:29 +00:00
|
|
|
#include <reporter.h>
|
|
|
|
#include <confirm.h>
|
2020-11-18 01:21:04 +00:00
|
|
|
#include <core/arraydim.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <pcbplot.h>
|
2020-10-24 01:38:50 +00:00
|
|
|
#include <locale_io.h>
|
2018-06-13 12:20:29 +00:00
|
|
|
#include <dialog_export_svg_base.h>
|
|
|
|
#include <bitmaps.h>
|
2022-12-13 20:47:28 +00:00
|
|
|
#include <widgets/std_bitmap_button.h>
|
2022-09-03 18:29:02 +00:00
|
|
|
#include <widgets/wx_html_report_panel.h>
|
2020-12-14 02:00:53 +00:00
|
|
|
#include <plotters/plotters_pslike.h>
|
2021-06-07 07:26:13 +00:00
|
|
|
#include <wx/dirdlg.h>
|
2021-06-09 01:56:00 +00:00
|
|
|
#include <pgm_base.h>
|
2023-07-12 13:26:52 +00:00
|
|
|
#include <project/project_file.h>
|
2023-08-18 17:44:54 +00:00
|
|
|
#include <exporters/export_svg.h>
|
2014-06-24 16:17:18 +00:00
|
|
|
|
2018-06-13 12:20:29 +00:00
|
|
|
class DIALOG_EXPORT_SVG : public DIALOG_EXPORT_SVG_BASE
|
2014-06-24 16:17:18 +00:00
|
|
|
{
|
|
|
|
public:
|
2020-01-13 01:44:19 +00:00
|
|
|
DIALOG_EXPORT_SVG( PCB_EDIT_FRAME* aParent, BOARD* aBoard );
|
2018-06-13 12:20:29 +00:00
|
|
|
~DIALOG_EXPORT_SVG() override;
|
2014-06-24 16:17:18 +00:00
|
|
|
|
|
|
|
private:
|
2018-06-13 12:20:29 +00:00
|
|
|
BOARD* m_board;
|
2020-01-13 01:44:19 +00:00
|
|
|
PCB_EDIT_FRAME* m_parent;
|
2023-09-28 14:59:11 +00:00
|
|
|
LSEQ m_printMaskLayer;
|
2016-06-19 18:29:13 +00:00
|
|
|
// the list of existing board layers in wxCheckListBox, with the
|
|
|
|
// board layers id:
|
2017-03-13 03:19:33 +00:00
|
|
|
std::pair<wxCheckListBox*, int> m_boxSelectLayer[PCB_LAYER_ID_COUNT];
|
2018-06-13 12:20:29 +00:00
|
|
|
bool m_printBW;
|
|
|
|
wxString m_outputDirectory;
|
|
|
|
bool m_printMirror;
|
|
|
|
bool m_oneFileOnly;
|
2014-06-24 16:17:18 +00:00
|
|
|
|
|
|
|
void initDialog();
|
|
|
|
|
2016-09-24 18:53:15 +00:00
|
|
|
void OnButtonPlot( wxCommandEvent& event ) override;
|
2014-06-24 16:17:18 +00:00
|
|
|
|
2021-04-16 12:12:55 +00:00
|
|
|
void onPagePerLayerClicked( wxCommandEvent& event ) override;
|
2016-09-24 18:53:15 +00:00
|
|
|
void OnOutputDirectoryBrowseClicked( wxCommandEvent& event ) override;
|
2014-06-24 16:17:18 +00:00
|
|
|
void ExportSVGFile( bool aOnlyOneFile );
|
|
|
|
|
|
|
|
LSET getCheckBoxSelectedLayers() const;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2020-01-13 01:44:19 +00:00
|
|
|
DIALOG_EXPORT_SVG::DIALOG_EXPORT_SVG( PCB_EDIT_FRAME* aParent, BOARD* aBoard ) :
|
2020-04-05 21:17:26 +00:00
|
|
|
DIALOG_EXPORT_SVG_BASE( aParent ),
|
|
|
|
m_board( aBoard ),
|
|
|
|
m_parent( aParent ),
|
|
|
|
m_printBW( false ),
|
|
|
|
m_printMirror( false ),
|
2021-02-06 14:43:17 +00:00
|
|
|
m_oneFileOnly( false )
|
2009-01-11 19:12:18 +00:00
|
|
|
{
|
2021-03-08 02:59:07 +00:00
|
|
|
m_browseButton->SetBitmap( KiBitmap( BITMAPS::small_folder ) );
|
2018-06-13 12:20:29 +00:00
|
|
|
|
2021-02-25 15:05:26 +00:00
|
|
|
m_messagesPanel->SetFileName( Prj().GetProjectPath() + wxT( "report.txt" ) );
|
|
|
|
|
2011-12-16 20:12:49 +00:00
|
|
|
initDialog();
|
2016-06-19 18:29:13 +00:00
|
|
|
|
2021-11-16 19:39:58 +00:00
|
|
|
SetupStandardButtons( { { wxID_OK, _( "Export" ) },
|
|
|
|
{ wxID_CANCEL, _( "Close" ) } } );
|
2018-06-13 12:20:29 +00:00
|
|
|
|
2023-08-31 18:33:31 +00:00
|
|
|
PCBNEW_SETTINGS* cfg = m_parent->GetPcbNewSettings();
|
|
|
|
m_cbUsedBoardTheme->SetValue( !cfg->m_ExportSvg.use_selected_theme );
|
|
|
|
|
|
|
|
// Build color theme list, and select the previoulsy selected theme
|
|
|
|
wxString theme_old_selection = cfg->m_ExportSvg.color_theme;
|
|
|
|
|
|
|
|
for( COLOR_SETTINGS* settings : m_parent->GetSettingsManager()->GetColorSettingsList() )
|
|
|
|
{
|
|
|
|
int pos = m_colorTheme->Append( settings->GetName(), static_cast<void*>( settings ) );
|
|
|
|
|
|
|
|
if( settings->GetName() == theme_old_selection )
|
|
|
|
m_colorTheme->SetSelection( pos );
|
|
|
|
}
|
|
|
|
|
2020-11-16 11:16:44 +00:00
|
|
|
finishDialogSettings();
|
2018-06-13 12:20:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DIALOG_EXPORT_SVG::~DIALOG_EXPORT_SVG()
|
|
|
|
{
|
|
|
|
m_printBW = m_ModeColorOption->GetSelection();
|
2021-04-16 12:12:55 +00:00
|
|
|
m_oneFileOnly = !m_checkboxPagePerLayer->GetValue();
|
2018-06-13 12:20:29 +00:00
|
|
|
m_outputDirectory = m_outputDirectoryName->GetValue();
|
|
|
|
m_outputDirectory.Replace( wxT( "\\" ), wxT( "/" ) );
|
|
|
|
|
2023-07-12 13:26:52 +00:00
|
|
|
m_parent->Prj().GetProjectFile().m_PcbLastPath[ LAST_PATH_SVG ] = m_outputDirectory;
|
|
|
|
|
2023-10-16 21:04:01 +00:00
|
|
|
PCBNEW_SETTINGS* cfg = nullptr;
|
2018-06-13 12:20:29 +00:00
|
|
|
|
2023-10-16 21:04:01 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
cfg = m_parent->GetPcbNewSettings();
|
|
|
|
}
|
|
|
|
catch( const std::runtime_error& e )
|
|
|
|
{
|
|
|
|
wxFAIL_MSG( e.what() );
|
|
|
|
}
|
2018-06-13 12:20:29 +00:00
|
|
|
|
2023-10-16 21:04:01 +00:00
|
|
|
if( cfg )
|
|
|
|
{
|
|
|
|
cfg->m_ExportSvg.black_and_white = m_printBW;
|
|
|
|
cfg->m_ExportSvg.mirror = m_printMirror;
|
|
|
|
cfg->m_ExportSvg.one_file = m_oneFileOnly;
|
|
|
|
cfg->m_ExportSvg.page_size = m_rbSvgPageSizeOpt->GetSelection();
|
|
|
|
cfg->m_ExportSvg.output_dir = m_outputDirectory.ToStdString();
|
|
|
|
cfg->m_ExportSvg.use_selected_theme = !m_cbUsedBoardTheme->GetValue();
|
|
|
|
cfg->m_ExportSvg.color_theme = m_colorTheme->GetStringSelection();
|
|
|
|
}
|
2023-08-31 18:33:31 +00:00
|
|
|
|
2021-04-16 12:12:55 +00:00
|
|
|
if( m_checkboxPagePerLayer->GetValue() )
|
|
|
|
{
|
|
|
|
m_oneFileOnly = false;
|
2023-10-16 21:04:01 +00:00
|
|
|
|
|
|
|
if( cfg )
|
|
|
|
cfg->m_ExportSvg.plot_board_edges = m_checkboxEdgesOnAllPages->GetValue();
|
2021-04-16 12:12:55 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_oneFileOnly = true;
|
|
|
|
}
|
|
|
|
|
2023-10-16 21:04:01 +00:00
|
|
|
if( cfg )
|
|
|
|
cfg->m_ExportSvg.layers.clear();
|
2018-06-13 12:20:29 +00:00
|
|
|
|
2020-01-13 01:44:19 +00:00
|
|
|
for( unsigned layer = 0; layer < arrayDim( m_boxSelectLayer ); ++layer )
|
|
|
|
{
|
|
|
|
if( !m_boxSelectLayer[layer].first )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if( m_boxSelectLayer[layer].first->IsChecked( m_boxSelectLayer[layer].second ) )
|
2023-10-16 21:04:01 +00:00
|
|
|
{
|
|
|
|
if( cfg )
|
|
|
|
cfg->m_ExportSvg.layers.push_back( layer );
|
|
|
|
}
|
2018-06-13 12:20:29 +00:00
|
|
|
}
|
2009-01-11 19:12:18 +00:00
|
|
|
}
|
2014-06-24 16:17:18 +00:00
|
|
|
|
2009-01-11 19:12:18 +00:00
|
|
|
|
2018-06-13 12:20:29 +00:00
|
|
|
void DIALOG_EXPORT_SVG::initDialog()
|
2009-01-11 19:12:18 +00:00
|
|
|
{
|
2023-07-12 13:26:52 +00:00
|
|
|
PROJECT_FILE& projectFile = m_parent->Prj().GetProjectFile();
|
2021-04-16 12:12:55 +00:00
|
|
|
PCBNEW_SETTINGS* cfg = m_parent->GetPcbNewSettings();
|
2020-01-13 01:44:19 +00:00
|
|
|
|
|
|
|
m_printBW = cfg->m_ExportSvg.black_and_white;
|
|
|
|
m_printMirror = cfg->m_ExportSvg.mirror;
|
|
|
|
m_oneFileOnly = cfg->m_ExportSvg.one_file;
|
2023-07-12 13:26:52 +00:00
|
|
|
|
|
|
|
if( !projectFile.m_PcbLastPath[ LAST_PATH_SVG ].IsEmpty() )
|
|
|
|
m_outputDirectory = projectFile.m_PcbLastPath[ LAST_PATH_SVG ];
|
|
|
|
else
|
|
|
|
m_outputDirectory = cfg->m_ExportSvg.output_dir;
|
2020-01-13 01:44:19 +00:00
|
|
|
|
|
|
|
m_rbSvgPageSizeOpt->SetSelection( cfg->m_ExportSvg.page_size );
|
2021-04-16 12:12:55 +00:00
|
|
|
m_checkboxPagePerLayer->SetValue( !m_oneFileOnly );
|
|
|
|
|
|
|
|
wxCommandEvent dummy;
|
|
|
|
onPagePerLayerClicked( dummy );
|
2009-01-11 19:12:18 +00:00
|
|
|
|
2012-11-16 14:13:31 +00:00
|
|
|
m_outputDirectoryName->SetValue( m_outputDirectory );
|
|
|
|
|
2014-08-10 14:15:02 +00:00
|
|
|
m_ModeColorOption->SetSelection( m_printBW ? 1 : 0 );
|
2012-09-20 18:58:41 +00:00
|
|
|
m_printMirrorOpt->SetValue( m_printMirror );
|
|
|
|
|
2018-06-13 12:20:29 +00:00
|
|
|
for( LSEQ seq = m_board->GetEnabledLayers().UIOrder(); seq; ++seq )
|
2010-03-26 17:18:59 +00:00
|
|
|
{
|
2017-03-13 03:19:33 +00:00
|
|
|
PCB_LAYER_ID layer = *seq;
|
2016-06-19 18:29:13 +00:00
|
|
|
int checkIndex;
|
2009-01-11 19:12:18 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
if( IsCopperLayer( layer ) )
|
2016-06-19 18:29:13 +00:00
|
|
|
{
|
|
|
|
checkIndex = m_CopperLayersList->Append( m_board->GetLayerName( layer ) );
|
|
|
|
m_boxSelectLayer[layer] = std::make_pair( m_CopperLayersList, checkIndex );
|
|
|
|
}
|
2009-01-11 19:12:18 +00:00
|
|
|
else
|
|
|
|
{
|
2016-06-19 18:29:13 +00:00
|
|
|
checkIndex = m_TechnicalLayersList->Append( m_board->GetLayerName( layer ) );
|
|
|
|
m_boxSelectLayer[layer] = std::make_pair( m_TechnicalLayersList, checkIndex );
|
|
|
|
}
|
2012-09-20 18:58:41 +00:00
|
|
|
|
2020-09-26 13:42:40 +00:00
|
|
|
if( alg::contains( cfg->m_ExportSvg.layers, layer ) )
|
2020-01-13 01:44:19 +00:00
|
|
|
m_boxSelectLayer[layer].first->Check( checkIndex, true );
|
2009-01-11 19:12:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-05-10 19:22:29 +00:00
|
|
|
|
2018-06-13 12:20:29 +00:00
|
|
|
LSET DIALOG_EXPORT_SVG::getCheckBoxSelectedLayers() const
|
2014-06-24 16:17:18 +00:00
|
|
|
{
|
|
|
|
LSET ret;
|
|
|
|
|
2019-01-06 16:43:12 +00:00
|
|
|
for( unsigned layer = 0; layer < arrayDim(m_boxSelectLayer); ++layer )
|
2014-06-24 16:17:18 +00:00
|
|
|
{
|
2016-06-19 18:29:13 +00:00
|
|
|
if( !m_boxSelectLayer[layer].first )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if( m_boxSelectLayer[layer].first->IsChecked( m_boxSelectLayer[layer].second ) )
|
2014-06-24 16:17:18 +00:00
|
|
|
ret.set( layer );
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-06-13 12:20:29 +00:00
|
|
|
void DIALOG_EXPORT_SVG::OnOutputDirectoryBrowseClicked( wxCommandEvent& event )
|
2012-11-16 14:13:31 +00:00
|
|
|
{
|
2020-04-05 21:17:26 +00:00
|
|
|
// Build the absolute path of current output directory to preselect it in the file browser.
|
|
|
|
wxString path = ExpandEnvVarSubstitutions( m_outputDirectoryName->GetValue(), &Prj() );
|
|
|
|
path = Prj().AbsolutePath( path );
|
2012-11-16 14:13:31 +00:00
|
|
|
|
|
|
|
wxDirDialog dirDialog( this, _( "Select Output Directory" ), path );
|
|
|
|
|
|
|
|
if( dirDialog.ShowModal() == wxID_CANCEL )
|
|
|
|
return;
|
|
|
|
|
2020-04-05 21:17:26 +00:00
|
|
|
wxFileName dirName = wxFileName::DirName( dirDialog.GetPath() );
|
2012-11-16 14:13:31 +00:00
|
|
|
|
2018-06-13 12:20:29 +00:00
|
|
|
wxMessageDialog dialog( this, _( "Use a relative path?" ), _( "Plot Output Directory" ),
|
2012-11-16 14:13:31 +00:00
|
|
|
wxYES_NO | wxICON_QUESTION | wxYES_DEFAULT );
|
|
|
|
|
|
|
|
if( dialog.ShowModal() == wxID_YES )
|
|
|
|
{
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
wxString boardFilePath = Prj().AbsolutePath( m_board->GetFileName() );
|
|
|
|
|
|
|
|
boardFilePath = wxPathOnly( boardFilePath );
|
2012-11-16 14:13:31 +00:00
|
|
|
|
|
|
|
if( !dirName.MakeRelativeTo( boardFilePath ) )
|
2022-03-29 20:08:02 +00:00
|
|
|
wxMessageBox( _( "Cannot make path relative (target volume different from board "
|
|
|
|
"file volume)!" ),
|
2012-11-16 14:13:31 +00:00
|
|
|
_( "Plot Output Directory" ), wxOK | wxICON_ERROR );
|
|
|
|
}
|
|
|
|
|
|
|
|
m_outputDirectoryName->SetValue( dirName.GetFullPath() );
|
|
|
|
m_outputDirectory = m_outputDirectoryName->GetValue();
|
|
|
|
}
|
2009-01-11 19:12:18 +00:00
|
|
|
|
2013-05-10 19:22:29 +00:00
|
|
|
|
2021-04-16 12:12:55 +00:00
|
|
|
void DIALOG_EXPORT_SVG::onPagePerLayerClicked( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
PCBNEW_SETTINGS* cfg = m_parent->GetPcbNewSettings();
|
|
|
|
|
|
|
|
if( m_checkboxPagePerLayer->GetValue() )
|
|
|
|
{
|
|
|
|
m_checkboxEdgesOnAllPages->Enable( true );
|
|
|
|
m_checkboxEdgesOnAllPages->SetValue( cfg->m_ExportSvg.plot_board_edges );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_checkboxEdgesOnAllPages->Enable( false );
|
|
|
|
m_checkboxEdgesOnAllPages->SetValue( false );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-06-13 12:20:29 +00:00
|
|
|
void DIALOG_EXPORT_SVG::ExportSVGFile( bool aOnlyOneFile )
|
2009-01-11 19:12:18 +00:00
|
|
|
{
|
2012-11-16 14:13:31 +00:00
|
|
|
m_outputDirectory = m_outputDirectoryName->GetValue();
|
|
|
|
|
2022-01-23 17:23:17 +00:00
|
|
|
// Create output directory if it does not exist (also transform it in absolute form).
|
|
|
|
// Bail if it fails.
|
|
|
|
|
|
|
|
std::function<bool( wxString* )> textResolver =
|
|
|
|
[&]( wxString* token ) -> bool
|
|
|
|
{
|
|
|
|
// Handles m_board->GetTitleBlock() *and* m_board->GetProject()
|
|
|
|
return m_board->ResolveTextVar( token, 0 );
|
|
|
|
};
|
|
|
|
|
|
|
|
wxString path = m_outputDirectory;
|
2023-01-17 16:54:08 +00:00
|
|
|
path = ExpandTextVars( path, &textResolver );
|
2022-01-23 17:23:17 +00:00
|
|
|
path = ExpandEnvVarSubstitutions( path, nullptr );
|
|
|
|
|
2020-04-05 21:17:26 +00:00
|
|
|
wxFileName outputDir = wxFileName::DirName( path );
|
2020-04-05 23:31:45 +00:00
|
|
|
wxString boardFilename = m_board->GetFileName();
|
2014-06-24 16:17:18 +00:00
|
|
|
|
2015-06-16 12:20:42 +00:00
|
|
|
REPORTER& reporter = m_messagesPanel->Reporter();
|
2012-11-16 14:13:31 +00:00
|
|
|
|
2014-10-26 13:59:01 +00:00
|
|
|
if( !EnsureFileDirectoryExists( &outputDir, boardFilename, &reporter ) )
|
2013-05-10 19:22:29 +00:00
|
|
|
{
|
2021-06-27 13:24:02 +00:00
|
|
|
wxString msg = wxString::Format( _( "Could not write plot files to folder '%s'." ),
|
2018-06-13 12:20:29 +00:00
|
|
|
outputDir.GetPath() );
|
2013-05-10 19:22:29 +00:00
|
|
|
DisplayError( this, msg );
|
2012-11-16 14:13:31 +00:00
|
|
|
return;
|
2013-05-10 19:22:29 +00:00
|
|
|
}
|
2009-01-11 19:12:18 +00:00
|
|
|
|
2012-09-20 18:58:41 +00:00
|
|
|
m_printMirror = m_printMirrorOpt->GetValue();
|
|
|
|
m_printBW = m_ModeColorOption->GetSelection();
|
2009-01-11 19:12:18 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
LSET all_selected = getCheckBoxSelectedLayers();
|
2009-01-11 19:12:18 +00:00
|
|
|
|
2022-10-04 01:53:37 +00:00
|
|
|
PCB_PLOT_SVG_OPTIONS svgPlotOptions;
|
2023-10-16 21:04:01 +00:00
|
|
|
svgPlotOptions.m_negative = false;
|
2022-10-04 01:53:37 +00:00
|
|
|
svgPlotOptions.m_blackAndWhite = m_printBW;
|
|
|
|
svgPlotOptions.m_printMaskLayer = m_printMaskLayer;
|
|
|
|
svgPlotOptions.m_pageSizeMode = m_rbSvgPageSizeOpt->GetSelection();
|
2023-08-31 18:33:31 +00:00
|
|
|
|
|
|
|
PCBNEW_SETTINGS* cfg = m_parent->GetPcbNewSettings();
|
|
|
|
wxString export_theme = m_cbUsedBoardTheme->GetValue()
|
|
|
|
? cfg->m_ColorTheme
|
|
|
|
: m_colorTheme->GetStringSelection();
|
|
|
|
|
|
|
|
svgPlotOptions.m_colorTheme = export_theme;
|
|
|
|
|
2022-10-04 01:53:37 +00:00
|
|
|
svgPlotOptions.m_mirror = m_printMirror;
|
2022-12-14 03:48:07 +00:00
|
|
|
svgPlotOptions.m_plotFrame = svgPlotOptions.m_pageSizeMode == 0;
|
2023-08-27 19:16:29 +00:00
|
|
|
svgPlotOptions.m_drillShapeOption = 2; // actual size hole.
|
2022-10-04 01:53:37 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
for( LSEQ seq = all_selected.Seq(); seq; ++seq )
|
2009-01-11 19:12:18 +00:00
|
|
|
{
|
2017-03-13 03:19:33 +00:00
|
|
|
PCB_LAYER_ID layer = *seq;
|
2018-06-13 12:20:29 +00:00
|
|
|
wxFileName fn( boardFilename );
|
2023-02-12 21:29:26 +00:00
|
|
|
wxString suffix = aOnlyOneFile ? wxString( wxT( "brd" ) ) : m_board->GetStandardLayerName( layer );
|
2013-05-10 19:22:29 +00:00
|
|
|
|
2012-11-16 14:13:31 +00:00
|
|
|
BuildPlotFileName( &fn, outputDir.GetPath(), suffix, SVGFileExtension );
|
2020-04-05 23:31:45 +00:00
|
|
|
wxString svgPath = fn.GetFullPath();
|
2009-01-11 19:12:18 +00:00
|
|
|
|
2023-09-28 14:59:11 +00:00
|
|
|
m_printMaskLayer = aOnlyOneFile ? all_selected.SeqStackupBottom2Top() : LSEQ( { layer } );
|
2009-01-11 19:12:18 +00:00
|
|
|
|
2021-04-16 12:12:55 +00:00
|
|
|
if( m_checkboxEdgesOnAllPages->GetValue() )
|
2023-09-28 14:59:11 +00:00
|
|
|
m_printMaskLayer.push_back( Edge_Cuts );
|
2012-09-20 18:58:41 +00:00
|
|
|
|
2022-10-04 01:53:37 +00:00
|
|
|
svgPlotOptions.m_outputFile = svgPath;
|
|
|
|
svgPlotOptions.m_printMaskLayer = m_printMaskLayer;
|
|
|
|
|
2023-08-18 17:44:54 +00:00
|
|
|
if( EXPORT_SVG::Plot(m_board, svgPlotOptions ) )
|
2012-09-20 18:58:41 +00:00
|
|
|
{
|
2021-06-27 13:24:02 +00:00
|
|
|
reporter.Report( wxString::Format( _( "Exported '%s'." ), svgPath ),
|
|
|
|
RPT_SEVERITY_ACTION );
|
2013-05-10 19:22:29 +00:00
|
|
|
}
|
2012-09-20 18:58:41 +00:00
|
|
|
else // Error
|
2009-01-11 19:12:18 +00:00
|
|
|
{
|
2021-07-05 12:40:38 +00:00
|
|
|
reporter.Report( wxString::Format( _( "Failed to create file '%s'." ), svgPath ),
|
2020-03-04 09:48:18 +00:00
|
|
|
RPT_SEVERITY_ERROR );
|
2009-01-11 19:12:18 +00:00
|
|
|
}
|
|
|
|
|
2012-09-20 18:58:41 +00:00
|
|
|
if( aOnlyOneFile )
|
2009-01-11 19:12:18 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-06-13 12:20:29 +00:00
|
|
|
void DIALOG_EXPORT_SVG::OnButtonPlot( wxCommandEvent& event )
|
2009-01-11 19:12:18 +00:00
|
|
|
{
|
2021-04-16 12:12:55 +00:00
|
|
|
m_oneFileOnly = !m_checkboxPagePerLayer->GetValue();
|
2012-09-20 18:58:41 +00:00
|
|
|
ExportSVGFile( m_oneFileOnly );
|
2009-01-11 19:12:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-01-13 01:44:19 +00:00
|
|
|
bool InvokeExportSVG( PCB_EDIT_FRAME* aCaller, BOARD* aBoard )
|
2009-01-11 19:12:18 +00:00
|
|
|
{
|
2018-06-13 12:20:29 +00:00
|
|
|
DIALOG_EXPORT_SVG dlg( aCaller, aBoard );
|
2012-08-31 07:43:37 +00:00
|
|
|
|
2018-06-13 12:20:29 +00:00
|
|
|
dlg.ShowModal();
|
2014-06-24 16:17:18 +00:00
|
|
|
|
2018-06-13 12:20:29 +00:00
|
|
|
return true;
|
2009-01-11 19:12:18 +00:00
|
|
|
}
|