From 18a669675f8af7070af87108a7ce34014fdf96e6 Mon Sep 17 00:00:00 2001 From: Michael Lemaire Date: Wed, 20 Aug 2014 14:31:28 +0200 Subject: [PATCH] Restored tone mapping control of canvas preview --- src/interface/desktop/WidgetPreviewCanvas.cpp | 10 ++++++++++ src/interface/desktop/WidgetPreviewCanvas.h | 13 +++++++++---- src/interface/desktop/dialogrender.cpp | 4 +++- src/render/software/CanvasPreview.cpp | 6 ++++++ src/render/software/CanvasPreview.h | 1 + 5 files changed, 29 insertions(+), 5 deletions(-) diff --git a/src/interface/desktop/WidgetPreviewCanvas.cpp b/src/interface/desktop/WidgetPreviewCanvas.cpp index 74b3fd4..f52e72c 100644 --- a/src/interface/desktop/WidgetPreviewCanvas.cpp +++ b/src/interface/desktop/WidgetPreviewCanvas.cpp @@ -28,6 +28,16 @@ void WidgetPreviewCanvas::setCanvas(const Canvas *canvas) } } +void WidgetPreviewCanvas::setToneMapping(const ColorProfile &profile) +{ + if (canvas) + { + canvas->getPreview()->setToneMapping(profile); + canvas->getPreview()->updateLive(this); + update(); + } +} + void WidgetPreviewCanvas::paintEvent(QPaintEvent *) { QPainter painter(this); diff --git a/src/interface/desktop/WidgetPreviewCanvas.h b/src/interface/desktop/WidgetPreviewCanvas.h index 097ce57..3933d55 100644 --- a/src/interface/desktop/WidgetPreviewCanvas.h +++ b/src/interface/desktop/WidgetPreviewCanvas.h @@ -9,8 +9,8 @@ namespace paysages { namespace desktop { -/*! - * \brief Widget to display a live-updated preview of a Canvas software rendering. +/** + * Widget to display a live-updated preview of a Canvas software rendering. */ class WidgetPreviewCanvas : public QWidget, public CanvasLiveClient { @@ -19,13 +19,18 @@ public: explicit WidgetPreviewCanvas(QWidget *parent = 0); virtual ~WidgetPreviewCanvas(); - /*! - * \brief Set the canvas to watch and display, null to stop watching. + /** + * 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: diff --git a/src/interface/desktop/dialogrender.cpp b/src/interface/desktop/dialogrender.cpp index 63344f4..636fd81 100644 --- a/src/interface/desktop/dialogrender.cpp +++ b/src/interface/desktop/dialogrender.cpp @@ -99,6 +99,8 @@ DialogRender::DialogRender(QWidget *parent, SoftwareCanvasRenderer* renderer): 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() @@ -166,7 +168,7 @@ void DialogRender::saveRender() void DialogRender::toneMappingChanged() { ColorProfile profile((ColorProfile::ToneMappingOperator)_tonemapping_control->currentIndex(), ((double)_exposure_control->value()) * 0.01); - //canvas_renderer->render_area->setToneMapping(profile); + canvas_preview->setToneMapping(profile); } void DialogRender::loadLastRender() diff --git a/src/render/software/CanvasPreview.cpp b/src/render/software/CanvasPreview.cpp index 5012911..0a31e26 100644 --- a/src/render/software/CanvasPreview.cpp +++ b/src/render/software/CanvasPreview.cpp @@ -72,6 +72,12 @@ void CanvasPreview::setSize(int real_width, int real_height, int preview_width, reset(); } +void CanvasPreview::setToneMapping(const ColorProfile &profile) +{ + profile.copy(this->profile); + setAllDirty(); +} + void CanvasPreview::reset() { lock->acquire(); diff --git a/src/render/software/CanvasPreview.h b/src/render/software/CanvasPreview.h index dbcc0e4..94dd0ce 100644 --- a/src/render/software/CanvasPreview.h +++ b/src/render/software/CanvasPreview.h @@ -21,6 +21,7 @@ public: const Color &getFinalPixel(int x, int y) const; void setSize(int real_width, int real_height, int preview_width, int preview_height); + void setToneMapping(const ColorProfile &profile); void reset(); void initLive(CanvasLiveClient *client);