From 323dc8122c3924703c8d08d29f47f4991f970ad9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Lemaire?= Date: Sat, 23 Jun 2012 21:47:12 +0000 Subject: [PATCH] paysages : Preetham approximation for sky (WIP) - Added InputEnum. git-svn-id: https://subversion.assembla.com/svn/thunderk/paysages@357 b1fd45b6-86a6-48da-8261-f70d1f35bdcc --- TODO | 1 - gui_qt/baseform.cpp | 6 ++++++ gui_qt/baseform.h | 1 + gui_qt/formsky.cpp | 1 + gui_qt/inputenum.cpp | 29 +++++++++++++++++++++++++++ gui_qt/inputenum.h | 23 ++++++++++++++++++++++ gui_qt/inputint.cpp | 2 +- gui_qt/inputint.h | 2 +- i18n/paysages_fr.ts | 47 +++++++++++++++++++++++++++++--------------- 9 files changed, 93 insertions(+), 19 deletions(-) create mode 100644 gui_qt/inputenum.cpp create mode 100644 gui_qt/inputenum.h diff --git a/TODO b/TODO index c5f342f..c88d762 100644 --- a/TODO +++ b/TODO @@ -1,6 +1,5 @@ Technology Preview 2 : - Finalize Preetham's model usage - => Add enumarate to choose model in formsky => 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) diff --git a/gui_qt/baseform.cpp b/gui_qt/baseform.cpp index 27c9ac1..439b81b 100644 --- a/gui_qt/baseform.cpp +++ b/gui_qt/baseform.cpp @@ -8,6 +8,7 @@ #include "inputnoise.h" #include "inputcurve.h" #include "inputmaterial.h" +#include "inputenum.h" #include #include @@ -264,6 +265,11 @@ void BaseForm::addInputMaterial(QString label, SurfaceMaterial* material) addInput(new InputMaterial(form, label, material)); } +void BaseForm::addInputEnum(QString label, int* value, const QStringList& values) +{ + addInput(new InputEnum(form, label, value, values)); +} + int BaseForm::currentLayer() { if (with_layers) diff --git a/gui_qt/baseform.h b/gui_qt/baseform.h index 2e01630..d7bb5dc 100644 --- a/gui_qt/baseform.h +++ b/gui_qt/baseform.h @@ -46,6 +46,7 @@ protected: 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); int currentLayer(); void setLayerCount(int layer_count); diff --git a/gui_qt/formsky.cpp b/gui_qt/formsky.cpp index ce1c0fe..0677115 100644 --- a/gui_qt/formsky.cpp +++ b/gui_qt/formsky.cpp @@ -104,6 +104,7 @@ FormSky::FormSky(QWidget *parent): previewEast = new PreviewSkyEast(this); addPreview(previewEast, QString(tr("East preview"))); + addInputEnum(tr("Color model"), (int*)&_definition.model, QStringList(tr("Custom model")) << tr("Mixed Preetham/Shirley approximation")); addInputDouble(tr("Day time"), &_definition.daytime, 0.0, 1.0, 0.002, 0.1); addInputColor(tr("Sun color"), &_definition.sun_color); addInputDouble(tr("Sun radius"), &_definition.sun_radius, 0.0, 0.4, 0.004, 0.04); diff --git a/gui_qt/inputenum.cpp b/gui_qt/inputenum.cpp new file mode 100644 index 0000000..7745881 --- /dev/null +++ b/gui_qt/inputenum.cpp @@ -0,0 +1,29 @@ +#include "inputenum.h" + +#include +#include + +InputEnum::InputEnum(QWidget* form, QString label, int* value, const QStringList& values) : BaseInput(form, label) +{ + _value = value; + + _preview = new QWidget(form); + _control = new QComboBox(form); + ((QComboBox*)_control)->addItems(values); + + connect(_control, SIGNAL(currentIndexChanged(int)), this, SLOT(applyValue())); +} + +void InputEnum::applyValue() +{ + *_value = ((QComboBox*)_control)->currentIndex(); + + BaseInput::applyValue(); +} + +void InputEnum::revert() +{ + ((QComboBox*)_control)->setCurrentIndex(*_value); + + BaseInput::revert(); +} diff --git a/gui_qt/inputenum.h b/gui_qt/inputenum.h new file mode 100644 index 0000000..ef3747f --- /dev/null +++ b/gui_qt/inputenum.h @@ -0,0 +1,23 @@ +#ifndef _PAYSAGES_QT_INPUTENUM_H_ +#define _PAYSAGES_QT_INPUTENUM_H_ + +#include +#include +#include "baseinput.h" + +class InputEnum:public BaseInput +{ + Q_OBJECT + +public: + InputEnum(QWidget* form, QString label, int* value, const QStringList& values); + +public slots: + virtual void applyValue(); + virtual void revert(); + +private: + int* _value; +}; + +#endif diff --git a/gui_qt/inputint.cpp b/gui_qt/inputint.cpp index c6c3939..1e4d883 100644 --- a/gui_qt/inputint.cpp +++ b/gui_qt/inputint.cpp @@ -44,5 +44,5 @@ void InputInt::revert() { slider->setValue(*value); - BaseInput::revert(); + BaseInput::revert(); } diff --git a/gui_qt/inputint.h b/gui_qt/inputint.h index 759c705..7a32a03 100644 --- a/gui_qt/inputint.h +++ b/gui_qt/inputint.h @@ -26,4 +26,4 @@ private: int large_step; }; -#endif // _PAYSAGES_QT_INPUTINT_H_ +#endif diff --git a/i18n/paysages_fr.ts b/i18n/paysages_fr.ts index 77eb55d..0273327 100644 --- a/i18n/paysages_fr.ts +++ b/i18n/paysages_fr.ts @@ -4,32 +4,32 @@ BaseForm - + Layers : Niveaux : - + Add layer Ajouter un niveau - + Delete layer Supprimer un niveau - + Apply Appliquer - + Revert Annuler les modifications - + Layer %1 Niveau %1 @@ -603,56 +603,71 @@ Maintenir Ctrl : Plus rapide + 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 - + Haze color Couleur de la brume - + Haze height Hauteur apparente de la brume - + Haze smoothing Facteur de lissage de la brume