Added presets to FreeFormHelper + small fixes
This commit is contained in:
parent
171df529fa
commit
c46afa4152
10 changed files with 93 additions and 105 deletions
|
@ -7,6 +7,7 @@
|
||||||
#include <QSlider>
|
#include <QSlider>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
#include <QInputDialog>
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "dialogrender.h"
|
#include "dialogrender.h"
|
||||||
#include "dialogexplorer.h"
|
#include "dialogexplorer.h"
|
||||||
|
@ -24,6 +25,7 @@ FreeFormHelper::FreeFormHelper(QWidget* form_widget)
|
||||||
|
|
||||||
_button_apply = NULL;
|
_button_apply = NULL;
|
||||||
_button_revert = NULL;
|
_button_revert = NULL;
|
||||||
|
_button_presets = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
FreeFormHelper::~FreeFormHelper()
|
FreeFormHelper::~FreeFormHelper()
|
||||||
|
@ -78,22 +80,12 @@ void FreeFormHelper::startManaging()
|
||||||
}
|
}
|
||||||
|
|
||||||
void FreeFormHelper::addPreview(BasePreview* preview, PreviewRenderer* renderer)
|
void FreeFormHelper::addPreview(BasePreview* preview, PreviewRenderer* renderer)
|
||||||
{
|
|
||||||
if (preview && preview->inherits("BasePreview"))
|
|
||||||
{
|
{
|
||||||
_previews.append(preview);
|
_previews.append(preview);
|
||||||
preview->setRenderer(renderer);
|
preview->setRenderer(renderer);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void FreeFormHelper::addPreview(QString widget_name, PreviewRenderer* renderer)
|
|
||||||
{
|
|
||||||
addPreview(_form_widget->findChild<BasePreview*>(widget_name), renderer);
|
|
||||||
}
|
|
||||||
|
|
||||||
void FreeFormHelper::addDoubleInputSlider(WidgetSliderDecimal* slider, double* value, double min, double max, double small_step, double large_step)
|
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);
|
||||||
|
|
||||||
|
@ -104,48 +96,24 @@ void FreeFormHelper::addDoubleInputSlider(WidgetSliderDecimal* slider, double* v
|
||||||
|
|
||||||
connect(slider, SIGNAL(decimalValueChanged(double)), this, SLOT(processDecimalChange(double)));
|
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<WidgetSliderDecimal*>(widget_name), value, min, max, small_step, large_step);
|
|
||||||
}
|
|
||||||
|
|
||||||
void FreeFormHelper::setApplyButton(QPushButton* button)
|
void FreeFormHelper::setApplyButton(QPushButton* button)
|
||||||
{
|
|
||||||
if (button && button->inherits("QPushButton"))
|
|
||||||
{
|
{
|
||||||
_button_apply = button;
|
_button_apply = button;
|
||||||
button->setEnabled(_data_changed);
|
button->setEnabled(_data_changed);
|
||||||
|
|
||||||
connect(button, SIGNAL(clicked()), this, SLOT(processApplyClicked()));
|
connect(button, SIGNAL(clicked()), this, SLOT(processApplyClicked()));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void FreeFormHelper::setApplyButton(QString widget_name)
|
|
||||||
{
|
|
||||||
setApplyButton(_form_widget->findChild<QPushButton*>(widget_name));
|
|
||||||
}
|
|
||||||
|
|
||||||
void FreeFormHelper::setRevertButton(QPushButton* button)
|
void FreeFormHelper::setRevertButton(QPushButton* button)
|
||||||
{
|
|
||||||
if (button && button->inherits("QPushButton"))
|
|
||||||
{
|
{
|
||||||
_button_revert = button;
|
_button_revert = button;
|
||||||
button->setEnabled(_data_changed);
|
button->setEnabled(_data_changed);
|
||||||
|
|
||||||
connect(button, SIGNAL(clicked()), this, SLOT(processRevertClicked()));
|
connect(button, SIGNAL(clicked()), this, SLOT(processRevertClicked()));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void FreeFormHelper::setRevertButton(QString widget_name)
|
|
||||||
{
|
|
||||||
setRevertButton(_form_widget->findChild<QPushButton*>(widget_name));
|
|
||||||
}
|
|
||||||
|
|
||||||
void FreeFormHelper::setExploreButton(QPushButton* button)
|
void FreeFormHelper::setExploreButton(QPushButton* button)
|
||||||
{
|
|
||||||
if (button && button->inherits("QPushButton"))
|
|
||||||
{
|
{
|
||||||
_button_explore = button;
|
_button_explore = button;
|
||||||
|
|
||||||
|
@ -153,16 +121,8 @@ void FreeFormHelper::setExploreButton(QPushButton* button)
|
||||||
|
|
||||||
connect(button, SIGNAL(clicked()), this, SLOT(processExploreClicked()));
|
connect(button, SIGNAL(clicked()), this, SLOT(processExploreClicked()));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void FreeFormHelper::setExploreButton(QString widget_name)
|
|
||||||
{
|
|
||||||
setExploreButton(_form_widget->findChild<QPushButton*>(widget_name));
|
|
||||||
}
|
|
||||||
|
|
||||||
void FreeFormHelper::setRenderButton(QPushButton* button)
|
void FreeFormHelper::setRenderButton(QPushButton* button)
|
||||||
{
|
|
||||||
if (button && button->inherits("QPushButton"))
|
|
||||||
{
|
{
|
||||||
_button_render = button;
|
_button_render = button;
|
||||||
|
|
||||||
|
@ -170,24 +130,37 @@ void FreeFormHelper::setRenderButton(QPushButton* button)
|
||||||
|
|
||||||
connect(button, SIGNAL(clicked()), this, SLOT(processRenderClicked()));
|
connect(button, SIGNAL(clicked()), this, SLOT(processRenderClicked()));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void FreeFormHelper::setRenderButton(QString widget_name)
|
|
||||||
{
|
|
||||||
setRenderButton(_form_widget->findChild<QPushButton*>(widget_name));
|
|
||||||
}
|
|
||||||
|
|
||||||
void FreeFormHelper::setLabelText(QLabel* label, QString text)
|
void FreeFormHelper::setLabelText(QLabel* label, QString text)
|
||||||
{
|
|
||||||
if (label && label->inherits("QLabel"))
|
|
||||||
{
|
{
|
||||||
label->setText(text);
|
label->setText(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FreeFormHelper::addPreset(const QString& name)
|
||||||
|
{
|
||||||
|
_presets << name;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FreeFormHelper::setLabelText(QString widget_name, QString text)
|
void FreeFormHelper::setPresetButton(QPushButton* button)
|
||||||
{
|
{
|
||||||
setLabelText(_form_widget->findChild<QLabel*>(widget_name), text);
|
_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)
|
void FreeFormHelper::openDialog(QDialog* dialog)
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
#ifndef FREEFORMHELPER_H
|
#ifndef FREEFORMHELPER_H
|
||||||
#define FREEFORMHELPER_H
|
#define FREEFORMHELPER_H
|
||||||
|
|
||||||
|
#include <QVector>
|
||||||
|
#include <QStringList>
|
||||||
|
|
||||||
#include "widgetsliderdecimal.h"
|
#include "widgetsliderdecimal.h"
|
||||||
#include "../basepreview.h"
|
#include "../basepreview.h"
|
||||||
|
|
||||||
|
@ -18,25 +21,15 @@ public:
|
||||||
void startManaging();
|
void startManaging();
|
||||||
|
|
||||||
void addPreview(BasePreview* preview, PreviewRenderer* renderer);
|
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(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(QPushButton* button);
|
||||||
void setApplyButton(QString widget_name);
|
|
||||||
|
|
||||||
void setRevertButton(QPushButton* button);
|
void setRevertButton(QPushButton* button);
|
||||||
void setRevertButton(QString widget_name);
|
|
||||||
|
|
||||||
void setExploreButton(QPushButton* button);
|
void setExploreButton(QPushButton* button);
|
||||||
void setExploreButton(QString widget_name);
|
|
||||||
|
|
||||||
void setRenderButton(QPushButton* button);
|
void setRenderButton(QPushButton* button);
|
||||||
void setRenderButton(QString widget_name);
|
|
||||||
|
|
||||||
void setLabelText(QLabel* label, QString text);
|
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 openDialog(QDialog* dialog);
|
||||||
void gotoMainTab(int position);
|
void gotoMainTab(int position);
|
||||||
|
@ -45,6 +38,8 @@ signals:
|
||||||
void revertClicked();
|
void revertClicked();
|
||||||
void applyClicked();
|
void applyClicked();
|
||||||
|
|
||||||
|
void presetSelected(int position);
|
||||||
|
|
||||||
void needLocalRefreshing();
|
void needLocalRefreshing();
|
||||||
void needGlobalRefreshing();
|
void needGlobalRefreshing();
|
||||||
void needReverting();
|
void needReverting();
|
||||||
|
@ -59,6 +54,7 @@ public slots:
|
||||||
void processExploreClicked();
|
void processExploreClicked();
|
||||||
void processRenderClicked();
|
void processRenderClicked();
|
||||||
void processDecimalChange(double value);
|
void processDecimalChange(double value);
|
||||||
|
void processPresetClicked();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool eventFilter(QObject* object, QEvent* event);
|
bool eventFilter(QObject* object, QEvent* event);
|
||||||
|
@ -68,6 +64,9 @@ private:
|
||||||
|
|
||||||
bool _data_changed;
|
bool _data_changed;
|
||||||
|
|
||||||
|
QPushButton* _button_presets;
|
||||||
|
QStringList _presets;
|
||||||
|
|
||||||
QVector<BasePreview*> _previews;
|
QVector<BasePreview*> _previews;
|
||||||
QVector<WidgetSliderDecimal*> _inputs_decimal;
|
QVector<WidgetSliderDecimal*> _inputs_decimal;
|
||||||
|
|
||||||
|
|
|
@ -58,10 +58,10 @@ private:
|
||||||
RenderParams _params;
|
RenderParams _params;
|
||||||
};
|
};
|
||||||
|
|
||||||
class RenderArea:public QWidget
|
class _RenderArea:public QWidget
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
RenderArea(QWidget* parent):
|
_RenderArea(QWidget* parent):
|
||||||
QWidget(parent)
|
QWidget(parent)
|
||||||
{
|
{
|
||||||
setMinimumSize(800, 600);
|
setMinimumSize(800, 600);
|
||||||
|
@ -91,7 +91,7 @@ DialogRender::DialogRender(QWidget *parent, Renderer* renderer):
|
||||||
|
|
||||||
_scroll = new QScrollArea(this);
|
_scroll = new QScrollArea(this);
|
||||||
_scroll->setAlignment(Qt::AlignCenter);
|
_scroll->setAlignment(Qt::AlignCenter);
|
||||||
area = new RenderArea(_scroll);
|
area = new _RenderArea(_scroll);
|
||||||
_scroll->setWidget(area);
|
_scroll->setWidget(area);
|
||||||
layout()->addWidget(_scroll);
|
layout()->addWidget(_scroll);
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ public:
|
||||||
addOsd(QString("geolocation"));
|
addOsd(QString("geolocation"));
|
||||||
addToggle("highlight", tr("Coverage highlight"), true);
|
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);
|
configScrolling(-1000.0, 1000.0, 0.0, -1000.0, 1000.0, 0.0);
|
||||||
}
|
}
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -2,6 +2,9 @@
|
||||||
<ui version="4.0">
|
<ui version="4.0">
|
||||||
<class>DialogMaterialEditor</class>
|
<class>DialogMaterialEditor</class>
|
||||||
<widget class="QDialog" name="DialogMaterialEditor">
|
<widget class="QDialog" name="DialogMaterialEditor">
|
||||||
|
<property name="windowModality">
|
||||||
|
<enum>Qt::ApplicationModal</enum>
|
||||||
|
</property>
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
|
@ -11,7 +14,10 @@
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Dialog</string>
|
<string>Paysages 3D - Material editor</string>
|
||||||
|
</property>
|
||||||
|
<property name="modal">
|
||||||
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
<item>
|
<item>
|
||||||
|
@ -38,9 +44,6 @@
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>This controls the way the surface diffuses its inner color in all directions, when a light source reaches it</string>
|
<string>This controls the way the surface diffuses its inner color in all directions, when a light source reaches it</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="wordWrap">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
|
@ -155,9 +158,6 @@
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Amount and direction of light that is directly reflected from an incoming source (useful for shiny things)</string>
|
<string>Amount and direction of light that is directly reflected from an incoming source (useful for shiny things)</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="wordWrap">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
|
|
|
@ -56,11 +56,11 @@ void MainTerrainForm::refreshFromLocalData()
|
||||||
qint64 memused = terrainGetMemoryStats(_terrain);
|
qint64 memused = terrainGetMemoryStats(_terrain);
|
||||||
if (memused > 0)
|
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
|
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);
|
ui->widget_base_noise_preview->setNoise(_terrain->_height_noise);
|
||||||
|
|
|
@ -17,7 +17,7 @@ void PreviewTerrainShape::bindEvent(BasePreview* preview)
|
||||||
preview->addOsd(QString("geolocation"));
|
preview->addOsd(QString("geolocation"));
|
||||||
//preview->addToggle("highlight", tr("Coverage highlight"), true);
|
//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);
|
preview->configScrolling(-1000.0, 1000.0, 0.0, -1000.0, 1000.0, 0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,8 +18,8 @@ void WidgetTerrainBaseNoisePreview::setNoise(NoiseGenerator* noise)
|
||||||
|
|
||||||
void WidgetTerrainBaseNoisePreview::doDrawing(QPainter* painter)
|
void WidgetTerrainBaseNoisePreview::doDrawing(QPainter* painter)
|
||||||
{
|
{
|
||||||
painter->setBrush(Qt::SolidPattern);
|
painter->fillRect(rect(), QColor(20, 40, 80));
|
||||||
painter->drawRect(rect());
|
painter->setPen(QColor(220, 210, 180));
|
||||||
|
|
||||||
int height = this->height();
|
int height = this->height();
|
||||||
|
|
||||||
|
@ -37,7 +37,6 @@ void WidgetTerrainBaseNoisePreview::doDrawing(QPainter* painter)
|
||||||
{
|
{
|
||||||
value = noiseGet1DTotal(_noise, 100.0 * ((double)x) / factor);
|
value = noiseGet1DTotal(_noise, 100.0 * ((double)x) / factor);
|
||||||
|
|
||||||
painter->setPen(Qt::white);
|
|
||||||
painter->drawLine(x, height - 1 - (value - minvalue) * factor, x, height - 1);
|
painter->drawLine(x, height - 1 - (value - minvalue) * factor, x, height - 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,6 +33,12 @@ MainTexturesForm::MainTexturesForm(QWidget *parent) : QWidget(parent), ui(new Ui
|
||||||
preview_layer_coverage->setTextures(textures);
|
preview_layer_coverage->setTextures(textures);
|
||||||
form_helper->addPreview(ui->preview_coverage, preview_layer_coverage);
|
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()));
|
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()
|
void MainTexturesForm::updateLocalDataFromScenery()
|
||||||
{
|
{
|
||||||
sceneryGetTextures(textures);
|
sceneryGetTextures(textures);
|
||||||
|
|
|
@ -17,7 +17,13 @@ void texturesAutoPreset(TexturesDefinition* definition, TexturesPreset preset)
|
||||||
}
|
}
|
||||||
else if (preset == TEXTURES_PRESET_ALPS)
|
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)
|
else if (preset == TEXTURES_PRESET_CANYON)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue