Add single node mesh
parent
f49e88484f
commit
5e97e3d268
|
@ -181,6 +181,24 @@ void MeshGenerator::process()
|
||||||
meshlite_bmesh_add_edge(meshliteContext, bmeshId, bmeshFromNodeId, bmeshToNodeId);
|
meshlite_bmesh_add_edge(meshliteContext, bmeshId, bmeshFromNodeId, bmeshToNodeId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (const auto &nodeIt: m_snapshot->nodes) {
|
||||||
|
QString partId = valueOfKeyInMapOrEmpty(nodeIt.second, "partId");
|
||||||
|
const auto partBmeshIt = partBmeshMap.find(partId);
|
||||||
|
if (partBmeshIt == partBmeshMap.end())
|
||||||
|
continue;
|
||||||
|
const auto nodeBmeshIt = bmeshNodeMap.find(nodeIt.first);
|
||||||
|
if (nodeBmeshIt != bmeshNodeMap.end())
|
||||||
|
continue;
|
||||||
|
int bmeshId = partBmeshIt->second;
|
||||||
|
float radius = valueOfKeyInMapOrEmpty(nodeIt.second, "radius").toFloat() / longHeight;
|
||||||
|
float x = (valueOfKeyInMapOrEmpty(nodeIt.second, "x").toFloat() - mainProfileMiddleX) / longHeight;
|
||||||
|
float y = (valueOfKeyInMapOrEmpty(nodeIt.second, "y").toFloat() - mainProfileMiddleY) / longHeight;
|
||||||
|
float z = (valueOfKeyInMapOrEmpty(nodeIt.second, "z").toFloat() - sideProfileMiddleX) / longHeight;
|
||||||
|
int bmeshNodeId = meshlite_bmesh_add_node(meshliteContext, bmeshId, x, y, z, radius);
|
||||||
|
qDebug() << "bmeshId[" << bmeshId << "] add lonely node[" << bmeshNodeId << "]" << radius << x << y << z;
|
||||||
|
bmeshNodeMap[nodeIt.first] = bmeshNodeId;
|
||||||
|
}
|
||||||
|
|
||||||
std::map<QString, int> partMeshMap;
|
std::map<QString, int> partMeshMap;
|
||||||
std::vector<int> meshIds;
|
std::vector<int> meshIds;
|
||||||
for (const auto &partIdIt: m_snapshot->partIdList) {
|
for (const auto &partIdIt: m_snapshot->partIdList) {
|
||||||
|
|
|
@ -194,6 +194,7 @@ SkeletonDocumentWindow::SkeletonDocumentWindow() :
|
||||||
connect(graphicsWidget, &SkeletonGraphicsWidget::undo, m_document, &SkeletonDocument::undo);
|
connect(graphicsWidget, &SkeletonGraphicsWidget::undo, m_document, &SkeletonDocument::undo);
|
||||||
connect(graphicsWidget, &SkeletonGraphicsWidget::redo, m_document, &SkeletonDocument::redo);
|
connect(graphicsWidget, &SkeletonGraphicsWidget::redo, m_document, &SkeletonDocument::redo);
|
||||||
connect(graphicsWidget, &SkeletonGraphicsWidget::paste, m_document, &SkeletonDocument::paste);
|
connect(graphicsWidget, &SkeletonGraphicsWidget::paste, m_document, &SkeletonDocument::paste);
|
||||||
|
connect(graphicsWidget, &SkeletonGraphicsWidget::changeTurnaround, this, &SkeletonDocumentWindow::changeTurnaround);
|
||||||
|
|
||||||
connect(m_document, &SkeletonDocument::nodeAdded, graphicsWidget, &SkeletonGraphicsWidget::nodeAdded);
|
connect(m_document, &SkeletonDocument::nodeAdded, graphicsWidget, &SkeletonGraphicsWidget::nodeAdded);
|
||||||
connect(m_document, &SkeletonDocument::nodeRemoved, graphicsWidget, &SkeletonGraphicsWidget::nodeRemoved);
|
connect(m_document, &SkeletonDocument::nodeRemoved, graphicsWidget, &SkeletonGraphicsWidget::nodeRemoved);
|
||||||
|
|
|
@ -92,12 +92,12 @@ void SkeletonGraphicsWidget::showContextMenu(const QPoint &pos)
|
||||||
|
|
||||||
QAction cutAction("Cut", this);
|
QAction cutAction("Cut", this);
|
||||||
connect(&cutAction, &QAction::triggered, this, &SkeletonGraphicsWidget::cut);
|
connect(&cutAction, &QAction::triggered, this, &SkeletonGraphicsWidget::cut);
|
||||||
cutAction.setEnabled(!nodeItemMap.empty());
|
cutAction.setEnabled(!m_rangeSelectionSet.empty());
|
||||||
contextMenu.addAction(&cutAction);
|
contextMenu.addAction(&cutAction);
|
||||||
|
|
||||||
QAction copyAction("Copy", this);
|
QAction copyAction("Copy", this);
|
||||||
connect(©Action, &QAction::triggered, this, &SkeletonGraphicsWidget::copy);
|
connect(©Action, &QAction::triggered, this, &SkeletonGraphicsWidget::copy);
|
||||||
copyAction.setEnabled(!nodeItemMap.empty());
|
copyAction.setEnabled(!m_rangeSelectionSet.empty());
|
||||||
contextMenu.addAction(©Action);
|
contextMenu.addAction(©Action);
|
||||||
|
|
||||||
QAction pasteAction("Paste", this);
|
QAction pasteAction("Paste", this);
|
||||||
|
@ -121,6 +121,26 @@ void SkeletonGraphicsWidget::showContextMenu(const QPoint &pos)
|
||||||
unselectAllAction.setEnabled(!m_rangeSelectionSet.empty());
|
unselectAllAction.setEnabled(!m_rangeSelectionSet.empty());
|
||||||
contextMenu.addAction(&unselectAllAction);
|
contextMenu.addAction(&unselectAllAction);
|
||||||
|
|
||||||
|
contextMenu.addSeparator();
|
||||||
|
|
||||||
|
QAction addMirrorAction("Mirror", this);
|
||||||
|
connect(&addMirrorAction, &QAction::triggered, this, &SkeletonGraphicsWidget::addMirror);
|
||||||
|
addMirrorAction.setEnabled(readSkeletonNodeAndAnyEdgeOfNodeFromRangeSelection(nullptr, nullptr));
|
||||||
|
contextMenu.addAction(&addMirrorAction);
|
||||||
|
|
||||||
|
QAction deleteMirrorAction("Delete Mirror", this);
|
||||||
|
connect(&deleteMirrorAction, &QAction::triggered, this, &SkeletonGraphicsWidget::deleteMirror);
|
||||||
|
deleteMirrorAction.setEnabled(readSkeletonNodeAndAnyEdgeOfNodeFromRangeSelection(nullptr, nullptr));
|
||||||
|
contextMenu.addAction(&deleteMirrorAction);
|
||||||
|
|
||||||
|
contextMenu.addSeparator();
|
||||||
|
|
||||||
|
QAction changeTurnaroundAction("Change Turnaround..", this);
|
||||||
|
connect(&changeTurnaroundAction, &QAction::triggered, [=]() {
|
||||||
|
emit changeTurnaround();
|
||||||
|
});
|
||||||
|
contextMenu.addAction(&changeTurnaroundAction);
|
||||||
|
|
||||||
contextMenu.exec(mapToGlobal(pos));
|
contextMenu.exec(mapToGlobal(pos));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -589,6 +609,10 @@ QPointF SkeletonGraphicsWidget::scenePosFromUnified(QPointF pos)
|
||||||
|
|
||||||
bool SkeletonGraphicsWidget::mouseDoubleClick(QMouseEvent *event)
|
bool SkeletonGraphicsWidget::mouseDoubleClick(QMouseEvent *event)
|
||||||
{
|
{
|
||||||
|
if (m_hoveredNodeItem || m_hoveredEdgeItem) {
|
||||||
|
selectPartAll();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -947,6 +971,35 @@ void SkeletonGraphicsWidget::readSkeletonNodeAndEdgeIdSetFromRangeSelection(std:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SkeletonGraphicsWidget::readSkeletonNodeAndAnyEdgeOfNodeFromRangeSelection(SkeletonGraphicsNodeItem **nodeItem, SkeletonGraphicsEdgeItem **edgeItem)
|
||||||
|
{
|
||||||
|
SkeletonGraphicsNodeItem *choosenNodeItem = nullptr;
|
||||||
|
SkeletonGraphicsEdgeItem *choosenEdgeItem = nullptr;
|
||||||
|
for (const auto &it: m_rangeSelectionSet) {
|
||||||
|
QGraphicsItem *item = it;
|
||||||
|
if (item->data(0) == "node") {
|
||||||
|
choosenNodeItem = (SkeletonGraphicsNodeItem *)item;
|
||||||
|
} else if (item->data(0) == "edge") {
|
||||||
|
choosenEdgeItem = (SkeletonGraphicsEdgeItem *)item;
|
||||||
|
}
|
||||||
|
if (choosenNodeItem && choosenEdgeItem)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (!choosenNodeItem || !choosenEdgeItem)
|
||||||
|
return false;
|
||||||
|
if (choosenNodeItem->profile() != choosenEdgeItem->profile())
|
||||||
|
return false;
|
||||||
|
if (choosenNodeItem != choosenEdgeItem->firstItem() && choosenNodeItem != choosenEdgeItem->secondItem())
|
||||||
|
return false;
|
||||||
|
if (nodeItem)
|
||||||
|
*nodeItem = choosenNodeItem;
|
||||||
|
if (edgeItem)
|
||||||
|
*edgeItem = choosenEdgeItem;
|
||||||
|
if (m_rangeSelectionSet.size() != 2)
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void SkeletonGraphicsWidget::selectPartAll()
|
void SkeletonGraphicsWidget::selectPartAll()
|
||||||
{
|
{
|
||||||
unselectAll();
|
unselectAll();
|
||||||
|
@ -1041,4 +1094,3 @@ void SkeletonGraphicsWidget::copy()
|
||||||
QClipboard *clipboard = QApplication::clipboard();
|
QClipboard *clipboard = QApplication::clipboard();
|
||||||
clipboard->setText(snapshotXml);
|
clipboard->setText(snapshotXml);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -263,6 +263,9 @@ signals:
|
||||||
void undo();
|
void undo();
|
||||||
void redo();
|
void redo();
|
||||||
void paste();
|
void paste();
|
||||||
|
void changeTurnaround();
|
||||||
|
void addMirror();
|
||||||
|
void deleteMirror();
|
||||||
public:
|
public:
|
||||||
SkeletonGraphicsWidget(const SkeletonDocument *document);
|
SkeletonGraphicsWidget(const SkeletonDocument *document);
|
||||||
std::map<QUuid, std::pair<SkeletonGraphicsNodeItem *, SkeletonGraphicsNodeItem *>> nodeItemMap;
|
std::map<QUuid, std::pair<SkeletonGraphicsNodeItem *, SkeletonGraphicsNodeItem *>> nodeItemMap;
|
||||||
|
@ -277,6 +280,7 @@ public:
|
||||||
static SkeletonProfile readSkeletonItemProfile(QGraphicsItem *item);
|
static SkeletonProfile readSkeletonItemProfile(QGraphicsItem *item);
|
||||||
void readMergedSkeletonNodeSetFromRangeSelection(std::set<SkeletonGraphicsNodeItem *> *nodeItemSet);
|
void readMergedSkeletonNodeSetFromRangeSelection(std::set<SkeletonGraphicsNodeItem *> *nodeItemSet);
|
||||||
void readSkeletonNodeAndEdgeIdSetFromRangeSelection(std::set<QUuid> *nodeIdSet, std::set<QUuid> *edgeIdSet);
|
void readSkeletonNodeAndEdgeIdSetFromRangeSelection(std::set<QUuid> *nodeIdSet, std::set<QUuid> *edgeIdSet);
|
||||||
|
bool readSkeletonNodeAndAnyEdgeOfNodeFromRangeSelection(SkeletonGraphicsNodeItem **nodeItem, SkeletonGraphicsEdgeItem **edgeItem);
|
||||||
protected:
|
protected:
|
||||||
void mouseMoveEvent(QMouseEvent *event);
|
void mouseMoveEvent(QMouseEvent *event);
|
||||||
void wheelEvent(QWheelEvent *event);
|
void wheelEvent(QWheelEvent *event);
|
||||||
|
|
|
@ -25,7 +25,6 @@ SkeletonPartWidget::SkeletonPartWidget(const SkeletonDocument *document, QUuid p
|
||||||
QHBoxLayout *miniToolLayout = new QHBoxLayout;
|
QHBoxLayout *miniToolLayout = new QHBoxLayout;
|
||||||
miniToolLayout->setSpacing(0);
|
miniToolLayout->setSpacing(0);
|
||||||
miniToolLayout->setContentsMargins(0, 0, 0, 0);
|
miniToolLayout->setContentsMargins(0, 0, 0, 0);
|
||||||
miniToolLayout->addSpacing(5);
|
|
||||||
miniToolLayout->addWidget(m_visibleButton);
|
miniToolLayout->addWidget(m_visibleButton);
|
||||||
miniToolLayout->addWidget(m_lockButton);
|
miniToolLayout->addWidget(m_lockButton);
|
||||||
miniToolLayout->addWidget(m_subdivButton);
|
miniToolLayout->addWidget(m_subdivButton);
|
||||||
|
|
Loading…
Reference in New Issue