From 08698154c8acdfd22e687d6650e6aa023c9c71ba Mon Sep 17 00:00:00 2001 From: wmayer Date: Thu, 16 Jan 2014 14:04:19 +0100 Subject: [PATCH] + fixes #0001266: Part Common fails with two surface objects --- src/Mod/Part/Gui/Command.cpp | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/src/Mod/Part/Gui/Command.cpp b/src/Mod/Part/Gui/Command.cpp index 65df59e90937..1e47742d36d9 100644 --- a/src/Mod/Part/Gui/Command.cpp +++ b/src/Mod/Part/Gui/Command.cpp @@ -274,14 +274,18 @@ void CmdPartCut::activated(int iMsg) return; } + bool askUser = false; for (std::vector::iterator it = Sel.begin(); it != Sel.end(); ++it) { App::DocumentObject* obj = it->getObject(); if (obj->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) { const TopoDS_Shape& shape = static_cast(obj)->Shape.getValue(); - if (!PartGui::checkForSolids(shape)) { - QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"), - QObject::tr("Non-solids cannot be used for boolean operations.")); - return; + if (!PartGui::checkForSolids(shape) && !askUser) { + int ret = QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Non-solids selected"), + QObject::tr("The use of non-solids for boolean operations may lead to unexpected results.\n" + "Do you want to continue?"), QMessageBox::Yes, QMessageBox::No); + if (ret == QMessageBox::No) + return; + askUser = true; } } } @@ -333,6 +337,7 @@ void CmdPartCommon::activated(int iMsg) return; } + bool askUser = false; std::string FeatName = getUniqueObjectName("Common"); std::stringstream str; std::vector tempSelNames; @@ -341,10 +346,13 @@ void CmdPartCommon::activated(int iMsg) App::DocumentObject* obj = it->getObject(); if (obj->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) { const TopoDS_Shape& shape = static_cast(obj)->Shape.getValue(); - if (!PartGui::checkForSolids(shape)) { - QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"), - QObject::tr("Non-solids cannot be used for boolean operations.")); - return; + if (!PartGui::checkForSolids(shape) && !askUser) { + int ret = QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Non-solids selected"), + QObject::tr("The use of non-solids for boolean operations may lead to unexpected results.\n" + "Do you want to continue?"), QMessageBox::Yes, QMessageBox::No); + if (ret == QMessageBox::No) + return; + askUser = true; } str << "App.activeDocument()." << it->getFeatName() << ","; tempSelNames.push_back(it->getFeatName()); @@ -394,6 +402,7 @@ void CmdPartFuse::activated(int iMsg) return; } + bool askUser = false; std::string FeatName = getUniqueObjectName("Fusion"); std::stringstream str; std::vector tempSelNames; @@ -402,10 +411,13 @@ void CmdPartFuse::activated(int iMsg) App::DocumentObject* obj = it->getObject(); if (obj->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) { const TopoDS_Shape& shape = static_cast(obj)->Shape.getValue(); - if (!PartGui::checkForSolids(shape)) { - QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"), - QObject::tr("Non-solids cannot be used for boolean operations.")); - return; + if (!PartGui::checkForSolids(shape) && !askUser) { + int ret = QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Non-solids selected"), + QObject::tr("The use of non-solids for boolean operations may lead to unexpected results.\n" + "Do you want to continue?"), QMessageBox::Yes, QMessageBox::No); + if (ret == QMessageBox::No) + return; + askUser = true; } str << "App.activeDocument()." << it->getFeatName() << ","; tempSelNames.push_back(it->getFeatName());