2012-01-07 16:53:23 +00:00
|
|
|
#include "formsky.h"
|
|
|
|
|
|
|
|
#include "tools.h"
|
|
|
|
|
|
|
|
#include <QColor>
|
|
|
|
#include <QSlider>
|
|
|
|
#include <math.h>
|
|
|
|
|
|
|
|
#include "../lib_paysages/sky.h"
|
2012-01-24 13:16:20 +00:00
|
|
|
#include "../lib_paysages/scenery.h"
|
|
|
|
#include "../lib_paysages/renderer.h"
|
2012-01-07 16:53:23 +00:00
|
|
|
#include "../lib_paysages/shared/constants.h"
|
|
|
|
|
|
|
|
static SkyDefinition _definition;
|
|
|
|
|
|
|
|
/**************** Previews ****************/
|
2012-01-16 21:29:21 +00:00
|
|
|
class PreviewEast:public Preview
|
2012-01-07 16:53:23 +00:00
|
|
|
{
|
|
|
|
public:
|
2012-01-16 21:29:21 +00:00
|
|
|
PreviewEast(QWidget* parent):
|
2012-01-07 16:53:23 +00:00
|
|
|
Preview(parent)
|
|
|
|
{
|
2012-01-24 13:16:20 +00:00
|
|
|
_renderer = rendererGetFake();
|
2012-01-25 22:32:06 +00:00
|
|
|
_preview_definition = skyCreateDefinition();
|
2012-01-07 16:53:23 +00:00
|
|
|
}
|
|
|
|
protected:
|
|
|
|
QColor getColor(double x, double y)
|
|
|
|
{
|
|
|
|
Vector3 eye = {0.0, 0.0, 0.0};
|
|
|
|
Vector3 look;
|
|
|
|
|
2012-01-16 21:29:21 +00:00
|
|
|
look.x = 100.0;
|
|
|
|
look.y = -y;
|
|
|
|
look.z = x;
|
|
|
|
|
2012-01-25 22:32:06 +00:00
|
|
|
return colorToQColor(skyGetColor(&_preview_definition, &_renderer, eye, look));
|
|
|
|
}
|
|
|
|
void updateData()
|
|
|
|
{
|
|
|
|
skyCopyDefinition(&_definition, &_preview_definition);
|
2012-01-16 21:29:21 +00:00
|
|
|
}
|
2012-01-24 13:16:20 +00:00
|
|
|
private:
|
|
|
|
Renderer _renderer;
|
2012-01-25 22:32:06 +00:00
|
|
|
SkyDefinition _preview_definition;
|
2012-01-16 21:29:21 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class PreviewWest:public Preview
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
PreviewWest(QWidget* parent):
|
|
|
|
Preview(parent)
|
|
|
|
{
|
2012-01-24 13:16:20 +00:00
|
|
|
_renderer = rendererGetFake();
|
2012-01-25 22:32:06 +00:00
|
|
|
_preview_definition = skyCreateDefinition();
|
2012-01-16 21:29:21 +00:00
|
|
|
}
|
|
|
|
protected:
|
|
|
|
QColor getColor(double x, double y)
|
|
|
|
{
|
|
|
|
Vector3 eye = {0.0, 0.0, 0.0};
|
|
|
|
Vector3 look;
|
|
|
|
|
|
|
|
look.x = -100.0;
|
|
|
|
look.y = -y;
|
|
|
|
look.z = -x;
|
2012-01-07 16:53:23 +00:00
|
|
|
|
2012-01-25 22:32:06 +00:00
|
|
|
return colorToQColor(skyGetColor(&_preview_definition, &_renderer, eye, look));
|
|
|
|
}
|
|
|
|
void updateData()
|
|
|
|
{
|
|
|
|
skyCopyDefinition(&_definition, &_preview_definition);
|
2012-01-07 16:53:23 +00:00
|
|
|
}
|
2012-01-24 13:16:20 +00:00
|
|
|
private:
|
|
|
|
Renderer _renderer;
|
2012-01-25 22:32:06 +00:00
|
|
|
SkyDefinition _preview_definition;
|
2012-01-07 16:53:23 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**************** Form ****************/
|
|
|
|
FormSky::FormSky(QWidget *parent):
|
|
|
|
BaseForm(parent)
|
|
|
|
{
|
|
|
|
_definition = skyCreateDefinition();
|
|
|
|
|
2012-01-16 21:29:21 +00:00
|
|
|
previewWest = new PreviewWest(this);
|
|
|
|
addPreview(previewWest, QString("West preview"));
|
|
|
|
previewEast = new PreviewEast(this);
|
|
|
|
addPreview(previewEast, QString("East preview"));
|
2012-01-07 16:53:23 +00:00
|
|
|
|
|
|
|
addInputDouble("Day time", &_definition.daytime, 0.0, 1.0, 0.01, 0.1);
|
|
|
|
addInputColorGradation("Sun color", &_definition.sun_color);
|
|
|
|
addInputDouble("Sun radius", &_definition.sun_radius, 0.0, 0.3, 0.01, 0.03);
|
|
|
|
addInputColorGradation("Zenith color", &_definition.zenith_color);
|
|
|
|
addInputColorGradation("Haze color", &_definition.haze_color);
|
|
|
|
addInputDouble("Haze height", &_definition.haze_height, 0.0, 1.0, 0.01, 0.1);
|
|
|
|
addInputDouble("Haze smoothing", &_definition.haze_smoothing, 0.0, 1.0, 0.01, 0.1);
|
|
|
|
|
|
|
|
revertConfig();
|
|
|
|
}
|
|
|
|
|
|
|
|
void FormSky::revertConfig()
|
|
|
|
{
|
2012-01-24 13:16:20 +00:00
|
|
|
sceneryGetSky(&_definition);
|
2012-01-07 16:53:23 +00:00
|
|
|
BaseForm::revertConfig();
|
|
|
|
}
|
|
|
|
|
|
|
|
void FormSky::applyConfig()
|
|
|
|
{
|
2012-01-24 13:16:20 +00:00
|
|
|
scenerySetSky(&_definition);
|
2012-01-07 16:53:23 +00:00
|
|
|
BaseForm::applyConfig();
|
|
|
|
}
|
|
|
|
|
2012-01-25 22:32:06 +00:00
|
|
|
void FormSky::configChangeEvent()
|
2012-01-07 16:53:23 +00:00
|
|
|
{
|
|
|
|
skyValidateDefinition(&_definition);
|
2012-01-25 22:32:06 +00:00
|
|
|
BaseForm::configChangeEvent();
|
2012-01-07 16:53:23 +00:00
|
|
|
}
|