paysages : Preetham approximation for sky (WIP) - Added input fields visibility condition.

git-svn-id: https://subversion.assembla.com/svn/thunderk/paysages@358 b1fd45b6-86a6-48da-8261-f70d1f35bdcc
This commit is contained in:
Michaël Lemaire 2012-06-23 22:11:25 +00:00 committed by ThunderK
parent 323dc8122c
commit 197c7f53e8
7 changed files with 111 additions and 56 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
=> 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)
=> Apply model to atmosphere (aerial perspective) => Apply model to atmosphere (aerial perspective)

View file

@ -116,6 +116,12 @@ void BaseForm::configChangeEvent()
button_revert->setEnabled(true); button_revert->setEnabled(true);
} }
QList<BaseInput*> inputs = form->findChildren<BaseInput*>("_form_input_");
for (int i = 0; i < inputs.size(); i++)
{
inputs[i]->checkVisibility();
}
QList<BasePreview*> list_previews = previews->findChildren<BasePreview*>("_form_preview_"); QList<BasePreview*> list_previews = previews->findChildren<BasePreview*>("_form_preview_");
for (int i = 0; i < list_previews.size(); i++) for (int i = 0; i < list_previews.size(); i++)
{ {
@ -199,7 +205,7 @@ QPushButton* BaseForm::addButton(QString label)
return button; return button;
} }
void BaseForm::addInput(BaseInput* input) BaseInput* BaseForm::addInput(BaseInput* input)
{ {
int row_height = 30; int row_height = 30;
@ -223,51 +229,53 @@ void BaseForm::addInput(BaseInput* input)
input->setObjectName("_form_input_"); input->setObjectName("_form_input_");
input->revert(); 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() int BaseForm::currentLayer()

View file

@ -37,16 +37,16 @@ private slots:
protected: protected:
void addPreview(BasePreview* preview, QString label); void addPreview(BasePreview* preview, QString label);
QPushButton* addButton(QString label); QPushButton* addButton(QString label);
void addInput(BaseInput* input); BaseInput* addInput(BaseInput* input);
void addInputInt(QString label, int* value, int min, int max, int small_step, int large_step); BaseInput* 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); BaseInput* addInputDouble(QString label, double* value, double min, double max, double small_step, double large_step);
void addInputBoolean(QString label, int* value); BaseInput* addInputBoolean(QString label, int* value);
void addInputColor(QString label, Color* value); BaseInput* addInputColor(QString label, Color* value);
void addInputColorGradation(QString label, ColorGradation* value); BaseInput* addInputColorGradation(QString label, ColorGradation* value);
void addInputNoise(QString label, NoiseGenerator* value); BaseInput* addInputNoise(QString label, NoiseGenerator* value);
void addInputCurve(QString label, Curve* value, double xmin, double xmax, double ymin, double ymax); BaseInput* addInputCurve(QString label, Curve* value, double xmin, double xmax, double ymin, double ymax);
void addInputMaterial(QString label, SurfaceMaterial* material); BaseInput* addInputMaterial(QString label, SurfaceMaterial* material);
void addInputEnum(QString label, int* value, const QStringList& values); BaseInput* addInputEnum(QString label, int* value, const QStringList& values);
int currentLayer(); int currentLayer();
void setLayerCount(int layer_count); void setLayerCount(int layer_count);

View file

@ -7,6 +7,15 @@ BaseInput::BaseInput(QWidget* form, QString label):
_label->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); _label->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
_label->setWordWrap(true); _label->setWordWrap(true);
_visibility_value = NULL;
_visible = true;
}
void BaseInput::setVisibilityCondition(int* value, int condition)
{
_visibility_value = value;
_visibility_condition = condition;
} }
void BaseInput::updatePreview() void BaseInput::updatePreview()
@ -23,3 +32,29 @@ void BaseInput::revert()
{ {
updatePreview(); 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();
}
}
}

View file

@ -13,11 +13,13 @@ public:
inline QWidget* label() {return _label;} inline QWidget* label() {return _label;}
inline QWidget* preview() {return _preview;} inline QWidget* preview() {return _preview;}
inline QWidget* control() {return _control;} inline QWidget* control() {return _control;}
void setVisibilityCondition(int* value, int condition);
public slots: public slots:
virtual void updatePreview(); virtual void updatePreview();
virtual void revert(); virtual void revert();
virtual void applyValue(); virtual void applyValue();
void checkVisibility();
signals: signals:
void valueChanged(); void valueChanged();
@ -26,6 +28,9 @@ protected:
QLabel* _label; QLabel* _label;
QWidget* _preview; QWidget* _preview;
QWidget* _control; QWidget* _control;
int* _visibility_value;
int _visibility_condition;
bool _visible;
}; };
#endif #endif

