diff --git a/src/Mod/MeshPart/Gui/Tessellation.cpp b/src/Mod/MeshPart/Gui/Tessellation.cpp index 590d9106968c..a70081cc9a69 100644 --- a/src/Mod/MeshPart/Gui/Tessellation.cpp +++ b/src/Mod/MeshPart/Gui/Tessellation.cpp @@ -105,7 +105,6 @@ Tessellation::Tessellation(QWidget* parent) } meshingMethod(buttonGroup->checkedId()); - findShapes(); } Tessellation::~Tessellation() @@ -183,18 +182,18 @@ void Tessellation::changeEvent(QEvent *e) QWidget::changeEvent(e); } -void Tessellation::findShapes() +std::list Tessellation::findShapes() { + std::list shapeObjects; App::Document* activeDoc = App::GetApplication().getActiveDocument(); - if (!activeDoc) return; + if (!activeDoc) return shapeObjects; Gui::Document* activeGui = Gui::Application::Instance->getDocument(activeDoc); - if (!activeGui) return; + if (!activeGui) return shapeObjects; this->document = QString::fromLatin1(activeDoc->getName()); std::vector objs = activeDoc->getObjectsOfType(); double edgeLen = 0; - bool foundSelection = false; for (std::vector::iterator it = objs.begin(); it!=objs.end(); ++it) { const TopoDS_Shape& shape = (*it)->Shape.getValue(); if (shape.IsNull()) continue; @@ -210,31 +209,22 @@ void Tessellation::findShapes() edgeLen = std::max(edgeLen, bbox.LengthX()); edgeLen = std::max(edgeLen, bbox.LengthY()); edgeLen = std::max(edgeLen, bbox.LengthZ()); - QString label = QString::fromUtf8((*it)->Label.getValue()); - QString name = QString::fromLatin1((*it)->getNameInDocument()); - - QTreeWidgetItem* child = new QTreeWidgetItem(); - child->setText(0, label); - child->setToolTip(0, label); - child->setData(0, Qt::UserRole, name); - Gui::ViewProvider* vp = activeGui->getViewProvider(*it); - if (vp) child->setIcon(0, vp->getIcon()); - ui->treeWidget->addTopLevelItem(child); + if (Gui::Selection().isSelected(*it)) { - child->setSelected(true); - foundSelection = true; + App::DocumentObjectT objT(*it); + shapeObjects.push_back(objT); } } } ui->spinMaximumEdgeLength->setValue(edgeLen/10); - if (foundSelection) - ui->treeWidget->hide(); + return shapeObjects; } bool Tessellation::accept() { - if (ui->treeWidget->selectedItems().isEmpty()) { + std::list shapeObjects = findShapes(); + if (shapeObjects.empty()) { QMessageBox::critical(this, windowTitle(), tr("Select a shape for meshing, first.")); return false; @@ -266,11 +256,9 @@ bool Tessellation::accept() } activeDoc->openTransaction("Meshing"); - QList items = ui->treeWidget->selectedItems(); - std::vector shapes = Gui::Selection().getObjectsOfType(); - for (QList::iterator it = items.begin(); it != items.end(); ++it) { - shape = (*it)->data(0, Qt::UserRole).toString(); - label = (*it)->text(0); + for (std::list::iterator it = shapeObjects.begin(); it != shapeObjects.end(); ++it) { + shape = QString::fromLatin1(it->getObjectName().c_str()); + label = QString::fromUtf8(it->getObjectLabel().c_str()); QString cmd; if (method == 0) { // Standard diff --git a/src/Mod/MeshPart/Gui/Tessellation.h b/src/Mod/MeshPart/Gui/Tessellation.h index c394fc3d31a8..8b4316a3302d 100644 --- a/src/Mod/MeshPart/Gui/Tessellation.h +++ b/src/Mod/MeshPart/Gui/Tessellation.h @@ -27,6 +27,7 @@ #include #include #include +#include #include class QButtonGroup; @@ -47,7 +48,7 @@ class Tessellation : public QWidget void changeEvent(QEvent *e); private: - void findShapes(); + std::list findShapes(); private Q_SLOTS: void meshingMethod(int id); diff --git a/src/Mod/MeshPart/Gui/Tessellation.ui b/src/Mod/MeshPart/Gui/Tessellation.ui index 64dd30c95cf2..1eeab865fd2a 100644 --- a/src/Mod/MeshPart/Gui/Tessellation.ui +++ b/src/Mod/MeshPart/Gui/Tessellation.ui @@ -15,21 +15,6 @@ - - - Select a shape to be meshed - - - QAbstractItemView::ExtendedSelection - - - - Shapes - - - - - Meshing options @@ -448,9 +433,6 @@ A value in the range of 0.2-10.
Gui/QuantitySpinBox.h
- - treeWidget -