Added render progress bar
This commit is contained in:
parent
2de920e091
commit
8c2091de03
4 changed files with 35 additions and 5 deletions
|
@ -20,7 +20,7 @@ MainModelerWindow::MainModelerWindow()
|
|||
renderer = new OpenGLRenderer(scenery);
|
||||
|
||||
render_preview_provider = new RenderPreviewProvider();
|
||||
render_process = new RenderProcess(render_preview_provider);
|
||||
render_process = new RenderProcess(this, render_preview_provider);
|
||||
|
||||
qmlRegisterType<OpenGLView>("Paysages", 1, 0, "OpenGLView");
|
||||
engine()->addImageProvider("renderpreviewprovider", render_preview_provider);
|
||||
|
@ -58,7 +58,14 @@ void MainModelerWindow::keyReleaseEvent(QKeyEvent *event)
|
|||
if (event->key() == Qt::Key_F5)
|
||||
{
|
||||
// Start render in a thread
|
||||
render_process->startRender(scenery, RenderConfig(400, 300, 1, 3));
|
||||
if (event->modifiers() & Qt::ControlModifier)
|
||||
{
|
||||
render_process->startRender(scenery, RenderConfig(1920, 1080, 4, 8));
|
||||
}
|
||||
else
|
||||
{
|
||||
render_process->startRender(scenery, RenderConfig(400, 300, 1, 3));
|
||||
}
|
||||
|
||||
// Resize preview
|
||||
QSize preview_size = render_process->getPreviewSize();
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include "RenderProcess.h"
|
||||
|
||||
#include <QSize>
|
||||
#include "MainModelerWindow.h"
|
||||
#include "SoftwareCanvasRenderer.h"
|
||||
#include "RenderPreviewProvider.h"
|
||||
#include "RenderConfig.h"
|
||||
|
@ -22,8 +23,8 @@ private:
|
|||
SoftwareCanvasRenderer *renderer;
|
||||
};
|
||||
|
||||
RenderProcess::RenderProcess(RenderPreviewProvider *destination):
|
||||
destination(destination)
|
||||
RenderProcess::RenderProcess(MainModelerWindow *window, RenderPreviewProvider *destination):
|
||||
window(window), destination(destination)
|
||||
{
|
||||
rendering = false;
|
||||
renderer = NULL;
|
||||
|
@ -108,4 +109,13 @@ void RenderProcess::timerEvent(QTimerEvent *)
|
|||
delete render_thread;
|
||||
render_thread = NULL;
|
||||
}
|
||||
|
||||
if (renderer)
|
||||
{
|
||||
QObject *progress = window->findQmlObject("render_progress");
|
||||
if (progress)
|
||||
{
|
||||
progress->setProperty("value", renderer->getProgress());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ class RenderProcess: public QObject
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
RenderProcess(RenderPreviewProvider *destination);
|
||||
RenderProcess(MainModelerWindow *window, RenderPreviewProvider *destination);
|
||||
virtual ~RenderProcess();
|
||||
|
||||
/**
|
||||
|
@ -35,6 +35,7 @@ protected:
|
|||
virtual void timerEvent(QTimerEvent *event) override;
|
||||
|
||||
private:
|
||||
MainModelerWindow *window;
|
||||
RenderPreviewProvider *destination;
|
||||
bool rendering;
|
||||
SoftwareCanvasRenderer *renderer;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import QtQuick 2.2
|
||||
import QtQuick.Controls 1.2
|
||||
|
||||
Rectangle {
|
||||
width: 400
|
||||
|
@ -11,9 +12,11 @@ Rectangle {
|
|||
|
||||
onOpacityChanged: {
|
||||
refresh();
|
||||
render_progress.value = 0;
|
||||
}
|
||||
onVisibleChanged: {
|
||||
refresh();
|
||||
render_progress.value = 0;
|
||||
}
|
||||
|
||||
Image {
|
||||
|
@ -26,6 +29,15 @@ Rectangle {
|
|||
cache: false
|
||||
}
|
||||
|
||||
ProgressBar {
|
||||
id: render_progress
|
||||
objectName: "render_progress"
|
||||
width: parent.width * 0.8
|
||||
anchors.top: preview_image.bottom
|
||||
anchors.horizontalCenter: preview_image.horizontalCenter
|
||||
anchors.topMargin: 20
|
||||
}
|
||||
|
||||
Timer {
|
||||
interval: 500
|
||||
running: true
|
||||
|
|
Loading…
Reference in a new issue