paysages3d/src/interface/desktop/formatmosphere.cpp

80 lines
2.4 KiB
C++
Raw Normal View History

#include "formatmosphere.h"
#include "tools.h"
#include <QColor>
#include <QSlider>
#include <cmath>
#include "AtmosphereColorPreviewRenderer.h"
#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"
static AtmosphereDefinition* _definition;
/**************** Form ****************/
FormAtmosphere::FormAtmosphere(QWidget *parent):
BaseForm(parent)
{
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);
previewWest = new BasePreview(this);
2013-11-20 10:27:21 +00:00
previewWestRenderer = new AtmosphereColorPreviewRenderer(_definition, M_PI / 2.0);
previewWest->setRenderer(previewWestRenderer);
addPreview(previewWest, QString(tr("West preview")));
previewEast = new BasePreview(this);
2013-11-20 10:27:21 +00:00
previewEastRenderer = new AtmosphereColorPreviewRenderer(_definition, -M_PI / 2.0);
previewEast->setRenderer(previewEastRenderer);
addPreview(previewEast, QString(tr("East preview")));
//addInputEnum(tr("Color model"), (int*)&_definition->model, QStringList(tr("Simplified model (with weather)")) << tr("Complex model"));
addInputInt(tr("Day time (hour)"), &_definition->hour, 0, 23, 1, 10);
addInputInt(tr("Day time (minute)"), &_definition->minute, 0, 59, 1, 10);
//addInputColor(tr("Sun color"), &_definition->sun_color);
addInputDouble(tr("Sun radius"), &_definition->sun_radius, 0.0, 5.0, 0.05, 0.5);
//addInputDouble(tr("Influence of skydome on lighting"), &_definition->dome_lighting, 0.0, 2.0, 0.01, 0.1);
addInputDouble(tr("Humidity"), &_definition->humidity, 0.0, 1.0, 0.01, 0.1);
revertConfig();
}
FormAtmosphere::~FormAtmosphere()
{
delete previewWest;
delete previewWestRenderer;
delete previewEast;
delete previewEastRenderer;
}
void FormAtmosphere::revertConfig()
{
DesktopScenery::getCurrent()->getAtmosphere(_definition);
BaseForm::revertConfig();
}
void FormAtmosphere::applyConfig()
{
DesktopScenery::getCurrent()->setAtmosphere(_definition);
BaseForm::applyConfig();
}
void FormAtmosphere::configChangeEvent()
{
2013-11-15 23:27:40 +00:00
_definition->validate();
BaseForm::configChangeEvent();
}
void FormAtmosphere::autoPresetSelected(int preset)
{
2013-11-15 23:27:40 +00:00
_definition->applyPreset((AtmosphereDefinition::AtmospherePreset)preset);
BaseForm::autoPresetSelected(preset);
}