CalcMySky  v0.3.1
ToolsWidget.hpp
1 #ifndef INCLUDE_ONCE_5D7304A4_A588_478B_B21C_55EA5C4F88C0
2 #define INCLUDE_ONCE_5D7304A4_A588_478B_B21C_55EA5C4F88C0
3 
4 #include <QProgressBar>
5 #include <QDockWidget>
6 #include <QPushButton>
7 #include <QComboBox>
8 #include <QCheckBox>
9 #include "Manipulator.hpp"
10 #include "RadiancePlot.hpp"
11 #include "GLWidget.hpp"
12 #include "api/ShowMySky/Settings.hpp"
13 
14 class QCheckBox;
15 
16 class ToolsWidget : public QDockWidget, public ShowMySky::Settings
17 {
18  Q_OBJECT
19 
20  static constexpr double degree=M_PI/180;
21 
22  QVBoxLayout* scattererCheckboxes_=new QVBoxLayout;
23  QComboBox* ditheringMode_=new QComboBox;
24  QComboBox* ditheringMethod_=new QComboBox;
25  QComboBox* solarSpectrumMode_=new QComboBox;
26  QComboBox* projection_=new QComboBox;
27  QComboBox* colorMode_=new QComboBox;
28  QDoubleSpinBox* solarSpectrumTemperature_=new QDoubleSpinBox;
29  Manipulator* altitude_=nullptr;
30  Manipulator* exposure_=nullptr;
31  Manipulator* sunElevation_=nullptr;
32  Manipulator* sunAzimuth_=nullptr;
33  Manipulator* sunAngularRadius_=nullptr;
34  Manipulator* moonElevation_=nullptr;
35  Manipulator* moonAzimuth_=nullptr;
36  Manipulator* earthMoonDistance_=nullptr;
37  Manipulator* zoomFactor_=nullptr;
38  Manipulator* cameraPitch_=nullptr;
39  Manipulator* cameraYaw_=nullptr;
40  Manipulator* lightPollutionGroundLuminance_=nullptr;
41  QCheckBox* onTheFlySingleScatteringEnabled_=nullptr;
42  QCheckBox* onTheFlyPrecompDoubleScatteringEnabled_=nullptr;
43  QCheckBox* zeroOrderScatteringEnabled_=nullptr;
44  QCheckBox* singleScatteringEnabled_=nullptr;
45  QCheckBox* multipleScatteringEnabled_=nullptr;
46  QCheckBox* textureFilteringEnabled_=nullptr;
47  QCheckBox* usingEclipseShader_=nullptr;
48  QCheckBox* pseudoMirrorEnabled_=nullptr;
49  QCheckBox* gradualClippingEnabled_=nullptr;
50  QCheckBox* glareEnabled_=nullptr;
51  QPushButton* showRadiancePlot_=nullptr;
52  std::unique_ptr<QWidget> radiancePlotWindow_;
53  RadiancePlot* radiancePlot_=nullptr;
54  QCheckBox* windowDecorationEnabled_=nullptr;
55  QVector<QCheckBox*> scatterers;
56 public:
57  ToolsWidget(QWidget* parent=nullptr);
58 
59  double altitude() override { return altitude_->value(); }
60  double sunAzimuth() override { return degree*sunAzimuth_->value(); }
61  double sunZenithAngle() override { return degree*(90-sunElevation_->value()); }
62  double sunAngularRadius() override { return degree*sunAngularRadius_->value(); }
63  double moonAzimuth() override { return degree*moonAzimuth_->value(); }
64  double moonZenithAngle() override { return degree*(90-moonElevation_->value()); }
65  double earthMoonDistance() override { return 1000*earthMoonDistance_->value(); }
66  float zoomFactor() const { return zoomFactor_->value(); }
67  float cameraYaw() const { return degree*cameraYaw_->value(); }
68  float cameraPitch() const { return degree*cameraPitch_->value(); }
69  double lightPollutionGroundLuminance() override { return lightPollutionGroundLuminance_->value(); }
70  bool onTheFlySingleScatteringEnabled() override { return onTheFlySingleScatteringEnabled_->isChecked(); }
71  bool onTheFlyPrecompDoubleScatteringEnabled() override { return onTheFlyPrecompDoubleScatteringEnabled_->isChecked(); }
72  bool zeroOrderScatteringEnabled() override { return zeroOrderScatteringEnabled_->isChecked(); }
73  bool singleScatteringEnabled() override { return singleScatteringEnabled_->isChecked(); }
74  bool multipleScatteringEnabled() override { return multipleScatteringEnabled_->isChecked(); }
75  bool textureFilteringEnabled() override { return textureFilteringEnabled_->isChecked(); }
76  bool usingEclipseShader() override { return usingEclipseShader_->isChecked(); }
77  bool pseudoMirrorEnabled() override { return pseudoMirrorEnabled_->isChecked(); }
78  bool gradualClippingEnabled() const { return gradualClippingEnabled_->isChecked(); }
79  bool glareEnabled() const { return glareEnabled_->isChecked(); }
80  float exposure() const { return std::pow(10., exposure_->value()); }
81  GLWidget::DitheringMode ditheringMode() const { return static_cast<GLWidget::DitheringMode>(ditheringMode_->currentIndex()); }
82  GLWidget::DitheringMethod ditheringMethod() const { return static_cast<GLWidget::DitheringMethod>(ditheringMethod_->currentIndex()); }
83 
84  bool handleSpectralRadiance(ShowMySky::AtmosphereRenderer::SpectralRadiance const& spectrum);
85  void setCanGrabRadiance(bool can);
86  void setCanSetSolarSpectrum(bool can);
87  void setZoomFactor(double zoom);
88  void setCameraPitch(double pitch);
89  void setCameraYaw(double yaw);
90  void setSunAzimuth(double azimuth);
91  void setSunZenithAngle(double elevation);
92  void updateParameters(AtmosphereParameters const& params);
93  void setWindowDecorationEnabled(bool enabled);
94 
95 private:
96  void showRadiancePlot();
97  void onSolarSpectrumChanged();
98 
99 signals:
100  void settingChanged();
101  void ditheringMethodChanged();
102  void setScattererEnabled(QString const& name, bool enable);
103  void reloadShadersClicked();
104  void setFlatSolarSpectrum();
105  void resetSolarSpectrum();
106  void setBlackBodySolarSpectrum(double temperature);
107  void windowDecorationToggled(bool enabled);
108  void projectionChanged(GLWidget::Projection);
109  void colorModeChanged(GLWidget::ColorMode);
110 };
111 
112 #endif
double moonAzimuth() override
Azimuth of the Moon.
Definition: ToolsWidget.hpp:63
Definition: ToolsWidget.hpp:16
bool onTheFlySingleScatteringEnabled() override
Whether single scattering should be computed on the fly.
Definition: ToolsWidget.hpp:70
Scene settings for AtmosphereRenderer.
Definition: Settings.hpp:9
Definition: AtmosphereParameters.hpp:10
bool usingEclipseShader() override
Whether to use shader designed to render eclipse atmosphere.
Definition: ToolsWidget.hpp:76
double lightPollutionGroundLuminance() override
Ground luminance for light pollution.
Definition: ToolsWidget.hpp:69
bool zeroOrderScatteringEnabled() override
Whether to render zero-order scattering.
Definition: ToolsWidget.hpp:72
bool singleScatteringEnabled() override
Whether to render single scattering.
Definition: ToolsWidget.hpp:73
double sunAngularRadius() override
Angular radius of the Sun.
Definition: ToolsWidget.hpp:62
double moonZenithAngle() override
Zenith angle of the Moon.
Definition: ToolsWidget.hpp:64
bool textureFilteringEnabled() override
Whether to enable texture filtering.
Definition: ToolsWidget.hpp:75
double sunZenithAngle() override
Zenith angle of the Sun.
Definition: ToolsWidget.hpp:61
bool pseudoMirrorEnabled() override
Whether to mirror the sky instead of rendering the ground.
Definition: ToolsWidget.hpp:77
DitheringMode
Definition: GLWidget.hpp:57
Definition: Manipulator.hpp:10
bool multipleScatteringEnabled() override
Whether to render multiple scattering.
Definition: ToolsWidget.hpp:74
Definition: RadiancePlot.hpp:10
DitheringMethod
Definition: GLWidget.hpp:64
double earthMoonDistance() override
Distance between the Earth and the Moon.
Definition: ToolsWidget.hpp:65
double altitude() override
Camera altitude.
Definition: ToolsWidget.hpp:59
Spectral radiance of a pixel.
Definition: AtmosphereRenderer.hpp:40
bool onTheFlyPrecompDoubleScatteringEnabled() override
Whether double scattering should be precomputed on the fly when using eclipse shader.
Definition: ToolsWidget.hpp:71
double sunAzimuth() override
Azimuth of the Sun.
Definition: ToolsWidget.hpp:60