diff --git a/ACKNOWLEDGEMENTS.html b/ACKNOWLEDGEMENTS.html index ae461b54..014f570d 100644 --- a/ACKNOWLEDGEMENTS.html +++ b/ACKNOWLEDGEMENTS.html @@ -399,4 +399,4 @@
https://rosettacode.org/wiki/Catmull%E2%80%93Clark_subdivision_surface/C -\ No newline at end of file + diff --git a/src/modelmeshbinder.cpp b/src/modelmeshbinder.cpp index 1f123497..de042297 100644 --- a/src/modelmeshbinder.cpp +++ b/src/modelmeshbinder.cpp @@ -9,7 +9,7 @@ ModelMeshBinder::ModelMeshBinder() : m_renderEdgeVertexCount(0), m_mesh(NULL), m_meshUpdated(false), - m_showFrames(true) + m_showWireframes(true) { } @@ -104,7 +104,7 @@ void ModelMeshBinder::paint() } } - if (m_showFrames) { + if (m_showWireframes) { if (m_renderEdgeVertexCount > 0) { QOpenGLVertexArrayObject::Binder vaoBinder(&m_vaoEdge); glDrawArrays(GL_LINES, 0, m_renderEdgeVertexCount); @@ -124,12 +124,12 @@ void ModelMeshBinder::cleanup() m_vboEdge.destroy(); } -void ModelMeshBinder::showFrames() +void ModelMeshBinder::showWireframes() { - m_showFrames = true; + m_showWireframes = true; } -void ModelMeshBinder::hideFrames() +void ModelMeshBinder::hideWireframes() { - m_showFrames = false; + m_showWireframes = false; } diff --git a/src/modelmeshbinder.h b/src/modelmeshbinder.h index c2d11d25..ee15af0f 100644 --- a/src/modelmeshbinder.h +++ b/src/modelmeshbinder.h @@ -16,8 +16,8 @@ public: void initialize(); void paint(); void cleanup(); - void showFrames(); - void hideFrames(); + void showWireframes(); + void hideWireframes(); private: QOpenGLVertexArrayObject m_vaoTriangle; QOpenGLBuffer m_vboTriangle; @@ -28,7 +28,7 @@ private: int m_renderTriangleVertexCount; int m_renderEdgeVertexCount; bool m_meshUpdated; - bool m_showFrames; + bool m_showWireframes; }; #endif diff --git a/src/modelofflinerender.cpp b/src/modelofflinerender.cpp index d803bb06..3101b245 100644 --- a/src/modelofflinerender.cpp +++ b/src/modelofflinerender.cpp @@ -64,7 +64,7 @@ QImage ModelOfflineRender::toImage(const QSize &size) ModelShaderProgram *program = new ModelShaderProgram; ModelMeshBinder meshBinder; meshBinder.initialize(); - meshBinder.hideFrames(); + meshBinder.hideWireframes(); program->setUniformValue(program->lightPosLoc(), QVector3D(0, 0, 70)); diff --git a/src/modelwidget.cpp b/src/modelwidget.cpp index 8c087f9d..474154c6 100644 --- a/src/modelwidget.cpp +++ b/src/modelwidget.cpp @@ -35,6 +35,7 @@ ModelWidget::ModelWidget(QWidget *parent) setFormat(fmt); } setMouseTracking(true); + setContextMenuPolicy(Qt::CustomContextMenu); } int ModelWidget::xRot() @@ -188,6 +189,8 @@ void ModelWidget::mousePressEvent(QMouseEvent *event) m_moveStartPos = mapToParent(event->pos()); m_moveStartGeometry = geometry(); m_moveStarted = true; + m_meshBinder.hideWireframes(); + update(); } } } @@ -198,6 +201,8 @@ void ModelWidget::mouseReleaseEvent(QMouseEvent *event) m_graphicsFunctions->mouseRelease(event); if (m_moveStarted) { m_moveStarted = false; + m_meshBinder.showWireframes(); + update(); } } @@ -210,15 +215,17 @@ void ModelWidget::mouseMoveEvent(QMouseEvent *event) int dy = event->y() - m_lastPos.y(); if (event->buttons() & Qt::MidButton) { - if (m_moveStarted) { - QRect rect = m_moveStartGeometry; - QPoint pos = mapToParent(event->pos()); - rect.translate(pos.x() - m_moveStartPos.x(), pos.y() - m_moveStartPos.y()); - setGeometry(rect); + if (QGuiApplication::queryKeyboardModifiers().testFlag(Qt::ShiftModifier)) { + if (m_moveStarted) { + QRect rect = m_moveStartGeometry; + QPoint pos = mapToParent(event->pos()); + rect.translate(pos.x() - m_moveStartPos.x(), pos.y() - m_moveStartPos.y()); + setGeometry(rect); + } + } else { + setXRotation(m_xRot - 8 * dy); + setYRotation(m_yRot - 8 * dx); } - } else if (event->buttons() & Qt::RightButton) { - setXRotation(m_xRot - 8 * dy); - setYRotation(m_yRot - 8 * dx); } m_lastPos = event->pos(); } diff --git a/src/skeletondocumentwindow.cpp b/src/skeletondocumentwindow.cpp index 6f0b6670..9dc97c57 100644 --- a/src/skeletondocumentwindow.cpp +++ b/src/skeletondocumentwindow.cpp @@ -385,6 +385,10 @@ SkeletonDocumentWindow::SkeletonDocumentWindow() : connect(m_document, &SkeletonDocument::skeletonChanged, this, &SkeletonDocumentWindow::documentChanged); connect(m_document, &SkeletonDocument::turnaroundChanged, this, &SkeletonDocumentWindow::documentChanged); + connect(m_modelWidget, &ModelWidget::customContextMenuRequested, [=](const QPoint &pos) { + graphicsWidget->showContextMenu(graphicsWidget->mapFromGlobal(m_modelWidget->mapToGlobal(pos))); + }); + connect(this, &SkeletonDocumentWindow::initialized, m_document, &SkeletonDocument::uiReady); } diff --git a/src/skeletongraphicswidget.cpp b/src/skeletongraphicswidget.cpp index 109b94a4..01bb026b 100644 --- a/src/skeletongraphicswidget.cpp +++ b/src/skeletongraphicswidget.cpp @@ -320,14 +320,6 @@ void SkeletonGraphicsWidget::mousePressEvent(QMouseEvent *event) return; } m_mouseEventFromSelf = false; - if (event->button() == Qt::LeftButton) { - if (SkeletonDocumentEditMode::Select == m_document->editMode) { - if (!m_rangeSelectionStarted) { - m_rangeSelectionStartPos = mouseEventScenePos(event); - m_rangeSelectionStarted = true; - } - } - } } void SkeletonGraphicsWidget::mouseDoubleClickEvent(QMouseEvent *event) @@ -660,6 +652,15 @@ bool SkeletonGraphicsWidget::mousePress(QMouseEvent *event) //} } } + + if (event->button() == Qt::LeftButton) { + if (SkeletonDocumentEditMode::Select == m_document->editMode) { + if (!m_rangeSelectionStarted) { + m_rangeSelectionStartPos = mouseEventScenePos(event); + m_rangeSelectionStarted = true; + } + } + } return false; }