Removed old QtWidget UI

This commit is contained in:
Michaël Lemaire 2015-07-28 19:03:10 +02:00
parent fc15f7d9b8
commit 0585bc4b6f
101 changed files with 3 additions and 10564 deletions

View file

@ -48,9 +48,6 @@ run:build
run_cli:build
LD_LIBRARY_PATH=$(LIBRARY_PATH) ${RUNNER} ${BUILDPATH}/interface/commandline/paysages-cli $(ARGS)
run_legacy:build
LD_LIBRARY_PATH=$(LIBRARY_PATH) ${RUNNER} ${BUILDPATH}/interface/desktop/paysages-gui $(ARGS)
profile:build
LD_LIBRARY_PATH=${LIBRARY_PATH} perf record -g ${BUILDPATH}/interface/modeler/quickapp/paysages-modeler $(ARGS)
perf report -g
@ -70,8 +67,8 @@ package:build
cp $(BUILDPATH)/render/software/libpaysages_render_software.so* paysages3d-linux/lib/
cp $(BUILDPATH)/render/preview/libpaysages_render_preview.so* paysages3d-linux/lib/
cp $(BUILDPATH)/render/opengl/libpaysages_render_opengl.so* paysages3d-linux/lib/
cp $(BUILDPATH)/interface/desktop/paysages-gui paysages3d-linux/lib/
chmod +x paysages3d-linux/lib/paysages-gui
cp $(BUILDPATH)/interface/modeler/quickapp/paysages-modeler paysages3d-linux/lib/
chmod +x paysages3d-linux/lib/paysages-modeler
cp -r data paysages3d-linux/
cp dist/paysages3d.sh paysages3d-linux/
chmod +x paysages3d-linux/paysages3d.sh

2
dist/paysages3d.sh vendored
View file

@ -5,6 +5,6 @@ export LD_LIBRARY_PATH=${SCRIPT_PATH}/lib:"${LD_LIBRARY_PATH}"
cd ${SCRIPT_PATH}
COLLECT_NEEDED=$(ldd lib/paysages-gui | grep -c 'not found')
[ $COLLECT_NEEDED -gt 0 ] && export LD_LIBRARY_PATH=${SCRIPT_PATH}/lib/collected:"${LD_LIBRARY_PATH}"
${SCRIPT_PATH}/lib/paysages-gui
${SCRIPT_PATH}/lib/paysages-modeler
cd - > /dev/null

View file

@ -1,24 +0,0 @@
#include "DesktopScenery.h"
#include "common/mainwindow.h"
static DesktopScenery _main_scenery;
void DesktopScenery::save(PackStream *stream) const
{
Scenery::save(stream);
MainWindow::instance()->guiSave(stream);
}
void DesktopScenery::load(PackStream *stream)
{
Scenery::load(stream);
MainWindow::instance()->guiLoad(stream);
}
DesktopScenery* DesktopScenery::getCurrent()
{
return &_main_scenery;
}

View file

@ -1,17 +0,0 @@
#ifndef DESKTOPSCENERY_H
#define DESKTOPSCENERY_H
#include "desktop_global.h"
#include "Scenery.h"
class DesktopScenery: public Scenery
{
public:
virtual void save(PackStream* stream) const override;
virtual void load(PackStream* stream) override;
static DesktopScenery* getCurrent();
};
#endif // DESKTOPSCENERY_H

View file

@ -1,6 +0,0 @@
#include "WidgetCanvas.h"
WidgetCanvas::WidgetCanvas(QWidget *parent) :
QWidget(parent)
{
}

View file

@ -1,29 +0,0 @@
#ifndef WIDGETCANVAS_H
#define WIDGETCANVAS_H
#include "desktop_global.h"
#include <QWidget>
namespace paysages {
namespace desktop {
/*!
* \brief Widget to display the full content of a Canvas.
*/
class WidgetCanvas : public QWidget
{
Q_OBJECT
public:
explicit WidgetCanvas(QWidget *parent = 0);
signals:
public slots:
};
}
}
#endif // WIDGETCANVAS_H

View file

@ -1,77 +0,0 @@
#include "WidgetPreviewCanvas.h"
#include "tools.h"
#include "Canvas.h"
#include "CanvasPreview.h"
#include <QPainter>
WidgetPreviewCanvas::WidgetPreviewCanvas(QWidget *parent) :
QWidget(parent), canvas(NULL)
{
pixbuf = new QImage();
startTimer(500);
}
WidgetPreviewCanvas::~WidgetPreviewCanvas()
{
delete pixbuf;
}
void WidgetPreviewCanvas::setCanvas(const Canvas *canvas)
{
if (not this->canvas)
{
this->canvas = canvas;
canvas->getPreview()->initLive(this);
}
}
void WidgetPreviewCanvas::setToneMapping(const ColorProfile &profile)
{
if (canvas)
{
canvas->getPreview()->setToneMapping(profile);
canvas->getPreview()->updateLive(this);
update();
}
}
void WidgetPreviewCanvas::paintEvent(QPaintEvent *)
{
QPainter painter(this);
painter.drawImage(0, 0, *pixbuf);
}
void WidgetPreviewCanvas::canvasResized(int width, int height)
{
if (QSize(width, height) != this->size())
{
setMaximumSize(width, height);
setMinimumSize(width, height);
resize(width, height);
delete pixbuf;
pixbuf = new QImage(width, height, QImage::Format_ARGB32);
}
}
void WidgetPreviewCanvas::canvasCleared(const Color &col)
{
pixbuf->fill(colorToQColor(col));
}
void WidgetPreviewCanvas::canvasPainted(int x, int y, const Color &col)
{
pixbuf->setPixel(x, pixbuf->height() - 1 - y, colorToQColor(col).rgb());
}
void WidgetPreviewCanvas::timerEvent(QTimerEvent *)
{
if (canvas)
{
canvas->getPreview()->updateLive(this);
update();
}
}

View file

@ -1,50 +0,0 @@
#ifndef WIDGETPREVIEWCANVAS_H
#define WIDGETPREVIEWCANVAS_H
#include "desktop_global.h"
#include <QWidget>
#include "CanvasLiveClient.h"
namespace paysages {
namespace desktop {
/**
* Widget to display a live-updated preview of a Canvas software rendering.
*/
class WidgetPreviewCanvas : public QWidget, public CanvasLiveClient
{
Q_OBJECT
public:
explicit WidgetPreviewCanvas(QWidget *parent = 0);
virtual ~WidgetPreviewCanvas();
/**
* Set the canvas to watch and display, null to stop watching.
*
* This function must be called from the graphics thread.
*/
void setCanvas(const Canvas *canvas);
/**
* Set the tone mapping to apply to pixel colors.
*/
void setToneMapping(const ColorProfile &profile);
virtual void paintEvent(QPaintEvent* event);
protected:
virtual void canvasResized(int width, int height);
virtual void canvasCleared(const Color &col);
virtual void canvasPainted(int x, int y, const Color &col);
virtual void timerEvent(QTimerEvent *event);
private:
QImage* pixbuf;
const Canvas *canvas;
};
}
}
#endif // WIDGETPREVIEWCANVAS_H

View file

@ -1,532 +0,0 @@
#include "baseform.h"
#include "inputdouble.h"
#include "inputint.h"
#include "inputboolean.h"
#include "inputcolor.h"
#include "inputnoise.h"
#include "inputcurve.h"
#include "inputmaterial.h"
#include "inputenum.h"
#include "inputlayers.h"
#include "BasePreview.h"
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QLabel>
#include <QVariant>
#include <QInputDialog>
#include <QComboBox>
#include <QPushButton>
BaseForm::BaseForm(QWidget* parent, bool auto_apply, bool with_layers) : QWidget(parent)
{
QWidget* control;
QWidget* layers;
QLabel* label;
this->_auto_apply = auto_apply;
this->_with_layers = with_layers;
setLayout(new QHBoxLayout());
control = new QWidget(this);
control->setLayout(new QVBoxLayout());
control->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
layout()->addWidget(control);
_layer_count = 0;
if (with_layers)
{
layers = new QWidget(this);
layers->setLayout(new QHBoxLayout());
layers->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
label = new QLabel(tr("Layers : "), layers);
label->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
layers->layout()->addWidget(label);
_layer_list = new QComboBox(layers);
layers->layout()->addWidget(_layer_list);
QObject::connect(_layer_list, SIGNAL(currentIndexChanged(int)), this, SLOT(layerListChanged()));
_layer_new = new QPushButton(QIcon(getDataPath("images/layer_add.png")), "", layers);
_layer_new->setToolTip(tr("Add layer"));
_layer_new->setMaximumSize(30, 30);
layers->layout()->addWidget(_layer_new);
QObject::connect(_layer_new, SIGNAL(clicked()), this, SLOT(layerAddClicked()));
_layer_del = new QPushButton(QIcon(getDataPath("images/layer_del.png")), "", layers);
_layer_del->setToolTip(tr("Delete layer"));
_layer_del->setMaximumSize(30, 30);
layers->layout()->addWidget(_layer_del);
QObject::connect(_layer_del, SIGNAL(clicked()), this, SLOT(layerDelClicked()));
_layer_rename = new QPushButton(QIcon(getDataPath("images/layer_rename.png")), "", layers);
_layer_rename->setToolTip(tr("Rename layer"));
_layer_rename->setMaximumSize(30, 30);
layers->layout()->addWidget(_layer_rename);
QObject::connect(_layer_rename, SIGNAL(clicked()), this, SLOT(layerRenameClicked()));
_layer_up = new QPushButton(QIcon(getDataPath("images/layer_up.png")), "", layers);
_layer_up->setToolTip(tr("Move layer upward"));
_layer_up->setMaximumSize(30, 30);
layers->layout()->addWidget(_layer_up);
QObject::connect(_layer_up, SIGNAL(clicked()), this, SLOT(layerUpClicked()));
_layer_down = new QPushButton(QIcon(getDataPath("images/layer_down.png")), "", layers);
_layer_down->setToolTip(tr("Move layer downward"));
_layer_down->setMaximumSize(30, 30);
layers->layout()->addWidget(_layer_down);
QObject::connect(_layer_down, SIGNAL(clicked()), this, SLOT(layerDownClicked()));
control->layout()->addWidget(layers);
control->layout()->setAlignment(_buttons, Qt::AlignTop);
}
_previews = new QWidget(this);
_previews->setLayout(new QVBoxLayout());
_previews->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
layout()->addWidget(_previews);
layout()->setAlignment(_previews, Qt::AlignTop);
_form = new QWidget(this);
_form->setLayout(new QHBoxLayout());
control->layout()->addWidget(_form);
control->layout()->setAlignment(_form, Qt::AlignTop);
_form_labels = new QWidget(_form);
_form_labels->setLayout(new QVBoxLayout());
_form->layout()->addWidget(_form_labels);
_form_previews = new QWidget(_form);
_form_previews->setLayout(new QVBoxLayout());
_form->layout()->addWidget(_form_previews);
_form_controls = new QWidget(_form);
_form_controls->setLayout(new QVBoxLayout());
_form->layout()->addWidget(_form_controls);
_buttons = new QWidget(this);
_buttons->setLayout(new QHBoxLayout());
control->layout()->addWidget(_buttons);
control->layout()->setAlignment(_buttons, Qt::AlignBottom);
_button_revert = addButton(tr("Revert"));
_button_revert->setIcon(QIcon(getDataPath("images/cancel.png")));
_button_revert->setEnabled(false);
connect(_button_revert, SIGNAL(clicked()), this, SLOT(revertConfig()));
_button_apply = addButton(tr("Apply"));
_button_apply->setIcon(QIcon(getDataPath("images/apply.png")));
_button_apply->setEnabled(false);
connect(_button_apply, SIGNAL(clicked()), this, SLOT(applyConfig()));
_button_preset = addButton(tr("Load preset"));
_button_preset->setIcon(QIcon(getDataPath("images/auto.png")));
_button_preset->hide();
connect(_button_preset, SIGNAL(clicked()), this, SLOT(presetChoiceClicked()));
_auto_update_previews = true;
if (auto_apply)
{
hideButtons();
}
}
void BaseForm::hideButtons()
{
_button_apply->hide();
_button_revert->hide();
}
void BaseForm::savePack(PackStream* stream)
{
// Save previews status
for (int i = 0; i < _previews_list.size(); i++)
{
_previews_list[i]->savePack(stream);
}
}
void BaseForm::loadPack(PackStream* stream)
{
// Load previews status
for (int i = 0; i < _previews_list.size(); i++)
{
_previews_list[i]->loadPack(stream);
}
}
void BaseForm::configChangeEvent()
{
if (_auto_apply)
{
applyConfig();
}
else
{
_button_apply->setEnabled(true);
_button_revert->setEnabled(true);
}
for (int i = 0; i < _inputs_list.size(); i++)
{
if (_with_layers && _layer_list->count() == 0)
{
_inputs_list[i]->checkVisibility(false);
}
else
{
_inputs_list[i]->checkVisibility(true);
}
}
if (_auto_update_previews)
{
updatePreviews();
}
}
void BaseForm::autoPresetSelected(int)
{
for (int i = 0; i < _inputs_list.size(); i++)
{
_inputs_list[i]->revert();
}
updatePreviews();
configChangeEvent();
}
void BaseForm::revertConfig()
{
for (int i = 0; i < _inputs_list.size(); i++)
{
_inputs_list[i]->revert();
}
if (_with_layers)
{
rebuildLayerList();
if (_layer_list->currentIndex() < 0 && _layer_list->count() > 0)
{
_layer_list->setCurrentIndex(0);
}
}
for (int i = 0; i < _inputs_list.size(); i++)
{
if (_with_layers && _layer_list->count() == 0)
{
_inputs_list[i]->checkVisibility(false);
}
else
{
_inputs_list[i]->checkVisibility(true);
}
}
updatePreviews();
//configChangeEvent();
_button_apply->setEnabled(false);
_button_revert->setEnabled(false);
}
void BaseForm::applyConfig()
{
_button_apply->setEnabled(false);
_button_revert->setEnabled(false);
emit(configApplied());
}
void BaseForm::rebuildLayerList()
{
if (_with_layers)
{
int selected = _layer_list->currentIndex();
_layer_list->clear();
_layer_names = getLayers();
_layer_count = _layer_names.count();
for (int i = 0; i < _layer_count; i++)
{
_layer_list->addItem(QString(tr("Layer %1 - %2")).arg(i + 1).arg(_layer_names[i]));
}
if (selected >= 0)
{
if (selected >= _layer_count)
{
_layer_list->setCurrentIndex(_layer_count - 1);
}
else
{
_layer_list->setCurrentIndex(selected);
}
}
}
}
void BaseForm::layerAddClicked()
{
layerAddedEvent();
rebuildLayerList();
_layer_list->setCurrentIndex(_layer_list->count() - 1);
_button_apply->setEnabled(true);
_button_revert->setEnabled(true);
}
void BaseForm::layerDelClicked()
{
if (_layer_list->currentIndex() >= 0)
{
layerDeletedEvent(_layer_list->currentIndex());
rebuildLayerList();
_button_apply->setEnabled(true);
_button_revert->setEnabled(true);
}
}
void BaseForm::layerUpClicked()
{
if (_layer_list->currentIndex() < _layer_count - 1)
{
layerMovedEvent(_layer_list->currentIndex(), _layer_list->currentIndex() + 1);
rebuildLayerList();
_layer_list->setCurrentIndex(_layer_list->currentIndex() + 1);
_button_apply->setEnabled(true);
_button_revert->setEnabled(true);
}
}
void BaseForm::layerDownClicked()
{
if (_layer_list->currentIndex() > 0)
{
layerMovedEvent(_layer_list->currentIndex(), _layer_list->currentIndex() - 1);
rebuildLayerList();
_layer_list->setCurrentIndex(_layer_list->currentIndex() - 1);
_button_apply->setEnabled(true);
_button_revert->setEnabled(true);
}
}
void BaseForm::layerRenameClicked()
{
int layer = _layer_list->currentIndex();
if (layer >= 0)
{
QString new_name = QInputDialog::getText(this, tr("Rename layer"), tr("New name: "), QLineEdit::Normal, _layer_names[layer]);
if (not new_name.isEmpty())
{
layerRenamedEvent(layer, new_name);
_button_apply->setEnabled(true);
_button_revert->setEnabled(true);
}
}
}
void BaseForm::layerListChanged()
{
bool changed = _button_apply->isEnabled();
layerSelectedEvent(_layer_list->currentIndex());
_button_apply->setEnabled(changed);
_button_revert->setEnabled(changed);
}
void BaseForm::presetChoiceClicked()
{
bool ok;
QString item = QInputDialog::getItem(this, tr("Choose a preset"), tr("Preset settings : "), _preset_list, 0, false, &ok);
if (ok && !item.isEmpty())
{
int preset = _preset_list.indexOf(item);
if (preset >= 0)
{
autoPresetSelected(preset);
}
}
}
void BaseForm::addPreview(BasePreview* preview, QString label)
{
QLabel* label_widget;
label_widget = new QLabel(label, _previews);
label_widget->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
_previews->layout()->addWidget(label_widget);
_previews->layout()->addWidget(preview);
preview->setMinimumSize(256, 256);
preview->setMaximumSize(256, 256);
preview->resize(256, 256);
_previews_list.append(preview);
}
QPushButton* BaseForm::addButton(QString label)
{
QPushButton* button = new QPushButton(label);
_buttons->layout()->addWidget(button);
return button;
}
void BaseForm::addAutoPreset(QString label)
{
_preset_list.append(label);
_button_preset->show();
}
BaseInput* BaseForm::addInput(BaseInput* input)
{
int row_height = 30;
_form_labels->layout()->addWidget(input->label());
_form_previews->layout()->addWidget(input->preview());
_form_controls->layout()->addWidget(input->control());
input->label()->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
input->label()->setMinimumSize(150, row_height);
input->label()->setMaximumSize(250, row_height);
input->preview()->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
input->preview()->setMinimumSize(100, row_height);
input->preview()->setMaximumSize(250, row_height);
input->control()->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
input->control()->setMinimumSize(280, row_height);
input->control()->setMaximumSize(700, row_height);
connect(input, SIGNAL(valueChanged()), this, SLOT(configChangeEvent()));
_inputs_list.append(input);
input->revert();
return input;
}
BaseInput* BaseForm::addInputInt(QString label, int* value, int min, int max, int small_step, int large_step)
{
return addInput(new InputInt(_form, label, value, min, max, small_step, large_step));
}
BaseInput* BaseForm::addInputDouble(QString label, double* value, double min, double max, double small_step, double large_step)
{
return addInput(new InputDouble(_form, label, value, min, max, small_step, large_step));
}
BaseInput* BaseForm::addInputBoolean(QString label, int* value)
{
return addInput(new InputBoolean(_form, label, value));
}
BaseInput* BaseForm::addInputColor(QString label, Color* value)
{
return addInput(new InputColor(_form, label, value));
}
BaseInput* BaseForm::addInputNoise(QString label, NoiseGenerator* value)
{
return addInput(new InputNoise(_form, label, value));
}
BaseInput* BaseForm::addInputCurve(QString label, Curve* value, double xmin, double xmax, double ymin, double ymax, QString xlabel, QString ylabel)
{
return addInput(new InputCurve(_form, label, value, xmin, xmax, ymin, ymax, xlabel, ylabel));
}
BaseInput* BaseForm::addInputMaterial(QString label, SurfaceMaterial* material)
{
return addInput(new InputMaterial(_form, label, material));
}
BaseInput* BaseForm::addInputEnum(QString label, int* value, const QStringList& values)
{
return addInput(new InputEnum(_form, label, value, values));
}
void BaseForm::updatePreviews()
{
for (int i = 0; i < _previews_list.size(); i++)
{
_previews_list[i]->redraw();
}
}
void BaseForm::disablePreviewsUpdate()
{
_auto_update_previews = false;
}
int BaseForm::currentLayer()
{
if (_with_layers)
{
return _layer_list->currentIndex();
}
else
{
return -1;
}
}
QStringList BaseForm::getLayers()
{
return QStringList();
}
void BaseForm::layerAddedEvent()
{
rebuildLayerList();
}
void BaseForm::layerDeletedEvent(int)
{
rebuildLayerList();
}
void BaseForm::layerMovedEvent(int, int)
{
rebuildLayerList();
}
void BaseForm::layerRenamedEvent(int, QString)
{
rebuildLayerList();
}
void BaseForm::layerSelectedEvent(int layer)
{
for (int i = 0; i < _inputs_list.size(); i++)
{
_inputs_list[i]->revert();
_inputs_list[i]->checkVisibility(layer >= 0);
}
for (int i = 0; i < _previews_list.size(); i++)
{
_previews_list[i]->redraw();
}
_layer_del->setEnabled(layer >= 0);
_layer_rename->setEnabled(layer >= 0);
_layer_down->setEnabled(layer > 0);
_layer_up->setEnabled(layer >= 0 and layer < _layer_count - 1);
}

View file

@ -1,106 +0,0 @@
#ifndef _PAYSAGES_QT_BASEFORM_H_
#define _PAYSAGES_QT_BASEFORM_H_
#include "desktop_global.h"
#include <QWidget>
#include <QStringList>
class QPushButton;
class QComboBox;
class ColorGradation;
namespace paysages {
namespace desktop {
class BaseForm : public QWidget
{
Q_OBJECT
public:
BaseForm(QWidget* parent, bool auto_apply = false, bool with_layers = false);
void hideButtons();
virtual void savePack(PackStream* stream);
virtual void loadPack(PackStream* stream);
signals:
void configApplied();
public slots:
virtual void revertConfig();
virtual void applyConfig();
protected slots:
virtual void configChangeEvent();
virtual void autoPresetSelected(int preset);
private slots:
void rebuildLayerList();
void layerAddClicked();
void layerDelClicked();
void layerUpClicked();
void layerDownClicked();
void layerRenameClicked();
void layerListChanged();
void presetChoiceClicked();
protected:
void addPreview(BasePreview* preview, QString label);
QPushButton* addButton(QString label);
void addAutoPreset(QString label);
BaseInput* addInput(BaseInput* input);
BaseInput* addInputInt(QString label, int* value, int min, int max, int small_step, int large_step);
BaseInput* addInputDouble(QString label, double* value, double min, double max, double small_step, double large_step);
BaseInput* addInputBoolean(QString label, int* value);
BaseInput* addInputColor(QString label, Color* value);
BaseInput* addInputNoise(QString label, NoiseGenerator* value);
BaseInput* addInputCurve(QString label, Curve* value, double xmin, double xmax, double ymin, double ymax, QString xlabel, QString ylabel);
BaseInput* addInputMaterial(QString label, SurfaceMaterial* material);
BaseInput* addInputEnum(QString label, int* value, const QStringList& values);
void updatePreviews();
void disablePreviewsUpdate();
int currentLayer();
virtual QStringList getLayers();
virtual void layerAddedEvent();
virtual void layerDeletedEvent(int layer);
virtual void layerMovedEvent(int layer, int new_position);
virtual void layerRenamedEvent(int layer, QString new_name);
virtual void layerSelectedEvent(int layer);
private:
bool _auto_apply;
QWidget* _form;
QWidget* _form_labels;
QWidget* _form_previews;
QWidget* _form_controls;
QWidget* _buttons;
QPushButton* _button_apply;
QPushButton* _button_revert;
QPushButton* _button_preset;
QWidget* _previews;
QVector<BasePreview*> _previews_list;
bool _auto_update_previews;
QVector<BaseInput*> _inputs_list;
QStringList _preset_list;
bool _with_layers;
QComboBox* _layer_list;
int _layer_count;
QStringList _layer_names;
QPushButton* _layer_new;
QPushButton* _layer_del;
QPushButton* _layer_up;
QPushButton* _layer_down;
QPushButton* _layer_rename;
};
}
}
#endif

View file

@ -1,145 +0,0 @@
#include "baseformlayer.h"
#include <QInputDialog>
#include "Layers.h"
BaseFormLayer::BaseFormLayer(QWidget* parent, Layers* layers) : BaseForm(parent, false, true)
{
_layers_original = NULL;
_layers_modified = NULL;
if (layers)
{
_layers_original = layers;
_layers_modified = _layers_original->newCopy();
}
}
BaseFormLayer::~BaseFormLayer()
{
if (_layers_modified)
{
delete _layers_modified;
}
}
void BaseFormLayer::revertConfig()
{
if (_layers_original && _layers_modified)
{
_layers_original->copy(_layers_modified);
layerSelectedEvent(currentLayer());
}
BaseForm::revertConfig();
}
void BaseFormLayer::applyConfig()
{
if (_layers_original && _layers_modified)
{
_layers_modified->copy(_layers_original);
}
BaseForm::applyConfig();
}
void BaseFormLayer::setLayers(Layers* layers)
{
_layers_original = layers;
if (_layers_modified)
{
delete _layers_modified;
}
_layers_modified = _layers_original->newCopy();
revertConfig();
}
void BaseFormLayer::afterLayerAdded(void*)
{
}
void BaseFormLayer::configChangeEvent()
{
if (_layers_modified)
{
layerWriteCurrentTo(_layers_modified->getLayer(currentLayer()));
_layers_modified->validate();
}
BaseForm::configChangeEvent();
}
QStringList BaseFormLayer::getLayers()
{
QStringList result;
if (_layers_modified)
{
for (int i = 0; i < _layers_modified->count(); i++)
{
result << QString::fromStdString(_layers_modified->getLayer(i)->getName());
}
}
return result;
}
void BaseFormLayer::layerAddedEvent()
{
if (_layers_modified)
{
QString layer_name = QInputDialog::getText(this, tr("Create layer"), tr("Layer name :"), QLineEdit::Normal, tr("Unnamed layer"));
if (not layer_name.isEmpty())
{
int layer = _layers_modified->addLayer();
if (layer >= 0)
{
_layers_modified->getLayer(layer)->setName(layer_name.toStdString());
BaseForm::layerAddedEvent();
afterLayerAdded(_layers_modified->getLayer(layer));
}
}
}
}
void BaseFormLayer::layerDeletedEvent(int layer)
{
if (_layers_modified)
{
_layers_modified->removeLayer(layer);
}
BaseForm::layerDeletedEvent(layer);
}
void BaseFormLayer::layerMovedEvent(int layer, int new_position)
{
if (_layers_modified)
{
_layers_modified->moveLayer(layer, new_position);
}
BaseForm::layerMovedEvent(layer, new_position);
}
void BaseFormLayer::layerRenamedEvent(int layer, QString new_name)
{
if (_layers_modified)
{
_layers_modified->getLayer(layer)->setName(new_name.toStdString());
}
BaseForm::layerRenamedEvent(layer, new_name);
}
void BaseFormLayer::layerSelectedEvent(int layer)
{
if (_layers_modified && layer >= 0)
{
layerReadCurrentFrom(_layers_modified->getLayer(layer));
}
BaseForm::layerSelectedEvent(layer);
}

View file

@ -1,43 +0,0 @@
#ifndef _PAYSAGES_QT_BASEFORMLAYER_H_
#define _PAYSAGES_QT_BASEFORMLAYER_H_
/* Base form, with automatic layer control */
#include "baseform.h"
#include "Layers.h"
class BaseFormLayer:public BaseForm
{
Q_OBJECT
public:
BaseFormLayer(QWidget* parent, Layers* layers=NULL);
~BaseFormLayer();
public slots:
virtual void revertConfig();
virtual void applyConfig();
protected:
void setLayers(Layers* layers);
virtual void layerReadCurrentFrom(void* layer_definition) = 0;
virtual void layerWriteCurrentTo(void* layer_definition) = 0;
virtual void afterLayerAdded(void* layer_definition);
private:
virtual QStringList getLayers();
virtual void layerAddedEvent();
virtual void layerDeletedEvent(int layer);
virtual void layerMovedEvent(int layer, int new_position);
virtual void layerRenamedEvent(int layer, QString new_name);
virtual void layerSelectedEvent(int layer);
protected slots:
virtual void configChangeEvent();
private:
Layers* _layers_original;
Layers* _layers_modified;
};
#endif

