Restored tone mapping control of canvas preview

This commit is contained in:
Michaël Lemaire 2014-08-20 14:31:28 +02:00
parent 8ef8b0386c
commit 18a669675f
5 changed files with 29 additions and 5 deletions

View file

@ -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);

View file

@ -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:

View file

@ -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()

View file

@ -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();

View file

@ -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);