2012-01-26 23:08:09 +00:00
|
|
|
#include "formclouds.h"
|
|
|
|
|
2013-11-12 20:34:35 +00:00
|
|
|
#include "clouds/clo_preview.h"
|
|
|
|
#include "tools/color.h"
|
|
|
|
#include "tools/euclid.h"
|
2013-10-29 20:28:59 +00:00
|
|
|
#include "Scenery.h"
|
2013-11-12 22:15:35 +00:00
|
|
|
#include "BasePreview.h"
|
|
|
|
#include "renderer.h"
|
2012-02-05 11:31:16 +00:00
|
|
|
|
|
|
|
#include "tools.h"
|
2012-01-26 23:08:09 +00:00
|
|
|
|
|
|
|
/**************** Previews ****************/
|
2012-02-21 13:41:02 +00:00
|
|
|
class PreviewCloudsCoverage:public BasePreview
|
2012-02-05 11:31:16 +00:00
|
|
|
{
|
|
|
|
public:
|
2012-08-26 13:36:46 +00:00
|
|
|
PreviewCloudsCoverage(QWidget* parent, CloudsLayerDefinition* layer):BasePreview(parent)
|
2012-02-05 11:31:16 +00:00
|
|
|
{
|
2013-06-02 19:49:48 +00:00
|
|
|
_renderer = cloudsPreviewCoverageCreateRenderer();
|
2013-01-30 10:57:41 +00:00
|
|
|
_3d = true;
|
2012-12-06 14:04:04 +00:00
|
|
|
|
2012-08-26 13:36:46 +00:00
|
|
|
_original_layer = layer;
|
2012-12-06 14:04:04 +00:00
|
|
|
|
2013-01-30 10:57:41 +00:00
|
|
|
addToggle("3d", tr("Perspective"), true);
|
2012-04-12 20:02:31 +00:00
|
|
|
configScaling(100.0, 1000.0, 20.0, 200.0);
|
2012-02-05 11:31:16 +00:00
|
|
|
}
|
2012-08-26 13:36:46 +00:00
|
|
|
~PreviewCloudsCoverage()
|
|
|
|
{
|
2013-01-20 15:07:45 +00:00
|
|
|
rendererDelete(_renderer);
|
2012-08-26 13:36:46 +00:00
|
|
|
}
|
2012-02-05 11:31:16 +00:00
|
|
|
protected:
|
2013-01-16 14:26:46 +00:00
|
|
|
Color getColor(double x, double y)
|
2012-02-05 11:31:16 +00:00
|
|
|
{
|
2013-06-02 19:49:48 +00:00
|
|
|
return cloudsPreviewCoverageGetPixel(_renderer, x, y, scaling, _3d);
|
2013-01-30 10:57:41 +00:00
|
|
|
}
|
|
|
|
virtual void toggleChangeEvent(QString key, bool value)
|
|
|
|
{
|
|
|
|
if (key == "3d")
|
|
|
|
{
|
|
|
|
_3d = value;
|
|
|
|
}
|
|
|
|
BasePreview::toggleChangeEvent(key, value);
|
2012-02-05 11:31:16 +00:00
|
|
|
}
|
|
|
|
void updateData()
|
|
|
|
{
|
2013-06-02 19:49:48 +00:00
|
|
|
cloudsPreviewCoverageBindLayer(_renderer, _original_layer);
|
2012-06-05 20:22:12 +00:00
|
|
|
}
|
2012-02-05 11:31:16 +00:00
|
|
|
|
|
|
|
private:
|
2013-01-20 15:07:45 +00:00
|
|
|
Renderer* _renderer;
|
2012-08-26 13:36:46 +00:00
|
|
|
CloudsLayerDefinition* _original_layer;
|
2013-01-30 10:57:41 +00:00
|
|
|
bool _3d;
|
2012-02-05 11:31:16 +00:00
|
|
|
};
|
2012-01-26 23:08:09 +00:00
|
|
|
|
2012-02-21 13:41:02 +00:00
|
|
|
class PreviewCloudsColor:public BasePreview
|
2012-02-08 14:24:53 +00:00
|
|
|
{
|
|
|
|
public:
|
2012-08-26 13:36:46 +00:00
|
|
|
PreviewCloudsColor(QWidget* parent, CloudsLayerDefinition* layer):BasePreview(parent)
|
2012-02-08 14:24:53 +00:00
|
|
|
{
|
2012-08-26 13:36:46 +00:00
|
|
|
_original_layer = layer;
|
2013-01-22 20:50:37 +00:00
|
|
|
|
2013-06-02 19:49:48 +00:00
|
|
|
_renderer = cloudsPreviewMaterialCreateRenderer();
|
2012-12-06 14:04:04 +00:00
|
|
|
|
2012-07-01 13:27:57 +00:00
|
|
|
configScaling(0.5, 2.0, 0.1, 2.0);
|
2012-02-08 14:24:53 +00:00
|
|
|
}
|
2013-06-02 19:49:48 +00:00
|
|
|
|
|
|
|
~PreviewCloudsColor()
|
|
|
|
{
|
|
|
|
rendererDelete(_renderer);
|
|
|
|
}
|
2012-02-08 14:24:53 +00:00
|
|
|
protected:
|
2013-01-16 14:26:46 +00:00
|
|
|
Color getColor(double x, double y)
|
2012-02-08 14:24:53 +00:00
|
|
|
{
|
2013-06-02 19:49:48 +00:00
|
|
|
return cloudsPreviewMaterialGetPixel(_renderer, x, y);
|
2012-02-08 14:24:53 +00:00
|
|
|
}
|
|
|
|
void updateData()
|
|
|
|
{
|
2013-06-02 19:49:48 +00:00
|
|
|
cloudsPreviewMaterialBindLayer(_renderer, _original_layer);
|
2012-02-08 14:24:53 +00:00
|
|
|
}
|
|
|
|
private:
|
2013-01-20 15:07:45 +00:00
|
|
|
Renderer* _renderer;
|
2012-08-26 13:36:46 +00:00
|
|
|
CloudsLayerDefinition* _original_layer;
|
2012-02-08 14:24:53 +00:00
|
|
|
};
|
|
|
|
|
2012-01-26 23:08:09 +00:00
|
|
|
/**************** Form ****************/
|
|
|
|
FormClouds::FormClouds(QWidget *parent):
|
2012-08-26 13:36:46 +00:00
|
|
|
BaseFormLayer(parent)
|
2012-01-26 23:08:09 +00:00
|
|
|
{
|
2012-11-24 12:30:51 +00:00
|
|
|
addAutoPreset(tr("Cirrus"));
|
2012-11-24 16:04:33 +00:00
|
|
|
addAutoPreset(tr("Cumulus"));
|
|
|
|
addAutoPreset(tr("Stratocumulus"));
|
2012-11-24 12:30:51 +00:00
|
|
|
addAutoPreset(tr("Stratus"));
|
|
|
|
|
2013-01-22 20:50:37 +00:00
|
|
|
_definition = (CloudsDefinition*)CloudsDefinitionClass.create();
|
|
|
|
_layer = (CloudsLayerDefinition*)cloudsGetLayerType().callback_create();
|
2012-12-06 14:04:04 +00:00
|
|
|
|
2012-08-26 13:36:46 +00:00
|
|
|
_previewCoverage = new PreviewCloudsCoverage(parent, _layer);
|
|
|
|
_previewColor = new PreviewCloudsColor(parent, _layer);
|
|
|
|
addPreview(_previewCoverage, tr("Layer coverage (no lighting)"));
|
|
|
|
addPreview(_previewColor, tr("Appearance"));
|
|
|
|
|
2012-12-05 15:35:25 +00:00
|
|
|
addInputEnum(tr("Clouds model"), (int*)&_layer->type, QStringList() << tr("Cirrus") << tr("Cumulus") << tr("Stratocumulus") << tr("Stratus"));
|
2012-08-26 13:36:46 +00:00
|
|
|
addInputDouble(tr("Lower altitude"), &_layer->lower_altitude, -10.0, 50.0, 0.5, 5.0);
|
|
|
|
addInputDouble(tr("Layer thickness"), &_layer->thickness, 0.0, 20.0, 0.1, 1.0);
|
|
|
|
addInputDouble(tr("Max coverage"), &_layer->base_coverage, 0.0, 1.0, 0.01, 0.1);
|
2012-08-26 20:02:10 +00:00
|
|
|
addInputDouble(tr("Shape scaling"), &_layer->shape_scaling, 3.0, 30.0, 0.3, 3.0);
|
2012-11-24 12:30:51 +00:00
|
|
|
addInputDouble(tr("Edge scaling"), &_layer->edge_scaling, 0.5, 5.0, 0.05, 0.5);
|
2012-08-26 13:36:46 +00:00
|
|
|
addInputDouble(tr("Edge length"), &_layer->edge_length, 0.0, 1.0, 0.01, 0.1);
|
|
|
|
addInputMaterial(tr("Material"), &_layer->material);
|
|
|
|
addInputDouble(tr("Hardness to light"), &_layer->hardness, 0.0, 1.0, 0.01, 0.1);
|
2012-08-27 20:40:35 +00:00
|
|
|
addInputDouble(tr("Transparency depth"), &_layer->transparencydepth, 0.0, 10.0, 0.1, 1.0);
|
|
|
|
addInputDouble(tr("Light traversal depth"), &_layer->lighttraversal, 0.0, 10.0, 0.1, 1.0);
|
2012-08-26 13:36:46 +00:00
|
|
|
addInputDouble(tr("Minimum lighting"), &_layer->minimumlight, 0.0, 1.0, 0.01, 0.1);
|
|
|
|
|
2013-01-22 20:50:37 +00:00
|
|
|
setLayers(_definition->layers);
|
2012-01-26 23:08:09 +00:00
|
|
|
}
|
|
|
|
|
2013-03-31 20:27:21 +00:00
|
|
|
FormClouds::~FormClouds()
|
|
|
|
{
|
|
|
|
CloudsDefinitionClass.destroy(_definition);
|
|
|
|
cloudsGetLayerType().callback_delete(_layer);
|
|
|
|
|
|
|
|
delete _previewCoverage;
|
|
|
|
delete _previewColor;
|
|
|
|
}
|
|
|
|
|
2012-01-26 23:08:09 +00:00
|
|
|
void FormClouds::revertConfig()
|
|
|
|
{
|
2013-11-13 22:03:02 +00:00
|
|
|
Scenery::getCurrent()->getClouds(_definition);
|
2012-08-26 13:36:46 +00:00
|
|
|
BaseFormLayer::revertConfig();
|
2012-01-26 23:08:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void FormClouds::applyConfig()
|
|
|
|
{
|
2012-08-26 13:36:46 +00:00
|
|
|
BaseFormLayer::applyConfig();
|
2013-11-13 22:03:02 +00:00
|
|
|
Scenery::getCurrent()->setClouds(_definition);
|
2012-12-05 15:35:25 +00:00
|
|
|
}
|
|
|
|
|
2012-12-06 14:04:04 +00:00
|
|
|
void FormClouds::layerReadCurrentFrom(void* layer_definition)
|
2012-07-05 17:05:03 +00:00
|
|
|
{
|
2013-01-22 20:50:37 +00:00
|
|
|
cloudsGetLayerType().callback_copy((CloudsLayerDefinition*)layer_definition, _layer);
|
2012-02-05 11:31:16 +00:00
|
|
|
}
|
|
|
|
|
2012-12-06 14:04:04 +00:00
|
|
|
void FormClouds::layerWriteCurrentTo(void* layer_definition)
|
2012-07-05 15:01:58 +00:00
|
|
|
{
|
2013-01-22 20:50:37 +00:00
|
|
|
cloudsGetLayerType().callback_copy(_layer, (CloudsLayerDefinition*)layer_definition);
|
2012-02-05 11:31:16 +00:00
|
|
|
}
|
2012-11-24 12:30:51 +00:00
|
|
|
|
|
|
|
void FormClouds::autoPresetSelected(int preset)
|
|
|
|
{
|
2013-01-30 14:30:06 +00:00
|
|
|
cloudsLayerAutoPreset(_layer, (CloudsLayerPreset)preset);
|
2012-11-24 12:30:51 +00:00
|
|
|
BaseForm::autoPresetSelected(preset);
|
|
|
|
}
|