From 827f6c420e8945ee4144f1b99bbc241db24b9dcc Mon Sep 17 00:00:00 2001 From: wandererfan Date: Mon, 1 Apr 2019 20:27:08 -0400 Subject: [PATCH] Fix search for subShapes - this is mainly for Arch objects. the search for shapes is more difficult. --- src/Mod/TechDraw/App/DrawViewPart.cpp | 45 ++++++++++++++++++++------- 1 file changed, 33 insertions(+), 12 deletions(-) diff --git a/src/Mod/TechDraw/App/DrawViewPart.cpp b/src/Mod/TechDraw/App/DrawViewPart.cpp index a8655501a4..620df235e6 100644 --- a/src/Mod/TechDraw/App/DrawViewPart.cpp +++ b/src/Mod/TechDraw/App/DrawViewPart.cpp @@ -190,8 +190,11 @@ TopoDS_Shape DrawViewPart::getSourceShape(void) const TopoDS_Shape shape = BuilderCopy.Shape(); builder.Add(comp, shape); } - //it appears that an empty compound is !IsNull(), so we need to check if we added anything to the compound. - if (found) { + //it appears that an empty compound is !IsNull(), so we need to check a different way + //if we added anything to the compound. + if (!found) { + Base::Console().Error("DVP::getSourceShapes - source shape is empty!\n"); + } else { result = comp; } } @@ -202,12 +205,14 @@ std::vector DrawViewPart::getShapesFromObject(App::DocumentObject* { std::vector result; App::GroupExtension* gex = dynamic_cast(docObj); + App::Property* gProp = docObj->getPropertyByName("Group"); + App::Property* sProp = docObj->getPropertyByName("Shape"); if (docObj->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) { Part::Feature* pf = static_cast(docObj); Part::TopoShape ts = pf->Shape.getShape(); ts.setPlacement(pf->globalPlacement()); result.push_back(ts.getShape()); - } else if (gex != nullptr) { + } else if (gex != nullptr) { //is a group extension std::vector objs = gex->Group.getValues(); std::vector shapes; for (auto& d: objs) { @@ -216,6 +221,29 @@ std::vector DrawViewPart::getShapesFromObject(App::DocumentObject* result.insert(result.end(),shapes.begin(),shapes.end()); } } + //the next 2 bits are mostly for Arch module objects + } else if (gProp != nullptr) { //has a Group property + App::PropertyLinkList* list = dynamic_cast(gProp); + if (list != nullptr) { + std::vector objs = list->getValues(); + std::vector shapes; + for (auto& d: objs) { + shapes = getShapesFromObject(d); + if (!shapes.empty()) { + result.insert(result.end(),shapes.begin(),shapes.end()); + } + } + } else { + Base::Console().Log("DVP::getShapesFromObject - Group is not a PropertyLinkList!\n"); + } + } else if (sProp != nullptr) { //has a Shape property + Part::PropertyPartShape* shape = dynamic_cast(sProp); + if (shape != nullptr) { + TopoDS_Shape occShape = shape->getValue(); + result.push_back(occShape); + } else { + Base::Console().Log("DVP::getShapesFromObject - Shape is not a PropertyPartShape!\n"); + } } return result; } @@ -244,14 +272,13 @@ TopoDS_Shape DrawViewPart::getSourceShapeFused(void) const App::DocumentObjectExecReturn *DrawViewPart::execute(void) { -// Base::Console().Message("DVP::execute() - %s\n",getNameInDocument()); if (!keepUpdated()) { return App::DocumentObject::StdReturn; } - + App::Document* doc = getDocument(); + bool isRestoring = doc->testStatus(App::Document::Status::Restoring); const std::vector& links = Source.getValues(); if (links.empty()) { - bool isRestoring = getDocument()->testStatus(App::Document::Status::Restoring); if (isRestoring) { Base::Console().Warning("DVP::execute - No Sources (but document is restoring) - %s\n", getNameInDocument()); @@ -264,7 +291,6 @@ App::DocumentObjectExecReturn *DrawViewPart::execute(void) TopoDS_Shape shape = getSourceShape(); //if shape is null, it is probably(?) obj creation time. if (shape.IsNull()) { - bool isRestoring = getDocument()->testStatus(App::Document::Status::Restoring); if (isRestoring) { Base::Console().Warning("DVP::execute - source shape is invalid - (but document is restoring) - %s\n", getNameInDocument()); @@ -353,11 +379,6 @@ void DrawViewPart::onChanged(const App::Property* prop) //TODO: when scale changes, any Dimensions for this View sb recalculated. DVD should pick this up subject to topological naming issues. } -//void DrawViewPart::onDocumentRestored() -//{ -// m_restoreComplete = true; -//} - //note: slightly different than routine with same name in DrawProjectSplit TechDrawGeometry::GeometryObject* DrawViewPart::buildGeometryObject(TopoDS_Shape shape, gp_Ax2 viewAxis) {