View file

@ -1,93 +0,0 @@
#include "baseinput.h"
#include <QWidget>
#include <QLabel>
BaseInput::BaseInput(QWidget* form, QString label):
QObject(form)
{
_label = new QLabel(label);
_label->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
_label->setWordWrap(true);
_visibility_value = NULL;
_enabled_value = NULL;
_visible = true;
_enabled = true;
}
void BaseInput::setVisibilityCondition(int* value, int condition)
{
_visibility_value = value;
_visibility_condition = condition;
}
void BaseInput::setEnabledCondition(int* value, int condition)
{
_enabled_value = value;
_enabled_condition = condition;
}
void BaseInput::updatePreview()
{
}
void BaseInput::applyValue()
{
updatePreview();
emit(valueChanged());
}
void BaseInput::revert()
{
updatePreview();
}
void BaseInput::checkVisibility(bool enabled)
{
if (!_visibility_value || *_visibility_value == _visibility_condition)
{
if (not _visible)
{
_visible = true;
_label->show();
_preview->show();
_control->show();
}
}
else
{
if (_visible)
{
_visible = false;
_label->hide();
_preview->hide();
_control->hide();
}
}
if (enabled && (!_enabled_value || *_enabled_value == _enabled_condition))
{
if (not _enabled)
{
_enabled = true;
_preview->setEnabled(true);
_control->setEnabled(true);
}
}
else
{
if (_enabled)
{
_enabled = false;
_preview->setEnabled(false);
_control->setEnabled(false);
}
}
}

View file

@ -1,49 +0,0 @@
#ifndef _PAYSAGES_QT_BASEINPUT_H_
#define _PAYSAGES_QT_BASEINPUT_H_
#include "desktop_global.h"
#include <QObject>
class QWidget;
class QLabel;
namespace paysages {
namespace desktop {
class BaseInput:public QObject
{
Q_OBJECT
public:
BaseInput(QWidget* form, QString label);
inline QLabel* label() {return _label;}
inline QWidget* preview() {return _preview;}
inline QWidget* control() {return _control;}
void setVisibilityCondition(int* value, int condition);
void setEnabledCondition(int* value, int condition);
public slots:
virtual void updatePreview();
virtual void revert();
virtual void applyValue();
void checkVisibility(bool enabled);
signals:
void valueChanged();
protected:
QLabel* _label;
QWidget* _preview;
QWidget* _control;
int* _visibility_value;
int _visibility_condition;
int* _enabled_value;
int _enabled_condition;
bool _visible;
bool _enabled;
};
}
}
#endif

View file

@ -1,294 +0,0 @@
#include "freeformhelper.h"
#include <cmath>
#include <QDialog>
#include <QVariant>
#include <QResizeEvent>
#include <QSlider>
#include <QPushButton>
#include <QWidget>
#include <QInputDialog>
#include <QLabel>
#include "mainwindow.h"
#include "dialogrender.h"
#include "dialogexplorer.h"
#include "RenderConfig.h"
#include "DesktopScenery.h"
#include "BasePreview.h"
#include "SoftwareCanvasRenderer.h"
#include "CameraDefinition.h"
#include "tools.h"
Q_DECLARE_METATYPE(double*)
FreeFormHelper::FreeFormHelper(QWidget* form_widget)
:QObject()
{
_form_widget = form_widget;
_data_changed = false;
_button_apply = NULL;
_button_revert = NULL;
_button_presets = NULL;
}
FreeFormHelper::~FreeFormHelper()
{
}
bool FreeFormHelper::eventFilter(QObject* object, QEvent* event)
{
if (event->type() == QEvent::Resize && object == _form_widget)
{
QSize form_size = ((QResizeEvent*) event)->size();
QSize preview_size;
if (form_size.width() > 1400 && form_size.height() > 900)
{
preview_size = QSize(320, 320);
}
else if (form_size.width() < 1100 || form_size.height() < 750)
{
preview_size = QSize(200, 200);
}
else
{
preview_size = QSize(260, 260);
}
for (int i = 0; i < _previews.size(); i++)
{
if (_previews[i]->size() != preview_size)
{
_previews[i]->setMinimumSize(preview_size);
_previews[i]->setMaximumSize(preview_size);
_previews[i]->resize(preview_size);
}
}
}
return false;
}
void FreeFormHelper::startManaging()
{
_form_widget->installEventFilter(this);
connect(MainWindow::instance(), SIGNAL(refreshed()), this, SLOT(processGlobalRefresh()));
connect(this, SIGNAL(needLocalRefreshing()), _form_widget, SLOT(refreshFromLocalData()));
connect(this, SIGNAL(needGlobalRefreshing()), _form_widget, SLOT(refreshFromFellowData()));
connect(this, SIGNAL(needReverting()), _form_widget, SLOT(updateLocalDataFromScenery()));
connect(this, SIGNAL(needCommitting()), _form_widget, SLOT(commitLocalDataToScenery()));
connect(this, SIGNAL(needAlterRenderer(SoftwareRenderer*)), _form_widget, SLOT(alterRenderer(SoftwareRenderer*)));
processGlobalRefresh();
}
void FreeFormHelper::addPreview(BasePreview* preview, Base2dPreviewRenderer* renderer)
{
_previews.append(preview);
preview->setRenderer(renderer);
}
void FreeFormHelper::addDoubleInputSlider(WidgetSliderDecimal* slider, double* value, double min, double max, double small_step, double large_step)
{
_inputs_decimal.append(slider);
slider->setDecimalRange(min, max, small_step, large_step);
slider->setDecimalValue(*value);
slider->setProperty("data_pointer", QVariant::fromValue<double*>(value));
connect(slider, SIGNAL(decimalValueChanged(double)), this, SLOT(processDecimalChange(double)));
}
void FreeFormHelper::setApplyButton(QPushButton* button)
{
_button_apply = button;
button->setEnabled(_data_changed);
connect(button, SIGNAL(clicked()), this, SLOT(processApplyClicked()));
}
void FreeFormHelper::setRevertButton(QPushButton* button)
{
_button_revert = button;
button->setEnabled(_data_changed);
connect(button, SIGNAL(clicked()), this, SLOT(processRevertClicked()));
}
void FreeFormHelper::setExploreButton(QPushButton* button)
{
_button_explore = button;
button->setToolTip(tr("Explore the scenery in 3D, with current changes applied"));
connect(button, SIGNAL(clicked()), this, SLOT(processExploreClicked()));
}
void FreeFormHelper::setRenderButton(QPushButton* button)
{
_button_render = button;
button->setToolTip(tr("Quick render preview, with current changes applied"));
connect(button, SIGNAL(clicked()), this, SLOT(processRenderClicked()));
}
void FreeFormHelper::setLabelText(QLabel* label, QString text)
{
label->setText(text);
}
void FreeFormHelper::addPreset(const QString& name)
{
_presets << name;
}
void FreeFormHelper::setPresetButton(QPushButton* button)
{
_button_presets = button;
connect(button, SIGNAL(clicked()), this, SLOT(processPresetClicked()));
}
void FreeFormHelper::openDialog(QDialog* dialog)
{
if (dialog->exec())
{
processDataChange();
}
}
void FreeFormHelper::gotoMainTab(int position)
{
MainWindow::instance()->openTab(position);
}
void FreeFormHelper::processDataChange()
{
_data_changed = true;
if (_button_apply)
{
_button_apply->setEnabled(true);
}
if (_button_revert)
{
_button_revert->setEnabled(true);
}
for (int i = 0; i < _previews.size(); i++)
{
_previews[i]->redraw();
}
emit needLocalRefreshing();
}
void FreeFormHelper::processGlobalRefresh()
{
emit needGlobalRefreshing();
processRevertClicked();
}
void FreeFormHelper::processRevertClicked()
{
emit needReverting();
for (int i = 0; i < _previews.size(); i++)
{
_previews[i]->redraw();
}
for (int i = 0; i < _inputs_decimal.size(); i++)
{
WidgetSliderDecimal* slider = _inputs_decimal.at(i);
double* pointer = slider->property("data_pointer").value<double*>();
if (pointer)
{
slider->setDecimalValue(*pointer);
}
}
_data_changed = false;
if (_button_apply)
{
_button_apply->setEnabled(false);
}
if (_button_revert)
{
_button_revert->setEnabled(false);
}
emit needLocalRefreshing();
}
void FreeFormHelper::processApplyClicked()
{
emit needCommitting();
MainWindow::instance()->refreshAll();
}
void FreeFormHelper::processExploreClicked()
{
SoftwareRenderer renderer(DesktopScenery::getCurrent());
emit needAlterRenderer(&renderer);
CameraDefinition camera;
DesktopScenery::getCurrent()->getCamera(&camera);
DialogExplorer* dialog = new DialogExplorer(_form_widget, &camera, false, renderer.getScenery());
dialog->exec();
delete dialog;
}
void FreeFormHelper::processRenderClicked()
{
RenderConfig params(400, 300, 1, 3);
SoftwareCanvasRenderer renderer;
renderer.setConfig(params);
renderer.setScenery(DesktopScenery::getCurrent());
emit needAlterRenderer(&renderer);
DialogRender dialog(_form_widget, &renderer);
dialog.startRender();
}
void FreeFormHelper::processDecimalChange(double value)
{
QObject* signal_sender = sender();
if (signal_sender && signal_sender->inherits("WidgetSliderDecimal"))
{
WidgetSliderDecimal* slider = (WidgetSliderDecimal*)signal_sender;
double* pointer = slider->property("data_pointer").value<double*>();
if (pointer)
{
*pointer = value;
}
processDataChange();
}
}
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);
processDataChange();
}
}
}

View file

@ -1,81 +0,0 @@
#ifndef FREEFORMHELPER_H
#define FREEFORMHELPER_H
#include "desktop_global.h"
#include <QVector>
#include <QStringList>
#include "widgetsliderdecimal.h"
class QSlider;
class QPushButton;
class QLabel;
class FreeFormHelper:public QObject
{
Q_OBJECT
public:
FreeFormHelper(QWidget* form_widget);
~FreeFormHelper();
void startManaging();
void addPreview(BasePreview* preview, Base2dPreviewRenderer* 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 setApplyButton(QPushButton* button);
void setRevertButton(QPushButton* button);
void setExploreButton(QPushButton* button);
void setRenderButton(QPushButton* button);
void setLabelText(QLabel* label, QString text);
void setPresetButton(QPushButton* button);
void addPreset(const QString& name);
void openDialog(QDialog* dialog);
void gotoMainTab(int position);
signals:
void revertClicked();
void applyClicked();
void presetSelected(int position);
void needLocalRefreshing();
void needGlobalRefreshing();
void needReverting();
void needCommitting();
void needAlterRenderer(SoftwareRenderer* renderer);
public slots:
void processDataChange();
void processGlobalRefresh();
void processRevertClicked();
void processApplyClicked();
void processExploreClicked();
void processRenderClicked();
void processDecimalChange(double value);
void processPresetClicked();
protected:
bool eventFilter(QObject* object, QEvent* event);
private:
QWidget* _form_widget;
bool _data_changed;
QPushButton* _button_presets;
QStringList _presets;
QVector<BasePreview*> _previews;
QVector<WidgetSliderDecimal*> _inputs_decimal;
QPushButton* _button_apply;
QPushButton* _button_revert;
QPushButton* _button_explore;
QPushButton* _button_render;
};
#endif

View file

@ -1,158 +0,0 @@
#include "freelayerhelper.h"
#include <QTableWidget>
#include <QPushButton>
FreeLayerHelper::FreeLayerHelper(Layers* layers, bool reverse)
{
_table = NULL;
_selected = -1;
_layers = layers;
_reverse = reverse;
}
FreeLayerHelper::~FreeLayerHelper()
{
}
void FreeLayerHelper::refreshLayers()
{
if (_table)
{
int selected = _selected;
emit tableUpdateNeeded();
int n = _layers->count();
if (n == 0)
{
_selected = -1;
}
if (selected < 0)
{
_table->clearSelection();
emit selectionChanged(-1);
}
else
{
if (selected >= n)
{
selected = n - 1;
}
_table->setCurrentCell(selected, 0);
}
}
}
void FreeLayerHelper::setLayerTable(QTableWidget* table)
{
_table = table;
connect(table, SIGNAL(currentCellChanged(int, int, int, int)), this, SLOT(tableSelectionChanged(int, int)));
refreshLayers();
}
void FreeLayerHelper::setAddButton(QPushButton* button)
{
connect(button, SIGNAL(clicked()), this, SLOT(addLayer()));
}
void FreeLayerHelper::setDelButton(QPushButton* button)
{
connect(button, SIGNAL(clicked()), this, SLOT(deleteLayer()));
}
void FreeLayerHelper::setDownButton(QPushButton* button)
{
if (_reverse)
{
connect(button, SIGNAL(clicked()), this, SLOT(moveLayerDown()));
}
else
{
connect(button, SIGNAL(clicked()), this, SLOT(moveLayerUp()));
}
}
void FreeLayerHelper::setUpButton(QPushButton* button)
{
if (_reverse)
{
connect(button, SIGNAL(clicked()), this, SLOT(moveLayerUp()));
}
else
{
connect(button, SIGNAL(clicked()), this, SLOT(moveLayerDown()));
}
}
void FreeLayerHelper::setEditButton(QPushButton* button)
{
connect(button, SIGNAL(clicked()), this, SLOT(startEditing()));
}
void FreeLayerHelper::addLayer()
{
_selected = _layers->addLayer(NULL);
emit(layersChanged());
refreshLayers();
}
void FreeLayerHelper::deleteLayer()
{
if (_selected >= 0)
{
_layers->removeLayer(_selected);
emit(layersChanged());
refreshLayers();
}
}
void FreeLayerHelper::moveLayerDown()
{
if (_selected > 0)
{
_layers->moveLayer(_selected, _selected - 1);
_selected--;
emit(layersChanged());
refreshLayers();
}
}
void FreeLayerHelper::moveLayerUp()
{
if (_selected >= 0 && _selected < _layers->count() - 1)
{
_layers->moveLayer(_selected, _selected + 1);
_selected++;
emit(layersChanged());
refreshLayers();
}
}
void FreeLayerHelper::startEditing()
{
if (_selected >= 0 && _selected < _layers->count())
{
emit(editRequired(_selected));
}
}
void FreeLayerHelper::tableSelectionChanged(int row, int)
{
int n = _layers->count();
if (n == 0 or row >= n)
{
_selected = -1;
}
else
{
_selected = _reverse ? n - 1 - row : row;
}
emit(selectionChanged(_selected));
}

View file

@ -1,47 +0,0 @@
#ifndef _EDITING_COMMON_FREELAYERHELPER_H_
#define _EDITING_COMMON_FREELAYERHELPER_H_
#include <QObject>
#include "Layers.h"
class QTableWidget;
class QPushButton;
class FreeLayerHelper : public QObject {
Q_OBJECT
public:
FreeLayerHelper(Layers* layers, bool reverse=false);
~FreeLayerHelper();
void refreshLayers();
void setLayerTable(QTableWidget* table);
void setAddButton(QPushButton* button);
void setDelButton(QPushButton* button);
void setDownButton(QPushButton* button);
void setUpButton(QPushButton* button);
void setEditButton(QPushButton* button);
signals:
void selectionChanged(int layer);
void layersChanged();
void tableUpdateNeeded();
void editRequired(int layer);
public slots:
void addLayer();
void deleteLayer();
void moveLayerDown();
void moveLayerUp();
void startEditing();
void tableSelectionChanged(int row, int col);
private:
QTableWidget* _table;
Layers* _layers;
int _selected;
bool _reverse;
};
#endif

View file

@ -1,286 +0,0 @@
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QApplication>
#include <QMenuBar>
#include <QMenu>
#include <QIcon>
#include <QFileDialog>
#include <QFileInfo>
#include <QTabWidget>
#include <QTranslator>
#include <QLocale>
#include <QMessageBox>
#include "BasePreview.h"
#include "PreviewOsd.h"
#include "PreviewOsdItem.h"
#include "CameraDefinition.h"
#include "formclouds.h"
#include "formatmosphere.h"
#include "formwater.h"
#include "formrender.h"
#include "terrain/mainterrainform.h"
#include "dialogrender.h"
#include "dialogexplorer.h"
#include "DesktopScenery.h"
#include "PackStream.h"
#include "tools.h"
MainWindow* MainWindow::_instance = NULL;
int main(int argc, char** argv)
{
MainWindow* window;
int result;
QApplication app(argc, argv);
QTranslator qtTranslator;
QTranslator myTranslator;
QString i18ndir = QString::fromStdString(DataFile::findDir("i18n"));
if (not i18ndir.isEmpty() and myTranslator.load("paysages_" + QLocale::system().name(), i18ndir))
{
app.installTranslator(&myTranslator);
qtTranslator.load("qt_" + QLocale::system().name());
app.installTranslator(&qtTranslator);
}
else
{
qtTranslator.load("qt_en");
app.installTranslator(&qtTranslator);
}
//splash->showMessage(app.tr("Preloading..."), Qt::AlignCenter, Qt::white);
app.processEvents();
BasePreview::initDrawers();
window = new MainWindow();
window->show();
//window->showMaximized();
result = app.exec();
BasePreview::stopDrawers();
delete window;
return result;
}
MainWindow::MainWindow() :
QMainWindow(),
ui(new Ui::MainWindow)
{
_instance = this;
ui->setupUi(this);
BaseForm* form;
connect(ui->action_explore, SIGNAL(triggered()), this, SLOT(explore3D()));
connect(ui->action_quick_render, SIGNAL(triggered()), this, SLOT(quickPreview()));
connect(ui->action_final_render, SIGNAL(triggered()), this, SLOT(finalRender()));
connect(ui->action_last_render, SIGNAL(triggered()), this, SLOT(showLastRender()));
connect(ui->action_file_new, SIGNAL(triggered()), this, SLOT(fileNew()));
connect(ui->action_file_save, SIGNAL(triggered()), this, SLOT(fileSave()));
connect(ui->action_file_load, SIGNAL(triggered()), this, SLOT(fileLoad()));
connect(ui->action_about, SIGNAL(triggered()), this, SLOT(showAboutDialog()));
form = new FormWater(ui->tabs);
ui->tabs->addTab(form, QIcon(getDataPath("images/tab_water.png")), tr("Water"));
QObject::connect(form, SIGNAL(configApplied()), this, SLOT(refreshAll()), Qt::QueuedConnection);
_forms.append(form);
form = new FormAtmosphere(ui->tabs);
ui->tabs->addTab(form, QIcon(getDataPath("images/tab_atmosphere.png")), tr("Atmosphere"));
QObject::connect(form, SIGNAL(configApplied()), this, SLOT(refreshAll()), Qt::QueuedConnection);
_forms.append(form);
form = new FormClouds(ui->tabs);
ui->tabs->addTab(form, QIcon(getDataPath("images/tab_clouds.png")), tr("Clouds"));
QObject::connect(form, SIGNAL(configApplied()), this, SLOT(refreshAll()), Qt::QueuedConnection);
_forms.append(form);
_form_render = new FormRender(ui->tabs);
ui->tabs->addTab(_form_render, QIcon(getDataPath("images/tab_render.png")), tr("Render"));
_forms.append(_form_render);
ui->tabs->setCurrentIndex(0);
// TODO Decide this according to platform / screen size
ui->toolBar->hide();
ui->tool_panel->hide();
//ui->menuBar->hide();
// FIXME AutoPreset has already been called by paysagesInit but we need to redo it here because
// the auto apply on FormRender overwrites the camera. Delete this when the render form is no longer a BaseForm.
DesktopScenery::getCurrent()->autoPreset(0);
refreshAll();
}
MainWindow::~MainWindow()
{
delete ui;
}
bool MainWindow::event(QEvent* event)
{
if (event->type() == QEvent::WindowActivate)
{
BasePreview::reviveAll();
}
return QMainWindow::event(event);
}
void MainWindow::refreshAll()
{
logDebug("[MainWindow] Refreshing whole UI");
// Refresh all tabs
for (int i = 0; i < _forms.size(); i++)
{
_forms[i]->revertConfig();
}
// Refresh preview OSD
PreviewOsd* osd = PreviewOsd::getInstance(QString("geolocation"));
osd->clearItems();
PreviewOsdItem* item = osd->newItem(50, 50);
item->drawCamera(DesktopScenery::getCurrent()->getCamera());
item->setToolTip(QString(tr("Camera")));
emit refreshed();
}
void MainWindow::openTab(int position)
{
ui->tabs->setCurrentIndex(position);
}
void MainWindow::fileNew()
{
if (QMessageBox::question(this, tr("Paysages 3D - New scenery"), tr("Do you want to start a new scenery ? Any unsaved changes will be lost."), QMessageBox::Yes | QMessageBox::No, QMessageBox::No) == QMessageBox::Yes)
{
DesktopScenery::getCurrent()->autoPreset(0);
refreshAll();
}
}
void MainWindow::fileSave()
{
QString filepath = QFileDialog::getSaveFileName(this, tr("Paysages 3D - Choose a file to save the scenery"), QString(), tr("Paysages 3D Scenery (*.p3d)"));
if (!filepath.isNull())
{
if (!filepath.toLower().endsWith(".p3d"))
{
filepath = filepath.append(".p3d");
}
Scenery::FileOperationResult result = DesktopScenery::getCurrent()->saveGlobal(filepath.toStdString());
switch (result)
{
case Scenery::FILE_OPERATION_OK:
break;
case Scenery::FILE_OPERATION_IOERROR:
QMessageBox::critical(this, tr("Paysages 3D - File saving error"), tr("Can't write specified file : %1").arg(filepath));
break;
default:
QMessageBox::critical(this, tr("Paysages 3D - File saving error"), tr("Unexpected error while saving file : %1").arg(filepath));
}
}
}
void MainWindow::fileLoad()
{
if (QMessageBox::question(this, tr("Paysages 3D - Load scenery"), tr("Do you want to load a scenery from file ? Any unsaved changes will be lost."), QMessageBox::Yes | QMessageBox::No, QMessageBox::No) == QMessageBox::Yes)
{
QString filepath = QFileDialog::getOpenFileName(this, tr("Paysages 3D - Choose a scenery file to load"), QString(), tr("Paysages 3D Scenery (*.p3d)"));
if (!filepath.isNull())
{
Scenery::FileOperationResult result = DesktopScenery::getCurrent()->loadGlobal(filepath.toStdString());
switch (result)
{
case Scenery::FILE_OPERATION_OK:
refreshAll();
break;
case Scenery::FILE_OPERATION_IOERROR:
QMessageBox::critical(this, tr("Paysages 3D - File loading error"), tr("Can't read specified file : %1").arg(filepath));
break;
case Scenery::FILE_OPERATION_APP_MISMATCH:
QMessageBox::critical(this, tr("Paysages 3D - File loading error"), tr("This file doesn't look like a Paysages 3D file : %1").arg(filepath));
break;
case Scenery::FILE_OPERATION_VERSION_MISMATCH:
QMessageBox::critical(this, tr("Paysages 3D - File loading error"), tr("This file was created with an incompatible Paysages 3D version : %1").arg(filepath));
break;
default:
QMessageBox::critical(this, tr("Paysages 3D - File loading error"), tr("Unexpected error while loading file : %1").arg(filepath));
}
}
}
}
void MainWindow::showAboutDialog()
{
QMessageBox::about(this, tr("Paysages 3D"), tr("A 3D landscape editing and rendering software.\n\nAuthors :\nProgramming - Michael Lemaire\n\nCredits :\nQt - http://qt-project.org/\nDevIL - http://openil.sourceforge.net/\nGLib - http://www.gtk.org/\n"));
}
void MainWindow::quickPreview()
{
_form_render->startQuickRender();
}
void MainWindow::finalRender()
{
_form_render->startRender();
}
void MainWindow::showLastRender()
{
_form_render->showRender();
}
void MainWindow::explore3D()
{
CameraDefinition* camera = new CameraDefinition;
int result;
DesktopScenery::getCurrent()->getCamera(camera);
DialogExplorer* dialog = new DialogExplorer(this, camera, true);
result = dialog->exec();
delete dialog;
if (result == QDialog::Accepted)
{
DesktopScenery::getCurrent()->setCamera(camera);
refreshAll();
}
delete camera;
}
void MainWindow::guiSave(PackStream* stream)
{
// Save all tabs status
for (int i = 0; i < _forms.size(); i++)
{
_forms[i]->savePack(stream);
}
}
void MainWindow::guiLoad(PackStream* stream)
{
// Load all tabs status
for (int i = 0; i < _forms.size(); i++)
{
_forms[i]->loadPack(stream);
}
}

View file

@ -1,65 +0,0 @@
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include "desktop_global.h"
#include <QMainWindow>
#include <QVector>
class FormRender;
namespace Ui {
class MainWindow;
}
class MainWindow;
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow();
~MainWindow();
virtual bool event(QEvent* event);
void guiSave(PackStream* stream);
void guiLoad(PackStream* stream);
static inline MainWindow* instance()
{
return _instance;
}
protected:
public slots:
void refreshAll();
void openTab(int position);
void fileNew();
void fileSave();
void fileLoad();
void showAboutDialog();
void quickPreview();
void finalRender();
void showLastRender();
void explore3D();
signals:
void refreshed();
private:
static MainWindow* _instance;
Ui::MainWindow *ui;
QVector<BaseForm*> _forms;
FormRender* _form_render;
};
#endif // MAINWINDOW_H

View file

