From 175966a6f778e7fcf26f94f351e2e7e9bc999e53 Mon Sep 17 00:00:00 2001 From: wandererfan Date: Mon, 1 Apr 2019 09:08:04 -0400 Subject: [PATCH] Improve error messages for invalid shapes --- src/Mod/TechDraw/App/DrawViewDetail.cpp | 18 +++++++++++- src/Mod/TechDraw/App/DrawViewPart.cpp | 36 ++++++++++++++++++++---- src/Mod/TechDraw/App/DrawViewPart.h | 2 ++ src/Mod/TechDraw/App/DrawViewSection.cpp | 9 +++++- 4 files changed, 58 insertions(+), 7 deletions(-) diff --git a/src/Mod/TechDraw/App/DrawViewDetail.cpp b/src/Mod/TechDraw/App/DrawViewDetail.cpp index 29eb7d526d..35cf164731 100644 --- a/src/Mod/TechDraw/App/DrawViewDetail.cpp +++ b/src/Mod/TechDraw/App/DrawViewDetail.cpp @@ -68,6 +68,7 @@ # include #include +#include #include #include #include @@ -158,7 +159,14 @@ App::DocumentObjectExecReturn *DrawViewDetail::execute(void) App::DocumentObject* baseObj = BaseView.getValue(); if (!baseObj) { - Base::Console().Log("INFO - DVD::execute - No BaseView - creation?\n"); + bool isRestoring = getDocument()->testStatus(App::Document::Status::Restoring); + if (isRestoring) { + Base::Console().Warning("DVD::execute - No BaseView (but document is restoring) - %s\n", + getNameInDocument()); + } else { + Base::Console().Error("Error: DVD::execute - No BaseView(s) linked. - %s\n", + getNameInDocument()); + } return DrawView::execute(); } @@ -189,6 +197,14 @@ App::DocumentObjectExecReturn *DrawViewDetail::execute(void) } if (shape.IsNull()) { + bool isRestoring = getDocument()->testStatus(App::Document::Status::Restoring); + if (isRestoring) { + Base::Console().Warning("DVD::execute - source shape is invalid - (but document is restoring) - %s\n", + getNameInDocument()); + } else { + Base::Console().Error("Error: DVD::execute - Source shape is Null. - %s\n", + getNameInDocument()); + } return new App::DocumentObjectExecReturn("DVD - Linked shape object is invalid"); } diff --git a/src/Mod/TechDraw/App/DrawViewPart.cpp b/src/Mod/TechDraw/App/DrawViewPart.cpp index 75cff63844..a8655501a4 100644 --- a/src/Mod/TechDraw/App/DrawViewPart.cpp +++ b/src/Mod/TechDraw/App/DrawViewPart.cpp @@ -162,7 +162,14 @@ TopoDS_Shape DrawViewPart::getSourceShape(void) const TopoDS_Shape result; const std::vector& links = Source.getValues(); if (links.empty()) { - Base::Console().Log("DVP::getSourceShape - No Sources - creation? - %s\n",getNameInDocument()); + bool isRestoring = getDocument()->testStatus(App::Document::Status::Restoring); + if (isRestoring) { + Base::Console().Warning("DVP::getSourceShape - No Sources (but document is restoring) - %s\n", + getNameInDocument()); + } else { + Base::Console().Error("Error: DVP::getSourceShape - No Source(s) linked. - %s\n", + getNameInDocument()); + } } else { std::vector sourceShapes; for (auto& l:links) { @@ -237,20 +244,34 @@ 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; } const std::vector& links = Source.getValues(); if (links.empty()) { - Base::Console().Log("DVP::execute - %s - No Sources - creation time?\n",getNameInDocument()); + bool isRestoring = getDocument()->testStatus(App::Document::Status::Restoring); + if (isRestoring) { + Base::Console().Warning("DVP::execute - No Sources (but document is restoring) - %s\n", + getNameInDocument()); + } else { + Base::Console().Error("Error: DVP::execute - No Source(s) linked. - %s\n", + getNameInDocument()); + } return App::DocumentObject::StdReturn; } - TopoDS_Shape shape = getSourceShape(); //if shape is null, it is probably obj creation time. + TopoDS_Shape shape = getSourceShape(); //if shape is null, it is probably(?) obj creation time. if (shape.IsNull()) { - Base::Console().Log("DVP::execute - %s - source shape is invalid - creation time?\n", - getNameInDocument()); + 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()); + } else { + Base::Console().Error("Error: DVP::execute - Source shape is Null. - %s\n", + getNameInDocument()); + } return App::DocumentObject::StdReturn; } @@ -332,6 +353,11 @@ 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) { diff --git a/src/Mod/TechDraw/App/DrawViewPart.h b/src/Mod/TechDraw/App/DrawViewPart.h index 265da3e50e..2287106455 100644 --- a/src/Mod/TechDraw/App/DrawViewPart.h +++ b/src/Mod/TechDraw/App/DrawViewPart.h @@ -136,6 +136,7 @@ public: const bool flip=true) const; virtual short mustExecute() const; +/* virtual void onDocumentRestored() override;*/ bool handleFaces(void); bool showSectionEdges(void); @@ -184,6 +185,7 @@ protected: private: bool nowUnsetting; +/* bool m_restoreComplete;*/ }; diff --git a/src/Mod/TechDraw/App/DrawViewSection.cpp b/src/Mod/TechDraw/App/DrawViewSection.cpp index 208fa34202..1dbad65013 100644 --- a/src/Mod/TechDraw/App/DrawViewSection.cpp +++ b/src/Mod/TechDraw/App/DrawViewSection.cpp @@ -204,7 +204,14 @@ App::DocumentObjectExecReturn *DrawViewSection::execute(void) } if (baseShape.IsNull()) { - Base::Console().Log("DVS::execute - baseShape is Null\n"); + 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"); }