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 :
- 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)

View file

@ -116,6 +116,12 @@ void BaseForm::configChangeEvent()
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_");
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()

View file

@ -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);

View file

@ -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();
}
}
}

View file

@ -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

View file

@ -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();
}

View file

@ -29,7 +29,7 @@
<translation>Annuler les modifications</translation>
</message>
<message>
<location filename="../gui_qt/baseform.cpp" line="296"/>
<location filename="../gui_qt/baseform.cpp" line="304"/>
<source>Layer %1</source>
<translation>Niveau %1</translation>
</message>
@ -592,82 +592,82 @@ Maintenir Ctrl : Plus rapide</translation>
<context>
<name>FormSky</name>
<message>
<location filename="../gui_qt/formsky.cpp" line="103"/>
<location filename="../gui_qt/formsky.cpp" line="105"/>
<source>West preview</source>
<translation>Aperçu de l&apos;ouest</translation>
</message>
<message>
<location filename="../gui_qt/formsky.cpp" line="105"/>
<location filename="../gui_qt/formsky.cpp" line="107"/>
<source>East preview</source>
<translation>Aperçu de l&apos;est</translation>
</message>
<message>
<location filename="../gui_qt/formsky.cpp" line="107"/>
<location filename="../gui_qt/formsky.cpp" line="109"/>
<source>Color model</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../gui_qt/formsky.cpp" line="107"/>
<location filename="../gui_qt/formsky.cpp" line="109"/>
<source>Mixed Preetham/Shirley approximation</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../gui_qt/formsky.cpp" line="107"/>
<location filename="../gui_qt/formsky.cpp" line="109"/>
<source>Custom model</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../gui_qt/formsky.cpp" line="108"/>
<location filename="../gui_qt/formsky.cpp" line="110"/>
<source>Day time</source>
<translation>Heure du jour</translation>
</message>
<message>
<location filename="../gui_qt/formsky.cpp" line="109"/>
<location filename="../gui_qt/formsky.cpp" line="111"/>
<source>Sun color</source>
<translation>Couleur du soleil</translation>
</message>
<message>
<location filename="../gui_qt/formsky.cpp" line="110"/>
<location filename="../gui_qt/formsky.cpp" line="112"/>
<source>Sun radius</source>
<translation>Diamètre apparent du soleil</translation>
</message>
<message>
<location filename="../gui_qt/formsky.cpp" line="111"/>
<location filename="../gui_qt/formsky.cpp" line="113"/>
<source>Sun halo radius</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../gui_qt/formsky.cpp" line="112"/>
<location filename="../gui_qt/formsky.cpp" line="114"/>
<source>Sun halo profile</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../gui_qt/formsky.cpp" line="113"/>
<source>Auto from daytime</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../gui_qt/formsky.cpp" line="118"/>
<location filename="../gui_qt/formsky.cpp" line="125"/>
<source>Turbidity</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../gui_qt/formsky.cpp" line="114"/>
<location filename="../gui_qt/formsky.cpp" line="117"/>
<source>Zenith color</source>
<translation>Couleur du ciel au zénith</translation>
</message>
<message>
<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>
<translation>Couleur de la brume</translation>
</message>
<message>
<location filename="../gui_qt/formsky.cpp" line="116"/>
<location filename="../gui_qt/formsky.cpp" line="121"/>
<source>Haze height</source>
<translation>Hauteur apparente de la brume</translation>
</message>
<message>
<location filename="../gui_qt/formsky.cpp" line="117"/>
<location filename="../gui_qt/formsky.cpp" line="123"/>
<source>Haze smoothing</source>
<translation>Facteur de lissage de la brume</translation>
</message>