Add node delete operation
parent
de0fa135fb
commit
24fbff4218
|
@ -1,6 +1,7 @@
|
|||
#include <QApplication>
|
||||
#include <QDesktopWidget>
|
||||
#include <QStyleFactory>
|
||||
#include <QFontDatabase>
|
||||
#include "mainwindow.h"
|
||||
#include "meshlite.h"
|
||||
|
||||
|
@ -30,6 +31,9 @@ int main(int argc, char ** argv)
|
|||
|
||||
QCoreApplication::setApplicationName("Dust 3D");
|
||||
|
||||
const QFont fixedFont = QFontDatabase::systemFont(QFontDatabase::FixedFont);
|
||||
QApplication::setFont(fixedFont);
|
||||
|
||||
MainWindow mainWindow;
|
||||
mainWindow.showMaximized();
|
||||
return app.exec();
|
||||
|
|
|
@ -149,6 +149,7 @@ void MainWindow::loadModel()
|
|||
}
|
||||
}
|
||||
}
|
||||
m_skeletonWidget->graphicsView()->turnOffAddNodeMode();
|
||||
}
|
||||
|
||||
void MainWindow::saveModel()
|
||||
|
|
|
@ -116,6 +116,60 @@ float SkeletonEditGraphicsView::findXForSlave(float x)
|
|||
return x - m_backgroundItem->boundingRect().width() / 4;
|
||||
}
|
||||
|
||||
void SkeletonEditGraphicsView::removeSelectedItems()
|
||||
{
|
||||
if (m_nextStartNodeItem) {
|
||||
SkeletonEditNodeItem *nodeItem = m_nextStartNodeItem;
|
||||
setNextStartNodeItem(NULL);
|
||||
removeNodeItem(nodeItem);
|
||||
emit nodesChanged();
|
||||
}
|
||||
}
|
||||
|
||||
void SkeletonEditGraphicsView::removeNodeItem(SkeletonEditNodeItem *nodeItem)
|
||||
{
|
||||
if (nodeItem->pair()) {
|
||||
scene()->removeItem(nodeItem->pair());
|
||||
}
|
||||
scene()->removeItem(nodeItem);
|
||||
QList<QGraphicsItem *>::iterator it;
|
||||
QList<QGraphicsItem *> list = scene()->items();
|
||||
for (it = list.begin(); it != list.end(); ++it) {
|
||||
if ((*it)->data(0).toString() == "edge") {
|
||||
SkeletonEditEdgeItem *edgeItem = static_cast<SkeletonEditEdgeItem *>(*it);
|
||||
if (edgeItem->firstNode() == nodeItem || edgeItem->secondNode() == nodeItem) {
|
||||
scene()->removeItem(edgeItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SkeletonEditGraphicsView::removeGroupByNodeItem(SkeletonEditNodeItem *nodeItem)
|
||||
{
|
||||
if (nodeItem->pair()) {
|
||||
scene()->removeItem(nodeItem->pair());
|
||||
}
|
||||
scene()->removeItem(nodeItem);
|
||||
QList<QGraphicsItem *>::iterator it;
|
||||
QList<QGraphicsItem *> list = scene()->items();
|
||||
std::vector<SkeletonEditNodeItem *> delayRemoveList;
|
||||
for (it = list.begin(); it != list.end(); ++it) {
|
||||
if ((*it)->data(0).toString() == "edge") {
|
||||
SkeletonEditEdgeItem *edgeItem = static_cast<SkeletonEditEdgeItem *>(*it);
|
||||
if (edgeItem->firstNode() == nodeItem) {
|
||||
scene()->removeItem(edgeItem);
|
||||
delayRemoveList.push_back(edgeItem->secondNode());
|
||||
} else if (edgeItem->secondNode() == nodeItem) {
|
||||
scene()->removeItem(edgeItem);
|
||||
delayRemoveList.push_back(edgeItem->firstNode());
|
||||
}
|
||||
}
|
||||
}
|
||||
for (size_t i = 0; i < delayRemoveList.size(); i++) {
|
||||
removeNodeItem(delayRemoveList[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void SkeletonEditGraphicsView::keyPressEvent(QKeyEvent *event)
|
||||
{
|
||||
QWidget::keyPressEvent(event);
|
||||
|
@ -123,6 +177,9 @@ void SkeletonEditGraphicsView::keyPressEvent(QKeyEvent *event)
|
|||
return;
|
||||
if (event->key() == Qt::Key_A)
|
||||
toggleAddNodeMode();
|
||||
else if (event->key() == Qt::Key_Delete || event->key() ==Qt::Key_Backspace) {
|
||||
removeSelectedItems();
|
||||
}
|
||||
}
|
||||
|
||||
void SkeletonEditGraphicsView::resizeEvent(QResizeEvent *event)
|
||||
|
|
|
@ -55,6 +55,9 @@ private:
|
|||
void AddItemRadius(QGraphicsEllipseItem *item, float delta);
|
||||
bool canAddItemRadius(QGraphicsEllipseItem *item, float delta);
|
||||
void adjustItems(QSizeF oldSceneSize, QSizeF newSceneSize);
|
||||
void removeSelectedItems();
|
||||
void removeNodeItem(SkeletonEditNodeItem *nodeItem);
|
||||
void removeGroupByNodeItem(SkeletonEditNodeItem *nodeItem);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -267,7 +267,7 @@ Mesh *SkeletonToMesh::takeResultMesh()
|
|||
return mesh;
|
||||
}
|
||||
|
||||
#define USE_CARVE 0
|
||||
#define USE_CARVE 1
|
||||
|
||||
#if USE_CARVE
|
||||
#define ExternalMesh carve::poly::Polyhedron
|
||||
|
@ -342,7 +342,6 @@ void SkeletonToMesh::process()
|
|||
meshlite_bmesh_add_edge(context, group->bmeshId, firstNode->bmeshNodeId, secondNode->bmeshNodeId);
|
||||
}
|
||||
group->meshId = meshlite_bmesh_generate_mesh(context, group->bmeshId, group->nodes[group->rootNode].bmeshNodeId);
|
||||
group->meshId = meshlite_triangulate(context, group->meshId);
|
||||
}
|
||||
|
||||
ExternalMesh *unionPolyhedron = makeExternalMeshFromMeshlite(context, m_groups[0].meshId);
|
||||
|
|
Loading…
Reference in New Issue