@ -1,585 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>946</width>
<height>651</height>
</rect>
</property>
<property name="windowTitle">
<string>Paysages 3D</string>
</property>
<property name="windowIcon">
<iconset resource="../../../../data/ui_pictures.qrc">
<normaloff>:/logo/images/logo_32.png</normaloff>:/logo/images/logo_32.png</iconset>
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QWidget" name="tool_panel" native="true">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-size:14pt; font-weight:600;&quot;&gt;Paysages 3D&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;img src=&quot;:/logo/images/logo_32.png&quot;/&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="textFormat">
<enum>Qt::RichText</enum>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_3">
<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>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QRadioButton" name="radioButton_3">
<property name="text">
<string>Preview</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButton_2">
<property name="text">
<string>3D</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButton">
<property name="text">
<string>Top</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QFrame" name="frame">
<property name="frameShape">
<enum>QFrame::Panel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<property name="lineWidth">
<number>3</number>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="spacing">
<number>0</number>
</property>
<property name="sizeConstraint">
<enum>QLayout::SetMinimumSize</enum>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QWidget" name="widget" native="true">
<property name="minimumSize">
<size>
<width>200</width>
<height>150</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>400</width>
<height>300</height>
</size>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer_4">
<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_2">
<property name="title">
<string>Actions</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<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>
<property name="shortcut">
<string>F2</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="button_render">
<property name="text">
<string>Render</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>
</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">
<property name="title">
<string>File</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QPushButton" name="button_file_new">
<property name="text">
<string>New</string>
</property>
<property name="icon">
<iconset resource="../../../../data/ui_pictures.qrc">
<normaloff>:/buttons/logo/images/new.png</normaloff>:/buttons/logo/images/new.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="button_file_save">
<property name="text">
<string>Save</string>
</property>
<property name="icon">
<iconset resource="../../../../data/ui_pictures.qrc">
<normaloff>:/buttons/logo/images/save.png</normaloff>:/buttons/logo/images/save.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="button_file_load">
<property name="text">
<string>Load</string>
</property>
<property name="icon">
<iconset resource="../../../../data/ui_pictures.qrc">
<normaloff>:/buttons/logo/images/load.png</normaloff>:/buttons/logo/images/load.png</iconset>
</property>
</widget>
</item>
</layout>
</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>
</widget>
</item>
<item>
<widget class="QTabWidget" name="tabs">
<property name="currentIndex">
<number>1</number>
</property>
<property name="iconSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
<widget class="MainTerrainForm" name="tab_terrain">
<attribute name="icon">
<iconset resource="../../../../data/ui_pictures.qrc">
<normaloff>:/tabs/images/tab_terrain.png</normaloff>:/tabs/images/tab_terrain.png</iconset>
</attribute>
<attribute name="title">
<string>Lanscape shape</string>
</attribute>
</widget>
<widget class="MainTexturesForm" name="tab">
<attribute name="icon">
<iconset resource="../../../../data/ui_pictures.qrc">
<normaloff>:/tabs/images/tab_textures.png</normaloff>:/tabs/images/tab_textures.png</iconset>
</attribute>
<attribute name="title">
<string>Textures</string>
</attribute>
</widget>
</widget>
</item>
</layout>
</widget>
<widget class="QToolBar" name="toolBar">
<property name="windowTitle">
<string>toolBar</string>
</property>
<property name="movable">
<bool>false</bool>
</property>
<property name="allowedAreas">
<set>Qt::LeftToolBarArea</set>
</property>
<property name="iconSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
<property name="toolButtonStyle">
<enum>Qt::ToolButtonTextUnderIcon</enum>
</property>
<property name="floatable">
<bool>false</bool>
</property>
<attribute name="toolBarArea">
<enum>LeftToolBarArea</enum>
</attribute>
<attribute name="toolBarBreak">
<bool>false</bool>
</attribute>
<addaction name="action_file_new"/>
<addaction name="action_file_save"/>
<addaction name="action_file_load"/>
<addaction name="separator"/>
<addaction name="action_explore"/>
<addaction name="action_quick_render"/>
<addaction name="action_final_render"/>
<addaction name="separator"/>
<addaction name="action_about"/>
</widget>
<widget class="QMenuBar" name="menuBar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>946</width>
<height>20</height>
</rect>
</property>
<widget class="QMenu" name="menuFile">
<property name="title">
<string>File</string>
</property>
<addaction name="action_file_new"/>
<addaction name="action_file_save"/>
<addaction name="action_file_load"/>
</widget>
<widget class="QMenu" name="menuActions">
<property name="title">
<string>Actions</string>
</property>
<addaction name="action_explore"/>
<addaction name="action_quick_render"/>
<addaction name="action_final_render"/>
<addaction name="action_last_render"/>
</widget>
<widget class="QMenu" name="menuHelp">
<property name="title">
<string>Help</string>
</property>
<addaction name="action_about"/>
</widget>
<addaction name="menuFile"/>
<addaction name="menuActions"/>
<addaction name="menuHelp"/>
</widget>
<action name="action_explore">
<property name="icon">
<iconset resource="../../../../data/ui_pictures.qrc">
<normaloff>:/buttons/logo/images/explore.png</normaloff>:/buttons/logo/images/explore.png</iconset>
</property>
<property name="text">
<string>Explore in 3D</string>
</property>
<property name="toolTip">
<string>Start exploring your scenery in real-time 3D</string>
</property>
<property name="shortcut">
<string>F2</string>
</property>
</action>
<action name="action_file_new">
<property name="icon">
<iconset resource="../../../../data/ui_pictures.qrc">
<normaloff>:/buttons/logo/images/new.png</normaloff>:/buttons/logo/images/new.png</iconset>
</property>
<property name="text">
<string>New scene</string>
</property>
<property name="toolTip">
<string>Create a virgin scene</string>
</property>
<property name="shortcut">
<string>Ctrl+N</string>
</property>
</action>
<action name="action_file_load">
<property name="icon">
<iconset resource="../../../../data/ui_pictures.qrc">
<normaloff>:/buttons/logo/images/load.png</normaloff>:/buttons/logo/images/load.png</iconset>
</property>
<property name="text">
<string>Load scene</string>
</property>
<property name="toolTip">
<string>Load a scenery from a file</string>
</property>
<property name="shortcut">
<string>Ctrl+O</string>
</property>
</action>
<action name="action_file_save">
<property name="icon">
<iconset resource="../../../../data/ui_pictures.qrc">
<normaloff>:/buttons/logo/images/save.png</normaloff>:/buttons/logo/images/save.png</iconset>
</property>
<property name="text">
<string>Save scene</string>
</property>
<property name="toolTip">
<string>Save a scenery to a file</string>
</property>
<property name="shortcut">
<string>Ctrl+S</string>
</property>
</action>
<action name="action_quick_render">
<property name="icon">
<iconset resource="../../../../data/ui_pictures.qrc">
<normaloff>:/buttons/logo/images/render.png</normaloff>:/buttons/logo/images/render.png</iconset>
</property>
<property name="text">
<string>Quick render</string>
</property>
<property name="toolTip">
<string>Start a quick render</string>
</property>
<property name="shortcut">
<string>F5</string>
</property>
</action>
<action name="action_final_render">
<property name="icon">
<iconset resource="../../../../data/ui_pictures.qrc">
<normaloff>:/buttons/logo/images/render.png</normaloff>:/buttons/logo/images/render.png</iconset>
</property>
<property name="text">
<string>Final render</string>
</property>
<property name="toolTip">
<string>Start the final rendering processs</string>
</property>
<property name="shortcut">
<string>Ctrl+F5</string>
</property>
</action>
<action name="action_about">
<property name="icon">
<iconset resource="../../../../data/ui_pictures.qrc">
<normaloff>:/buttons/logo/images/about.png</normaloff>:/buttons/logo/images/about.png</iconset>
</property>
<property name="text">
<string>About</string>
</property>
<property name="toolTip">
<string>Display information on this software</string>
</property>
<property name="shortcut">
<string>F1</string>
</property>
</action>
<action name="action_last_render">
<property name="icon">
<iconset resource="../../../../data/ui_pictures.qrc">
<normaloff>:/buttons/logo/images/render.png</normaloff>:/buttons/logo/images/render.png</iconset>
</property>
<property name="text">
<string>Show last render</string>
</property>
<property name="toolTip">
<string>Display the last render done</string>
</property>
<property name="shortcut">
<string>F6</string>
</property>
</action>
</widget>
<customwidgets>
<customwidget>
<class>MainTerrainForm</class>
<extends>QWidget</extends>
<header>terrain/mainterrainform.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>MainTexturesForm</class>
<extends>QWidget</extends>
<header>textures/maintexturesform.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources>
<include location="../../../../data/ui_pictures.qrc"/>
</resources>
<connections>
<connection>
<sender>button_explore</sender>
<signal>clicked()</signal>
<receiver>action_explore</receiver>
<slot>trigger()</slot>
<hints>
<hint type="sourcelabel">
<x>127</x>
<y>380</y>
</hint>
<hint type="destinationlabel">
<x>-1</x>
<y>-1</y>
</hint>
</hints>
</connection>
<connection>
<sender>button_render</sender>
<signal>clicked()</signal>
<receiver>action_final_render</receiver>
<slot>trigger()</slot>
<hints>
<hint type="sourcelabel">
<x>213</x>
<y>425</y>
</hint>
<hint type="destinationlabel">
<x>-1</x>
<y>-1</y>
</hint>
</hints>
</connection>
<connection>
<sender>button_file_new</sender>
<signal>clicked()</signal>
<receiver>action_file_new</receiver>
<slot>trigger()</slot>
<hints>
<hint type="sourcelabel">
<x>213</x>
<y>522</y>
</hint>
<hint type="destinationlabel">
<x>-1</x>
<y>-1</y>
</hint>
</hints>
</connection>
<connection>
<sender>button_file_load</sender>
<signal>clicked()</signal>
<receiver>action_file_load</receiver>
<slot>trigger()</slot>
<hints>
<hint type="sourcelabel">
<x>213</x>
<y>588</y>
</hint>
<hint type="destinationlabel">
<x>-1</x>
<y>-1</y>
</hint>
</hints>
</connection>
<connection>
<sender>button_file_save</sender>
<signal>clicked()</signal>
<receiver>action_file_save</receiver>
<slot>trigger()</slot>
<hints>
<hint type="sourcelabel">
<x>213</x>
<y>555</y>
</hint>
<hint type="destinationlabel">
<x>-1</x>
<y>-1</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View file

@ -1,18 +0,0 @@
#include "widgetglobalformbuttons.h"
#include "ui_widgetglobalformbuttons.h"
WidgetGlobalFormButtons::WidgetGlobalFormButtons(QWidget *parent) :
QWidget(parent),
ui(new Ui::WidgetGlobalFormButtons)
{
ui->setupUi(this);
connect(ui->button_ok, SIGNAL(clicked()), this, SIGNAL(okClicked()));
connect(ui->button_cancel, SIGNAL(clicked()), this, SIGNAL(cancelClicked()));
connect(ui->button_revert, SIGNAL(clicked()), this, SIGNAL(revertClicked()));
}
WidgetGlobalFormButtons::~WidgetGlobalFormButtons()
{
delete ui;
}

View file

@ -1,27 +0,0 @@
#ifndef WIDGETGLOBALFORMBUTTONS_H
#define WIDGETGLOBALFORMBUTTONS_H
#include <QWidget>
namespace Ui {
class WidgetGlobalFormButtons;
}
class WidgetGlobalFormButtons : public QWidget
{
Q_OBJECT
public:
explicit WidgetGlobalFormButtons(QWidget *parent = 0);
~WidgetGlobalFormButtons();
signals:
void okClicked();
void revertClicked();
void cancelClicked();
private:
Ui::WidgetGlobalFormButtons *ui;
};
#endif // WIDGETGLOBALFORMBUTTONS_H

View file

@ -1,85 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>WidgetGlobalFormButtons</class>
<widget class="QWidget" name="WidgetGlobalFormButtons">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>560</width>
<height>43</height>
</rect>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>50</height>
</size>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QPushButton" name="button_cancel">
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
<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>
<widget class="QPushButton" name="button_revert">
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
<property name="text">
<string>Revert modifications</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>
<item>
<widget class="QPushButton" name="button_ok">
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
<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>
</widget>
</item>
</layout>
</widget>
<resources>
<include location="../../../../data/ui_pictures.qrc"/>
</resources>
<connections/>
<slots>
<signal>applyClicked()</signal>
<signal>revertClicked()</signal>
<signal>cancelClicked()</signal>
</slots>
</ui>

View file

@ -1,67 +0,0 @@
#include "widgetsliderdecimal.h"
#include <cmath>
WidgetSliderDecimal::WidgetSliderDecimal(QWidget *parent) :
QSlider(parent)
{
_min = 0.0;
_max = 1.0;
_step = 0.01;
_value = 0.0;
connect(this, SIGNAL(valueChanged(int)), this, SLOT(processIntValue(int)));
}
void WidgetSliderDecimal::setDecimalRange(double min, double max, double precision, double tick_precision)
{
double range = max - min;
if (range < 0.000001)
{
max = min + 0.000001;
range = max - min;
}
if (precision < 0.000001)
{
precision = range / 1000.0;
}
_min = min;
_max = max;
_step = precision;
setMinimum(0);
setMaximum(round(range / precision));
if (tick_precision < 0.000001)
{
tick_precision = 20.0 * range / precision;
}
setTickInterval(round(tick_precision / precision));
}
void WidgetSliderDecimal::setDecimalValue(double value)
{
_value = value;
setValue(round((value - _min) / _step));
}
void WidgetSliderDecimal::processIntValue(int value)
{
double result;
if (value == maximum())
{
result = _max;
}
else
{
result = _min + ((double)value) * _step;
}
if (fabs(result) < 0.0000001)
{
result = 0.0;
}
_value = result;
emit decimalValueChanged(result);
}

View file

@ -1,29 +0,0 @@
#ifndef WIDGETSLIDERDECIMAL_H
#define WIDGETSLIDERDECIMAL_H
#include <QSlider>
class WidgetSliderDecimal : public QSlider
{
Q_OBJECT
public:
explicit WidgetSliderDecimal(QWidget *parent = 0);
void setDecimalRange(double min, double max, double precision=0.0, double tick_interval=0.0);
void setDecimalValue(double value);
inline double decimalValue() {return _value;}
signals:
void decimalValueChanged(double value);
public slots:
void processIntValue(int value);
private:
double _min;
double _max;
double _step;
double _value;
};
#endif // WIDGETSLIDERDECIMAL_H

View file

@ -1,154 +0,0 @@
TEMPLATE = app
CONFIG += qt
QT += core gui opengl
TARGET = paysages-gui
unix:LIBS += -lGLU
include(../../common.pri)
HEADERS += \
terrain/widgetheightmap.h \
widgetcurveeditor.h \
tools.h \
previewmaterial.h \
inputnoise.h \
inputmaterial.h \
inputlayers.h \
inputint.h \
inputenum.h \
inputdouble.h \
inputcurve.h \
inputcolor.h \
inputcamera.h \
inputboolean.h \
formwater.h \
formrender.h \
formclouds.h \
formatmosphere.h \
dialogrender.h \
dialognoise.h \
dialoglayers.h \
dialogexplorer.h \
dialogcurve.h \
baseinput.h \
baseformlayer.h \
baseform.h \
terrain/dialogterrainpainting.h \
common/widgetglobalformbuttons.h \
terrain/paintingbrush.h \
terrain/mainterrainform.h \
common/freeformhelper.h \
common/widgetsliderdecimal.h \
terrain/widgetterrainbasenoisepreview.h \
common/mainwindow.h \
terrain/dialogbaseterrainnoise.h \
textures/maintexturesform.h \
common/freelayerhelper.h \
lighting/DialogMaterialEditor.h \
lighting/SmallPreviewColor.h \
lighting/SmallPreviewHues.h \
textures/DialogTexturesLayer.h \
desktop_global.h \
DesktopScenery.h \
WidgetCanvas.h \
WidgetPreviewCanvas.h
SOURCES += \
terrain/widgetheightmap.cpp \
widgetcurveeditor.cpp \
tools.cpp \
previewmaterial.cpp \
inputnoise.cpp \
inputmaterial.cpp \
inputlayers.cpp \
inputint.cpp \
inputenum.cpp \
inputdouble.cpp \
inputcurve.cpp \
inputcolor.cpp \
inputcamera.cpp \
inputboolean.cpp \
formwater.cpp \
formrender.cpp \
formclouds.cpp \
formatmosphere.cpp \
dialogrender.cpp \
dialognoise.cpp \
dialoglayers.cpp \
dialogexplorer.cpp \
dialogcurve.cpp \
baseinput.cpp \
baseformlayer.cpp \
baseform.cpp \
terrain/dialogterrainpainting.cpp \
common/widgetglobalformbuttons.cpp \
terrain/paintingbrush.cpp \
terrain/mainterrainform.cpp \
common/freeformhelper.cpp \
common/widgetsliderdecimal.cpp \
terrain/widgetterrainbasenoisepreview.cpp \
common/mainwindow.cpp \
terrain/dialogbaseterrainnoise.cpp \
textures/maintexturesform.cpp \
common/freelayerhelper.cpp \
lighting/DialogMaterialEditor.cpp \
lighting/SmallPreviewColor.cpp \
lighting/SmallPreviewHues.cpp \
textures/DialogTexturesLayer.cpp \
DesktopScenery.cpp \
WidgetCanvas.cpp \
WidgetPreviewCanvas.cpp
FORMS += \
terrain/dialogterrainpainting.ui \
common/widgetglobalformbuttons.ui \
terrain/mainterrainform.ui \
common/mainwindow.ui \
terrain/dialogbaseterrainnoise.ui \
textures/maintexturesform.ui \
lighting/DialogMaterialEditor.ui \
textures/DialogTexturesLayer.ui
RESOURCES += \
../../../data/ui_pictures.qrc
TRANSLATIONS = ../../../data/i18n/paysages_fr.ts
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../../system/release/ -lpaysages_system
else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../../system/debug/ -lpaysages_system
else:unix: LIBS += -L$$OUT_PWD/../../system/ -lpaysages_system
INCLUDEPATH += $$PWD/../../system
DEPENDPATH += $$PWD/../../system
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../../basics/release/ -lpaysages_basics
else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../../basics/debug/ -lpaysages_basics
else:unix: LIBS += -L$$OUT_PWD/../../basics/ -lpaysages_basics
INCLUDEPATH += $$PWD/../../basics
DEPENDPATH += $$PWD/../../basics
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../../definition/release/ -lpaysages_definition
else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../../definition/debug/ -lpaysages_definition
else:unix: LIBS += -L$$OUT_PWD/../../definition/ -lpaysages_definition
INCLUDEPATH += $$PWD/../../definition
DEPENDPATH += $$PWD/../../definition
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../../render/software/release/ -lpaysages_render_software
else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../../render/software/debug/ -lpaysages_render_software
else:unix: LIBS += -L$$OUT_PWD/../../render/software/ -lpaysages_render_software
INCLUDEPATH += $$PWD/../../render/software
DEPENDPATH += $$PWD/../../render/software
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../../render/preview/release/ -lpaysages_render_preview
else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../../render/preview/debug/ -lpaysages_render_preview
else:unix: LIBS += -L$$OUT_PWD/../../render/preview/ -lpaysages_render_preview
INCLUDEPATH += $$PWD/../../render/preview
DEPENDPATH += $$PWD/../../render/preview
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../../render/opengl/release/ -lpaysages_render_opengl
else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../../render/opengl/debug/ -lpaysages_render_opengl
else:unix: LIBS += -L$$OUT_PWD/../../render/opengl/ -lpaysages_render_opengl
INCLUDEPATH += $$PWD/../../render/opengl
DEPENDPATH += $$PWD/../../render/opengl

View file

@ -1,21 +0,0 @@
#ifndef EDITING_GLOBAL_H
#define EDITING_GLOBAL_H
#include "definition_global.h"
#include "software_global.h"
#include "opengl_global.h"
#include "preview_global.h"
namespace paysages {
namespace desktop {
class BaseInput;
class BaseForm;
class WidgetCanvas;
class WidgetPreviewCanvas;
}
}
using namespace paysages::desktop;
#endif // EDITING_GLOBAL_H

View file

@ -1,104 +0,0 @@
#include "dialogcurve.h"
#include <QGridLayout>
#include <QLabel>
#include <QPushButton>
#include "Curve.h"
#include "baseform.h"
#include "tools.h"
#include "widgetcurveeditor.h"
/**************** Dialog ****************/
DialogCurve::DialogCurve(QWidget *parent, Curve* curve, double xmin, double xmax, double ymin, double ymax, QString xlabel, QString ylabel) : QDialog(parent)
{
QWidget* buttons;
QWidget* form;
QGridLayout* form_layout;
QLabel* label;
_base = curve;
_current = new Curve;
_base->copy(_current);
setLayout(new QVBoxLayout());
form = new QWidget(this);
form_layout = new QGridLayout();
form->setLayout(form_layout);
layout()->addWidget(form);
label = new QLabel(tr("This is the curve editor.\nClick on points and drag them to move them.\nDouble click to add a new point.\nRight click on a point to delete it."), form);
label->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Minimum);
label->setMinimumWidth(150);
label->setMaximumWidth(200);
label->setWordWrap(true);
form_layout->addWidget(label, 0, 1);
_curve_editor = new WidgetCurveEditor(form, xmin, xmax, ymin, ymax);
_curve_editor->setAxisLabels(xlabel, ylabel);
_curve_editor->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
form_layout->addWidget(_curve_editor, 0, 0);
buttons = new QWidget(this);
layout()->addWidget(buttons);
buttons->setLayout(new QHBoxLayout());
_button_cancel = new QPushButton(tr("Cancel"), buttons);
_button_cancel->setIcon(QIcon(getDataPath("images/cancel.png")));
buttons->layout()->addWidget(_button_cancel);
QObject::connect(_button_cancel, SIGNAL(clicked()), this, SLOT(reject()));
_button_revert = new QPushButton(tr("Revert"), buttons);
_button_revert->setIcon(QIcon(getDataPath("images/revert.png")));
buttons->layout()->addWidget(_button_revert);
QObject::connect(_button_revert, SIGNAL(clicked()), this, SLOT(revert()));
_button_accept = new QPushButton(tr("Validate"), buttons);
_button_accept->setIcon(QIcon(getDataPath("images/apply.png")));
buttons->layout()->addWidget(_button_accept);
QObject::connect(_button_accept, SIGNAL(clicked()), this, SLOT(accept()));
setWindowTitle(tr("Paysages 3D - Curve editor"));
resize(900, 600);
revert();
}
DialogCurve::~DialogCurve()
{
delete _current;
}
bool DialogCurve::getCurve(QWidget* parent, Curve* curve, double xmin, double xmax, double ymin, double ymax, QString xlabel, QString ylabel)
{
int result;
DialogCurve* dialog = new DialogCurve(parent, curve, xmin, xmax, ymin, ymax, xlabel, ylabel);
result = dialog->exec();
delete dialog;
return (result != 0) ? true : false;
}
void DialogCurve::closeEvent(QCloseEvent*)
{
reject();
}
void DialogCurve::accept()
{
_curve_editor->getCurve(_current);
_current->copy(_base);
QDialog::accept();
}
void DialogCurve::revert()
{
_base->copy(_current);
revertToCurrent();
}
void DialogCurve::revertToCurrent()
{
_curve_editor->setCurve(_current);
}

View file

@ -1,39 +0,0 @@
#ifndef _PAYSAGES_QT_DIALOGCURVE_H_
#define _PAYSAGES_QT_DIALOGCURVE_H_
#include "desktop_global.h"
#include <QDialog>
class QPushButton;
class WidgetCurveEditor;
class DialogCurve : public QDialog
{
Q_OBJECT
public:
explicit DialogCurve(QWidget* parent, Curve* curve, double xmin, double xmax, double ymin, double ymax, QString xlabel, QString ylabel);
~DialogCurve();
static bool getCurve(QWidget* parent, Curve* curve, double xmin, double xmax, double ymin, double ymax, QString xlabel, QString ylabel);
public slots:
virtual void accept();
void revert();
protected:
virtual void closeEvent(QCloseEvent* e);
private:
void revertToCurrent();
private:
Curve* _base;
Curve* _current;
WidgetCurveEditor* _curve_editor;
QPushButton* _button_accept;
QPushButton* _button_revert;
QPushButton* _button_cancel;
};
#endif

View file

@ -1,86 +0,0 @@
#include "dialogexplorer.h"
#include <QWidget>
#include <QPushButton>
#include <QVBoxLayout>
#include <QLabel>
#include <QSlider>
#include "WidgetExplorer.h"
#include "DesktopScenery.h"
#include "CameraDefinition.h"
DialogExplorer::DialogExplorer(QWidget* parent, CameraDefinition* camera, bool camera_validable, Scenery* scenery) : QDialog(parent)
{
QWidget* panel;
QPushButton* button;
QLabel* label;
setModal(true);
setWindowTitle(tr("Paysages 3D - Explore"));
setLayout(new QHBoxLayout());
if (!scenery)
{
scenery = DesktopScenery::getCurrent();
}
_wanderer = new WidgetExplorer(this, camera, scenery);
layout()->addWidget(_wanderer);
panel = new QWidget(this);
panel->setLayout(new QVBoxLayout());
panel->setMaximumWidth(230);
label = new QLabel(tr("Field of vision"), panel);
label->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
panel->layout()->addWidget(label);
_fov = new QSlider(Qt::Horizontal, panel);
_fov->setRange(0, 1000);
_fov->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
connect(_fov, SIGNAL(valueChanged(int)), this, SLOT(fovChanged(int)));
panel->layout()->addWidget(_fov);
panel->layout()->addWidget(new QLabel(tr("COMMANDS\n\nLeft click : Look around\nRight click : Pan (adjust framing)\nWheel : Move forward/backward\nHold SHIFT : Faster\nHold CTRL : Slower"), panel));
button = new QPushButton(tr("Reset camera"), panel);
panel->layout()->addWidget(button);
QObject::connect(button, SIGNAL(clicked()), this, SLOT(resetCamera()));
if (camera_validable)
{
button = new QPushButton(tr("Validate as render camera"), panel);
panel->layout()->addWidget(button);
QObject::connect(button, SIGNAL(clicked()), this, SLOT(validateCamera()));
}
button = new QPushButton(tr("Close"), panel);
panel->layout()->addWidget(button);
QObject::connect(button, SIGNAL(clicked()), this, SLOT(reject()));
layout()->addWidget(panel);
resize(900, 600);
resetCamera();
}
DialogExplorer::~DialogExplorer()
{
}
void DialogExplorer::validateCamera()
{
_wanderer->validateCamera();
accept();
}
void DialogExplorer::resetCamera()
{
_wanderer->resetCamera();
_fov->setValue((int)(1000.0 * (_wanderer->getCurrentCamera()->getPerspective().yfov - 0.7) / 1.0));
}
void DialogExplorer::fovChanged(int value)
{
_wanderer->setCameraFov(0.7 + 1.0 * ((double)value) / 1000.0);
}

View file

@ -1,27 +0,0 @@
#ifndef _PAYSAGES_QT_DIALOGEXPLORER_H_
#define _PAYSAGES_QT_DIALOGEXPLORER_H_
#include "desktop_global.h"
#include <QDialog>
class QSlider;
class DialogExplorer : public QDialog
{
Q_OBJECT
public:
explicit DialogExplorer(QWidget *parent, CameraDefinition* camera, bool camera_validable=false, Scenery* scenery=0);
~DialogExplorer();
protected slots:
void validateCamera();
void resetCamera();
void fovChanged(int value);
private:
WidgetExplorer* _wanderer;
QSlider* _fov;
};
#endif

View file

@ -1,76 +0,0 @@
#include "dialoglayers.h"
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QPushButton>
#include <QWidget>
#include "baseformlayer.h"
/**************** Dialog form ****************/
DialogLayers::DialogLayers(QWidget *parent, Layers* layers, QString title, FormLayerBuilder form_builder) : DialogWithPreview(parent)
{
QPushButton* button;
QWidget* buttons;
_layers = layers;
setLayout(new QVBoxLayout());
_form = form_builder(this, _layers);
_form->hideButtons();
layout()->addWidget(_form);
buttons = new QWidget(this);
buttons->setLayout(new QHBoxLayout());
layout()->addWidget(buttons);
layout()->setAlignment(buttons, Qt::AlignBottom);
button = new QPushButton(tr("Cancel"), buttons);
button->setIcon(QIcon(getDataPath("images/cancel.png")));
buttons->layout()->addWidget(button);
QObject::connect(button, SIGNAL(clicked()), this, SLOT(reject()));
button = new QPushButton(tr("Reset"), buttons);
button->setIcon(QIcon(getDataPath("images/revert.png")));
buttons->layout()->addWidget(button);
QObject::connect(button, SIGNAL(clicked()), this, SLOT(revert()));
button = new QPushButton(tr("Validate"), buttons);
button->setIcon(QIcon(getDataPath("images/apply.png")));
buttons->layout()->addWidget(button);
QObject::connect(button, SIGNAL(clicked()), this, SLOT(accept()));
setWindowTitle(tr("Paysages 3D - ") + title);
}
DialogLayers::~DialogLayers()
{
}
bool DialogLayers::editLayers(QWidget* parent, Layers* layers, QString title, FormLayerBuilder form_builder)
{
int result;
DialogLayers* dialog = new DialogLayers(parent, layers, title, form_builder);
result = dialog->exec();
delete dialog;
return result != 0;
}
void DialogLayers::closeEvent(QCloseEvent*)
{
reject();
}
void DialogLayers::accept()
{
_form->applyConfig();
QDialog::accept();
}
void DialogLayers::revert()
{
_form->revertConfig();
}

