paysages : Preetham approximation for sky (WIP) - Added InputEnum.

git-svn-id: https://subversion.assembla.com/svn/thunderk/paysages@357 b1fd45b6-86a6-48da-8261-f70d1f35bdcc
This commit is contained in:
Michaël Lemaire 2012-06-23 21:47:12 +00:00 committed by ThunderK
parent 4a6d9bb001
commit 323dc8122c
9 changed files with 93 additions and 19 deletions

1
TODO
View file

@ -1,6 +1,5 @@
Technology Preview 2 : Technology Preview 2 :
- Finalize Preetham's model usage - Finalize Preetham's model usage
=> Add enumarate to choose model in formsky
=> Hide fields based on chosen model => Hide fields based on chosen model
=> Update all fields when "auto from daytime" is selected => Update all fields when "auto from daytime" is selected
=> Apply the skydome lighting by directly sampling it (no more amplitude in lights) => Apply the skydome lighting by directly sampling it (no more amplitude in lights)

View file

@ -8,6 +8,7 @@
#include "inputnoise.h" #include "inputnoise.h"
#include "inputcurve.h" #include "inputcurve.h"
#include "inputmaterial.h" #include "inputmaterial.h"
#include "inputenum.h"
#include <QVBoxLayout> #include <QVBoxLayout>
#include <QHBoxLayout> #include <QHBoxLayout>
@ -264,6 +265,11 @@ void BaseForm::addInputMaterial(QString label, SurfaceMaterial* material)
addInput(new InputMaterial(form, label, 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() int BaseForm::currentLayer()
{ {
if (with_layers) if (with_layers)

View file

@ -46,6 +46,7 @@ protected:
void addInputNoise(QString label, NoiseGenerator* value); void addInputNoise(QString label, NoiseGenerator* value);
void addInputCurve(QString label, Curve* value, double xmin, double xmax, double ymin, double ymax); void addInputCurve(QString label, Curve* value, double xmin, double xmax, double ymin, double ymax);
void addInputMaterial(QString label, SurfaceMaterial* material); void addInputMaterial(QString label, SurfaceMaterial* material);
void addInputEnum(QString label, int* value, const QStringList& values);
int currentLayer(); int currentLayer();
void setLayerCount(int layer_count); void setLayerCount(int layer_count);

View file

@ -104,6 +104,7 @@ FormSky::FormSky(QWidget *parent):
previewEast = new PreviewSkyEast(this); previewEast = new PreviewSkyEast(this);
addPreview(previewEast, QString(tr("East preview"))); 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); addInputDouble(tr("Day time"), &_definition.daytime, 0.0, 1.0, 0.002, 0.1);
addInputColor(tr("Sun color"), &_definition.sun_color); addInputColor(tr("Sun color"), &_definition.sun_color);
addInputDouble(tr("Sun radius"), &_definition.sun_radius, 0.0, 0.4, 0.004, 0.04); addInputDouble(tr("Sun radius"), &_definition.sun_radius, 0.0, 0.4, 0.004, 0.04);

29
gui_qt/inputenum.cpp Normal file
View file

@ -0,0 +1,29 @@
#include "inputenum.h"
#include <QLabel>
#include <QComboBox>
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();
}

23
gui_qt/inputenum.h Normal file
View file

@ -0,0 +1,23 @@
#ifndef _PAYSAGES_QT_INPUTENUM_H_
#define _PAYSAGES_QT_INPUTENUM_H_
#include <QWidget>
#include <QStringList>
#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

View file

@ -44,5 +44,5 @@ void InputInt::revert()
{ {
slider->setValue(*value); slider->setValue(*value);
BaseInput::revert(); BaseInput::revert();
} }

View file

@ -26,4 +26,4 @@ private:
int large_step; int large_step;
}; };
#endif // _PAYSAGES_QT_INPUTINT_H_ #endif

View file

