Improved basic quick ui usability
This commit is contained in:
parent
404b54a865
commit
2c877953e7
6 changed files with 56 additions and 4 deletions
|
@ -11,6 +11,7 @@
|
||||||
#include "RenderConfig.h"
|
#include "RenderConfig.h"
|
||||||
|
|
||||||
#include <QQmlEngine>
|
#include <QQmlEngine>
|
||||||
|
#include <QGuiApplication>
|
||||||
|
|
||||||
MainModelerWindow::MainModelerWindow()
|
MainModelerWindow::MainModelerWindow()
|
||||||
{
|
{
|
||||||
|
@ -73,4 +74,11 @@ void MainModelerWindow::keyReleaseEvent(QKeyEvent *event)
|
||||||
|
|
||||||
rootObject()->setProperty("state", QString("Init"));
|
rootObject()->setProperty("state", QString("Init"));
|
||||||
}
|
}
|
||||||
|
else if (event->key() == Qt::Key_Q)
|
||||||
|
{
|
||||||
|
if (event->modifiers() & Qt::ControlModifier)
|
||||||
|
{
|
||||||
|
QGuiApplication::instance()->exit();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,12 +35,24 @@ ModelerCameras::~ModelerCameras()
|
||||||
void ModelerCameras::processZoom(double value)
|
void ModelerCameras::processZoom(double value)
|
||||||
{
|
{
|
||||||
active->strafeForward(value);
|
active->strafeForward(value);
|
||||||
|
|
||||||
|
validate();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModelerCameras::processScroll(double xvalue, double yvalue)
|
void ModelerCameras::processScroll(double xvalue, double yvalue)
|
||||||
{
|
{
|
||||||
active->strafeRight(xvalue);
|
active->strafeRight(xvalue);
|
||||||
active->strafeUp(yvalue);
|
active->strafeUp(yvalue);
|
||||||
|
|
||||||
|
validate();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ModelerCameras::processPanning(double xvalue, double yvalue)
|
||||||
|
{
|
||||||
|
active->rotateYaw(xvalue);
|
||||||
|
active->rotatePitch(yvalue);
|
||||||
|
|
||||||
|
validate();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModelerCameras::timerEvent(QTimerEvent *)
|
void ModelerCameras::timerEvent(QTimerEvent *)
|
||||||
|
@ -51,6 +63,13 @@ void ModelerCameras::timerEvent(QTimerEvent *)
|
||||||
renderer->setCamera(current);
|
renderer->setCamera(current);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ModelerCameras::validate()
|
||||||
|
{
|
||||||
|
if (active == render) {
|
||||||
|
parent->getScenery()->setCamera(active);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ModelerCameras::changeActiveCamera(const QString &name)
|
void ModelerCameras::changeActiveCamera(const QString &name)
|
||||||
{
|
{
|
||||||
if (name == "Render camera")
|
if (name == "Render camera")
|
||||||
|
|
|
@ -29,9 +29,19 @@ public:
|
||||||
*/
|
*/
|
||||||
void processScroll(double xvalue, double yvalue);
|
void processScroll(double xvalue, double yvalue);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Process a panning rotation.
|
||||||
|
*/
|
||||||
|
void processPanning(double xvalue, double yvalue);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void timerEvent(QTimerEvent *event);
|
void timerEvent(QTimerEvent *event);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validate current camera, pushing it to rendered scenery if needed.
|
||||||
|
*/
|
||||||
|
void validate();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void changeActiveCamera(const QString &name);
|
void changeActiveCamera(const QString &name);
|
||||||
|
|
||||||
|
|
|
@ -76,10 +76,14 @@ void OpenGLView::mouseReleaseEvent(QMouseEvent *)
|
||||||
void OpenGLView::mouseMoveEvent(QMouseEvent *event)
|
void OpenGLView::mouseMoveEvent(QMouseEvent *event)
|
||||||
{
|
{
|
||||||
QPointF diff = event->windowPos() - mouse_pos;
|
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());
|
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();
|
mouse_pos = event->windowPos();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -70,8 +70,8 @@ void RenderPreviewProvider::canvasResized(int width, int height)
|
||||||
{
|
{
|
||||||
delete pixbuf;
|
delete pixbuf;
|
||||||
pixbuf = new QImage(width, height, QImage::Format_ARGB32);
|
pixbuf = new QImage(width, height, QImage::Format_ARGB32);
|
||||||
pixbuf->fill(Qt::black);
|
|
||||||
}
|
}
|
||||||
|
pixbuf->fill(Qt::black);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderPreviewProvider::canvasCleared(const Color &col)
|
void RenderPreviewProvider::canvasCleared(const Color &col)
|
||||||
|
|
|
@ -4,6 +4,18 @@ Rectangle {
|
||||||
width: 400
|
width: 400
|
||||||
height: 300
|
height: 300
|
||||||
|
|
||||||
|
function refresh() {
|
||||||
|
preview_image.source = "";
|
||||||
|
preview_image.source = "image://renderpreviewprovider/live";
|
||||||
|
}
|
||||||
|
|
||||||
|
onOpacityChanged: {
|
||||||
|
refresh();
|
||||||
|
}
|
||||||
|
onVisibleChanged: {
|
||||||
|
refresh();
|
||||||
|
}
|
||||||
|
|
||||||
Image {
|
Image {
|
||||||
id: preview_image
|
id: preview_image
|
||||||
objectName: "preview_image"
|
objectName: "preview_image"
|
||||||
|
@ -20,8 +32,7 @@ Rectangle {
|
||||||
repeat: true
|
repeat: true
|
||||||
|
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
preview_image.source = "";
|
refresh();
|
||||||
preview_image.source = "image://renderpreviewprovider/live";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue