Fix background transparency option in kicad-cli pcb render.
Fixes https://gitlab.com/kicad/code/kicad/-/issues/17865
This commit is contained in:
parent
20b2e11f21
commit
18fde2b9cb
|
@ -698,6 +698,10 @@ std::map<int, COLOR4D> BOARD_ADAPTER::GetLayerColors() const
|
||||||
}
|
}
|
||||||
|
|
||||||
colors[ LAYER_3D_COPPER_BOTTOM ] = colors[ LAYER_3D_COPPER_TOP ];
|
colors[ LAYER_3D_COPPER_BOTTOM ] = colors[ LAYER_3D_COPPER_TOP ];
|
||||||
|
|
||||||
|
for( const auto& [layer, val] : m_ColorOverrides )
|
||||||
|
colors[layer] = val;
|
||||||
|
|
||||||
return colors;
|
return colors;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -430,6 +430,8 @@ public:
|
||||||
SFVEC4F m_ECO1Color;
|
SFVEC4F m_ECO1Color;
|
||||||
SFVEC4F m_ECO2Color;
|
SFVEC4F m_ECO2Color;
|
||||||
|
|
||||||
|
std::map<int, COLOR4D> m_ColorOverrides; ///< allows to override color scheme colors
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BOARD* m_board;
|
BOARD* m_board;
|
||||||
S3D_CACHE* m_3dModelManager;
|
S3D_CACHE* m_3dModelManager;
|
||||||
|
|
|
@ -252,24 +252,16 @@ int PCBNEW_JOBS_HANDLER::JobExportRender( JOB* aJob )
|
||||||
BOARD* brd = LoadBoard( aRenderJob->m_filename, true );
|
BOARD* brd = LoadBoard( aRenderJob->m_filename, true );
|
||||||
brd->GetProject()->ApplyTextVars( aJob->GetVarOverrides() );
|
brd->GetProject()->ApplyTextVars( aJob->GetVarOverrides() );
|
||||||
|
|
||||||
BOARD_ADAPTER m_boardAdapter;
|
BOARD_ADAPTER boardAdapter;
|
||||||
|
|
||||||
m_boardAdapter.SetBoard( brd );
|
boardAdapter.SetBoard( brd );
|
||||||
m_boardAdapter.m_IsBoardView = false;
|
boardAdapter.m_IsBoardView = false;
|
||||||
m_boardAdapter.m_IsPreviewer =
|
boardAdapter.m_IsPreviewer =
|
||||||
true; // Force display 3D models, regardless the 3D viewer options
|
true; // Force display 3D models, regardless the 3D viewer options
|
||||||
|
|
||||||
EDA_3D_VIEWER_SETTINGS* cfg =
|
EDA_3D_VIEWER_SETTINGS* cfg =
|
||||||
Pgm().GetSettingsManager().GetAppSettings<EDA_3D_VIEWER_SETTINGS>();
|
Pgm().GetSettingsManager().GetAppSettings<EDA_3D_VIEWER_SETTINGS>();
|
||||||
|
|
||||||
if( aRenderJob->m_bgStyle == JOB_PCB_RENDER::BG_STYLE::TRANSPARENT
|
|
||||||
|| ( aRenderJob->m_bgStyle == JOB_PCB_RENDER::BG_STYLE::DEFAULT
|
|
||||||
&& aRenderJob->m_format == JOB_PCB_RENDER::FORMAT::PNG ) )
|
|
||||||
{
|
|
||||||
BOARD_ADAPTER::g_DefaultBackgroundTop = COLOR4D( 1.0, 1.0, 1.0, 0.0 );
|
|
||||||
BOARD_ADAPTER::g_DefaultBackgroundBot = COLOR4D( 1.0, 1.0, 1.0, 0.0 );
|
|
||||||
}
|
|
||||||
|
|
||||||
if( aRenderJob->m_quality == JOB_PCB_RENDER::QUALITY::BASIC )
|
if( aRenderJob->m_quality == JOB_PCB_RENDER::QUALITY::BASIC )
|
||||||
{
|
{
|
||||||
// Silkscreen is pixelated without antialiasing
|
// Silkscreen is pixelated without antialiasing
|
||||||
|
@ -309,9 +301,17 @@ int PCBNEW_JOBS_HANDLER::JobExportRender( JOB* aJob )
|
||||||
}
|
}
|
||||||
|
|
||||||
cfg->m_CurrentPreset = aRenderJob->m_colorPreset;
|
cfg->m_CurrentPreset = aRenderJob->m_colorPreset;
|
||||||
m_boardAdapter.m_Cfg = cfg;
|
boardAdapter.m_Cfg = cfg;
|
||||||
|
|
||||||
m_boardAdapter.Set3dCacheManager( PROJECT_PCB::Get3DCacheManager( brd->GetProject() ) );
|
if( aRenderJob->m_bgStyle == JOB_PCB_RENDER::BG_STYLE::TRANSPARENT
|
||||||
|
|| ( aRenderJob->m_bgStyle == JOB_PCB_RENDER::BG_STYLE::DEFAULT
|
||||||
|
&& aRenderJob->m_format == JOB_PCB_RENDER::FORMAT::PNG ) )
|
||||||
|
{
|
||||||
|
boardAdapter.m_ColorOverrides[LAYER_3D_BACKGROUND_TOP] = COLOR4D( 1.0, 1.0, 1.0, 0.0 );
|
||||||
|
boardAdapter.m_ColorOverrides[LAYER_3D_BACKGROUND_BOTTOM] = COLOR4D( 1.0, 1.0, 1.0, 0.0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
boardAdapter.Set3dCacheManager( PROJECT_PCB::Get3DCacheManager( brd->GetProject() ) );
|
||||||
|
|
||||||
static std::map<JOB_PCB_RENDER::SIDE, VIEW3D_TYPE> s_viewCmdMap = {
|
static std::map<JOB_PCB_RENDER::SIDE, VIEW3D_TYPE> s_viewCmdMap = {
|
||||||
{ JOB_PCB_RENDER::SIDE::TOP, VIEW3D_TYPE::VIEW3D_TOP },
|
{ JOB_PCB_RENDER::SIDE::TOP, VIEW3D_TYPE::VIEW3D_TOP },
|
||||||
|
@ -331,14 +331,14 @@ int PCBNEW_JOBS_HANDLER::JobExportRender( JOB* aJob )
|
||||||
camera.SetProjection( projection );
|
camera.SetProjection( projection );
|
||||||
camera.SetCurWindowSize( windowSize );
|
camera.SetCurWindowSize( windowSize );
|
||||||
|
|
||||||
RENDER_3D_RAYTRACE_RAM raytrace( m_boardAdapter, camera );
|
RENDER_3D_RAYTRACE_RAM raytrace( boardAdapter, camera );
|
||||||
raytrace.SetCurWindowSize( windowSize );
|
raytrace.SetCurWindowSize( windowSize );
|
||||||
|
|
||||||
for( bool first = true; raytrace.Redraw( false, m_reporter, m_reporter ); first = false )
|
for( bool first = true; raytrace.Redraw( false, m_reporter, m_reporter ); first = false )
|
||||||
{
|
{
|
||||||
if( first )
|
if( first )
|
||||||
{
|
{
|
||||||
const float cmTo3D = m_boardAdapter.BiuTo3dUnits() * pcbIUScale.mmToIU( 10.0 );
|
const float cmTo3D = boardAdapter.BiuTo3dUnits() * pcbIUScale.mmToIU( 10.0 );
|
||||||
|
|
||||||
// First redraw resets lookat point to the board center, so set up the camera here
|
// First redraw resets lookat point to the board center, so set up the camera here
|
||||||
camera.ViewCommand_T1( s_viewCmdMap[aRenderJob->m_side] );
|
camera.ViewCommand_T1( s_viewCmdMap[aRenderJob->m_side] );
|
||||||
|
|
Loading…
Reference in New Issue