From 8c2091de03d284cb347874f4efae22a59b7bc32c Mon Sep 17 00:00:00 2001 From: Michael Lemaire Date: Wed, 22 Jul 2015 19:23:22 +0200 Subject: [PATCH] Added render progress bar --- .../modeler/quickapp/MainModelerWindow.cpp | 11 +++++++++-- src/interface/modeler/quickapp/RenderProcess.cpp | 14 ++++++++++++-- src/interface/modeler/quickapp/RenderProcess.h | 3 ++- .../modeler/quickapp/qml/RenderDialog.qml | 12 ++++++++++++ 4 files changed, 35 insertions(+), 5 deletions(-) diff --git a/src/interface/modeler/quickapp/MainModelerWindow.cpp b/src/interface/modeler/quickapp/MainModelerWindow.cpp index a14fcfb..2d15232 100644 --- a/src/interface/modeler/quickapp/MainModelerWindow.cpp +++ b/src/interface/modeler/quickapp/MainModelerWindow.cpp @@ -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("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(); diff --git a/src/interface/modeler/quickapp/RenderProcess.cpp b/src/interface/modeler/quickapp/RenderProcess.cpp index 4a8589a..d0c0c0f 100644 --- a/src/interface/modeler/quickapp/RenderProcess.cpp +++ b/src/interface/modeler/quickapp/RenderProcess.cpp @@ -1,6 +1,7 @@ #include "RenderProcess.h" #include +#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()); + } + } } diff --git a/src/interface/modeler/quickapp/RenderProcess.h b/src/interface/modeler/quickapp/RenderProcess.h index 366eb51..cbb916a 100644 --- a/src/interface/modeler/quickapp/RenderProcess.h +++ b/src/interface/modeler/quickapp/RenderProcess.h @@ -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; diff --git a/src/interface/modeler/quickapp/qml/RenderDialog.qml b/src/interface/modeler/quickapp/qml/RenderDialog.qml index f92142a..e18de6e 100644 --- a/src/interface/modeler/quickapp/qml/RenderDialog.qml +++ b/src/interface/modeler/quickapp/qml/RenderDialog.qml @@ -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