dialog_export_svg: add color theme selection.

Previously, the Kicad Classic theme was always used.
This commit is contained in:
jean-pierre charras 2023-08-31 20:33:31 +02:00
parent 5358343023
commit 160ec181ac
6 changed files with 364 additions and 88 deletions

View File

@ -71,9 +71,8 @@ private:
};
/*
* DIALOG_EXPORT_SVG functions
*/
/* DIALOG_EXPORT_SVG functions
*/
DIALOG_EXPORT_SVG::DIALOG_EXPORT_SVG( PCB_EDIT_FRAME* aParent, BOARD* aBoard ) :
DIALOG_EXPORT_SVG_BASE( aParent ),
m_board( aBoard ),
@ -91,6 +90,20 @@ DIALOG_EXPORT_SVG::DIALOG_EXPORT_SVG( PCB_EDIT_FRAME* aParent, BOARD* aBoard ) :
SetupStandardButtons( { { wxID_OK, _( "Export" ) },
{ wxID_CANCEL, _( "Close" ) } } );
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 );
}
finishDialogSettings();
}
@ -112,6 +125,9 @@ DIALOG_EXPORT_SVG::~DIALOG_EXPORT_SVG()
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();
if( m_checkboxPagePerLayer->GetValue() )
{
m_oneFileOnly = false;
@ -289,7 +305,14 @@ void DIALOG_EXPORT_SVG::ExportSVGFile( bool aOnlyOneFile )
svgPlotOptions.m_blackAndWhite = m_printBW;
svgPlotOptions.m_printMaskLayer = m_printMaskLayer;
svgPlotOptions.m_pageSizeMode = m_rbSvgPageSizeOpt->GetSelection();
svgPlotOptions.m_colorTheme = ""; // will use default
PCBNEW_SETTINGS* cfg = m_parent->GetPcbNewSettings();
wxString export_theme = m_cbUsedBoardTheme->GetValue()
? cfg->m_ColorTheme
: m_colorTheme->GetStringSelection();
svgPlotOptions.m_colorTheme = export_theme;
svgPlotOptions.m_mirror = m_printMirror;
svgPlotOptions.m_plotFrame = svgPlotOptions.m_pageSizeMode == 0;
svgPlotOptions.m_drillShapeOption = 2; // actual size hole.

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b)
// C++ code generated with wxFormBuilder (version 3.10.0-39-g3487c3cb)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
@ -86,6 +86,31 @@ DIALOG_EXPORT_SVG_BASE::DIALOG_EXPORT_SVG_BASE( wxWindow* parent, wxWindowID id,
sbOptionsSizer->Add( m_ModeColorOption, 0, wxEXPAND|wxALL, 5 );
m_cbUsedBoardTheme = new wxCheckBox( sbOptionsSizer->GetStaticBox(), wxID_ANY, _("Use current board theme"), wxDefaultPosition, wxDefaultSize, 0 );
m_cbUsedBoardTheme->SetValue(true);
sbOptionsSizer->Add( m_cbUsedBoardTheme, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
wxBoxSizer* bSizerTheme;
bSizerTheme = new wxBoxSizer( wxHORIZONTAL );
m_stColorTheme = new wxStaticText( sbOptionsSizer->GetStaticBox(), wxID_ANY, _("Color theme:"), wxDefaultPosition, wxDefaultSize, 0 );
m_stColorTheme->Wrap( -1 );
bSizerTheme->Add( m_stColorTheme, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
wxArrayString m_colorThemeChoices;
m_colorTheme = new wxChoice( sbOptionsSizer->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, m_colorThemeChoices, 0 );
m_colorTheme->SetSelection( 0 );
bSizerTheme->Add( m_colorTheme, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 );
sbOptionsSizer->Add( bSizerTheme, 0, wxEXPAND, 5 );
wxBoxSizer* bSizer8;
bSizer8 = new wxBoxSizer( wxVERTICAL );
sbOptionsSizer->Add( bSizer8, 1, wxEXPAND, 5 );
wxString m_rbSvgPageSizeOptChoices[] = { _("Page with frame and title block"), _("Current page size"), _("Board area only") };
int m_rbSvgPageSizeOptNChoices = sizeof( m_rbSvgPageSizeOptChoices ) / sizeof( wxString );
m_rbSvgPageSizeOpt = new wxRadioBox( sbOptionsSizer->GetStaticBox(), wxID_ANY, _("SVG Page Size"), wxDefaultPosition, wxDefaultSize, m_rbSvgPageSizeOptNChoices, m_rbSvgPageSizeOptChoices, 1, wxRA_SPECIFY_COLS );
@ -98,16 +123,19 @@ DIALOG_EXPORT_SVG_BASE::DIALOG_EXPORT_SVG_BASE( wxWindow* parent, wxWindowID id,
sbOptionsSizer->Add( m_printMirrorOpt, 0, wxALL, 5 );
m_checkboxPagePerLayer = new wxCheckBox( sbOptionsSizer->GetStaticBox(), wxID_ANY, _("Print one page per layer"), wxDefaultPosition, wxDefaultSize, 0 );
sbOptionsSizer->Add( m_checkboxPagePerLayer, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
sbOptionsSizer->Add( m_checkboxPagePerLayer, 0, wxALL, 5 );
wxBoxSizer* bSizerBrdEdges;
bSizerBrdEdges = new wxBoxSizer( wxHORIZONTAL );
sbOptionsSizer->Add( 0, 3, 0, wxEXPAND, 5 );
bSizerBrdEdges->Add( 20, 0, 0, wxEXPAND, 5 );
m_checkboxEdgesOnAllPages = new wxCheckBox( sbOptionsSizer->GetStaticBox(), wxID_ANY, _("Print board edges on all pages"), wxDefaultPosition, wxDefaultSize, 0 );
sbOptionsSizer->Add( m_checkboxEdgesOnAllPages, 0, wxRIGHT|wxLEFT, 28 );
bSizerBrdEdges->Add( m_checkboxEdgesOnAllPages, 0, wxBOTTOM|wxLEFT, 5 );
sbOptionsSizer->Add( 0, 0, 0, wxEXPAND|wxBOTTOM, 5 );
sbOptionsSizer->Add( bSizerBrdEdges, 0, wxEXPAND, 5 );
bUpperSizer->Add( sbOptionsSizer, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );

View File

@ -642,6 +642,217 @@
<property name="window_style"></property>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxTOP|wxRIGHT|wxLEFT</property>
<property name="proportion">0</property>
<object class="wxCheckBox" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="checked">1</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Use current board theme</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_cbUsedBoardTheme</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND</property>
<property name="proportion">0</property>
<object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property>
<property name="name">bSizerTheme</property>
<property name="orient">wxHORIZONTAL</property>
<property name="permission">none</property>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL|wxALIGN_CENTER_VERTICAL</property>
<property name="proportion">0</property>
<object class="wxStaticText" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Color theme:</property>
<property name="markup">0</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_stColorTheme</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<property name="wrap">-1</property>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND</property>
<property name="proportion">0</property>
<object class="wxChoice" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="choices"></property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_colorTheme</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="selection">0</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
</object>
</object>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND</property>
<property name="proportion">1</property>
<object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property>
<property name="name">bSizer8</property>
<property name="orient">wxVERTICAL</property>
<property name="permission">none</property>
</object>
</object>
<object class="sizeritem" expanded="0">
<property name="border">5</property>
<property name="flag">wxEXPAND|wxALL</property>
@ -774,7 +985,7 @@
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxTOP|wxRIGHT|wxLEFT</property>
<property name="flag">wxALL</property>
<property name="proportion">0</property>
<object class="wxCheckBox" expanded="1">
<property name="BottomDockable">1</property>
@ -841,84 +1052,85 @@
<property name="border">5</property>
<property name="flag">wxEXPAND</property>
<property name="proportion">0</property>
<object class="spacer" expanded="1">
<property name="height">3</property>
<property name="permission">protected</property>
<property name="width">0</property>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">28</property>
<property name="flag">wxRIGHT|wxLEFT</property>
<property name="proportion">0</property>
<object class="wxCheckBox" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="checked">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Print board edges on all pages</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_checkboxEdgesOnAllPages</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND|wxBOTTOM</property>
<property name="proportion">0</property>
<object class="spacer" expanded="1">
<property name="height">0</property>
<property name="permission">protected</property>
<property name="width">0</property>
<property name="name">bSizerBrdEdges</property>
<property name="orient">wxHORIZONTAL</property>
<property name="permission">none</property>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND</property>
<property name="proportion">0</property>
<object class="spacer" expanded="1">
<property name="height">0</property>
<property name="permission">protected</property>
<property name="width">20</property>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxBOTTOM|wxLEFT</property>
<property name="proportion">0</property>
<object class="wxCheckBox" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="checked">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Print board edges on all pages</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_checkboxEdgesOnAllPages</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
</object>
</object>
</object>
</object>
</object>

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b)
// C++ code generated with wxFormBuilder (version 3.10.0-39-g3487c3cb)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
@ -31,6 +31,7 @@ class WX_HTML_REPORT_PANEL;
#include <wx/statbox.h>
#include <wx/radiobox.h>
#include <wx/checkbox.h>
#include <wx/choice.h>
#include <wx/panel.h>
#include <wx/dialog.h>
@ -52,6 +53,9 @@ class DIALOG_EXPORT_SVG_BASE : public DIALOG_SHIM
wxStaticText* m_staticTextTechLayers;
wxCheckListBox* m_TechnicalLayersList;
wxRadioBox* m_ModeColorOption;
wxCheckBox* m_cbUsedBoardTheme;
wxStaticText* m_stColorTheme;
wxChoice* m_colorTheme;
wxRadioBox* m_rbSvgPageSizeOpt;
wxCheckBox* m_printMirrorOpt;
wxCheckBox* m_checkboxPagePerLayer;

View File

@ -375,6 +375,12 @@ PCBNEW_SETTINGS::PCBNEW_SETTINGS()
m_params.emplace_back( new PARAM<bool>( "export_svg.black_and_white",
&m_ExportSvg.black_and_white, false ) );
m_params.emplace_back( new PARAM<bool>( "export_svg.use_theme",
&m_ExportSvg.use_selected_theme, true ) );
m_params.emplace_back( new PARAM<wxString>( "export_svg.color_theme",
&m_ExportSvg.color_theme, "" ) );
m_params.emplace_back( new PARAM<bool>( "export_svg.mirror",
&m_ExportSvg.mirror, false ) );

View File

@ -197,6 +197,9 @@ public:
int page_size;
wxString output_dir; // legacy; now in project settings
std::vector<int> layers;
bool use_selected_theme;// color theme option to use for export
// false = board theme, true = selected theme
wxString color_theme; // color theme used for export
};
struct DIALOG_EXPORT_VRML