Fix search for subShapes

- this is mainly for Arch objects. the search for shapes
  is more difficult.
This commit is contained in:
wandererfan
2019-04-01 20:27:08 -04:00
committed by WandererFan
parent 4492576c6b
commit 3beb18b256

View File

@@ -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<TopoDS_Shape> DrawViewPart::getShapesFromObject(App::DocumentObject*
{
std::vector<TopoDS_Shape> result;
App::GroupExtension* gex = dynamic_cast<App::GroupExtension*>(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<Part::Feature*>(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<App::DocumentObject*> objs = gex->Group.getValues();
std::vector<TopoDS_Shape> shapes;
for (auto& d: objs) {
@@ -216,6 +221,29 @@ std::vector<TopoDS_Shape> 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<App::PropertyLinkList*>(gProp);
if (list != nullptr) {
std::vector<App::DocumentObject*> objs = list->getValues();
std::vector<TopoDS_Shape> 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<Part::PropertyPartShape*>(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<App::DocumentObject*>& 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)
{