paysages: Made terrain preview work again
git-svn-id: https://subversion.assembla.com/svn/thunderk/paysages@567 b1fd45b6-86a6-48da-8261-f70d1f35bdcc
This commit is contained in:
parent
319d33e9f2
commit
e116d01c29
12 changed files with 131 additions and 34 deletions
2
Makefile
2
Makefile
|
@ -30,7 +30,7 @@ release:
|
||||||
make BUILDMODE=release all
|
make BUILDMODE=release all
|
||||||
|
|
||||||
tests: all
|
tests: all
|
||||||
LD_LIBRARY_PATH=${BUILDPATH} ${BUILDPATH}/paysages-tests
|
LD_LIBRARY_PATH=${BUILDPATH} CK_DEFAULT_TIMEOUT=30 ${BUILDPATH}/paysages-tests
|
||||||
|
|
||||||
run_cli: all
|
run_cli: all
|
||||||
LD_LIBRARY_PATH=${BUILDPATH} ${BUILDPATH}/paysages-cli
|
LD_LIBRARY_PATH=${BUILDPATH} ${BUILDPATH}/paysages-cli
|
||||||
|
|
|
@ -354,6 +354,8 @@ QWidget(parent)
|
||||||
_transactions_count = 0;
|
_transactions_count = 0;
|
||||||
_redraw_requested = false;
|
_redraw_requested = false;
|
||||||
|
|
||||||
|
_renderer = NULL;
|
||||||
|
|
||||||
_info = new QLabel(this);
|
_info = new QLabel(this);
|
||||||
_info->setVisible(false);
|
_info->setVisible(false);
|
||||||
_info->setStyleSheet("QLabel { background-color: white; color: black; }");
|
_info->setStyleSheet("QLabel { background-color: white; color: black; }");
|
||||||
|
@ -385,6 +387,12 @@ BasePreview::~BasePreview()
|
||||||
delete _lock_drawing;
|
delete _lock_drawing;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BasePreview::setRenderer(PreviewRenderer* renderer)
|
||||||
|
{
|
||||||
|
_renderer = renderer;
|
||||||
|
_renderer->bindEvent(this);
|
||||||
|
}
|
||||||
|
|
||||||
void BasePreview::configHdrToneMapping(bool active)
|
void BasePreview::configHdrToneMapping(bool active)
|
||||||
{
|
{
|
||||||
_hdr_enabled = active;
|
_hdr_enabled = active;
|
||||||
|
@ -436,15 +444,26 @@ void BasePreview::reviveAll()
|
||||||
|
|
||||||
void BasePreview::updateData()
|
void BasePreview::updateData()
|
||||||
{
|
{
|
||||||
|
if (_renderer)
|
||||||
|
{
|
||||||
|
_renderer->updateEvent();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BasePreview::cameraEvent()
|
void BasePreview::cameraEvent()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
Color BasePreview::getColor(double, double)
|
Color BasePreview::getColor(double x, double y)
|
||||||
{
|
{
|
||||||
|
if (_renderer)
|
||||||
|
{
|
||||||
|
return _renderer->getColor2D(x, y, scaling);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
return COLOR_BLACK;
|
return COLOR_BLACK;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BasePreview::configScaling(double min, double max, double step, double init, bool logarithmic)
|
void BasePreview::configScaling(double min, double max, double step, double init, bool logarithmic)
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QHash>
|
#include <QHash>
|
||||||
#include "previewosd.h"
|
#include "previewosd.h"
|
||||||
|
#include "common/previewrenderer.h"
|
||||||
#include "rendering/tools/pack.h"
|
#include "rendering/tools/pack.h"
|
||||||
#include "rendering/tools/color.h"
|
#include "rendering/tools/color.h"
|
||||||
|
|
||||||
|
@ -36,6 +37,8 @@ public:
|
||||||
BasePreview(QWidget* parent);
|
BasePreview(QWidget* parent);
|
||||||
~BasePreview();
|
~BasePreview();
|
||||||
|
|
||||||
|
void setRenderer(PreviewRenderer* renderer);
|
||||||
|
|
||||||
virtual void savePack(PackStream* stream);
|
virtual void savePack(PackStream* stream);
|
||||||
virtual void loadPack(PackStream* stream);
|
virtual void loadPack(PackStream* stream);
|
||||||
|
|
||||||
|
@ -51,23 +54,23 @@ public:
|
||||||
|
|
||||||
QColor getPixelColor(int x, int y);
|
QColor getPixelColor(int x, int y);
|
||||||
|
|
||||||
protected:
|
void addOsd(QString name);
|
||||||
virtual void updateData();
|
|
||||||
virtual void cameraEvent();
|
|
||||||
virtual Color getColor(double x, double y);
|
|
||||||
|
|
||||||
void configHdrToneMapping(bool active);
|
void configHdrToneMapping(bool active);
|
||||||
void configScaling(double min, double max, double step, double init, bool logarithmic = true);
|
void configScaling(double min, double max, double step, double init, bool logarithmic = true);
|
||||||
void configScrolling(double xmin, double xmax, double xinit, double ymin, double ymax, double yinit);
|
void configScrolling(double xmin, double xmax, double xinit, double ymin, double ymax, double yinit);
|
||||||
|
|
||||||
void addOsd(QString name);
|
|
||||||
|
|
||||||
void addChoice(const QString& key, const QString& title, const QStringList& choices, int init_value);
|
void addChoice(const QString& key, const QString& title, const QStringList& choices, int init_value);
|
||||||
virtual void choiceChangeEvent(const QString& key, int position);
|
virtual void choiceChangeEvent(const QString& key, int position);
|
||||||
|
|
||||||
void addToggle(const QString& key, const QString& text, bool init_value);
|
void addToggle(const QString& key, const QString& text, bool init_value);
|
||||||
virtual void toggleChangeEvent(QString key, bool value);
|
virtual void toggleChangeEvent(QString key, bool value);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void updateData();
|
||||||
|
virtual void cameraEvent();
|
||||||
|
virtual Color getColor(double x, double y);
|
||||||
|
|
||||||
double xoffset;
|
double xoffset;
|
||||||
double yoffset;
|
double yoffset;
|
||||||
double scaling;
|
double scaling;
|
||||||
|
@ -96,6 +99,8 @@ private:
|
||||||
|
|
||||||
QLabel* _info;
|
QLabel* _info;
|
||||||
|
|
||||||
|
PreviewRenderer* _renderer;
|
||||||
|
|
||||||
int _width;
|
int _width;
|
||||||
int _height;
|
int _height;
|
||||||
|
|
||||||
|
|
|
@ -32,17 +32,18 @@ void FreeFormHelper::startManaging()
|
||||||
emit needReverting();
|
emit needReverting();
|
||||||
}
|
}
|
||||||
|
|
||||||
void FreeFormHelper::addPreview(BasePreview* preview)
|
void FreeFormHelper::addPreview(BasePreview* preview, PreviewRenderer* renderer)
|
||||||
{
|
{
|
||||||
if (preview && preview->inherits("BasePreview"))
|
if (preview && preview->inherits("BasePreview"))
|
||||||
{
|
{
|
||||||
_previews.append(preview);
|
_previews.append(preview);
|
||||||
|
preview->setRenderer(renderer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FreeFormHelper::addPreview(QString widget_name)
|
void FreeFormHelper::addPreview(QString widget_name, PreviewRenderer* renderer)
|
||||||
{
|
{
|
||||||
addPreview(_form_widget->findChild<BasePreview*>(widget_name));
|
addPreview(_form_widget->findChild<BasePreview*>(widget_name), renderer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FreeFormHelper::addDoubleInputSlider(WidgetSliderDecimal* slider, double* value, double min, double max, double small_step, double large_step)
|
void FreeFormHelper::addDoubleInputSlider(WidgetSliderDecimal* slider, double* value, double min, double max, double small_step, double large_step)
|
||||||
|
|
|
@ -16,8 +16,8 @@ public:
|
||||||
|
|
||||||
void startManaging();
|
void startManaging();
|
||||||
|
|
||||||
void addPreview(BasePreview* preview);
|
void addPreview(BasePreview* preview, PreviewRenderer* renderer);
|
||||||
void addPreview(QString widget_name);
|
void addPreview(QString widget_name, PreviewRenderer* renderer);
|
||||||
|
|
||||||
void addDoubleInputSlider(WidgetSliderDecimal* slider, double* value, double min=0.0, double max=1.0, double small_step=0.0, double large_step=0.0);
|
void addDoubleInputSlider(WidgetSliderDecimal* slider, double* value, double min=0.0, double max=1.0, double small_step=0.0, double large_step=0.0);
|
||||||
void addDoubleInputSlider(QString widget_name, double* value, double min=0.0, double max=1.0, double small_step=0.0, double large_step=0.0);
|
void addDoubleInputSlider(QString widget_name, double* value, double min=0.0, double max=1.0, double small_step=0.0, double large_step=0.0);
|
||||||
|
|
25
src/editing/common/previewrenderer.cpp
Normal file
25
src/editing/common/previewrenderer.cpp
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
#include "previewrenderer.h"
|
||||||
|
|
||||||
|
PreviewRenderer::PreviewRenderer(QObject *parent) :
|
||||||
|
QObject(parent)
|
||||||
|
{
|
||||||
|
renderer = rendererCreate();
|
||||||
|
}
|
||||||
|
|
||||||
|
PreviewRenderer::~PreviewRenderer()
|
||||||
|
{
|
||||||
|
rendererDelete(renderer);
|
||||||
|
}
|
||||||
|
|
||||||
|
Color PreviewRenderer::getColor2D(double, double, double)
|
||||||
|
{
|
||||||
|
return COLOR_BLACK;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PreviewRenderer::bindEvent(BasePreview*)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void PreviewRenderer::updateEvent()
|
||||||
|
{
|
||||||
|
}
|
30
src/editing/common/previewrenderer.h
Normal file
30
src/editing/common/previewrenderer.h
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
#ifndef PREVIEWRENDERER_H
|
||||||
|
#define PREVIEWRENDERER_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include "rendering/tools/color.h"
|
||||||
|
#include "rendering/renderer.h"
|
||||||
|
|
||||||
|
class BasePreview;
|
||||||
|
|
||||||
|
class PreviewRenderer : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit PreviewRenderer(QObject *parent = 0);
|
||||||
|
~PreviewRenderer();
|
||||||
|
|
||||||
|
virtual void bindEvent(BasePreview* preview);
|
||||||
|
virtual void updateEvent();
|
||||||
|
virtual Color getColor2D(double x, double y, double scaling);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
|
||||||
|
protected:
|
||||||
|
Renderer* renderer;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // PREVIEWRENDERER_H
|
|
@ -69,7 +69,8 @@ HEADERS += \
|
||||||
terrain/mainterrainform.h \
|
terrain/mainterrainform.h \
|
||||||
common/freeformhelper.h \
|
common/freeformhelper.h \
|
||||||
terrain/previewterrainshape.h \
|
terrain/previewterrainshape.h \
|
||||||
common/widgetsliderdecimal.h
|
common/widgetsliderdecimal.h \
|
||||||
|
common/previewrenderer.h
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
widgetheightmap.cpp \
|
widgetheightmap.cpp \
|
||||||
|
@ -117,7 +118,8 @@ SOURCES += \
|
||||||
terrain/mainterrainform.cpp \
|
terrain/mainterrainform.cpp \
|
||||||
common/freeformhelper.cpp \
|
common/freeformhelper.cpp \
|
||||||
terrain/previewterrainshape.cpp \
|
terrain/previewterrainshape.cpp \
|
||||||
common/widgetsliderdecimal.cpp
|
common/widgetsliderdecimal.cpp \
|
||||||
|
common/previewrenderer.cpp
|
||||||
|
|
||||||
FORMS += \
|
FORMS += \
|
||||||
terrain/dialogterrainpainting.ui \
|
terrain/dialogterrainpainting.ui \
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#include "ui_mainterrainform.h"
|
#include "ui_mainterrainform.h"
|
||||||
|
|
||||||
#include "dialogterrainpainting.h"
|
#include "dialogterrainpainting.h"
|
||||||
|
#include "previewterrainshape.h"
|
||||||
#include "tools.h"
|
#include "tools.h"
|
||||||
#include "rendering/scenery.h"
|
#include "rendering/scenery.h"
|
||||||
|
|
||||||
|
@ -15,7 +16,8 @@ MainTerrainForm::MainTerrainForm(QWidget *parent) :
|
||||||
|
|
||||||
_form_helper = new FreeFormHelper(this);
|
_form_helper = new FreeFormHelper(this);
|
||||||
|
|
||||||
_form_helper->addPreview("preview_shape");
|
_renderer_shape = new PreviewTerrainShape(_terrain);
|
||||||
|
_form_helper->addPreview("preview_shape", _renderer_shape);
|
||||||
|
|
||||||
_form_helper->addDoubleInputSlider("input_scaling", &_terrain->scaling, 0.1, 3.0, 0.03, 0.3);
|
_form_helper->addDoubleInputSlider("input_scaling", &_terrain->scaling, 0.1, 3.0, 0.03, 0.3);
|
||||||
_form_helper->addDoubleInputSlider("input_height", &_terrain->height, 0.0, 3.0, 0.01, 0.1);
|
_form_helper->addDoubleInputSlider("input_height", &_terrain->height, 0.0, 3.0, 0.01, 0.1);
|
||||||
|
@ -34,6 +36,7 @@ MainTerrainForm::~MainTerrainForm()
|
||||||
{
|
{
|
||||||
delete _form_helper;
|
delete _form_helper;
|
||||||
delete ui;
|
delete ui;
|
||||||
|
delete _renderer_shape;
|
||||||
|
|
||||||
TerrainDefinitionClass.destroy(_terrain);
|
TerrainDefinitionClass.destroy(_terrain);
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,6 +33,8 @@ private:
|
||||||
FreeFormHelper* _form_helper;
|
FreeFormHelper* _form_helper;
|
||||||
|
|
||||||
TerrainDefinition* _terrain;
|
TerrainDefinition* _terrain;
|
||||||
|
|
||||||
|
PreviewRenderer* _renderer_shape;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MAINTERRAINFORM_H
|
#endif // MAINTERRAINFORM_H
|
||||||
|
|
|
@ -1,22 +1,30 @@
|
||||||
#include "previewterrainshape.h"
|
#include "previewterrainshape.h"
|
||||||
|
|
||||||
PreviewTerrainShape::PreviewTerrainShape(QWidget *parent) :
|
#include "basepreview.h"
|
||||||
BasePreview(parent)
|
|
||||||
|
PreviewTerrainShape::PreviewTerrainShape(TerrainDefinition* terrain)
|
||||||
{
|
{
|
||||||
_renderer = terrainCreatePreviewRenderer();
|
_terrain = terrain;
|
||||||
|
|
||||||
addOsd(QString("geolocation"));
|
// TODO Don't delete the base renderer, just alter it
|
||||||
|
rendererDelete(renderer);
|
||||||
configScaling(20.0, 1000.0, 20.0, 50.0);
|
renderer = terrainCreatePreviewRenderer();
|
||||||
configScrolling(-1000.0, 1000.0, 0.0, -1000.0, 1000.0, 0.0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Color PreviewTerrainShape::getColor(double x, double y)
|
void PreviewTerrainShape::bindEvent(BasePreview* preview)
|
||||||
{
|
{
|
||||||
return terrainGetPreviewColor(_renderer, x, y, scaling);
|
preview->addOsd(QString("geolocation"));
|
||||||
|
|
||||||
|
preview->configScaling(20.0, 1000.0, 20.0, 50.0);
|
||||||
|
preview->configScrolling(-1000.0, 1000.0, 0.0, -1000.0, 1000.0, 0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PreviewTerrainShape::updateData()
|
void PreviewTerrainShape::updateEvent()
|
||||||
{
|
{
|
||||||
//TerrainRendererClass.bind(_renderer, _definition);
|
TerrainRendererClass.bind(renderer, _terrain);
|
||||||
|
}
|
||||||
|
|
||||||
|
Color PreviewTerrainShape::getColor2D(double x, double y, double scaling)
|
||||||
|
{
|
||||||
|
return terrainGetPreviewColor(renderer, x, y, scaling);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,21 +1,23 @@
|
||||||
#ifndef PREVIEWTERRAINSHAPE_H
|
#ifndef PREVIEWTERRAINSHAPE_H
|
||||||
#define PREVIEWTERRAINSHAPE_H
|
#define PREVIEWTERRAINSHAPE_H
|
||||||
|
|
||||||
#include "basepreview.h"
|
#include "common/previewrenderer.h"
|
||||||
#include "rendering/renderer.h"
|
#include "rendering/renderer.h"
|
||||||
|
#include "rendering/terrain/public.h"
|
||||||
|
|
||||||
class PreviewTerrainShape : public BasePreview
|
class PreviewTerrainShape : public PreviewRenderer
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit PreviewTerrainShape(QWidget *parent = 0);
|
explicit PreviewTerrainShape(TerrainDefinition* terrain);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual Color getColor(double x, double y);
|
virtual void bindEvent(BasePreview* preview);
|
||||||
virtual void updateData();
|
virtual void updateEvent();
|
||||||
|
virtual Color getColor2D(double x, double y, double scaling);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Renderer* _renderer;
|
TerrainDefinition* _terrain;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // PREVIEWTERRAINSHAPE_H
|
#endif // PREVIEWTERRAINSHAPE_H
|
||||||
|
|
Loading…
Reference in a new issue