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);
|
2013-05-25 13:33:37 +00:00
|
|
|
_form_helper->addPreview(ui->preview_shape, _renderer_shape);
|
2013-05-09 17:13:04 +00:00
|
|
|
|
2013-05-25 13:33:37 +00:00
|
|
|
_form_helper->addDoubleInputSlider(ui->input_scaling, &_terrain->scaling, 0.1, 3.0, 0.03, 0.3);
|
2013-06-09 13:11:03 +00:00
|
|
|
_form_helper->addDoubleInputSlider(ui->input_height, &_terrain->height, 1.0, 90.0, 0.5, 5.0);
|
2013-05-25 13:33:37 +00:00
|
|
|
_form_helper->addDoubleInputSlider(ui->input_shadow_smoothing, &_terrain->shadow_smoothing, 0.0, 0.3, 0.003, 0.03);
|
|
|
|
_form_helper->addDoubleInputSlider(ui->input_water_height, &_terrain->water_height, -2.0, 2.0, 0.01, 0.1);
|
2013-05-09 17:13:04 +00:00
|
|
|
|
2013-05-25 13:33:37 +00:00
|
|
|
_form_helper->setApplyButton(ui->button_apply);
|
|
|
|
_form_helper->setRevertButton(ui->button_revert);
|
|
|
|
_form_helper->setExploreButton(ui->button_explore);
|
|
|
|
_form_helper->setRenderButton(ui->button_render);
|
2013-05-09 17:13:04 +00:00
|
|
|
|
2013-05-25 13:33:37 +00:00
|
|
|
connect(ui->button_dialog_painting, SIGNAL(clicked()), this, SLOT(buttonPaintingPressed()));
|
|
|
|
connect(ui->button_goto_textures, SIGNAL(clicked()), this, SLOT(buttonTexturesPressed()));
|
2013-05-09 17:13:04 +00:00
|
|
|
|
|
|
|
_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
|
|
|
}
|