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());
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();
//! 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
//! 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
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;
}