2012-01-26 23:08:09 +00:00
|
|
|
#include "formclouds.h"
|
|
|
|
|
2013-01-19 22:42:50 +00:00
|
|
|
#include "../lib_paysages/tools/color.h"
|
|
|
|
#include "../lib_paysages/tools/euclid.h"
|
2012-01-26 23:08:09 +00:00
|
|
|
#include "../lib_paysages/scenery.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-01-22 20:50:37 +00:00
|
|
|
_renderer = cloudsCreatePreviewCoverageRenderer();
|
2012-12-06 14:04:04 +00:00
|
|
|
|
2012-08-26 13:36:46 +00:00
|
|
|
_original_layer = layer;
|
2013-01-22 20:50:37 +00:00
|
|
|
_preview_definition = (CloudsDefinition*)CloudsDefinitionClass.create();
|
2012-12-06 14:04:04 +00:00
|
|
|
|
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-22 20:50:37 +00:00
|
|
|
CloudsDefinitionClass.destroy(_preview_definition);
|
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-01-22 20:50:37 +00:00
|
|
|
return cloudsGetPreviewCoverage(_renderer, x, y, scaling);
|
2012-02-05 11:31:16 +00:00
|
|
|
}
|
|
|
|
void updateData()
|
|
|
|
{
|
2013-01-22 20:50:37 +00:00
|
|
|
layersDeleteLayer(_preview_definition->layers, 0);
|
|
|
|
layersAddLayer(_preview_definition->layers, _original_layer);
|
|
|
|
CloudsRendererClass.bind(_renderer, _preview_definition);
|
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-22 20:50:37 +00:00
|
|
|
CloudsDefinition* _preview_definition;
|
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
|
|
|
_preview_definition = (CloudsDefinition*)CloudsDefinitionClass.create();
|
|
|
|
|
|
|
|
_renderer = cloudsCreatePreviewColorRenderer();
|
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
|
|
|
}
|
|
|
|
protected:
|
2013-01-16 14:26:46 +00:00
|
|
|
Color getColor(double x, double y)
|
2012-02-08 14:24:53 +00:00
|
|
|
{
|
2013-01-22 20:50:37 +00:00
|
|
|
return cloudsGetPreviewColor(_renderer, x, y);
|
2012-02-08 14:24:53 +00:00
|
|
|
}
|
|
|
|
void updateData()
|
|
|
|
{
|
2013-01-22 20:50:37 +00:00
|
|
|
layersDeleteLayer(_preview_definition->layers, 0);
|
|
|
|
layersAddLayer(_preview_definition->layers, _original_layer);
|
|
|
|
CloudsRendererClass.bind(_renderer, _preview_definition);
|
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;
|
2013-01-22 20:50:37 +00:00
|
|
|
CloudsDefinition* _preview_definition;
|
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
|
|
|
}
|
|
|
|
|
|
|
|
void FormClouds::revertConfig()
|
|
|
|
{
|
2013-01-22 20:50:37 +00:00
|
|
|
sceneryGetClouds(_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-01-22 20:50:37 +00:00
|
|
|
scenerySetClouds(_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-22 20:50:37 +00:00
|
|
|
cloudsAutoPreset(_layer, (CloudsPreset)preset);
|
2012-11-24 12:30:51 +00:00
|
|
|
BaseForm::autoPresetSelected(preset);
|
|
|
|
}
|
|
|
|
|