From: mpv Date: Wed, 20 May 2015 13:49:30 +0000 (+0300) Subject: Make sub-features of sketch defined as current feature after it is become sub-feature... X-Git-Tag: V_1.2.0~133^2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=07eadc6d62935271cf75fec5ad99a25eeda273a4;p=modules%2Fshaper.git Make sub-features of sketch defined as current feature after it is become sub-feature of sketch (on Length creation sub-elements are not disappeared) --- diff --git a/src/Model/Model_Document.cpp b/src/Model/Model_Document.cpp index 3f1ae6a4d..e5c87013e 100644 --- a/src/Model/Model_Document.cpp +++ b/src/Model/Model_Document.cpp @@ -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 aSession = std::dynamic_pointer_cast(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(); diff --git a/src/Model/Model_Document.h b/src/Model/Model_Document.h index fc0c0f353..127934e03 100644 --- a/src/Model/Model_Document.h +++ b/src/Model/Model_Document.h @@ -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 diff --git a/src/ModelAPI/ModelAPI_Document.h b/src/ModelAPI/ModelAPI_Document.h index 4248ea23a..72a69e045 100644 --- a/src/ModelAPI/ModelAPI_Document.h +++ b/src/ModelAPI/ModelAPI_Document.h @@ -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 addFeature(std::string theID) = 0; + //! \param theMakeCurrent to make current this new feature in this document + virtual std::shared_ptr addFeature(std::string theID, + const bool theMakeCurrent = true) = 0; //! Return a list of features, which refers to the feature //! \param theFeature a feature diff --git a/src/SketchPlugin/SketchPlugin_Sketch.cpp b/src/SketchPlugin/SketchPlugin_Sketch.cpp index 2190a6e4b..2d02f0dd1 100644 --- a/src/SketchPlugin/SketchPlugin_Sketch.cpp +++ b/src/SketchPlugin/SketchPlugin_Sketch.cpp @@ -125,11 +125,13 @@ void SketchPlugin_Sketch::execute() std::shared_ptr SketchPlugin_Sketch::addFeature(std::string theID) { - std::shared_ptr aNew = document()->addFeature(theID); + std::shared_ptr aNew = document()->addFeature(theID, false); if (aNew) { std::dynamic_pointer_cast(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; }