Added rendered picture saving ui

This commit is contained in:
Michaël Lemaire 2015-09-15 01:26:05 +02:00
parent 20c03f84b7
commit 4fb7078815
5 changed files with 60 additions and 5 deletions

1
TODO
View file

@ -5,6 +5,7 @@ Technlology Preview 2 :
- Add clouds to OpenGL with 3d textures.
- Fix potential holes in land rendering (OpenGL and software).
- Fix polygon culling near the camera in low-res renders (automatic tessellation ?).
- Fix OpenGL water renderer sometimes not initializing correctly (value error in OpenGL).
Technology Preview 3 :
- Alter aerial perspective using estimation of the amount of light left after cloud layers traversal.

View file

@ -27,7 +27,7 @@ MainModelerWindow::MainModelerWindow()
qmlRegisterType<OpenGLView>("Paysages", 1, 0, "OpenGLView");
engine()->addImageProvider("renderpreviewprovider", render_preview_provider);
setMinimumSize(QSize(1000, 800));
setMinimumSize(QSize(1280, 720));
setTitle(QObject::tr("Paysages 3D"));
setResizeMode(QQuickView::SizeRootObjectToView);
setSource(QUrl("qrc:///main.qml"));

View file

@ -61,6 +61,11 @@ RenderProcess::RenderProcess(MainModelerWindow *window, RenderPreviewProvider *d
connect(button_cancel, SIGNAL(clicked()), this, SLOT(stopRender()));
}
QObject *dialog_save = window->findQmlObject("render_save_dialog");
if (dialog_save) {
connect(dialog_save, SIGNAL(saveRequired(QString)), this, SLOT(savePicture(QString)));
}
startTimer(100);
}
@ -93,10 +98,8 @@ void RenderProcess::startRender(Scenery *scenery, const RenderConfig &config)
}
// Enable "show last render" button
QObject *button_show = window->findQmlObject("tool_render_show");
if (button_show) {
button_show->setProperty("enabled", true);
}
window->setQmlProperty("tool_render_show", "enabled", true);
window->setQmlProperty("render_dialog", "rendering", true);
has_render = true;
rendering = true;
@ -169,6 +172,11 @@ void RenderProcess::stopRender()
}
}
void RenderProcess::savePicture(QString path)
{
renderer->saveToDisk(path.replace("file://", "").toStdString());
}
const QSize RenderProcess::getPreviewSize()
{
if (renderer)
@ -192,6 +200,7 @@ void RenderProcess::timerEvent(QTimerEvent *)
delete render_thread;
render_thread = NULL;
window->setQmlProperty("render_dialog", "rendering", false);
window->getRenderer()->resume();
}

View file

@ -54,6 +54,11 @@ public slots:
*/
void stopRender();
/**
* Save the current picture to a given path on disk.
*/
void savePicture(QString path);
protected:
virtual void timerEvent(QTimerEvent *event) override;

View file

@ -1,11 +1,15 @@
import QtQuick 2.2
import QtQuick.Controls 1.2
import QtQuick.Dialogs 1.0
import QtGraphicalEffects 1.0
BaseRectangle {
id: render_dialog
objectName: "render_dialog"
width: 400
height: 300
color: "#222429"
property bool rendering: false
function refresh() {
preview_image.source = "";
@ -20,6 +24,41 @@ BaseRectangle {
}
}
Rectangle {
width: parent.width
height: 80
anchors.top: parent.top
anchors.left: parent.left
color: "#667080"
}
FileDialog {
id: render_save_dialog
objectName: "render_save_dialog"
title: "Choose a file to save the rendered image"
folder: shortcuts.documents
selectExisting: false
signal saveRequired(string filepath);
onAccepted: saveRequired(render_save_dialog.fileUrls[0].toString())
}
ToolbarButton {
id: render_save
objectName: "render_save"
picture: "images/icon_file_save.png"
anchors.top: parent.top
anchors.left: parent.left
anchors.margins: 10
enabled: !render_dialog.rendering
checkable: false
image_width: 48
image_height: 48
onClicked: render_save_dialog.open()
}
ToolbarButton {
id: render_cancel
objectName: "render_cancel"
@ -53,6 +92,7 @@ BaseRectangle {
ProgressBar {
id: render_progress
objectName: "render_progress"
visible: render_dialog.rendering
width: parent.width * 0.8
anchors.top: preview_image.bottom
anchors.horizontalCenter: preview_image.horizontalCenter