View file

@ -1,37 +0,0 @@
#ifndef _PAYSAGES_QT_DIALOGLAYERS_H_
#define _PAYSAGES_QT_DIALOGLAYERS_H_
/* Dialog for generic layers control */
#include <QListWidget>
#include "tools.h"
#include "Layers.h"
class DialogLayers;
class BaseFormLayer;
typedef BaseFormLayer* (*FormLayerBuilder)(DialogLayers* parent, Layers* layers);
class DialogLayers : public DialogWithPreview
{
Q_OBJECT
public:
explicit DialogLayers(QWidget* parent, Layers* layers, QString title, FormLayerBuilder form_builder);
~DialogLayers();
static bool editLayers(QWidget* parent, Layers* layers, QString title, FormLayerBuilder form_builder);
public slots:
virtual void accept();
void revert();
protected:
virtual void closeEvent(QCloseEvent* e);
private:
BaseFormLayer* _form;
Layers* _layers;
};
#endif

View file

@ -1,352 +0,0 @@
#include "dialognoise.h"
#include <QWidget>
#include <QVBoxLayout>
#include <QImage>
#include <QLabel>
#include <QColor>
#include <QPainter>
#include <QSlider>
#include <QScrollArea>
#include <QPushButton>
#include <cmath>
#include "BasePreview.h"
/**************** Previews ****************/
class PreviewLevel:public BasePreview
{
public:
PreviewLevel(QWidget* parent, NoiseGenerator* noise): BasePreview(parent)
{
_noise_original = noise;
_noise_preview = new NoiseGenerator();
_level = -1;
configScaling(0.15, 6.0, 0.09, 6.0);
}
void setLevel(int row)
{
_level = row;
redraw();
}
protected:
void updateData()
{
_noise_original->copy(_noise_preview);
}
Color getColor(double x, double y)
{
if ((_level >= 0) && (-y > _noise_preview->get1DLevel(_level, x)))
{
return COLOR_WHITE;
}
else
{
return COLOR_BLACK;
}
}
private:
NoiseGenerator* _noise_original;
NoiseGenerator* _noise_preview;
int _level;
};
class PreviewTotal:public BasePreview
{
public:
PreviewTotal(QWidget* parent, NoiseGenerator* noise): BasePreview(parent)
{
_noise_original = noise;
_noise_preview = new NoiseGenerator();
configScaling(0.15, 6.0, 0.09, 6.0);
}
protected:
void updateData()
{
_noise_original->copy(_noise_preview);
}
Color getColor(double x, double y)
{
if (-y > _noise_preview->get1DTotal(x))
{
return COLOR_WHITE;
}
else
{
return COLOR_BLACK;
}
}
private:
NoiseGenerator* _noise_original;
NoiseGenerator* _noise_preview;
};
/**************** Dialog form ****************/
DialogNoise::DialogNoise(QWidget *parent, NoiseGenerator* value):
DialogWithPreview(parent)
{
QWidget* function;
QWidget* previews;
QWidget* form;
QWidget* buttons;
QPushButton* button;
QLabel* label;
_base = value;
_current = new NoiseGenerator();
setLayout(new QHBoxLayout());
previews = new QWidget(this);
previews->setLayout(new QVBoxLayout());
layout()->addWidget(previews);
layout()->setAlignment(previews, Qt::AlignTop);
previewLevel = new PreviewLevel(previews, _current);
label = new QLabel(tr("Level preview"));
label->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
previews->layout()->addWidget(label);
previews->layout()->addWidget(previewLevel);
previewTotal = new PreviewTotal(previews, _current);
label = new QLabel(tr("Total preview"));
label->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
previews->layout()->addWidget(label);
previews->layout()->addWidget(previewTotal);
form = new QWidget(this);
form->setLayout(new QVBoxLayout());
layout()->addWidget(form);
function = new QWidget(form);
function->setLayout(new QHBoxLayout());
form->layout()->addWidget(function);
function->layout()->addWidget(new QLabel(tr("Noise function")));
function_algo = new QComboBox(function);
function_algo->addItems(QStringList(tr("Simplex (best)")) << tr("Perlin (fast)") << tr("Naive (slow)"));
function->layout()->addWidget(function_algo);
function->layout()->addWidget(new QLabel(tr("Ridge factor")));
function_ridge = new QSlider(Qt::Horizontal, function);
function_ridge->setRange(-10, 10);
function_ridge->setTickInterval(10);
function_ridge->setTickPosition(QSlider::TicksBelow);
function_ridge->setMinimumWidth(150);
function->layout()->addWidget(function_ridge);
QObject::connect(function_algo, SIGNAL(currentIndexChanged(int)), this, SLOT(functionChanged()));
QObject::connect(function_ridge, SIGNAL(valueChanged(int)), this, SLOT(functionChanged()));
form->layout()->addWidget(new QLabel(tr("Noise components")));
levels = new QListWidget(form);
form->layout()->addWidget(levels);
QObject::connect(levels, SIGNAL(currentRowChanged(int)), this, SLOT(levelChanged(int)));
buttons = new QWidget(form);
buttons->setLayout(new QHBoxLayout());
form->layout()->addWidget(buttons);
button = new QPushButton(tr("Add component"), buttons);
buttons->layout()->addWidget(button);
QObject::connect(button, SIGNAL(clicked()), this, SLOT(addLevel()));
button = new QPushButton(tr("Remove component"), buttons);
buttons->layout()->addWidget(button);
QObject::connect(button, SIGNAL(clicked()), this, SLOT(removeLevel()));
form->layout()->addWidget(new QLabel(tr("Component height")));
slider_height = new QSlider(form);
slider_height->setOrientation(Qt::Horizontal);
slider_height->setMinimumWidth(150);
//slider_height->setMaximumWidth(400);
slider_height->setMinimum(0);
slider_height->setMaximum(1000);
slider_height->setTickInterval(100);
slider_height->setTickPosition(QSlider::TicksBelow);
form->layout()->addWidget(slider_height);
QObject::connect(slider_height, SIGNAL(valueChanged(int)), this, SLOT(heightChanged(int)));
form->layout()->addWidget(new QLabel(tr("Component scaling")));
slider_scaling = new QSlider(form);
slider_scaling->setOrientation(Qt::Horizontal);
slider_scaling->setMinimumWidth(150);
//slider_scaling->setMaximumWidth(400);
slider_scaling->setMinimum(1);
slider_scaling->setMaximum(1000);
slider_scaling->setTickInterval(100);
slider_scaling->setTickPosition(QSlider::TicksBelow);
form->layout()->addWidget(slider_scaling);
QObject::connect(slider_scaling, SIGNAL(valueChanged(int)), this, SLOT(scalingChanged(int)));
buttons = new QWidget(form);
buttons->setLayout(new QHBoxLayout());
form->layout()->addWidget(buttons);
button = new QPushButton(tr("Cancel"), buttons);
button->setIcon(QIcon(getDataPath("images/cancel.png")));
buttons->layout()->addWidget(button);
QObject::connect(button, SIGNAL(clicked()), this, SLOT(reject()));
button = new QPushButton(tr("Revert"), buttons);
button->setIcon(QIcon(getDataPath("images/revert.png")));
buttons->layout()->addWidget(button);
QObject::connect(button, SIGNAL(clicked()), this, SLOT(revert()));
button = new QPushButton(tr("Validate"), buttons);
button->setIcon(QIcon(getDataPath("images/apply.png")));
buttons->layout()->addWidget(button);
QObject::connect(button, SIGNAL(clicked()), this, SLOT(accept()));
setWindowTitle(tr("Paysages 3D - Noise editor"));
revert();
}
DialogNoise::~DialogNoise()
{
delete previewLevel;
delete previewTotal;
delete _current;
}
bool DialogNoise::getNoise(QWidget* parent, NoiseGenerator* noise)
{
int result;
DialogNoise* dialog = new DialogNoise(parent, noise);
result = dialog->exec();
delete dialog;
return (result != 0) ? true : false;
}
void DialogNoise::closeEvent(QCloseEvent*)
{
reject();
}
void DialogNoise::accept()
{
_current->copy(_base);
QDialog::accept();
}
void DialogNoise::revert()
{
_base->copy(_current);
revertToCurrent();
}
void DialogNoise::revertToCurrent()
{
int i, n;
int selected;
NoiseGenerator::NoiseFunction function;
selected = levels->currentRow();
levels->clear();
n = _current->getLevelCount();
for (i = 0; i < n; i++)
{
levels->addItem(QString(tr("Component %1")).arg(i + 1));
}
if (n > 0)
{
if (selected < 0)
{
selected = 0;
}
if (selected >= n)
{
selected = n - 1;
}
levels->setCurrentRow(selected);
}
function = _current->getFunction();
function_algo->setCurrentIndex((int)function.algorithm);
function_ridge->setValue(round(function.ridge_factor * 20.0));
previewLevel->redraw();
previewTotal->redraw();
}
void DialogNoise::addLevel()
{
NoiseGenerator::NoiseLevel level;
level.amplitude = 0.1;
level.frequency = 0.1;
_current->addLevel(level);
revertToCurrent();
levels->setCurrentRow(levels->count() - 1);
}
void DialogNoise::removeLevel()
{
int row;
row = levels->currentRow();
_current->removeLevel(_current_level);
revertToCurrent();
if (row >= levels->count())
{
row--;
}
levels->setCurrentRow(row);
}
void DialogNoise::functionChanged()
{
NoiseGenerator::NoiseFunction function;
function.algorithm = (NoiseGenerator::NoiseFunctionAlgorithm)function_algo->currentIndex();
function.ridge_factor = (double)function_ridge->value() * 0.05;
_current->setFunction(&function);
_current->validate();
previewLevel->redraw();
previewTotal->redraw();
}
void DialogNoise::levelChanged(int row)
{
if (_current->getLevel(row, &_current_level_params))
{
_current_level = row;
((PreviewLevel*)previewLevel)->setLevel(row);
slider_height->setValue(_current_level_params.amplitude * 1000.0);
slider_scaling->setValue(_current_level_params.frequency * 1000.0);
}
// TODO else ...
}
void DialogNoise::heightChanged(int value)
{
_current_level_params.amplitude = ((double)value) / 1000.0;
_current->setLevel(_current_level, _current_level_params);
previewLevel->redraw();
previewTotal->redraw();
}
void DialogNoise::scalingChanged(int value)
{
_current_level_params.frequency = ((double)value) / 1000.0;
_current->setLevel(_current_level, _current_level_params);
previewLevel->redraw();
previewTotal->redraw();
}

View file

@ -1,52 +0,0 @@
#ifndef _PAYSAGES_QT_DIALOGNOISE_H_
#define _PAYSAGES_QT_DIALOGNOISE_H_
#include "desktop_global.h"
#include <QListWidget>
#include <QComboBox>
#include "tools.h"
#include "NoiseGenerator.h"
class DialogNoise : public DialogWithPreview
{
Q_OBJECT
public:
explicit DialogNoise(QWidget* parent, NoiseGenerator* noise);
~DialogNoise();
static bool getNoise(QWidget* parent, NoiseGenerator* noise);
public slots:
virtual void accept();
void revert();
protected:
virtual void closeEvent(QCloseEvent* e);
private:
void revertToCurrent();
private slots:
void addLevel();
void removeLevel();
void functionChanged();
void levelChanged(int row);
void heightChanged(int value);
void scalingChanged(int value);
private:
NoiseGenerator* _base;
NoiseGenerator* _current;
int _current_level;
NoiseGenerator::NoiseLevel _current_level_params;
BasePreview* previewLevel;
BasePreview* previewTotal;
QComboBox* function_algo;
QSlider* function_ridge;
QListWidget* levels;
QSlider* slider_height;
QSlider* slider_scaling;
};
#endif

View file

@ -1,189 +0,0 @@
#include "dialogrender.h"
#include <cmath>
#include <QVBoxLayout>
#include <QImage>
#include <QColor>
#include <QPainter>
#include <QMessageBox>
#include <QFileDialog>
#include <QMessageBox>
#include <QListWidget>
#include <QPushButton>
#include <QMutex>
#include <QThread>
#include <QScrollArea>
#include <QLabel>
#include <QProgressBar>
#include <QComboBox>
#include "tools.h"
#include "Scenery.h"
#include "ColorProfile.h"
#include "SoftwareCanvasRenderer.h"
#include "WidgetPreviewCanvas.h"
#include "Canvas.h"
class RenderThread:public QThread
{
public:
RenderThread(DialogRender* dialog, SoftwareCanvasRenderer* renderer):QThread()
{
_dialog = dialog;
_renderer = renderer;
}
void run()
{
_renderer->render();
_dialog->tellRenderEnded();
}
private:
DialogRender* _dialog;
SoftwareCanvasRenderer* _renderer;
};
DialogRender::DialogRender(QWidget *parent, SoftwareCanvasRenderer* renderer):
QDialog(parent, Qt::WindowTitleHint | Qt::WindowMaximizeButtonHint | Qt::WindowMinimizeButtonHint | Qt::WindowCloseButtonHint)
{
pixbuf_lock = new QMutex();
pixbuf = new QImage(1, 1, QImage::Format_ARGB32);
_render_thread = NULL;
canvas_renderer = renderer;
setModal(true);
setWindowTitle(tr("Paysages 3D - Render"));
setLayout(new QVBoxLayout());
canvas_preview = new WidgetPreviewCanvas(this);
canvas_preview->setCanvas(canvas_renderer->getCanvas());
layout()->addWidget(canvas_preview);
// Status bar
_info = new QWidget(this);
_info->setLayout(new QHBoxLayout());
layout()->addWidget(_info);
_timer = new QLabel(QString("0:00.00"), _info);
_info->layout()->addWidget(_timer);
_progress = new QProgressBar(_info);
_progress->setMaximumHeight(12);
_progress->setMinimum(0);
_progress->setMaximum(1000);
_progress->setValue(0);
_info->layout()->addWidget(_progress);
// Action bar
_actions = new QWidget(this);
_actions->setLayout(new QHBoxLayout());
layout()->addWidget(_actions);
_actions->layout()->addWidget(new QLabel(tr("Tone-mapping: "), _actions));
_tonemapping_control = new QComboBox(_actions);
_tonemapping_control->addItems(QStringList(tr("Uncharted")) << tr("Reinhard"));
_actions->layout()->addWidget(_tonemapping_control);
_actions->layout()->addWidget(new QLabel(tr("Exposure: "), _actions));
_actions->hide();
_exposure_control = new QSlider(Qt::Horizontal, _actions);
_exposure_control->setMinimumWidth(200);
_exposure_control->setRange(0, 1000);
_exposure_control->setValue(200);
_actions->layout()->addWidget(_exposure_control);
_save_button = new QPushButton(QIcon(getDataPath("images/save.png")), tr("Save picture"), _actions);
_actions->layout()->addWidget(_save_button);
// Connections
connect(this, SIGNAL(renderEnded()), this, SLOT(applyRenderEnded()));
connect(_save_button, SIGNAL(clicked()), this, SLOT(saveRender()));
connect(_tonemapping_control, SIGNAL(currentIndexChanged(int)), this, SLOT(toneMappingChanged()));
connect(_exposure_control, SIGNAL(valueChanged(int)), this, SLOT(toneMappingChanged()));
toneMappingChanged();
}
DialogRender::~DialogRender()
{
if (_render_thread)
{
canvas_renderer->interrupt();
_render_thread->wait();
delete _render_thread;
}
delete pixbuf;
delete pixbuf_lock;
}
void DialogRender::tellRenderEnded()
{
emit renderEnded();
}
void DialogRender::startRender()
{
_started = time(NULL);
_render_thread = new RenderThread(this, canvas_renderer);
_render_thread->start();
startTimer(100);
exec();
}
void DialogRender::applyRenderEnded()
{
_info->hide();
_actions->show();
}
void DialogRender::saveRender()
{
QString filepath;
filepath = QFileDialog::getSaveFileName(this, tr("Paysages 3D - Choose a filename to save the last render"), QString(), tr("Images (*.png *.jpg)"));
if (!filepath.isNull())
{
if (!filepath.toLower().endsWith(".jpg") && !filepath.toLower().endsWith(".jpeg") && !filepath.toLower().endsWith(".png"))
{
filepath = filepath.append(".png");
}
if (canvas_renderer->saveToDisk(filepath.toStdString()))
{
QMessageBox::information(this, "Message", QString(tr("The picture %1 has been saved.")).arg(filepath));
}
else
{
QMessageBox::critical(this, "Message", QString(tr("Can't write to file : %1")).arg(filepath));
}
}
}
void DialogRender::toneMappingChanged()
{
ColorProfile profile((ColorProfile::ToneMappingOperator)_tonemapping_control->currentIndex(), ((double)_exposure_control->value()) * 0.01);
canvas_preview->setToneMapping(profile);
}
void DialogRender::loadLastRender()
{
renderEnded();
toneMappingChanged();
exec();
}
void DialogRender::timerEvent(QTimerEvent *)
{
double diff = difftime(time(NULL), _started);
int hours = (int)floor(diff / 3600.0);
int minutes = (int)floor((diff - 3600.0 * hours) / 60.0);
int seconds = (int)floor(diff - 3600.0 * hours - 60.0 * minutes);
_timer->setText(tr("%1:%2.%3").arg(hours).arg(minutes, 2, 10, QLatin1Char('0')).arg(seconds, 2, 10, QLatin1Char('0')));
_progress->setValue((int)(canvas_renderer->getProgress() * 1000.0));
_progress->update();
}

View file

@ -1,56 +0,0 @@
#ifndef _PAYSAGES_QT_DIALOGRENDER_H_
#define _PAYSAGES_QT_DIALOGRENDER_H_
#include "desktop_global.h"
#include <ctime>
#include <QDialog>
class QThread;
class QProgressBar;
class QSlider;
class QComboBox;
class QLabel;
class QScrollArea;
class QMutex;
class DialogRender : public QDialog
{
Q_OBJECT
public:
explicit DialogRender(QWidget *parent, SoftwareCanvasRenderer *renderer);
~DialogRender();
void tellRenderEnded();
void startRender();
void loadLastRender();
virtual void timerEvent(QTimerEvent *event) override;
QImage* pixbuf;
QMutex* pixbuf_lock;
private slots:
void saveRender();
void applyRenderEnded();
void toneMappingChanged();
signals:
void renderEnded();
private:
SoftwareCanvasRenderer* canvas_renderer;
WidgetPreviewCanvas* canvas_preview;
QWidget* _info;
QWidget* _actions;
QComboBox* _tonemapping_control;
QSlider* _exposure_control;
QPushButton* _save_button;
QThread* _render_thread;
QLabel* _timer;
QProgressBar* _progress;
time_t _started;
};
#endif

View file

@ -1,82 +0,0 @@
#include "formatmosphere.h"
#include "tools.h"
#include <QColor>
#include <QSlider>
#include <cmath>
#include "AtmosphereColorPreviewRenderer.h"
#include "DesktopScenery.h"
#include "BasePreview.h"
#include "AtmosphereDefinition.h"
static AtmosphereDefinition* _definition;
/**************** Form ****************/
FormAtmosphere::FormAtmosphere(QWidget *parent):
BaseForm(parent)
{
addAutoPreset(tr("Clear day"));
addAutoPreset(tr("Clear sunset"));
addAutoPreset(tr("Hazy morning"));
addAutoPreset(tr("Foggy"));
addAutoPreset(tr("Stormy"));
_definition = new AtmosphereDefinition(NULL);
previewWest = new BasePreview(this);
previewWestRenderer = new AtmosphereColorPreviewRenderer(_definition, M_PI / 2.0);
addPreview(previewWest, QString(tr("West preview")));
previewWest->setRenderer(previewWestRenderer);
previewEast = new BasePreview(this);
previewEastRenderer = new AtmosphereColorPreviewRenderer(_definition, -M_PI / 2.0);
addPreview(previewEast, QString(tr("East preview")));
previewEast->setRenderer(previewEastRenderer);
//addInputEnum(tr("Color model"), (int*)&_definition->model, QStringList(tr("Simplified model (with weather)")) << tr("Complex model"));
addInputInt(tr("Day time (hour)"), &_definition->hour, 0, 23, 1, 10);
addInputInt(tr("Day time (minute)"), &_definition->minute, 0, 59, 1, 10);
//addInputColor(tr("Sun color"), &_definition->sun_color);
addInputDouble(tr("Sun radius"), &_definition->sun_radius, 0.0, 5.0, 0.05, 0.5);
//addInputDouble(tr("Influence of skydome on lighting"), &_definition->dome_lighting, 0.0, 2.0, 0.01, 0.1);
addInputDouble(tr("Humidity"), &_definition->humidity, 0.0, 1.0, 0.01, 0.1);
addInputDouble(tr("Moon radius"), &_definition->moon_radius, 0.5, 3.0, 0.03, 0.3);
addInputDouble(tr("Moon location (horizontal)"), &_definition->moon_phi, 0.0, M_PI * 2.0, 0.05, 0.5);
addInputDouble(tr("Moon location (vertical)"), &_definition->moon_theta, -0.1, M_PI * 0.5, 0.02, 0.2);
revertConfig();
}
FormAtmosphere::~FormAtmosphere()
{
delete previewWest;
delete previewWestRenderer;
delete previewEast;
delete previewEastRenderer;
}
void FormAtmosphere::revertConfig()
{
DesktopScenery::getCurrent()->getAtmosphere(_definition);
BaseForm::revertConfig();
}
void FormAtmosphere::applyConfig()
{
DesktopScenery::getCurrent()->setAtmosphere(_definition);
BaseForm::applyConfig();
}
void FormAtmosphere::configChangeEvent()
{
_definition->validate();
BaseForm::configChangeEvent();
}
void FormAtmosphere::autoPresetSelected(int preset)
{
_definition->applyPreset((AtmosphereDefinition::AtmospherePreset)preset);
BaseForm::autoPresetSelected(preset);
}

View file

@ -1,32 +0,0 @@
#ifndef _PAYSAGES_QT_FORMATMOSPHERE_H_
#define _PAYSAGES_QT_FORMATMOSPHERE_H_
#include "desktop_global.h"
#include "baseform.h"
class QWidget;
class FormAtmosphere : public BaseForm
{
Q_OBJECT
public:
explicit FormAtmosphere(QWidget *parent = 0);
virtual ~FormAtmosphere();
public slots:
virtual void revertConfig();
virtual void applyConfig();
protected slots:
virtual void configChangeEvent();
virtual void autoPresetSelected(int preset);
private:
BasePreview* previewEast;
Base2dPreviewRenderer* previewEastRenderer;
BasePreview* previewWest;
Base2dPreviewRenderer* previewWestRenderer;
};
#endif

View file

@ -1,81 +0,0 @@
#include "formclouds.h"
#include "DesktopScenery.h"
#include "BasePreview.h"
#include "CloudsDefinition.h"
#include "CloudLayerDefinition.h"
#include "CloudsCoveragePreviewRenderer.h"
#include "CloudsAspectPreviewRenderer.h"
#include "tools.h"
/**************** Form ****************/
FormClouds::FormClouds(QWidget *parent):
BaseFormLayer(parent)
{
_definition = new CloudsDefinition(NULL);
_layer = new CloudLayerDefinition(NULL);
_previewCoverageRenderer = new CloudsCoveragePreviewRenderer(_layer);
_previewCoverage = new BasePreview(parent);
addPreview(_previewCoverage, tr("Layer coverage (no lighting)"));
_previewCoverage->setRenderer(_previewCoverageRenderer);
_previewColorRenderer = new CloudsAspectPreviewRenderer(_layer);
_previewColor = new BasePreview(parent);
addPreview(_previewColor, tr("Appearance"));
_previewColor->setRenderer(_previewColorRenderer);
QStringList cloud_models;
cloud_models << tr("Stratus")
<< tr("Nimbo-stratus")
<< tr("Cumulus")
<< tr("Strato-cumulus")
<< tr("Alto-cumulus")
<< tr("Alto-stratus")
<< tr("Cumulo-nimbus")
<< tr("Cirro-cumulus")
<< tr("Cirro-stratus")
<< tr("Cirrus");
addInputEnum(tr("Clouds model"), (int*)&_layer->type, cloud_models);
addInputDouble(tr("Altitude"), &_layer->altitude, 0.0, 1.0, 0.01, 0.1);
addInputDouble(tr("Scaling"), &_layer->scaling, 0.0, 1.0, 0.01, 0.1);
addInputDouble(tr("Coverage"), &_layer->coverage, 0.0, 1.0, 0.01, 0.1);
setLayers(_definition);
}
FormClouds::~FormClouds()
{
delete _layer;
delete _definition;
delete _previewCoverage;
delete _previewCoverageRenderer;
delete _previewColor;
delete _previewColorRenderer;
}
void FormClouds::revertConfig()
{
DesktopScenery::getCurrent()->getClouds(_definition);
BaseFormLayer::revertConfig();
}
void FormClouds::applyConfig()
{
BaseFormLayer::applyConfig();
DesktopScenery::getCurrent()->setClouds(_definition);
}
void FormClouds::layerReadCurrentFrom(void* layer_definition)
{
((CloudLayerDefinition*)layer_definition)->copy(_layer);
}
void FormClouds::layerWriteCurrentTo(void* layer_definition)
{
_layer->copy((CloudLayerDefinition*)layer_definition);
}

View file

@ -1,36 +0,0 @@
#ifndef _PAYSAGES_QT_FORMCLOUDS_H_
#define _PAYSAGES_QT_FORMCLOUDS_H_
#include "desktop_global.h"
#include "baseformlayer.h"
class QWidget;
class FormClouds : public BaseFormLayer
{
Q_OBJECT
public:
explicit FormClouds(QWidget *parent = 0);
~FormClouds();
public slots:
virtual void revertConfig();
virtual void applyConfig();
protected:
virtual void layerReadCurrentFrom(void* layer_definition);
virtual void layerWriteCurrentTo(void* layer_definition);
private:
CloudsDefinition* _definition;
CloudLayerDefinition* _layer;
BasePreview* _previewCoverage;
CloudsCoveragePreviewRenderer* _previewCoverageRenderer;
BasePreview* _previewColor;
CloudsAspectPreviewRenderer* _previewColorRenderer;
};
#endif

View file

