From: mpv Date: Tue, 14 Jul 2015 12:26:00 +0000 (+0300) Subject: Fix for empty set of parameters on activation/deactivation of parts that contains... X-Git-Tag: V_1.3.0~17 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=44b45faaf1f822790d1837bcc703ae7b5b32c039;p=modules%2Fshaper.git Fix for empty set of parameters on activation/deactivation of parts that contains only parameters --- diff --git a/src/Model/Model_Document.cpp b/src/Model/Model_Document.cpp index 51e0782e4..6e9fbf778 100644 --- a/src/Model/Model_Document.cpp +++ b/src/Model/Model_Document.cpp @@ -974,3 +974,10 @@ AttributeSelectionListPtr Model_Document::selectionInPartFeature() } return mySelectionFeature->selectionList("selection"); } + +FeaturePtr Model_Document::lastFeature() +{ + if (myObjs) + return myObjs->lastFeature(); + return FeaturePtr(); +} diff --git a/src/Model/Model_Document.h b/src/Model/Model_Document.h index 7c757ce07..9dff1f2cf 100644 --- a/src/Model/Model_Document.h +++ b/src/Model/Model_Document.h @@ -196,6 +196,10 @@ class Model_Document : public ModelAPI_Document /// Returns true if document is opened and valid MODEL_EXPORT virtual bool isOpened(); + /// Returns the last feature in the document (even not visible or disabled) + /// \returns null if there is no features + FeaturePtr lastFeature(); + protected: //! Returns (creates if needed) the general label TDF_Label generalLabel() const; diff --git a/src/Model/Model_Session.cpp b/src/Model/Model_Session.cpp index c0d83dd64..ff74e5bf3 100644 --- a/src/Model/Model_Session.cpp +++ b/src/Model/Model_Session.cpp @@ -218,9 +218,8 @@ std::shared_ptr Model_Session::activeDocument() /// makes the last feature in the document as the current static void makeCurrentLast(std::shared_ptr theDoc) { if (theDoc.get()) { - FeaturePtr aLastFeature = std::dynamic_pointer_cast(theDoc->object( - ModelAPI_Feature::group(), theDoc->size(ModelAPI_Feature::group()) - 1)); - theDoc->setCurrentFeature(aLastFeature, false); + FeaturePtr aLast = std::dynamic_pointer_cast(theDoc)->lastFeature(); + theDoc->setCurrentFeature(aLast, false); } } diff --git a/src/SketchSolver/SketchSolver_Builder.cpp b/src/SketchSolver/SketchSolver_Builder.cpp index e0c6855db..e311b4b55 100644 --- a/src/SketchSolver/SketchSolver_Builder.cpp +++ b/src/SketchSolver/SketchSolver_Builder.cpp @@ -300,7 +300,8 @@ bool SketchSolver_Builder::createNormal( { std::shared_ptr aNorm = std::dynamic_pointer_cast(theNormal); std::shared_ptr aDirX = std::dynamic_pointer_cast(theDirX); - if (!aDirX || (fabs(aDirX->x()) + fabs(aDirX->y()) + fabs(aDirX->z()) < tolerance)) + if (!aDirX || (fabs(aDirX->x()) + fabs(aDirX->y()) + fabs(aDirX->z()) < tolerance) || + !aNorm->isInitialized()) return false; // calculate Y direction std::shared_ptr aDirY(new GeomAPI_Dir(aNorm->dir()->cross(aDirX->dir())));