Use enums for 3d Viewer settings instead of ints

This commit is contained in:
Ian McInerney 2021-12-30 23:02:38 +00:00
parent 59a495948e
commit 9e6446a8dc
8 changed files with 58 additions and 51 deletions

View File

@ -41,39 +41,37 @@ enum class ROTATION_DIR
Z_CCW
};
/// Camera types
enum class CAMERA_TYPE
{
TRACKBALL
};
// Do not modify the following enum numbers, they are saved in the config file and used in the UI
/// Grid types
enum GRID3D_TYPE
enum class GRID3D_TYPE
{
NONE,
GRID_1MM,
GRID_2P5MM,
GRID_5MM,
GRID_10MM
NONE = 0,
GRID_1MM = 1,
GRID_2P5MM = 2,
GRID_5MM = 3,
GRID_10MM = 4
};
/// Render engine mode
enum RENDER_ENGINE
enum class RENDER_ENGINE
{
OPENGL,
RAYTRACING,
OPENGL = 0,
RAYTRACING = 1,
};
/// Render 3d model shape materials mode
enum MATERIAL_MODE
enum class MATERIAL_MODE
{
NORMAL, ///< Use all material properties from model file
DIFFUSE_ONLY, ///< Use only diffuse material properties
CAD_MODE ///< Use a gray shading based on diffuse material
NORMAL = 0, ///< Use all material properties from model file
DIFFUSE_ONLY = 1, ///< Use only diffuse material properties
CAD_MODE = 2 ///< Use a gray shading based on diffuse material
};
#endif // _3D_ENUMS_H_

View File

@ -920,8 +920,8 @@ void RENDER_3D_OPENGL::load3dModels( REPORTER* aStatusReporter )
// only add it if the return is not NULL
if( modelPtr )
{
int materialMode = m_boardAdapter.m_Cfg->m_Render.material_mode;
MODEL_3D* model = new MODEL_3D( *modelPtr, (MATERIAL_MODE) materialMode );
MATERIAL_MODE materialMode = m_boardAdapter.m_Cfg->m_Render.material_mode;
MODEL_3D* model = new MODEL_3D( *modelPtr, materialMode );
m_3dModelMap[ fp_model.m_Filename ] = model;
}

View File

