Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
+ fixes #1266: Part Common fails with two surface objects
  • Loading branch information
wwmayer committed Jan 16, 2014
1 parent 795bd01 commit 0869815
Showing 1 changed file with 24 additions and 12 deletions.
36 changes: 24 additions & 12 deletions src/Mod/Part/Gui/Command.cpp
Expand Up @@ -274,14 +274,18 @@ void CmdPartCut::activated(int iMsg)
return;
}

bool askUser = false;
for (std::vector<Gui::SelectionObject>::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<Part::Feature*>(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;
}
}
}
Expand Down Expand Up @@ -333,6 +337,7 @@ void CmdPartCommon::activated(int iMsg)
return;
}

bool askUser = false;
std::string FeatName = getUniqueObjectName("Common");
std::stringstream str;
std::vector<std::string> tempSelNames;
Expand All @@ -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<Part::Feature*>(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());
Expand Down Expand Up @@ -394,6 +402,7 @@ void CmdPartFuse::activated(int iMsg)
return;
}

bool askUser = false;
std::string FeatName = getUniqueObjectName("Fusion");
std::stringstream str;
std::vector<std::string> tempSelNames;
Expand All @@ -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<Part::Feature*>(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());
Expand Down

0 comments on commit 0869815

Please sign in to comment.