MeshLib
 
Loading...
Searching...
No Matches
MRViewerSettingsPlugin.h
Go to the documentation of this file.
1#pragma once
2
7#include "MRMesh/MRVector4.h"
8#include "MRCommonPlugins/exports.h"
9
10namespace MR
11{
12
13class MRVIEWER_CLASS ViewerSettingsPlugin : public StatePlugin
14{
15public:
16
17 enum class TabType
18 {
19 Quick,
20 Application,
21 Control,
23 MeasurementUnits,
24 Features,
25 Count
26 };
27
29
30 virtual const std::string& uiName() const override;
31
32 virtual void drawDialog( float menuScaling, ImGuiContext* ctx ) override;
33
34 virtual bool blocking() const override { return false; }
35
36 // call this function if you save/delete color theme, or change current theme outside of this plugin
37 MRVIEWER_API void updateThemes();
38
39 // basic class of external settings
41 {
42 public:
43 virtual ~ExternalSettings() {}
44 // returns the name of the setting, which is a unique value
45 virtual const std::string& getName() const = 0;
46 // the function of drawing the configuration UI
47 virtual void draw( float menuScaling ) = 0;
48 // restore the settings to their default values
49 virtual void reset() {}
50 // if not overriden this setting will be drawn in tools block
51 virtual const char* separatorName() const { return "Tools"; }
52 };
53
55 MRVIEWER_API void addComboSettings( const TabType tab, std::shared_ptr<ExternalSettings> settings );
56
58 MRVIEWER_API void delComboSettings( const TabType tab, const ExternalSettings * settings );
59
62 MRVIEWER_API static ViewerSettingsPlugin* instance();
63
65 MRVIEWER_API void setActiveTab( TabType tab );
66private:
67 virtual bool onEnable_() override;
68 virtual bool onDisable_() override;
69
70 void drawTab_( float menuWidth, float menuScaling );
71
72 void drawQuickTab_( float menuWidth, float menuScaling );
73 void drawApplicationTab_( float menuWidth, float menuScaling );
74 void drawControlTab_( float menuWidth, float menuScaling );
75 void drawViewportTab_( float menuWidth, float menuScaling );
76 void drawMeasurementUnitsTab_( float menuScaling );
77 void drawFeaturesTab_( float menuScaling );
78
79 void drawThemeSelector_( float menuScaling );
80 void drawResetDialog_( bool activated, float menuScaling );
81 void drawShadingModeCombo_( bool inGroup, float menuScaling, float toolWidth );
82 void drawProjectionModeSelector_( float menuScaling, float toolWidth );
83 void drawUpDirectionSelector_();
84 void drawBackgroundButton_( bool allViewports );
85 void drawRenderOptions_( float menuScaling );
86 void drawShadowsOptions_( float menuWidth, float menuScaling );
87 void drawMouseSceneControlsSettings_( float menuWidth, float menuScaling );
88 void drawSpaceMouseSettings_( float menuWidth, float menuScaling );
89 void drawTouchpadSettings_( float menuScaling );
90
91 void drawGlobalSettings_( float buttonWidth, float menuScaling );
92 void drawCustomSettings_( const std::string& separatorName, bool needSeparator, float menuScaling );
93 void drawSeparator_( const std::string& separatorName, float menuScaling );
94
95
96 void updateDialog_();
97 void resetSettings_();
98
99 int curSamples_{ 0 };
100 int storedSamples_{ 0 };
101 int maxSamples_{ 0 };
102 bool needReset_{ false };
103#ifndef __EMSCRIPTEN__
104 bool gpuOverridesMSAA_{ false };
105#endif
106
107 Vector4f backgroundColor_;
108
109 int selectedUserPreset_{ 0 };
110 std::vector<std::string> userThemesPresets_;
111
112 std::unique_ptr<ShadowsGL> shadowGl_;
113
114 SpaceMouseParameters spaceMouseParams_;
115#if defined(_WIN32) || defined(__APPLE__)
116 bool activeMouseScrollZoom_{ false };
117#endif
118
119 TouchpadParameters touchpadParameters_;
120
121 TabType activeTab_ = TabType::Quick;
122 TabType orderedTab_ = TabType::Count; // invalid
123
124 std::array<std::vector<std::shared_ptr<ExternalSettings>>, size_t(TabType::Count)> comboSettings_;
125};
126
127}
Definition MRViewerFwd.h:60
Definition MRViewerSettingsPlugin.h:41
virtual const std::string & getName() const =0
virtual void reset()
Definition MRViewerSettingsPlugin.h:49
virtual void draw(float menuScaling)=0
virtual ~ExternalSettings()
Definition MRViewerSettingsPlugin.h:43
virtual const char * separatorName() const
Definition MRViewerSettingsPlugin.h:51
Definition MRViewerSettingsPlugin.h:14
MRVIEWER_API void delComboSettings(const TabType tab, const ExternalSettings *settings)
delete external settings with UI combo box
MRVIEWER_API void setActiveTab(TabType tab)
changes active tab
virtual void drawDialog(float menuScaling, ImGuiContext *ctx) override
virtual bool blocking() const override
Definition MRViewerSettingsPlugin.h:34
MRVIEWER_API void addComboSettings(const TabType tab, std::shared_ptr< ExternalSettings > settings)
add external settings with UI combo box
MRVIEWER_API void updateThemes()
static MRVIEWER_API ViewerSettingsPlugin * instance()
virtual const std::string & uiName() const override
TabType
Definition MRViewerSettingsPlugin.h:18
Definition MRViewport.h:49
Definition MRCameraOrientationPlugin.h:8