@ -346,7 +346,7 @@ void EDA_3D_VIEWER_FRAME::Process_Special_Functions( wxCommandEvent &event )
void EDA_3D_VIEWER_FRAME::OnRenderEngineSelection( wxCommandEvent &event )
{
int old_engine = m_boardAdapter.m_Cfg->m_Render.engine;
RENDER_ENGINE old_engine = m_boardAdapter.m_Cfg->m_Render.engine;
if( old_engine == RENDER_ENGINE::OPENGL )
m_boardAdapter.m_Cfg->m_Render.engine = RENDER_ENGINE::RAYTRACING;

View File

@ -37,25 +37,27 @@ EDA_3D_VIEWER_SETTINGS::EDA_3D_VIEWER_SETTINGS()
m_Render(),
m_Camera()
{
m_params.emplace_back( new PARAM<int>( "render.engine", &m_Render.engine,
static_cast<int>( RENDER_ENGINE::OPENGL ),
static_cast<int>( RENDER_ENGINE::OPENGL ),
static_cast<int>( RENDER_ENGINE::RAYTRACING ) ) );
m_params.emplace_back( new PARAM_ENUM<RENDER_ENGINE>( "render.engine", &m_Render.engine,
RENDER_ENGINE::OPENGL,
RENDER_ENGINE::OPENGL,
RENDER_ENGINE::RAYTRACING ) );
m_params.emplace_back( new PARAM<int>( "render.grid_type", &m_Render.grid_type,
static_cast<int>( GRID3D_TYPE::NONE ),
static_cast<int>( GRID3D_TYPE::NONE ),
static_cast<int>( GRID3D_TYPE::GRID_10MM ) ) );
m_params.emplace_back( new PARAM_ENUM<GRID3D_TYPE>( "render.grid_type", &m_Render.grid_type,
GRID3D_TYPE::NONE,
GRID3D_TYPE::NONE,
GRID3D_TYPE::GRID_10MM ) );
m_params.emplace_back( new PARAM<int>( "render.material_mode", &m_Render.material_mode,
static_cast<int>( MATERIAL_MODE::NORMAL ),
static_cast<int>( MATERIAL_MODE::NORMAL ),
static_cast<int>( MATERIAL_MODE::CAD_MODE ) ) );
m_params.emplace_back( new PARAM_ENUM<MATERIAL_MODE>( "render.material_mode",
&m_Render.material_mode,
MATERIAL_MODE::NORMAL,
MATERIAL_MODE::NORMAL,
MATERIAL_MODE::CAD_MODE ) );
m_params.emplace_back( new PARAM<int>( "render.opengl_AA_mode", &m_Render.opengl_AA_mode,
static_cast<int>( ANTIALIASING_MODE::AA_8X ),
static_cast<int>( ANTIALIASING_MODE::AA_NONE ),
static_cast<int>( ANTIALIASING_MODE::AA_8X ) ) );
m_params.emplace_back( new PARAM_ENUM<ANTIALIASING_MODE>( "render.opengl_AA_mode",
&m_Render.opengl_AA_mode,
ANTIALIASING_MODE::AA_8X,
ANTIALIASING_MODE::AA_NONE,
ANTIALIASING_MODE::AA_8X ) );
m_params.emplace_back( new PARAM<COLOR4D>( "render.opengl_selection_color",
&m_Render.opengl_selection_color,

View File

@ -21,19 +21,23 @@
#ifndef EDA_3D_VIEWER_SETTINGS_H_
#define EDA_3D_VIEWER_SETTINGS_H_
#include <3d_enums.h>
#include <common_ogl/ogl_attr_list.h>
#include <plugins/3dapi/xv3d_types.h>
#include <settings/app_settings.h>
#include <settings/parameters.h>
#include <plugins/3dapi/xv3d_types.h>
class EDA_3D_VIEWER_SETTINGS : public APP_SETTINGS_BASE
{
public:
struct RENDER_SETTINGS
{
int engine;
int grid_type;
int opengl_AA_mode;
int material_mode;
RENDER_ENGINE engine;
GRID3D_TYPE grid_type;
ANTIALIASING_MODE opengl_AA_mode;
MATERIAL_MODE material_mode;
bool opengl_AA_disableOnMove;
bool opengl_thickness_disableOnMove;
bool opengl_vias_disableOnMove;

View File

@ -33,10 +33,11 @@
/// Anti-aliasing options
enum class ANTIALIASING_MODE
{
AA_NONE,
AA_2X,
AA_4X,
AA_8X
// Do not change these numbers, they are stored in the config file
AA_NONE = 0,
AA_2X = 1,
AA_4X = 2,
AA_8X = 3
};
/**

View File

@ -22,6 +22,7 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <3d_enums.h>
#include <pgm_base.h>
#include <settings/settings_manager.h>
#include <eda_3d_viewer_settings.h>
@ -57,7 +58,7 @@ void PANEL_3D_DISPLAY_OPTIONS::loadViewSettings( EDA_3D_VIEWER_SETTINGS* aCfg )
m_checkBoxClipSilkOnViaAnnulus->SetValue( aCfg->m_Render.clip_silk_on_via_annulus );
m_checkBoxRenderPlatedPadsAsPlated->SetValue( aCfg->m_Render.renderPlatedPadsAsPlated );
m_materialProperties->SetSelection( aCfg->m_Render.material_mode );
m_materialProperties->SetSelection( static_cast<int>( aCfg->m_Render.material_mode ) );
// Camera Options
m_checkBoxEnableAnimation->SetValue( aCfg->m_Camera.animation_enabled );
@ -92,7 +93,7 @@ bool PANEL_3D_DISPLAY_OPTIONS::TransferDataFromWindow()
cfg->m_Render.clip_silk_on_via_annulus = m_checkBoxClipSilkOnViaAnnulus->GetValue();
cfg->m_Render.renderPlatedPadsAsPlated = m_checkBoxRenderPlatedPadsAsPlated->GetValue();
cfg->m_Render.material_mode = m_materialProperties->GetSelection();
cfg->m_Render.material_mode = static_cast<MATERIAL_MODE>( m_materialProperties->GetSelection() );
// Set Layer visibility
cfg->m_Render.show_silkscreen = m_checkBoxSilkscreen->GetValue();

View File

@ -22,6 +22,7 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <3d_enums.h>
#include <pgm_base.h>
#include <settings/settings_manager.h>
#include <eda_3d_viewer_settings.h>
@ -43,7 +44,7 @@ void PANEL_3D_OPENGL_OPTIONS::loadSettings( EDA_3D_VIEWER_SETTINGS* aCfg )
m_checkBoxBoundingBoxes->SetValue( aCfg->m_Render.opengl_show_model_bbox );
m_checkBoxHighlightOnRollOver->SetValue( aCfg->m_Render.opengl_highlight_on_rollover );
m_choiceAntiAliasing->SetSelection( aCfg->m_Render.opengl_AA_mode );
m_choiceAntiAliasing->SetSelection( static_cast<int>( aCfg->m_Render.opengl_AA_mode ) );
m_selectionColorSwatch->SetSwatchColor( aCfg->m_Render.opengl_selection_color, false );
m_checkBoxDisableAAMove->SetValue( aCfg->m_Render.opengl_AA_disableOnMove );
@ -71,7 +72,7 @@ bool PANEL_3D_OPENGL_OPTIONS::TransferDataFromWindow()
cfg->m_Render.opengl_show_model_bbox = m_checkBoxBoundingBoxes->GetValue();
cfg->m_Render.opengl_highlight_on_rollover = m_checkBoxHighlightOnRollOver->GetValue();
cfg->m_Render.opengl_AA_mode = m_choiceAntiAliasing->GetSelection();
cfg->m_Render.opengl_AA_mode = static_cast<ANTIALIASING_MODE>( m_choiceAntiAliasing->GetSelection() );
cfg->m_Render.opengl_selection_color = m_selectionColorSwatch->GetSwatchColor();
cfg->m_Render.opengl_AA_disableOnMove = m_checkBoxDisableAAMove->GetValue();