Added shortcut to show previous render again
This commit is contained in:
parent
efcbeecf3e
commit
e84698dbb3
6 changed files with 106 additions and 17 deletions
|
@ -20,7 +20,6 @@ MainModelerWindow::MainModelerWindow()
|
||||||
renderer = new OpenGLRenderer(scenery);
|
renderer = new OpenGLRenderer(scenery);
|
||||||
|
|
||||||
render_preview_provider = new RenderPreviewProvider();
|
render_preview_provider = new RenderPreviewProvider();
|
||||||
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);
|
||||||
|
@ -33,6 +32,8 @@ MainModelerWindow::MainModelerWindow()
|
||||||
cameras = new ModelerCameras(this);
|
cameras = new ModelerCameras(this);
|
||||||
atmosphere = new AtmosphereModeler(this);
|
atmosphere = new AtmosphereModeler(this);
|
||||||
water = new WaterModeler(this);
|
water = new WaterModeler(this);
|
||||||
|
|
||||||
|
render_process = new RenderProcess(this, render_preview_provider);
|
||||||
}
|
}
|
||||||
|
|
||||||
MainModelerWindow::~MainModelerWindow()
|
MainModelerWindow::~MainModelerWindow()
|
||||||
|
@ -53,6 +54,20 @@ QObject *MainModelerWindow::findQmlObject(const QString &objectName)
|
||||||
return rootObject()->findChild<QObject *>(objectName);
|
return rootObject()->findChild<QObject *>(objectName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainModelerWindow::setQmlProperty(const QString &objectName, const QString &propertyName, const QVariant &value)
|
||||||
|
{
|
||||||
|
QObject *item = findQmlObject(objectName);
|
||||||
|
if (item)
|
||||||
|
{
|
||||||
|
item->setProperty(propertyName.toLocal8Bit(), value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainModelerWindow::setState(const QString &stateName)
|
||||||
|
{
|
||||||
|
rootObject()->setProperty("state", stateName);
|
||||||
|
}
|
||||||
|
|
||||||
void MainModelerWindow::keyReleaseEvent(QKeyEvent *event)
|
void MainModelerWindow::keyReleaseEvent(QKeyEvent *event)
|
||||||
{
|
{
|
||||||
if (event->key() == Qt::Key_F5)
|
if (event->key() == Qt::Key_F5)
|
||||||
|
@ -60,20 +75,16 @@ void MainModelerWindow::keyReleaseEvent(QKeyEvent *event)
|
||||||
// Start render in a thread
|
// Start render in a thread
|
||||||
if (event->modifiers() & Qt::ControlModifier)
|
if (event->modifiers() & Qt::ControlModifier)
|
||||||
{
|
{
|
||||||
render_process->startRender(scenery, RenderConfig(1920, 1080, 4, 8));
|
render_process->startFinalRender();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
render_process->startRender(scenery, RenderConfig(400, 300, 1, 3));
|
render_process->startQuickRender();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// Resize preview
|
else if (event->key() == Qt::Key_F6)
|
||||||
QSize preview_size = render_process->getPreviewSize();
|
{
|
||||||
findQmlObject("preview_image")->setProperty("width", preview_size.width());
|
render_process->showPreviousRender();
|
||||||
findQmlObject("preview_image")->setProperty("height", preview_size.height());
|
|
||||||
|
|
||||||
// Show render dialog
|
|
||||||
rootObject()->setProperty("state", QString("Render Dialog"));
|
|
||||||
}
|
}
|
||||||
else if (event->key() == Qt::Key_Escape)
|
else if (event->key() == Qt::Key_Escape)
|
||||||
{
|
{
|
||||||
|
|
|
@ -15,7 +15,9 @@ public:
|
||||||
MainModelerWindow();
|
MainModelerWindow();
|
||||||
virtual ~MainModelerWindow();
|
virtual ~MainModelerWindow();
|
||||||
|
|
||||||
QObject *findQmlObject(const QString& objectName);
|
QObject *findQmlObject(const QString &objectName);
|
||||||
|
void setQmlProperty(const QString &objectName, const QString &propertyName, const QVariant &value);
|
||||||
|
void setState(const QString &stateName);
|
||||||
|
|
||||||
inline Scenery *getScenery() const {return scenery;}
|
inline Scenery *getScenery() const {return scenery;}
|
||||||
inline OpenGLRenderer *getRenderer() const {return renderer;}
|
inline OpenGLRenderer *getRenderer() const {return renderer;}
|
||||||
|
|
|
@ -26,10 +26,16 @@ private:
|
||||||
RenderProcess::RenderProcess(MainModelerWindow *window, RenderPreviewProvider *destination):
|
RenderProcess::RenderProcess(MainModelerWindow *window, RenderPreviewProvider *destination):
|
||||||
window(window), destination(destination)
|
window(window), destination(destination)
|
||||||
{
|
{
|
||||||
|
has_render = false;
|
||||||
rendering = false;
|
rendering = false;
|
||||||
renderer = NULL;
|
renderer = NULL;
|
||||||
render_thread = NULL;
|
render_thread = NULL;
|
||||||
|
|
||||||
|
QObject *button_quick = window->findQmlObject("tool_render_quick");
|
||||||
|
if (button_quick) {
|
||||||
|
connect(button_quick, SIGNAL(clicked()), this, SLOT(startQuickRender()));
|
||||||
|
}
|
||||||
|
|
||||||
startTimer(100);
|
startTimer(100);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,6 +67,7 @@ void RenderProcess::startRender(Scenery *scenery, const RenderConfig &config)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
has_render = true;
|
||||||
rendering = true;
|
rendering = true;
|
||||||
|
|
||||||
if (renderer)
|
if (renderer)
|
||||||
|
@ -74,8 +81,38 @@ void RenderProcess::startRender(Scenery *scenery, const RenderConfig &config)
|
||||||
|
|
||||||
destination->setCanvas(renderer->getCanvas());
|
destination->setCanvas(renderer->getCanvas());
|
||||||
|
|
||||||
|
// Resize preview
|
||||||
|
QSize preview_size = getPreviewSize();
|
||||||
|
QObject *image = window->findQmlObject("preview_image");
|
||||||
|
if (image) {
|
||||||
|
image->setProperty("width", preview_size.width());
|
||||||
|
image->setProperty("height", preview_size.height());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Start render thread
|
||||||
render_thread = new RenderThread(renderer);
|
render_thread = new RenderThread(renderer);
|
||||||
render_thread->start();
|
render_thread->start();
|
||||||
|
|
||||||
|
// Show render dialog
|
||||||
|
window->setState("Render Dialog");
|
||||||
|
}
|
||||||
|
|
||||||
|
void RenderProcess::startQuickRender()
|
||||||
|
{
|
||||||
|
startRender(window->getScenery(), RenderConfig(400, 300, 1, 3));
|
||||||
|
}
|
||||||
|
|
||||||
|
void RenderProcess::startFinalRender()
|
||||||
|
{
|
||||||
|
startRender(window->getScenery(), RenderConfig(1920, 1080, 4, 8));
|
||||||
|
}
|
||||||
|
|
||||||
|
void RenderProcess::showPreviousRender()
|
||||||
|
{
|
||||||
|
if (not rendering and has_render)
|
||||||
|
{
|
||||||
|
window->setState("Render Dialog");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderProcess::stopRender()
|
void RenderProcess::stopRender()
|
||||||
|
@ -112,10 +149,6 @@ void RenderProcess::timerEvent(QTimerEvent *)
|
||||||
|
|
||||||
if (renderer)
|
if (renderer)
|
||||||
{
|
{
|
||||||
QObject *progress = window->findQmlObject("render_progress");
|
window->setQmlProperty("render_progress", "value", renderer->getProgress());
|
||||||
if (progress)
|
|
||||||
{
|
|
||||||
progress->setProperty("value", renderer->getProgress());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,12 +31,31 @@ public:
|
||||||
*/
|
*/
|
||||||
const QSize getPreviewSize();
|
const QSize getPreviewSize();
|
||||||
|
|
||||||
|
inline bool isRendering() const {return rendering;}
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
/**
|
||||||
|
* Start a quick render.
|
||||||
|
*/
|
||||||
|
void startQuickRender();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Start a final render.
|
||||||
|
*/
|
||||||
|
void startFinalRender();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the previous rendering.
|
||||||
|
*/
|
||||||
|
void showPreviousRender();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void timerEvent(QTimerEvent *event) override;
|
virtual void timerEvent(QTimerEvent *event) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
MainModelerWindow *window;
|
MainModelerWindow *window;
|
||||||
RenderPreviewProvider *destination;
|
RenderPreviewProvider *destination;
|
||||||
|
bool has_render;
|
||||||
bool rendering;
|
bool rendering;
|
||||||
SoftwareCanvasRenderer *renderer;
|
SoftwareCanvasRenderer *renderer;
|
||||||
Thread *render_thread;
|
Thread *render_thread;
|
||||||
|
|
|
@ -7,6 +7,7 @@ Item {
|
||||||
property bool hovered: false
|
property bool hovered: false
|
||||||
property string helptext
|
property string helptext
|
||||||
property string hovertext
|
property string hovertext
|
||||||
|
signal clicked
|
||||||
|
|
||||||
width: image.width + 10
|
width: image.width + 10
|
||||||
height: image.height + 10
|
height: image.height + 10
|
||||||
|
@ -82,6 +83,7 @@ Item {
|
||||||
{
|
{
|
||||||
tooltip_widget.helptext = "";
|
tooltip_widget.helptext = "";
|
||||||
}
|
}
|
||||||
|
parent.clicked();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,6 +91,19 @@ OpenGLView {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Toolbar {
|
||||||
|
id: render_toolbar
|
||||||
|
opacity: 0
|
||||||
|
anchors.left: primary_toolbar.right
|
||||||
|
|
||||||
|
ToolbarButton {
|
||||||
|
id: tool_render_quick
|
||||||
|
objectName: "tool_render_quick"
|
||||||
|
picture: "images/tab_render.png"
|
||||||
|
hovertext: qsTr("Start a quick render")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
CameraChoice {
|
CameraChoice {
|
||||||
id: camera_choice
|
id: camera_choice
|
||||||
anchors.bottom: main_ui.bottom
|
anchors.bottom: main_ui.bottom
|
||||||
|
@ -140,6 +153,15 @@ OpenGLView {
|
||||||
opacity: 1
|
opacity: 1
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
State {
|
||||||
|
name: "Render Mode"
|
||||||
|
when: tool_render.selected
|
||||||
|
|
||||||
|
PropertyChanges {
|
||||||
|
target: render_toolbar
|
||||||
|
opacity: 1
|
||||||
|
}
|
||||||
|
},
|
||||||
State {
|
State {
|
||||||
name: "Render Dialog"
|
name: "Render Dialog"
|
||||||
when: tool_display.selected
|
when: tool_display.selected
|
||||||
|
|
Loading…
Reference in a new issue