paysages : Terrain canvas (WIP).

git-svn-id: https://subversion.assembla.com/svn/thunderk/paysages@387 b1fd45b6-86a6-48da-8261-f70d1f35bdcc
This commit is contained in:
Michaël Lemaire 2012-07-11 13:18:43 +00:00 committed by ThunderK
parent aa62e46702
commit e1def5c5d5
5 changed files with 53 additions and 16 deletions

View file

@ -11,11 +11,26 @@ BaseFormLayer::~BaseFormLayer()
layersDelete(_layers_modified); 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() void BaseFormLayer::configChangeEvent()
{ {
/*texturesLayerCopyDefinition(&_layer, texturesGetLayer(&_definition, currentLayer())); layerApply(layersGetLayer(_layers_modified, currentLayer()));
layersValidate(_layers_modified);
layersValidate(_layers_modified);*/
BaseForm::configChangeEvent(); BaseForm::configChangeEvent();
} }
@ -62,7 +77,7 @@ void BaseFormLayer::layerRenamedEvent(int layer, QString new_name)
void BaseFormLayer::layerSelectedEvent(int layer) void BaseFormLayer::layerSelectedEvent(int layer)
{ {
//texturesLayerCopyDefinition(texturesGetLayer(&_definition, layer), &_layer); layerGetCopy(layersGetLayer(_layers_modified, layer));
BaseForm::layerSelectedEvent(layer); BaseForm::layerSelectedEvent(layer);
} }

View file

@ -14,7 +14,15 @@ public:
BaseFormLayer(QWidget* parent, Layers* layers); BaseFormLayer(QWidget* parent, Layers* layers);
~BaseFormLayer(); ~BaseFormLayer();
public slots:
virtual void revertConfig();
virtual void applyConfig();
protected: protected:
virtual void layerGetCopy(void* layer_definition) = 0;
virtual void layerApply(void* layer_definition) = 0;
private:
virtual QStringList getLayers(); virtual QStringList getLayers();
virtual void layerAddedEvent(); virtual void layerAddedEvent();
virtual void layerDeletedEvent(int layer); virtual void layerDeletedEvent(int layer);

View file

@ -4,19 +4,32 @@
FormTerrainCanvas::FormTerrainCanvas(QWidget *parent, Layers* layers): FormTerrainCanvas::FormTerrainCanvas(QWidget *parent, Layers* layers):
BaseFormLayer(parent, 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);
} }

View file

@ -4,6 +4,7 @@
#include <QWidget> #include <QWidget>
#include "basepreview.h" #include "basepreview.h"
#include "baseformlayer.h" #include "baseformlayer.h"
#include "../lib_paysages/terraincanvas.h"
class FormTerrainCanvas : public BaseFormLayer class FormTerrainCanvas : public BaseFormLayer
{ {
@ -11,15 +12,14 @@ class FormTerrainCanvas : public BaseFormLayer
public: public:
FormTerrainCanvas(QWidget* parent, Layers* layers); FormTerrainCanvas(QWidget* parent, Layers* layers);
~FormTerrainCanvas();
public slots:
virtual void revertConfig(); protected:
virtual void applyConfig(); virtual void layerGetCopy(void* layer_definition);
virtual void layerApply(void* layer_definition);
protected slots:
virtual void configChangeEvent();
private: private:
TerrainCanvas* _definition;
// BasePreview* previewHeight; // BasePreview* previewHeight;
// BasePreview* previewColor; // BasePreview* previewColor;
}; };

View file

@ -28,5 +28,6 @@ void InputLayers::editLayers()
{ {
if (DialogLayers::editLayers(_control, _value, _label->text(), _form_builder)) if (DialogLayers::editLayers(_control, _value, _label->text(), _form_builder))
{ {
applyValue();
} }
} }