@ -1,140 +0,0 @@
#include "formrender.h"
#include <QPushButton>
#include "dialogrender.h"
#include "inputcamera.h"
#include "tools.h"
#include "DesktopScenery.h"
#include "PackStream.h"
#include "SoftwareCanvasRenderer.h"
#include "BasePreview.h"
#include "CloudsDefinition.h"
#include "CameraDefinition.h"
#include "SceneryTopDownPreviewRenderer.h"
/**************** Form ****************/
FormRender::FormRender(QWidget *parent) :
BaseForm(parent, true)
{
QPushButton* button;
_params.quality = 5;
_params.width = 800;
_params.height = 600;
_params.antialias = 1;
_camera = new CameraDefinition;
_renderer_inited = false;
disablePreviewsUpdate();
_preview_landscape = new BasePreview(this);
_preview_landscape_renderer = new SceneryTopDownPreviewRenderer(DesktopScenery::getCurrent());
addPreview(_preview_landscape, QString(tr("Top-down preview")));
_preview_landscape->setRenderer(_preview_landscape_renderer);
addInput(new InputCamera(this, tr("Camera"), _camera));
addInputInt(tr("Quality"), &_params.quality, 1, 10, 1, 1);
addInputInt(tr("Image width"), &_params.width, 100, 4000, 10, 100);
addInputInt(tr("Image height"), &_params.height, 100, 3000, 10, 100);
addInputInt(tr("Anti aliasing"), &_params.antialias, 1, 4, 1, 1);
button = addButton(tr("Start new render"));
connect(button, SIGNAL(clicked()), this, SLOT(startRender()));
button = addButton(tr("Show last render"));
connect(button, SIGNAL(clicked()), this, SLOT(showRender()));
revertConfig();
}
FormRender::~FormRender()
{
delete _camera;
if (_renderer_inited)
{
delete _renderer;
}
}
void FormRender::savePack(PackStream* stream)
{
BaseForm::savePack(stream);
stream->write(&_params.width);
stream->write(&_params.height);
stream->write(&_params.antialias);
stream->write(&_params.quality);
}
void FormRender::loadPack(PackStream* stream)
{
BaseForm::loadPack(stream);
stream->read(&_params.width);
stream->read(&_params.height);
stream->read(&_params.antialias);
stream->read(&_params.quality);
revertConfig();
}
void FormRender::revertConfig()
{
DesktopScenery::getCurrent()->getCamera(_camera);
BaseForm::revertConfig();
}
void FormRender::applyConfig()
{
DesktopScenery::getCurrent()->setCamera(_camera);
BaseForm::applyConfig();
}
void FormRender::configChangeEvent()
{
_camera->validate();
BaseForm::configChangeEvent();
}
void FormRender::startQuickRender()
{
if (_renderer_inited)
{
delete _renderer;
}
RenderConfig config(400, 300, 1, 3);
_renderer = new SoftwareCanvasRenderer();
_renderer->setScenery(DesktopScenery::getCurrent());
_renderer->setConfig(config);
_renderer_inited = true;
DialogRender dialog(this, _renderer);
dialog.startRender();
}
void FormRender::startRender()
{
if (_renderer_inited)
{
delete _renderer;
}
_renderer = new SoftwareCanvasRenderer();
_renderer->setScenery(DesktopScenery::getCurrent());
_renderer->setConfig(_params);
_renderer_inited = true;
DialogRender dialog(this, _renderer);
dialog.startRender();
}
void FormRender::showRender()
{
if (_renderer_inited)
{
DialogRender dialog(this, _renderer);
dialog.loadLastRender();
}
}

View file

@ -1,40 +0,0 @@
#ifndef _PAYSAGES_QT_FORMRENDER_H_
#define _PAYSAGES_QT_FORMRENDER_H_
#include "desktop_global.h"
#include "baseform.h"
#include "RenderConfig.h"
class FormRender : public BaseForm
{
Q_OBJECT
public:
explicit FormRender(QWidget *parent = 0);
~FormRender();
virtual void savePack(PackStream* stream);
virtual void loadPack(PackStream* stream);
public slots:
virtual void revertConfig();
virtual void applyConfig();
void startQuickRender();
void startRender();
void showRender();
protected slots:
virtual void configChangeEvent();
private:
RenderConfig _params;
CameraDefinition* _camera;
SoftwareCanvasRenderer* _renderer;
bool _renderer_inited;
BasePreview* _preview_landscape;
Base2dPreviewRenderer* _preview_landscape_renderer;
};
#endif

View file

@ -1,88 +0,0 @@
#include "formwater.h"
#include <QColor>
#include <QSlider>
#include <cmath>
#include "tools.h"
#include "DesktopScenery.h"
#include "BasePreview.h"
#include "CameraDefinition.h"
#include "WaterDefinition.h"
#include "WaterCoveragePreviewRenderer.h"
#include "WaterAspectPreviewRenderer.h"
static WaterDefinition* _definition;
/**************** Form ****************/
FormWater::FormWater(QWidget *parent) :
BaseForm(parent)
{
addAutoPreset(tr("Lake surface"));
addAutoPreset(tr("Standard sea"));
_definition = new WaterDefinition(NULL);
previewCoverage = new BasePreview(this);
previewCoverageRenderer = new WaterCoveragePreviewRenderer(_definition);
addPreview(previewCoverage, tr("Coverage preview"));
previewCoverage->setRenderer(previewCoverageRenderer);
previewColor = new BasePreview(this);
previewColorRenderer = new WaterAspectPreviewRenderer(_definition);
addPreview(previewColor, tr("Rendered preview"));
previewColor->setRenderer(previewColorRenderer);
//addInputDouble(tr("Height"), &_definition->height, -15.0, 15.0, 0.1, 1.0);
addInputMaterial(tr("Surface material"), _definition->material);
addInputColor(tr("Depth color"), _definition->depth_color);
addInputDouble(tr("Transparency"), &_definition->transparency, 0.0, 1.0, 0.001, 0.1);
addInputDouble(tr("Reflection"), &_definition->reflection, 0.0, 1.0, 0.001, 0.1);
addInputDouble(tr("Transparency distance"), &_definition->transparency_depth, 0.0, 20.0, 0.1, 1.0);
addInputDouble(tr("Light-through distance"), &_definition->lighting_depth, 0.0, 20.0, 0.1, 1.0);
addInputDouble(tr("Waves scaling"), &_definition->scaling, 0.02, 2.0, 0.02, 0.2);
addInputDouble(tr("Waves height"), &_definition->waves_height, 0.0, 2.0, 0.02, 0.2);
addInputDouble(tr("Waves detail"), &_definition->detail_height, 0.0, 0.3, 0.003, 0.03);
addInputDouble(tr("Waves turbulence"), &_definition->turbulence, 0.0, 0.5, 0.005, 0.05);
addInputDouble(tr("Foam coverage"), &_definition->foam_coverage, 0.0, 1.0, 0.01, 0.1);
addInputMaterial(tr("Foam material"), _definition->foam_material);
revertConfig();
}
FormWater::~FormWater()
{
delete _definition;
delete previewCoverageRenderer;
delete previewCoverage;
delete previewColorRenderer;
delete previewColor;
}
void FormWater::revertConfig()
{
previewCoverageRenderer->setTerrain(DesktopScenery::getCurrent()->getTerrain());
DesktopScenery::getCurrent()->getWater(_definition);
BaseForm::revertConfig();
}
void FormWater::applyConfig()
{
DesktopScenery::getCurrent()->setWater(_definition);
BaseForm::applyConfig();
}
void FormWater::configChangeEvent()
{
_definition->validate();
BaseForm::configChangeEvent();
}
void FormWater::autoPresetSelected(int preset)
{
_definition->applyPreset((WaterDefinition::WaterPreset)preset);
BaseForm::autoPresetSelected(preset);
}

View file

@ -1,33 +0,0 @@
#ifndef _PAYSAGES_QT_FORMWATER_H_
#define _PAYSAGES_QT_FORMWATER_H_
#include "desktop_global.h"
#include "baseform.h"
class QWidget;
class FormWater : public BaseForm
{
Q_OBJECT
public:
explicit FormWater(QWidget *parent = 0);
virtual ~FormWater();
public slots:
virtual void revertConfig();
virtual void applyConfig();
protected slots:
virtual void configChangeEvent();
virtual void autoPresetSelected(int preset);
private:
BasePreview* previewCoverage;
WaterCoveragePreviewRenderer* previewCoverageRenderer;
BasePreview* previewColor;
WaterAspectPreviewRenderer* previewColorRenderer;
};
#endif

View file

@ -1,59 +0,0 @@
#include "inputboolean.h"
#include <QLabel>
#include "math.h"
InputBoolean::InputBoolean(QWidget* form, QString label, int* value) : BaseInput(form, label)
{
this->value = value;
checkbox = new QCheckBox(form);
connect(checkbox, SIGNAL(stateChanged(int)), this, SLOT(applyValue()));
_preview = new QLabel(form);
((QLabel*)_preview)->setAlignment(Qt::AlignCenter);
_control = checkbox;
}
void InputBoolean::updatePreview()
{
if (checkbox->checkState() == Qt::Checked)
{
((QLabel*)_preview)->setText(tr("Yes"));
}
else
{
((QLabel*)_preview)->setText(tr("No"));
}
BaseInput::updatePreview();
}
void InputBoolean::applyValue()
{
if (checkbox->checkState() == Qt::Checked)
{
*value = 1;
}
else
{
*value = 0;
}
BaseInput::applyValue();
}
void InputBoolean::revert()
{
if (*value)
{
checkbox->setCheckState(Qt::Checked);
}
else
{
checkbox->setCheckState(Qt::Unchecked);
}
BaseInput::revert();
}

View file

@ -1,25 +0,0 @@
#ifndef _PAYSAGES_QT_INPUTBOOLEAN_H_
#define _PAYSAGES_QT_INPUTBOOLEAN_H_
#include <QWidget>
#include <QCheckBox>
#include "baseinput.h"
class InputBoolean:public BaseInput
{
Q_OBJECT
public:
InputBoolean(QWidget* form, QString label, int* value);
public slots:
virtual void updatePreview();
virtual void applyValue();
virtual void revert();
private:
QCheckBox* checkbox;
int* value;
};
#endif

View file

@ -1,52 +0,0 @@
#include "inputcamera.h"
#include <QLabel>
#include <QPushButton>
#include <QPainter>
#include <QColorDialog>
#include "dialogexplorer.h"
InputCamera::InputCamera(QWidget* form, QString label, CameraDefinition* value):BaseInput(form, label)
{
_value = value;
_preview = new QWidget(form);
_control = new QPushButton(tr("Edit"), form);
_control->setMaximumWidth(150);
connect((QPushButton*)_control, SIGNAL(clicked()), this, SLOT(editCamera()));
}
void InputCamera::updatePreview()
{
//_preview->update();
BaseInput::updatePreview();
}
void InputCamera::applyValue()
{
BaseInput::applyValue();
}
void InputCamera::revert()
{
BaseInput::revert();
}
void InputCamera::editCamera()
{
int result;
DialogExplorer* dialog = new DialogExplorer(_control, _value, true);
result = dialog->exec();
delete dialog;
if (result == QDialog::Accepted)
{
applyValue();
}
}

View file

@ -1,30 +0,0 @@
#ifndef _PAYSAGES_QT_INPUTCAMERA_H_
#define _PAYSAGES_QT_INPUTCAMERA_H_
#include "desktop_global.h"
#include "baseinput.h"
#include <QObject>
class QWidget;
class InputCamera:public BaseInput
{
Q_OBJECT
public:
InputCamera(QWidget* form, QString label, CameraDefinition* value);
public slots:
virtual void updatePreview();
virtual void applyValue();
virtual void revert();
private slots:
void editCamera();
private:
CameraDefinition* _value;
};
#endif

View file

@ -1,54 +0,0 @@
#include "inputcolor.h"
#include <QLabel>
#include <QPushButton>
#include <QPainter>
#include <QColorDialog>
#include "Color.h"
#include "lighting/SmallPreviewColor.h"
#include "tools.h"
InputColor::InputColor(QWidget* form, QString label, Color* value):
BaseInput(form, label),
_original(value)
{
_edited = new Color();
_preview = new SmallPreviewColor(form, _edited);
_preview->setMinimumSize(50, 20);
_control = new QPushButton(tr("Edit"), form);
_control->setMaximumWidth(150);
connect((QPushButton*)_control, SIGNAL(clicked()), this, SLOT(chooseColor()));
}
void InputColor::updatePreview()
{
_preview->update();
BaseInput::updatePreview();
}
void InputColor::applyValue()
{
*_original = *_edited;
BaseInput::applyValue();
}
void InputColor::revert()
{
*_edited = *_original;
BaseInput::revert();
}
void InputColor::chooseColor()
{
QColor col = QColorDialog::getColor(colorToQColor(*_edited), _control);
if (col.isValid())
{
_edited->r = col.redF();
_edited->g = col.greenF();
_edited->b = col.blueF();
applyValue();
}
}

View file

@ -1,27 +0,0 @@
#ifndef _PAYSAGES_QT_INPUTCOLOR_H_
#define _PAYSAGES_QT_INPUTCOLOR_H_
#include <QWidget>
#include "baseinput.h"
class InputColor:public BaseInput
{
Q_OBJECT
public:
InputColor(QWidget* form, QString label, Color* value);
public slots:
virtual void updatePreview();
virtual void applyValue();
virtual void revert();
private slots:
void chooseColor();
private:
Color* _original;
Color* _edited;
};
#endif

View file

@ -1,94 +0,0 @@
#include "inputcurve.h"
#include <QLabel>
#include <QPushButton>
#include <QPainter>
#include "Curve.h"
#include "dialogcurve.h"
class CurveSmallPreview:public QWidget
{
public:
CurveSmallPreview(QWidget* parent, Curve* curve, double xmin, double xmax, double ymin, double ymax) : QWidget(parent)
{
_curve = curve;
_xmin = xmin;
_xmax = xmax;
_ymin = ymin;
_ymax = ymax;
}
void paintEvent(QPaintEvent*)
{
if (!_curve)
{
return;
}
QPainter painter(this);
int width = this->width();
int height = this->height();
double position, value, prev_value, next_value;
painter.fillRect(rect(), QColor(255, 255, 255));
for (int x = 0; x < width; x++)
{
painter.setPen(QColor(0, 0, 0));
position = _xmin + (_xmax - _xmin) * (double)x / (double)(width - 1);
value = (_curve->getValue(position) - _ymin) * (_ymax - _ymin);
prev_value = (_curve->getValue(position - (_xmax - _xmin) / (double)(width - 1)) - _ymin) * (_ymax - _ymin);
next_value = (_curve->getValue(position + (_xmax - _xmin) / (double)(width - 1)) - _ymin) * (_ymax - _ymin);
painter.drawLine(x, height - 1 - (int)((value + (prev_value - value) / 2.0) * (double)(height - 1)), x, height - 1 - (int)((value + (next_value - value) / 2.0) * (double)(height - 1)));
painter.drawPoint(x, height - 1 - (int)(value * (double)(height - 1)));
}
}
Curve* _curve;
double _xmin;
double _xmax;
double _ymin;
double _ymax;
};
InputCurve::InputCurve(QWidget* form, QString label, Curve* value, double xmin, double xmax, double ymin, double ymax, QString xlabel, QString ylabel) : BaseInput(form, label)
{
_value = value;
_xmin = xmin;
_xmax = xmax;
_ymin = ymin;
_ymax = ymax;
_xlabel = xlabel;
_ylabel = ylabel;
_preview = new CurveSmallPreview(form, value, xmin, xmax, ymin, ymax);
_preview->setMinimumSize(100, 40);
_control = new QPushButton(tr("Edit"), form);
_control->setMaximumWidth(150);
connect((QPushButton*)_control, SIGNAL(clicked()), this, SLOT(editCurve()));
}
void InputCurve::updatePreview()
{
_preview->update();
BaseInput::updatePreview();
}
void InputCurve::applyValue()
{
BaseInput::applyValue();
}
void InputCurve::revert()
{
BaseInput::revert();
}
void InputCurve::editCurve()
{
if (DialogCurve::getCurve(_control, _value, _xmin, _xmax, _ymin, _ymax, _xlabel, _ylabel))
{
applyValue();
}
}

View file

@ -1,34 +0,0 @@
#ifndef _PAYSAGES_QT_INPUTCURVE_H_
#define _PAYSAGES_QT_INPUTCURVE_H_
#include "desktop_global.h"
#include <QWidget>
#include "baseinput.h"
class InputCurve:public BaseInput
{
Q_OBJECT
public:
InputCurve(QWidget* form, QString label, Curve* value, double xmin, double xmax, double ymin, double ymax, QString xlabel, QString ylabel);
public slots:
virtual void updatePreview();
virtual void applyValue();
virtual void revert();
private slots:
void editCurve();
private:
Curve* _value;
double _xmin;
double _xmax;
double _ymin;
double _ymax;
QString _xlabel;
QString _ylabel;
};
#endif

View file

@ -1,76 +0,0 @@
#include "inputdouble.h"
#include <QLabel>
#include "math.h"
InputDouble::InputDouble(QWidget* form, QString label, double* value, double min, double max, double small_step, double large_step):
BaseInput(form, label)
{
_value = value;
_min = min;
_max = max;
_small_step = small_step;
_large_step = large_step;
_slider = new QSlider(form);
_slider->setOrientation(Qt::Horizontal);
_slider->setMinimumWidth(200);
_slider->setMaximumWidth(400);
_slider->setMinimum(0);
_slider->setMaximum(round((max - min) / small_step));
_slider->setValue(round((*value - min) / small_step));
_slider->setTickInterval(round(large_step / small_step));
_slider->setTickPosition(QSlider::TicksBelow);
connect(_slider, SIGNAL(valueChanged(int)), this, SLOT(applyValue()));
_preview = new QLabel(form);
((QLabel*)_preview)->setAlignment(Qt::AlignCenter);
_control = _slider;
}
void InputDouble::updatePreview()
{
((QLabel*)_preview)->setText(QString::number(*_value, 'g', 3));
BaseInput::updatePreview();
}
double InputDouble::getValue()
{
double result;
int ivalue = _slider->value();
if (ivalue == _slider->maximum())
{
result = _max;
}
else
{
result = _min + ((double)ivalue) * _small_step;
}
if (fabs(result) < 0.0000001)
{
result = 0.0;
}
return result;
}
void InputDouble::applyValue()
{
*_value = getValue();
BaseInput::applyValue();
}
void InputDouble::revert()
{
double value = round((*_value - _min) / _small_step);
if (value != _slider->value())
{
_slider->setValue(value);
}
BaseInput::revert();
}

View file

@ -1,32 +0,0 @@
#ifndef _PAYSAGES_QT_INPUTDOUBLE_H_
#define _PAYSAGES_QT_INPUTDOUBLE_H_
#include <QWidget>
#include <QSlider>
#include "baseinput.h"
class InputDouble:public BaseInput
{
Q_OBJECT
public:
InputDouble(QWidget* form, QString label, double* value, double min, double max, double small_step, double large_step);
public slots:
virtual void updatePreview();
virtual void applyValue();
virtual void revert();
protected:
double getValue();
private:
QSlider* _slider;
double* _value;
double _min;
double _max;
double _small_step;
double _large_step;
};
#endif

View file

@ -1,32 +0,0 @@
#include "inputenum.h"
#include <QLabel>
#include <QComboBox>
InputEnum::InputEnum(QWidget* form, QString label, int* value, const QStringList& values) : BaseInput(form, label)
{
_value = value;
_preview = new QWidget(form);
_control = new QComboBox(form);
((QComboBox*)_control)->addItems(values);
connect(_control, SIGNAL(currentIndexChanged(int)), this, SLOT(applyValue()));
}
void InputEnum::applyValue()
{
*_value = ((QComboBox*)_control)->currentIndex();
BaseInput::applyValue();
}
void InputEnum::revert()
{
if (*_value != ((QComboBox*)_control)->currentIndex())
{
((QComboBox*)_control)->setCurrentIndex(*_value);
}
BaseInput::revert();
}

View file

@ -1,23 +0,0 @@
#ifndef _PAYSAGES_QT_INPUTENUM_H_
#define _PAYSAGES_QT_INPUTENUM_H_
#include <QWidget>
#include <QStringList>
#include "baseinput.h"
class InputEnum:public BaseInput
{
Q_OBJECT
public:
InputEnum(QWidget* form, QString label, int* value, const QStringList& values);
public slots:
virtual void applyValue();
virtual void revert();
private:
int* _value;
};
#endif

View file

@ -1,29 +0,0 @@
#include "inputint.h"
#include <QLabel>
InputInt::InputInt(QWidget* form, QString label, int* value, int min, int max, int small_step, int large_step):
InputDouble(form, label, &_dvalue, (double)min, (double)max, (double)small_step, (double)large_step)
{
_value = value;
_dvalue = (double)(*value);
}
void InputInt::updatePreview()
{
((QLabel*)_preview)->setText(QString("%1").arg(_dvalue, 0, 'f', 0));
}
void InputInt::applyValue()
{
*_value = (int)getValue();
InputDouble::applyValue();
}
void InputInt::revert()
{
_dvalue = (double)(*_value);
InputDouble::revert();
}

View file

@ -1,25 +0,0 @@
#ifndef _PAYSAGES_QT_INPUTINT_H_
#define _PAYSAGES_QT_INPUTINT_H_
#include <QWidget>
#include <QSlider>
#include "inputdouble.h"
class InputInt:public InputDouble
{
Q_OBJECT
public:
InputInt(QWidget* form, QString label, int* value, int min, int max, int small_step, int large_step);
public slots:
virtual void updatePreview();
virtual void applyValue();
virtual void revert();
private:
int* _value;
double _dvalue;
};
#endif

View file

@ -1,33 +0,0 @@
#include "inputlayers.h"
#include <QLabel>
#include <QPushButton>
#include "dialoglayers.h"
InputLayers::InputLayers(QWidget* form, QString label, Layers* value, FormLayerBuilder form_builder):
BaseInput(form, label)
{
_value = value;
_form_builder = form_builder;
_preview = new QLabel(form);
((QLabel*)_preview)->setAlignment(Qt::AlignCenter);
_control = new QPushButton(tr("Editer"), form);
connect(_control, SIGNAL(clicked()), this, SLOT(editLayers()));
}
void InputLayers::updatePreview()
{
((QLabel*)_preview)->setText(tr("%1 layers").arg(_value->count()));
BaseInput::updatePreview();
}
void InputLayers::editLayers()
{
if (DialogLayers::editLayers(_control, _value, _label->text(), _form_builder))
{
applyValue();
}
}

View file

@ -1,25 +0,0 @@
#ifndef _PAYSAGES_QT_INPUTLAYERS_H_
#define _PAYSAGES_QT_INPUTLAYERS_H_
#include <QWidget>
#include "baseinput.h"
#include "dialoglayers.h"
#include "Layers.h"
class InputLayers:public BaseInput
{
Q_OBJECT
public:
InputLayers(QWidget* form, QString label, Layers* value, FormLayerBuilder form_builder);
public slots:
virtual void updatePreview();
void editLayers();
private:
Layers* _value;
FormLayerBuilder _form_builder;
};
#endif

View file

@ -1,47 +0,0 @@
#include "inputmaterial.h"
#include <QLabel>
#include <QPushButton>
#include <QPainter>
#include <QColorDialog>
#include "lighting/DialogMaterialEditor.h"
#include "previewmaterial.h"
InputMaterial::InputMaterial(QWidget* form, QString label, SurfaceMaterial* value) : BaseInput(form, label)
{
_value = value;
_preview = new SmallMaterialPreview(form, value);
_preview->setMinimumSize(100, 40);
_control = new QPushButton(tr("Edit"), form);
_control->setMaximumWidth(150);
connect((QPushButton*)_control, SIGNAL(clicked()), this, SLOT(editMaterial()));
}
void InputMaterial::updatePreview()
{
_preview->update();
BaseInput::updatePreview();
}
void InputMaterial::applyValue()
{
BaseInput::applyValue();
}
void InputMaterial::revert()
{
BaseInput::revert();
}
void InputMaterial::editMaterial()
{
if (DialogMaterialEditor::getMaterial(_control, _value))
{
applyValue();
}
}

View file

@ -1,26 +0,0 @@
#ifndef _PAYSAGES_QT_INPUTMATERIAL_H_
#define _PAYSAGES_QT_INPUTMATERIAL_H_
#include <QWidget>
#include "baseinput.h"
class InputMaterial:public BaseInput
{
Q_OBJECT
public:
InputMaterial(QWidget* form, QString label, SurfaceMaterial* value);
public slots:
virtual void updatePreview();
virtual void applyValue();
virtual void revert();
private slots:
void editMaterial();
private:
SurfaceMaterial* _value;
};
#endif

View file

@ -1,82 +0,0 @@
#include "inputnoise.h"
#include <QLabel>
#include <QPushButton>
#include <QPainter>
#include <QColorDialog>
#include "dialognoise.h"
class NoiseSmallPreview:public QWidget
{
public:
NoiseSmallPreview(QWidget* parent, NoiseGenerator* noise):
QWidget(parent),
noise(noise)
{
}
void paintEvent(QPaintEvent*)
{
if (!noise)
{
return;
}
QPainter painter(this);
int width = this->width();
int height = this->height();
double value, factor;
double minvalue, maxvalue;
noise->getRange(&minvalue, &maxvalue);
for (int x = 0; x < width; x++)
{
factor = ((double)(height / 2)) / maxvalue;
value = -noise->get1DTotal(((double)x) / factor) * factor;
painter.setPen(Qt::white);
painter.drawLine(x, 0, x, height / 2 + value);
painter.setPen(Qt::black);
painter.drawLine(x, height / 2 + value + 1, x, height);
}
}
NoiseGenerator* noise;
};
InputNoise::InputNoise(QWidget* form, QString label, NoiseGenerator* value):
BaseInput(form, label),
_value(value)
{
_preview = new NoiseSmallPreview(form, value);
_preview->setMinimumSize(100, 40);
_control = new QPushButton(tr("Edit"), form);
_control->setMaximumWidth(150);
connect((QPushButton*)_control, SIGNAL(clicked()), this, SLOT(editNoise()));
}
void InputNoise::updatePreview()
{
_preview->update();
BaseInput::updatePreview();
}
void InputNoise::applyValue()
{
BaseInput::applyValue();
}
void InputNoise::revert()
{
BaseInput::revert();
}
void InputNoise::editNoise()
{
if (DialogNoise::getNoise(_control, _value))
{
applyValue();
}
}

View file

@ -1,30 +0,0 @@
#ifndef _PAYSAGES_QT_INPUTNOISE_H_
#define _PAYSAGES_QT_INPUTNOISE_H_
#include "desktop_global.h"
#include "baseinput.h"
#include <QObject>
class QWidget;
class InputNoise:public BaseInput
{
Q_OBJECT
public:
InputNoise(QWidget* form, QString label, NoiseGenerator* value);
public slots:
virtual void updatePreview();
virtual void applyValue();
virtual void revert();
private slots:
void editNoise();
private:
NoiseGenerator* _value;
};
#endif

View file

@ -1,79 +0,0 @@
#include "DialogMaterialEditor.h"
#include "ui_DialogMaterialEditor.h"
#include "common/freeformhelper.h"
DialogMaterialEditor::DialogMaterialEditor(QWidget *parent, SurfaceMaterial* material) :
QDialog(parent),
ui(new Ui::DialogMaterialEditor),
preview_lighted(&edited)
{
ui->setupUi(this);
original = material;
edited = *original;
form_helper = new FreeFormHelper(this);
form_helper->addPreview(ui->preview_lighted, &preview_lighted);
form_helper->addDoubleInputSlider(ui->slider_hue, &edited.base.h);
form_helper->addDoubleInputSlider(ui->slider_lightness, &edited.base.l);
form_helper->addDoubleInputSlider(ui->slider_saturation, &edited.base.s);
form_helper->addDoubleInputSlider(ui->slider_hardness, &edited.hardness);
form_helper->addDoubleInputSlider(ui->slider_reflection, &edited.reflection);
form_helper->addDoubleInputSlider(ui->slider_specularity, &edited.shininess);
form_helper->addDoubleInputSlider(ui->slider_receive_shadows, &edited.receive_shadows);
form_helper->setRevertButton(ui->button_revert);
form_helper->startManaging();
ui->preview_color->setColor(&edited._rgb);
connect(ui->button_apply, SIGNAL(clicked()), this, SLOT(accept()));
connect(ui->button_cancel, SIGNAL(clicked()), this, SLOT(reject()));
}
DialogMaterialEditor::~DialogMaterialEditor()
{
delete form_helper;
delete ui;
}
bool DialogMaterialEditor::getMaterial(QWidget* parent, SurfaceMaterial* material)
{
DialogMaterialEditor dialog(parent, material);
bool validated = dialog.exec() != 0;
if (validated)
{
*material = dialog.edited;
}
return validated;
}
void DialogMaterialEditor::refreshFromLocalData()
{
edited.validate();
ui->preview_color->update();
}
void DialogMaterialEditor::refreshFromFellowData()
{
}
void DialogMaterialEditor::updateLocalDataFromScenery()
{
// Revert
edited = *original;
}
void DialogMaterialEditor::commitLocalDataToScenery()
{
}
void DialogMaterialEditor::alterRenderer(SoftwareRenderer*)
{
}

