diff --git a/src/main.cpp b/src/main.cpp index b19f9b42..275996d9 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -31,8 +31,10 @@ int main(int argc, char ** argv) QCoreApplication::setApplicationName("Dust 3D"); - const QFont fixedFont = QFontDatabase::systemFont(QFontDatabase::FixedFont); - QApplication::setFont(fixedFont); + QFont font; + font.setWeight(QFont::Light); + font.setPointSize(9); + QApplication::setFont(font); MainWindow mainWindow; mainWindow.showMaximized(); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index bfc03811..3776f3e1 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -64,7 +64,7 @@ MainWindow::MainWindow() QVBoxLayout *modelRightLayout = new QVBoxLayout; - modelRightLayout->addSpacing(20); + modelRightLayout->addSpacing(10); QPushButton *changeTurnaroundButton = new QPushButton(" Change Turnaround "); modelRightLayout->addWidget(changeTurnaroundButton); diff --git a/src/skeletoneditgraphicsview.cpp b/src/skeletoneditgraphicsview.cpp index a69c8176..394ee811 100644 --- a/src/skeletoneditgraphicsview.cpp +++ b/src/skeletoneditgraphicsview.cpp @@ -497,6 +497,7 @@ void SkeletonEditGraphicsView::loadFromXmlStream(QXmlStreamReader &reader) std::vector> pendingNodes; std::vector> pendingEdges; std::map addedNodeMapById; + std::map addedGroupMapById; while (!reader.atEnd()) { reader.readNext(); @@ -523,11 +524,13 @@ void SkeletonEditGraphicsView::loadFromXmlStream(QXmlStreamReader &reader) } } else if (reader.name() == "node") { QString nodeId = reader.attributes().value("id").toString(); + QString nodeGroupId = reader.attributes().value("group").toString(); QString nodeType = reader.attributes().value("type").toString(); QString nodePairId = reader.attributes().value("pair").toString(); QString nodeRadius = reader.attributes().value("radius").toString(); std::map pendingNode; pendingNode["id"] = nodeId; + pendingNode["group"] = nodeGroupId; pendingNode["type"] = nodeType; pendingNode["pair"] = nodePairId; pendingNode["radius"] = QString("%1").arg(nodeRadius.toFloat() * radiusMul); @@ -554,7 +557,15 @@ void SkeletonEditGraphicsView::loadFromXmlStream(QXmlStreamReader &reader) float radius = (*pendingNode)["radius"].toFloat(); QRectF nodeRect((*pendingNode)["x"].toFloat() - radius, (*pendingNode)["y"].toFloat() - radius, radius * 2, radius * 2); - addedNodeMapById[(*pendingNode)["id"]] = new SkeletonEditNodeItem(nodeRect); + SkeletonEditNodeItem *nodeItem = new SkeletonEditNodeItem(nodeRect); + addedNodeMapById[(*pendingNode)["id"]] = nodeItem; + std::map::iterator findGroup = addedGroupMapById.find((*pendingNode)["group"]); + if (findGroup == addedGroupMapById.end()) { + QGraphicsItemGroup *group = new QGraphicsItemGroup; + scene()->addItem(group); + addedGroupMapById[(*pendingNode)["group"]] = group; + } + nodeItem->setGroup(addedGroupMapById[(*pendingNode)["group"]]); } for (size_t i = 0; i < pendingNodes.size(); i++) { @@ -570,7 +581,9 @@ void SkeletonEditGraphicsView::loadFromXmlStream(QXmlStreamReader &reader) for (size_t i = 0; i < pendingEdges.size(); i++) { std::map *pendingEdge = &pendingEdges[i]; SkeletonEditEdgeItem *newEdge = new SkeletonEditEdgeItem(); - newEdge->setNodes(addedNodeMapById[(*pendingEdge)["from"]], addedNodeMapById[(*pendingEdge)["to"]]); + SkeletonEditNodeItem *fromNodeItem = addedNodeMapById[(*pendingEdge)["from"]]; + SkeletonEditNodeItem *toNodeItem = addedNodeMapById[(*pendingEdge)["to"]]; + newEdge->setNodes(fromNodeItem, toNodeItem); scene()->addItem(newEdge); } @@ -589,7 +602,9 @@ void SkeletonEditGraphicsView::saveToXmlStream(QXmlStreamWriter *writer) QList::iterator it; QList list = scene()->items(); std::map nodeIdMap; + std::map groupIdMap; int nextNodeId = 1; + int nextGroupId = 1; for (it = list.begin(); it != list.end(); ++it) { if ((*it)->data(0).toString() == "node") { SkeletonEditNodeItem *nodeItem = static_cast(*it); @@ -602,7 +617,12 @@ void SkeletonEditGraphicsView::saveToXmlStream(QXmlStreamWriter *writer) if ((*it)->data(0).toString() == "node") { SkeletonEditNodeItem *nodeItem = static_cast(*it); writer->writeStartElement("node"); + std::map::iterator findGroup = groupIdMap.find(nodeItem->group()); + if (findGroup == groupIdMap.end()) { + groupIdMap[nodeItem->group()] = nextGroupId++; + } writer->writeAttribute("id", QString("node%1").arg(nodeIdMap[nodeItem])); + writer->writeAttribute("group", QString("group%1").arg(groupIdMap[nodeItem->group()])); writer->writeAttribute("type", nodeItem->isMaster() ? "master" : "slave"); writer->writeAttribute("pair", QString("node%1").arg(nodeIdMap[nodeItem->pair()])); writer->writeAttribute("radius", QString("%1").arg(nodeItem->radius())); diff --git a/src/skeletontomesh.cpp b/src/skeletontomesh.cpp index d00b6d6a..5438dac9 100644 --- a/src/skeletontomesh.cpp +++ b/src/skeletontomesh.cpp @@ -353,6 +353,12 @@ void SkeletonToMesh::process() group->meshId = meshlite_bmesh_generate_mesh(context, group->bmeshId, group->nodes[group->rootNode].bmeshNodeId); } + int mergedMeshId = m_groups[0].meshId; + for (size_t i = 1; i < m_groups.size(); i++) { + mergedMeshId = meshlite_merge(context, mergedMeshId, m_groups[i].meshId); + } + + /* ExternalMesh *unionPolyhedron = makeExternalMeshFromMeshlite(context, m_groups[0].meshId); for (size_t i = 1; i < m_groups.size(); i++) { ExternalMesh *polyhedron = makeExternalMeshFromMeshlite(context, m_groups[i].meshId); @@ -364,11 +370,13 @@ void SkeletonToMesh::process() break; } } + */ for (size_t i = 1; i < m_groups.size(); i++) { meshlite_bmesh_destroy(context, m_groups[i].bmeshId); } + /* if (unionPolyhedron) { int meshIdGeneratedFromExternal = makeMeshliteMeshFromExternal(context, unionPolyhedron); delete unionPolyhedron; @@ -376,6 +384,10 @@ void SkeletonToMesh::process() meshlite_export(context, meshIdGeneratedFromExternal, "/Users/jeremy/testlib.obj"); m_mesh = new Mesh(context, meshIdGeneratedFromExternal); } + */ + + m_mesh = new Mesh(context, mergedMeshId); + meshlite_destroy_context(context); emit finished(); }