Add trival control of radius

master
Jeremy Hu 2018-03-28 19:41:33 +08:00
parent 09d21e8935
commit 64ce4e6843
3 changed files with 22 additions and 15 deletions

View File

@ -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);

View File

@ -2,6 +2,7 @@
#include <QXmlStreamWriter>
#include <QFile>
#include <QApplication>
#include <QGuiApplication>
#include <cmath>
#include <map>
#include <vector>
@ -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 (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);
//}
emit nodesChanged();
}
}

View File

@ -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<QString, int> bmeshNodeMap;
@ -255,11 +257,11 @@ void SkeletonToMesh::process()
std::map<QString, std::map<QString, QString>>::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;