2013-05-05 16:42:55 +00:00
|
|
|
#include "mainterrainform.h"
|
|
|
|
#include "ui_mainterrainform.h"
|
|
|
|
|
2013-05-09 17:13:04 +00:00
|
|
|
#include "dialogterrainpainting.h"
|
2013-05-10 08:10:07 +00:00
|
|
|
#include "previewterrainshape.h"
|
2013-05-09 17:13:04 +00:00
|
|
|
#include "tools.h"
|
|
|
|
#include "rendering/scenery.h"
|
|
|
|
|
2013-05-05 16:42:55 +00:00
|
|
|
MainTerrainForm::MainTerrainForm(QWidget *parent) :
|
|
|
|
QWidget(parent),
|
|
|
|
ui(new Ui::MainTerrainForm)
|
|
|
|
{
|
2013-05-09 17:13:04 +00:00
|
|
|
_terrain = (TerrainDefinition*)TerrainDefinitionClass.create();
|
|
|
|
|
2013-05-05 16:42:55 +00:00
|
|
|
ui->setupUi(this);
|
2013-05-09 17:13:04 +00:00
|
|
|
|
|
|
|
_form_helper = new FreeFormHelper(this);
|
|
|
|
|
2013-05-10 08:10:07 +00:00
|
|
|
_renderer_shape = new PreviewTerrainShape(_terrain);
|
|
|
|
_form_helper->addPreview("preview_shape", _renderer_shape);
|
2013-05-09 17:13:04 +00:00
|
|
|
|
|
|
|
_form_helper->addDoubleInputSlider("input_scaling", &_terrain->scaling, 0.1, 3.0, 0.03, 0.3);
|
2013-05-11 21:34:30 +00:00
|
|
|
_form_helper->addDoubleInputSlider("input_height", &_terrain->height, 1.0, 45.0, 0.3, 3.0);
|
2013-05-09 17:13:04 +00:00
|
|
|
_form_helper->addDoubleInputSlider("input_shadow_smoothing", &_terrain->shadow_smoothing, 0.0, 0.3, 0.003, 0.03);
|
2013-05-11 21:34:30 +00:00
|
|
|
_form_helper->addDoubleInputSlider("input_water_height", &_terrain->water_height, -2.0, 2.0, 0.01, 0.1);
|
2013-05-09 17:13:04 +00:00
|
|
|
|
|
|
|
_form_helper->setApplyButton("button_apply");
|
|
|
|
_form_helper->setRevertButton("button_revert");
|
2013-05-14 20:32:56 +00:00
|
|
|
_form_helper->setExploreButton("button_explore");
|
|
|
|
_form_helper->setRenderButton("button_render");
|
2013-05-09 17:13:04 +00:00
|
|
|
|
|
|
|
connect(findChild<QPushButton*>("button_dialog_painting"), SIGNAL(clicked()), this, SLOT(buttonPaintingPressed()));
|
|
|
|
connect(findChild<QPushButton*>("button_goto_textures"), SIGNAL(clicked()), this, SLOT(buttonTexturesPressed()));
|
|
|
|
|
|
|
|
_form_helper->startManaging();
|
2013-05-05 16:42:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
MainTerrainForm::~MainTerrainForm()
|
|
|
|
{
|
2013-05-09 17:13:04 +00:00
|
|
|
delete _form_helper;
|
2013-05-05 16:42:55 +00:00
|
|
|
delete ui;
|
2013-05-10 08:10:07 +00:00
|
|
|
delete _renderer_shape;
|
2013-05-09 17:13:04 +00:00
|
|
|
|
|
|
|
TerrainDefinitionClass.destroy(_terrain);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainTerrainForm::refreshFromLocalData()
|
|
|
|
{
|
|
|
|
qint64 memused = terrainGetMemoryStats(_terrain);
|
|
|
|
if (memused > 0)
|
|
|
|
{
|
|
|
|
_form_helper->setLabelText("label_painting_info", tr("Memory used by sculpted data: %1").arg(getHumanMemory(memused)));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
_form_helper->setLabelText("label_painting_info", tr("No manual scuplting done"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainTerrainForm::refreshFromFellowData()
|
|
|
|
{
|
|
|
|
// TODO Refresh texture info
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainTerrainForm::updateLocalDataFromScenery()
|
|
|
|
{
|
|
|
|
sceneryGetTerrain(_terrain);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainTerrainForm::commitLocalDataToScenery()
|
|
|
|
{
|
|
|
|
scenerySetTerrain(_terrain);
|
|
|
|
}
|
|
|
|
|
2013-05-14 20:32:56 +00:00
|
|
|
void MainTerrainForm::alterRenderer(Renderer* renderer)
|
|
|
|
{
|
|
|
|
TerrainRendererClass.bind(renderer, _terrain);
|
|
|
|
}
|
|
|
|
|
2013-05-09 17:13:04 +00:00
|
|
|
void MainTerrainForm::buttonPaintingPressed()
|
|
|
|
{
|
|
|
|
DialogTerrainPainting dialog(this, _terrain);
|
|
|
|
_form_helper->openDialog(&dialog);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainTerrainForm::buttonTexturesPressed()
|
|
|
|
{
|
|
|
|
// TODO Switch to textures tab
|
2013-05-05 16:42:55 +00:00
|
|
|
}
|