View file

@ -97,6 +97,8 @@ private:
FormSky::FormSky(QWidget *parent): FormSky::FormSky(QWidget *parent):
BaseForm(parent) BaseForm(parent)
{ {
BaseInput* input;
_definition = skyCreateDefinition(); _definition = skyCreateDefinition();
previewWest = new PreviewSkyWest(this); 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 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); 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); 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); input = addInputBoolean(tr("Auto colors from daytime"), &_definition.model_custom.auto_from_daytime);
addInputColor(tr("Zenith color"), &_definition.model_custom.zenith_color); input->setVisibilityCondition((int*)&_definition.model, SKY_MODEL_CUSTOM);
addInputColor(tr("Haze color"), &_definition.model_custom.haze_color); input = addInputColor(tr("Zenith color"), &_definition.model_custom.zenith_color);
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);
addInputDouble(tr("Haze smoothing"), &_definition.model_custom.haze_smoothing, 0.0, 1.0, 0.01, 0.1); input = addInputColor(tr("Haze color"), &_definition.model_custom.haze_color);
addInputDouble(tr("Turbidity"), &_definition.model_preetham.turbidity, 1.8, 6.0, 0.05, 0.5); 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(); revertConfig();
} }

View file

@ -29,7 +29,7 @@
<translation>Annuler les modifications</translation> <translation>Annuler les modifications</translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/baseform.cpp" line="296"/> <location filename="../gui_qt/baseform.cpp" line="304"/>
<source>Layer %1</source> <source>Layer %1</source>
<translation>Niveau %1</translation> <translation>Niveau %1</translation>
</message> </message>
@ -592,82 +592,82 @@ Maintenir Ctrl : Plus rapide</translation>
<context> <context>
<name>FormSky</name> <name>FormSky</name>
<message> <message>
<location filename="../gui_qt/formsky.cpp" line="103"/> <location filename="../gui_qt/formsky.cpp" line="105"/>
<source>West preview</source> <source>West preview</source>
<translation>Aperçu de l&apos;ouest</translation> <translation>Aperçu de l&apos;ouest</translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/formsky.cpp" line="105"/> <location filename="../gui_qt/formsky.cpp" line="107"/>
<source>East preview</source> <source>East preview</source>
<translation>Aperçu de l&apos;est</translation> <translation>Aperçu de l&apos;est</translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/formsky.cpp" line="107"/> <location filename="../gui_qt/formsky.cpp" line="109"/>
<source>Color model</source> <source>Color model</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/formsky.cpp" line="107"/> <location filename="../gui_qt/formsky.cpp" line="109"/>
<source>Mixed Preetham/Shirley approximation</source> <source>Mixed Preetham/Shirley approximation</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/formsky.cpp" line="107"/> <location filename="../gui_qt/formsky.cpp" line="109"/>
<source>Custom model</source> <source>Custom model</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/formsky.cpp" line="108"/> <location filename="../gui_qt/formsky.cpp" line="110"/>
<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="109"/> <location filename="../gui_qt/formsky.cpp" line="111"/>
<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="110"/> <location filename="../gui_qt/formsky.cpp" line="112"/>
<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="111"/> <location filename="../gui_qt/formsky.cpp" line="113"/>
<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="112"/> <location filename="../gui_qt/formsky.cpp" line="114"/>
<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="113"/> <location filename="../gui_qt/formsky.cpp" line="125"/>
<source>Auto from daytime</source>
<translation type="unfinished"></translation>
</message>
<message>
<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="114"/> <location filename="../gui_qt/formsky.cpp" line="117"/>
<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="115"/> <location filename="../gui_qt/formsky.cpp" line="115"/>
<source>Auto colors from daytime</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../gui_qt/formsky.cpp" line="119"/>
<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="116"/> <location filename="../gui_qt/formsky.cpp" line="121"/>
<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="117"/> <location filename="../gui_qt/formsky.cpp" line="123"/>
<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>