Add node delete operation
parent
de0fa135fb
commit
24fbff4218
|
@ -1,6 +1,7 @@
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QDesktopWidget>
|
#include <QDesktopWidget>
|
||||||
#include <QStyleFactory>
|
#include <QStyleFactory>
|
||||||
|
#include <QFontDatabase>
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "meshlite.h"
|
#include "meshlite.h"
|
||||||
|
|
||||||
|
@ -30,6 +31,9 @@ int main(int argc, char ** argv)
|
||||||
|
|
||||||
QCoreApplication::setApplicationName("Dust 3D");
|
QCoreApplication::setApplicationName("Dust 3D");
|
||||||
|
|
||||||
|
const QFont fixedFont = QFontDatabase::systemFont(QFontDatabase::FixedFont);
|
||||||
|
QApplication::setFont(fixedFont);
|
||||||
|
|
||||||
MainWindow mainWindow;
|
MainWindow mainWindow;
|
||||||
mainWindow.showMaximized();
|
mainWindow.showMaximized();
|
||||||
return app.exec();
|
return app.exec();
|
||||||
|
|
|
@ -149,6 +149,7 @@ void MainWindow::loadModel()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
m_skeletonWidget->graphicsView()->turnOffAddNodeMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::saveModel()
|
void MainWindow::saveModel()
|
||||||
|
|
|
@ -116,6 +116,60 @@ float SkeletonEditGraphicsView::findXForSlave(float x)
|
||||||
return x - m_backgroundItem->boundingRect().width() / 4;
|
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)
|
void SkeletonEditGraphicsView::keyPressEvent(QKeyEvent *event)
|
||||||
{
|
{
|
||||||
QWidget::keyPressEvent(event);
|
QWidget::keyPressEvent(event);
|
||||||
|
@ -123,6 +177,9 @@ void SkeletonEditGraphicsView::keyPressEvent(QKeyEvent *event)
|
||||||
return;
|
return;
|
||||||
if (event->key() == Qt::Key_A)
|
if (event->key() == Qt::Key_A)
|
||||||
toggleAddNodeMode();
|
toggleAddNodeMode();
|
||||||
|
else if (event->key() == Qt::Key_Delete || event->key() ==Qt::Key_Backspace) {
|
||||||
|
removeSelectedItems();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SkeletonEditGraphicsView::resizeEvent(QResizeEvent *event)
|
void SkeletonEditGraphicsView::resizeEvent(QResizeEvent *event)
|
||||||
|
|
|
@ -55,6 +55,9 @@ private:
|
||||||
void AddItemRadius(QGraphicsEllipseItem *item, float delta);
|
void AddItemRadius(QGraphicsEllipseItem *item, float delta);
|
||||||
bool canAddItemRadius(QGraphicsEllipseItem *item, float delta);
|
bool canAddItemRadius(QGraphicsEllipseItem *item, float delta);
|
||||||
void adjustItems(QSizeF oldSceneSize, QSizeF newSceneSize);
|
void adjustItems(QSizeF oldSceneSize, QSizeF newSceneSize);
|
||||||
|
void removeSelectedItems();
|
||||||
|
void removeNodeItem(SkeletonEditNodeItem *nodeItem);
|
||||||
|
void removeGroupByNodeItem(SkeletonEditNodeItem *nodeItem);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -267,7 +267,7 @@ Mesh *SkeletonToMesh::takeResultMesh()
|
||||||
return mesh;
|
return mesh;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define USE_CARVE 0
|
#define USE_CARVE 1
|
||||||
|
|
||||||
#if USE_CARVE
|
#if USE_CARVE
|
||||||
#define ExternalMesh carve::poly::Polyhedron
|
#define ExternalMesh carve::poly::Polyhedron
|
||||||
|
@ -342,7 +342,6 @@ void SkeletonToMesh::process()
|
||||||
meshlite_bmesh_add_edge(context, group->bmeshId, firstNode->bmeshNodeId, secondNode->bmeshNodeId);
|
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_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);
|
ExternalMesh *unionPolyhedron = makeExternalMeshFromMeshlite(context, m_groups[0].meshId);
|
||||||
|
|
Loading…
Reference in New Issue