Started textures edition dialog (WIP)

This commit is contained in:
Michaël Lemaire 2013-10-03 23:28:30 +02:00
parent a7bc90a1a1
commit 23cad30548
9 changed files with 408 additions and 38 deletions

View file

@ -89,6 +89,11 @@ void FreeLayerHelper::setUpButton(QPushButton* button)
} }
} }
void FreeLayerHelper::setEditButton(QPushButton* button)
{
connect(button, SIGNAL(clicked()), this, SLOT(startEditing()));
}
void FreeLayerHelper::addLayer() void FreeLayerHelper::addLayer()
{ {
_selected = layersAddLayer(_layers, NULL); _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) void FreeLayerHelper::tableSelectionChanged(int row, int)
{ {
int n = layersCount(_layers); int n = layersCount(_layers);

View file

@ -20,17 +20,20 @@ public:
void setDelButton(QPushButton* button); void setDelButton(QPushButton* button);
void setDownButton(QPushButton* button); void setDownButton(QPushButton* button);
void setUpButton(QPushButton* button); void setUpButton(QPushButton* button);
void setEditButton(QPushButton* button);
signals: signals:
void selectionChanged(int layer); void selectionChanged(int layer);
void layersChanged(); void layersChanged();
void tableUpdateNeeded(); void tableUpdateNeeded();
void editRequired(int layer);
public slots: public slots:
void addLayer(); void addLayer();
void deleteLayer(); void deleteLayer();
void moveLayerDown(); void moveLayerDown();
void moveLayerUp(); void moveLayerUp();
void startEditing();
void tableSelectionChanged(int row, int col); void tableSelectionChanged(int row, int col);
private: private:

View file

@ -72,7 +72,8 @@ HEADERS += \
lighting/SmallPreviewHues.h \ lighting/SmallPreviewHues.h \
textures/PreviewLayerCoverage.h \ textures/PreviewLayerCoverage.h \
textures/PreviewLayerLook.h \ textures/PreviewLayerLook.h \
textures/PreviewCumul.h textures/PreviewCumul.h \
textures/DialogTexturesLayer.h
SOURCES += \ SOURCES += \
terrain/widgetheightmap.cpp \ terrain/widgetheightmap.cpp \
@ -130,7 +131,8 @@ SOURCES += \
lighting/SmallPreviewHues.cpp \ lighting/SmallPreviewHues.cpp \
textures/PreviewLayerCoverage.cpp \ textures/PreviewLayerCoverage.cpp \
textures/PreviewLayerLook.cpp \ textures/PreviewLayerLook.cpp \
textures/PreviewCumul.cpp textures/PreviewCumul.cpp \
textures/DialogTexturesLayer.cpp
FORMS += \ FORMS += \
terrain/dialogterrainpainting.ui \ terrain/dialogterrainpainting.ui \
@ -139,7 +141,8 @@ FORMS += \
common/mainwindow.ui \ common/mainwindow.ui \
terrain/dialogbaseterrainnoise.ui \ terrain/dialogbaseterrainnoise.ui \
textures/maintexturesform.ui \ textures/maintexturesform.ui \
lighting/DialogMaterialEditor.ui lighting/DialogMaterialEditor.ui \
textures/DialogTexturesLayer.ui
RESOURCES += \ RESOURCES += \
../../data/ui_pictures.qrc ../../data/ui_pictures.qrc

View file

@ -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);
}

View file

@ -0,0 +1,27 @@
#ifndef DIALOGTEXTURESLAYER_H
#define DIALOGTEXTURESLAYER_H
#include <QDialog>
#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

View file

@ -0,0 +1,294 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DialogTexturesLayer</class>
<widget class="QDialog" name="DialogTexturesLayer">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1020</width>
<height>648</height>
</rect>
</property>
<property name="windowTitle">
<string>Paysages 3D - Texture editing</string>
</property>
<property name="modal">
<bool>true</bool>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Height constraints</string>
</property>
<property name="flat">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QLabel" name="label">
<property name="font">
<font>
<italic>true</italic>
</font>
</property>
<property name="text">
<string>Control at which altitude the texture is present</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_3">
<property name="title">
<string>Slope constraints</string>
</property>
<property name="flat">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_8">
<item>
<widget class="QLabel" name="label_2">
<property name="font">
<font>
<italic>true</italic>
</font>
</property>
<property name="text">
<string>Control the slope influence on texture presence</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QGroupBox" name="groupBox_5">
<property name="title">
<string>Ground displacement</string>
</property>
<property name="flat">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_9">
<item>
<widget class="QLabel" name="label_3">
<property name="font">
<font>
<italic>true</italic>
</font>
</property>
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_6">
<property name="title">
<string>Material</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Coverage preview</string>
</property>
<property name="flat">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_6">
<item>
<widget class="BasePreview" name="preview_cumul_2" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>200</width>
<height>200</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>200</width>
<height>200</height>
</size>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_7">
<property name="title">
<string>Colored preview</string>
</property>
<property name="flat">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_7">
<item>
<widget class="BasePreview" name="preview_cumul_3" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>200</width>
<height>200</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>200</width>
<height>200</height>
</size>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QGroupBox" name="groupBox_4">
<property name="title">
<string>Actions</string>
</property>
<property name="flat">
<bool>true</bool>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="2">
<widget class="QPushButton" name="button_explore_2">
<property name="text">
<string>Explore in 3D</string>
</property>
<property name="icon">
<iconset resource="../../../data/ui_pictures.qrc">
<normaloff>:/buttons/logo/images/explore.png</normaloff>:/buttons/logo/images/explore.png</iconset>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QPushButton" name="button_cancel">
<property name="text">
<string>Cancel</string>
</property>
<property name="icon">
<iconset resource="../../../data/ui_pictures.qrc">
<normaloff>:/buttons/logo/images/cancel.png</normaloff>:/buttons/logo/images/cancel.png</iconset>
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="QPushButton" name="button_apply">
<property name="text">
<string>Validate</string>
</property>
<property name="icon">
<iconset resource="../../../data/ui_pictures.qrc">
<normaloff>:/buttons/logo/images/apply.png</normaloff>:/buttons/logo/images/apply.png</iconset>
</property>
<property name="default">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QPushButton" name="button_render_2">
<property name="text">
<string>Render preview</string>
</property>
<property name="icon">
<iconset resource="../../../data/ui_pictures.qrc">
<normaloff>:/buttons/logo/images/render.png</normaloff>:/buttons/logo/images/render.png</iconset>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QPushButton" name="button_preset">
<property name="text">
<string>Load preset</string>
</property>
<property name="icon">
<iconset resource="../../../data/ui_pictures.qrc">
<normaloff>:/buttons/logo/images/auto.png</normaloff>:/buttons/logo/images/auto.png</iconset>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QPushButton" name="button_revert">
<property name="text">
<string>Revert</string>
</property>
<property name="icon">
<iconset resource="../../../data/ui_pictures.qrc">
<normaloff>:/buttons/logo/images/revert.png</normaloff>:/buttons/logo/images/revert.png</iconset>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>BasePreview</class>
<extends>QWidget</extends>
<header>basepreview.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources>
<include location="../../../data/ui_pictures.qrc"/>
</resources>
<connections/>
</ui>

View file

@ -8,6 +8,7 @@
#include "editing/textures/PreviewLayerCoverage.h" #include "editing/textures/PreviewLayerCoverage.h"
#include "editing/textures/PreviewLayerLook.h" #include "editing/textures/PreviewLayerLook.h"
#include "editing/textures/PreviewCumul.h" #include "editing/textures/PreviewCumul.h"
#include "editing/textures/DialogTexturesLayer.h"
MainTexturesForm::MainTexturesForm(QWidget *parent) : QWidget(parent), ui(new Ui::MainTexturesForm) 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->setDelButton(ui->layer_del);
layer_helper->setDownButton(ui->layer_down); layer_helper->setDownButton(ui->layer_down);
layer_helper->setUpButton(ui->layer_up); layer_helper->setUpButton(ui->layer_up);
layer_helper->setEditButton(ui->layer_edit);
connect(layer_helper, SIGNAL(tableUpdateNeeded()), this, SLOT(updateLayers())); connect(layer_helper, SIGNAL(tableUpdateNeeded()), this, SLOT(updateLayers()));
connect(layer_helper, SIGNAL(selectionChanged(int)), this, SLOT(selectLayer(int))); 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 = new FreeFormHelper(this);
form_helper->setApplyButton(ui->button_apply); 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) void MainTexturesForm::selectPreset(int preset)
{ {
texturesAutoPreset(textures, (TexturesPreset)preset); texturesAutoPreset(textures, (TexturesPreset)preset);

View file

@ -31,6 +31,7 @@ public slots:
void updateLayers(); void updateLayers();
void selectLayer(int layer); void selectLayer(int layer);
void editLayer(int layer);
void selectPreset(int preset); void selectPreset(int preset);
private: private:

View file

@ -349,44 +349,44 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QPushButton" name="button_render">
<property name="text">
<string>Render preview</string>
</property>
<property name="icon">
<iconset resource="../../../data/ui_pictures.qrc">
<normaloff>:/buttons/logo/images/render.png</normaloff>:/buttons/logo/images/render.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="button_explore">
<property name="text">
<string>Explore in 3D</string>
</property>
<property name="icon">
<iconset resource="../../../data/ui_pictures.qrc">
<normaloff>:/buttons/logo/images/explore.png</normaloff>:/buttons/logo/images/explore.png</iconset>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>
<item>
<widget class="QPushButton" name="button_explore">
<property name="text">
<string>Explore in 3D</string>
</property>
<property name="icon">
<iconset resource="../../../data/ui_pictures.qrc">
<normaloff>:/buttons/logo/images/explore.png</normaloff>:/buttons/logo/images/explore.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="button_render">
<property name="text">
<string>Render preview</string>
</property>
<property name="icon">
<iconset resource="../../../data/ui_pictures.qrc">
<normaloff>:/buttons/logo/images/render.png</normaloff>:/buttons/logo/images/render.png</iconset>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item> <item>
<widget class="QGroupBox" name="groupBox_4"> <widget class="QGroupBox" name="groupBox_4">
<property name="title"> <property name="title">