Refactoring of BasePreview
This commit is contained in:
parent
d9f2f3878f
commit
aed4f9d80e
52 changed files with 359 additions and 325 deletions
|
@ -30,4 +30,8 @@
|
||||||
<file>images/logo_64.png</file>
|
<file>images/logo_64.png</file>
|
||||||
<file>images/logo_256.png</file>
|
<file>images/logo_256.png</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
|
<qresource prefix="/">
|
||||||
|
<file>images/toggle_on.png</file>
|
||||||
|
<file>images/choice_on.png</file>
|
||||||
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#include "inputmaterial.h"
|
#include "inputmaterial.h"
|
||||||
#include "inputenum.h"
|
#include "inputenum.h"
|
||||||
#include "inputlayers.h"
|
#include "inputlayers.h"
|
||||||
|
#include "BasePreview.h"
|
||||||
|
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
#ifndef _PAYSAGES_QT_BASEFORM_H_
|
#ifndef _PAYSAGES_QT_BASEFORM_H_
|
||||||
#define _PAYSAGES_QT_BASEFORM_H_
|
#define _PAYSAGES_QT_BASEFORM_H_
|
||||||
|
|
||||||
|
#include "editing_global.h"
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include "basepreview.h"
|
|
||||||
#include "baseinput.h"
|
#include "baseinput.h"
|
||||||
#include "dialoglayers.h"
|
#include "dialoglayers.h"
|
||||||
#include "shared/types.h"
|
#include "shared/types.h"
|
||||||
|
@ -14,18 +15,6 @@
|
||||||
class QPushButton;
|
class QPushButton;
|
||||||
class QComboBox;
|
class QComboBox;
|
||||||
|
|
||||||
namespace paysages {
|
|
||||||
namespace system {
|
|
||||||
class PackStream;
|
|
||||||
}
|
|
||||||
namespace basics {
|
|
||||||
class NoiseGenerator;
|
|
||||||
}
|
|
||||||
namespace definition {
|
|
||||||
class Layers;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class BaseForm : public QWidget
|
class BaseForm : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
|
@ -8,11 +8,14 @@
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <QInputDialog>
|
#include <QInputDialog>
|
||||||
|
#include <QLabel>
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "dialogrender.h"
|
#include "dialogrender.h"
|
||||||
#include "dialogexplorer.h"
|
#include "dialogexplorer.h"
|
||||||
#include "Scenery.h"
|
#include "Scenery.h"
|
||||||
|
#include "BasePreview.h"
|
||||||
#include "renderer.h"
|
#include "renderer.h"
|
||||||
|
#include "camera.h"
|
||||||
#include "tools.h"
|
#include "tools.h"
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(double*)
|
Q_DECLARE_METATYPE(double*)
|
||||||
|
@ -79,7 +82,7 @@ void FreeFormHelper::startManaging()
|
||||||
processGlobalRefresh();
|
processGlobalRefresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
void FreeFormHelper::addPreview(BasePreview* preview, PreviewRenderer* renderer)
|
void FreeFormHelper::addPreview(BasePreview* preview, Base2dPreviewRenderer* renderer)
|
||||||
{
|
{
|
||||||
_previews.append(preview);
|
_previews.append(preview);
|
||||||
preview->setRenderer(renderer);
|
preview->setRenderer(renderer);
|
||||||
|
|
|
@ -1,14 +1,17 @@
|
||||||
#ifndef FREEFORMHELPER_H
|
#ifndef FREEFORMHELPER_H
|
||||||
#define FREEFORMHELPER_H
|
#define FREEFORMHELPER_H
|
||||||
|
|
||||||
|
#include "editing_global.h"
|
||||||
|
|
||||||
#include <QVector>
|
#include <QVector>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
|
|
||||||
#include "widgetsliderdecimal.h"
|
#include "widgetsliderdecimal.h"
|
||||||
#include "../basepreview.h"
|
|
||||||
|
|
||||||
class QSlider;
|
class QSlider;
|
||||||
class QPushButton;
|
class QPushButton;
|
||||||
|
class QLabel;
|
||||||
|
class Renderer;
|
||||||
|
|
||||||
class FreeFormHelper:public QObject
|
class FreeFormHelper:public QObject
|
||||||
{
|
{
|
||||||
|
@ -20,7 +23,7 @@ public:
|
||||||
|
|
||||||
void startManaging();
|
void startManaging();
|
||||||
|
|
||||||
void addPreview(BasePreview* preview, PreviewRenderer* renderer);
|
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 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 setApplyButton(QPushButton* button);
|
||||||
void setRevertButton(QPushButton* button);
|
void setRevertButton(QPushButton* button);
|
||||||
|
|
|
@ -12,7 +12,9 @@
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QSplashScreen>
|
#include <QSplashScreen>
|
||||||
|
|
||||||
#include "basepreview.h"
|
#include "BasePreview.h"
|
||||||
|
#include "PreviewOsd.h"
|
||||||
|
#include "PreviewOsdItem.h"
|
||||||
#include "formclouds.h"
|
#include "formclouds.h"
|
||||||
#include "formatmosphere.h"
|
#include "formatmosphere.h"
|
||||||
#include "formwater.h"
|
#include "formwater.h"
|
||||||
|
|
|
@ -1,25 +0,0 @@
|
||||||
#include "previewrenderer.h"
|
|
||||||
|
|
||||||
#include "SoftwareRenderer.h"
|
|
||||||
|
|
||||||
PreviewRenderer::PreviewRenderer()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
PreviewRenderer::~PreviewRenderer()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
Color PreviewRenderer::getColor2D(double, double, double) const
|
|
||||||
{
|
|
||||||
return COLOR_BLACK;
|
|
||||||
}
|
|
||||||
|
|
||||||
void PreviewRenderer::bindEvent(BasePreview*)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void PreviewRenderer::updateEvent()
|
|
||||||
{
|
|
||||||
renderer->prepare();
|
|
||||||
}
|
|
|
@ -1,22 +0,0 @@
|
||||||
#ifndef PREVIEWRENDERER_H
|
|
||||||
#define PREVIEWRENDERER_H
|
|
||||||
|
|
||||||
#include "rendering_global.h"
|
|
||||||
|
|
||||||
#include "Base2dPreviewRenderer.h"
|
|
||||||
#include "renderer.h"
|
|
||||||
|
|
||||||
class BasePreview;
|
|
||||||
|
|
||||||
class PreviewRenderer : public Base2dPreviewRenderer
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
PreviewRenderer();
|
|
||||||
virtual ~PreviewRenderer();
|
|
||||||
|
|
||||||
virtual void bindEvent(BasePreview* preview);
|
|
||||||
virtual void updateEvent();
|
|
||||||
virtual Color getColor2D(double x, double y, double scaling) const override;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // PREVIEWRENDERER_H
|
|
|
@ -11,6 +11,7 @@
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include "tools/color.h"
|
#include "tools/color.h"
|
||||||
|
#include "BasePreview.h"
|
||||||
|
|
||||||
/**************** Previews ****************/
|
/**************** Previews ****************/
|
||||||
class PreviewLevel:public BasePreview
|
class PreviewLevel:public BasePreview
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
#ifndef _PAYSAGES_QT_DIALOGNOISE_H_
|
#ifndef _PAYSAGES_QT_DIALOGNOISE_H_
|
||||||
#define _PAYSAGES_QT_DIALOGNOISE_H_
|
#define _PAYSAGES_QT_DIALOGNOISE_H_
|
||||||
|
|
||||||
|
#include "editing_global.h"
|
||||||
|
|
||||||
#include <QListWidget>
|
#include <QListWidget>
|
||||||
#include <QComboBox>
|
#include <QComboBox>
|
||||||
#include "basepreview.h"
|
|
||||||
#include "tools.h"
|
#include "tools.h"
|
||||||
#include "NoiseGenerator.h"
|
#include "NoiseGenerator.h"
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,6 @@ HEADERS += \
|
||||||
terrain/widgetheightmap.h \
|
terrain/widgetheightmap.h \
|
||||||
widgetcurveeditor.h \
|
widgetcurveeditor.h \
|
||||||
tools.h \
|
tools.h \
|
||||||
previewosd.h \
|
|
||||||
previewmaterial.h \
|
previewmaterial.h \
|
||||||
previewcolorgradation.h \
|
previewcolorgradation.h \
|
||||||
inputnoise.h \
|
inputnoise.h \
|
||||||
|
@ -38,7 +37,6 @@ HEADERS += \
|
||||||
dialogexplorer.h \
|
dialogexplorer.h \
|
||||||
dialogcurve.h \
|
dialogcurve.h \
|
||||||
dialogcolorgradation.h \
|
dialogcolorgradation.h \
|
||||||
basepreview.h \
|
|
||||||
baseinput.h \
|
baseinput.h \
|
||||||
baseformlayer.h \
|
baseformlayer.h \
|
||||||
baseform.h \
|
baseform.h \
|
||||||
|
@ -49,14 +47,12 @@ HEADERS += \
|
||||||
common/freeformhelper.h \
|
common/freeformhelper.h \
|
||||||
terrain/previewterrainshape.h \
|
terrain/previewterrainshape.h \
|
||||||
common/widgetsliderdecimal.h \
|
common/widgetsliderdecimal.h \
|
||||||
common/previewrenderer.h \
|
|
||||||
terrain/widgetterrainbasenoisepreview.h \
|
terrain/widgetterrainbasenoisepreview.h \
|
||||||
common/mainwindow.h \
|
common/mainwindow.h \
|
||||||
terrain/dialogbaseterrainnoise.h \
|
terrain/dialogbaseterrainnoise.h \
|
||||||
textures/maintexturesform.h \
|
textures/maintexturesform.h \
|
||||||
common/freelayerhelper.h \
|
common/freelayerhelper.h \
|
||||||
lighting/DialogMaterialEditor.h \
|
lighting/DialogMaterialEditor.h \
|
||||||
common/DrawingWidget.h \
|
|
||||||
lighting/SmallPreviewColor.h \
|
lighting/SmallPreviewColor.h \
|
||||||
lighting/SmallPreviewHues.h \
|
lighting/SmallPreviewHues.h \
|
||||||
textures/PreviewLayerCoverage.h \
|
textures/PreviewLayerCoverage.h \
|
||||||
|
@ -69,7 +65,6 @@ SOURCES += \
|
||||||
terrain/widgetheightmap.cpp \
|
terrain/widgetheightmap.cpp \
|
||||||
widgetcurveeditor.cpp \
|
widgetcurveeditor.cpp \
|
||||||
tools.cpp \
|
tools.cpp \
|
||||||
previewosd.cpp \
|
|
||||||
previewmaterial.cpp \
|
previewmaterial.cpp \
|
||||||
previewcolorgradation.cpp \
|
previewcolorgradation.cpp \
|
||||||
inputnoise.cpp \
|
inputnoise.cpp \
|
||||||
|
@ -94,7 +89,6 @@ SOURCES += \
|
||||||
dialogexplorer.cpp \
|
dialogexplorer.cpp \
|
||||||
dialogcurve.cpp \
|
dialogcurve.cpp \
|
||||||
dialogcolorgradation.cpp \
|
dialogcolorgradation.cpp \
|
||||||
basepreview.cpp \
|
|
||||||
baseinput.cpp \
|
baseinput.cpp \
|
||||||
baseformlayer.cpp \
|
baseformlayer.cpp \
|
||||||
baseform.cpp \
|
baseform.cpp \
|
||||||
|
@ -105,14 +99,12 @@ SOURCES += \
|
||||||
common/freeformhelper.cpp \
|
common/freeformhelper.cpp \
|
||||||
terrain/previewterrainshape.cpp \
|
terrain/previewterrainshape.cpp \
|
||||||
common/widgetsliderdecimal.cpp \
|
common/widgetsliderdecimal.cpp \
|
||||||
common/previewrenderer.cpp \
|
|
||||||
terrain/widgetterrainbasenoisepreview.cpp \
|
terrain/widgetterrainbasenoisepreview.cpp \
|
||||||
common/mainwindow.cpp \
|
common/mainwindow.cpp \
|
||||||
terrain/dialogbaseterrainnoise.cpp \
|
terrain/dialogbaseterrainnoise.cpp \
|
||||||
textures/maintexturesform.cpp \
|
textures/maintexturesform.cpp \
|
||||||
common/freelayerhelper.cpp \
|
common/freelayerhelper.cpp \
|
||||||
lighting/DialogMaterialEditor.cpp \
|
lighting/DialogMaterialEditor.cpp \
|
||||||
common/DrawingWidget.cpp \
|
|
||||||
lighting/SmallPreviewColor.cpp \
|
lighting/SmallPreviewColor.cpp \
|
||||||
lighting/SmallPreviewHues.cpp \
|
lighting/SmallPreviewHues.cpp \
|
||||||
textures/PreviewLayerCoverage.cpp \
|
textures/PreviewLayerCoverage.cpp \
|
||||||
|
|
|
@ -4,5 +4,6 @@
|
||||||
#include "definition_global.h"
|
#include "definition_global.h"
|
||||||
#include "software_global.h"
|
#include "software_global.h"
|
||||||
#include "opengl_global.h"
|
#include "opengl_global.h"
|
||||||
|
#include "preview_global.h"
|
||||||
|
|
||||||
#endif // EDITING_GLOBAL_H
|
#endif // EDITING_GLOBAL_H
|
||||||
|
|
|
@ -9,12 +9,13 @@
|
||||||
#include "atmosphere/public.h"
|
#include "atmosphere/public.h"
|
||||||
#include "AtmosphereColorPreviewRenderer.h"
|
#include "AtmosphereColorPreviewRenderer.h"
|
||||||
#include "Scenery.h"
|
#include "Scenery.h"
|
||||||
|
#include "BasePreview.h"
|
||||||
#include "renderer.h"
|
#include "renderer.h"
|
||||||
|
|
||||||
static AtmosphereDefinition* _definition;
|
static AtmosphereDefinition* _definition;
|
||||||
|
|
||||||
/**************** Previews ****************/
|
/**************** Previews ****************/
|
||||||
class PreviewSkyEast:public PreviewRenderer, public AtmosphereColorPreviewRenderer
|
class PreviewSkyEast:public AtmosphereColorPreviewRenderer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
void bindEvent(BasePreview* preview) override
|
void bindEvent(BasePreview* preview) override
|
||||||
|
@ -22,14 +23,14 @@ public:
|
||||||
preview->configHdrToneMapping(true);
|
preview->configHdrToneMapping(true);
|
||||||
preview->configScaling(0.5, 5.0, 0.5, 2.5);
|
preview->configScaling(0.5, 5.0, 0.5, 2.5);
|
||||||
}
|
}
|
||||||
void updateData()
|
void updateEvent() override
|
||||||
{
|
{
|
||||||
/*AtmosphereRendererClass.bind(_renderer, _definition);
|
/*AtmosphereRendererClass.bind(renderer, _definition);
|
||||||
_renderer->prepare();*/
|
renderer->prepare();*/
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class PreviewSkyWest:public PreviewRenderer, public AtmosphereColorPreviewRenderer
|
class PreviewSkyWest:public AtmosphereColorPreviewRenderer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
void bindEvent(BasePreview* preview) override
|
void bindEvent(BasePreview* preview) override
|
||||||
|
@ -37,10 +38,10 @@ public:
|
||||||
preview->configHdrToneMapping(true);
|
preview->configHdrToneMapping(true);
|
||||||
preview->configScaling(0.5, 5.0, 0.5, 2.5);
|
preview->configScaling(0.5, 5.0, 0.5, 2.5);
|
||||||
}
|
}
|
||||||
void updateData()
|
void updateEvent() override
|
||||||
{
|
{
|
||||||
/*AtmosphereRendererClass.bind(_renderer, _definition);
|
/*AtmosphereRendererClass.bind(renderer, _definition);
|
||||||
_renderer->prepare();*/
|
renderer->prepare();*/
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
#ifndef _PAYSAGES_QT_FORMATMOSPHERE_H_
|
#ifndef _PAYSAGES_QT_FORMATMOSPHERE_H_
|
||||||
#define _PAYSAGES_QT_FORMATMOSPHERE_H_
|
#define _PAYSAGES_QT_FORMATMOSPHERE_H_
|
||||||
|
|
||||||
#include <QWidget>
|
#include "editing_global.h"
|
||||||
#include "basepreview.h"
|
|
||||||
#include "baseform.h"
|
#include "baseform.h"
|
||||||
|
class QWidget;
|
||||||
|
|
||||||
class FormAtmosphere : public BaseForm
|
class FormAtmosphere : public BaseForm
|
||||||
{
|
{
|
||||||
|
|
|
@ -4,6 +4,8 @@
|
||||||
#include "tools/color.h"
|
#include "tools/color.h"
|
||||||
#include "tools/euclid.h"
|
#include "tools/euclid.h"
|
||||||
#include "Scenery.h"
|
#include "Scenery.h"
|
||||||
|
#include "BasePreview.h"
|
||||||
|
#include "renderer.h"
|
||||||
|
|
||||||
#include "tools.h"
|
#include "tools.h"
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
#ifndef _PAYSAGES_QT_FORMCLOUDS_H_
|
#ifndef _PAYSAGES_QT_FORMCLOUDS_H_
|
||||||
#define _PAYSAGES_QT_FORMCLOUDS_H_
|
#define _PAYSAGES_QT_FORMCLOUDS_H_
|
||||||
|
|
||||||
#include <QWidget>
|
#include "editing_global.h"
|
||||||
#include "basepreview.h"
|
|
||||||
#include "baseformlayer.h"
|
#include "baseformlayer.h"
|
||||||
#include "clouds/public.h"
|
#include "clouds/public.h"
|
||||||
|
class QWidget;
|
||||||
|
|
||||||
class FormClouds : public BaseFormLayer
|
class FormClouds : public BaseFormLayer
|
||||||
{
|
{
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
#include "Scenery.h"
|
#include "Scenery.h"
|
||||||
#include "PackStream.h"
|
#include "PackStream.h"
|
||||||
#include "SoftwareRenderer.h"
|
#include "SoftwareRenderer.h"
|
||||||
|
#include "BasePreview.h"
|
||||||
|
|
||||||
/**************** Previews ****************/
|
/**************** Previews ****************/
|
||||||
class PreviewRenderLandscape : public BasePreview
|
class PreviewRenderLandscape : public BasePreview
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
#include "formtextures.h"
|
#include "formtextures.h"
|
||||||
|
|
||||||
#include "Scenery.h"
|
#include "Scenery.h"
|
||||||
|
#include "BasePreview.h"
|
||||||
|
#include "renderer.h"
|
||||||
#include "tools.h"
|
#include "tools.h"
|
||||||
|
#include "camera.h"
|
||||||
|
|
||||||
/**************** Previews ****************/
|
/**************** Previews ****************/
|
||||||
class PreviewTexturesCoverage : public BasePreview
|
class PreviewTexturesCoverage : public BasePreview
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
#ifndef _PAYSAGES_QT_FORMTEXTURES_H_
|
#ifndef _PAYSAGES_QT_FORMTEXTURES_H_
|
||||||
#define _PAYSAGES_QT_FORMTEXTURES_H_
|
#define _PAYSAGES_QT_FORMTEXTURES_H_
|
||||||
|
|
||||||
#include <QWidget>
|
#include "editing_global.h"
|
||||||
#include "basepreview.h"
|
|
||||||
#include "baseformlayer.h"
|
#include "baseformlayer.h"
|
||||||
#include "textures/public.h"
|
#include "textures/public.h"
|
||||||
|
class QWidget;
|
||||||
|
|
||||||
class FormTextures : public BaseFormLayer
|
class FormTextures : public BaseFormLayer
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
#include "basepreview.h"
|
|
||||||
#include "formwater.h"
|
#include "formwater.h"
|
||||||
|
|
||||||
#include <QColor>
|
#include <QColor>
|
||||||
|
@ -13,6 +12,8 @@
|
||||||
#include "atmosphere/public.h"
|
#include "atmosphere/public.h"
|
||||||
#include "tools.h"
|
#include "tools.h"
|
||||||
#include "Scenery.h"
|
#include "Scenery.h"
|
||||||
|
#include "BasePreview.h"
|
||||||
|
#include "camera.h"
|
||||||
|
|
||||||
static WaterDefinition* _definition;
|
static WaterDefinition* _definition;
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
#ifndef _PAYSAGES_QT_FORMWATER_H_
|
#ifndef _PAYSAGES_QT_FORMWATER_H_
|
||||||
#define _PAYSAGES_QT_FORMWATER_H_
|
#define _PAYSAGES_QT_FORMWATER_H_
|
||||||
|
|
||||||
#include <QWidget>
|
#include "editing_global.h"
|
||||||
#include "basepreview.h"
|
|
||||||
#include "baseform.h"
|
#include "baseform.h"
|
||||||
|
class QWidget;
|
||||||
|
|
||||||
class FormWater : public BaseForm
|
class FormWater : public BaseForm
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#ifndef SMALLPREVIEWCOLOR_H
|
#ifndef SMALLPREVIEWCOLOR_H
|
||||||
#define SMALLPREVIEWCOLOR_H
|
#define SMALLPREVIEWCOLOR_H
|
||||||
|
|
||||||
#include "common/DrawingWidget.h"
|
#include "DrawingWidget.h"
|
||||||
|
|
||||||
#include "tools/color.h"
|
#include "tools/color.h"
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#ifndef SMALLPREVIEWHUES_H
|
#ifndef SMALLPREVIEWHUES_H
|
||||||
#define SMALLPREVIEWHUES_H
|
#define SMALLPREVIEWHUES_H
|
||||||
|
|
||||||
#include "common/DrawingWidget.h"
|
#include "DrawingWidget.h"
|
||||||
|
|
||||||
class SmallPreviewHues: public DrawingWidget
|
class SmallPreviewHues: public DrawingWidget
|
||||||
{
|
{
|
||||||
|
|
|
@ -4,9 +4,11 @@
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include "tools.h"
|
#include "tools.h"
|
||||||
#include "SoftwareRenderer.h"
|
#include "SoftwareRenderer.h"
|
||||||
|
#include "BasePreview.h"
|
||||||
|
|
||||||
#include "tools/lighting.h"
|
#include "tools/lighting.h"
|
||||||
#include "tools/color.h"
|
#include "tools/color.h"
|
||||||
|
#include "camera.h"
|
||||||
|
|
||||||
/***** Shared renderer *****/
|
/***** Shared renderer *****/
|
||||||
MaterialPreviewRenderer::MaterialPreviewRenderer(SurfaceMaterial* material)
|
MaterialPreviewRenderer::MaterialPreviewRenderer(SurfaceMaterial* material)
|
||||||
|
@ -24,7 +26,7 @@ MaterialPreviewRenderer::MaterialPreviewRenderer(SurfaceMaterial* material)
|
||||||
_material = material;
|
_material = material;
|
||||||
|
|
||||||
Vector3 camera_location = {0.0, 0.0, 10.0};
|
Vector3 camera_location = {0.0, 0.0, 10.0};
|
||||||
cameraSetLocation(renderer->render_camera, camera_location);
|
cameraSetLocation(render_camera, camera_location);
|
||||||
|
|
||||||
_color_profile = colorProfileCreate();
|
_color_profile = colorProfileCreate();
|
||||||
colorProfileSetToneMapping(_color_profile, TONE_MAPPING_UNCHARTED, 1.0);
|
colorProfileSetToneMapping(_color_profile, TONE_MAPPING_UNCHARTED, 1.0);
|
||||||
|
@ -64,7 +66,7 @@ Color MaterialPreviewRenderer::getColor2D(double x, double y, double)
|
||||||
}
|
}
|
||||||
|
|
||||||
point = v3Normalize(point);
|
point = v3Normalize(point);
|
||||||
color = lightingApplyOneLight(&_light, renderer->getCameraLocation(renderer, point), point, point, _material);
|
color = lightingApplyOneLight(&_light, getCameraLocation(this, point), point, point, _material);
|
||||||
if (dist > 0.95)
|
if (dist > 0.95)
|
||||||
{
|
{
|
||||||
color.a = (1.0 - dist) / 0.05;
|
color.a = (1.0 - dist) / 0.05;
|
||||||
|
|
|
@ -1,16 +1,18 @@
|
||||||
#ifndef _PAYSAGES_QT_PREVIEWMATERIAL_H_
|
#ifndef _PAYSAGES_QT_PREVIEWMATERIAL_H_
|
||||||
#define _PAYSAGES_QT_PREVIEWMATERIAL_H_
|
#define _PAYSAGES_QT_PREVIEWMATERIAL_H_
|
||||||
|
|
||||||
#include "basepreview.h"
|
#include "editing_global.h"
|
||||||
#include "common/previewrenderer.h"
|
|
||||||
|
#include "Base2dPreviewRenderer.h"
|
||||||
|
#include <QWidget>
|
||||||
|
|
||||||
#include "tools/lighting.h"
|
#include "tools/lighting.h"
|
||||||
#include "renderer.h"
|
#include "renderer.h"
|
||||||
|
|
||||||
class MaterialPreviewRenderer:public PreviewRenderer {
|
class MaterialPreviewRenderer:public Base2dPreviewRenderer {
|
||||||
public:
|
public:
|
||||||
MaterialPreviewRenderer(SurfaceMaterial* material);
|
MaterialPreviewRenderer(SurfaceMaterial* material);
|
||||||
~MaterialPreviewRenderer();
|
virtual ~MaterialPreviewRenderer();
|
||||||
|
|
||||||
virtual void bindEvent(BasePreview* preview);
|
virtual void bindEvent(BasePreview* preview);
|
||||||
virtual Color getColor2D(double x, double y, double scaling);
|
virtual Color getColor2D(double x, double y, double scaling);
|
||||||
|
|
|
@ -1,45 +0,0 @@
|
||||||
#ifndef _PAYSAGES_QT_PREVIEWOSD_H_
|
|
||||||
#define _PAYSAGES_QT_PREVIEWOSD_H_
|
|
||||||
|
|
||||||
#include <QImage>
|
|
||||||
#include "camera.h"
|
|
||||||
|
|
||||||
class PreviewOsdItem:public QImage
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
PreviewOsdItem(int width, int height);
|
|
||||||
|
|
||||||
void setLocation(double x, double y);
|
|
||||||
inline double xlocation() {return _xlocation;};
|
|
||||||
inline double ylocation() {return _ylocation;};
|
|
||||||
|
|
||||||
void setToolTip(QString text);
|
|
||||||
QString getToolTip(double x, double y, double scaling);
|
|
||||||
|
|
||||||
void drawCamera(CameraDefinition* camera);
|
|
||||||
|
|
||||||
private:
|
|
||||||
double _xlocation;
|
|
||||||
double _ylocation;
|
|
||||||
QString _tooltip;
|
|
||||||
};
|
|
||||||
|
|
||||||
class PreviewOsd
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
PreviewOsd();
|
|
||||||
~PreviewOsd();
|
|
||||||
|
|
||||||
static PreviewOsd* getInstance(QString name);
|
|
||||||
|
|
||||||
void clearItems();
|
|
||||||
PreviewOsdItem* newItem(int width, int height);
|
|
||||||
PreviewOsdItem* newItem(QImage image);
|
|
||||||
void apply(QImage* mask, double xoffset, double yoffset, double scaling);
|
|
||||||
QString getToolTip(double x, double y, double scaling);
|
|
||||||
|
|
||||||
private:
|
|
||||||
QVector<PreviewOsdItem*> _items;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -5,6 +5,7 @@
|
||||||
#include "dialogbaseterrainnoise.h"
|
#include "dialogbaseterrainnoise.h"
|
||||||
#include "dialogterrainpainting.h"
|
#include "dialogterrainpainting.h"
|
||||||
#include "previewterrainshape.h"
|
#include "previewterrainshape.h"
|
||||||
|
#include "common/freeformhelper.h"
|
||||||
#include "tools.h"
|
#include "tools.h"
|
||||||
#include "Scenery.h"
|
#include "Scenery.h"
|
||||||
#include "textures/public.h"
|
#include "textures/public.h"
|
||||||
|
|
|
@ -1,9 +1,12 @@
|
||||||
#ifndef MAINTERRAINFORM_H
|
#ifndef MAINTERRAINFORM_H
|
||||||
#define MAINTERRAINFORM_H
|
#define MAINTERRAINFORM_H
|
||||||
|
|
||||||
|
#include "editing_global.h"
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include "common/freeformhelper.h"
|
|
||||||
#include "terrain/public.h"
|
#include "terrain/public.h"
|
||||||
|
class FreeFormHelper;
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class MainTerrainForm;
|
class MainTerrainForm;
|
||||||
|
@ -36,7 +39,7 @@ private:
|
||||||
|
|
||||||
TerrainDefinition* _terrain;
|
TerrainDefinition* _terrain;
|
||||||
|
|
||||||
PreviewRenderer* _renderer_shape;
|
Base2dPreviewRenderer* _renderer_shape;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MAINTERRAINFORM_H
|
#endif // MAINTERRAINFORM_H
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#include "previewterrainshape.h"
|
#include "previewterrainshape.h"
|
||||||
|
|
||||||
#include "SoftwareRenderer.h"
|
#include "SoftwareRenderer.h"
|
||||||
#include "basepreview.h"
|
#include "BasePreview.h"
|
||||||
#include "water/public.h"
|
#include "water/public.h"
|
||||||
|
|
||||||
PreviewTerrainShape::PreviewTerrainShape(TerrainDefinition* terrain)
|
PreviewTerrainShape::PreviewTerrainShape(TerrainDefinition* terrain)
|
||||||
|
@ -9,7 +9,7 @@ PreviewTerrainShape::PreviewTerrainShape(TerrainDefinition* terrain)
|
||||||
_terrain = terrain;
|
_terrain = terrain;
|
||||||
_highlight_enabled = true;
|
_highlight_enabled = true;
|
||||||
|
|
||||||
terrainAlterPreviewRenderer(renderer);
|
terrainAlterPreviewRenderer(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PreviewTerrainShape::bindEvent(BasePreview* preview)
|
void PreviewTerrainShape::bindEvent(BasePreview* preview)
|
||||||
|
@ -23,12 +23,12 @@ void PreviewTerrainShape::bindEvent(BasePreview* preview)
|
||||||
|
|
||||||
void PreviewTerrainShape::updateEvent()
|
void PreviewTerrainShape::updateEvent()
|
||||||
{
|
{
|
||||||
TerrainRendererClass.bind(renderer, _terrain);
|
TerrainRendererClass.bind(this, _terrain);
|
||||||
}
|
}
|
||||||
|
|
||||||
Color PreviewTerrainShape::getColor2D(double x, double y, double scaling) const
|
Color PreviewTerrainShape::getColor2D(double x, double y, double scaling)
|
||||||
{
|
{
|
||||||
return waterGetPreviewCoverage(renderer, x, y, scaling, _highlight_enabled ? 1 : 0);
|
return waterGetPreviewCoverage(this, x, y, scaling, _highlight_enabled ? 1 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PreviewTerrainShape::toggleChangeEvent(QString key, bool value)
|
void PreviewTerrainShape::toggleChangeEvent(QString key, bool value)
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
#ifndef PREVIEWTERRAINSHAPE_H
|
#ifndef PREVIEWTERRAINSHAPE_H
|
||||||
#define PREVIEWTERRAINSHAPE_H
|
#define PREVIEWTERRAINSHAPE_H
|
||||||
|
|
||||||
#include "common/previewrenderer.h"
|
#include "editing_global.h"
|
||||||
#include "renderer.h"
|
|
||||||
|
#include "Base2dPreviewRenderer.h"
|
||||||
#include "terrain/public.h"
|
#include "terrain/public.h"
|
||||||
|
|
||||||
class PreviewTerrainShape : public PreviewRenderer
|
class PreviewTerrainShape : public Base2dPreviewRenderer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit PreviewTerrainShape(TerrainDefinition* terrain);
|
explicit PreviewTerrainShape(TerrainDefinition* terrain);
|
||||||
|
@ -13,7 +14,7 @@ public:
|
||||||
protected:
|
protected:
|
||||||
virtual void bindEvent(BasePreview* preview);
|
virtual void bindEvent(BasePreview* preview);
|
||||||
virtual void updateEvent();
|
virtual void updateEvent();
|
||||||
virtual Color getColor2D(double x, double y, double scaling) const override;
|
virtual Color getColor2D(double x, double y, double scaling) override;
|
||||||
virtual void toggleChangeEvent(QString key, bool value);
|
virtual void toggleChangeEvent(QString key, bool value);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
#include "editing_global.h"
|
#include "editing_global.h"
|
||||||
|
|
||||||
#include "common/DrawingWidget.h"
|
#include "DrawingWidget.h"
|
||||||
class QPainter;
|
class QPainter;
|
||||||
|
|
||||||
class WidgetTerrainBaseNoisePreview : public DrawingWidget
|
class WidgetTerrainBaseNoisePreview : public DrawingWidget
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#include "PreviewCumul.h"
|
#include "PreviewCumul.h"
|
||||||
|
|
||||||
#include "SoftwareRenderer.h"
|
#include "SoftwareRenderer.h"
|
||||||
#include "basepreview.h"
|
#include "BasePreview.h"
|
||||||
#include "textures/tex_preview.h"
|
#include "textures/tex_preview.h"
|
||||||
|
|
||||||
void PreviewCumul::setTextures(TexturesDefinition* textures)
|
void PreviewCumul::setTextures(TexturesDefinition* textures)
|
||||||
|
@ -28,7 +28,7 @@ void PreviewCumul::updateEvent()
|
||||||
{
|
{
|
||||||
if (textures)
|
if (textures)
|
||||||
{
|
{
|
||||||
TexturesPreviewCumul_bind(renderer, textures);
|
TexturesPreviewCumul_bind(this, textures);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ Color PreviewCumul::getColor2D(double x, double y, double scaling)
|
||||||
{
|
{
|
||||||
if (textures)
|
if (textures)
|
||||||
{
|
{
|
||||||
return TexturesPreviewCumul_getColor(renderer, x, y, scaling, layer);
|
return TexturesPreviewCumul_getColor(this, x, y, scaling, layer);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,16 +1,17 @@
|
||||||
#ifndef EDITING_TEXTURES_PREVIEWCUMUL_H
|
#ifndef EDITING_TEXTURES_PREVIEWCUMUL_H
|
||||||
#define EDITING_TEXTURES_PREVIEWCUMUL_H
|
#define EDITING_TEXTURES_PREVIEWCUMUL_H
|
||||||
|
|
||||||
#include "common/previewrenderer.h"
|
#include "editing_global.h"
|
||||||
|
|
||||||
|
#include "Base2dPreviewRenderer.h"
|
||||||
|
|
||||||
class BasePreview;
|
|
||||||
class TexturesDefinition;
|
class TexturesDefinition;
|
||||||
|
|
||||||
class PreviewCumul : public PreviewRenderer
|
class PreviewCumul : public Base2dPreviewRenderer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit PreviewCumul():
|
explicit PreviewCumul():
|
||||||
PreviewRenderer(),textures(0){}
|
Base2dPreviewRenderer(),textures(0){}
|
||||||
|
|
||||||
void setTextures(TexturesDefinition* textures);
|
void setTextures(TexturesDefinition* textures);
|
||||||
void setLayer(int layer);
|
void setLayer(int layer);
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#include "PreviewLayerCoverage.h"
|
#include "PreviewLayerCoverage.h"
|
||||||
|
|
||||||
#include "SoftwareRenderer.h"
|
#include "SoftwareRenderer.h"
|
||||||
#include "basepreview.h"
|
#include "BasePreview.h"
|
||||||
#include "textures/tex_preview.h"
|
#include "textures/tex_preview.h"
|
||||||
|
|
||||||
void PreviewLayerCoverage::setTextures(TexturesDefinition* textures)
|
void PreviewLayerCoverage::setTextures(TexturesDefinition* textures)
|
||||||
|
@ -26,7 +26,7 @@ void PreviewLayerCoverage::updateEvent()
|
||||||
{
|
{
|
||||||
if (textures)
|
if (textures)
|
||||||
{
|
{
|
||||||
TexturesPreviewLayerCoverage_bind(renderer, textures);
|
TexturesPreviewLayerCoverage_bind(this, textures);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ Color PreviewLayerCoverage::getColor2D(double x, double y, double scaling)
|
||||||
{
|
{
|
||||||
if (textures)
|
if (textures)
|
||||||
{
|
{
|
||||||
return TexturesPreviewLayerCoverage_getColor(renderer, x, y, scaling, layer);
|
return TexturesPreviewLayerCoverage_getColor(this, x, y, scaling, layer);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,16 +1,17 @@
|
||||||
#ifndef EDITING_TEXTURES_PREVIEWLAYERCOVERAGE_H
|
#ifndef EDITING_TEXTURES_PREVIEWLAYERCOVERAGE_H
|
||||||
#define EDITING_TEXTURES_PREVIEWLAYERCOVERAGE_H
|
#define EDITING_TEXTURES_PREVIEWLAYERCOVERAGE_H
|
||||||
|
|
||||||
#include "common/previewrenderer.h"
|
#include "editing_global.h"
|
||||||
|
|
||||||
|
#include "Base2dPreviewRenderer.h"
|
||||||
|
|
||||||
class BasePreview;
|
|
||||||
class TexturesDefinition;
|
class TexturesDefinition;
|
||||||
|
|
||||||
class PreviewLayerCoverage : public PreviewRenderer
|
class PreviewLayerCoverage : public Base2dPreviewRenderer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit PreviewLayerCoverage():
|
explicit PreviewLayerCoverage():
|
||||||
PreviewRenderer(),textures(0){}
|
Base2dPreviewRenderer(),textures(0){}
|
||||||
|
|
||||||
void setTextures(TexturesDefinition* textures);
|
void setTextures(TexturesDefinition* textures);
|
||||||
void setLayer(int layer);
|
void setLayer(int layer);
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#include "PreviewLayerLook.h"
|
#include "PreviewLayerLook.h"
|
||||||
|
|
||||||
#include "SoftwareRenderer.h"
|
#include "SoftwareRenderer.h"
|
||||||
#include "basepreview.h"
|
#include "BasePreview.h"
|
||||||
#include "textures/tex_preview.h"
|
#include "textures/tex_preview.h"
|
||||||
|
|
||||||
void PreviewLayerLook::setTextures(TexturesDefinition* textures)
|
void PreviewLayerLook::setTextures(TexturesDefinition* textures)
|
||||||
|
@ -25,7 +25,7 @@ void PreviewLayerLook::updateEvent()
|
||||||
{
|
{
|
||||||
if (textures)
|
if (textures)
|
||||||
{
|
{
|
||||||
TexturesPreviewLayerLook_bind(renderer, textures);
|
TexturesPreviewLayerLook_bind(this, textures);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ Color PreviewLayerLook::getColor2D(double x, double y, double scaling)
|
||||||
{
|
{
|
||||||
if (textures)
|
if (textures)
|
||||||
{
|
{
|
||||||
return TexturesPreviewLayerLook_getColor(renderer, x, y, scaling, layer);
|
return TexturesPreviewLayerLook_getColor(this, x, y, scaling, layer);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,16 +1,17 @@
|
||||||
#ifndef EDITING_TEXTURES_PREVIEWLAYERLOOK_H
|
#ifndef EDITING_TEXTURES_PREVIEWLAYERLOOK_H
|
||||||
#define EDITING_TEXTURES_PREVIEWLAYERLOOK_H
|
#define EDITING_TEXTURES_PREVIEWLAYERLOOK_H
|
||||||
|
|
||||||
#include "common/previewrenderer.h"
|
#include "editing_global.h"
|
||||||
|
|
||||||
|
#include "Base2dPreviewRenderer.h"
|
||||||
|
|
||||||
class BasePreview;
|
|
||||||
class TexturesDefinition;
|
class TexturesDefinition;
|
||||||
|
|
||||||
class PreviewLayerLook : public PreviewRenderer
|
class PreviewLayerLook : public Base2dPreviewRenderer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit PreviewLayerLook():
|
explicit PreviewLayerLook():
|
||||||
PreviewRenderer(),textures(0){}
|
Base2dPreviewRenderer(),textures(0){}
|
||||||
|
|
||||||
void setTextures(TexturesDefinition* textures);
|
void setTextures(TexturesDefinition* textures);
|
||||||
void setLayer(int layer);
|
void setLayer(int layer);
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#include "tools.h"
|
#include "tools.h"
|
||||||
|
|
||||||
#include <QEvent>
|
#include <QEvent>
|
||||||
#include "basepreview.h"
|
#include "BasePreview.h"
|
||||||
|
|
||||||
DialogWithPreview::DialogWithPreview(QWidget* parent) : QDialog(parent)
|
DialogWithPreview::DialogWithPreview(QWidget* parent) : QDialog(parent)
|
||||||
{
|
{
|
||||||
|
|
|
@ -147,10 +147,10 @@ static inline int _checkHit(Vector3 eye, Vector3 direction, Vector3* hit, Vector
|
||||||
AtmosphereColorPreviewRenderer::AtmosphereColorPreviewRenderer():
|
AtmosphereColorPreviewRenderer::AtmosphereColorPreviewRenderer():
|
||||||
heading(0.0)
|
heading(0.0)
|
||||||
{
|
{
|
||||||
cameraSetLocation(renderer->render_camera, Vector3(0.0, 7.0, 0.0));
|
cameraSetLocation(render_camera, Vector3(0.0, 7.0, 0.0));
|
||||||
}
|
}
|
||||||
|
|
||||||
Color AtmosphereColorPreviewRenderer::getColor2D(double x, double y, double) const
|
Color AtmosphereColorPreviewRenderer::getColor2D(double x, double y, double)
|
||||||
{
|
{
|
||||||
Vector3 eye = {0.0, 7.0, 0.0};
|
Vector3 eye = {0.0, 7.0, 0.0};
|
||||||
Vector3 direction = {x, y, -1.0};
|
Vector3 direction = {x, y, -1.0};
|
||||||
|
@ -166,13 +166,13 @@ Color AtmosphereColorPreviewRenderer::getColor2D(double x, double y, double) con
|
||||||
normal = m4Transform(rotation, normal);
|
normal = m4Transform(rotation, normal);
|
||||||
hit = m4Transform(rotation, hit);
|
hit = m4Transform(rotation, hit);
|
||||||
|
|
||||||
color = renderer->applyLightingToSurface(renderer, hit, normal, &MOUNT_MATERIAL);
|
color = this->applyLightingToSurface(this, hit, normal, &MOUNT_MATERIAL);
|
||||||
return renderer->atmosphere->applyAerialPerspective(renderer, hit, color).final;
|
return this->atmosphere->applyAerialPerspective(this, hit, color).final;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
direction = m4Transform(rotation, direction);
|
direction = m4Transform(rotation, direction);
|
||||||
|
|
||||||
return renderer->atmosphere->getSkyColor(renderer, direction).final;
|
return this->atmosphere->getSkyColor(this, direction).final;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ class AtmosphereColorPreviewRenderer:public Base2dPreviewRenderer
|
||||||
public:
|
public:
|
||||||
AtmosphereColorPreviewRenderer();
|
AtmosphereColorPreviewRenderer();
|
||||||
|
|
||||||
virtual Color getColor2D(double x, double y, double scaling) const override;
|
virtual Color getColor2D(double x, double y, double scaling) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
double heading;
|
double heading;
|
||||||
|
|
|
@ -1,18 +1,28 @@
|
||||||
#include "Base2dPreviewRenderer.h"
|
#include "Base2dPreviewRenderer.h"
|
||||||
|
|
||||||
|
#include "Scenery.h"
|
||||||
#include "SoftwareRenderer.h"
|
#include "SoftwareRenderer.h"
|
||||||
|
|
||||||
Base2dPreviewRenderer::Base2dPreviewRenderer()
|
Base2dPreviewRenderer::Base2dPreviewRenderer():
|
||||||
|
SoftwareRenderer()
|
||||||
|
{
|
||||||
|
scenery = new Scenery();
|
||||||
|
}
|
||||||
|
|
||||||
|
Base2dPreviewRenderer::~Base2dPreviewRenderer()
|
||||||
|
{
|
||||||
|
delete scenery;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Base2dPreviewRenderer::bindEvent(BasePreview*)
|
||||||
{
|
{
|
||||||
renderer = new SoftwareRenderer();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Base2dPreviewRenderer::updateEvent()
|
void Base2dPreviewRenderer::updateEvent()
|
||||||
{
|
{
|
||||||
delete renderer;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Color Base2dPreviewRenderer::getColor2D(double, double, double) const
|
Color Base2dPreviewRenderer::getColor2D(double, double, double)
|
||||||
{
|
{
|
||||||
return COLOR_BLACK;
|
return COLOR_BLACK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,22 +3,28 @@
|
||||||
|
|
||||||
#include "preview_global.h"
|
#include "preview_global.h"
|
||||||
|
|
||||||
|
#include "SoftwareRenderer.h"
|
||||||
#include "tools/color.h"
|
#include "tools/color.h"
|
||||||
|
|
||||||
|
class Scenery;
|
||||||
|
|
||||||
namespace paysages {
|
namespace paysages {
|
||||||
namespace preview {
|
namespace preview {
|
||||||
|
|
||||||
class PREVIEWSHARED_EXPORT Base2dPreviewRenderer
|
class PREVIEWSHARED_EXPORT Base2dPreviewRenderer: protected SoftwareRenderer
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Base2dPreviewRenderer();
|
Base2dPreviewRenderer();
|
||||||
|
virtual ~Base2dPreviewRenderer();
|
||||||
|
|
||||||
|
virtual void bindEvent(BasePreview* preview);
|
||||||
|
|
||||||
virtual void updateEvent();
|
virtual void updateEvent();
|
||||||
virtual Color getColor2D(double x, double y, double scaling) const;
|
virtual Color getColor2D(double x, double y, double scaling);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
SoftwareRenderer* renderer;
|
Scenery* scenery;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#include "basepreview.h"
|
#include "BasePreview.h"
|
||||||
|
|
||||||
#include <QVector>
|
#include <QVector>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
@ -6,11 +6,15 @@
|
||||||
#include <QWheelEvent>
|
#include <QWheelEvent>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <assert.h>
|
#include <QThread>
|
||||||
#include <math.h>
|
#include <QMutex>
|
||||||
|
#include <cassert>
|
||||||
|
#include <cmath>
|
||||||
#include "tools.h"
|
#include "tools.h"
|
||||||
#include "System.h"
|
#include "System.h"
|
||||||
#include "PackStream.h"
|
#include "PackStream.h"
|
||||||
|
#include "Base2dPreviewRenderer.h"
|
||||||
|
#include "PreviewOsd.h"
|
||||||
|
|
||||||
/*************** PreviewChunk ***************/
|
/*************** PreviewChunk ***************/
|
||||||
class PreviewChunk
|
class PreviewChunk
|
||||||
|
@ -142,9 +146,50 @@ private:
|
||||||
int _ysize;
|
int _ysize;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class PreviewDrawingThread;
|
||||||
|
class PreviewDrawingManager
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
PreviewDrawingManager();
|
||||||
|
void startThreads();
|
||||||
|
void stopThreads();
|
||||||
|
void addChunk(PreviewChunk* chunk);
|
||||||
|
void removeChunks(BasePreview* preview);
|
||||||
|
void updateChunks(BasePreview* preview);
|
||||||
|
void suspendChunks(BasePreview* preview);
|
||||||
|
void updateAllChunks();
|
||||||
|
void performOneThreadJob();
|
||||||
|
int chunkCount();
|
||||||
|
|
||||||
|
private:
|
||||||
|
int _thread_count;
|
||||||
|
QVector<PreviewDrawingThread*> _threads;
|
||||||
|
QVector<PreviewChunk*> _chunks;
|
||||||
|
QList<PreviewChunk*> _updateQueue;
|
||||||
|
QMutex _lock;
|
||||||
|
};
|
||||||
|
|
||||||
static PreviewDrawingManager* _drawing_manager = NULL;
|
static PreviewDrawingManager* _drawing_manager = NULL;
|
||||||
|
|
||||||
/*************** PreviewDrawingThread ***************/
|
/*************** PreviewDrawingThread ***************/
|
||||||
|
class PreviewDrawingThread : public QThread
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
PreviewDrawingThread();
|
||||||
|
void askStop();
|
||||||
|
|
||||||
|
static inline void usleep(int us)
|
||||||
|
{
|
||||||
|
QThread::usleep(us);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void run();
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool _running;
|
||||||
|
};
|
||||||
|
|
||||||
PreviewDrawingThread::PreviewDrawingThread() :
|
PreviewDrawingThread::PreviewDrawingThread() :
|
||||||
QThread()
|
QThread()
|
||||||
{
|
{
|
||||||
|
@ -184,7 +229,7 @@ void PreviewDrawingManager::startThreads()
|
||||||
|
|
||||||
void PreviewDrawingManager::stopThreads()
|
void PreviewDrawingManager::stopThreads()
|
||||||
{
|
{
|
||||||
logDebug(QString("[Previews] Stopping all render threads"));
|
qDebug("[Previews] Stopping all render threads");
|
||||||
for (int i = 0; i < _threads.size(); i++)
|
for (int i = 0; i < _threads.size(); i++)
|
||||||
{
|
{
|
||||||
_threads.at(i)->askStop();
|
_threads.at(i)->askStop();
|
||||||
|
@ -226,7 +271,7 @@ void PreviewDrawingManager::removeChunks(BasePreview* preview)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
logDebug(QString("[Previews] %1 chunks removed, %2 remaining").arg(removed).arg(_chunks.size()));
|
qDebug("[Previews] %d chunks removed, %d remaining", removed, _chunks.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
void PreviewDrawingManager::suspendChunks(BasePreview* preview)
|
void PreviewDrawingManager::suspendChunks(BasePreview* preview)
|
||||||
|
@ -270,7 +315,7 @@ void PreviewDrawingManager::updateChunks(BasePreview* preview)
|
||||||
|
|
||||||
void PreviewDrawingManager::updateAllChunks()
|
void PreviewDrawingManager::updateAllChunks()
|
||||||
{
|
{
|
||||||
logDebug(QString("[Previews] Reviving all %1 preview chunks").arg(_chunks.size()));
|
qDebug("[Previews] Reviving all %d preview chunks", _chunks.size());
|
||||||
for (int i = 0; i < _chunks.size(); i++)
|
for (int i = 0; i < _chunks.size(); i++)
|
||||||
{
|
{
|
||||||
PreviewChunk* chunk;
|
PreviewChunk* chunk;
|
||||||
|
@ -388,7 +433,7 @@ BasePreview::~BasePreview()
|
||||||
delete _lock_drawing;
|
delete _lock_drawing;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BasePreview::setRenderer(PreviewRenderer* renderer)
|
void BasePreview::setRenderer(Base2dPreviewRenderer* renderer)
|
||||||
{
|
{
|
||||||
_renderer = renderer;
|
_renderer = renderer;
|
||||||
_renderer->bindEvent(this);
|
_renderer->bindEvent(this);
|
||||||
|
@ -605,7 +650,7 @@ QColor BasePreview::getPixelColor(int x, int y)
|
||||||
{
|
{
|
||||||
colorNormalize(&col);
|
colorNormalize(&col);
|
||||||
}
|
}
|
||||||
return colorToQColor(col);
|
return QColor::fromRgbF(col.r, col.g, col.b, col.a);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BasePreview::timerEvent(QTimerEvent*)
|
void BasePreview::timerEvent(QTimerEvent*)
|
||||||
|
@ -681,7 +726,7 @@ void BasePreview::resizeEvent(QResizeEvent* event)
|
||||||
added++;
|
added++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
logDebug(QString("[Previews] %1 chunks added, %2 total").arg(added).arg(_drawing_manager->chunkCount()));
|
qDebug("[Previews] %d chunks added, %d total", added, _drawing_manager->chunkCount());
|
||||||
|
|
||||||
delete image;
|
delete image;
|
||||||
|
|
||||||
|
@ -770,7 +815,7 @@ void BasePreview::contextMenuEvent(QContextMenuEvent* event)
|
||||||
action->setProperty("value", i);
|
action->setProperty("value", i);
|
||||||
if (i == iter1.value().current)
|
if (i == iter1.value().current)
|
||||||
{
|
{
|
||||||
action->setIcon(QIcon(getDataPath("images/choice_on.png")));
|
action->setIcon(QIcon(":/images/choice_on.png"));
|
||||||
action->setIconVisibleInMenu(true);
|
action->setIconVisibleInMenu(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -793,7 +838,7 @@ void BasePreview::contextMenuEvent(QContextMenuEvent* event)
|
||||||
action->setProperty("value", not iter2.value().value);
|
action->setProperty("value", not iter2.value().value);
|
||||||
if (iter2.value().value)
|
if (iter2.value().value)
|
||||||
{
|
{
|
||||||
action->setIcon(QIcon(getDataPath("images/toggle_on.png")));
|
action->setIcon(QIcon(":/images/toggle_on.png"));
|
||||||
action->setIconVisibleInMenu(true);
|
action->setIconVisibleInMenu(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,26 +1,18 @@
|
||||||
#ifndef _PAYSAGES_QT_BASEPREVIEW_H_
|
#ifndef BASEPREVIEW_H
|
||||||
#define _PAYSAGES_QT_BASEPREVIEW_H_
|
#define BASEPREVIEW_H
|
||||||
|
|
||||||
#include "editing_global.h"
|
#include "preview_global.h"
|
||||||
|
|
||||||
#include <QMutex>
|
#include "DrawingWidget.h"
|
||||||
#include <QImage>
|
|
||||||
#include <QThread>
|
|
||||||
#include <QVector>
|
|
||||||
#include <QList>
|
|
||||||
#include <QLabel>
|
|
||||||
#include <QHash>
|
|
||||||
|
|
||||||
#include "previewosd.h"
|
|
||||||
#include "common/DrawingWidget.h"
|
|
||||||
#include "common/previewrenderer.h"
|
|
||||||
#include "tools/color.h"
|
#include "tools/color.h"
|
||||||
|
#include <QImage>
|
||||||
|
#include <QStringList>
|
||||||
|
class QPainter;
|
||||||
|
class QMutex;
|
||||||
|
class QLabel;
|
||||||
|
|
||||||
namespace paysages {
|
namespace paysages {
|
||||||
namespace system {
|
namespace preview {
|
||||||
class PackStream;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class _ContextChoice
|
class _ContextChoice
|
||||||
{
|
{
|
||||||
|
@ -37,8 +29,6 @@ public:
|
||||||
bool value;
|
bool value;
|
||||||
};
|
};
|
||||||
|
|
||||||
class QPainter;
|
|
||||||
|
|
||||||
class BasePreview : public DrawingWidget
|
class BasePreview : public DrawingWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -47,7 +37,7 @@ public:
|
||||||
BasePreview(QWidget* parent);
|
BasePreview(QWidget* parent);
|
||||||
~BasePreview();
|
~BasePreview();
|
||||||
|
|
||||||
void setRenderer(PreviewRenderer* renderer);
|
void setRenderer(Base2dPreviewRenderer* renderer);
|
||||||
|
|
||||||
virtual void savePack(PackStream* stream);
|
virtual void savePack(PackStream* stream);
|
||||||
virtual void loadPack(PackStream* stream);
|
virtual void loadPack(PackStream* stream);
|
||||||
|
@ -110,7 +100,7 @@ private:
|
||||||
|
|
||||||
QLabel* _info;
|
QLabel* _info;
|
||||||
|
|
||||||
PreviewRenderer* _renderer;
|
Base2dPreviewRenderer* _renderer;
|
||||||
|
|
||||||
int _width;
|
int _width;
|
||||||
int _height;
|
int _height;
|
||||||
|
@ -149,50 +139,7 @@ private slots:
|
||||||
void choiceSelected(QAction* action);
|
void choiceSelected(QAction* action);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/*** Private section ***/
|
|
||||||
class PreviewChunk;
|
|
||||||
|
|
||||||
class PreviewDrawingThread : public QThread
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
PreviewDrawingThread();
|
|
||||||
void askStop();
|
|
||||||
|
|
||||||
static inline void usleep(int us)
|
|
||||||
{
|
|
||||||
QThread::usleep(us);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
#endif // BASEPREVIEW_H
|
||||||
void run();
|
|
||||||
|
|
||||||
private:
|
|
||||||
bool _running;
|
|
||||||
};
|
|
||||||
|
|
||||||
class PreviewDrawingManager
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
PreviewDrawingManager();
|
|
||||||
void startThreads();
|
|
||||||
void stopThreads();
|
|
||||||
void addChunk(PreviewChunk* chunk);
|
|
||||||
void removeChunks(BasePreview* preview);
|
|
||||||
void updateChunks(BasePreview* preview);
|
|
||||||
void suspendChunks(BasePreview* preview);
|
|
||||||
void updateAllChunks();
|
|
||||||
void performOneThreadJob();
|
|
||||||
int chunkCount();
|
|
||||||
|
|
||||||
private:
|
|
||||||
int _thread_count;
|
|
||||||
QVector<PreviewDrawingThread*> _threads;
|
|
||||||
QVector<PreviewChunk*> _chunks;
|
|
||||||
QList<PreviewChunk*> _updateQueue;
|
|
||||||
QMutex _lock;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,11 +1,16 @@
|
||||||
#ifndef DRAWINGWIDGET_H
|
#ifndef DRAWINGWIDGET_H
|
||||||
#define DRAWINGWIDGET_H
|
#define DRAWINGWIDGET_H
|
||||||
|
|
||||||
|
#include "preview_global.h"
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
class QPaintEvent;
|
class QPaintEvent;
|
||||||
class QPainter;
|
class QPainter;
|
||||||
|
|
||||||
|
namespace paysages {
|
||||||
|
namespace preview {
|
||||||
|
|
||||||
class DrawingWidget : public QWidget
|
class DrawingWidget : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -17,5 +22,8 @@ private:
|
||||||
virtual void paintEvent(QPaintEvent* event);
|
virtual void paintEvent(QPaintEvent* event);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* DRAWINGWIDGET_H */
|
#endif /* DRAWINGWIDGET_H */
|
||||||
|
|
|
@ -1,59 +1,12 @@
|
||||||
#include "previewosd.h"
|
#include "PreviewOsd.h"
|
||||||
|
|
||||||
|
#include <QImage>
|
||||||
#include <QHash>
|
#include <QHash>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <math.h>
|
#include "PreviewOsdItem.h"
|
||||||
|
|
||||||
static QHash<QString, PreviewOsd*> _instances;
|
static QHash<QString, PreviewOsd*> _instances;
|
||||||
|
|
||||||
/*************** PreviewOsdItem ***************/
|
|
||||||
PreviewOsdItem::PreviewOsdItem(int width, int height) : QImage(width, height, QImage::Format_ARGB32)
|
|
||||||
{
|
|
||||||
_xlocation = 0.0;
|
|
||||||
_ylocation = 0.0;
|
|
||||||
fill(0x00000000);
|
|
||||||
}
|
|
||||||
|
|
||||||
void PreviewOsdItem::setLocation(double x, double y)
|
|
||||||
{
|
|
||||||
_xlocation = x;
|
|
||||||
_ylocation = y;
|
|
||||||
}
|
|
||||||
|
|
||||||
void PreviewOsdItem::drawCamera(CameraDefinition* camera)
|
|
||||||
{
|
|
||||||
Vector3 camera_location = cameraGetLocation(camera);
|
|
||||||
VectorSpherical camera_direction = cameraGetDirectionSpherical(camera);
|
|
||||||
int w2 = width() / 2;
|
|
||||||
int h2 = height() / 2;
|
|
||||||
|
|
||||||
_xlocation = camera_location.x;
|
|
||||||
_ylocation = camera_location.z;
|
|
||||||
|
|
||||||
QPainter painter(this);
|
|
||||||
painter.setPen(QPen(Qt::red, 2));
|
|
||||||
painter.setRenderHints(QPainter::Antialiasing | QPainter::HighQualityAntialiasing, true);
|
|
||||||
painter.drawLine(w2, h2, w2 + w2 * cos(camera_direction.phi - M_PI_4), h2 - h2 * sin(camera_direction.phi - M_PI_4));
|
|
||||||
painter.drawLine(w2, h2, w2 + w2 * cos(camera_direction.phi + M_PI_4), h2 - h2 * sin(camera_direction.phi + M_PI_4));
|
|
||||||
}
|
|
||||||
|
|
||||||
void PreviewOsdItem::setToolTip(QString text)
|
|
||||||
{
|
|
||||||
_tooltip = text;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString PreviewOsdItem::getToolTip(double x, double y, double scaling)
|
|
||||||
{
|
|
||||||
if (_tooltip.isEmpty() or (x > _xlocation - (width() / 2) * scaling and x < _xlocation + (width() / 2) * scaling and y > _ylocation - (height() / 2) * scaling and y < _ylocation + (height() / 2) * scaling))
|
|
||||||
{
|
|
||||||
return _tooltip;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return QString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*************** PreviewOsd ***************/
|
/*************** PreviewOsd ***************/
|
||||||
PreviewOsd::PreviewOsd()
|
PreviewOsd::PreviewOsd()
|
||||||
{
|
{
|
||||||
|
@ -97,7 +50,7 @@ PreviewOsdItem* PreviewOsd::newItem(int width, int height)
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
PreviewOsdItem* PreviewOsd::newItem(QImage image)
|
PreviewOsdItem* PreviewOsd::newItem(const QImage &image)
|
||||||
{
|
{
|
||||||
PreviewOsdItem* item = newItem(image.width(), image.height());
|
PreviewOsdItem* item = newItem(image.width(), image.height());
|
||||||
QPainter painter(item);
|
QPainter painter(item);
|
33
src/render/preview/PreviewOsd.h
Normal file
33
src/render/preview/PreviewOsd.h
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
#ifndef PREVIEWOSD_H
|
||||||
|
#define PREVIEWOSD_H
|
||||||
|
|
||||||
|
#include "preview_global.h"
|
||||||
|
|
||||||
|
#include <QVector>
|
||||||
|
class QImage;
|
||||||
|
|
||||||
|
namespace paysages {
|
||||||
|
namespace preview {
|
||||||
|
|
||||||
|
class PreviewOsd
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
PreviewOsd();
|
||||||
|
~PreviewOsd();
|
||||||
|
|
||||||
|
static PreviewOsd* getInstance(QString name);
|
||||||
|
|
||||||
|
void clearItems();
|
||||||
|
PreviewOsdItem* newItem(int width, int height);
|
||||||
|
PreviewOsdItem* newItem(const QImage& image);
|
||||||
|
void apply(QImage* mask, double xoffset, double yoffset, double scaling);
|
||||||
|
QString getToolTip(double x, double y, double scaling);
|
||||||
|
|
||||||
|
private:
|
||||||
|
QVector<PreviewOsdItem*> _items;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
52
src/render/preview/PreviewOsdItem.cpp
Normal file
52
src/render/preview/PreviewOsdItem.cpp
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
#include "PreviewOsdItem.h"
|
||||||
|
|
||||||
|
#include <QPainter>
|
||||||
|
#include "Vector3.h"
|
||||||
|
#include "camera.h"
|
||||||
|
|
||||||
|
PreviewOsdItem::PreviewOsdItem(int width, int height) : QImage(width, height, QImage::Format_ARGB32)
|
||||||
|
{
|
||||||
|
_xlocation = 0.0;
|
||||||
|
_ylocation = 0.0;
|
||||||
|
fill(0x00000000);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PreviewOsdItem::setLocation(double x, double y)
|
||||||
|
{
|
||||||
|
_xlocation = x;
|
||||||
|
_ylocation = y;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PreviewOsdItem::drawCamera(CameraDefinition* camera)
|
||||||
|
{
|
||||||
|
Vector3 camera_location = cameraGetLocation(camera);
|
||||||
|
VectorSpherical camera_direction = cameraGetDirectionSpherical(camera);
|
||||||
|
int w2 = width() / 2;
|
||||||
|
int h2 = height() / 2;
|
||||||
|
|
||||||
|
_xlocation = camera_location.x;
|
||||||
|
_ylocation = camera_location.z;
|
||||||
|
|
||||||
|
QPainter painter(this);
|
||||||
|
painter.setPen(QPen(Qt::red, 2));
|
||||||
|
painter.setRenderHints(QPainter::Antialiasing | QPainter::HighQualityAntialiasing, true);
|
||||||
|
painter.drawLine(w2, h2, w2 + w2 * cos(camera_direction.phi - M_PI_4), h2 - h2 * sin(camera_direction.phi - M_PI_4));
|
||||||
|
painter.drawLine(w2, h2, w2 + w2 * cos(camera_direction.phi + M_PI_4), h2 - h2 * sin(camera_direction.phi + M_PI_4));
|
||||||
|
}
|
||||||
|
|
||||||
|
void PreviewOsdItem::setToolTip(QString text)
|
||||||
|
{
|
||||||
|
_tooltip = text;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString PreviewOsdItem::getToolTip(double x, double y, double scaling)
|
||||||
|
{
|
||||||
|
if (_tooltip.isEmpty() or (x > _xlocation - (width() / 2) * scaling and x < _xlocation + (width() / 2) * scaling and y > _ylocation - (height() / 2) * scaling and y < _ylocation + (height() / 2) * scaling))
|
||||||
|
{
|
||||||
|
return _tooltip;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return QString();
|
||||||
|
}
|
||||||
|
}
|
36
src/render/preview/PreviewOsdItem.h
Normal file
36
src/render/preview/PreviewOsdItem.h
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
#ifndef PREVIEWOSDITEM_H
|
||||||
|
#define PREVIEWOSDITEM_H
|
||||||
|
|
||||||
|
#include "preview_global.h"
|
||||||
|
|
||||||
|
#include <QImage>
|
||||||
|
|
||||||
|
class CameraDefinition;
|
||||||
|
|
||||||
|
namespace paysages {
|
||||||
|
namespace preview {
|
||||||
|
|
||||||
|
class PreviewOsdItem:public QImage
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
PreviewOsdItem(int width, int height);
|
||||||
|
|
||||||
|
void setLocation(double x, double y);
|
||||||
|
inline double xlocation() {return _xlocation;}
|
||||||
|
inline double ylocation() {return _ylocation;}
|
||||||
|
|
||||||
|
void setToolTip(QString text);
|
||||||
|
QString getToolTip(double x, double y, double scaling);
|
||||||
|
|
||||||
|
void drawCamera(CameraDefinition* camera);
|
||||||
|
|
||||||
|
private:
|
||||||
|
double _xlocation;
|
||||||
|
double _ylocation;
|
||||||
|
QString _tooltip;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // PREVIEWOSDITEM_H
|
|
@ -6,17 +6,26 @@
|
||||||
|
|
||||||
TARGET = paysages_render_preview
|
TARGET = paysages_render_preview
|
||||||
TEMPLATE = lib
|
TEMPLATE = lib
|
||||||
|
QT += gui widgets
|
||||||
|
|
||||||
DEFINES += PREVIEW_LIBRARY
|
DEFINES += PREVIEW_LIBRARY
|
||||||
|
|
||||||
include(../../common.pri)
|
include(../../common.pri)
|
||||||
|
|
||||||
SOURCES += Base2dPreviewRenderer.cpp \
|
SOURCES += Base2dPreviewRenderer.cpp \
|
||||||
AtmosphereColorPreviewRenderer.cpp
|
AtmosphereColorPreviewRenderer.cpp \
|
||||||
|
BasePreview.cpp \
|
||||||
|
PreviewOsd.cpp \
|
||||||
|
DrawingWidget.cpp \
|
||||||
|
PreviewOsdItem.cpp
|
||||||
|
|
||||||
HEADERS += Base2dPreviewRenderer.h\
|
HEADERS += Base2dPreviewRenderer.h\
|
||||||
preview_global.h \
|
preview_global.h \
|
||||||
AtmosphereColorPreviewRenderer.h
|
AtmosphereColorPreviewRenderer.h \
|
||||||
|
BasePreview.h \
|
||||||
|
PreviewOsd.h \
|
||||||
|
DrawingWidget.h \
|
||||||
|
PreviewOsdItem.h
|
||||||
|
|
||||||
unix:!symbian {
|
unix:!symbian {
|
||||||
maemo5 {
|
maemo5 {
|
||||||
|
|
|
@ -11,8 +11,14 @@
|
||||||
|
|
||||||
#include "software_global.h"
|
#include "software_global.h"
|
||||||
|
|
||||||
|
// TEMP
|
||||||
|
class Scenery;
|
||||||
|
|
||||||
namespace paysages {
|
namespace paysages {
|
||||||
namespace preview {
|
namespace preview {
|
||||||
|
class PreviewOsd;
|
||||||
|
class PreviewOsdItem;
|
||||||
|
class BasePreview;
|
||||||
class Base2dPreviewRenderer;
|
class Base2dPreviewRenderer;
|
||||||
class AtmosphereColorPreviewRenderer;
|
class AtmosphereColorPreviewRenderer;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue