paysages3d/src/interface/desktop/formatmosphere.cpp
Michaël Lemaire 6e323dbea7 BasePreview no longer fix its own size in constructor
This prevented free-sized previews from correctly sizing
2014-02-24 22:25:53 +01:00

82 lines
2.7 KiB
C++

#include "formatmosphere.h"
#include "tools.h"
#include <QColor>
#include <QSlider>
#include <cmath>
#include "AtmosphereColorPreviewRenderer.h"
#include "DesktopScenery.h"
#include "BasePreview.h"
#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"));
_definition = new AtmosphereDefinition(NULL);
previewWest = new BasePreview(this);
previewWestRenderer = new AtmosphereColorPreviewRenderer(_definition, M_PI / 2.0);
addPreview(previewWest, QString(tr("West preview")));
previewWest->setRenderer(previewWestRenderer);
previewEast = new BasePreview(this);
previewEastRenderer = new AtmosphereColorPreviewRenderer(_definition, -M_PI / 2.0);
addPreview(previewEast, QString(tr("East preview")));
previewEast->setRenderer(previewEastRenderer);
//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);
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);
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()
{
_definition->validate();
BaseForm::configChangeEvent();
}
void FormAtmosphere::autoPresetSelected(int preset)
{
_definition->applyPreset((AtmosphereDefinition::AtmospherePreset)preset);
BaseForm::autoPresetSelected(preset);
}