Seperate model render view control and edit view control
parent
f0e68d9f7a
commit
e1e4953dec
|
@ -399,4 +399,4 @@
|
|||
<h1>Catmull–Clark subdivision surface/C</h1>
|
||||
<pre>
|
||||
https://rosettacode.org/wiki/Catmull%E2%80%93Clark_subdivision_surface/C
|
||||
</pre>
|
||||
</pre>
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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));
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue