diff --git a/src/interface/modeler/quickapp/MainModelerWindow.cpp b/src/interface/modeler/quickapp/MainModelerWindow.cpp index c21b459..a14fcfb 100644 --- a/src/interface/modeler/quickapp/MainModelerWindow.cpp +++ b/src/interface/modeler/quickapp/MainModelerWindow.cpp @@ -11,6 +11,7 @@ #include "RenderConfig.h" #include +#include MainModelerWindow::MainModelerWindow() { @@ -73,4 +74,11 @@ void MainModelerWindow::keyReleaseEvent(QKeyEvent *event) rootObject()->setProperty("state", QString("Init")); } + else if (event->key() == Qt::Key_Q) + { + if (event->modifiers() & Qt::ControlModifier) + { + QGuiApplication::instance()->exit(); + } + } } diff --git a/src/interface/modeler/quickapp/ModelerCameras.cpp b/src/interface/modeler/quickapp/ModelerCameras.cpp index 8e4104f..3b87f19 100644 --- a/src/interface/modeler/quickapp/ModelerCameras.cpp +++ b/src/interface/modeler/quickapp/ModelerCameras.cpp @@ -35,12 +35,24 @@ ModelerCameras::~ModelerCameras() void ModelerCameras::processZoom(double value) { active->strafeForward(value); + + validate(); } void ModelerCameras::processScroll(double xvalue, double yvalue) { active->strafeRight(xvalue); active->strafeUp(yvalue); + + validate(); +} + +void ModelerCameras::processPanning(double xvalue, double yvalue) +{ + active->rotateYaw(xvalue); + active->rotatePitch(yvalue); + + validate(); } void ModelerCameras::timerEvent(QTimerEvent *) @@ -51,6 +63,13 @@ void ModelerCameras::timerEvent(QTimerEvent *) renderer->setCamera(current); } +void ModelerCameras::validate() +{ + if (active == render) { + parent->getScenery()->setCamera(active); + } +} + void ModelerCameras::changeActiveCamera(const QString &name) { if (name == "Render camera") diff --git a/src/interface/modeler/quickapp/ModelerCameras.h b/src/interface/modeler/quickapp/ModelerCameras.h index 5621203..40d851b 100644 --- a/src/interface/modeler/quickapp/ModelerCameras.h +++ b/src/interface/modeler/quickapp/ModelerCameras.h @@ -29,9 +29,19 @@ public: */ void processScroll(double xvalue, double yvalue); + /** + * Process a panning rotation. + */ + void processPanning(double xvalue, double yvalue); + protected: void timerEvent(QTimerEvent *event); + /** + * Validate current camera, pushing it to rendered scenery if needed. + */ + void validate(); + public slots: void changeActiveCamera(const QString &name); diff --git a/src/interface/modeler/quickapp/OpenGLView.cpp b/src/interface/modeler/quickapp/OpenGLView.cpp index ad3a12b..1b94a41 100644 --- a/src/interface/modeler/quickapp/OpenGLView.cpp +++ b/src/interface/modeler/quickapp/OpenGLView.cpp @@ -76,10 +76,14 @@ void OpenGLView::mouseReleaseEvent(QMouseEvent *) void OpenGLView::mouseMoveEvent(QMouseEvent *event) { QPointF diff = event->windowPos() - mouse_pos; - if (mouse_button == Qt::MidButton) + if (mouse_button == Qt::LeftButton) { window->getCamera()->processScroll(-0.1 * diff.x(), 0.1 * diff.y()); } + else if (mouse_button == Qt::RightButton) + { + window->getCamera()->processPanning(0.006 * diff.x(), 0.002 * diff.y()); + } mouse_pos = event->windowPos(); } diff --git a/src/interface/modeler/quickapp/RenderPreviewProvider.cpp b/src/interface/modeler/quickapp/RenderPreviewProvider.cpp index b6b5151..473977c 100644 --- a/src/interface/modeler/quickapp/RenderPreviewProvider.cpp +++ b/src/interface/modeler/quickapp/RenderPreviewProvider.cpp @@ -70,8 +70,8 @@ void RenderPreviewProvider::canvasResized(int width, int height) { delete pixbuf; pixbuf = new QImage(width, height, QImage::Format_ARGB32); - pixbuf->fill(Qt::black); } + pixbuf->fill(Qt::black); } void RenderPreviewProvider::canvasCleared(const Color &col) diff --git a/src/interface/modeler/quickapp/qml/RenderDialog.qml b/src/interface/modeler/quickapp/qml/RenderDialog.qml index 7f465ad..f92142a 100644 --- a/src/interface/modeler/quickapp/qml/RenderDialog.qml +++ b/src/interface/modeler/quickapp/qml/RenderDialog.qml @@ -4,6 +4,18 @@ Rectangle { width: 400 height: 300 + function refresh() { + preview_image.source = ""; + preview_image.source = "image://renderpreviewprovider/live"; + } + + onOpacityChanged: { + refresh(); + } + onVisibleChanged: { + refresh(); + } + Image { id: preview_image objectName: "preview_image" @@ -20,8 +32,7 @@ Rectangle { repeat: true onTriggered: { - preview_image.source = ""; - preview_image.source = "image://renderpreviewprovider/live"; + refresh(); } } }