From 64ce4e6843188d43bc0b7e1687b2a2c1b7f2876e Mon Sep 17 00:00:00 2001 From: Jeremy Hu Date: Wed, 28 Mar 2018 19:41:33 +0800 Subject: [PATCH] Add trival control of radius --- src/mainwindow.cpp | 8 +++----- src/skeletoneditgraphicsview.cpp | 17 ++++++++++++----- src/skeletontomesh.cpp | 12 +++++++----- 3 files changed, 22 insertions(+), 15 deletions(-) diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 96882c90..e6ba8f7f 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -138,10 +138,8 @@ MainWindow::MainWindow() saveAct->setStatusTip(tr("Save the document to disk")); connect(saveAct, &QAction::triggered, this, &MainWindow::save); - QAction *exitAct = new QAction(tr("E&xit"), this); - exitAct->setShortcuts(QKeySequence::Quit); - exitAct->setStatusTip(tr("Exit the application")); - connect(exitAct, &QAction::triggered, this, &QWidget::close); + QAction *exportAct = new QAction(tr("E&xport.."), this); + connect(exportAct, &QAction::triggered, this, &MainWindow::exportModel); QAction *undoAct = new QAction(tr("&Undo"), this); undoAct->setShortcuts(QKeySequence::Undo); @@ -179,7 +177,7 @@ MainWindow::MainWindow() fileMenu->addAction(openAct); fileMenu->addAction(saveAct); fileMenu->addSeparator(); - fileMenu->addAction(exitAct); + fileMenu->addAction(exportAct); QMenu *editMenu = menuBar()->addMenu(tr("&Edit")); editMenu->addAction(undoAct); diff --git a/src/skeletoneditgraphicsview.cpp b/src/skeletoneditgraphicsview.cpp index 521f2b5d..accba1cf 100644 --- a/src/skeletoneditgraphicsview.cpp +++ b/src/skeletoneditgraphicsview.cpp @@ -2,6 +2,7 @@ #include #include #include +#include #include #include #include @@ -152,6 +153,7 @@ void SkeletonEditGraphicsView::removeSelectedItems() if (m_nextStartNodeItem) { SkeletonEditNodeItem *nodeItem = m_nextStartNodeItem; setNextStartNodeItem(NULL); + removeNodeItem(nodeItem->nextSidePair()); removeNodeItem(nodeItem); emit nodesChanged(); } @@ -401,13 +403,18 @@ void SkeletonEditGraphicsView::wheelEvent(QWheelEvent *event) if (!m_backgroundLoaded) return; qreal delta = event->delta() / 10; - if (fabs(delta) < 1) - delta = delta < 0 ? -1.0 : 1.0; + if (QGuiApplication::queryKeyboardModifiers().testFlag(Qt::ShiftModifier)) { + if (delta > 0) + delta = 1; + else + delta = -1; + } else { + if (fabs(delta) < 1) + delta = delta < 0 ? -1.0 : 1.0; + } AddItemRadius(m_pendingNodeItem, delta); if (!m_inAddNodeMode && m_lastHoverNodeItem) { - //if (canAddItemRadius(m_lastHoverNodeItem, delta)) { - AddItemRadius(m_lastHoverNodeItem, delta); - //} + AddItemRadius(m_lastHoverNodeItem, delta); emit nodesChanged(); } } diff --git a/src/skeletontomesh.cpp b/src/skeletontomesh.cpp index 21b8cad3..1501f9d1 100644 --- a/src/skeletontomesh.cpp +++ b/src/skeletontomesh.cpp @@ -244,6 +244,8 @@ void SkeletonToMesh::process() SkeletonSnapshot *skeleton = &groups[i]; QRectF front = skeleton->boundingBoxFront(); QRectF side = skeleton->boundingBoxSide(); + float canvasWidth = skeleton->canvas["width"].toFloat(); + float canvasHeight = skeleton->canvas["height"].toFloat(); std::map bmeshNodeMap; @@ -255,11 +257,11 @@ void SkeletonToMesh::process() std::map>::iterator nextSidePair = skeleton->nodes.find(nodeIterator->second["nextSidePair"]); if (nextSidePair == skeleton->nodes.end()) continue; - float x = (nodeIterator->second["x"].toFloat() - front.left() - front.height() / 2) / front.height(); - float y = (nodeIterator->second["y"].toFloat() - front.top() - front.height() / 2) / front.height(); - float z = (nextSidePair->second["x"].toFloat() - side.left() - side.width() / 2) / side.height(); - float r = nodeIterator->second["radius"].toFloat() / front.height(); - float t = nextSidePair->second["radius"].toFloat() / side.height(); + float x = (nodeIterator->second["x"].toFloat() - front.left()) / canvasHeight; + float y = (nodeIterator->second["y"].toFloat()) / canvasHeight; + float z = (nextSidePair->second["x"].toFloat() - side.left()) / canvasHeight; + float r = nodeIterator->second["radius"].toFloat() / canvasHeight; + float t = nextSidePair->second["radius"].toFloat() / canvasHeight; int bmeshNodeId = meshlite_bmesh_add_node(meshliteContext, bmeshId, x, y, z, r, t); printf("meshlite_bmesh_add_node x:%f y:%f z:%f r:%f t:%f nodeName:%s bmeshNodeId:%d\n", x, y, z, r, t, nodeIterator->first.toUtf8().constData(), bmeshNodeId); bmeshNodeMap[nodeIterator->first] = bmeshNodeId;