2012-01-22 18:39:42 +00:00
|
|
|
#include "formterrain.h"
|
|
|
|
|
|
|
|
#include <QColor>
|
|
|
|
#include <QSlider>
|
2012-06-25 20:11:15 +00:00
|
|
|
#include "tools.h"
|
2012-12-10 22:05:53 +00:00
|
|
|
#include "dialogheightmap.h"
|
2012-12-28 11:28:01 +00:00
|
|
|
#include "../lib_paysages/scenery.h"
|
2012-01-22 18:39:42 +00:00
|
|
|
|
2012-12-09 17:49:28 +00:00
|
|
|
static TerrainDefinition* _definition;
|
2012-01-22 18:39:42 +00:00
|
|
|
|
|
|
|
/**************** Previews ****************/
|
2012-02-21 13:41:02 +00:00
|
|
|
class PreviewTerrainColor:public BasePreview
|
2012-01-22 18:39:42 +00:00
|
|
|
{
|
|
|
|
public:
|
2012-02-21 13:41:02 +00:00
|
|
|
PreviewTerrainColor(QWidget* parent):BasePreview(parent)
|
2012-01-22 18:39:42 +00:00
|
|
|
{
|
2012-12-28 11:28:01 +00:00
|
|
|
_renderer = terrainCreatePreviewRenderer();
|
2012-06-25 20:11:15 +00:00
|
|
|
|
|
|
|
addOsd(QString("geolocation"));
|
2012-12-09 17:49:28 +00:00
|
|
|
|
2012-06-02 14:17:01 +00:00
|
|
|
configScaling(0.5, 200.0, 3.0, 50.0);
|
2012-04-15 20:08:01 +00:00
|
|
|
configScrolling(-1000.0, 1000.0, 0.0, -1000.0, 1000.0, 0.0);
|
2012-01-22 18:39:42 +00:00
|
|
|
}
|
|
|
|
protected:
|
2013-01-16 14:26:46 +00:00
|
|
|
Color getColor(double x, double y)
|
2012-01-22 18:39:42 +00:00
|
|
|
{
|
2013-01-16 14:26:46 +00:00
|
|
|
return terrainGetPreviewColor(&_renderer, x, -y, scaling);
|
2012-01-25 22:32:06 +00:00
|
|
|
}
|
|
|
|
void updateData()
|
|
|
|
{
|
2012-12-09 17:49:28 +00:00
|
|
|
TerrainRendererClass.bind(_renderer.terrain, _definition);
|
2012-01-22 18:39:42 +00:00
|
|
|
}
|
|
|
|
private:
|
2012-01-24 13:16:20 +00:00
|
|
|
Renderer _renderer;
|
2012-01-22 18:39:42 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**************** Form ****************/
|
|
|
|
FormTerrain::FormTerrain(QWidget *parent):
|
|
|
|
BaseForm(parent)
|
|
|
|
{
|
2012-12-09 17:49:28 +00:00
|
|
|
_definition = (TerrainDefinition*)TerrainDefinitionClass.create();
|
2012-01-22 18:39:42 +00:00
|
|
|
|
2012-12-10 22:05:53 +00:00
|
|
|
QPushButton* button = addButton(tr("Paint"));
|
|
|
|
connect(button, SIGNAL(clicked()), this, SLOT(startPainting()));
|
|
|
|
|
2012-12-28 11:28:01 +00:00
|
|
|
/*previewHeight = new PreviewTerrainHeight(this);*/
|
2012-01-22 18:39:42 +00:00
|
|
|
previewColor = new PreviewTerrainColor(this);
|
2012-12-28 11:28:01 +00:00
|
|
|
/*addPreview(previewHeight, tr("Height preview (normalized)"));*/
|
2012-08-02 19:26:22 +00:00
|
|
|
addPreview(previewColor, tr("Lighted preview (no texture)"));
|
2012-01-22 18:39:42 +00:00
|
|
|
|
2012-12-09 17:49:28 +00:00
|
|
|
//addInputNoise(tr("Noise"), _definition.height_noise);
|
2013-01-14 12:08:38 +00:00
|
|
|
addInputDouble(tr("Scaling"), &_definition->scaling, 0.1, 3.0, 0.03, 0.3);
|
|
|
|
addInputDouble(tr("Height modifier"), &_definition->height, 0.0, 3.0, 0.01, 0.1);
|
2012-12-09 17:49:28 +00:00
|
|
|
addInputDouble(tr("Shadow smoothing"), &_definition->shadow_smoothing, 0.0, 0.3, 0.003, 0.03);
|
2012-01-22 18:39:42 +00:00
|
|
|
|
|
|
|
revertConfig();
|
|
|
|
}
|
|
|
|
|
|
|
|
void FormTerrain::revertConfig()
|
|
|
|
{
|
2012-12-09 17:49:28 +00:00
|
|
|
sceneryGetTerrain(_definition);
|
2012-01-22 18:39:42 +00:00
|
|
|
BaseForm::revertConfig();
|
|
|
|
}
|
|
|
|
|
|
|
|
void FormTerrain::applyConfig()
|
|
|
|
{
|
2012-12-09 17:49:28 +00:00
|
|
|
scenerySetTerrain(_definition);
|
2012-01-22 18:39:42 +00:00
|
|
|
BaseForm::applyConfig();
|
|
|
|
}
|
2012-01-23 23:45:33 +00:00
|
|
|
|
2012-01-25 22:32:06 +00:00
|
|
|
void FormTerrain::configChangeEvent()
|
2012-01-23 23:45:33 +00:00
|
|
|
{
|
2012-12-09 17:49:28 +00:00
|
|
|
TerrainDefinitionClass.validate(_definition);
|
2012-01-25 22:32:06 +00:00
|
|
|
BaseForm::configChangeEvent();
|
2012-01-23 23:45:33 +00:00
|
|
|
}
|
2012-12-10 22:05:53 +00:00
|
|
|
|
|
|
|
void FormTerrain::startPainting()
|
|
|
|
{
|
|
|
|
DialogHeightMap::editHeightMap(this, _definition);
|
|
|
|
}
|