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);
|
||||
|
||||
render_preview_provider = new RenderPreviewProvider();
|
||||
render_process = new RenderProcess(this, render_preview_provider);
|
||||
|
||||
qmlRegisterType<OpenGLView>("Paysages", 1, 0, "OpenGLView");
|
||||
engine()->addImageProvider("renderpreviewprovider", render_preview_provider);
|
||||
|
@ -33,6 +32,8 @@ MainModelerWindow::MainModelerWindow()
|
|||
cameras = new ModelerCameras(this);
|
||||
atmosphere = new AtmosphereModeler(this);
|
||||
water = new WaterModeler(this);
|
||||
|
||||
render_process = new RenderProcess(this, render_preview_provider);
|
||||
}
|
||||
|
||||
MainModelerWindow::~MainModelerWindow()
|
||||
|
@ -53,6 +54,20 @@ QObject *MainModelerWindow::findQmlObject(const QString &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)
|
||||
{
|
||||
if (event->key() == Qt::Key_F5)
|
||||
|
@ -60,20 +75,16 @@ void MainModelerWindow::keyReleaseEvent(QKeyEvent *event)
|
|||
// Start render in a thread
|
||||
if (event->modifiers() & Qt::ControlModifier)
|
||||
{
|
||||
render_process->startRender(scenery, RenderConfig(1920, 1080, 4, 8));
|
||||
render_process->startFinalRender();
|
||||
}
|
||||
else
|
||||
{
|
||||
render_process->startRender(scenery, RenderConfig(400, 300, 1, 3));
|
||||
render_process->startQuickRender();
|
||||
}
|
||||
|
||||
// Resize preview
|
||||
QSize preview_size = render_process->getPreviewSize();
|
||||
findQmlObject("preview_image")->setProperty("width", preview_size.width());
|
||||
findQmlObject("preview_image")->setProperty("height", preview_size.height());
|
||||
|
||||
// Show render dialog
|
||||
rootObject()->setProperty("state", QString("Render Dialog"));
|
||||
}
|
||||
else if (event->key() == Qt::Key_F6)
|
||||
{
|
||||
render_process->showPreviousRender();
|
||||
}
|
||||
else if (event->key() == Qt::Key_Escape)
|
||||
{
|
||||
|
|
|
@ -15,7 +15,9 @@ public:
|
|||
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 OpenGLRenderer *getRenderer() const {return renderer;}
|
||||
|
|
|
@ -26,10 +26,16 @@ private:
|
|||
RenderProcess::RenderProcess(MainModelerWindow *window, RenderPreviewProvider *destination):
|
||||
window(window), destination(destination)
|
||||
{
|
||||
has_render = false;
|
||||
rendering = false;
|
||||
renderer = 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);
|
||||
}
|
||||
|
||||
|
@ -61,6 +67,7 @@ void RenderProcess::startRender(Scenery *scenery, const RenderConfig &config)
|
|||
return;
|
||||
}
|
||||
|
||||
has_render = true;
|
||||
rendering = true;
|
||||
|
||||
if (renderer)
|
||||
|
@ -74,8 +81,38 @@ void RenderProcess::startRender(Scenery *scenery, const RenderConfig &config)
|
|||
|
||||
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->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()
|
||||
|
@ -112,10 +149,6 @@ void RenderProcess::timerEvent(QTimerEvent *)
|
|||
|
||||
if (renderer)
|
||||
{
|
||||
QObject *progress = window->findQmlObject("render_progress");
|
||||
if (progress)
|
||||
{
|
||||
progress->setProperty("value", renderer->getProgress());
|
||||
}
|
||||
window->setQmlProperty("render_progress", "value", renderer->getProgress());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,12 +31,31 @@ public:
|
|||
*/
|
||||
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:
|
||||
virtual void timerEvent(QTimerEvent *event) override;
|
||||
|
||||
private:
|
||||
MainModelerWindow *window;
|
||||
RenderPreviewProvider *destination;
|
||||
bool has_render;
|
||||
bool rendering;
|
||||
SoftwareCanvasRenderer *renderer;
|
||||
Thread *render_thread;
|
||||
|
|
|
@ -7,6 +7,7 @@ Item {
|
|||
property bool hovered: false
|
||||
property string helptext
|
||||
property string hovertext
|
||||
signal clicked
|
||||
|
||||
width: image.width + 10
|
||||
height: image.height + 10
|
||||
|
@ -82,6 +83,7 @@ Item {
|
|||
{
|
||||
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 {
|
||||
id: camera_choice
|
||||
anchors.bottom: main_ui.bottom
|
||||
|
@ -140,6 +153,15 @@ OpenGLView {
|
|||
opacity: 1
|
||||
}
|
||||
},
|
||||
State {
|
||||
name: "Render Mode"
|
||||
when: tool_render.selected
|
||||
|
||||
PropertyChanges {
|
||||
target: render_toolbar
|
||||
opacity: 1
|
||||
}
|
||||
},
|
||||
State {
|
||||
name: "Render Dialog"
|
||||
when: tool_display.selected
|
||||
|
|
Loading…
Reference in a new issue