diff --git a/common/jobs/job_pcb_render.cpp b/common/jobs/job_pcb_render.cpp index 112781a1fb..7f2292d2d3 100644 --- a/common/jobs/job_pcb_render.cpp +++ b/common/jobs/job_pcb_render.cpp @@ -84,6 +84,7 @@ JOB_PCB_RENDER::JOB_PCB_RENDER() : JOB( "render", false ), m_filename() { m_params.emplace_back( new JOB_PARAM( "format", &m_format, m_format ) ); + m_params.emplace_back( new JOB_PARAM( "preset", &m_appearancePreset, m_appearancePreset ) ); m_params.emplace_back( new JOB_PARAM( "quality", &m_quality, m_quality ) ); m_params.emplace_back( new JOB_PARAM( "bg_style", &m_bgStyle, m_bgStyle ) ); m_params.emplace_back( new JOB_PARAM( "side", &m_side, m_side ) ); diff --git a/common/jobs/job_pcb_render.h b/common/jobs/job_pcb_render.h index 4b6be97c32..ff23744187 100644 --- a/common/jobs/job_pcb_render.h +++ b/common/jobs/job_pcb_render.h @@ -86,7 +86,7 @@ public: BG_STYLE m_bgStyle = BG_STYLE::DEFAULT; int m_width = 0; int m_height = 0; - std::string m_colorPreset; + std::string m_appearancePreset; SIDE m_side = SIDE::TOP; double m_zoom = 1.0; bool m_perspective = false; diff --git a/kicad/cli/command_pcb_render.cpp b/kicad/cli/command_pcb_render.cpp index 9e796771a3..7d2d2449b9 100644 --- a/kicad/cli/command_pcb_render.cpp +++ b/kicad/cli/command_pcb_render.cpp @@ -254,9 +254,10 @@ CLI::PCB_RENDER_COMMAND::PCB_RENDER_COMMAND() : COMMAND( "render" ) m_argParser.add_argument( ARG_PRESET ) .default_value( std::string( wxString( FOLLOW_PLOT_SETTINGS ) ) ) .metavar( "PRESET" ) - .help( UTF8STDSTR( wxString::Format( _( "Color preset. Options: %s, %s, %s, ..." ), - FOLLOW_PCB, FOLLOW_PLOT_SETTINGS, - LEGACY_PRESET_FLAG ) ) ); + .help( UTF8STDSTR( wxString::Format( _( "Appearance preset. Options: %s, %s, or user-defined " + "preset name" ), + FOLLOW_PCB, + FOLLOW_PLOT_SETTINGS ) ) ); m_argParser.add_argument( ARG_FLOOR ) .flag() @@ -326,7 +327,14 @@ int CLI::PCB_RENDER_COMMAND::doPerform( KIWAY& aKiway ) renderJob->m_filename = m_argInput; renderJob->SetVarOverrides( m_argDefineVars ); - renderJob->m_colorPreset = m_argParser.get( ARG_PRESET ); + renderJob->m_appearancePreset = m_argParser.get( ARG_PRESET ); + + if( renderJob->m_appearancePreset == LEGACY_PRESET_FLAG ) + { + wxFprintf( stderr, _( "Invalid preset\n" ) ); + return EXIT_CODES::ERR_ARGS; + } + renderJob->m_width = m_argParser.get( ARG_WIDTH ); renderJob->m_height = m_argParser.get( ARG_HEIGHT ); renderJob->m_zoom = m_argParser.get( ARG_ZOOM ); diff --git a/pcbnew/dialogs/dialog_render_job.cpp b/pcbnew/dialogs/dialog_render_job.cpp index aba9c1c37e..4d46c16e4c 100644 --- a/pcbnew/dialogs/dialog_render_job.cpp +++ b/pcbnew/dialogs/dialog_render_job.cpp @@ -22,6 +22,10 @@ #include #include #include +#include +#include +#include <3d_viewer/eda_3d_viewer_settings.h> + static std::map bgStyleMap = { { JOB_PCB_RENDER::BG_STYLE::DEFAULT, _HKI( "Default" ) }, @@ -39,7 +43,8 @@ static std::map sideMap = { }; DIALOG_RENDER_JOB::DIALOG_RENDER_JOB( wxWindow* aParent, JOB_PCB_RENDER* aJob ) : - DIALOG_RENDER_JOB_BASE( aParent ), m_job( aJob ) + DIALOG_RENDER_JOB_BASE( aParent ), + m_job( aJob ) { SetTitle( aJob->GetSettingsDialogTitle() ); @@ -52,6 +57,14 @@ DIALOG_RENDER_JOB::DIALOG_RENDER_JOB( wxWindow* aParent, JOB_PCB_RENDER* aJob ) for( const auto& [k, name] : sideMap ) m_choiceSide->Append( wxGetTranslation( name ) ); + SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager(); + + if( EDA_3D_VIEWER_SETTINGS* cfg = mgr.GetAppSettings( "3d_viewer" ) ) + { + for( const LAYER_PRESET_3D& preset : cfg->m_LayerPresets ) + m_presetCtrl->Append( preset.name ); + } + SetupStandardButtons(); } @@ -125,6 +138,12 @@ bool DIALOG_RENDER_JOB::TransferDataFromWindow() m_job->m_format = getSelectedFormat(); m_job->m_quality = JOB_PCB_RENDER::QUALITY::JOB_SETTINGS; + + if( m_presetCtrl->GetSelection() == 0 ) + m_job->m_appearancePreset = ""; + else + m_job->m_appearancePreset = m_presetCtrl->GetStringSelection(); + m_job->m_bgStyle = getSelectedBgStyle(); m_job->m_side = getSelectedSide(); m_job->m_zoom = m_spinCtrlZoom->GetValue(); @@ -167,6 +186,10 @@ bool DIALOG_RENDER_JOB::TransferDataToWindow() m_textCtrlOutputFile->SetValue( m_job->GetConfiguredOutputPath() ); setSelectedFormat( m_job->m_format ); + + if( !m_presetCtrl->SetStringSelection( m_job->m_appearancePreset ) ) + m_presetCtrl->SetSelection( 0 ); + setSelectedBgStyle( m_job->m_bgStyle ); setSelectedSide( m_job->m_side ); m_spinCtrlZoom->SetValue( m_job->m_zoom ); diff --git a/pcbnew/dialogs/dialog_render_job_base.cpp b/pcbnew/dialogs/dialog_render_job_base.cpp index 558171b2ef..4dd1b102ad 100644 --- a/pcbnew/dialogs/dialog_render_job_base.cpp +++ b/pcbnew/dialogs/dialog_render_job_base.cpp @@ -44,29 +44,39 @@ DIALOG_RENDER_JOB_BASE::DIALOG_RENDER_JOB_BASE( wxWindow* parent, wxWindowID id, m_dimensionsLabel->Wrap( -1 ); fgSizerTop->Add( m_dimensionsLabel, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 ); - wxBoxSizer* bSizer3; - bSizer3 = new wxBoxSizer( wxHORIZONTAL ); + wxBoxSizer* bSizerDimensions; + bSizerDimensions = new wxBoxSizer( wxHORIZONTAL ); m_spinCtrlWidth = new wxSpinCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 128, 32767, 0 ); - bSizer3->Add( m_spinCtrlWidth, 0, wxRIGHT|wxALIGN_CENTER_VERTICAL, 5 ); + bSizerDimensions->Add( m_spinCtrlWidth, 0, wxRIGHT|wxALIGN_CENTER_VERTICAL, 5 ); m_staticText17 = new wxStaticText( this, wxID_ANY, _("px"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticText17->Wrap( -1 ); - bSizer3->Add( m_staticText17, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 ); + bSizerDimensions->Add( m_staticText17, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 ); m_staticText19 = new wxStaticText( this, wxID_ANY, _("x"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticText19->Wrap( -1 ); - bSizer3->Add( m_staticText19, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 10 ); + bSizerDimensions->Add( m_staticText19, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 10 ); m_spinCtrlHeight = new wxSpinCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 128, 32767, 0 ); - bSizer3->Add( m_spinCtrlHeight, 0, wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 5 ); + bSizerDimensions->Add( m_spinCtrlHeight, 0, wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 5 ); m_staticText182 = new wxStaticText( this, wxID_ANY, _("px"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticText182->Wrap( -1 ); - bSizer3->Add( m_staticText182, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 ); + bSizerDimensions->Add( m_staticText182, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 ); - fgSizerTop->Add( bSizer3, 1, wxEXPAND, 5 ); + fgSizerTop->Add( bSizerDimensions, 1, wxEXPAND, 5 ); + + m_presetLabel = new wxStaticText( this, wxID_ANY, _("Appearance preset:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_presetLabel->Wrap( -1 ); + fgSizerTop->Add( m_presetLabel, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); + + wxString m_presetCtrlChoices[] = { _("Default") }; + int m_presetCtrlNChoices = sizeof( m_presetCtrlChoices ) / sizeof( wxString ); + m_presetCtrl = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_presetCtrlNChoices, m_presetCtrlChoices, 0 ); + m_presetCtrl->SetSelection( 0 ); + fgSizerTop->Add( m_presetCtrl, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM, 5 ); m_backgroundStyleLabel = new wxStaticText( this, wxID_ANY, _("Background style:"), wxDefaultPosition, wxDefaultSize, 0 ); m_backgroundStyleLabel->Wrap( -1 ); diff --git a/pcbnew/dialogs/dialog_render_job_base.fbp b/pcbnew/dialogs/dialog_render_job_base.fbp index 337a12297f..265673b0aa 100644 --- a/pcbnew/dialogs/dialog_render_job_base.fbp +++ b/pcbnew/dialogs/dialog_render_job_base.fbp @@ -397,13 +397,13 @@ -1 - + 5 wxEXPAND 1 - bSizer3 + bSizerDimensions wxHORIZONTAL none @@ -720,6 +720,133 @@ + + 5 + wxALL|wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + Appearance preset: + 0 + + 0 + + + 0 + + 1 + m_presetLabel + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + + + 5 + wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM + 0 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + + + + 1 + 0 + "Default" + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_presetCtrl + 1 + + + protected + 1 + + Resizable + 0 + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + 5 wxALIGN_CENTER_VERTICAL|wxLEFT diff --git a/pcbnew/dialogs/dialog_render_job_base.h b/pcbnew/dialogs/dialog_render_job_base.h index 9b30b6c28f..d3c18d8b6f 100644 --- a/pcbnew/dialogs/dialog_render_job_base.h +++ b/pcbnew/dialogs/dialog_render_job_base.h @@ -48,6 +48,8 @@ class DIALOG_RENDER_JOB_BASE : public DIALOG_SHIM wxStaticText* m_staticText19; wxSpinCtrl* m_spinCtrlHeight; wxStaticText* m_staticText182; + wxStaticText* m_presetLabel; + wxChoice* m_presetCtrl; wxStaticText* m_backgroundStyleLabel; wxChoice* m_choiceBgStyle; wxCheckBox* m_cbRaytracing_proceduralTextures; diff --git a/pcbnew/pcbnew_jobs_handler.cpp b/pcbnew/pcbnew_jobs_handler.cpp index 1319a32d24..b66ce4ff65 100644 --- a/pcbnew/pcbnew_jobs_handler.cpp +++ b/pcbnew/pcbnew_jobs_handler.cpp @@ -579,7 +579,9 @@ int PCBNEW_JOBS_HANDLER::JobExportRender( JOB* aJob ) boardAdapter.SetBoard( brd ); boardAdapter.m_IsBoardView = false; - boardAdapter.m_IsPreviewer = true; // Force display 3D models, regardless of 3D viewer options + + if( aRenderJob->m_appearancePreset.empty() ) + boardAdapter.m_IsPreviewer = true; // Force display 3D models, regardless of 3D viewer options SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager(); EDA_3D_VIEWER_SETTINGS cfg; @@ -660,7 +662,7 @@ int PCBNEW_JOBS_HANDLER::JobExportRender( JOB* aJob ) 45, 135, 225, 315, 45, 135, 225, 315, }; - cfg.m_CurrentPreset = aRenderJob->m_colorPreset; + cfg.m_CurrentPreset = aRenderJob->m_appearancePreset; boardAdapter.m_Cfg = &cfg; if( aRenderJob->m_bgStyle == JOB_PCB_RENDER::BG_STYLE::TRANSPARENT