View file

@ -1,45 +0,0 @@
#ifndef DIALOGMATERIALEDITOR_H
#define DIALOGMATERIALEDITOR_H
#include "desktop_global.h"
#include <QDialog>
#include "previewmaterial.h"
#include "SurfaceMaterial.h"
namespace Ui {
class DialogMaterialEditor;
}
class FreeFormHelper;
class DialogMaterialEditor : public QDialog
{
Q_OBJECT
public:
DialogMaterialEditor(QWidget *parent, SurfaceMaterial* material);
~DialogMaterialEditor();
static bool getMaterial(QWidget* parent, SurfaceMaterial* material);
public slots:
void refreshFromLocalData();
void refreshFromFellowData();
void updateLocalDataFromScenery();
void commitLocalDataToScenery();
void alterRenderer(SoftwareRenderer* renderer);
private:
Ui::DialogMaterialEditor *ui;
SurfaceMaterial* original;
SurfaceMaterial edited;
MaterialPreviewRenderer preview_lighted;
FreeFormHelper* form_helper;
};
#endif // DIALOGMATERIALEDITOR_H

View file

@ -1,416 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DialogMaterialEditor</class>
<widget class="QDialog" name="DialogMaterialEditor">
<property name="windowModality">
<enum>Qt::ApplicationModal</enum>
</property>
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1139</width>
<height>627</height>
</rect>
</property>
<property name="windowTitle">
<string>Paysages 3D - Material editor</string>
</property>
<property name="modal">
<bool>true</bool>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<layout class="QVBoxLayout" name="verticalLayout_10">
<property name="spacing">
<number>20</number>
</property>
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Material diffusion</string>
</property>
<property name="flat">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_9">
<item>
<widget class="QLabel" name="label">
<property name="font">
<font>
<italic>true</italic>
</font>
</property>
<property name="text">
<string>This controls the way the surface diffuses its inner color in all directions, when a light source reaches it</string>
</property>
</widget>
</item>
<item>
<layout class="QFormLayout" name="formLayout">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property>
<item row="0" column="0">
<widget class="QLabel" name="baseColorLabel">
<property name="text">
<string>Base color</string>
</property>
</widget>
</item>
<item row="0" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="SmallPreviewColor" name="preview_color" native="true">
<property name="minimumSize">
<size>
<width>80</width>
<height>30</height>
</size>
</property>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="WidgetSliderDecimal" name="slider_hue">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="SmallPreviewHues" name="widget_2" native="true">
<property name="minimumSize">
<size>
<width>600</width>
<height>40</height>
</size>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item row="1" column="0">
<widget class="QLabel" name="diffuseFactorLabel">
<property name="text">
<string>Colorfulness (saturation)</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="WidgetSliderDecimal" name="slider_saturation">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="diffuseFactorLabel_2">
<property name="text">
<string>Diffuse factor (lightness)</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="WidgetSliderDecimal" name="slider_lightness">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="hardnessToLightLabel">
<property name="text">
<string>Hardness to light</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="WidgetSliderDecimal" name="slider_hardness">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
</layout>
</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_3">
<property name="title">
<string>Light reflection</string>
</property>
<property name="flat">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_11">
<item>
<widget class="QLabel" name="label_2">
<property name="font">
<font>
<italic>true</italic>
</font>
</property>
<property name="text">
<string>Amount and direction of light that is directly reflected from an incoming source (useful for shiny things)</string>
</property>
</widget>
</item>
<item>
<layout class="QFormLayout" name="formLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="reflectionFactorLabel">
<property name="text">
<string>Reflection factor</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="specularityLabel">
<property name="text">
<string>Specularity</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="WidgetSliderDecimal" name="slider_reflection">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="WidgetSliderDecimal" name="slider_specularity">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer_3">
<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_5">
<property name="title">
<string>Ambient lighting</string>
</property>
<property name="flat">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_12">
<item>
<widget class="QLabel" name="label_3">
<property name="font">
<font>
<italic>true</italic>
</font>
</property>
<property name="text">
<string>Influence of the environment on the material color</string>
</property>
</widget>
</item>
<item>
<layout class="QFormLayout" name="formLayout_3">
<item row="0" column="0">
<widget class="QLabel" name="receiveShadowsLabel">
<property name="text">
<string>Receive shadows</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="WidgetSliderDecimal" name="slider_receive_shadows">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer_4">
<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>
</item>
<item>
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Lighted preview</string>
</property>
<property name="flat">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="BasePreview" name="preview_lighted" 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>
<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>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_4">
<property name="title">
<string>Actions</string>
</property>
<property name="flat">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<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>
<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>
<item>
<widget class="QPushButton" name="button_apply">
<property name="text">
<string>Ok</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>
</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>
<customwidget>
<class>WidgetSliderDecimal</class>
<extends>QSlider</extends>
<header>common/widgetsliderdecimal.h</header>
</customwidget>
<customwidget>
<class>SmallPreviewColor</class>
<extends>QWidget</extends>
<header>lighting/SmallPreviewColor.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>SmallPreviewHues</class>
<extends>QWidget</extends>
<header>lighting/SmallPreviewHues.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources>
<include location="../../../../data/ui_pictures.qrc"/>
</resources>
<connections/>
</ui>

View file

@ -1,24 +0,0 @@
#include "SmallPreviewColor.h"
#include <QPainter>
#include "tools.h"
SmallPreviewColor::SmallPreviewColor(QWidget* parent, Color* color) : DrawingWidget(parent)
{
_color = color;
}
void SmallPreviewColor::setColor(Color* color)
{
_color = color;
update();
}
void SmallPreviewColor::doDrawing(QPainter* painter)
{
if (_color)
{
painter->fillRect(rect(), colorToQColor(*_color));
}
}

View file

@ -1,21 +0,0 @@
#ifndef SMALLPREVIEWCOLOR_H
#define SMALLPREVIEWCOLOR_H
#include "software_global.h"
#include "DrawingWidget.h"
class SmallPreviewColor: public DrawingWidget
{
Q_OBJECT
public:
SmallPreviewColor(QWidget* parent, Color* color = 0);
void setColor(Color* color);
protected:
virtual void doDrawing(QPainter* painter);
private:
Color* _color;
};
#endif /* SMALLPREVIEWCOLOR_H */

View file

@ -1,27 +0,0 @@
#include "SmallPreviewHues.h"
#include <QPainter>
#include "tools.h"
#include "ColorHSL.h"
SmallPreviewHues::SmallPreviewHues(QWidget* parent) : DrawingWidget(parent)
{
}
void SmallPreviewHues::doDrawing(QPainter* painter)
{
int x;
ColorHSL colhsl;
colhsl.s = 1.0;
colhsl.l = 0.5;
colhsl.a = 1.0;
for (x = 0; x < width(); x++)
{
colhsl.h = (double)x / (double)(width() - 1);
painter->setPen(colorToQColor(colorFromHSL(colhsl)));
painter->drawLine(x, 0, x, height() - 1);
}
}

View file

@ -1,16 +0,0 @@
#ifndef SMALLPREVIEWHUES_H
#define SMALLPREVIEWHUES_H
#include "DrawingWidget.h"
class SmallPreviewHues: public DrawingWidget
{
Q_OBJECT
public:
SmallPreviewHues(QWidget* parent);
protected:
virtual void doDrawing(QPainter* painter);
};
#endif /* SMALLPREVIEWHUES_H */

View file

@ -1,118 +0,0 @@
#include "previewmaterial.h"
#include <cmath>
#include <QPainter>
#include "tools.h"
#include "SoftwareRenderer.h"
#include "BasePreview.h"
#include "CameraDefinition.h"
#include "ColorProfile.h"
#include "LightComponent.h"
#include "LightingManager.h"
/***** Shared renderer *****/
MaterialPreviewRenderer::MaterialPreviewRenderer(SurfaceMaterial* material)
{
_light = new LightComponent;
_light->color.r = 3.0;
_light->color.g = 3.0;
_light->color.b = 3.0;
_light->direction.x = -0.5;
_light->direction.y = -0.5;
_light->direction.z = -0.5;
_light->direction = _light->direction.normalize();
_light->altered = 0;
_light->reflection = 1.0;
_material = material;
render_camera->setLocation(Vector3(0.0, 0.0, 10.0));
_color_profile = new ColorProfile;
_color_profile->setToneMapping(ColorProfile::TONE_MAPPING_UNCHARTED, 1.0);
}
MaterialPreviewRenderer::~MaterialPreviewRenderer()
{
delete _color_profile;
delete _light;
}
void MaterialPreviewRenderer::bindEvent(BasePreview* preview)
{
preview->configScaling(0.05, 2.0, 0.05, 2.0);
}
Color MaterialPreviewRenderer::getColor2D(double x, double y, double)
{
double dist = sqrt(x * x + y * y);
Vector3 point;
Color color;
if (dist >= 1.0)
{
return COLOR_TRANSPARENT;
}
else
{
point.x = x;
point.y = -y;
if (dist == 0)
{
point.z = 1.0;
}
else
{
point.z = fabs(acos(dist));
}
point = point.normalize();
color = getLightingManager()->applyFinalComponent(*_light, getCameraLocation(point), point, point, *_material);
if (dist > 0.95)
{
color.a = (1.0 - dist) / 0.05;
}
return _color_profile->apply(color);
}
}
/***** Small static preview *****/
SmallMaterialPreview::SmallMaterialPreview(QWidget* parent, SurfaceMaterial* material):
QWidget(parent),
_renderer(material)
{
}
Color SmallMaterialPreview::getColor(double x, double y)
{
return _renderer.getColor2D(x, y, 1.0);
}
void SmallMaterialPreview::paintEvent(QPaintEvent*)
{
QPainter painter(this);
int width = this->width();
int height = this->height();
double factor, dx, dy;
if (width > height)
{
factor = 2.0 / (double) height;
}
else
{
factor = 2.0 / (double) width;
}
dx = factor * (double) width / 2.0;
dy = factor * (double) height / 2.0;
for (int x = 0; x < width; x++)
{
for (int y = 0; y < height; y++)
{
painter.setPen(colorToQColor(_renderer.getColor2D((double) x * factor - dx, (double) y * factor - dy, 1.0)));
painter.drawPoint(x, y);
}
}
}

View file

@ -1,37 +0,0 @@
#ifndef _PAYSAGES_QT_PREVIEWMATERIAL_H_
#define _PAYSAGES_QT_PREVIEWMATERIAL_H_
#include "desktop_global.h"
#include "Base2dPreviewRenderer.h"
#include <QWidget>
class MaterialPreviewRenderer:public Base2dPreviewRenderer {
public:
MaterialPreviewRenderer(SurfaceMaterial* material);
virtual ~MaterialPreviewRenderer();
virtual void bindEvent(BasePreview* preview);
virtual Color getColor2D(double x, double y, double scaling);
private:
SurfaceMaterial* _material;
LightComponent* _light;
ColorProfile* _color_profile;
};
class SmallMaterialPreview:public QWidget
{
public:
SmallMaterialPreview(QWidget* parent, SurfaceMaterial* material);
Color getColor(double x, double y);
protected:
virtual void paintEvent(QPaintEvent* event);
private:
MaterialPreviewRenderer _renderer;
};
#endif

View file

@ -1,33 +0,0 @@
#include "dialogbaseterrainnoise.h"
#include "ui_dialogbaseterrainnoise.h"
#include "NoiseGenerator.h"
DialogBaseTerrainNoise::DialogBaseTerrainNoise(QWidget *parent) :
QDialog(parent),
ui(new Ui::DialogBaseTerrainNoise)
{
ui->setupUi(this);
_original = 0;
_modified = new NoiseGenerator();
}
DialogBaseTerrainNoise::~DialogBaseTerrainNoise()
{
delete ui;
delete _modified;
}
void DialogBaseTerrainNoise::setNoise(NoiseGenerator* noise)
{
_original = noise;
noise->copy(_modified);
}
int DialogBaseTerrainNoise::editNoise(QWidget* parent, NoiseGenerator* noise)
{
DialogBaseTerrainNoise dialog(parent);
dialog.setNoise(noise);
return dialog.exec();
}

View file

@ -1,35 +0,0 @@
#ifndef DIALOGBASETERRAINNOISE_H
#define DIALOGBASETERRAINNOISE_H
#include "desktop_global.h"
#include <QDialog>
namespace paysages {
namespace basics {
class NoiseGenerator;
}
}
namespace Ui {
class DialogBaseTerrainNoise;
}
class DialogBaseTerrainNoise : public QDialog
{
Q_OBJECT
public:
explicit DialogBaseTerrainNoise(QWidget *parent = 0);
~DialogBaseTerrainNoise();
void setNoise(NoiseGenerator* noise);
static int editNoise(QWidget* parent, NoiseGenerator* noise);
private:
Ui::DialogBaseTerrainNoise *ui;
NoiseGenerator* _original;
NoiseGenerator* _modified;
};
#endif // DIALOGBASETERRAINNOISE_H

View file

@ -1,43 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DialogBaseTerrainNoise</class>
<widget class="QDialog" name="DialogBaseTerrainNoise">
<property name="windowModality">
<enum>Qt::ApplicationModal</enum>
</property>
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Paysages 3D - Base terrain noise</string>
</property>
<property name="modal">
<bool>true</bool>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="WidgetGlobalFormButtons" name="widget" native="true"/>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>WidgetGlobalFormButtons</class>
<extends>QWidget</extends>
<header>common/widgetglobalformbuttons.h</header>
<container>1</container>
<slots>
<signal>okClicked()</signal>
<signal>revertClicked()</signal>
<signal>cancelClicked()</signal>
</slots>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

View file

@ -1,126 +0,0 @@
#include "dialogterrainpainting.h"
#include "ui_dialogterrainpainting.h"
#include <QKeyEvent>
#include <QWheelEvent>
#include <QMessageBox>
#include "tools.h"
#include "TerrainDefinition.h"
DialogTerrainPainting::DialogTerrainPainting(QWidget*parent, TerrainDefinition* terrain) :
QDialog(parent),
ui(new Ui::DialogTerrainPainting)
{
ui->setupUi(this);
// TEMP
ui->brush_preview->hide();
_terrain_original = terrain;
_terrain_modified = new TerrainDefinition(NULL);
ui->widget_commands->hide();
revert();
brushConfigChanged();
}
DialogTerrainPainting::~DialogTerrainPainting()
{
delete ui;
}
void DialogTerrainPainting::keyReleaseEvent(QKeyEvent* event)
{
switch (event->key())
{
case Qt::Key_F2:
ui->input_brush_mode->setCurrentIndex(0);
event->accept();
break;
case Qt::Key_F3:
ui->input_brush_mode->setCurrentIndex(1);
event->accept();
break;
case Qt::Key_F4:
ui->input_brush_mode->setCurrentIndex(2);
event->accept();
break;
case Qt::Key_F12:
ui->input_brush_mode->setCurrentIndex(3);
event->accept();
break;
default:
QDialog::keyReleaseEvent(event);
}
}
void DialogTerrainPainting::wheelEvent(QWheelEvent* event)
{
if (event->modifiers() & Qt::ControlModifier)
{
ui->input_brush_size->setValue(ui->input_brush_size->value() + (event->delta() > 0 ? 1 : -1));
event->accept();
}
else if (event->modifiers() & Qt::ShiftModifier)
{
ui->input_brush_strength->setValue(ui->input_brush_strength->value() + (event->delta() > 0 ? 1 : -1));
event->accept();
}
else if (event->modifiers() & Qt::AltModifier)
{
ui->input_brush_smoothing->setValue(ui->input_brush_smoothing->value() + (event->delta() > 0 ? 1 : -1));
event->accept();
}
else
{
event->ignore();
}
}
void DialogTerrainPainting::accept()
{
_terrain_modified->copy(_terrain_original);
QDialog::accept();
}
void DialogTerrainPainting::revert()
{
_terrain_original->copy(_terrain_modified);
ui->widget_heightmap->setTerrain(_terrain_modified);
ui->widget_heightmap->setBrush(&_brush);
}
void DialogTerrainPainting::brushConfigChanged()
{
// Fill brush object
_brush.setMode((PaintingBrushMode) ui->input_brush_mode->currentIndex());
_brush.setSize(ui->input_brush_size);
_brush.setSmoothing(ui->input_brush_smoothing);
_brush.setStrength(ui->input_brush_strength);
// Update brush description
ui->label_brush_description->setText(getHelpText());
// Update brush preview
// TODO
// Tell to 3D widget
ui->widget_heightmap->setBrush(&_brush);
}
void DialogTerrainPainting::heightmapChanged()
{
unsigned long memused = _terrain_modified->getMemoryStats();
ui->label_memory_consumption->setText(tr("Memory used: %1").arg(getHumanMemory(memused)));
ui->progress_memory_consumption->setMaximum(1024);
ui->progress_memory_consumption->setValue(memused / 1024);
}
QString DialogTerrainPainting::getHelpText()
{
QString result = _brush.getHelpText();
return result;
}

View file

@ -1,41 +0,0 @@
#ifndef DIALOGTERRAINPAINTING_H
#define DIALOGTERRAINPAINTING_H
#include "desktop_global.h"
#include <QDialog>
#include "paintingbrush.h"
namespace Ui {
class DialogTerrainPainting;
}
class DialogTerrainPainting : public QDialog
{
Q_OBJECT
public:
explicit DialogTerrainPainting(QWidget *parent, TerrainDefinition* terrain);
~DialogTerrainPainting();
protected:
virtual void keyReleaseEvent(QKeyEvent* event);
virtual void wheelEvent(QWheelEvent* event);
public slots:
void brushConfigChanged();
void heightmapChanged();
virtual void accept();
void revert();
private:
QString getHelpText();
Ui::DialogTerrainPainting *ui;
TerrainDefinition* _terrain_modified;
TerrainDefinition* _terrain_original;
PaintingBrush _brush;
};
#endif // DIALOGTERRAINPAINTING_H

View file

