diff --git a/src/Mod/TechDraw/App/DrawViewDetail.cpp b/src/Mod/TechDraw/App/DrawViewDetail.cpp index 5214cd246f..f515d5ab7b 100644 --- a/src/Mod/TechDraw/App/DrawViewDetail.cpp +++ b/src/Mod/TechDraw/App/DrawViewDetail.cpp @@ -213,25 +213,13 @@ App::DocumentObjectExecReturn *DrawViewDetail::execute() } DrawViewPart* dvp = static_cast(baseObj); - - DrawProjGroupItem* dpgi = nullptr; - if (dvp->isDerivedFrom(TechDraw::DrawProjGroupItem::getClassTypeId())) { - dpgi= static_cast(dvp); - } - DrawViewSection* dvs = nullptr; + TopoDS_Shape shape; if (dvp->isDerivedFrom(TechDraw::DrawViewSection::getClassTypeId())) { dvs= static_cast(dvp); - } - - TopoDS_Shape shape; - if (dvs) { shape = dvs->getCutShape(); - } - else if (dpgi) { - shape = dpgi->getSourceShapeFused(); - } - else { + } else { + //getSourceShapeFused will complain if called on section shape = dvp->getSourceShapeFused(); } diff --git a/src/Mod/TechDraw/App/DrawViewSection.cpp b/src/Mod/TechDraw/App/DrawViewSection.cpp index 7e82ebb8f4..07a5d062d3 100644 --- a/src/Mod/TechDraw/App/DrawViewSection.cpp +++ b/src/Mod/TechDraw/App/DrawViewSection.cpp @@ -306,15 +306,7 @@ App::DocumentObjectExecReturn *DrawViewSection::execute() } if (baseShape.IsNull()) { - bool isRestoring = getDocument()->testStatus(App::Document::Status::Restoring); - if (isRestoring) { - Base::Console().Warning("DVS::execute - base shape is invalid - (but document is restoring) - %s\n", - getNameInDocument()); - } else { - Base::Console().Error("Error: DVS::execute - base shape is Null. - %s\n", - getNameInDocument()); - } - return new App::DocumentObjectExecReturn("BaseView Source object is Null"); + return DrawView::execute(); } // checkXDirection(); @@ -353,9 +345,14 @@ void DrawViewSection::sectionExec(TopoDS_Shape& baseShape) // getNameInDocument(), baseShape.IsNull()); if (waitingForCut()) { -// Base::Console().Message("DVS::sectionExec - %s - waiting for cut\n", getNameInDocument()); return; } + + if (baseShape.IsNull()) { + //should be caught before this + return; + } + try { QObject::connect(&m_cutWatcher, SIGNAL(finished()), this, SLOT(onSectionCutFinished())); m_cutFuture = QtConcurrent::run(this, &DrawViewSection::makeSectionCut, baseShape); @@ -371,16 +368,10 @@ void DrawViewSection::makeSectionCut(TopoDS_Shape &baseShape) { // Base::Console().Message("DVS::makeSectionCut() - %s - baseShape.IsNull: %d\n", // getNameInDocument(), baseShape.IsNull()); -// if (waitingForCut()) { -// Base::Console().Message("DVS::makeSectionCut - %s - waiting for cut - returning\n", getNameInDocument()); -// return; -// } waitingForCut(true); showProgressMessage(getNameInDocument(), "is making section cut"); - // auto start = chrono::high_resolution_clock::now(); - // cut base shape with tool //is SectionOrigin valid? Bnd_Box centerBox; @@ -490,38 +481,30 @@ void DrawViewSection::makeSectionCut(TopoDS_Shape &baseShape) return; } -// auto end = chrono::high_resolution_clock::now(); -// auto diff = end - start; -// double diffOut = chrono::duration (diff).count(); -// Base::Console().Message("DVS::makeSectionCut - %s spent: %.3f millisecs making section cut\n", getNameInDocument(), diffOut); waitingForCut(false); } void DrawViewSection::onSectionCutFinished() { // Base::Console().Message("DVS::onSectionCutFinished() - %s\n", getNameInDocument()); -// if (waitingForCut()) { - //this should never happen since sectionExec only starts makeSectionCut if - //a cut is not already in progress -// Base::Console().Message("DVS::onSectionCutFinished - %s - cut not completed yet\n", -// getNameInDocument()); -// return; -// } QObject::disconnect(&m_cutWatcher, SIGNAL(finished()), this, SLOT(onSectionCutFinished())); + showProgressMessage(getNameInDocument(), "has finished making section cut"); + + postSectionCutTasks(); + //display geometry for cut shape is in geometryObject as in DVP geometryObject = buildGeometryObject(m_scaledShape, m_viewAxis); } +//activities that depend on updated geometry object void DrawViewSection::postHlrTasks(void) { // Base::Console().Message("DVS::postHlrTasks() - %s\n", getNameInDocument()); -// auto start = chrono::high_resolution_clock::now(); // build section face geometry TopoDS_Compound faceIntersections = findSectionPlaneIntersections(m_rawShape); if (faceIntersections.IsNull()) { -// Base::Console().Message("DVS::postHlrTasks - no face intersections found\n"); requestPaint(); DrawViewPart::postHlrTasks(); return; @@ -590,11 +573,6 @@ void DrawViewSection::postHlrTasks(void) tdSectionFaces.push_back(sectionFace); } -// auto end = chrono::high_resolution_clock::now(); -// auto diff = end - start; -// double diffOut = chrono::duration (diff).count(); -// Base::Console().Message("DVS::sectionExec - %s spent: %.3f millisecs finding section faces\n", getNameInDocument(), diffOut); - App::DocumentObject* base = BaseView.getValue(); if (base != nullptr) { if (base->getTypeId().isDerivedFrom(TechDraw::DrawViewPart::getClassTypeId())) { @@ -606,6 +584,18 @@ void DrawViewSection::postHlrTasks(void) DrawViewPart::postHlrTasks(); } +//activities that depend on a valid section cut +void DrawViewSection::postSectionCutTasks() +{ + std::vector children = getInList(); + for (auto& c: children) { + if (c->getTypeId().isDerivedFrom(DrawViewPart::getClassTypeId())) { + //details or sections need cut shape + c->recomputeFeature(); + } + } +} + gp_Pln DrawViewSection::getSectionPlane() const { gp_Ax2 viewAxis = getSectionCS(); diff --git a/src/Mod/TechDraw/App/DrawViewSection.h b/src/Mod/TechDraw/App/DrawViewSection.h index 67b8578646..9bcf95dadd 100644 --- a/src/Mod/TechDraw/App/DrawViewSection.h +++ b/src/Mod/TechDraw/App/DrawViewSection.h @@ -24,8 +24,8 @@ #ifndef _DrawViewSection_h_ #define _DrawViewSection_h_ - -#include + +#include #include #include @@ -101,6 +101,7 @@ public: void sectionExec(TopoDS_Shape& s); void makeSectionCut(TopoDS_Shape &baseShape); void postHlrTasks(void) override; + virtual void postSectionCutTasks(); void waitingForCut(bool s) { m_waitingForCut = s; } bool waitingForCut(void) const { return m_waitingForCut; }