From 23cad305483c5615981d332b6c4a72037dedf0d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Lemaire?= Date: Thu, 3 Oct 2013 23:28:30 +0200 Subject: [PATCH] Started textures edition dialog (WIP) --- src/editing/common/freelayerhelper.cpp | 13 + src/editing/common/freelayerhelper.h | 3 + src/editing/editing.pro | 9 +- src/editing/textures/DialogTexturesLayer.cpp | 20 ++ src/editing/textures/DialogTexturesLayer.h | 27 ++ src/editing/textures/DialogTexturesLayer.ui | 294 +++++++++++++++++++ src/editing/textures/maintexturesform.cpp | 9 + src/editing/textures/maintexturesform.h | 1 + src/editing/textures/maintexturesform.ui | 70 ++--- 9 files changed, 408 insertions(+), 38 deletions(-) create mode 100644 src/editing/textures/DialogTexturesLayer.cpp create mode 100644 src/editing/textures/DialogTexturesLayer.h create mode 100644 src/editing/textures/DialogTexturesLayer.ui diff --git a/src/editing/common/freelayerhelper.cpp b/src/editing/common/freelayerhelper.cpp index 9e92ac6..0eef212 100644 --- a/src/editing/common/freelayerhelper.cpp +++ b/src/editing/common/freelayerhelper.cpp @@ -89,6 +89,11 @@ void FreeLayerHelper::setUpButton(QPushButton* button) } } +void FreeLayerHelper::setEditButton(QPushButton* button) +{ + connect(button, SIGNAL(clicked()), this, SLOT(startEditing())); +} + void FreeLayerHelper::addLayer() { _selected = layersAddLayer(_layers, NULL); @@ -128,6 +133,14 @@ void FreeLayerHelper::moveLayerUp() } } +void FreeLayerHelper::startEditing() +{ + if (_selected >= 0 && _selected < layersCount(_layers)) + { + emit(editRequired(_selected)); + } +} + void FreeLayerHelper::tableSelectionChanged(int row, int) { int n = layersCount(_layers); diff --git a/src/editing/common/freelayerhelper.h b/src/editing/common/freelayerhelper.h index 6ff3615..af6178b 100644 --- a/src/editing/common/freelayerhelper.h +++ b/src/editing/common/freelayerhelper.h @@ -20,17 +20,20 @@ public: void setDelButton(QPushButton* button); void setDownButton(QPushButton* button); void setUpButton(QPushButton* button); + void setEditButton(QPushButton* button); signals: void selectionChanged(int layer); void layersChanged(); void tableUpdateNeeded(); + void editRequired(int layer); public slots: void addLayer(); void deleteLayer(); void moveLayerDown(); void moveLayerUp(); + void startEditing(); void tableSelectionChanged(int row, int col); private: diff --git a/src/editing/editing.pro b/src/editing/editing.pro index 2a7b4fa..4346502 100644 --- a/src/editing/editing.pro +++ b/src/editing/editing.pro @@ -72,7 +72,8 @@ HEADERS += \ lighting/SmallPreviewHues.h \ textures/PreviewLayerCoverage.h \ textures/PreviewLayerLook.h \ - textures/PreviewCumul.h + textures/PreviewCumul.h \ + textures/DialogTexturesLayer.h SOURCES += \ terrain/widgetheightmap.cpp \ @@ -130,7 +131,8 @@ SOURCES += \ lighting/SmallPreviewHues.cpp \ textures/PreviewLayerCoverage.cpp \ textures/PreviewLayerLook.cpp \ - textures/PreviewCumul.cpp + textures/PreviewCumul.cpp \ + textures/DialogTexturesLayer.cpp FORMS += \ terrain/dialogterrainpainting.ui \ @@ -139,7 +141,8 @@ FORMS += \ common/mainwindow.ui \ terrain/dialogbaseterrainnoise.ui \ textures/maintexturesform.ui \ - lighting/DialogMaterialEditor.ui + lighting/DialogMaterialEditor.ui \ + textures/DialogTexturesLayer.ui RESOURCES += \ ../../data/ui_pictures.qrc diff --git a/src/editing/textures/DialogTexturesLayer.cpp b/src/editing/textures/DialogTexturesLayer.cpp new file mode 100644 index 0000000..6352938 --- /dev/null +++ b/src/editing/textures/DialogTexturesLayer.cpp @@ -0,0 +1,20 @@ +#include "DialogTexturesLayer.h" +#include "ui_DialogTexturesLayer.h" + +DialogTexturesLayer::DialogTexturesLayer(QWidget* parent, TexturesDefinition* textures, int layer) : + QDialog(parent), + ui(new Ui::DialogTexturesLayer) +{ + ui->setupUi(this); + + this->layer = layer; + original = textures; + modified = (TexturesDefinition*)TexturesDefinitionClass.create(); +} + +DialogTexturesLayer::~DialogTexturesLayer() +{ + delete ui; + + TexturesDefinitionClass.destroy(modified); +} diff --git a/src/editing/textures/DialogTexturesLayer.h b/src/editing/textures/DialogTexturesLayer.h new file mode 100644 index 0000000..d151009 --- /dev/null +++ b/src/editing/textures/DialogTexturesLayer.h @@ -0,0 +1,27 @@ +#ifndef DIALOGTEXTURESLAYER_H +#define DIALOGTEXTURESLAYER_H + +#include +#include "rendering/textures/public.h" + +namespace Ui { +class DialogTexturesLayer; +} + +class DialogTexturesLayer : public QDialog +{ + Q_OBJECT + +public: + explicit DialogTexturesLayer(QWidget* parent, TexturesDefinition* textures, int layer); + ~DialogTexturesLayer(); + +private: + Ui::DialogTexturesLayer *ui; + + int layer; + TexturesDefinition* original; + TexturesDefinition* modified; +}; + +#endif // DIALOGTEXTURESLAYER_H diff --git a/src/editing/textures/DialogTexturesLayer.ui b/src/editing/textures/DialogTexturesLayer.ui new file mode 100644 index 0000000..c190240 --- /dev/null +++ b/src/editing/textures/DialogTexturesLayer.ui @@ -0,0 +1,294 @@ + + + DialogTexturesLayer + + + + 0 + 0 + 1020 + 648 + + + + Paysages 3D - Texture editing + + + true + + + + + + + + Height constraints + + + true + + + + + + + true + + + + Control at which altitude the texture is present + + + + + + + + + + Slope constraints + + + true + + + + + + + true + + + + Control the slope influence on texture presence + + + + + + + + + + + + + + Ground displacement + + + true + + + + + + + true + + + + TextLabel + + + + + + + + + + Material + + + + + + + + + Qt::Vertical + + + + + + + + + Coverage preview + + + true + + + + + + + 0 + 0 + + + + + 200 + 200 + + + + + 200 + 200 + + + + + + + + + + + Colored preview + + + true + + + + + + + 0 + 0 + + + + + 200 + 200 + + + + + 200 + 200 + + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + Actions + + + true + + + + + + Explore in 3D + + + + :/buttons/logo/images/explore.png:/buttons/logo/images/explore.png + + + + + + + Cancel + + + + :/buttons/logo/images/cancel.png:/buttons/logo/images/cancel.png + + + + + + + Validate + + + + :/buttons/logo/images/apply.png:/buttons/logo/images/apply.png + + + true + + + + + + + Render preview + + + + :/buttons/logo/images/render.png:/buttons/logo/images/render.png + + + + + + + Load preset + + + + :/buttons/logo/images/auto.png:/buttons/logo/images/auto.png + + + + + + + Revert + + + + :/buttons/logo/images/revert.png:/buttons/logo/images/revert.png + + + + + + + + + + + + + BasePreview + QWidget +
basepreview.h
+ 1 +
+
+ + + + +
diff --git a/src/editing/textures/maintexturesform.cpp b/src/editing/textures/maintexturesform.cpp index 1afa935..5b81ed2 100644 --- a/src/editing/textures/maintexturesform.cpp +++ b/src/editing/textures/maintexturesform.cpp @@ -8,6 +8,7 @@ #include "editing/textures/PreviewLayerCoverage.h" #include "editing/textures/PreviewLayerLook.h" #include "editing/textures/PreviewCumul.h" +#include "editing/textures/DialogTexturesLayer.h" MainTexturesForm::MainTexturesForm(QWidget *parent) : QWidget(parent), ui(new Ui::MainTexturesForm) { @@ -21,8 +22,10 @@ MainTexturesForm::MainTexturesForm(QWidget *parent) : QWidget(parent), ui(new Ui layer_helper->setDelButton(ui->layer_del); layer_helper->setDownButton(ui->layer_down); layer_helper->setUpButton(ui->layer_up); + layer_helper->setEditButton(ui->layer_edit); connect(layer_helper, SIGNAL(tableUpdateNeeded()), this, SLOT(updateLayers())); connect(layer_helper, SIGNAL(selectionChanged(int)), this, SLOT(selectLayer(int))); + connect(layer_helper, SIGNAL(editRequired(int)), this, SLOT(editLayer(int))); form_helper = new FreeFormHelper(this); form_helper->setApplyButton(ui->button_apply); @@ -114,6 +117,12 @@ void MainTexturesForm::selectLayer(int layer) } } +void MainTexturesForm::editLayer(int layer) +{ + DialogTexturesLayer dialog(this, textures, layer); + dialog.exec(); +} + void MainTexturesForm::selectPreset(int preset) { texturesAutoPreset(textures, (TexturesPreset)preset); diff --git a/src/editing/textures/maintexturesform.h b/src/editing/textures/maintexturesform.h index bb78c3e..c131b86 100644 --- a/src/editing/textures/maintexturesform.h +++ b/src/editing/textures/maintexturesform.h @@ -31,6 +31,7 @@ public slots: void updateLayers(); void selectLayer(int layer); + void editLayer(int layer); void selectPreset(int preset); private: diff --git a/src/editing/textures/maintexturesform.ui b/src/editing/textures/maintexturesform.ui index f3db5cb..8449c3b 100644 --- a/src/editing/textures/maintexturesform.ui +++ b/src/editing/textures/maintexturesform.ui @@ -349,44 +349,44 @@ - - - - Render preview - - - - :/buttons/logo/images/render.png:/buttons/logo/images/render.png - - - - - - - Explore in 3D - - - - :/buttons/logo/images/explore.png:/buttons/logo/images/explore.png - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - + + + + Explore in 3D + + + + :/buttons/logo/images/explore.png:/buttons/logo/images/explore.png + + + + + + + Render preview + + + + :/buttons/logo/images/render.png:/buttons/logo/images/render.png + + + + + + + Qt::Vertical + + + + 20 + 40 + + + +