Skip to content

Commit

Permalink
remove the built-in tree widget from the tessellation task panel
Browse files Browse the repository at this point in the history
  • Loading branch information
wwmayer committed Oct 13, 2019
1 parent c98549a commit 1f5f00e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 44 deletions.
38 changes: 13 additions & 25 deletions src/Mod/MeshPart/Gui/Tessellation.cpp
Expand Up @@ -105,7 +105,6 @@ Tessellation::Tessellation(QWidget* parent)
}

meshingMethod(buttonGroup->checkedId());
findShapes();
}

Tessellation::~Tessellation()
Expand Down Expand Up @@ -183,18 +182,18 @@ void Tessellation::changeEvent(QEvent *e)
QWidget::changeEvent(e);
}

void Tessellation::findShapes()
std::list<App::DocumentObjectT> Tessellation::findShapes()
{
std::list<App::DocumentObjectT> 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<Part::Feature*> objs = activeDoc->getObjectsOfType<Part::Feature>();

double edgeLen = 0;
bool foundSelection = false;
for (std::vector<Part::Feature*>::iterator it = objs.begin(); it!=objs.end(); ++it) {
const TopoDS_Shape& shape = (*it)->Shape.getValue();
if (shape.IsNull()) continue;
Expand All @@ -210,31 +209,22 @@ void Tessellation::findShapes()
edgeLen = std::max<double>(edgeLen, bbox.LengthX());
edgeLen = std::max<double>(edgeLen, bbox.LengthY());
edgeLen = std::max<double>(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<App::DocumentObjectT> shapeObjects = findShapes();
if (shapeObjects.empty()) {
QMessageBox::critical(this, windowTitle(),
tr("Select a shape for meshing, first."));
return false;
Expand Down Expand Up @@ -266,11 +256,9 @@ bool Tessellation::accept()
}

activeDoc->openTransaction("Meshing");
QList<QTreeWidgetItem *> items = ui->treeWidget->selectedItems();
std::vector<Part::Feature*> shapes = Gui::Selection().getObjectsOfType<Part::Feature>();
for (QList<QTreeWidgetItem *>::iterator it = items.begin(); it != items.end(); ++it) {
shape = (*it)->data(0, Qt::UserRole).toString();
label = (*it)->text(0);
for (std::list<App::DocumentObjectT>::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
Expand Down
3 changes: 2 additions & 1 deletion src/Mod/MeshPart/Gui/Tessellation.h
Expand Up @@ -27,6 +27,7 @@
#include <Gui/TaskView/TaskDialog.h>
#include <Gui/TaskView/TaskView.h>
#include <Gui/Selection.h>
#include <App/DocumentObserver.h>
#include <memory>

class QButtonGroup;
Expand All @@ -47,7 +48,7 @@ class Tessellation : public QWidget
void changeEvent(QEvent *e);

private:
void findShapes();
std::list<App::DocumentObjectT> findShapes();

private Q_SLOTS:
void meshingMethod(int id);
Expand Down
18 changes: 0 additions & 18 deletions src/Mod/MeshPart/Gui/Tessellation.ui
Expand Up @@ -15,21 +15,6 @@
</property>
<layout class="QGridLayout" name="gridLayout_7">
<item row="0" column="0">
<widget class="QTreeWidget" name="treeWidget">
<property name="toolTip">
<string>Select a shape to be meshed</string>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::ExtendedSelection</enum>
</property>
<column>
<property name="text">
<string>Shapes</string>
</property>
</column>
</widget>
</item>
<item row="1" column="0">
<widget class="QGroupBox" name="groupBoxMeshingOptions">
<property name="title">
<string>Meshing options</string>
Expand Down Expand Up @@ -448,9 +433,6 @@ A value in the range of 0.2-10.</string>
<header>Gui/QuantitySpinBox.h</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>treeWidget</tabstop>
</tabstops>
<resources/>
<connections>
<connection>
Expand Down

0 comments on commit 1f5f00e

Please sign in to comment.