diff --git a/TODO b/TODO index c88d762..ab18220 100644 --- a/TODO +++ b/TODO @@ -1,6 +1,5 @@ Technology Preview 2 : - Finalize Preetham's model usage - => Hide fields based on chosen model => Update all fields when "auto from daytime" is selected => Apply the skydome lighting by directly sampling it (no more amplitude in lights) => Apply model to atmosphere (aerial perspective) diff --git a/gui_qt/baseform.cpp b/gui_qt/baseform.cpp index 439b81b..608c1cc 100644 --- a/gui_qt/baseform.cpp +++ b/gui_qt/baseform.cpp @@ -116,6 +116,12 @@ void BaseForm::configChangeEvent() button_revert->setEnabled(true); } + QList inputs = form->findChildren("_form_input_"); + for (int i = 0; i < inputs.size(); i++) + { + inputs[i]->checkVisibility(); + } + QList list_previews = previews->findChildren("_form_preview_"); for (int i = 0; i < list_previews.size(); i++) { @@ -199,7 +205,7 @@ QPushButton* BaseForm::addButton(QString label) return button; } -void BaseForm::addInput(BaseInput* input) +BaseInput* BaseForm::addInput(BaseInput* input) { int row_height = 30; @@ -223,51 +229,53 @@ void BaseForm::addInput(BaseInput* input) input->setObjectName("_form_input_"); input->revert(); + + return input; } -void BaseForm::addInputInt(QString label, int* value, int min, int max, int small_step, int large_step) +BaseInput* BaseForm::addInputInt(QString label, int* value, int min, int max, int small_step, int large_step) { - addInput(new InputInt(form, label, value, min, max, small_step, large_step)); + return addInput(new InputInt(form, label, value, min, max, small_step, large_step)); } -void BaseForm::addInputDouble(QString label, double* value, double min, double max, double small_step, double large_step) +BaseInput* BaseForm::addInputDouble(QString label, double* value, double min, double max, double small_step, double large_step) { - addInput(new InputDouble(form, label, value, min, max, small_step, large_step)); + return addInput(new InputDouble(form, label, value, min, max, small_step, large_step)); } -void BaseForm::addInputBoolean(QString label, int* value) +BaseInput* BaseForm::addInputBoolean(QString label, int* value) { - addInput(new InputBoolean(form, label, value)); + return addInput(new InputBoolean(form, label, value)); } -void BaseForm::addInputColor(QString label, Color* value) +BaseInput* BaseForm::addInputColor(QString label, Color* value) { - addInput(new InputColor(form, label, value)); + return addInput(new InputColor(form, label, value)); } -void BaseForm::addInputColorGradation(QString label, ColorGradation* value) +BaseInput* BaseForm::addInputColorGradation(QString label, ColorGradation* value) { - addInput(new InputColorGradation(form, label, value)); + return addInput(new InputColorGradation(form, label, value)); } -void BaseForm::addInputNoise(QString label, NoiseGenerator* value) +BaseInput* BaseForm::addInputNoise(QString label, NoiseGenerator* value) { - addInput(new InputNoise(form, label, value)); + return addInput(new InputNoise(form, label, value)); } -void BaseForm::addInputCurve(QString label, Curve* value, double xmin, double xmax, double ymin, double ymax) +BaseInput* BaseForm::addInputCurve(QString label, Curve* value, double xmin, double xmax, double ymin, double ymax) { - addInput(new InputCurve(form, label, value, xmin, xmax, ymin, ymax)); + return addInput(new InputCurve(form, label, value, xmin, xmax, ymin, ymax)); } -void BaseForm::addInputMaterial(QString label, SurfaceMaterial* material) +BaseInput* BaseForm::addInputMaterial(QString label, SurfaceMaterial* material) { - addInput(new InputMaterial(form, label, material)); + return addInput(new InputMaterial(form, label, material)); } -void BaseForm::addInputEnum(QString label, int* value, const QStringList& values) +BaseInput* BaseForm::addInputEnum(QString label, int* value, const QStringList& values) { - addInput(new InputEnum(form, label, value, values)); + return addInput(new InputEnum(form, label, value, values)); } int BaseForm::currentLayer() diff --git a/gui_qt/baseform.h b/gui_qt/baseform.h index d7bb5dc..9f94074 100644 --- a/gui_qt/baseform.h +++ b/gui_qt/baseform.h @@ -37,16 +37,16 @@ private slots: protected: void addPreview(BasePreview* preview, QString label); QPushButton* addButton(QString label); - void addInput(BaseInput* input); - void addInputInt(QString label, int* value, int min, int max, int small_step, int large_step); - void addInputDouble(QString label, double* value, double min, double max, double small_step, double large_step); - void addInputBoolean(QString label, int* value); - void addInputColor(QString label, Color* value); - void addInputColorGradation(QString label, ColorGradation* value); - void addInputNoise(QString label, NoiseGenerator* value); - void addInputCurve(QString label, Curve* value, double xmin, double xmax, double ymin, double ymax); - void addInputMaterial(QString label, SurfaceMaterial* material); - void addInputEnum(QString label, int* value, const QStringList& values); + BaseInput* addInput(BaseInput* input); + BaseInput* addInputInt(QString label, int* value, int min, int max, int small_step, int large_step); + BaseInput* addInputDouble(QString label, double* value, double min, double max, double small_step, double large_step); + BaseInput* addInputBoolean(QString label, int* value); + BaseInput* addInputColor(QString label, Color* value); + BaseInput* addInputColorGradation(QString label, ColorGradation* value); + BaseInput* addInputNoise(QString label, NoiseGenerator* value); + BaseInput* addInputCurve(QString label, Curve* value, double xmin, double xmax, double ymin, double ymax); + BaseInput* addInputMaterial(QString label, SurfaceMaterial* material); + BaseInput* addInputEnum(QString label, int* value, const QStringList& values); int currentLayer(); void setLayerCount(int layer_count); diff --git a/gui_qt/baseinput.cpp b/gui_qt/baseinput.cpp index 85d7a19..b58d238 100644 --- a/gui_qt/baseinput.cpp +++ b/gui_qt/baseinput.cpp @@ -7,6 +7,15 @@ BaseInput::BaseInput(QWidget* form, QString label): _label->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); _label->setWordWrap(true); + + _visibility_value = NULL; + _visible = true; +} + +void BaseInput::setVisibilityCondition(int* value, int condition) +{ + _visibility_value = value; + _visibility_condition = condition; } void BaseInput::updatePreview() @@ -23,3 +32,29 @@ void BaseInput::revert() { updatePreview(); } + +void BaseInput::checkVisibility() +{ + if (!_visibility_value || *_visibility_value == _visibility_condition) + { + if (not _visible) + { + _visible = true; + + _label->show(); + _preview->show(); + _control->show(); + } + } + else + { + if (_visible) + { + _visible = false; + + _label->hide(); + _preview->hide(); + _control->hide(); + } + } +} diff --git a/gui_qt/baseinput.h b/gui_qt/baseinput.h index 16f8eab..3e38e98 100644 --- a/gui_qt/baseinput.h +++ b/gui_qt/baseinput.h @@ -13,11 +13,13 @@ public: inline QWidget* label() {return _label;} inline QWidget* preview() {return _preview;} inline QWidget* control() {return _control;} + void setVisibilityCondition(int* value, int condition); public slots: virtual void updatePreview(); virtual void revert(); virtual void applyValue(); + void checkVisibility(); signals: void valueChanged(); @@ -26,6 +28,9 @@ protected: QLabel* _label; QWidget* _preview; QWidget* _control; + int* _visibility_value; + int _visibility_condition; + bool _visible; }; #endif diff --git a/gui_qt/formsky.cpp b/gui_qt/formsky.cpp index 0677115..c24a148 100644 --- a/gui_qt/formsky.cpp +++ b/gui_qt/formsky.cpp @@ -97,6 +97,8 @@ private: FormSky::FormSky(QWidget *parent): BaseForm(parent) { + BaseInput* input; + _definition = skyCreateDefinition(); previewWest = new PreviewSkyWest(this); @@ -110,12 +112,18 @@ FormSky::FormSky(QWidget *parent): addInputDouble(tr("Sun radius"), &_definition.sun_radius, 0.0, 0.4, 0.004, 0.04); addInputDouble(tr("Sun halo radius"), &_definition.sun_halo_size, 0.0, 0.4, 0.004, 0.04); addInputCurve(tr("Sun halo profile"), _definition.sun_halo_profile, 0.0, 1.0, 0.0, 1.0); - addInputBoolean(tr("Auto from daytime"), &_definition.model_custom.auto_from_daytime); - addInputColor(tr("Zenith color"), &_definition.model_custom.zenith_color); - addInputColor(tr("Haze color"), &_definition.model_custom.haze_color); - addInputDouble(tr("Haze height"), &_definition.model_custom.haze_height, 0.0, 1.0, 0.01, 0.1); - addInputDouble(tr("Haze smoothing"), &_definition.model_custom.haze_smoothing, 0.0, 1.0, 0.01, 0.1); - addInputDouble(tr("Turbidity"), &_definition.model_preetham.turbidity, 1.8, 6.0, 0.05, 0.5); + input = addInputBoolean(tr("Auto colors from daytime"), &_definition.model_custom.auto_from_daytime); + input->setVisibilityCondition((int*)&_definition.model, SKY_MODEL_CUSTOM); + input = addInputColor(tr("Zenith color"), &_definition.model_custom.zenith_color); + input->setVisibilityCondition((int*)&_definition.model, SKY_MODEL_CUSTOM); + input = addInputColor(tr("Haze color"), &_definition.model_custom.haze_color); + input->setVisibilityCondition((int*)&_definition.model, SKY_MODEL_CUSTOM); + input = addInputDouble(tr("Haze height"), &_definition.model_custom.haze_height, 0.0, 1.0, 0.01, 0.1); + input->setVisibilityCondition((int*)&_definition.model, SKY_MODEL_CUSTOM); + input = addInputDouble(tr("Haze smoothing"), &_definition.model_custom.haze_smoothing, 0.0, 1.0, 0.01, 0.1); + input->setVisibilityCondition((int*)&_definition.model, SKY_MODEL_CUSTOM); + input = addInputDouble(tr("Turbidity"), &_definition.model_preetham.turbidity, 1.8, 6.0, 0.05, 0.5); + input->setVisibilityCondition((int*)&_definition.model, SKY_MODEL_PREETHAM); revertConfig(); } diff --git a/i18n/paysages_fr.ts b/i18n/paysages_fr.ts index 0273327..9138f49 100644 --- a/i18n/paysages_fr.ts +++ b/i18n/paysages_fr.ts @@ -29,7 +29,7 @@ Annuler les modifications - + Layer %1 Niveau %1 @@ -592,82 +592,82 @@ Maintenir Ctrl : Plus rapide FormSky - + West preview Aperçu de l'ouest - + East preview Aperçu de l'est - + Color model - + Mixed Preetham/Shirley approximation - + Custom model - + Day time Heure du jour - + Sun color Couleur du soleil - + Sun radius Diamètre apparent du soleil - + Sun halo radius - + Sun halo profile - - Auto from daytime - - - - + Turbidity - + Zenith color Couleur du ciel au zénith + Auto colors from daytime + + + + Haze color Couleur de la brume - + Haze height Hauteur apparente de la brume - + Haze smoothing Facteur de lissage de la brume