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);
|
renderer = new OpenGLRenderer(scenery);
|
||||||
|
|
||||||
render_preview_provider = new RenderPreviewProvider();
|
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");
|
qmlRegisterType<OpenGLView>("Paysages", 1, 0, "OpenGLView");
|
||||||
engine()->addImageProvider("renderpreviewprovider", render_preview_provider);
|
engine()->addImageProvider("renderpreviewprovider", render_preview_provider);
|
||||||
|
@ -58,7 +58,14 @@ void MainModelerWindow::keyReleaseEvent(QKeyEvent *event)
|
||||||
if (event->key() == Qt::Key_F5)
|
if (event->key() == Qt::Key_F5)
|
||||||
{
|
{
|
||||||
// Start render in a thread
|
// 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
|
// Resize preview
|
||||||
QSize preview_size = render_process->getPreviewSize();
|
QSize preview_size = render_process->getPreviewSize();
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#include "RenderProcess.h"
|
#include "RenderProcess.h"
|
||||||
|
|
||||||
#include <QSize>
|
#include <QSize>
|
||||||
|
#include "MainModelerWindow.h"
|
||||||
#include "SoftwareCanvasRenderer.h"
|
#include "SoftwareCanvasRenderer.h"
|
||||||
#include "RenderPreviewProvider.h"
|
#include "RenderPreviewProvider.h"
|
||||||
#include "RenderConfig.h"
|
#include "RenderConfig.h"
|
||||||
|
@ -22,8 +23,8 @@ private:
|
||||||
SoftwareCanvasRenderer *renderer;
|
SoftwareCanvasRenderer *renderer;
|
||||||
};
|
};
|
||||||
|
|
||||||
RenderProcess::RenderProcess(RenderPreviewProvider *destination):
|
RenderProcess::RenderProcess(MainModelerWindow *window, RenderPreviewProvider *destination):
|
||||||
destination(destination)
|
window(window), destination(destination)
|
||||||
{
|
{
|
||||||
rendering = false;
|
rendering = false;
|
||||||
renderer = NULL;
|
renderer = NULL;
|
||||||
|
@ -108,4 +109,13 @@ void RenderProcess::timerEvent(QTimerEvent *)
|
||||||
delete render_thread;
|
delete render_thread;
|
||||||
render_thread = NULL;
|
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
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
RenderProcess(RenderPreviewProvider *destination);
|
RenderProcess(MainModelerWindow *window, RenderPreviewProvider *destination);
|
||||||
virtual ~RenderProcess();
|
virtual ~RenderProcess();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -35,6 +35,7 @@ protected:
|
||||||
virtual void timerEvent(QTimerEvent *event) override;
|
virtual void timerEvent(QTimerEvent *event) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
MainModelerWindow *window;
|
||||||
RenderPreviewProvider *destination;
|
RenderPreviewProvider *destination;
|
||||||
bool rendering;
|
bool rendering;
|
||||||
SoftwareCanvasRenderer *renderer;
|
SoftwareCanvasRenderer *renderer;
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import QtQuick 2.2
|
import QtQuick 2.2
|
||||||
|
import QtQuick.Controls 1.2
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
width: 400
|
width: 400
|
||||||
|
@ -11,9 +12,11 @@ Rectangle {
|
||||||
|
|
||||||
onOpacityChanged: {
|
onOpacityChanged: {
|
||||||
refresh();
|
refresh();
|
||||||
|
render_progress.value = 0;
|
||||||
}
|
}
|
||||||
onVisibleChanged: {
|
onVisibleChanged: {
|
||||||
refresh();
|
refresh();
|
||||||
|
render_progress.value = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Image {
|
Image {
|
||||||
|
@ -26,6 +29,15 @@ Rectangle {
|
||||||
cache: false
|
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 {
|
Timer {
|
||||||
interval: 500
|
interval: 500
|
||||||
running: true
|
running: true
|
||||||
|
|
Loading…
Reference in a new issue