@ -4,32 +4,32 @@
<context> <context>
<name>BaseForm</name> <name>BaseForm</name>
<message> <message>
<location filename="../gui_qt/baseform.cpp" line="39"/> <location filename="../gui_qt/baseform.cpp" line="40"/>
<source>Layers : </source> <source>Layers : </source>
<translation>Niveaux :</translation> <translation>Niveaux :</translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/baseform.cpp" line="47"/> <location filename="../gui_qt/baseform.cpp" line="48"/>
<source>Add layer</source> <source>Add layer</source>
<translation>Ajouter un niveau</translation> <translation>Ajouter un niveau</translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/baseform.cpp" line="51"/> <location filename="../gui_qt/baseform.cpp" line="52"/>
<source>Delete layer</source> <source>Delete layer</source>
<translation>Supprimer un niveau</translation> <translation>Supprimer un niveau</translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/baseform.cpp" line="87"/> <location filename="../gui_qt/baseform.cpp" line="88"/>
<source>Apply</source> <source>Apply</source>
<translation>Appliquer</translation> <translation>Appliquer</translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/baseform.cpp" line="90"/> <location filename="../gui_qt/baseform.cpp" line="91"/>
<source>Revert</source> <source>Revert</source>
<translation>Annuler les modifications</translation> <translation>Annuler les modifications</translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/baseform.cpp" line="290"/> <location filename="../gui_qt/baseform.cpp" line="296"/>
<source>Layer %1</source> <source>Layer %1</source>
<translation>Niveau %1</translation> <translation>Niveau %1</translation>
</message> </message>
@ -603,56 +603,71 @@ Maintenir Ctrl : Plus rapide</translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/formsky.cpp" line="107"/> <location filename="../gui_qt/formsky.cpp" line="107"/>
<source>Color model</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../gui_qt/formsky.cpp" line="107"/>
<source>Mixed Preetham/Shirley approximation</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../gui_qt/formsky.cpp" line="107"/>
<source>Custom model</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../gui_qt/formsky.cpp" line="108"/>
<source>Day time</source> <source>Day time</source>
<translation>Heure du jour</translation> <translation>Heure du jour</translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/formsky.cpp" line="108"/> <location filename="../gui_qt/formsky.cpp" line="109"/>
<source>Sun color</source> <source>Sun color</source>
<translation>Couleur du soleil</translation> <translation>Couleur du soleil</translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/formsky.cpp" line="109"/> <location filename="../gui_qt/formsky.cpp" line="110"/>
<source>Sun radius</source> <source>Sun radius</source>
<translation>Diamètre apparent du soleil</translation> <translation>Diamètre apparent du soleil</translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/formsky.cpp" line="110"/> <location filename="../gui_qt/formsky.cpp" line="111"/>
<source>Sun halo radius</source> <source>Sun halo radius</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/formsky.cpp" line="111"/> <location filename="../gui_qt/formsky.cpp" line="112"/>
<source>Sun halo profile</source> <source>Sun halo profile</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/formsky.cpp" line="112"/> <location filename="../gui_qt/formsky.cpp" line="113"/>
<source>Auto from daytime</source> <source>Auto from daytime</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/formsky.cpp" line="117"/> <location filename="../gui_qt/formsky.cpp" line="118"/>
<source>Turbidity</source> <source>Turbidity</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/formsky.cpp" line="113"/> <location filename="../gui_qt/formsky.cpp" line="114"/>
<source>Zenith color</source> <source>Zenith color</source>
<translation>Couleur du ciel au zénith</translation> <translation>Couleur du ciel au zénith</translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/formsky.cpp" line="114"/> <location filename="../gui_qt/formsky.cpp" line="115"/>
<source>Haze color</source> <source>Haze color</source>
<translation>Couleur de la brume</translation> <translation>Couleur de la brume</translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/formsky.cpp" line="115"/> <location filename="../gui_qt/formsky.cpp" line="116"/>
<source>Haze height</source> <source>Haze height</source>
<translation>Hauteur apparente de la brume</translation> <translation>Hauteur apparente de la brume</translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/formsky.cpp" line="116"/> <location filename="../gui_qt/formsky.cpp" line="117"/>
<source>Haze smoothing</source> <source>Haze smoothing</source>
<translation>Facteur de lissage de la brume</translation> <translation>Facteur de lissage de la brume</translation>
</message> </message>