@ -1,993 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DialogTerrainPainting</class>
<widget class="QDialog" name="DialogTerrainPainting">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1145</width>
<height>777</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>Paysages 3D - Terrain painting</string>
</property>
<property name="sizeGripEnabled">
<bool>true</bool>
</property>
<property name="modal">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QWidget" name="verticalWidget2" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>1</horstretch>
<verstretch>1</verstretch>
</sizepolicy>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2" stretch="0,0,0">
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<property name="spacing">
<number>20</number>
</property>
<item>
<widget class="QLabel" name="label_21">
<property name="text">
<string>Display :</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBox">
<property name="text">
<string>Water</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBox_2">
<property name="text">
<string>Grid</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBox_3">
<property name="text">
<string>Painted area</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="pushButton">
<property name="text">
<string>Commands</string>
</property>
<property name="icon">
<iconset resource="../../../../data/ui_pictures.qrc">
<normaloff>:/buttons/logo/images/about.png</normaloff>:/buttons/logo/images/about.png</iconset>
</property>
<property name="iconSize">
<size>
<width>16</width>
<height>16</height>
</size>
</property>
<property name="shortcut">
<string notr="true">F1</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
<property name="flat">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QWidget" name="widget_commands" native="true">
<property name="styleSheet">
<string notr="true"/>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item alignment="Qt::AlignTop">
<widget class="QGroupBox" name="groupBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Shortcuts</string>
</property>
<property name="flat">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<layout class="QGridLayout" name="gridLayout">
<property name="horizontalSpacing">
<number>16</number>
</property>
<item row="1" column="1">
<widget class="QLabel" name="label_9">
<property name="text">
<string>Switch to raise/lower tool</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_10">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>F3</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Show these commands</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_12">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>F4</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>F1</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_8">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>F2</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLabel" name="label_11">
<property name="text">
<string>Switch to noise/smooth tool</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLabel" name="label_13">
<property name="text">
<string>Switch to flatten tool</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_16">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>F12</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLabel" name="label_17">
<property name="text">
<string>Switch to restore tool</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item alignment="Qt::AlignTop">
<widget class="QGroupBox" name="groupBox_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Brush control</string>
</property>
<property name="flat">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_6">
<item>
<layout class="QGridLayout" name="gridLayout_2">
<property name="horizontalSpacing">
<number>16</number>
</property>
<item row="1" column="1">
<widget class="QLabel" name="label_18">
<property name="text">
<string>Set brush smoothing</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_19">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>SHIFT + Mouse wheel</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="label_20">
<property name="text">
<string>Set brush size</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_22">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>CTRL + Mouse wheel</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_23">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>ALT + Mouse wheel</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLabel" name="label_25">
<property name="text">
<string>Set brush strength</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<widget class="Line" name="line_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item alignment="Qt::AlignTop">
<widget class="QGroupBox" name="groupBox_3">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Camera control</string>
</property>
<property name="flat">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_7">
<item>
<layout class="QGridLayout" name="gridLayout_3">
<property name="horizontalSpacing">
<number>16</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label_34">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Mouse wheel</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_35">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Borders</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="label_30">
<property name="text">
<string>Scroll view</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="label_32">
<property name="text">
<string>Zoom</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="WidgetHeightMap" name="widget_heightmap" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>1</horstretch>
<verstretch>1</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>400</width>
<height>400</height>
</size>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="verticalWidget" native="true">
<property name="maximumSize">
<size>
<width>450</width>
<height>16777215</height>
</size>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QWidget" name="widget_2" native="true">
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<layout class="QFormLayout" name="formLayout">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Brush Tool : </string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="input_brush_mode">
<item>
<property name="text">
<string>Raise / Lower (F2)</string>
</property>
</item>
<item>
<property name="text">
<string>Add noise / Smooth (F3)</string>
</property>
</item>
<item>
<property name="text">
<string>Flatten terrain (F4)</string>
</property>
</item>
<item>
<property name="text">
<string>Restore to base shape (F12)</string>
</property>
</item>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Brush size :</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QSlider" name="input_brush_size">
<property name="maximum">
<number>100</number>
</property>
<property name="value">
<number>40</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Brush smoothing :</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QSlider" name="input_brush_smoothing">
<property name="maximum">
<number>100</number>
</property>
<property name="value">
<number>100</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Brush strength :</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QSlider" name="input_brush_strength">
<property name="maximum">
<number>100</number>
</property>
<property name="value">
<number>20</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="label_brush_description">
<property name="minimumSize">
<size>
<width>0</width>
<height>100</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::Panel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
<property name="text">
<string notr="true">{ Brush information }</string>
</property>
<property name="textFormat">
<enum>Qt::RichText</enum>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="margin">
<number>20</number>
</property>
</widget>
</item>
<item>
<widget class="QWidget" name="brush_preview" native="true">
<layout class="QHBoxLayout" name="container_brush_preview">
<property name="topMargin">
<number>8</number>
</property>
<item>
<widget class="QLabel" name="label_7">
<property name="text">
<string>Brush preview :</string>
</property>
</widget>
</item>
<item>
<widget class="QWidget" name="widget_brush_preview" native="true">
<property name="minimumSize">
<size>
<width>200</width>
<height>200</height>
</size>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</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>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<item>
<widget class="QProgressBar" name="progress_memory_consumption">
<property name="maximumSize">
<size>
<width>150</width>
<height>16777215</height>
</size>
</property>
<property name="value">
<number>24</number>
</property>
<property name="textVisible">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_memory_consumption">
<property name="text">
<string notr="true">{ memory consumption }</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="WidgetGlobalFormButtons" name="widget_4" native="true">
<property name="minimumSize">
<size>
<width>100</width>
<height>30</height>
</size>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>WidgetGlobalFormButtons</class>
<extends>QWidget</extends>
<header>common/widgetglobalformbuttons.h</header>
<container>1</container>
<slots>
<signal>okClicked()</signal>
<signal>revertClicked()</signal>
<signal>cancelClicked()</signal>
</slots>
</customwidget>
<customwidget>
<class>WidgetHeightMap</class>
<extends>QWidget</extends>
<header>terrain/widgetheightmap.h</header>
<container>1</container>
<slots>
<signal>heightmapChanged()</signal>
<slot>toggleWater(bool)</slot>
<slot>toggleGrid(bool)</slot>
<slot>togglePaintedArea(bool)</slot>
</slots>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>input_brush_mode</tabstop>
<tabstop>input_brush_size</tabstop>
<tabstop>input_brush_smoothing</tabstop>
<tabstop>input_brush_strength</tabstop>
</tabstops>
<resources>
<include location="../../../../data/ui_pictures.qrc"/>
</resources>
<connections>
<connection>
<sender>input_brush_smoothing</sender>
<signal>valueChanged(int)</signal>
<receiver>DialogTerrainPainting</receiver>
<slot>brushConfigChanged()</slot>
<hints>
<hint type="sourcelabel">
<x>919</x>
<y>94</y>
</hint>
<hint type="destinationlabel">
<x>437</x>
<y>102</y>
</hint>
</hints>
</connection>
<connection>
<sender>input_brush_mode</sender>
<signal>currentIndexChanged(int)</signal>
<receiver>DialogTerrainPainting</receiver>
<slot>brushConfigChanged()</slot>
<hints>
<hint type="sourcelabel">
<x>1115</x>
<y>53</y>
</hint>
<hint type="destinationlabel">
<x>437</x>
<y>40</y>
</hint>
</hints>
</connection>
<connection>
<sender>input_brush_strength</sender>
<signal>valueChanged(int)</signal>
<receiver>DialogTerrainPainting</receiver>
<slot>brushConfigChanged()</slot>
<hints>
<hint type="sourcelabel">
<x>1115</x>
<y>143</y>
</hint>
<hint type="destinationlabel">
<x>437</x>
<y>132</y>
</hint>
</hints>
</connection>
<connection>
<sender>input_brush_size</sender>
<signal>valueChanged(int)</signal>
<receiver>DialogTerrainPainting</receiver>
<slot>brushConfigChanged()</slot>
<hints>
<hint type="sourcelabel">
<x>919</x>
<y>73</y>
</hint>
<hint type="destinationlabel">
<x>437</x>
<y>72</y>
</hint>
</hints>
</connection>
<connection>
<sender>widget_4</sender>
<signal>cancelClicked()</signal>
<receiver>DialogTerrainPainting</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>1134</x>
<y>766</y>
</hint>
<hint type="destinationlabel">
<x>711</x>
<y>597</y>
</hint>
</hints>
</connection>
<connection>
<sender>widget_4</sender>
<signal>okClicked()</signal>
<receiver>DialogTerrainPainting</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>1134</x>
<y>766</y>
</hint>
<hint type="destinationlabel">
<x>683</x>
<y>597</y>
</hint>
</hints>
</connection>
<connection>
<sender>widget_4</sender>
<signal>revertClicked()</signal>
<receiver>DialogTerrainPainting</receiver>
<slot>revert()</slot>
<hints>
<hint type="sourcelabel">
<x>1134</x>
<y>766</y>
</hint>
<hint type="destinationlabel">
<x>747</x>
<y>597</y>
</hint>
</hints>
</connection>
<connection>
<sender>checkBox</sender>
<signal>toggled(bool)</signal>
<receiver>widget_heightmap</receiver>
<slot>toggleWater(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>153</x>
<y>43</y>
</hint>
<hint type="destinationlabel">
<x>58</x>
<y>480</y>
</hint>
</hints>
</connection>
<connection>
<sender>checkBox_2</sender>
<signal>toggled(bool)</signal>
<receiver>widget_heightmap</receiver>
<slot>toggleGrid(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>234</x>
<y>43</y>
</hint>
<hint type="destinationlabel">
<x>121</x>
<y>463</y>
</hint>
</hints>
</connection>
<connection>
<sender>widget_heightmap</sender>
<signal>heightmapChanged()</signal>
<receiver>DialogTerrainPainting</receiver>
<slot>heightmapChanged()</slot>
<hints>
<hint type="sourcelabel">
<x>465</x>
<y>523</y>
</hint>
<hint type="destinationlabel">
<x>481</x>
<y>569</y>
</hint>
</hints>
</connection>
<connection>
<sender>pushButton</sender>
<signal>toggled(bool)</signal>
<receiver>widget_commands</receiver>
<slot>setVisible(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>734</x>
<y>40</y>
</hint>
<hint type="destinationlabel">
<x>536</x>
<y>104</y>
</hint>
</hints>
</connection>
<connection>
<sender>checkBox_3</sender>
<signal>toggled(bool)</signal>
<receiver>widget_heightmap</receiver>
<slot>togglePaintedArea(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>307</x>
<y>33</y>
</hint>
<hint type="destinationlabel">
<x>377</x>
<y>519</y>
</hint>
</hints>
</connection>
</connections>
<slots>
<slot>brushConfigChanged()</slot>
<slot>heightmapChanged()</slot>
<slot>revert()</slot>
<slot>displayCommands()</slot>
</slots>
</ui>

View file

@ -1,135 +0,0 @@
#include "mainterrainform.h"
#include "ui_mainterrainform.h"
#include <QMessageBox>
#include "dialogbaseterrainnoise.h"
#include "dialogterrainpainting.h"
#include "TerrainShapePreviewRenderer.h"
#include "common/freeformhelper.h"
#include "tools.h"
#include "DesktopScenery.h"
#include "TexturesDefinition.h"
#include "TerrainDefinition.h"
#include "TerrainHeightMap.h"
MainTerrainForm::MainTerrainForm(QWidget *parent) :
QWidget(parent),
ui(new Ui::MainTerrainForm)
{
_terrain = new TerrainDefinition(NULL);
ui->setupUi(this);
// TEMP
ui->button_dialog_basenoise->hide();
_form_helper = new FreeFormHelper(this);
_renderer_shape = new TerrainShapePreviewRenderer(_terrain);
_form_helper->addPreview(ui->preview_shape, _renderer_shape);
_form_helper->addDoubleInputSlider(ui->input_scaling, &_terrain->scaling, 0.1, 3.0, 0.03, 0.3);
_form_helper->addDoubleInputSlider(ui->input_height, &_terrain->height, 1.0, 90.0, 0.5, 5.0);
_form_helper->addDoubleInputSlider(ui->input_shadow_smoothing, &_terrain->shadow_smoothing, 0.0, 0.3, 0.003, 0.03);
_form_helper->addDoubleInputSlider(ui->input_water_height, &_terrain->water_height, -1.0, 1.0, 0.01, 0.1);
_form_helper->setApplyButton(ui->button_apply);
_form_helper->setRevertButton(ui->button_revert);
_form_helper->setExploreButton(ui->button_explore);
_form_helper->setRenderButton(ui->button_render);
connect(ui->button_dialog_basenoise, SIGNAL(clicked()), this, SLOT(buttonBaseNoisePressed()));
connect(ui->button_dialog_painting, SIGNAL(clicked()), this, SLOT(buttonPaintingPressed()));
connect(ui->button_goto_textures, SIGNAL(clicked()), this, SLOT(buttonTexturesPressed()));
_form_helper->startManaging();
}
MainTerrainForm::~MainTerrainForm()
{
delete _form_helper;
delete ui;
delete _renderer_shape;
delete _terrain;
}
void MainTerrainForm::refreshFromLocalData()
{
unsigned long memused = _terrain->getMemoryStats();
if (memused > 0)
{
_form_helper->setLabelText(ui->label_painting_info, tr("Memory used by sculpted data: %1").arg(getHumanMemory(memused)));
}
else
{
_form_helper->setLabelText(ui->label_painting_info, tr("No manual scuplting done"));
}
ui->widget_base_noise_preview->setNoise(_terrain->_height_noise);
}
void MainTerrainForm::refreshFromFellowData()
{
double disp = DesktopScenery::getCurrent()->getTextures()->getMaximalDisplacement();
if (disp == 0.0)
{
ui->label_info_textures->setText(tr("No displacement textures"));
}
else
{
HeightInfo info = DesktopScenery::getCurrent()->getTerrain()->getHeightInfo();
double terrain_height = info.max_height - info.min_height;
ui->label_info_textures->setText(tr("Maximal displacement : %1% of total height").arg(100.0 * disp / terrain_height, 0, 'f', 1));
}
}
void MainTerrainForm::updateLocalDataFromScenery()
{
DesktopScenery::getCurrent()->getTerrain(_terrain);
}
void MainTerrainForm::commitLocalDataToScenery()
{
DesktopScenery::getCurrent()->setTerrain(_terrain);
}
void MainTerrainForm::alterRenderer(SoftwareRenderer* renderer)
{
renderer->getScenery()->setTerrain(_terrain);
renderer->prepare();
}
void MainTerrainForm::buttonBaseNoisePressed()
{
int erase;
if (_terrain->getMemoryStats() > 0)
{
erase = QMessageBox::question(this, tr("Paysages 3D - Base noise edition"), tr("You have manual modifications on this terrain, regenerating base noise may produce weird results."), tr("Keep my changes anyway"), tr("Erase my changes"));
}
else
{
erase = 0;
}
if (DialogBaseTerrainNoise::editNoise(this, _terrain->_height_noise))
{
if (erase)
{
_terrain->height_map->clearPainting();
}
}
}
void MainTerrainForm::buttonPaintingPressed()
{
DialogTerrainPainting dialog(this, _terrain);
_form_helper->openDialog(&dialog);
}
void MainTerrainForm::buttonTexturesPressed()
{
// Switch to textures tab
_form_helper->gotoMainTab(1);
}

View file

@ -1,44 +0,0 @@
#ifndef MAINTERRAINFORM_H
#define MAINTERRAINFORM_H
#include "desktop_global.h"
#include <QWidget>
class FreeFormHelper;
namespace Ui {
class MainTerrainForm;
}
class MainTerrainForm : public QWidget
{
Q_OBJECT
public:
explicit MainTerrainForm(QWidget *parent = 0);
~MainTerrainForm();
inline TerrainDefinition* getTerrainDefinition() {return _terrain;}
public slots:
void refreshFromLocalData();
void refreshFromFellowData();
void updateLocalDataFromScenery();
void commitLocalDataToScenery();
void alterRenderer(SoftwareRenderer* renderer);
void buttonBaseNoisePressed();
void buttonPaintingPressed();
void buttonTexturesPressed();
private:
Ui::MainTerrainForm *ui;
FreeFormHelper* _form_helper;
TerrainDefinition* _terrain;
Base2dPreviewRenderer* _renderer_shape;
};
#endif // MAINTERRAINFORM_H

View file

@ -1,538 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainTerrainForm</class>
<widget class="QWidget" name="MainTerrainForm">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1181</width>
<height>693</height>
</rect>
</property>
<property name="windowTitle">
<string>Terrain editor</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<layout class="QVBoxLayout" name="verticalLayout_10">
<property name="spacing">
<number>20</number>
</property>
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Infinite base shape</string>
</property>
<property name="flat">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_9">
<item>
<widget class="QLabel" name="label_5">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-style:italic;&quot;&gt;This is the base shape for your landscape, infinitely generated from a random mathematical function. You can then customize this raw shape by sculpting it, and adding displacement textures.&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="scaledContents">
<bool>false</bool>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QPushButton" name="button_dialog_basenoise">
<property name="text">
<string>Generate base noise</string>
</property>
<property name="flat">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="WidgetTerrainBaseNoisePreview" name="widget_base_noise_preview" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>500</width>
<height>80</height>
</size>
</property>
</widget>
</item>
</layout>
</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_3">
<property name="title">
<string>Manual modifications</string>
</property>
<property name="flat">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_8">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QPushButton" name="button_dialog_painting">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Sculpt the terrain shape</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_painting_info">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string notr="true">{ heightmap info }</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer_3">
<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_1">
<property name="title">
<string>Global modifiers</string>
</property>
<property name="flat">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_6">
<item>
<widget class="QLabel" name="label_6">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-style:italic;&quot;&gt;These modifiers change the base shape and manual modifications altogether.&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="textFormat">
<enum>Qt::RichText</enum>
</property>
</widget>
</item>
<item>
<layout class="QFormLayout" name="formLayout">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Scaling</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="WidgetSliderDecimal" name="input_scaling">
<property name="maximumSize">
<size>
<width>400</width>
<height>16777215</height>
</size>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Height</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="WidgetSliderDecimal" name="input_height">
<property name="maximumSize">
<size>
<width>400</width>
<height>16777215</height>
</size>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer_4">
<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_6">
<property name="title">
<string>Rendering control</string>
</property>
<property name="flat">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_7">
<item>
<layout class="QFormLayout" name="formLayout_3">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Shadow smoothing</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="WidgetSliderDecimal" name="input_shadow_smoothing">
<property name="maximumSize">
<size>
<width>400</width>
<height>16777215</height>
</size>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer_5">
<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_7">
<property name="title">
<string>Links to other modules</string>
</property>
<property name="flat">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<layout class="QVBoxLayout" name="verticalLayout_12">
<item>
<layout class="QFormLayout" name="formLayout_6">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Relative water height</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="WidgetSliderDecimal" name="input_water_height">
<property name="minimumSize">
<size>
<width>450</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>400</width>
<height>16777215</height>
</size>
</property>
<property name="maximum">
<number>499</number>
</property>
<property name="pageStep">
<number>50</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QPushButton" name="button_goto_textures">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>500</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>Go to textures to add relief effect (rocks...)</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_info_textures">
<property name="text">
<string notr="true">{ textures info }</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
<widget class="QWidget" name="widget_8" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>200</width>
<height>0</height>
</size>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer_6">
<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>
</item>
<item>
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Result preview</string>
</property>
<property name="flat">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="BasePreview" name="preview_shape" 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>
<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>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_4">
<property name="title">
<string>Actions</string>
</property>
<property name="flat">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<widget class="QPushButton" name="button_revert">
<property name="text">
<string>Revert modifications</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>
<item>
<widget class="QPushButton" name="button_apply">
<property name="text">
<string>Apply modifications</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>
</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>
<customwidget>
<class>WidgetSliderDecimal</class>
<extends>QSlider</extends>
<header>common/widgetsliderdecimal.h</header>
</customwidget>
<customwidget>
<class>WidgetTerrainBaseNoisePreview</class>
<extends>QWidget</extends>
<header>terrain/widgetterrainbasenoisepreview.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources>
<include location="../../../../data/ui_pictures.qrc"/>
</resources>
<connections/>
</ui>

View file

@ -1,151 +0,0 @@
#include "paintingbrush.h"
#include <cmath>
#include <QAbstractSlider>
#include "NoiseGenerator.h"
#include "TerrainDefinition.h"
#include "TerrainHeightMap.h"
#include "PaintedGridBrush.h"
PaintingBrush::PaintingBrush()
{
_mode = PAINTING_BRUSH_RAISE;
_size = 0.0;
_smoothing = 0.0;
_strength = 0.0;
_height = 0.0;
_noise = new NoiseGenerator();
_noise->addLevelsSimple(10, 1.0, -0.5, 0.5, 0.5);
}
PaintingBrush::~PaintingBrush()
{
delete _noise;
}
void PaintingBrush::setMode(PaintingBrushMode mode)
{
_mode = mode;
}
void PaintingBrush::setSize(double value)
{
_size = value;
}
void PaintingBrush::setSize(QAbstractSlider* slider)
{
double value = (double)slider->value() / (double)slider->maximum();
setSize(2.0 + value * value * 28.0);
}
void PaintingBrush::setSmoothing(double value)
{
_smoothing = value;
}
void PaintingBrush::setSmoothing(QAbstractSlider* slider)
{
setSmoothing((double)slider->value() / (double)slider->maximum());
}
void PaintingBrush::setStrength(double value)
{
_strength = value;
}
void PaintingBrush::setStrength(QAbstractSlider* slider)
{
setStrength(0.1 + 0.9 * (double)slider->value() / (double)slider->maximum());
}
void PaintingBrush::randomizeNoise()
{
_noise->randomizeOffsets();
}
double PaintingBrush::getInfluence(double relative_x, double relative_z)
{
double distance = sqrt(relative_x * relative_x + relative_z * relative_z);
if (distance > _size)
{
return 0.0;
}
else if (distance > _size * (1.0 - _smoothing))
{
return 1.0 - (distance - _size * (1.0 - _smoothing)) / (_size * _smoothing);
}
else
{
return 1.0;
}
}
void PaintingBrush::drawPreview(QWidget*)
{
}
QString PaintingBrush::getHelpText()
{
switch (_mode)
{
case PAINTING_BRUSH_RAISE:
return QObject::tr("<strong>Left click</strong>: raise terrain<br><br><strong>Right click</strong>: lower terrain");
case PAINTING_BRUSH_SMOOTH:
return QObject::tr("<strong>Left click</strong>: add random noise to terrain<br><br><strong>Right click</strong>: smooth details");
case PAINTING_BRUSH_FLATTEN:
return QObject::tr("<strong>Left click</strong>: flatten at height picked with right click<br><br><strong>Right click</strong>: pick height at center");
case PAINTING_BRUSH_RESTORE:
return QObject::tr("<strong>Left click</strong>: remove your manual modifications from terrain");
}
return QString("");
}
void PaintingBrush::applyToTerrain(TerrainDefinition* terrain, double x, double z, double duration, bool reverse)
{
double brush_strength;
double hard_radius = _size * (1.0 - _smoothing);
double smoothed_size = _size * _smoothing;
double total_radius = hard_radius + smoothed_size;
PaintedGridBrush brush(hard_radius, smoothed_size, total_radius);
brush_strength = 0.5 * _strength * duration / 0.1;
switch (_mode)
{
case PAINTING_BRUSH_RAISE:
if (reverse)
{
brush_strength = -brush_strength;
}
terrain->height_map->brushElevation(brush, x, z, brush_strength * 2.0);
break;
case PAINTING_BRUSH_SMOOTH:
if (reverse)
{
terrain->height_map->brushSmooth(brush, x, z, brush_strength * 30.0);
}
else
{
terrain->height_map->brushAddNoise(brush, x, z, _noise, brush_strength * 0.3);
}
break;
case PAINTING_BRUSH_FLATTEN:
if (reverse)
{
_height = terrain->getInterpolatedHeight(x * terrain->scaling, z * terrain->scaling, false, true);
}
else
{
terrain->height_map->brushFlatten(brush, x, z, _height, brush_strength * 30.0);
}
break;
case PAINTING_BRUSH_RESTORE:
terrain->height_map->brushReset(brush, x, z, brush_strength * 30.0);
break;
default:
return;
}
}

View file

@ -1,48 +0,0 @@
#ifndef PAINTINGBRUSH_H
#define PAINTINGBRUSH_H
#include "desktop_global.h"
class QAbstractSlider;
class QWidget;
typedef enum
{
PAINTING_BRUSH_RAISE = 0,
PAINTING_BRUSH_SMOOTH = 1,
PAINTING_BRUSH_FLATTEN = 2,
PAINTING_BRUSH_RESTORE = 3
} PaintingBrushMode;
class PaintingBrush
{
public:
PaintingBrush();
~PaintingBrush();
void setMode(PaintingBrushMode mode);
void setSize(double value);
void setSize(QAbstractSlider* slider);
void setSmoothing(double value);
void setSmoothing(QAbstractSlider* slider);
void setStrength(double value);
void setStrength(QAbstractSlider* slider);
void randomizeNoise();
double getInfluence(double relative_x, double relative_z);
void drawPreview(QWidget* widget);
QString getHelpText();
void applyToTerrain(TerrainDefinition* terrain, double x, double z, double duration, bool reverse);
private:
PaintingBrushMode _mode;
double _size;
double _smoothing;
double _strength;
double _height;
NoiseGenerator* _noise;
};
#endif // PAINTINGBRUSH_H

View file

@ -1,573 +0,0 @@
#include "widgetheightmap.h"
#include <QTime>
#include <QMouseEvent>
#include <QWidget>
#include <math.h>
#include <GL/glu.h>
#include "tools.h"
#include "SoftwareRenderer.h"
#include "Scenery.h"
#include "TerrainDefinition.h"
#include "TerrainHeightMap.h"
#include "WaterDefinition.h"
#include "TerrainRenderer.h"
#define HEIGHTMAP_RESOLUTION 256
WidgetHeightMap::WidgetHeightMap(QWidget* parent) :
QGLWidget(parent)
{
setMinimumSize(500, 500);
setFocusPolicy(Qt::StrongFocus);
setMouseTracking(true);
setCursor(Qt::CrossCursor);
startTimer(100);
_terrain = NULL;
_renderer = new SoftwareRenderer();
_vertices = new _VertexInfo[HEIGHTMAP_RESOLUTION * HEIGHTMAP_RESOLUTION];
_dirty = true;
_water = true;
_wireframe = true;
_painted_area = true;
_average_frame_time = 0.0;
_last_brush_action = 0;
_last_mouse_x = 250;
_last_mouse_y = 250;
_last_time = QDateTime::currentDateTime();
_mouse_moved = false;
_target_x = 0.0;
_target_z = 0.0;
_last_update_x = 0;
_last_update_z = 0;
_current_camera = new CameraDefinition;
_top_camera = new CameraDefinition;
_temp_camera = new CameraDefinition;
_zoom = 35.0;
_current_camera->setLocation(Vector3(0.0, 80.0, 10.0));
_current_camera->setTarget(VECTOR_ZERO);
_top_camera->setZoomToTarget(_zoom);
_current_camera->copy(_top_camera);
_brush = NULL;
_brush_x = 0.0;
_brush_z = 0.0;
}
WidgetHeightMap::~WidgetHeightMap()
{
delete _current_camera;
delete _top_camera;
delete _temp_camera;
delete _renderer;
delete[] _vertices;
}
void WidgetHeightMap::setTerrain(TerrainDefinition* terrain)
{
_terrain = terrain;
_renderer->getScenery()->setTerrain(_terrain);
_renderer->prepare();
revert();
}
void WidgetHeightMap::setBrush(PaintingBrush* brush)
{
_brush = brush;
updateGL();
}
void WidgetHeightMap::revert()
{
_dirty = true;
updateGL();
}
void WidgetHeightMap::toggleWater(bool enabled)
{
_water = enabled;
updateGL();
}
void WidgetHeightMap::toggleGrid(bool enabled)
{
_wireframe = enabled;
updateGL();
}
void WidgetHeightMap::togglePaintedArea(bool enabled)
{
_painted_area = enabled;
updateGL();
}
void WidgetHeightMap::keyPressEvent(QKeyEvent* event)
{
if (event->key() == Qt::Key_Up)
{
scrollTopCamera(0.0, -1.0);
}
else if (event->key() == Qt::Key_Down)
{
scrollTopCamera(0.0, 1.0);
}
else if (event->key() == Qt::Key_Left)
{
scrollTopCamera(-1.0, 0.0);
}
else if (event->key() == Qt::Key_Right)
{
scrollTopCamera(1.0, 0.0);
}
else if (event->key() == Qt::Key_PageUp)
{
zoomTopCamera(-3.0);
}
else if (event->key() == Qt::Key_PageDown)
{
zoomTopCamera(3.0);
}
else
{
QGLWidget::keyPressEvent(event);
}
}
void WidgetHeightMap::wheelEvent(QWheelEvent* event)
{
if (event->modifiers() == Qt::NoModifier)
{
if (event->orientation() == Qt::Vertical)
{
zoomTopCamera(-0.05 * (double) event->delta());
}
event->accept();
}
else
{
event->ignore();
}
}
void WidgetHeightMap::mousePressEvent(QMouseEvent* event)
{
_last_mouse_x = event->x();
_last_mouse_y = event->y();
if (event->buttons() & Qt::LeftButton)
{
_last_brush_action = 1;
}
else if (event->buttons() & Qt::RightButton)
{
_last_brush_action = -1;
}
}
void WidgetHeightMap::mouseReleaseEvent(QMouseEvent*)
{
_last_brush_action = 0;
if (_terrain)
{
_terrain->height_map->endBrushStroke();
}
if (_brush)
{
_brush->randomizeNoise();
}
}
void WidgetHeightMap::mouseMoveEvent(QMouseEvent* event)
{
/*if (event->buttons() & Qt::MiddleButton)
{
// Rotate around the turntable
int move_x = event->x() - _last_mouse_x;
int move_y = event->y() - _last_mouse_y;
// TODO
//_angle_h -= (double)move_x * 0.008;
//_angle_v += (double)move_y * 0.003;
}*/
_last_mouse_x = event->x();
_last_mouse_y = event->y();
_mouse_moved = true;
updateGL();
}
void WidgetHeightMap::timerEvent(QTimerEvent*)
{
if (not _terrain)
{
return;
}
QDateTime new_time = QDateTime::currentDateTime();
double duration = 0.001 * (double) _last_time.msecsTo(new_time);
_last_time = new_time;
// Update top camera
Vector3 target = {_target_x, _terrain->getInterpolatedHeight(_target_x, _target_z, true, true), _target_z};
_top_camera->setLocationCoords(target.x, target.y + 1.0, target.z + 0.1);
_top_camera->setTarget(target);
_top_camera->setZoomToTarget(_zoom);
if (_current_camera->transitionToAnother(_top_camera, 0.8))
{
int update_x = (int) (floor(_target_x));
int update_z = (int) (floor(_target_z));
if (update_x - _last_update_x < -10 || update_x - _last_update_x > 10 || update_z - _last_update_z < -10 || update_z - _last_update_z > 10)
{
_dirty = true;
}
updateGL();
}
if (not underMouse())
{
return;
}
// Apply brush action
if (_last_brush_action != 0 && _brush)
{
_brush->applyToTerrain(_terrain, _brush_x + _target_x, _brush_z + _target_z, duration, _last_brush_action < 0);
// TODO Only mark dirty the updated area
_dirty = true;
updateGL();
}
// Edge scrolling
double wx = (double) _last_mouse_x / (double) width();
double wy = (double) _last_mouse_y / (double) height();
double limit = 0.15;
double force = 1.0;
if (wx < limit)
{
scrollTopCamera(-(1.0 - wx / limit) * force, 0.0);
}
else if (wx > 1.0 - limit)
{
scrollTopCamera(force * (wx - (1.0 - limit)) / limit, 0.0);
}
if (wy < limit)
{
scrollTopCamera(0.0, -(1.0 - wy / limit) * force);
}
else if (wy > 1.0 - limit)
{
scrollTopCamera(0.0, force * (wy - (1.0 - limit)) / limit);
}
}
void WidgetHeightMap::initializeGL()
{
glClearColor(0.0, 0.0, 0.0, 0.0);
GLfloat light_diffuse[] = {0.75, 0.74, 0.7, 1.0};
GLfloat light_specular[] = {0.0, 0.0, 0.0, 0.0};
glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse);
glLightfv(GL_LIGHT0, GL_SPECULAR, light_specular);
light_diffuse[0] = 0.3;
light_diffuse[1] = 0.3;
light_diffuse[2] = 0.4;
glLightfv(GL_LIGHT1, GL_DIFFUSE, light_diffuse);
glLightfv(GL_LIGHT1, GL_SPECULAR, light_specular);
glShadeModel(GL_SMOOTH);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glEnable(GL_LIGHT1);
glEnable(GL_COLOR_MATERIAL);
//glColorMaterial(GL_FRONT_AND_BACK, GL_EMISSION);
//glFrontFace(GL_CCW);
//glCullFace(GL_BACK);
glDisable(GL_CULL_FACE);
glDepthFunc(GL_LEQUAL);
glDepthMask(GL_TRUE);
glEnable(GL_DEPTH_TEST);
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
glEnable(GL_LINE_SMOOTH);
glLineWidth(2.0);
glDisable(GL_FOG);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
}
void WidgetHeightMap::resizeGL(int w, int h)
{
glViewport(0, 0, w, h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(1.57 * 180.0 / M_PI, 1.0, 1.0, 1000.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
}
void WidgetHeightMap::paintGL()
{
GLenum error_code;
QTime start_time;
double frame_time;
int rx, rz;
if (not _terrain)
{
return;
}
rx = HEIGHTMAP_RESOLUTION;
rz = HEIGHTMAP_RESOLUTION;
// Update vertex cache
if (_dirty)
{
updateVertexInfo();
emit heightmapChanged();
_dirty = false;
}
// Picking mouse position using z-buffer (for brush)
if (_mouse_moved)
{
GLint viewport[4];
GLdouble modelview[16];
GLdouble projection[16];
GLfloat winX, winY, winZ;
Vector3 point;
glGetDoublev(GL_MODELVIEW_MATRIX, modelview);
glGetDoublev(GL_PROJECTION_MATRIX, projection);
glGetIntegerv(GL_VIEWPORT, viewport);
winX = (float) _last_mouse_x;
winY = (float) height() - (float) _last_mouse_y;
glReadPixels(_last_mouse_x, (int) winY, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &winZ);
if (winZ > 0.0 && winZ < 1000.0)
{
gluUnProject(winX, winY, winZ, modelview, projection, viewport, &point.x, &point.y, &point.z);
_brush_x = point.x - _target_x;
_brush_z = point.z - _target_z;
}
_mouse_moved = false;
}
// Place camera
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
Vector3 camera_location = _current_camera->getLocation();
Vector3 camera_target = _current_camera->getTarget();
Vector3 camera_up = _current_camera->getUpVector();
gluLookAt(camera_location.x, camera_location.y, camera_location.z, camera_target.x, camera_target.y, camera_target.z, camera_up.x, camera_up.y, camera_up.z);
// Place lights
GLfloat light_position[] = {40.0, 40.0, 40.0, 0.0};
glLightfv(GL_LIGHT0, GL_POSITION, light_position);
light_position[0] = -40.0;
light_position[2] = -60.0;
glLightfv(GL_LIGHT1, GL_POSITION, light_position);
// Background
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// Height map
for (int x = 0; x < rx - 1; x++)
{
glBegin(GL_QUAD_STRIP);
for (int z = 0; z < rz; z++)
{
for (int dx = 1; dx >= 0; dx--)
{
_VertexInfo* vertex = _vertices + z * rx + x + dx;
double brush_influence;
if (_brush)
{
double diff_x, diff_z;
diff_x = vertex->point.x - _target_x - _brush_x;
diff_z = vertex->point.z - _target_z - _brush_z;
brush_influence = _brush->getInfluence(diff_x, diff_z);
}
else
{
brush_influence = 0.0;
}
glColor3f(0.8 + brush_influence, (_painted_area && vertex->painted) ? 1.0 : 0.8, 0.8);
glNormal3f(vertex->normal.x, vertex->normal.y, vertex->normal.z);
glVertex3f(vertex->point.x, vertex->point.y, vertex->point.z);
}
}
glEnd();
}
// Wireframe
if (_wireframe)
{
glDisable(GL_LIGHTING);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glDisable(GL_DEPTH_TEST);
glColor4f(0.8, 0.0, 0.0, 0.1);
for (int z = 0; z < rz; z++)
{
glBegin(GL_LINE_STRIP);
for (int x = 0; x < rx; x++)
{
_VertexInfo* vertex = _vertices + z * rx + x;
glVertex3f(vertex->point.x, vertex->point.y, vertex->point.z);
}
glEnd();
}
for (int x = 0; x < rx; x++)
{
glBegin(GL_LINE_STRIP);
for (int z = 0; z < rz; z++)
{
_VertexInfo* vertex = _vertices + z * rx + x;
glVertex3f(vertex->point.x, vertex->point.y, vertex->point.z);
}
glEnd();
}
glEnable(GL_LIGHTING);
glEnable(GL_DEPTH_TEST);
glDisable(GL_BLEND);
}
// Water
if (_water)
{
glDisable(GL_LIGHTING);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glColor4f(0.2, 0.3, 0.7, 0.7);
glBegin(GL_QUADS);
double water_height = _terrain->water_height * _terrain->scaling * _terrain->height;
glVertex3f(_target_x - 500.0, water_height, _target_z - 500.0);
glVertex3f(_target_x - 500.0, water_height, _target_z + 500.0);
glVertex3f(_target_x + 500.0, water_height, _target_z + 500.0);
glVertex3f(_target_x + 500.0, water_height, _target_z - 500.0);
glEnd();
glDisable(GL_BLEND);
glEnable(GL_LIGHTING);
}
// Time stats
frame_time = 0.001 * (double) start_time.msecsTo(QTime::currentTime());
_average_frame_time = _average_frame_time * 0.8 + frame_time * 0.2;
//printf("%d %f\n", quality, average_frame_time);
while ((error_code = glGetError()) != GL_NO_ERROR)
{
logDebug(QString("[OpenGL] ERROR : ") + (const char*) gluErrorString(error_code));
}
}
void WidgetHeightMap::scrollTopCamera(double dx, double dz)
{
if (dx != 0.0)
{
_target_x += dx * _zoom * 0.05;
}
if (dz != 0.0)
{
_target_z += dz * _zoom * 0.05;
}
}
void WidgetHeightMap::zoomTopCamera(double dzoom)
{
_zoom += dzoom;
if (_zoom < 10.0)
{
_zoom = 10.0;
}
else if (_zoom > 80.0)
{
_zoom = 80.0;
}
}
void WidgetHeightMap::updateVertexInfo()
{
int rx = HEIGHTMAP_RESOLUTION;
int rz = HEIGHTMAP_RESOLUTION;
int dx, dz;
_VertexInfo* old_vertices = _vertices;
_vertices = new _VertexInfo[rx * rz];
delete[] old_vertices;
_last_update_x = (int) (floor(_target_x));
_last_update_z = (int) (floor(_target_z));
// Update positions
for (int x = 0; x < rx; x++)
{
for (int z = 0; z < rz; z++)
{
_VertexInfo* vertex = _vertices + z * rx + x;
dx = _last_update_x + x - rx / 2;
dz = _last_update_z + z - rz / 2;
vertex->point.x = (double) dx;
vertex->point.z = (double) dz;
vertex->point.y = _terrain->getGridHeight(dx, dz, 1) * _terrain->height;
vertex->painted = _terrain->height_map->isPainted(dx, dz);
}
}
// Update normals
for (int x = 0; x < rx; x++)
{
for (int z = 0; z < rz; z++)
{
_VertexInfo* vertex = _vertices + z * rx + x;
if (x == rx - 1)
{
vertex->normal = (vertex - 1)->normal;
}
else if (z == rz - 1)
{
vertex->normal = (vertex - rx)->normal;
}
else
{
Vector3 dx, dz;
dx = (vertex + 1)->point.sub(vertex->point);
dz = (vertex + rx)->point.sub(vertex->point);
vertex->normal = dz.normalize().crossProduct(dx.normalize());
}
}
}
}

View file

@ -1,91 +0,0 @@
#ifndef _PAYSAGES_QT_WIDGETHEIGHTMAP_H_
#define _PAYSAGES_QT_WIDGETHEIGHTMAP_H_
#include "desktop_global.h"
#include <QGLWidget>
#include <QDateTime>
#include "terrain/paintingbrush.h"
#include "CameraDefinition.h"
typedef struct
{
Vector3 point;
Vector3 normal;
int painted;
} _VertexInfo;
class WidgetHeightMap : public QGLWidget
{
Q_OBJECT
public:
WidgetHeightMap(QWidget* parent);
~WidgetHeightMap();
void setTerrain(TerrainDefinition* terrain);
void setBrush(PaintingBrush* brush);
public slots:
void revert();
void toggleWater(bool enabled);
void toggleGrid(bool enabled);
void togglePaintedArea(bool enabled);
signals:
void heightmapChanged();
protected:
void keyPressEvent(QKeyEvent* event);
void mousePressEvent(QMouseEvent* event);
void mouseReleaseEvent(QMouseEvent* event);
void mouseMoveEvent(QMouseEvent* event);
void wheelEvent(QWheelEvent* event);
void timerEvent(QTimerEvent* event);
void initializeGL();
void resizeGL(int w, int h);
void paintGL();
private:
void scrollTopCamera(double dx, double dz);
void zoomTopCamera(double dzoom);
void updateVertexInfo();
private:
TerrainDefinition* _terrain;
SoftwareRenderer* _renderer;
_VertexInfo* _vertices;
bool _dirty;
bool _water;
bool _wireframe;
bool _painted_area;
double _average_frame_time;
int _last_brush_action;
int _last_mouse_x;
int _last_mouse_y;
QDateTime _last_time;
bool _mouse_moved;
double _target_x;
double _target_z;
int _last_update_x;
int _last_update_z;
CameraDefinition* _top_camera;
CameraDefinition* _temp_camera;
CameraDefinition* _current_camera;
double _zoom;
PaintingBrush* _brush;
double _brush_x;
double _brush_z;
};
#endif

View file

@ -1,44 +0,0 @@
#include "widgetterrainbasenoisepreview.h"
#include <QPainter>
#include <QPaintEvent>
#include "tools.h"
#include "NoiseGenerator.h"
WidgetTerrainBaseNoisePreview::WidgetTerrainBaseNoisePreview(QWidget* parent) :
DrawingWidget(parent)
{
_noise = NULL;
}
void WidgetTerrainBaseNoisePreview::setNoise(NoiseGenerator* noise)
{
_noise = noise;
update();
}
void WidgetTerrainBaseNoisePreview::doDrawing(QPainter* painter)
{
painter->fillRect(rect(), QColor(20, 40, 80));
painter->setPen(QColor(220, 210, 180));
int height = this->height();
if (_noise)
{
//QRect boundaries = event->region().boundingRect();
QRect boundaries = rect(); // TODO Limit to updated region
double value, factor;
double minvalue, maxvalue;
_noise->getRange(&minvalue, &maxvalue);
factor = ((double)height) / (maxvalue - minvalue);
for (int x = boundaries.left(); x <= boundaries.right(); x++)
{
value = _noise->get1DTotal(100.0 * ((double)x) / factor);
painter->drawLine(x, height - 1 - (value - minvalue) * factor, x, height - 1);
}
}
}

View file

@ -1,24 +0,0 @@
#ifndef _PAYSAGES_EDITING_TERRAIN_WIDGETTERRAINBASENOISEPREVIEW_H_
#define _PAYSAGES_EDITING_TERRAIN_WIDGETTERRAINBASENOISEPREVIEW_H_
#include "desktop_global.h"
#include "DrawingWidget.h"
class QPainter;
class WidgetTerrainBaseNoisePreview : public DrawingWidget
{
Q_OBJECT
public:
explicit WidgetTerrainBaseNoisePreview(QWidget* parent = 0);
void setNoise(NoiseGenerator* noise);
protected:
virtual void doDrawing(QPainter* painter);
private:
NoiseGenerator* _noise;
};
#endif

View file

@ -1,22 +0,0 @@
#include "DialogTexturesLayer.h"
#include "ui_DialogTexturesLayer.h"
#include "TexturesDefinition.h"
DialogTexturesLayer::DialogTexturesLayer(QWidget* parent, TexturesDefinition* textures, int layer) :
QDialog(parent),
ui(new Ui::DialogTexturesLayer)
{
ui->setupUi(this);
this->layer = layer;
original = textures;
modified = new TexturesDefinition(NULL);
}
DialogTexturesLayer::~DialogTexturesLayer()
{
delete ui;
delete modified;
}

View file

@ -1,28 +0,0 @@
#ifndef DIALOGTEXTURESLAYER_H
#define DIALOGTEXTURESLAYER_H
#include "desktop_global.h"
#include <QDialog>
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

@ -1,294 +0,0 @@
<?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

@ -1,160 +0,0 @@
#include "maintexturesform.h"
#include "ui_maintexturesform.h"
#include "../common/freeformhelper.h"
#include "../common/freelayerhelper.h"
#include "DesktopScenery.h"
#include "TexturesDefinition.h"
#include "TextureLayerDefinition.h"
#include "previewmaterial.h"
#include "textures/DialogTexturesLayer.h"
#include "TexturesMixPreviewRenderer.h"
#include "TextureLayerCoveragePreviewRenderer.h"
#include "TextureLayerAspectPreviewRenderer.h"
MainTexturesForm::MainTexturesForm(QWidget *parent) : QWidget(parent), ui(new Ui::MainTexturesForm)
{
textures = new TexturesDefinition(NULL);
ui->setupUi(this);
layer_helper = new FreeLayerHelper(textures, true);
layer_helper->setLayerTable(ui->layersGrid);
layer_helper->setAddButton(ui->layer_add);
layer_helper->setDelButton(ui->layer_del);
layer_helper->setDownButton(ui->layer_down);
layer_helper->setUpButton(ui->layer_up);
layer_helper->setEditButton(ui->layer_edit);
connect(layer_helper, SIGNAL(tableUpdateNeeded()), this, SLOT(updateLayers()));
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->setApplyButton(ui->button_apply);
form_helper->setRevertButton(ui->button_revert);
form_helper->setExploreButton(ui->button_explore);
form_helper->setRenderButton(ui->button_render);
preview_layer_coverage = new TextureLayerCoveragePreviewRenderer();
preview_layer_coverage->setTextures(textures);
form_helper->addPreview(ui->preview_coverage, preview_layer_coverage);
preview_layer_look = new TextureLayerAspectPreviewRenderer();
preview_layer_look->setTextures(textures);
form_helper->addPreview(ui->preview_texture, preview_layer_look);
preview_cumul = new TexturesMixPreviewRenderer();
preview_cumul->setTextures(textures);
form_helper->addPreview(ui->preview_cumul, preview_cumul);
form_helper->addPreset(tr("Complex terrain"));
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()));
form_helper->startManaging();
}
MainTexturesForm::~MainTexturesForm()
{
delete ui;
delete form_helper;
delete layer_helper;
}
void MainTexturesForm::updateLayers()
{
int i, n;
ui->layersGrid->clearContents();
n = textures->count();
ui->layersGrid->setRowCount(n);
for (i = 0; i < n; i++)
{
QTableWidgetItem* item;
TextureLayerDefinition* layer = textures->getTextureLayer(i);
item = new QTableWidgetItem(QString("%1").arg(i + 1));
item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
ui->layersGrid->setItem(n - 1 - i, 0, item);
item = new QTableWidgetItem(QString::fromStdString(layer->getName()));
item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
ui->layersGrid->setItem(n - 1 - i, 1, item);
QWidget* widget = new SmallMaterialPreview(ui->layersGrid, layer->material);
//widget->setMinimumSize(50, 50);
ui->layersGrid->setCellWidget(n - 1 - i, 2, widget);
ui->layersGrid->setRowHeight(n - 1 - i, 50);
}
ui->preview_cumul->setEnabled(n > 0);
ui->layersGrid->resizeColumnsToContents();
}
void MainTexturesForm::selectLayer(int layer)
{
if (layer < 0)
{
ui->preview_coverage->setEnabled(false);
ui->preview_texture->setEnabled(false);
}
else
{
ui->preview_coverage->setEnabled(true);
ui->preview_texture->setEnabled(true);
preview_layer_coverage->setLayer(layer);
preview_layer_look->setLayer(layer);
ui->preview_coverage->redraw();
ui->preview_texture->redraw();
}
}
void MainTexturesForm::editLayer(int layer)
{
DialogTexturesLayer dialog(this, textures, layer);
dialog.exec();
}
void MainTexturesForm::selectPreset(int preset)
{
textures->applyPreset((TexturesDefinition::TexturesPreset)preset);
}
void MainTexturesForm::updateLocalDataFromScenery()
{
DesktopScenery::getCurrent()->getTextures(textures);
preview_layer_coverage->setTerrain(DesktopScenery::getCurrent()->getTerrain());
preview_cumul->setTerrain(DesktopScenery::getCurrent()->getTerrain());
}
void MainTexturesForm::commitLocalDataToScenery()
{
DesktopScenery::getCurrent()->setTextures(textures);
}
void MainTexturesForm::refreshFromLocalData()
{
layer_helper->refreshLayers();
}
void MainTexturesForm::refreshFromFellowData()
{
}
void MainTexturesForm::alterRenderer(SoftwareRenderer* renderer)
{
renderer->getScenery()->setTextures(textures);
renderer->prepare();
}

View file

@ -1,48 +0,0 @@
#ifndef MAINTEXTURESFORM_H
#define MAINTEXTURESFORM_H
#include "desktop_global.h"
#include <QWidget>
namespace Ui {
class MainTexturesForm;
}
class FreeFormHelper;
class FreeLayerHelper;
class PreviewLayerCoverage;
class PreviewLayerLook;
class PreviewCumul;
class MainTexturesForm : public QWidget
{
Q_OBJECT
public:
explicit MainTexturesForm(QWidget *parent = 0);
~MainTexturesForm();
public slots:
void updateLocalDataFromScenery();
void commitLocalDataToScenery();
void refreshFromLocalData();
void refreshFromFellowData();
void alterRenderer(SoftwareRenderer* renderer);
void updateLayers();
void selectLayer(int layer);
void editLayer(int layer);
void selectPreset(int preset);
private:
Ui::MainTexturesForm *ui;
TexturesDefinition* textures;
FreeFormHelper* form_helper;
FreeLayerHelper* layer_helper;
TextureLayerCoveragePreviewRenderer* preview_layer_coverage;
TextureLayerAspectPreviewRenderer* preview_layer_look;
TexturesMixPreviewRenderer* preview_cumul;
};
#endif // MAINTEXTURESFORM_H

View file

@ -1,451 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainTexturesForm</class>
<widget class="QWidget" name="MainTexturesForm">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>997</width>
<height>742</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Texture layers</string>
</property>
<property name="flat">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_6">
<item>
<widget class="QLabel" name="label_6">
<property name="font">
<font>
<italic>true</italic>
</font>
</property>
<property name="text">
<string>These are the layers of textures that control the ground details. Each texture has two effects : a relief effect to add better definition to the base terrain shape, and a detail effect for close views.</string>
</property>
<property name="textFormat">
<enum>Qt::AutoText</enum>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QTableWidget" name="layersGrid">
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::SingleSelection</enum>
</property>
<property name="selectionBehavior">
<enum>QAbstractItemView::SelectRows</enum>
</property>
<attribute name="horizontalHeaderHighlightSections">
<bool>false</bool>
</attribute>
<attribute name="verticalHeaderVisible">
<bool>false</bool>
</attribute>
<column>
<property name="text">
<string>Level</string>
</property>
</column>
<column>
<property name="text">
<string>Name</string>
</property>
</column>
<column>
<property name="text">
<string>Material</string>
</property>
</column>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<spacer name="verticalSpacer_4">
<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="QPushButton" name="layer_add">
<property name="text">
<string>Add layer</string>
</property>
<property name="icon">
<iconset resource="../../../../data/ui_pictures.qrc">
<normaloff>:/buttons/logo/images/layer_add.png</normaloff>:/buttons/logo/images/layer_add.png</iconset>
</property>
<property name="iconSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
<property name="flat">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="layer_del">
<property name="text">
<string>Remove layer</string>
</property>
<property name="icon">
<iconset resource="../../../../data/ui_pictures.qrc">
<normaloff>:/buttons/logo/images/layer_del.png</normaloff>:/buttons/logo/images/layer_del.png</iconset>
</property>
<property name="iconSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::MinimumExpanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="layer_edit">
<property name="text">
<string>Edit layer</string>
</property>
<property name="icon">
<iconset resource="../../../../data/ui_pictures.qrc">
<normaloff>:/buttons/logo/images/layer_rename.png</normaloff>:/buttons/logo/images/layer_rename.png</iconset>
</property>
<property name="iconSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::MinimumExpanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="layer_up">
<property name="text">
<string>Move layer up</string>
</property>
<property name="icon">
<iconset resource="../../../../data/ui_pictures.qrc">
<normaloff>:/buttons/logo/images/layer_up.png</normaloff>:/buttons/logo/images/layer_up.png</iconset>
</property>
<property name="iconSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="layer_down">
<property name="text">
<string>Move layer down</string>
</property>
<property name="icon">
<iconset resource="../../../../data/ui_pictures.qrc">
<normaloff>:/buttons/logo/images/layer_down.png</normaloff>:/buttons/logo/images/layer_down.png</iconset>
</property>
<property name="iconSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_5">
<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>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_3">
<property name="title">
<string>Selected layer previews</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="2" column="1">
<widget class="BasePreview" name="preview_texture" 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>
<item row="1" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Coverage</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="BasePreview" name="preview_coverage" 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>
<item row="1" column="1">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Appearance</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
</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_2">
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>All layers preview</string>
</property>
<property name="flat">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="BasePreview" name="preview_cumul" 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="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>
<widget class="QGroupBox" name="groupBox_4">
<property name="title">
<string>Actions</string>
</property>
<property name="flat">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<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>
<widget class="QPushButton" name="button_revert">
<property name="text">
<string>Revert modifications</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>
<item>
<widget class="QPushButton" name="button_apply">
<property name="text">
<string>Apply modifications</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>
</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

@ -1,47 +0,0 @@
#include "tools.h"
#include <QEvent>
#include "BasePreview.h"
DialogWithPreview::DialogWithPreview(QWidget* parent) : QDialog(parent)
{
}
bool DialogWithPreview::event(QEvent* event)
{
if (event->type() == QEvent::WindowActivate)
{
BasePreview::reviveAll();
}
return QDialog::event(event);
}
QString getHumanMemory(qint64 memused)
{
if (memused >= 1024)
{
memused /= 1024;
if (memused >= 1024)
{
memused /= 1024;
if (memused >= 1024)
{
memused /= 1024;
return QObject::tr("%1 GB").arg(memused);
}
else
{
return QObject::tr("%1 MB").arg(memused);
}
}
else
{
return QObject::tr("%1 kB").arg(memused);
}
}
else
{
return QObject::tr("%1 B").arg(memused);
}
}

View file

@ -1,43 +0,0 @@
#ifndef _PAYSAGES_QT_TOOLS_H_
#define _PAYSAGES_QT_TOOLS_H_
#include <QColor>
#include <QDialog>
#include "DataFile.h"
#include "Color.h"
static inline QColor colorToQColor(Color color)
{
color.normalize();
return QColor(color.r * 255.0, color.g * 255.0, color.b * 255.0, color.a * 255.0);
}
static inline QString getDataPath(QString path)
{
return QString::fromStdString(DataFile::findFile(path.toStdString()));
}
QString getHumanMemory(qint64 memused);
class DialogWithPreview:public QDialog
{
Q_OBJECT
public:
DialogWithPreview(QWidget* parent);
protected:
virtual bool event(QEvent* event);
};
#ifndef NDEBUG
#include <QDebug>
static inline void logDebug(QString string)
{
qDebug() << string;
}
#else
#define logDebug(_x_) ;
#endif
#endif

View file

@ -1,239 +0,0 @@
#include "widgetcurveeditor.h"
#include <QPainter>
#include <QPaintEngine>
#include <QMouseEvent>
#include "Curve.h"
#include "Geometry.h"
WidgetCurveEditor::WidgetCurveEditor(QWidget *parent, double xmin, double xmax, double ymin, double ymax) : QWidget(parent)
{
_curve = new Curve;
_dragged = -1;
_pen = QColor(0, 0, 0);
_xmin = xmin;
_xmax = xmax;
_ymin = ymin;
_ymax = ymax;
setMinimumSize(300, 300);
}
WidgetCurveEditor::~WidgetCurveEditor()
{
delete _curve;
}
void WidgetCurveEditor::setAxisLabels(QString xlabel, QString ylabel)
{
_xlabel = xlabel;
_ylabel = ylabel;
}
void WidgetCurveEditor::setCurve(Curve* curve)
{
curve->copy(_curve);
update();
}
void WidgetCurveEditor::getCurve(Curve* curve)
{
_curve->copy(curve);
}
void WidgetCurveEditor::setPenColor(QColor color)
{
_pen = color;
update();
}
void WidgetCurveEditor::paintEvent(QPaintEvent*)
{
int i, n;
int width, height;
double dwidth, dheight;
CurvePoint point;
double position, value, prev_value, next_value;
width = this->width();
height = this->height();
dheight = (double)(height - 1);
dwidth = (double)(width - 1);
QPainter painter(this);
painter.fillRect(rect(), Qt::white);
// Draw grid
painter.setPen(QPen(Qt::lightGray));
for (int x = 0; x <= 10; x++)
{
int vx = (x == 10) ? width - 1 : x * width / 10;
painter.drawLine(vx, 0, vx, height -1);
vx = (x == 10) ? height - 1 : x * height / 10;
painter.drawLine(0, vx, width - 1, vx);
}
// Draw labels
painter.setPen(QColor(50, 50, 50));
if (not _xlabel.isEmpty())
{
painter.drawText(rect(), Qt::AlignCenter | Qt::AlignBottom, _xlabel);
}
if (not _ylabel.isEmpty())
{
painter.rotate(-90.0);
painter.translate(-height, 0.0);
painter.drawText(0, 0, height, 20, Qt::AlignCenter | Qt::AlignTop, _ylabel);
painter.translate(height, 0.0);
painter.rotate(90.0);
}
// Draw curve path
painter.setPen(_pen);
for (int x = 0; x < width; x++)
{
position = ((double)x / dwidth) * (_xmax - _xmin) + _xmin;
value = (_curve->getValue(position) - _ymin) / (_ymax - _ymin);
prev_value = _curve->getValue(position - (_xmax - _xmin) / dwidth);
next_value = _curve->getValue(position + (_xmax - _xmin) / dwidth);
painter.drawLine(x, height - 1 - (int)((value + (prev_value - value) / 2.0) * dheight), x, height - 1 - (int)((value + (next_value - value) / 2.0) * dheight));
painter.drawPoint(x, height - 1 - (int)(value * dheight));
}
// Draw handles
n = _curve->getPointCount();
painter.setRenderHints(QPainter::Antialiasing | QPainter::HighQualityAntialiasing, true);
for (i = 0; i < n; i++)
{
_curve->getPoint(i, &point);
painter.drawEllipse(QPointF((int)((point.position - _xmin) / (_xmax - _xmin) * dwidth), height - 1 - (int)((point.value - _ymin) / (_ymax - _ymin) * dheight)), 4.0, 4.0);
}
}
void WidgetCurveEditor::mousePressEvent(QMouseEvent* event)
{
if (event->button() == Qt::LeftButton && _dragged < 0)
{
_dragged = getPointAt(event->x(), event->y());
}
event->accept();
}
void WidgetCurveEditor::mouseMoveEvent(QMouseEvent* event)
{
CurvePoint point;
if (_dragged >= 0 && (event->buttons() & Qt::LeftButton))
{
screenToCurve(event->x(), event->y(), &point.position, &point.value);
point.position = (point.position < _xmin) ? _xmin : point.position;
point.position = (point.position > _xmax) ? _xmax : point.position;
point.value = (point.value < _ymin) ? _ymin : point.value;
point.value = (point.value > _ymax) ? _ymax : point.value;
_curve->setPoint(_dragged, point);
update();
emit liveChanged();
}
event->accept();
}
void WidgetCurveEditor::mouseReleaseEvent(QMouseEvent* event)
{
int clicked;
if (event->button() == Qt::RightButton)
{
clicked = getPointAt(event->x(), event->y());
if (clicked >= 0)
{
_curve->removePoint(clicked);
update();
emit liveChanged();
}
}
else if (event->button() == Qt::LeftButton && _dragged >= 0)
{
_dragged = -1;
_curve->validate();
update();
}
event->accept();
}
void WidgetCurveEditor::mouseDoubleClickEvent(QMouseEvent* event)
{
CurvePoint point;
if (event->button() == Qt::LeftButton && _dragged < 0)
{
if (getPointAt(event->x(), event->y()) < 0)
{
screenToCurve(event->x(), event->y(), &point.position, &point.value);
_curve->addPoint(point);
_curve->validate();
update();
emit liveChanged();
}
}
}
void WidgetCurveEditor::curveToScreen(double curve_x, double curve_y, int* screen_x, int* screen_y)
{
*screen_x = (int)((curve_x - _xmin) / (_xmax - _xmin) * (double)(width() - 1));
*screen_y = (int)((1.0 - (curve_y - _ymin) / (_ymax - _ymin)) * (double)(height() - 1));
}
void WidgetCurveEditor::screenToCurve(int screen_x, int screen_y, double* curve_x, double* curve_y)
{
*curve_x = ((double)screen_x / (double)(width() - 1)) * (_xmax - _xmin) + _xmin;
*curve_y = (1.0 - ((double)screen_y / (double)(height() - 1))) * (_ymax - _ymin) + _ymin;
}
int WidgetCurveEditor::getPointAt(int x, int y)
{
int n;
int nearest;
double distance, ndistance;
CurvePoint point;
int dx, dy;
n = _curve->getPointCount();
if (n < 1)
{
return -1;
}
// Find nearest point
nearest = -1;
distance = 0.0;
for (int i = 0; i < n; i++)
{
_curve->getPoint(i, &point);
curveToScreen(point.position, point.value, &dx, &dy);
ndistance = Geometry::getDistance2D((double)x, (double)y, (double)dx, (double)dy);
if (nearest < 0 || ndistance < distance)
{
distance = ndistance;
nearest = i;
}
}
if (nearest >= 0 && distance < 5.0)
{
return nearest;
}
else
{
return -1;
}
}

View file

@ -1,50 +0,0 @@
#ifndef _PAYSAGES_QT_WIDGETCURVEEDITOR_H_
#define _PAYSAGES_QT_WIDGETCURVEEDITOR_H_
#include "desktop_global.h"
#include <QWidget>
#include <QColor>
class WidgetCurveEditor : public QWidget
{
Q_OBJECT
public:
WidgetCurveEditor(QWidget* parent, double xmin, double xmax, double ymin, double ymax);
~WidgetCurveEditor();
void setAxisLabels(QString xlabel, QString ylabel);
void setCurve(Curve* curve);
void getCurve(Curve* curve);
void setPenColor(QColor color);
signals:
void liveChanged();
protected:
void paintEvent(QPaintEvent* event);
void mousePressEvent(QMouseEvent* event);
void mouseMoveEvent(QMouseEvent* event);
void mouseReleaseEvent(QMouseEvent* event);
void mouseDoubleClickEvent(QMouseEvent* event);
private:
void curveToScreen(double curve_x, double curve_y, int* screen_x, int* screen_y);
void screenToCurve(int screen_x, int screen_y, double* curve_x, double* curve_y);
int getPointAt(int x, int y);
double _xmin;
double _xmax;
double _ymin;
double _ymax;
Curve* _curve;
int _dragged;
QColor _pen;
QString _xlabel;
QString _ylabel;
};
#endif

Some files were not shown because too many files have changed in this diff Show more