]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Make sub-features of sketch defined as current feature after it is become sub-feature...
authormpv <mpv@opencascade.com>
Wed, 20 May 2015 13:49:30 +0000 (16:49 +0300)
committermpv <mpv@opencascade.com>
Wed, 20 May 2015 13:49:30 +0000 (16:49 +0300)
src/Model/Model_Document.cpp
src/Model/Model_Document.h
src/ModelAPI/ModelAPI_Document.h
src/SketchPlugin/SketchPlugin_Sketch.cpp

index 3f1ae6a4d2da036ba6fbc0bab291a725b8fdfcfb..e5c87013ede6a926641a0f41b1c82a0c4fa167aa 100644 (file)
@@ -527,7 +527,7 @@ void Model_Document::operationId(const std::string& theId)
   myTransactions.rbegin()->myId = theId;
 }
 
-FeaturePtr Model_Document::addFeature(std::string theID)
+FeaturePtr Model_Document::addFeature(std::string theID, const bool theMakeCurrent)
 {
   std::shared_ptr<Model_Session> aSession = 
     std::dynamic_pointer_cast<Model_Session>(ModelAPI_Session::get());
@@ -547,7 +547,8 @@ FeaturePtr Model_Document::addFeature(std::string theID)
   if (aFeature) {
     aDocToAdd->myObjs->addFeature(aFeature, currentFeature(false));
     if (!aFeature->isAction()) {  // do not add action to the data model
-      setCurrentFeature(aFeature, false); // after all this feature stays in the document, so make it current
+      if (theMakeCurrent)  // after all this feature stays in the document, so make it current
+        setCurrentFeature(aFeature, false);
     } else { // feature must be executed
        // no creation event => updater not working, problem with remove part
       aFeature->execute();
index fc0c0f353ecafde91bbda083e9ec24c1e365aa1a..127934e03f201519a994a428b089d96876634b1b 100644 (file)
@@ -73,7 +73,8 @@ class Model_Document : public ModelAPI_Document
 
   //! Adds to the document the new feature of the given feature id
   //! \param theID creates feature and puts it in the document
-  MODEL_EXPORT virtual FeaturePtr addFeature(std::string theID);
+  //! \param theMakeCurrent to make current this new feature in this document
+  MODEL_EXPORT virtual FeaturePtr addFeature(std::string theID, const bool theMakeCurrent = true);
 
   //! Return a list of features, which refers to the feature
   //! \param theFeature a feature
index 4248ea23a084771ad055728a52758e0dc50cbde2..72a69e045c7bd51434f2f110a952521b9f2c08ef 100644 (file)
@@ -44,7 +44,9 @@ public:
 
   //! Adds to the document the new feature of the given feature id
   //! \param theID creates feature and puts it in the document (if it is not action)
-  virtual std::shared_ptr<ModelAPI_Feature> addFeature(std::string theID) = 0;
+  //! \param theMakeCurrent to make current this new feature in this document
+  virtual std::shared_ptr<ModelAPI_Feature> addFeature(std::string theID, 
+    const bool theMakeCurrent = true) = 0;
 
   //! Return a list of features, which refers to the feature
   //! \param theFeature a feature
index 2190a6e4b550bcda625e40fdcf071cd3251024cf..2d02f0dd10f3a64e2900c035b30f96cb48e06cb9 100644 (file)
@@ -125,11 +125,13 @@ void SketchPlugin_Sketch::execute()
 
 std::shared_ptr<ModelAPI_Feature> SketchPlugin_Sketch::addFeature(std::string theID)
 {
-  std::shared_ptr<ModelAPI_Feature> aNew = document()->addFeature(theID);
+  std::shared_ptr<ModelAPI_Feature> aNew = document()->addFeature(theID, false);
   if (aNew) {
     std::dynamic_pointer_cast<SketchPlugin_Feature>(aNew)->setSketch(this);
     data()->reflist(SketchPlugin_Sketch::FEATURES_ID())->append(aNew);
   }
+   // set as current also after it becomes sub to set correctly enabled for other sketch subs
+  document()->setCurrentFeature(aNew, false);
   return aNew;
 }