2013-06-23 20:54:57 +00:00
|
|
|
#include "maintexturesform.h"
|
|
|
|
#include "ui_maintexturesform.h"
|
|
|
|
|
2013-08-17 15:04:48 +00:00
|
|
|
#include "../common/freeformhelper.h"
|
|
|
|
#include "../common/freelayerhelper.h"
|
|
|
|
#include "rendering/scenery.h"
|
|
|
|
#include "previewmaterial.h"
|
2013-08-21 21:19:47 +00:00
|
|
|
#include "editing/textures/PreviewLayerCoverage.h"
|
2013-08-23 22:51:27 +00:00
|
|
|
#include "editing/textures/PreviewLayerLook.h"
|
|
|
|
#include "editing/textures/PreviewCumul.h"
|
2013-10-03 21:28:30 +00:00
|
|
|
#include "editing/textures/DialogTexturesLayer.h"
|
2013-08-17 15:04:48 +00:00
|
|
|
|
|
|
|
MainTexturesForm::MainTexturesForm(QWidget *parent) : QWidget(parent), ui(new Ui::MainTexturesForm)
|
2013-06-23 20:54:57 +00:00
|
|
|
{
|
2013-08-17 15:04:48 +00:00
|
|
|
textures = (TexturesDefinition*) TexturesDefinitionClass.create();
|
|
|
|
|
2013-06-23 20:54:57 +00:00
|
|
|
ui->setupUi(this);
|
2013-08-17 15:04:48 +00:00
|
|
|
|
|
|
|
layer_helper = new FreeLayerHelper(textures->layers, true);
|
|
|
|
layer_helper->setLayerTable(ui->layersGrid);
|
|
|
|
layer_helper->setAddButton(ui->layer_add);
|
|
|
|
layer_helper->setDelButton(ui->layer_del);
|
|
|
|
layer_helper->setDownButton(ui->layer_down);
|
|
|
|
layer_helper->setUpButton(ui->layer_up);
|
2013-10-03 21:28:30 +00:00
|
|
|
layer_helper->setEditButton(ui->layer_edit);
|
2013-08-17 15:04:48 +00:00
|
|
|
connect(layer_helper, SIGNAL(tableUpdateNeeded()), this, SLOT(updateLayers()));
|
|
|
|
connect(layer_helper, SIGNAL(selectionChanged(int)), this, SLOT(selectLayer(int)));
|
2013-10-03 21:28:30 +00:00
|
|
|
connect(layer_helper, SIGNAL(editRequired(int)), this, SLOT(editLayer(int)));
|
2013-08-17 16:08:37 +00:00
|
|
|
|
|
|
|
form_helper = new FreeFormHelper(this);
|
|
|
|
form_helper->setApplyButton(ui->button_apply);
|
|
|
|
form_helper->setRevertButton(ui->button_revert);
|
|
|
|
form_helper->setExploreButton(ui->button_explore);
|
|
|
|
form_helper->setRenderButton(ui->button_render);
|
|
|
|
form_helper->startManaging();
|
|
|
|
|
2013-08-21 21:19:47 +00:00
|
|
|
preview_layer_coverage = new PreviewLayerCoverage();
|
|
|
|
preview_layer_coverage->setTextures(textures);
|
|
|
|
form_helper->addPreview(ui->preview_coverage, preview_layer_coverage);
|
|
|
|
|
2013-08-23 22:51:27 +00:00
|
|
|
preview_layer_look = new PreviewLayerLook();
|
|
|
|
preview_layer_look->setTextures(textures);
|
|
|
|
form_helper->addPreview(ui->preview_texture, preview_layer_look);
|
|
|
|
|
|
|
|
preview_cumul = new PreviewCumul();
|
|
|
|
preview_cumul->setTextures(textures);
|
|
|
|
form_helper->addPreview(ui->preview_cumul, preview_cumul);
|
|
|
|
|
2013-10-03 21:27:37 +00:00
|
|
|
form_helper->addPreset(tr("Complex terrain"));
|
2013-08-21 21:22:13 +00:00
|
|
|
form_helper->addPreset(tr("Rocks with grass"));
|
|
|
|
form_helper->addPreset(tr("Snow covered mountains"));
|
2013-10-03 21:27:37 +00:00
|
|
|
//form_helper->addPreset(tr("Arid canyons"));
|
2013-08-21 21:22:13 +00:00
|
|
|
form_helper->setPresetButton(ui->button_preset);
|
|
|
|
connect(form_helper, SIGNAL(presetSelected(int)), this, SLOT(selectPreset(int)));
|
|
|
|
|
2013-08-17 16:08:37 +00:00
|
|
|
connect(layer_helper, SIGNAL(layersChanged()), form_helper, SLOT(processDataChange()));
|
2013-06-23 20:54:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
MainTexturesForm::~MainTexturesForm()
|
|
|
|
{
|
|
|
|
delete ui;
|
2013-08-17 15:04:48 +00:00
|
|
|
delete form_helper;
|
|
|
|
delete layer_helper;
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainTexturesForm::updateLayers()
|
|
|
|
{
|
|
|
|
int i, n;
|
|
|
|
|
|
|
|
ui->layersGrid->clearContents();
|
|
|
|
|
|
|
|
n = layersCount(textures->layers);
|
|
|
|
ui->layersGrid->setRowCount(n);
|
|
|
|
|
|
|
|
for (i = 0; i < n; i++)
|
|
|
|
{
|
|
|
|
QTableWidgetItem* item;
|
|
|
|
TexturesLayerDefinition* layer = (TexturesLayerDefinition*) layersGetLayer(textures->layers, i);
|
|
|
|
|
|
|
|
item = new QTableWidgetItem(QString("%1").arg(i + 1));
|
|
|
|
item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
|
|
|
|
ui->layersGrid->setItem(n - 1 - i, 0, item);
|
|
|
|
|
|
|
|
item = new QTableWidgetItem(QString(layersGetName(textures->layers, i)));
|
|
|
|
item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
|
|
|
|
ui->layersGrid->setItem(n - 1 - i, 1, item);
|
|
|
|
|
2013-08-22 21:45:46 +00:00
|
|
|
QWidget* widget = new SmallMaterialPreview(ui->layersGrid, &layer->material);
|
|
|
|
//widget->setMinimumSize(50, 50);
|
|
|
|
ui->layersGrid->setCellWidget(n - 1 - i, 2, widget);
|
|
|
|
|
|
|
|
ui->layersGrid->setRowHeight(n - 1 - i, 50);
|
2013-08-17 15:04:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ui->preview_cumul->setEnabled(n > 0);
|
|
|
|
|
|
|
|
ui->layersGrid->resizeColumnsToContents();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainTexturesForm::selectLayer(int layer)
|
|
|
|
{
|
|
|
|
if (layer < 0)
|
|
|
|
{
|
|
|
|
ui->preview_coverage->setEnabled(false);
|
|
|
|
ui->preview_texture->setEnabled(false);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ui->preview_coverage->setEnabled(true);
|
|
|
|
ui->preview_texture->setEnabled(true);
|
2013-08-21 21:19:47 +00:00
|
|
|
|
|
|
|
preview_layer_coverage->setLayer(layer);
|
2013-08-28 14:03:22 +00:00
|
|
|
preview_layer_look->setLayer(layer);
|
2013-08-21 21:19:47 +00:00
|
|
|
|
|
|
|
ui->preview_coverage->redraw();
|
|
|
|
ui->preview_texture->redraw();
|
2013-08-17 15:04:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-10-03 21:28:30 +00:00
|
|
|
void MainTexturesForm::editLayer(int layer)
|
|
|
|
{
|
|
|
|
DialogTexturesLayer dialog(this, textures, layer);
|
|
|
|
dialog.exec();
|
|
|
|
}
|
|
|
|
|
2013-08-21 21:22:13 +00:00
|
|
|
void MainTexturesForm::selectPreset(int preset)
|
|
|
|
{
|
|
|
|
texturesAutoPreset(textures, (TexturesPreset)preset);
|
|
|
|
}
|
|
|
|
|
2013-08-17 15:04:48 +00:00
|
|
|
void MainTexturesForm::updateLocalDataFromScenery()
|
|
|
|
{
|
|
|
|
sceneryGetTextures(textures);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainTexturesForm::commitLocalDataToScenery()
|
|
|
|
{
|
|
|
|
scenerySetTextures(textures);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainTexturesForm::refreshFromLocalData()
|
|
|
|
{
|
|
|
|
layer_helper->refreshLayers();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainTexturesForm::refreshFromFellowData()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainTexturesForm::alterRenderer(Renderer* renderer)
|
|
|
|
{
|
|
|
|
TexturesRendererClass.bind(renderer, textures);
|
2013-06-23 20:54:57 +00:00
|
|
|
}
|