Skip to content

Commit

Permalink
fix usability regression of Mefisto mesher cuased by 95f20b9
Browse files Browse the repository at this point in the history
The maximum edge length for the Mefisto mesher is always set in the accept() method so that effectively user input is always ignored.
There is now a button Estimate to guess a good default value. And user input is no longer ingored
  • Loading branch information
wwmayer committed Dec 10, 2019
1 parent d17b3c6 commit 36bd2f9
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 8 deletions.
37 changes: 29 additions & 8 deletions src/Mod/MeshPart/Gui/Tessellation.cpp
Expand Up @@ -193,23 +193,19 @@ struct ShapeInfo {
};
}

bool Tessellation::accept()
void Tessellation::on_estimateMaximumEdgeLength_clicked()
{
std::list<ShapeInfo> shapeObjects;
App::Document* activeDoc = App::GetApplication().getActiveDocument();
if (!activeDoc) {
QMessageBox::critical(this, windowTitle(), tr("No active document"));
return false;
return;
}

Gui::Document* activeGui = Gui::Application::Instance->getDocument(activeDoc);
if (!activeGui) {
QMessageBox::critical(this, windowTitle(), tr("No active document"));
return false;
return;
}

this->document = QString::fromLatin1(activeDoc->getName());

double edgeLen = 0;
for (auto &sel : Gui::Selection().getSelection("*",0)) {
auto shape = Part::Feature::getTopoShape(sel.pObject,sel.SubName);
Expand All @@ -218,11 +214,36 @@ bool Tessellation::accept()
edgeLen = std::max<double>(edgeLen, bbox.LengthX());
edgeLen = std::max<double>(edgeLen, bbox.LengthY());
edgeLen = std::max<double>(edgeLen, bbox.LengthZ());
shapeObjects.emplace_back(sel.pObject,sel.SubName);
shapeObjects.emplace_back(sel.pObject, sel.SubName);
}
}

ui->spinMaximumEdgeLength->setValue(edgeLen/10);
}

bool Tessellation::accept()
{
std::list<ShapeInfo> shapeObjects;
App::Document* activeDoc = App::GetApplication().getActiveDocument();
if (!activeDoc) {
QMessageBox::critical(this, windowTitle(), tr("No active document"));
return false;
}

Gui::Document* activeGui = Gui::Application::Instance->getDocument(activeDoc);
if (!activeGui) {
QMessageBox::critical(this, windowTitle(), tr("No active document"));
return false;
}

this->document = QString::fromLatin1(activeDoc->getName());

for (auto &sel : Gui::Selection().getSelection("*",0)) {
auto shape = Part::Feature::getTopoShape(sel.pObject,sel.SubName);
if (shape.hasSubShape(TopAbs_FACE)) {
shapeObjects.emplace_back(sel.pObject, sel.SubName);
}
}

if (shapeObjects.empty()) {
QMessageBox::critical(this, windowTitle(),
Expand Down
1 change: 1 addition & 0 deletions src/Mod/MeshPart/Gui/Tessellation.h
Expand Up @@ -49,6 +49,7 @@ class Tessellation : public QWidget

private Q_SLOTS:
void meshingMethod(int id);
void on_estimateMaximumEdgeLength_clicked();
void on_comboFineness_currentIndexChanged(int);
void on_checkSecondOrder_toggled(bool);
void on_checkQuadDominated_toggled(bool);
Expand Down
7 changes: 7 additions & 0 deletions src/Mod/MeshPart/Gui/Tessellation.ui
Expand Up @@ -195,6 +195,13 @@ The smallest value is 0.</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="estimateMaximumEdgeLength">
<property name="text">
<string>Estimate</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0">
Expand Down

0 comments on commit 36bd2f9

Please sign in to comment.