2012-07-10 19:39:12 +00:00
|
|
|
#include "formterraincanvas.h"
|
|
|
|
|
2012-08-02 19:26:22 +00:00
|
|
|
/**************** Form ****************/
|
|
|
|
class PreviewTerrainCanvasHeight:public BasePreview
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
PreviewTerrainCanvasHeight(QWidget* parent, TerrainCanvas* canvas):BasePreview(parent)
|
|
|
|
{
|
|
|
|
_base_canvas = canvas;
|
|
|
|
_preview_canvas = terrainCanvasCreate();
|
|
|
|
|
|
|
|
//addOsd(QString("geolocation"));
|
|
|
|
|
|
|
|
configScaling(0.5, 200.0, 3.0, 50.0);
|
|
|
|
configScrolling(-1000.0, 1000.0, 0.0, -1000.0, 1000.0, 0.0);
|
|
|
|
}
|
|
|
|
|
|
|
|
~PreviewTerrainCanvasHeight()
|
|
|
|
{
|
|
|
|
terrainCanvasDelete(_preview_canvas);
|
|
|
|
}
|
|
|
|
protected:
|
|
|
|
QColor getColor(double x, double y)
|
|
|
|
{
|
|
|
|
double height;
|
|
|
|
|
|
|
|
height = 0.0; // TODO
|
|
|
|
return QColor((int)(255.0 * height), (int)(255.0 * height), (int)(255.0 * height));
|
|
|
|
}
|
|
|
|
void updateData()
|
|
|
|
{
|
|
|
|
terrainCanvasCopy(_base_canvas, _preview_canvas);
|
|
|
|
}
|
|
|
|
private:
|
|
|
|
TerrainCanvas* _base_canvas;
|
|
|
|
TerrainCanvas* _preview_canvas;
|
|
|
|
};
|
|
|
|
|
2012-07-10 19:39:12 +00:00
|
|
|
/**************** Form ****************/
|
2012-07-10 20:00:44 +00:00
|
|
|
FormTerrainCanvas::FormTerrainCanvas(QWidget *parent, Layers* layers):
|
|
|
|
BaseFormLayer(parent, layers)
|
2012-07-10 19:39:12 +00:00
|
|
|
{
|
2012-07-11 13:18:43 +00:00
|
|
|
_definition = terrainCanvasCreate();
|
|
|
|
|
|
|
|
// TODO Area
|
2012-08-02 19:26:22 +00:00
|
|
|
//addInputDouble(tr("Apply at height"), &_definition->offset_y, -20.0, 20.0, 0.1, 1.0);
|
2012-08-08 13:30:40 +00:00
|
|
|
addInputHeightMap(tr("Height map"), &_definition->height_map, _definition);
|
2012-08-02 19:26:22 +00:00
|
|
|
//addInputDouble(tr("Canvas height"), &_definition->height_factor, 0.0, 20.0, 0.1, 1.0);
|
2012-07-11 13:18:43 +00:00
|
|
|
addInputNoise(tr("Detail noise"), _definition->detail_noise);
|
|
|
|
addInputDouble(tr("Detail noise height"), &_definition->detail_height_factor, 0.0, 20.0, 0.1, 1.0);
|
|
|
|
addInputDouble(tr("Detail noise scaling"), &_definition->detail_scaling, 0.0, 20.0, 0.1, 1.0);
|
2012-07-18 15:04:23 +00:00
|
|
|
addInputEnum(tr("Mask shape"), &_definition->mask.mode, QStringList(tr("Square")) << tr("Circle"));
|
|
|
|
addInputDouble(tr("Mask smoothing"), &_definition->mask.smoothing, 0.0, 1.0, 0.01, 0.1);
|
2012-07-11 13:18:43 +00:00
|
|
|
|
2012-08-02 19:26:22 +00:00
|
|
|
_previewHeight = new PreviewTerrainCanvasHeight(this, _definition);
|
|
|
|
addPreview(_previewHeight, tr("Height preview (normalized)"));
|
|
|
|
|
2012-07-11 13:18:43 +00:00
|
|
|
revertConfig();
|
2012-07-10 19:39:12 +00:00
|
|
|
}
|
|
|
|
|
2012-07-11 13:18:43 +00:00
|
|
|
FormTerrainCanvas::~FormTerrainCanvas()
|
2012-07-10 19:39:12 +00:00
|
|
|
{
|
2012-07-11 13:18:43 +00:00
|
|
|
terrainCanvasDelete(_definition);
|
2012-07-10 19:39:12 +00:00
|
|
|
}
|
|
|
|
|
2012-07-11 13:18:43 +00:00
|
|
|
void FormTerrainCanvas::layerGetCopy(void* layer_definition)
|
2012-07-10 19:39:12 +00:00
|
|
|
{
|
2012-07-11 13:18:43 +00:00
|
|
|
terrainCanvasCopy((TerrainCanvas*)layer_definition, _definition);
|
2012-07-10 19:39:12 +00:00
|
|
|
}
|
|
|
|
|
2012-07-11 13:18:43 +00:00
|
|
|
void FormTerrainCanvas::layerApply(void* layer_definition)
|
2012-07-10 19:39:12 +00:00
|
|
|
{
|
2012-07-11 13:18:43 +00:00
|
|
|
terrainCanvasCopy(_definition, (TerrainCanvas*)layer_definition);
|
2012-07-10 19:39:12 +00:00
|
|
|
}
|
2012-08-08 14:44:37 +00:00
|
|
|
|
|
|
|
void FormTerrainCanvas::afterLayerAdded(void* layer_definition)
|
|
|
|
{
|
|
|
|
terrainCanvasRevertToTerrain((TerrainCanvas*)layer_definition);
|
|
|
|
}
|