]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Fix for empty set of parameters on activation/deactivation of parts that contains...
authormpv <mpv@opencascade.com>
Tue, 14 Jul 2015 12:26:00 +0000 (15:26 +0300)
committermpv <mpv@opencascade.com>
Tue, 14 Jul 2015 12:26:00 +0000 (15:26 +0300)
src/Model/Model_Document.cpp
src/Model/Model_Document.h
src/Model/Model_Session.cpp
src/SketchSolver/SketchSolver_Builder.cpp

index 51e0782e42c19f64cecdf4a246c9acf035001421..6e9fbf778da1aeca0802669c0e14285f9681ff9c 100644 (file)
@@ -974,3 +974,10 @@ AttributeSelectionListPtr Model_Document::selectionInPartFeature()
   }
   return mySelectionFeature->selectionList("selection");
 }
+
+FeaturePtr Model_Document::lastFeature()
+{
+  if (myObjs)
+    return myObjs->lastFeature();
+  return FeaturePtr();
+}
index 7c757ce074144faef0d53d71ff290feededaca5c..9dff1f2cff23264a4113329a0c96106601ac591a 100644 (file)
@@ -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;
index c0d83dd648d770bb887e13f3acfc0aa0345ebe95..ff74e5bf3ad2b095e274c7cbdbfb9ff7c9739a91 100644 (file)
@@ -218,9 +218,8 @@ std::shared_ptr<ModelAPI_Document> Model_Session::activeDocument()
 /// makes the last feature in the document as the current
 static void makeCurrentLast(std::shared_ptr<ModelAPI_Document> theDoc) {
   if (theDoc.get()) {
-    FeaturePtr aLastFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(theDoc->object(
-      ModelAPI_Feature::group(), theDoc->size(ModelAPI_Feature::group()) - 1));
-    theDoc->setCurrentFeature(aLastFeature, false);
+    FeaturePtr aLast = std::dynamic_pointer_cast<Model_Document>(theDoc)->lastFeature();
+    theDoc->setCurrentFeature(aLast, false);
   }
 }
 
index e0c6855db43e824ee9ac1c301a5be13ea034247e..e311b4b55697ead5d95f352bbfcfba039514daad 100644 (file)
@@ -300,7 +300,8 @@ bool SketchSolver_Builder::createNormal(
 {
   std::shared_ptr<GeomDataAPI_Dir> aNorm = std::dynamic_pointer_cast<GeomDataAPI_Dir>(theNormal);
   std::shared_ptr<GeomDataAPI_Dir> aDirX = std::dynamic_pointer_cast<GeomDataAPI_Dir>(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<GeomAPI_Dir> aDirY(new GeomAPI_Dir(aNorm->dir()->cross(aDirX->dir())));