paysages : Automatic colors updating for custom sky.
git-svn-id: https://subversion.assembla.com/svn/thunderk/paysages@373 b1fd45b6-86a6-48da-8261-f70d1f35bdcc
This commit is contained in:
parent
bce5dfbd8f
commit
b7e4be1030
8 changed files with 78 additions and 53 deletions
1
TODO
1
TODO
|
@ -1,6 +1,5 @@
|
|||
Technology Preview 2 :
|
||||
- Finalize Preetham's model usage
|
||||
=> Update all fields when "auto from daytime" is selected
|
||||
=> Apply model to atmosphere (aerial perspective)
|
||||
=> Find a proper model for night sky (maybe Shirley)
|
||||
- InputInt doesn't honor small_step.
|
||||
|
|
|
@ -176,7 +176,7 @@ void BaseForm::revertConfig()
|
|||
}
|
||||
|
||||
updatePreviews();
|
||||
configChangeEvent();
|
||||
//configChangeEvent();
|
||||
|
||||
button_apply->setEnabled(false);
|
||||
button_revert->setEnabled(false);
|
||||
|
|
|
@ -144,5 +144,11 @@ void FormSky::applyConfig()
|
|||
void FormSky::configChangeEvent()
|
||||
{
|
||||
skyValidateDefinition(&_definition);
|
||||
|
||||
if (_definition.model == SKY_MODEL_CUSTOM && _definition.model_custom.auto_from_daytime)
|
||||
{
|
||||
BaseForm::revertConfig();
|
||||
}
|
||||
|
||||
BaseForm::configChangeEvent();
|
||||
}
|
||||
|
|
|
@ -4,50 +4,55 @@
|
|||
#include "math.h"
|
||||
|
||||
InputDouble::InputDouble(QWidget* form, QString label, double* value, double min, double max, double small_step, double large_step):
|
||||
BaseInput(form, label),
|
||||
value(value), min(min), max(max), small_step(small_step), large_step(large_step)
|
||||
BaseInput(form, label)
|
||||
{
|
||||
slider = new QSlider(form);
|
||||
_value = value;
|
||||
_min = min;
|
||||
_max = max;
|
||||
_small_step = small_step;
|
||||
_large_step = large_step;
|
||||
|
||||
slider->setOrientation(Qt::Horizontal);
|
||||
slider->setMinimumWidth(200);
|
||||
slider->setMaximumWidth(400);
|
||||
_slider = new QSlider(form);
|
||||
|
||||
slider->setMinimum(0);
|
||||
slider->setMaximum(round((max - min) / small_step));
|
||||
slider->setValue(round((*value - min) / small_step));
|
||||
_slider->setOrientation(Qt::Horizontal);
|
||||
_slider->setMinimumWidth(200);
|
||||
_slider->setMaximumWidth(400);
|
||||
|
||||
slider->setTickInterval(round(large_step / small_step));
|
||||
slider->setTickPosition(QSlider::TicksBelow);
|
||||
_slider->setMinimum(0);
|
||||
_slider->setMaximum(round((max - min) / small_step));
|
||||
_slider->setValue(round((*value - min) / small_step));
|
||||
|
||||
connect(slider, SIGNAL(valueChanged(int)), this, SLOT(applyValue()));
|
||||
_slider->setTickInterval(round(large_step / small_step));
|
||||
_slider->setTickPosition(QSlider::TicksBelow);
|
||||
|
||||
connect(_slider, SIGNAL(valueChanged(int)), this, SLOT(applyValue()));
|
||||
|
||||
_preview = new QLabel(form);
|
||||
((QLabel*)_preview)->setAlignment(Qt::AlignCenter);
|
||||
_control = slider;
|
||||
_control = _slider;
|
||||
}
|
||||
|
||||
void InputDouble::updatePreview()
|
||||
{
|
||||
((QLabel*)_preview)->setText(QString::number(*value, 'g', 3));
|
||||
((QLabel*)_preview)->setText(QString::number(*_value, 'g', 3));
|
||||
|
||||
BaseInput::updatePreview();
|
||||
}
|
||||
|
||||
void InputDouble::applyValue()
|
||||
{
|
||||
int ivalue = slider->value();
|
||||
if (ivalue == slider->maximum())
|
||||
int ivalue = _slider->value();
|
||||
if (ivalue == _slider->maximum())
|
||||
{
|
||||
*value = max;
|
||||
*_value = _max;
|
||||
}
|
||||
else
|
||||
{
|
||||
*value = min + ((double)ivalue) * small_step;
|
||||
*_value = _min + ((double)ivalue) * _small_step;
|
||||
}
|
||||
if (fabs(*value) < 0.0000001)
|
||||
if (fabs(*_value) < 0.0000001)
|
||||
{
|
||||
*value = 0.0;
|
||||
*_value = 0.0;
|
||||
}
|
||||
|
||||
BaseInput::applyValue();
|
||||
|
@ -55,7 +60,11 @@ void InputDouble::applyValue()
|
|||
|
||||
void InputDouble::revert()
|
||||
{
|
||||
slider->setValue(round((*value - min) / small_step));
|
||||
double value = round((*_value - _min) / _small_step);
|
||||
if (value != _slider->value())
|
||||
{
|
||||
_slider->setValue(value);
|
||||
}
|
||||
|
||||
BaseInput::revert();
|
||||
}
|
||||
|
|
|
@ -18,12 +18,12 @@ public slots:
|
|||
virtual void revert();
|
||||
|
||||
private:
|
||||
QSlider* slider;
|
||||
double* value;
|
||||
double min;
|
||||
double max;
|
||||
double small_step;
|
||||
double large_step;
|
||||
QSlider* _slider;
|
||||
double* _value;
|
||||
double _min;
|
||||
double _max;
|
||||
double _small_step;
|
||||
double _large_step;
|
||||
};
|
||||
|
||||
#endif // _PAYSAGES_QT_INPUTDOUBLE_H_
|
||||
#endif
|
||||
|
|
|
@ -23,7 +23,10 @@ void InputEnum::applyValue()
|
|||
|
||||
void InputEnum::revert()
|
||||
{
|
||||
((QComboBox*)_control)->setCurrentIndex(*_value);
|
||||
if (*_value != ((QComboBox*)_control)->currentIndex())
|
||||
{
|
||||
((QComboBox*)_control)->setCurrentIndex(*_value);
|
||||
}
|
||||
|
||||
BaseInput::revert();
|
||||
}
|
||||
|
|
|
@ -3,46 +3,54 @@
|
|||
#include <QLabel>
|
||||
|
||||
InputInt::InputInt(QWidget* form, QString label, int* value, int min, int max, int small_step, int large_step):
|
||||
BaseInput(form, label),
|
||||
value(value), min(min), max(max), small_step(small_step), large_step(large_step)
|
||||
BaseInput(form, label)
|
||||
{
|
||||
slider = new QSlider(form);
|
||||
_value = value;
|
||||
_min = min;
|
||||
_max = max;
|
||||
_small_step = small_step;
|
||||
_large_step = large_step;
|
||||
|
||||
slider->setOrientation(Qt::Horizontal);
|
||||
slider->setMinimumWidth(150);
|
||||
slider->setMaximumWidth(400);
|
||||
_slider = new QSlider(form);
|
||||
|
||||
slider->setMinimum(min);
|
||||
slider->setMaximum(max);
|
||||
slider->setValue(*value);
|
||||
_slider->setOrientation(Qt::Horizontal);
|
||||
_slider->setMinimumWidth(150);
|
||||
_slider->setMaximumWidth(400);
|
||||
|
||||
slider->setTickInterval(large_step);
|
||||
slider->setTickPosition(QSlider::TicksBelow);
|
||||
_slider->setMinimum(min);
|
||||
_slider->setMaximum(max);
|
||||
_slider->setValue(*value);
|
||||
|
||||
connect(slider, SIGNAL(valueChanged(int)), this, SLOT(applyValue()));
|
||||
_slider->setTickInterval(large_step);
|
||||
_slider->setTickPosition(QSlider::TicksBelow);
|
||||
|
||||
connect(_slider, SIGNAL(valueChanged(int)), this, SLOT(applyValue()));
|
||||
|
||||
_preview = new QLabel(form);
|
||||
((QLabel*)_preview)->setAlignment(Qt::AlignCenter);
|
||||
_control = slider;
|
||||
_control = _slider;
|
||||
}
|
||||
|
||||
void InputInt::updatePreview()
|
||||
{
|
||||
((QLabel*)_preview)->setText(QString("%1").arg(*value));
|
||||
((QLabel*)_preview)->setText(QString("%1").arg(*_value));
|
||||
|
||||
BaseInput::updatePreview();
|
||||
}
|
||||
|
||||
void InputInt::applyValue()
|
||||
{
|
||||
*value = (int)slider->value();
|
||||
*_value = (int)_slider->value();
|
||||
|
||||
BaseInput::applyValue();
|
||||
}
|
||||
|
||||
void InputInt::revert()
|
||||
{
|
||||
slider->setValue(*value);
|
||||
if (*_value != _slider->value())
|
||||
{
|
||||
_slider->setValue(*_value);
|
||||
}
|
||||
|
||||
BaseInput::revert();
|
||||
}
|
||||
|
|
|
@ -18,12 +18,12 @@ public slots:
|
|||
virtual void revert();
|
||||
|
||||
private:
|
||||
QSlider* slider;
|
||||
int* value;
|
||||
int min;
|
||||
int max;
|
||||
int small_step;
|
||||
int large_step;
|
||||
QSlider* _slider;
|
||||
int* _value;
|
||||
int _min;
|
||||
int _max;
|
||||
int _small_step;
|
||||
int _large_step;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue