Canvas preview widget is immediately sized (so that render dialog don't resize later)
This commit is contained in:
parent
2b135eedac
commit
8ef8b0386c
8 changed files with 42 additions and 47 deletions
|
@ -10,7 +10,6 @@ WidgetPreviewCanvas::WidgetPreviewCanvas(QWidget *parent) :
|
|||
QWidget(parent), canvas(NULL)
|
||||
{
|
||||
pixbuf = new QImage();
|
||||
inited = false;
|
||||
|
||||
startTimer(500);
|
||||
}
|
||||
|
@ -21,8 +20,12 @@ WidgetPreviewCanvas::~WidgetPreviewCanvas()
|
|||
}
|
||||
|
||||
void WidgetPreviewCanvas::setCanvas(const Canvas *canvas)
|
||||
{
|
||||
if (not this->canvas)
|
||||
{
|
||||
this->canvas = canvas;
|
||||
canvas->getPreview()->initLive(this);
|
||||
}
|
||||
}
|
||||
|
||||
void WidgetPreviewCanvas::paintEvent(QPaintEvent *)
|
||||
|
@ -58,12 +61,6 @@ void WidgetPreviewCanvas::timerEvent(QTimerEvent *)
|
|||
{
|
||||
if (canvas)
|
||||
{
|
||||
if (!inited)
|
||||
{
|
||||
canvas->getPreview()->initLive(this);
|
||||
inited = true;
|
||||
}
|
||||
|
||||
canvas->getPreview()->updateLive(this);
|
||||
update();
|
||||
}
|
||||
|
|
|
@ -21,6 +21,8 @@ public:
|
|||
|
||||
/*!
|
||||
* \brief 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);
|
||||
|
||||
|
@ -35,7 +37,6 @@ protected:
|
|||
private:
|
||||
QImage* pixbuf;
|
||||
const Canvas *canvas;
|
||||
bool inited;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -247,16 +247,16 @@ void FreeFormHelper::processExploreClicked()
|
|||
|
||||
void FreeFormHelper::processRenderClicked()
|
||||
{
|
||||
RenderConfig params(400, 300, 1, 3);
|
||||
|
||||
SoftwareCanvasRenderer renderer;
|
||||
renderer.setConfig(params);
|
||||
renderer.setScenery(DesktopScenery::getCurrent());
|
||||
|
||||
emit needAlterRenderer(&renderer);
|
||||
|
||||
DialogRender* dialog = new DialogRender(_form_widget, &renderer);
|
||||
RenderConfig params(400, 300, 1, 3);
|
||||
dialog->startRender(params);
|
||||
|
||||
delete dialog;
|
||||
DialogRender dialog(_form_widget, &renderer);
|
||||
dialog.startRender();
|
||||
}
|
||||
|
||||
void FreeFormHelper::processDecimalChange(double value)
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
#include <QComboBox>
|
||||
#include "tools.h"
|
||||
|
||||
#include "RenderConfig.h"
|
||||
#include "Scenery.h"
|
||||
#include "ColorProfile.h"
|
||||
#include "SoftwareCanvasRenderer.h"
|
||||
|
@ -27,22 +26,19 @@
|
|||
class RenderThread:public QThread
|
||||
{
|
||||
public:
|
||||
RenderThread(DialogRender* dialog, SoftwareCanvasRenderer* renderer, const RenderConfig ¶ms):QThread()
|
||||
RenderThread(DialogRender* dialog, SoftwareCanvasRenderer* renderer):QThread()
|
||||
{
|
||||
_dialog = dialog;
|
||||
_renderer = renderer;
|
||||
_params = params;
|
||||
}
|
||||
void run()
|
||||
{
|
||||
// FIXME Pass config to render
|
||||
_renderer->render();
|
||||
_dialog->tellRenderEnded();
|
||||
}
|
||||
private:
|
||||
DialogRender* _dialog;
|
||||
SoftwareCanvasRenderer* _renderer;
|
||||
RenderConfig _params;
|
||||
};
|
||||
|
||||
DialogRender::DialogRender(QWidget *parent, SoftwareCanvasRenderer* renderer):
|
||||
|
@ -98,7 +94,6 @@ DialogRender::DialogRender(QWidget *parent, SoftwareCanvasRenderer* renderer):
|
|||
_actions->layout()->addWidget(_save_button);
|
||||
|
||||
// Connections
|
||||
//connect(this, SIGNAL(renderSizeChanged(int, int)), this, SLOT(applyRenderSize(int, int)));
|
||||
connect(this, SIGNAL(progressChanged(double)), this, SLOT(applyProgress(double)));
|
||||
connect(this, SIGNAL(renderEnded()), this, SLOT(applyRenderEnded()));
|
||||
connect(_save_button, SIGNAL(clicked()), this, SLOT(saveRender()));
|
||||
|
@ -119,11 +114,6 @@ DialogRender::~DialogRender()
|
|||
delete pixbuf_lock;
|
||||
}
|
||||
|
||||
void DialogRender::tellRenderSize(int width, int height)
|
||||
{
|
||||
emit renderSizeChanged(width, height);
|
||||
}
|
||||
|
||||
void DialogRender::tellProgressChange(double value)
|
||||
{
|
||||
emit progressChanged(value);
|
||||
|
@ -134,13 +124,11 @@ void DialogRender::tellRenderEnded()
|
|||
emit renderEnded();
|
||||
}
|
||||
|
||||
void DialogRender::startRender(const RenderConfig ¶ms)
|
||||
void DialogRender::startRender()
|
||||
{
|
||||
_started = time(NULL);
|
||||
|
||||
canvas_renderer->setSize(params.width, params.height, params.antialias);
|
||||
|
||||
_render_thread = new RenderThread(this, canvas_renderer, params);
|
||||
_render_thread = new RenderThread(this, canvas_renderer);
|
||||
_render_thread->start();
|
||||
|
||||
exec();
|
||||
|
|
|
@ -21,10 +21,9 @@ public:
|
|||
explicit DialogRender(QWidget *parent, SoftwareCanvasRenderer* renderer);
|
||||
~DialogRender();
|
||||
|
||||
void tellRenderSize(int width, int height);
|
||||
void tellProgressChange(double value);
|
||||
void tellRenderEnded();
|
||||
void startRender(const RenderConfig ¶ms);
|
||||
void startRender();
|
||||
void loadLastRender();
|
||||
|
||||
QImage* pixbuf;
|
||||
|
@ -37,7 +36,6 @@ private slots:
|
|||
void toneMappingChanged();
|
||||
|
||||
signals:
|
||||
void renderSizeChanged(int width, int height);
|
||||
void progressChanged(double value);
|
||||
void renderEnded();
|
||||
|
||||
|
|
|
@ -103,15 +103,16 @@ void FormRender::startQuickRender()
|
|||
{
|
||||
delete _renderer;
|
||||
}
|
||||
|
||||
RenderConfig config(400, 300, 1, 3);
|
||||
|
||||
_renderer = new SoftwareCanvasRenderer();
|
||||
_renderer->setScenery(DesktopScenery::getCurrent());
|
||||
_renderer->setConfig(config);
|
||||
_renderer_inited = true;
|
||||
|
||||
DialogRender* dialog = new DialogRender(this, _renderer);
|
||||
RenderConfig params(400, 300, 1, 3);
|
||||
dialog->startRender(params);
|
||||
|
||||
delete dialog;
|
||||
DialogRender dialog(this, _renderer);
|
||||
dialog.startRender();
|
||||
}
|
||||
|
||||
void FormRender::startRender()
|
||||
|
@ -122,21 +123,18 @@ void FormRender::startRender()
|
|||
}
|
||||
_renderer = new SoftwareCanvasRenderer();
|
||||
_renderer->setScenery(DesktopScenery::getCurrent());
|
||||
_renderer->setConfig(_params);
|
||||
_renderer_inited = true;
|
||||
|
||||
DialogRender* dialog = new DialogRender(this, _renderer);
|
||||
dialog->startRender(_params);
|
||||
|
||||
delete dialog;
|
||||
DialogRender dialog(this, _renderer);
|
||||
dialog.startRender();
|
||||
}
|
||||
|
||||
void FormRender::showRender()
|
||||
{
|
||||
if (_renderer_inited)
|
||||
{
|
||||
DialogRender* dialog = new DialogRender(this, _renderer);
|
||||
dialog->loadLastRender();
|
||||
|
||||
delete dialog;
|
||||
DialogRender dialog(this, _renderer);
|
||||
dialog.loadLastRender();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include "ParallelWork.h"
|
||||
#include "CanvasPortion.h"
|
||||
#include "CanvasPixelShader.h"
|
||||
#include "RenderConfig.h"
|
||||
|
||||
SoftwareCanvasRenderer::SoftwareCanvasRenderer()
|
||||
{
|
||||
|
@ -34,6 +35,15 @@ SoftwareCanvasRenderer::~SoftwareCanvasRenderer()
|
|||
}
|
||||
}
|
||||
|
||||
void SoftwareCanvasRenderer::setConfig(const RenderConfig &config)
|
||||
{
|
||||
if (not started)
|
||||
{
|
||||
setSize(config.width, config.height, config.antialias);
|
||||
render_quality = config.quality;
|
||||
}
|
||||
}
|
||||
|
||||
void SoftwareCanvasRenderer::setSize(int width, int height, int samples)
|
||||
{
|
||||
if (not started)
|
||||
|
@ -44,9 +54,7 @@ void SoftwareCanvasRenderer::setSize(int width, int height, int samples)
|
|||
|
||||
void SoftwareCanvasRenderer::render()
|
||||
{
|
||||
// TEMP
|
||||
started = true;
|
||||
render_quality = 3;
|
||||
|
||||
render_camera->setRenderSize(canvas->getWidth(), canvas->getHeight());
|
||||
|
||||
|
|
|
@ -24,6 +24,11 @@ public:
|
|||
|
||||
inline const Canvas *getCanvas() const {return canvas;}
|
||||
|
||||
/**
|
||||
* Set the renderer configuration.
|
||||
*/
|
||||
void setConfig(const RenderConfig &config);
|
||||
|
||||
/**
|
||||
* @brief Set the rendering size in pixels.
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue