[TD]detect breakObject inside Body
This commit is contained in:
@@ -412,7 +412,6 @@ bool DrawBrokenView::isBreakObject(const App::DocumentObject& breakObj)
|
||||
//! horizontal or vertical
|
||||
bool DrawBrokenView::isBreakObjectSketch(const App::DocumentObject& breakObj)
|
||||
{
|
||||
// Base::Console().Message("DBV::isBreakObjectSketch()\n");
|
||||
TopoDS_Shape locShape = ShapeExtractor::getLocatedShape(&breakObj);
|
||||
if (locShape.IsNull()) {
|
||||
return false;
|
||||
|
||||
@@ -545,12 +545,14 @@ void CmdTechDrawBrokenView::activated(int iMsg)
|
||||
std::vector<App::DocumentObject*> xShapesFromBase;
|
||||
std::vector<App::DocumentObject*> baseViews =
|
||||
getSelection().getObjectsOfType(TechDraw::DrawViewPart::getClassTypeId());
|
||||
TechDraw::DrawViewPart* dvp{nullptr};
|
||||
if (!baseViews.empty()) {
|
||||
TechDraw::DrawViewPart* dvp = static_cast<TechDraw::DrawViewPart*>(*baseViews.begin());
|
||||
dvp = static_cast<TechDraw::DrawViewPart*>(*baseViews.begin());
|
||||
shapesFromBase = dvp->Source.getValues();
|
||||
xShapesFromBase = dvp->XSource.getValues();
|
||||
}
|
||||
|
||||
|
||||
// get the shape objects from the selection
|
||||
std::vector<App::DocumentObject*> shapes;
|
||||
std::vector<App::DocumentObject*> xShapes;
|
||||
@@ -560,13 +562,14 @@ void CmdTechDrawBrokenView::activated(int iMsg)
|
||||
shapes.insert(shapes.end(), shapesFromBase.begin(), shapesFromBase.end());
|
||||
shapes.insert(xShapes.end(), xShapesFromBase.begin(), xShapesFromBase.end());
|
||||
|
||||
if (shapes.empty() &&
|
||||
xShapes.empty()) {
|
||||
if (!dvp || (shapes.empty() && xShapes.empty())) {
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Empty selection"),
|
||||
QObject::tr("Please select objects to break or a base view and break definition objects."));
|
||||
return;
|
||||
}
|
||||
|
||||
auto doc = dvp->getDocument();
|
||||
|
||||
// pick the Break objects out of the selected pile
|
||||
std::vector<Gui::SelectionObject> selection = getSelection().getSelectionEx(
|
||||
nullptr, App::DocumentObject::getClassTypeId(), Gui::ResolveMode::NoResolve);
|
||||
@@ -574,8 +577,26 @@ void CmdTechDrawBrokenView::activated(int iMsg)
|
||||
std::vector<App::DocumentObject*> breakObjects;
|
||||
for (auto& selObj : selection) {
|
||||
auto temp = selObj.getObject();
|
||||
if (DrawBrokenView::isBreakObject(*temp)) {
|
||||
breakObjects.push_back(selObj.getObject());
|
||||
// a sketch outside a body is returned as an independent object in the selection
|
||||
if (selObj.getSubNames().empty()) {
|
||||
if (DrawBrokenView::isBreakObject(*temp)) {
|
||||
breakObjects.push_back(selObj.getObject());
|
||||
}
|
||||
continue;
|
||||
}
|
||||
// a sketch inside a body is returned as body + subelement, so we have to search through
|
||||
// subnames to find it. This may(?) apply to App::Part and Group also?
|
||||
auto subname = selObj.getSubNames().front();
|
||||
if (subname.back() == '.') {
|
||||
subname = subname.substr(0, subname.length() - 1);
|
||||
auto objects = doc->getObjects();
|
||||
for (auto& obj : objects) {
|
||||
std::string objname{obj->getNameInDocument()};
|
||||
if (subname == objname &&
|
||||
DrawBrokenView::isBreakObject(*obj)) {
|
||||
breakObjects.push_back(obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (breakObjects.empty()) {
|
||||
@@ -628,8 +649,6 @@ void CmdTechDrawBrokenView::activated(int iMsg)
|
||||
|
||||
commitCommand();
|
||||
|
||||
// Gui::Control().showDialog(new TaskDlgBrokenView(dbv));
|
||||
|
||||
dbv->recomputeFeature();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user