diff --git a/src/Mod/Mesh/Gui/Command.cpp b/src/Mod/Mesh/Gui/Command.cpp index e4e3eafec7f5..eb93c3dec620 100644 --- a/src/Mod/Mesh/Gui/Command.cpp +++ b/src/Mod/Mesh/Gui/Command.cpp @@ -1280,6 +1280,7 @@ void CmdMeshRemoveCompByHand::activated(int) viewer->setEditing(true); viewer->setEditingCursor(QCursor(Qt::OpenHandCursor)); viewer->addEventCallback(SoMouseButtonEvent::getClassTypeId(), MeshGui::ViewProviderMeshFaceSet::markPartCallback); + viewer->setSelectionEnabled(false); } } @@ -1595,6 +1596,7 @@ void CmdMeshFillInteractiveHole::activated(int) viewer->setEditing(true); viewer->setEditingCursor(QCursor(Gui::BitmapFactory().pixmap("mesh_fillhole"),5,5)); viewer->addEventCallback(SoMouseButtonEvent::getClassTypeId(), MeshGui::ViewProviderMeshFaceSet::fillHoleCallback); + viewer->setSelectionEnabled(false); } } diff --git a/src/Mod/Mesh/Gui/DlgSmoothing.cpp b/src/Mod/Mesh/Gui/DlgSmoothing.cpp index eed3829b4329..97ff13651e12 100644 --- a/src/Mod/Mesh/Gui/DlgSmoothing.cpp +++ b/src/Mod/Mesh/Gui/DlgSmoothing.cpp @@ -149,6 +149,7 @@ TaskSmoothing::TaskSmoothing() selection = new Selection(); selection->setObjects(Gui::Selection().getSelectionEx(0, Mesh::Feature::getClassTypeId())); + Gui::Selection().clearSelection(); #if !defined (QSINT_ACTIONPANEL) Gui::TaskView::TaskGroup* tasksel = new Gui::TaskView::TaskGroup(); #else diff --git a/src/Mod/Mesh/Gui/MeshEditor.cpp b/src/Mod/Mesh/Gui/MeshEditor.cpp index 4e759d754de5..a7f1723deb1a 100644 --- a/src/Mod/Mesh/Gui/MeshEditor.cpp +++ b/src/Mod/Mesh/Gui/MeshEditor.cpp @@ -195,6 +195,7 @@ void MeshFaceAddition::startEditing(MeshGui::ViewProviderMesh* vp) Gui::View3DInventor* view = static_cast(parent()); Gui::View3DInventorViewer* viewer = view->getViewer(); viewer->setEditing(true); + viewer->setSelectionEnabled(false); viewer->setRedirectToSceneGraph(true); viewer->setRedirectToSceneGraphEnabled(true); @@ -211,6 +212,7 @@ void MeshFaceAddition::finishEditing() Gui::View3DInventor* view = static_cast(parent()); Gui::View3DInventorViewer* viewer = view->getViewer(); viewer->setEditing(false); + viewer->setSelectionEnabled(true); viewer->setRedirectToSceneGraph(false); viewer->setRedirectToSceneGraphEnabled(false); diff --git a/src/Mod/Mesh/Gui/MeshSelection.cpp b/src/Mod/Mesh/Gui/MeshSelection.cpp index 3a4fa01baa52..8811efdee129 100644 --- a/src/Mod/Mesh/Gui/MeshSelection.cpp +++ b/src/Mod/Mesh/Gui/MeshSelection.cpp @@ -97,6 +97,14 @@ MeshSelection::~MeshSelection() } } +void MeshSelection::setEnabledViewerSelection(bool on) +{ + Gui::View3DInventorViewer* viewer = this->getViewer(); + if (viewer) { + viewer->setSelectionEnabled(on); + } +} + void MeshSelection::setCallback(SoEventCallbackCB *cb) { selectionCB = cb; diff --git a/src/Mod/Mesh/Gui/MeshSelection.h b/src/Mod/Mesh/Gui/MeshSelection.h index 9d5bcc9212ba..53bcef99b7b8 100644 --- a/src/Mod/Mesh/Gui/MeshSelection.h +++ b/src/Mod/Mesh/Gui/MeshSelection.h @@ -45,6 +45,8 @@ class MeshGuiExport MeshSelection MeshSelection(); ~MeshSelection(); + void setEnabledViewerSelection(bool); + void startSelection(); void startDeselection(); void stopSelection(); diff --git a/src/Mod/Mesh/Gui/RemoveComponents.cpp b/src/Mod/Mesh/Gui/RemoveComponents.cpp index b3755271520d..1ffc8a2be3b5 100644 --- a/src/Mod/Mesh/Gui/RemoveComponents.cpp +++ b/src/Mod/Mesh/Gui/RemoveComponents.cpp @@ -31,6 +31,7 @@ #include "ui_RemoveComponents.h" #include #include +#include using namespace MeshGui; @@ -45,8 +46,10 @@ RemoveComponents::RemoveComponents(QWidget* parent, Qt::WindowFlags fl) ui->spDeselectComp->setRange(1, INT_MAX); ui->spDeselectComp->setValue(10); + Gui::Selection().clearSelection(); meshSel.setCheckOnlyVisibleTriangles(ui->visibleTriangles->isChecked()); meshSel.setCheckOnlyPointToUserTriangles(ui->screenTriangles->isChecked()); + meshSel.setEnabledViewerSelection(false); } RemoveComponents::~RemoveComponents() @@ -153,6 +156,7 @@ void RemoveComponents::reject() { // deselect all meshes meshSel.clearSelection(); + meshSel.setEnabledViewerSelection(true); } // ------------------------------------------------- diff --git a/src/Mod/Mesh/Gui/SegmentationBestFit.cpp b/src/Mod/Mesh/Gui/SegmentationBestFit.cpp index 0e04012b3ad7..212f7fd28b63 100644 --- a/src/Mod/Mesh/Gui/SegmentationBestFit.cpp +++ b/src/Mod/Mesh/Gui/SegmentationBestFit.cpp @@ -197,14 +197,17 @@ ParametersDialog::ParametersDialog(std::vector& val, FitParameter* fitPar Gui::SelectionObject obj(mesh); std::vector sel; sel.push_back(obj); + Gui::Selection().clearSelection(); meshSel.setObjects(sel); meshSel.setCheckOnlyPointToUserTriangles(true); meshSel.setCheckOnlyVisibleTriangles(true); + meshSel.setEnabledViewerSelection(false); } ParametersDialog::~ParametersDialog() { meshSel.clearSelection(); + meshSel.setEnabledViewerSelection(true); delete fitParameter; } diff --git a/src/Mod/Mesh/Gui/Selection.cpp b/src/Mod/Mesh/Gui/Selection.cpp index ae6e1aeaf2f0..eb87787412b6 100644 --- a/src/Mod/Mesh/Gui/Selection.cpp +++ b/src/Mod/Mesh/Gui/Selection.cpp @@ -41,6 +41,7 @@ Selection::Selection(QWidget* parent) meshSel.setCheckOnlyVisibleTriangles(ui->visibleTriangles->isChecked()); meshSel.setCheckOnlyPointToUserTriangles(ui->screenTriangles->isChecked()); + meshSel.setEnabledViewerSelection(false); } /* @@ -51,6 +52,7 @@ Selection::~Selection() // no need to delete child widgets, Qt does it all for us delete ui; meshSel.clearSelection(); + meshSel.setEnabledViewerSelection(true); } void Selection::setObjects(const std::vector& o) diff --git a/src/Mod/Mesh/Gui/ViewProvider.cpp b/src/Mod/Mesh/Gui/ViewProvider.cpp index 431c0b64d03e..9cb1020c409a 100644 --- a/src/Mod/Mesh/Gui/ViewProvider.cpp +++ b/src/Mod/Mesh/Gui/ViewProvider.cpp @@ -314,8 +314,9 @@ ViewProviderMesh::ViewProviderMesh() : pcOpenEdge(0) CreaseAngle.setValue(angle); } - if (hGrp->GetBool("ShowBoundingBox", false)) + if (hGrp->GetBool("ShowBoundingBox", false)) { SelectionStyle.setValue(1); + } Coloring.setStatus(App::Property::Hidden, true); } @@ -371,8 +372,8 @@ void ViewProviderMesh::onChanged(const App::Property* prop) tryColorPerVertexOrFace(Coloring.getValue()); } else if (prop == &SelectionStyle) { - pcHighlight->style = SelectionStyle.getValue() - ?Gui::SoFCSelection::BOX:Gui::SoFCSelection::EMISSIVE; + pcHighlight->style = SelectionStyle.getValue() ? Gui::SoFCSelection::BOX + : Gui::SoFCSelection::EMISSIVE; } else { // Set the inverse color for open edges @@ -1582,6 +1583,7 @@ void ViewProviderMesh::fillHoleCallback(void * ud, SoEventCallback * n) QAction* id = menu.exec(QCursor::pos()); if (cl == id) { view->setEditing(false); + view->setSelectionEnabled(true); view->getWidget()->setCursor(QCursor(Qt::ArrowCursor)); view->removeEventCallback(SoMouseButtonEvent::getClassTypeId(), fillHoleCallback,ud); } @@ -1629,6 +1631,7 @@ void ViewProviderMesh::markPartCallback(void * ud, SoEventCallback * n) QAction* id = menu.exec(QCursor::pos()); if (cl == id) { view->setEditing(false); + view->setSelectionEnabled(true); view->removeEventCallback(SoMouseButtonEvent::getClassTypeId(), markPartCallback,ud); std::vector views = view->getViewProvidersOfType(ViewProviderMesh::getClassTypeId());