3D-Viewer: add selection color as an option

This commit is contained in:
Mario Luzeiro 2020-09-27 22:23:17 +01:00 committed by Jon Evans
parent ec3c20bf84
commit ab57c93c98
10 changed files with 250 additions and 26 deletions

View File

@ -643,6 +643,8 @@ public:
SFVEC4F m_SilkScreenColorTop; ///< in realistic mode: SilkScreen color ( top )
SFVEC4F m_CopperColor; ///< in realistic mode: copper color
SFVEC3F m_opengl_selectionColor;
// Raytracing light colors
SFVEC3F m_raytrace_lightColorCamera;

View File

@ -890,8 +890,6 @@ bool C3D_RENDER_OGL_LEGACY::Redraw(
glPopMatrix();
}
m_selectionColor = m_boardAdapter.GetItemColor( LAYER_SELECT_OVERLAY );
// Render 3D Models (Non-transparent)
// /////////////////////////////////////////////////////////////////////////
render_3D_models( false, false );
@ -1356,10 +1354,10 @@ void C3D_RENDER_OGL_LEGACY::render_3D_module( const MODULE* module,
if( aRenderTransparentOnly )
modelPtr->Draw_transparent( sM.m_Opacity,
module->IsSelected() || aIsSelected,
m_selectionColor );
m_boardAdapter.m_opengl_selectionColor );
else
modelPtr->Draw_opaque( module->IsSelected() || aIsSelected,
m_selectionColor );
m_boardAdapter.m_opengl_selectionColor );
if( m_boardAdapter.GetFlag( FL_RENDER_OPENGL_SHOW_MODEL_BBOX ) )
{

View File

@ -228,8 +228,6 @@ private:
void set_layer_material( PCB_LAYER_ID aLayerID );
SFVEC4F get_layer_color( PCB_LAYER_ID aLayerID );
SFVEC3F m_selectionColor;
};
#endif // C3D_RENDER_OGL_LEGACY_H_

View File

@ -56,6 +56,10 @@ EDA_3D_VIEWER_SETTINGS::EDA_3D_VIEWER_SETTINGS()
static_cast<int>( ANTIALIASING_MODE::AA_NONE ),
static_cast<int>( ANTIALIASING_MODE::AA_8X ) ) );
m_params.emplace_back( new PARAM<COLOR4D>( "render.opengl_selection_color",
&m_Render.opengl_selection_color,
COLOR4D( 0.0, 1.0, 0.0, 1.0 ) ) );
// OpenGL options
m_params.emplace_back( new PARAM<bool>(
"render.opengl_copper_thickness", &m_Render.opengl_copper_thickness, true ) );

View File

@ -41,6 +41,8 @@ public:
bool opengl_render_bbox_only_OnMove;
bool opengl_copper_thickness;
bool opengl_show_model_bbox;
KIGFX::COLOR4D opengl_selection_color;
bool raytrace_anti_aliasing;
bool raytrace_backfloor;
bool raytrace_post_processing;

View File

