diff --git a/src/editing/common/freeformhelper.cpp b/src/editing/common/freeformhelper.cpp index 5ea3724..3fbde3b 100644 --- a/src/editing/common/freeformhelper.cpp +++ b/src/editing/common/freeformhelper.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include "mainwindow.h" #include "dialogrender.h" #include "dialogexplorer.h" @@ -24,6 +25,7 @@ FreeFormHelper::FreeFormHelper(QWidget* form_widget) _button_apply = NULL; _button_revert = NULL; + _button_presets = NULL; } FreeFormHelper::~FreeFormHelper() @@ -79,115 +81,86 @@ void FreeFormHelper::startManaging() void FreeFormHelper::addPreview(BasePreview* preview, PreviewRenderer* renderer) { - if (preview && preview->inherits("BasePreview")) - { - _previews.append(preview); - preview->setRenderer(renderer); - } -} - -void FreeFormHelper::addPreview(QString widget_name, PreviewRenderer* renderer) -{ - addPreview(_form_widget->findChild(widget_name), renderer); + _previews.append(preview); + preview->setRenderer(renderer); } void FreeFormHelper::addDoubleInputSlider(WidgetSliderDecimal* slider, double* value, double min, double max, double small_step, double large_step) { - if (slider && slider->inherits("WidgetSliderDecimal")) - { - _inputs_decimal.append(slider); + _inputs_decimal.append(slider); - slider->setDecimalRange(min, max, small_step, large_step); - slider->setDecimalValue(*value); + slider->setDecimalRange(min, max, small_step, large_step); + slider->setDecimalValue(*value); - slider->setProperty("data_pointer", QVariant::fromValue(value)); + slider->setProperty("data_pointer", QVariant::fromValue(value)); - connect(slider, SIGNAL(decimalValueChanged(double)), this, SLOT(processDecimalChange(double))); - } -} - -void FreeFormHelper::addDoubleInputSlider(QString widget_name, double* value, double min, double max, double small_step, double large_step) -{ - addDoubleInputSlider(_form_widget->findChild(widget_name), value, min, max, small_step, large_step); + connect(slider, SIGNAL(decimalValueChanged(double)), this, SLOT(processDecimalChange(double))); } void FreeFormHelper::setApplyButton(QPushButton* button) { - if (button && button->inherits("QPushButton")) - { - _button_apply = button; - button->setEnabled(_data_changed); + _button_apply = button; + button->setEnabled(_data_changed); - connect(button, SIGNAL(clicked()), this, SLOT(processApplyClicked())); - } -} - -void FreeFormHelper::setApplyButton(QString widget_name) -{ - setApplyButton(_form_widget->findChild(widget_name)); + connect(button, SIGNAL(clicked()), this, SLOT(processApplyClicked())); } void FreeFormHelper::setRevertButton(QPushButton* button) { - if (button && button->inherits("QPushButton")) - { - _button_revert = button; - button->setEnabled(_data_changed); + _button_revert = button; + button->setEnabled(_data_changed); - connect(button, SIGNAL(clicked()), this, SLOT(processRevertClicked())); - } -} - -void FreeFormHelper::setRevertButton(QString widget_name) -{ - setRevertButton(_form_widget->findChild(widget_name)); + connect(button, SIGNAL(clicked()), this, SLOT(processRevertClicked())); } void FreeFormHelper::setExploreButton(QPushButton* button) { - if (button && button->inherits("QPushButton")) - { - _button_explore = button; + _button_explore = button; - button->setToolTip(tr("Explore the scenery in 3D, with current changes applied")); + button->setToolTip(tr("Explore the scenery in 3D, with current changes applied")); - connect(button, SIGNAL(clicked()), this, SLOT(processExploreClicked())); - } -} - -void FreeFormHelper::setExploreButton(QString widget_name) -{ - setExploreButton(_form_widget->findChild(widget_name)); + connect(button, SIGNAL(clicked()), this, SLOT(processExploreClicked())); } void FreeFormHelper::setRenderButton(QPushButton* button) { - if (button && button->inherits("QPushButton")) - { - _button_render = button; + _button_render = button; - button->setToolTip(tr("Quick render preview, with current changes applied")); + button->setToolTip(tr("Quick render preview, with current changes applied")); - connect(button, SIGNAL(clicked()), this, SLOT(processRenderClicked())); - } -} - -void FreeFormHelper::setRenderButton(QString widget_name) -{ - setRenderButton(_form_widget->findChild(widget_name)); + connect(button, SIGNAL(clicked()), this, SLOT(processRenderClicked())); } void FreeFormHelper::setLabelText(QLabel* label, QString text) { - if (label && label->inherits("QLabel")) - { - label->setText(text); - } + label->setText(text); } -void FreeFormHelper::setLabelText(QString widget_name, QString text) +void FreeFormHelper::addPreset(const QString& name) { - setLabelText(_form_widget->findChild(widget_name), text); + _presets << name; +} + +void FreeFormHelper::setPresetButton(QPushButton* button) +{ + _button_presets = button; + connect(button, SIGNAL(clicked()), this, SLOT(processPresetClicked())); +} + +void FreeFormHelper::processPresetClicked() +{ + bool ok; + QString item = QInputDialog::getItem(_form_widget, tr("Choose a preset"), tr("Preset settings : "), _presets, 0, false, &ok); + + if (ok && !item.isEmpty()) + { + int preset = _presets.indexOf(item); + if (preset >= 0) + { + emit presetSelected(preset); + emit needLocalRefreshing(); + } + } } void FreeFormHelper::openDialog(QDialog* dialog) diff --git a/src/editing/common/freeformhelper.h b/src/editing/common/freeformhelper.h index 5eb0383..c651381 100644 --- a/src/editing/common/freeformhelper.h +++ b/src/editing/common/freeformhelper.h @@ -1,6 +1,9 @@ #ifndef FREEFORMHELPER_H #define FREEFORMHELPER_H +#include +#include + #include "widgetsliderdecimal.h" #include "../basepreview.h" @@ -18,25 +21,15 @@ public: void startManaging(); void addPreview(BasePreview* preview, PreviewRenderer* renderer); - void addPreview(QString widget_name, PreviewRenderer* renderer); - void addDoubleInputSlider(WidgetSliderDecimal* slider, double* value, double min=0.0, double max=1.0, double small_step=0.0, double large_step=0.0); - void addDoubleInputSlider(QString widget_name, double* value, double min=0.0, double max=1.0, double small_step=0.0, double large_step=0.0); - void setApplyButton(QPushButton* button); - void setApplyButton(QString widget_name); - void setRevertButton(QPushButton* button); - void setRevertButton(QString widget_name); - void setExploreButton(QPushButton* button); - void setExploreButton(QString widget_name); - void setRenderButton(QPushButton* button); - void setRenderButton(QString widget_name); - void setLabelText(QLabel* label, QString text); - void setLabelText(QString widget_name, QString text); + + void setPresetButton(QPushButton* button); + void addPreset(const QString& name); void openDialog(QDialog* dialog); void gotoMainTab(int position); @@ -45,6 +38,8 @@ signals: void revertClicked(); void applyClicked(); + void presetSelected(int position); + void needLocalRefreshing(); void needGlobalRefreshing(); void needReverting(); @@ -59,6 +54,7 @@ public slots: void processExploreClicked(); void processRenderClicked(); void processDecimalChange(double value); + void processPresetClicked(); protected: bool eventFilter(QObject* object, QEvent* event); @@ -68,6 +64,9 @@ private: bool _data_changed; + QPushButton* _button_presets; + QStringList _presets; + QVector _previews; QVector _inputs_decimal; diff --git a/src/editing/dialogrender.cpp b/src/editing/dialogrender.cpp index 00a842c..9e6c17e 100644 --- a/src/editing/dialogrender.cpp +++ b/src/editing/dialogrender.cpp @@ -58,10 +58,10 @@ private: RenderParams _params; }; -class RenderArea:public QWidget +class _RenderArea:public QWidget { public: - RenderArea(QWidget* parent): + _RenderArea(QWidget* parent): QWidget(parent) { setMinimumSize(800, 600); @@ -91,7 +91,7 @@ DialogRender::DialogRender(QWidget *parent, Renderer* renderer): _scroll = new QScrollArea(this); _scroll->setAlignment(Qt::AlignCenter); - area = new RenderArea(_scroll); + area = new _RenderArea(_scroll); _scroll->setWidget(area); layout()->addWidget(_scroll); diff --git a/src/editing/formwater.cpp b/src/editing/formwater.cpp index d362036..330f7d3 100644 --- a/src/editing/formwater.cpp +++ b/src/editing/formwater.cpp @@ -27,7 +27,7 @@ public: addOsd(QString("geolocation")); addToggle("highlight", tr("Coverage highlight"), true); - configScaling(20.0, 1000.0, 20.0, 50.0); + configScaling(20.0, 1000.0, 20.0, 200.0); configScrolling(-1000.0, 1000.0, 0.0, -1000.0, 1000.0, 0.0); } protected: diff --git a/src/editing/lighting/DialogMaterialEditor.ui b/src/editing/lighting/DialogMaterialEditor.ui index 9943633..9c13a87 100644 --- a/src/editing/lighting/DialogMaterialEditor.ui +++ b/src/editing/lighting/DialogMaterialEditor.ui @@ -2,6 +2,9 @@ DialogMaterialEditor + + Qt::ApplicationModal + 0 @@ -11,7 +14,10 @@ - Dialog + Paysages 3D - Material editor + + + true @@ -38,9 +44,6 @@ This controls the way the surface diffuses its inner color in all directions, when a light source reaches it - - true - @@ -155,9 +158,6 @@ Amount and direction of light that is directly reflected from an incoming source (useful for shiny things) - - true - diff --git a/src/editing/terrain/mainterrainform.cpp b/src/editing/terrain/mainterrainform.cpp index c9e86f0..6df0940 100644 --- a/src/editing/terrain/mainterrainform.cpp +++ b/src/editing/terrain/mainterrainform.cpp @@ -56,11 +56,11 @@ void MainTerrainForm::refreshFromLocalData() qint64 memused = terrainGetMemoryStats(_terrain); if (memused > 0) { - _form_helper->setLabelText("label_painting_info", tr("Memory used by sculpted data: %1").arg(getHumanMemory(memused))); + _form_helper->setLabelText(ui->label_painting_info, tr("Memory used by sculpted data: %1").arg(getHumanMemory(memused))); } else { - _form_helper->setLabelText("label_painting_info", tr("No manual scuplting done")); + _form_helper->setLabelText(ui->label_painting_info, tr("No manual scuplting done")); } ui->widget_base_noise_preview->setNoise(_terrain->_height_noise); diff --git a/src/editing/terrain/previewterrainshape.cpp b/src/editing/terrain/previewterrainshape.cpp index 0919370..5d8446b 100644 --- a/src/editing/terrain/previewterrainshape.cpp +++ b/src/editing/terrain/previewterrainshape.cpp @@ -17,7 +17,7 @@ void PreviewTerrainShape::bindEvent(BasePreview* preview) preview->addOsd(QString("geolocation")); //preview->addToggle("highlight", tr("Coverage highlight"), true); - preview->configScaling(20.0, 1000.0, 20.0, 50.0); + preview->configScaling(20.0, 1000.0, 20.0, 200.0); preview->configScrolling(-1000.0, 1000.0, 0.0, -1000.0, 1000.0, 0.0); } diff --git a/src/editing/terrain/widgetterrainbasenoisepreview.cpp b/src/editing/terrain/widgetterrainbasenoisepreview.cpp index ba97b32..8769da6 100644 --- a/src/editing/terrain/widgetterrainbasenoisepreview.cpp +++ b/src/editing/terrain/widgetterrainbasenoisepreview.cpp @@ -18,8 +18,8 @@ void WidgetTerrainBaseNoisePreview::setNoise(NoiseGenerator* noise) void WidgetTerrainBaseNoisePreview::doDrawing(QPainter* painter) { - painter->setBrush(Qt::SolidPattern); - painter->drawRect(rect()); + painter->fillRect(rect(), QColor(20, 40, 80)); + painter->setPen(QColor(220, 210, 180)); int height = this->height(); @@ -37,7 +37,6 @@ void WidgetTerrainBaseNoisePreview::doDrawing(QPainter* painter) { value = noiseGet1DTotal(_noise, 100.0 * ((double)x) / factor); - painter->setPen(Qt::white); painter->drawLine(x, height - 1 - (value - minvalue) * factor, x, height - 1); } } diff --git a/src/editing/textures/maintexturesform.cpp b/src/editing/textures/maintexturesform.cpp index 602c8b2..9c71c6b 100644 --- a/src/editing/textures/maintexturesform.cpp +++ b/src/editing/textures/maintexturesform.cpp @@ -33,6 +33,12 @@ MainTexturesForm::MainTexturesForm(QWidget *parent) : QWidget(parent), ui(new Ui preview_layer_coverage->setTextures(textures); form_helper->addPreview(ui->preview_coverage, preview_layer_coverage); + form_helper->addPreset(tr("Rocks with grass")); + form_helper->addPreset(tr("Snow covered mountains")); + form_helper->addPreset(tr("Arid canyons")); + form_helper->setPresetButton(ui->button_preset); + connect(form_helper, SIGNAL(presetSelected(int)), this, SLOT(selectPreset(int))); + connect(layer_helper, SIGNAL(layersChanged()), form_helper, SLOT(processDataChange())); } @@ -92,6 +98,11 @@ void MainTexturesForm::selectLayer(int layer) } } +void MainTexturesForm::selectPreset(int preset) +{ + texturesAutoPreset(textures, (TexturesPreset)preset); +} + void MainTexturesForm::updateLocalDataFromScenery() { sceneryGetTextures(textures); diff --git a/src/rendering/textures/tex_presets.c b/src/rendering/textures/tex_presets.c index 32afe62..006c050 100644 --- a/src/rendering/textures/tex_presets.c +++ b/src/rendering/textures/tex_presets.c @@ -16,8 +16,14 @@ void texturesAutoPreset(TexturesDefinition* definition, TexturesPreset preset) layersSetName(definition->layers, 1, "Grass"); } else if (preset == TEXTURES_PRESET_ALPS) - { - /* TODO */ +{ + layer = layersGetLayer(definition->layers, layersAddLayer(definition->layers, NULL)); + texturesLayerAutoPreset(layer, TEXTURES_LAYER_PRESET_ROCK); + layersSetName(definition->layers, 0, "Ground"); + + layer = layersGetLayer(definition->layers, layersAddLayer(definition->layers, NULL)); + texturesLayerAutoPreset(layer, TEXTURES_LAYER_PRESET_SNOW); + layersSetName(definition->layers, 1, "Snow"); } else if (preset == TEXTURES_PRESET_CANYON) {