2012-01-26 23:08:09 +00:00
|
|
|
#include "formatmosphere.h"
|
|
|
|
|
2012-02-12 17:26:17 +00:00
|
|
|
#include "tools.h"
|
2012-11-25 21:53:01 +00:00
|
|
|
|
|
|
|
#include <QColor>
|
|
|
|
#include <QSlider>
|
2013-11-12 20:34:35 +00:00
|
|
|
#include <cmath>
|
2012-11-25 21:53:01 +00:00
|
|
|
|
2013-11-12 20:34:35 +00:00
|
|
|
#include "AtmosphereColorPreviewRenderer.h"
|
2013-12-10 21:32:58 +00:00
|
|
|
#include "DesktopScenery.h"
|
2013-11-12 22:15:35 +00:00
|
|
|
#include "BasePreview.h"
|
2013-11-15 23:27:40 +00:00
|
|
|
#include "AtmosphereDefinition.h"
|
2012-01-26 23:08:09 +00:00
|
|
|
|
2012-11-25 21:53:01 +00:00
|
|
|
static AtmosphereDefinition* _definition;
|
2012-01-26 23:08:09 +00:00
|
|
|
|
|
|
|
/**************** Form ****************/
|
|
|
|
FormAtmosphere::FormAtmosphere(QWidget *parent):
|
|
|
|
BaseForm(parent)
|
|
|
|
{
|
2012-12-24 13:59:17 +00:00
|
|
|
addAutoPreset(tr("Clear day"));
|
|
|
|
addAutoPreset(tr("Clear sunset"));
|
|
|
|
addAutoPreset(tr("Hazy morning"));
|
|
|
|
addAutoPreset(tr("Foggy"));
|
|
|
|
addAutoPreset(tr("Stormy"));
|
|
|
|
|
2013-11-15 23:27:40 +00:00
|
|
|
_definition = new AtmosphereDefinition(NULL);
|
2012-01-26 23:08:09 +00:00
|
|
|
|
2013-11-12 20:34:35 +00:00
|
|
|
previewWest = new BasePreview(this);
|
2013-11-20 10:27:21 +00:00
|
|
|
previewWestRenderer = new AtmosphereColorPreviewRenderer(_definition, M_PI / 2.0);
|
2012-11-25 21:53:01 +00:00
|
|
|
addPreview(previewWest, QString(tr("West preview")));
|
2014-02-24 21:25:53 +00:00
|
|
|
previewWest->setRenderer(previewWestRenderer);
|
2013-11-13 22:36:52 +00:00
|
|
|
|
2013-11-12 20:34:35 +00:00
|
|
|
previewEast = new BasePreview(this);
|
2013-11-20 10:27:21 +00:00
|
|
|
previewEastRenderer = new AtmosphereColorPreviewRenderer(_definition, -M_PI / 2.0);
|
2012-11-25 21:53:01 +00:00
|
|
|
addPreview(previewEast, QString(tr("East preview")));
|
2014-02-24 21:25:53 +00:00
|
|
|
previewEast->setRenderer(previewEastRenderer);
|
2012-01-26 23:08:09 +00:00
|
|
|
|
2013-03-11 16:57:26 +00:00
|
|
|
//addInputEnum(tr("Color model"), (int*)&_definition->model, QStringList(tr("Simplified model (with weather)")) << tr("Complex model"));
|
2012-12-24 15:15:40 +00:00
|
|
|
addInputInt(tr("Day time (hour)"), &_definition->hour, 0, 23, 1, 10);
|
|
|
|
addInputInt(tr("Day time (minute)"), &_definition->minute, 0, 59, 1, 10);
|
2013-01-16 15:56:17 +00:00
|
|
|
//addInputColor(tr("Sun color"), &_definition->sun_color);
|
2013-01-30 17:00:26 +00:00
|
|
|
addInputDouble(tr("Sun radius"), &_definition->sun_radius, 0.0, 5.0, 0.05, 0.5);
|
2013-03-11 16:57:26 +00:00
|
|
|
//addInputDouble(tr("Influence of skydome on lighting"), &_definition->dome_lighting, 0.0, 2.0, 0.01, 0.1);
|
2013-03-18 21:07:57 +00:00
|
|
|
addInputDouble(tr("Humidity"), &_definition->humidity, 0.0, 1.0, 0.01, 0.1);
|
2013-12-26 15:55:37 +00:00
|
|
|
addInputDouble(tr("Moon radius"), &_definition->moon_radius, 0.5, 3.0, 0.03, 0.3);
|
|
|
|
addInputDouble(tr("Moon location (horizontal)"), &_definition->moon_phi, 0.0, M_PI * 2.0, 0.05, 0.5);
|
|
|
|
addInputDouble(tr("Moon location (vertical)"), &_definition->moon_theta, -0.1, M_PI * 0.5, 0.02, 0.2);
|
2012-01-26 23:08:09 +00:00
|
|
|
|
|
|
|
revertConfig();
|
|
|
|
}
|
|
|
|
|
2013-11-13 22:36:52 +00:00
|
|
|
FormAtmosphere::~FormAtmosphere()
|
|
|
|
{
|
|
|
|
delete previewWest;
|
|
|
|
delete previewWestRenderer;
|
|
|
|
delete previewEast;
|
|
|
|
delete previewEastRenderer;
|
|
|
|
}
|
|
|
|
|
2012-01-26 23:08:09 +00:00
|
|
|
void FormAtmosphere::revertConfig()
|
|
|
|
{
|
2013-12-10 21:32:58 +00:00
|
|
|
DesktopScenery::getCurrent()->getAtmosphere(_definition);
|
2012-01-26 23:08:09 +00:00
|
|
|
BaseForm::revertConfig();
|
|
|
|
}
|
|
|
|
|
|
|
|
void FormAtmosphere::applyConfig()
|
|
|
|
{
|
2013-12-10 21:32:58 +00:00
|
|
|
DesktopScenery::getCurrent()->setAtmosphere(_definition);
|
2012-01-26 23:08:09 +00:00
|
|
|
BaseForm::applyConfig();
|
|
|
|
}
|
|
|
|
|
|
|
|
void FormAtmosphere::configChangeEvent()
|
|
|
|
{
|
2013-11-15 23:27:40 +00:00
|
|
|
_definition->validate();
|
2012-01-26 23:08:09 +00:00
|
|
|
BaseForm::configChangeEvent();
|
|
|
|
}
|
2012-12-24 13:59:17 +00:00
|
|
|
|
|
|
|
void FormAtmosphere::autoPresetSelected(int preset)
|
|
|
|
{
|
2013-11-15 23:27:40 +00:00
|
|
|
_definition->applyPreset((AtmosphereDefinition::AtmospherePreset)preset);
|
2012-12-24 13:59:17 +00:00
|
|
|
BaseForm::autoPresetSelected(preset);
|
|
|
|
}
|