From e1def5c5d5061f7ce908496f68a4e922e22906ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Lemaire?= Date: Wed, 11 Jul 2012 13:18:43 +0000 Subject: [PATCH] paysages : Terrain canvas (WIP). git-svn-id: https://subversion.assembla.com/svn/thunderk/paysages@387 b1fd45b6-86a6-48da-8261-f70d1f35bdcc --- gui_qt/baseformlayer.cpp | 21 ++++++++++++++++++--- gui_qt/baseformlayer.h | 8 ++++++++ gui_qt/formterraincanvas.cpp | 25 +++++++++++++++++++------ gui_qt/formterraincanvas.h | 14 +++++++------- gui_qt/inputlayers.cpp | 1 + 5 files changed, 53 insertions(+), 16 deletions(-) diff --git a/gui_qt/baseformlayer.cpp b/gui_qt/baseformlayer.cpp index b94aac0..38fb119 100644 --- a/gui_qt/baseformlayer.cpp +++ b/gui_qt/baseformlayer.cpp @@ -11,11 +11,26 @@ BaseFormLayer::~BaseFormLayer() layersDelete(_layers_modified); } +void BaseFormLayer::revertConfig() +{ + layersCopy(_layers_original, _layers_modified); + layerSelectedEvent(currentLayer()); + + BaseForm::revertConfig(); +} + +void BaseFormLayer::applyConfig() +{ + layersCopy(_layers_modified, _layers_original); + + BaseForm::applyConfig(); +} + void BaseFormLayer::configChangeEvent() { - /*texturesLayerCopyDefinition(&_layer, texturesGetLayer(&_definition, currentLayer())); + layerApply(layersGetLayer(_layers_modified, currentLayer())); + layersValidate(_layers_modified); - layersValidate(_layers_modified);*/ BaseForm::configChangeEvent(); } @@ -62,7 +77,7 @@ void BaseFormLayer::layerRenamedEvent(int layer, QString new_name) void BaseFormLayer::layerSelectedEvent(int layer) { - //texturesLayerCopyDefinition(texturesGetLayer(&_definition, layer), &_layer); + layerGetCopy(layersGetLayer(_layers_modified, layer)); BaseForm::layerSelectedEvent(layer); } diff --git a/gui_qt/baseformlayer.h b/gui_qt/baseformlayer.h index 1b3ce35..8244b63 100644 --- a/gui_qt/baseformlayer.h +++ b/gui_qt/baseformlayer.h @@ -14,7 +14,15 @@ public: BaseFormLayer(QWidget* parent, Layers* layers); ~BaseFormLayer(); +public slots: + virtual void revertConfig(); + virtual void applyConfig(); + protected: + virtual void layerGetCopy(void* layer_definition) = 0; + virtual void layerApply(void* layer_definition) = 0; + +private: virtual QStringList getLayers(); virtual void layerAddedEvent(); virtual void layerDeletedEvent(int layer); diff --git a/gui_qt/formterraincanvas.cpp b/gui_qt/formterraincanvas.cpp index cc3d38b..7239bb7 100644 --- a/gui_qt/formterraincanvas.cpp +++ b/gui_qt/formterraincanvas.cpp @@ -4,19 +4,32 @@ FormTerrainCanvas::FormTerrainCanvas(QWidget *parent, Layers* layers): BaseFormLayer(parent, layers) { + _definition = terrainCanvasCreate(); + + // TODO Area + addInputDouble(tr("Apply at height"), &_definition->offset_z, -20.0, 20.0, 0.1, 1.0); + // TODO Height map + addInputDouble(tr("Canvas height"), &_definition->height_factor, 0.0, 20.0, 0.1, 1.0); + addInputNoise(tr("Detail noise"), _definition->detail_noise); + addInputDouble(tr("Detail noise height"), &_definition->detail_height_factor, 0.0, 20.0, 0.1, 1.0); + addInputDouble(tr("Detail noise scaling"), &_definition->detail_scaling, 0.0, 20.0, 0.1, 1.0); + // TODO Mask mode + // TODO Mask smoothing + + revertConfig(); } -void FormTerrainCanvas::revertConfig() +FormTerrainCanvas::~FormTerrainCanvas() { - BaseFormLayer::revertConfig(); + terrainCanvasDelete(_definition); } -void FormTerrainCanvas::applyConfig() +void FormTerrainCanvas::layerGetCopy(void* layer_definition) { - BaseFormLayer::applyConfig(); + terrainCanvasCopy((TerrainCanvas*)layer_definition, _definition); } -void FormTerrainCanvas::configChangeEvent() +void FormTerrainCanvas::layerApply(void* layer_definition) { - BaseFormLayer::configChangeEvent(); + terrainCanvasCopy(_definition, (TerrainCanvas*)layer_definition); } diff --git a/gui_qt/formterraincanvas.h b/gui_qt/formterraincanvas.h index 4b8ccde..448199d 100644 --- a/gui_qt/formterraincanvas.h +++ b/gui_qt/formterraincanvas.h @@ -4,6 +4,7 @@ #include #include "basepreview.h" #include "baseformlayer.h" +#include "../lib_paysages/terraincanvas.h" class FormTerrainCanvas : public BaseFormLayer { @@ -11,15 +12,14 @@ class FormTerrainCanvas : public BaseFormLayer public: FormTerrainCanvas(QWidget* parent, Layers* layers); - -public slots: - virtual void revertConfig(); - virtual void applyConfig(); - -protected slots: - virtual void configChangeEvent(); + ~FormTerrainCanvas(); + +protected: + virtual void layerGetCopy(void* layer_definition); + virtual void layerApply(void* layer_definition); private: + TerrainCanvas* _definition; // BasePreview* previewHeight; // BasePreview* previewColor; }; diff --git a/gui_qt/inputlayers.cpp b/gui_qt/inputlayers.cpp index eae813f..e067040 100644 --- a/gui_qt/inputlayers.cpp +++ b/gui_qt/inputlayers.cpp @@ -28,5 +28,6 @@ void InputLayers::editLayers() { if (DialogLayers::editLayers(_control, _value, _label->text(), _form_builder)) { + applyValue(); } }