3D-Viewer: set default alpha when import from legacy
keep the current alpha when import colors from stackup. request a refresh instead of a reload when using OpenGL render. Fixes https://gitlab.com/kicad/code/kicad/issues/5717
This commit is contained in:
parent
a25d091b6c
commit
cea1a56f5f
|
@ -576,7 +576,6 @@ bool C3D_RENDER_OGL_LEGACY::Redraw(
|
|||
aStatusReporter->Report( _( "Loading..." ) );
|
||||
|
||||
reload( aStatusReporter, aWarningReporter );
|
||||
setupMaterials();
|
||||
|
||||
// generate a new 3D grid as the size of the board may had changed
|
||||
m_last_grid_type = m_boardAdapter.GridGet();
|
||||
|
@ -593,6 +592,8 @@ bool C3D_RENDER_OGL_LEGACY::Redraw(
|
|||
}
|
||||
}
|
||||
|
||||
setupMaterials();
|
||||
|
||||
// Initial setup
|
||||
// /////////////////////////////////////////////////////////////////////////
|
||||
glDepthFunc( GL_LESS );
|
||||
|
|
|
@ -231,9 +231,9 @@ bool EDA_3D_VIEWER_SETTINGS::MigrateFromLegacy( wxConfigBase* aCfg )
|
|||
|
||||
auto migrate_color =
|
||||
[&] ( const std::string& k_r, const std::string& k_g,
|
||||
const std::string &k_b, std::string dest )
|
||||
const std::string &k_b, std::string dest, double alpha = 1.0 )
|
||||
{
|
||||
COLOR4D color( 1, 1, 1, 1 );
|
||||
COLOR4D color( 1, 1, 1, alpha );
|
||||
|
||||
if( aCfg->Read( k_r, &color.r ) &&
|
||||
aCfg->Read( k_g, &color.g ) && aCfg->Read( k_b, &color.b ) )
|
||||
|
@ -251,7 +251,7 @@ bool EDA_3D_VIEWER_SETTINGS::MigrateFromLegacy( wxConfigBase* aCfg )
|
|||
migrate_color(
|
||||
"SilkColor_Red", "SilkColor_Green", "SilkColor_Blue", "colors.silkscreen_bottom" );
|
||||
migrate_color( "SilkColor_Red", "SilkColor_Green", "SilkColor_Blue", "colors.silkscreen_top" );
|
||||
migrate_color( "SMaskColor_Red", "SMaskColor_Green", "SMaskColor_Blue", "colors.soldermask" );
|
||||
migrate_color( "SMaskColor_Red", "SMaskColor_Green", "SMaskColor_Blue", "colors.soldermask", 0.83 );
|
||||
migrate_color(
|
||||
"SPasteColor_Red", "SPasteColor_Green", "SPasteColor_Blue", "colors.solderpaste" );
|
||||
|
||||
|
|
|
@ -278,6 +278,14 @@ void EDA_3D_VIEWER::Redraw()
|
|||
m_canvas->Request_refresh( true );
|
||||
}
|
||||
|
||||
void EDA_3D_VIEWER::refreshRender()
|
||||
{
|
||||
if( m_boardAdapter.RenderEngineGet() == RENDER_ENGINE::OPENGL_LEGACY )
|
||||
m_canvas->Request_refresh();
|
||||
else
|
||||
NewDisplay( true );
|
||||
}
|
||||
|
||||
void EDA_3D_VIEWER::Exit3DFrame( wxCommandEvent &event )
|
||||
{
|
||||
wxLogTrace( m_logTrace, "EDA_3D_VIEWER::Exit3DFrame" );
|
||||
|
@ -328,22 +336,12 @@ void EDA_3D_VIEWER::Process_Special_Functions( wxCommandEvent &event )
|
|||
case ID_MENU3D_BGCOLOR_BOTTOM:
|
||||
if( Set3DColorFromUser( m_boardAdapter.m_BgColorBot, _( "Background Color, Bottom" ),
|
||||
nullptr ) )
|
||||
{
|
||||
if( m_boardAdapter.RenderEngineGet() == RENDER_ENGINE::OPENGL_LEGACY )
|
||||
m_canvas->Request_refresh();
|
||||
else
|
||||
NewDisplay( true );
|
||||
}
|
||||
refreshRender();
|
||||
return;
|
||||
|
||||
case ID_MENU3D_BGCOLOR_TOP:
|
||||
if( Set3DColorFromUser( m_boardAdapter.m_BgColorTop, _( "Background Color, Top" ), nullptr ) )
|
||||
{
|
||||
if( m_boardAdapter.RenderEngineGet() == RENDER_ENGINE::OPENGL_LEGACY )
|
||||
m_canvas->Request_refresh();
|
||||
else
|
||||
NewDisplay( true );
|
||||
}
|
||||
refreshRender();
|
||||
return;
|
||||
|
||||
case ID_MENU3D_SILKSCREEN_COLOR:
|
||||
|
@ -368,7 +366,7 @@ void EDA_3D_VIEWER::Process_Special_Functions( wxCommandEvent &event )
|
|||
|
||||
case ID_MENU3D_STACKUP_COLORS:
|
||||
SynchroniseColoursWithBoard();
|
||||
NewDisplay( true );
|
||||
refreshRender();
|
||||
break;
|
||||
|
||||
case ID_MENU3D_RESET_DEFAULTS:
|
||||
|
@ -751,13 +749,15 @@ void EDA_3D_VIEWER::SynchroniseColoursWithBoard()
|
|||
m_boardAdapter.m_SolderMaskColorTop.r = color.Red() / 255.0;
|
||||
m_boardAdapter.m_SolderMaskColorTop.g = color.Green() / 255.0;
|
||||
m_boardAdapter.m_SolderMaskColorTop.b = color.Blue() / 255.0;
|
||||
m_boardAdapter.m_SolderMaskColorTop.a = color.Alpha() / 255.0;
|
||||
// Keep the previous alpha value
|
||||
//m_boardAdapter.m_SolderMaskColorTop.a = color.Alpha() / 255.0;
|
||||
break;
|
||||
case B_Mask:
|
||||
m_boardAdapter.m_SolderMaskColorBot.r = color.Red() / 255.0;
|
||||
m_boardAdapter.m_SolderMaskColorBot.g = color.Green() / 255.0;
|
||||
m_boardAdapter.m_SolderMaskColorBot.b = color.Blue() / 255.0;
|
||||
m_boardAdapter.m_SolderMaskColorBot.a = color.Alpha() / 255.0;
|
||||
// Keep the previous alpha value
|
||||
//m_boardAdapter.m_SolderMaskColorBot.a = color.Alpha() / 255.0;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -922,7 +922,9 @@ bool EDA_3D_VIEWER::Set3DSilkScreenColorFromUser()
|
|||
if( Set3DColorFromUser( m_boardAdapter.m_SilkScreenColorTop, _( "Silkscreen Color" ), &colors, false, colors[0].m_Color ) )
|
||||
{
|
||||
m_boardAdapter.m_SilkScreenColorBot = m_boardAdapter.m_SilkScreenColorTop;
|
||||
NewDisplay( true );
|
||||
|
||||
refreshRender();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -953,10 +955,7 @@ bool EDA_3D_VIEWER::Set3DSolderMaskColorFromUser()
|
|||
{
|
||||
m_boardAdapter.m_SolderMaskColorBot = m_boardAdapter.m_SolderMaskColorTop;
|
||||
|
||||
if( m_boardAdapter.RenderEngineGet() == RENDER_ENGINE::OPENGL_LEGACY )
|
||||
m_canvas->Request_refresh();
|
||||
else
|
||||
NewDisplay( true );
|
||||
refreshRender();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -976,7 +975,8 @@ bool EDA_3D_VIEWER::Set3DCopperColorFromUser()
|
|||
|
||||
if( Set3DColorFromUser( m_boardAdapter.m_CopperColor, _( "Copper Color" ), &colors, false, colors[0].m_Color ) )
|
||||
{
|
||||
NewDisplay( true );
|
||||
refreshRender();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -999,10 +999,7 @@ bool EDA_3D_VIEWER::Set3DBoardBodyColorFromUser()
|
|||
|
||||
if( Set3DColorFromUser( m_boardAdapter.m_BoardBodyColor, _( "Board Body Color" ), &colors, true, colors[0].m_Color ) )
|
||||
{
|
||||
if( m_boardAdapter.RenderEngineGet() == RENDER_ENGINE::OPENGL_LEGACY )
|
||||
m_canvas->Request_refresh();
|
||||
else
|
||||
NewDisplay( true );
|
||||
refreshRender();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -1021,7 +1018,8 @@ bool EDA_3D_VIEWER::Set3DSolderPasteColorFromUser()
|
|||
|
||||
if( Set3DColorFromUser( m_boardAdapter.m_SolderPasteColor, _( "Solder Paste Color" ), &colors, false, colors[0].m_Color ) )
|
||||
{
|
||||
NewDisplay( true );
|
||||
refreshRender();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -199,6 +199,8 @@ private:
|
|||
*/
|
||||
void RenderEngineChanged();
|
||||
|
||||
void refreshRender();
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
|
||||
private:
|
||||
|
|
Loading…
Reference in New Issue