@ -54,7 +54,7 @@ private:
/// Automatically called after creating the dialog
bool TransferDataToWindow() override;
void TransferLightDataToWindow();
void TransferColorDataToWindow();
};
@ -134,10 +134,10 @@ void DIALOG_3D_VIEW_OPTIONS::OnLightsResetToDefaults( wxCommandEvent& event )
m_settings.m_raytrace_lightSphericalCoords[i].y = (float)default_azimuth[i] / 180.0f;
}
TransferLightDataToWindow();
TransferColorDataToWindow();
}
void DIALOG_3D_VIEW_OPTIONS::TransferLightDataToWindow()
void DIALOG_3D_VIEW_OPTIONS::TransferColorDataToWindow()
{
auto Transfer_color = [] ( const SFVEC3F& aSource, wxColourPickerCtrl *aTarget )
{
@ -160,6 +160,8 @@ void DIALOG_3D_VIEW_OPTIONS::TransferLightDataToWindow()
Transfer_color( m_settings.m_raytrace_lightColor[6], m_colourPickerLight7 );
Transfer_color( m_settings.m_raytrace_lightColor[7], m_colourPickerLight8 );
Transfer_color( m_settings.m_opengl_selectionColor, m_colourPickerSelection );
m_spinCtrlLightElevation1->SetValue( (int)( m_settings.m_raytrace_lightSphericalCoords[0].x * 180.0f - 90.0f ) );
m_spinCtrlLightElevation2->SetValue( (int)( m_settings.m_raytrace_lightSphericalCoords[1].x * 180.0f - 90.0f ) );
m_spinCtrlLightElevation3->SetValue( (int)( m_settings.m_raytrace_lightSphericalCoords[2].x * 180.0f - 90.0f ) );
@ -229,7 +231,7 @@ bool DIALOG_3D_VIEW_OPTIONS::TransferDataToWindow()
m_spinCtrlRecursiveLevel_Reflections->SetValue( m_settings.m_raytrace_recursivelevel_reflections );
m_spinCtrlRecursiveLevel_Refractions->SetValue( m_settings.m_raytrace_recursivelevel_refractions );
TransferLightDataToWindow();
TransferColorDataToWindow();
// Camera Options
m_checkBoxEnableAnimation->SetValue( m_canvas->AnimationEnabledGet() );
@ -320,6 +322,8 @@ bool DIALOG_3D_VIEW_OPTIONS::TransferDataFromWindow()
Transfer_color( m_settings.m_raytrace_lightColor[6], m_colourPickerLight7 );
Transfer_color( m_settings.m_raytrace_lightColor[7], m_colourPickerLight8 );
Transfer_color( m_settings.m_opengl_selectionColor, m_colourPickerSelection );
m_settings.m_raytrace_lightSphericalCoords[0].x = ( m_spinCtrlLightElevation1->GetValue() + 90.0f ) / 180.0f;
m_settings.m_raytrace_lightSphericalCoords[1].x = ( m_spinCtrlLightElevation2->GetValue() + 90.0f ) / 180.0f;
m_settings.m_raytrace_lightSphericalCoords[2].x = ( m_spinCtrlLightElevation3->GetValue() + 90.0f ) / 180.0f;

View File

@ -319,30 +319,44 @@ DIALOG_3D_VIEW_OPTIONS_BASE::DIALOG_3D_VIEW_OPTIONS_BASE( wxWindow* parent, wxWi
bSizer7->Add( sbSizerOpenGLRenderoptions, 1, wxALL|wxEXPAND, 5 );
wxStaticBoxSizer* sbSizerAntialiasing;
sbSizerAntialiasing = new wxStaticBoxSizer( new wxStaticBox( m_panelOpenGL, wxID_ANY, _("Anti-aliasing") ), wxVERTICAL );
wxStaticBoxSizer* sbSizerOtherOptions;
sbSizerOtherOptions = new wxStaticBoxSizer( new wxStaticBox( m_panelOpenGL, wxID_ANY, _("Other Options") ), wxVERTICAL );
wxFlexGridSizer* fgSizer7;
fgSizer7 = new wxFlexGridSizer( 1, 2, 0, 0 );
fgSizer7 = new wxFlexGridSizer( 2, 3, 0, 0 );
fgSizer7->SetFlexibleDirection( wxBOTH );
fgSizer7->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
fgSizer7->Add( 0, 0, 1, wxLEFT|wxRIGHT, 5 );
m_staticText221 = new wxStaticText( sbSizerOtherOptions->GetStaticBox(), wxID_ANY, _("Anti-aliasing"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText221->Wrap( -1 );
fgSizer7->Add( m_staticText221, 0, wxALL, 5 );
wxString m_choiceAntiAliasingChoices[] = { _("Disabled"), _("2x"), _("4x"), _("8x"), wxEmptyString };
int m_choiceAntiAliasingNChoices = sizeof( m_choiceAntiAliasingChoices ) / sizeof( wxString );
m_choiceAntiAliasing = new wxChoice( sbSizerAntialiasing->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, m_choiceAntiAliasingNChoices, m_choiceAntiAliasingChoices, 0 );
m_choiceAntiAliasing = new wxChoice( sbSizerOtherOptions->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, m_choiceAntiAliasingNChoices, m_choiceAntiAliasingChoices, 0 );
m_choiceAntiAliasing->SetSelection( 0 );
m_choiceAntiAliasing->SetToolTip( _("3D-Viewer must be closed and re-opened to apply this setting") );
fgSizer7->Add( m_choiceAntiAliasing, 0, 0, 5 );
fgSizer7->Add( m_choiceAntiAliasing, 0, wxALL|wxEXPAND, 5 );
sbSizerAntialiasing->Add( fgSizer7, 1, wxALL|wxEXPAND, 5 );
fgSizer7->Add( 0, 0, 1, wxEXPAND, 5 );
m_staticText231 = new wxStaticText( sbSizerOtherOptions->GetStaticBox(), wxID_ANY, _("Selection color"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText231->Wrap( -1 );
fgSizer7->Add( m_staticText231, 0, wxALL, 5 );
m_colourPickerSelection = new wxColourPickerCtrl( sbSizerOtherOptions->GetStaticBox(), wxID_ANY, *wxBLACK, wxDefaultPosition, wxDefaultSize, wxCLRP_DEFAULT_STYLE );
fgSizer7->Add( m_colourPickerSelection, 0, wxALL|wxEXPAND, 5 );
bSizer7->Add( sbSizerAntialiasing, 1, wxALL|wxEXPAND, 5 );
sbSizerOtherOptions->Add( fgSizer7, 1, wxALL|wxEXPAND, 5 );
bSizer7->Add( sbSizerOtherOptions, 1, wxALL|wxEXPAND, 5 );
wxStaticBoxSizer* sbSizerWhileMoving;
sbSizerWhileMoving = new wxStaticBoxSizer( new wxStaticBox( m_panelOpenGL, wxID_ANY, _("While Moving") ), wxVERTICAL );

View File

@ -3157,24 +3157,24 @@
</object>
</object>
</object>
<object class="sizeritem" expanded="0">
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL|wxEXPAND</property>
<property name="proportion">1</property>
<object class="wxStaticBoxSizer" expanded="0">
<object class="wxStaticBoxSizer" expanded="1">
<property name="id">wxID_ANY</property>
<property name="label">Anti-aliasing</property>
<property name="label">Other Options</property>
<property name="minimum_size"></property>
<property name="name">sbSizerAntialiasing</property>
<property name="name">sbSizerOtherOptions</property>
<property name="orient">wxVERTICAL</property>
<property name="parent">1</property>
<property name="permission">none</property>
<object class="sizeritem" expanded="0">
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL|wxEXPAND</property>
<property name="proportion">1</property>
<object class="wxFlexGridSizer" expanded="0">
<property name="cols">2</property>
<object class="wxFlexGridSizer" expanded="1">
<property name="cols">3</property>
<property name="flexible_direction">wxBOTH</property>
<property name="growablecols"></property>
<property name="growablerows"></property>
@ -3183,7 +3183,7 @@
<property name="name">fgSizer7</property>
<property name="non_flexible_grow_mode">wxFLEX_GROWMODE_SPECIFIED</property>
<property name="permission">none</property>
<property name="rows">1</property>
<property name="rows">2</property>
<property name="vgap">0</property>
<object class="sizeritem" expanded="0">
<property name="border">5</property>
@ -3195,9 +3195,70 @@
<property name="width">0</property>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL</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">Anti-aliasing</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_staticText221</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="0">
<property name="border">5</property>
<property name="flag"></property>
<property name="flag">wxALL|wxEXPAND</property>
<property name="proportion">0</property>
<object class="wxChoice" expanded="0">
<property name="BottomDockable">1</property>
@ -3259,6 +3320,140 @@
<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">1</property>
<object class="spacer" expanded="1">
<property name="height">0</property>
<property name="permission">protected</property>
<property name="width">0</property>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL</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">Selection color</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_staticText231</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|wxEXPAND</property>
<property name="proportion">0</property>
<object class="wxColourPickerCtrl" 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="colour"></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_colourPickerSelection</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">wxCLRP_DEFAULT_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

@ -89,7 +89,10 @@ class DIALOG_3D_VIEW_OPTIONS_BASE : public DIALOG_SHIM
wxCheckBox* m_checkBoxBoundingBoxes;
wxStaticBitmap* m_bitmapCuThickness;
wxCheckBox* m_checkBoxCuThickness;
wxStaticText* m_staticText221;
wxChoice* m_choiceAntiAliasing;
wxStaticText* m_staticText231;
wxColourPickerCtrl* m_colourPickerSelection;
wxCheckBox* m_checkBoxDisableAAMove;
wxCheckBox* m_checkBoxDisableMoveThickness;
wxCheckBox* m_checkBoxDisableMoveVias;

View File

@ -539,6 +539,8 @@ void EDA_3D_VIEWER::LoadSettings( APP_SETTINGS_BASE *aCfg )
m_boardAdapter.GridSet( static_cast<GRID3D_TYPE>( cfg->m_Render.grid_type ) );
m_boardAdapter.AntiAliasingSet( static_cast<ANTIALIASING_MODE>( cfg->m_Render.opengl_AA_mode ) );
m_boardAdapter.m_opengl_selectionColor = m_boardAdapter.GetColor( cfg->m_Render.opengl_selection_color );
m_boardAdapter.m_raytrace_nrsamples_shadows = cfg->m_Render.raytrace_nrsamples_shadows;
m_boardAdapter.m_raytrace_nrsamples_reflections = cfg->m_Render.raytrace_nrsamples_reflections;
m_boardAdapter.m_raytrace_nrsamples_refractions = cfg->m_Render.raytrace_nrsamples_refractions;
@ -657,6 +659,8 @@ void EDA_3D_VIEWER::SaveSettings( APP_SETTINGS_BASE *aCfg )
cfg->m_Render.material_mode = static_cast<int>( m_boardAdapter.MaterialModeGet() );
cfg->m_Render.opengl_AA_mode = static_cast<int>( m_boardAdapter.AntiAliasingGet() );
save_color( m_boardAdapter.m_opengl_selectionColor, cfg->m_Render.opengl_selection_color );
cfg->m_Camera.animation_enabled = m_canvas->AnimationEnabledGet();
cfg->m_Camera.moving_speed_multiplier = m_canvas->MovingSpeedMultiplierGet();