Salome HOME
Copyright update 2021
[modules/shaper.git] / src / SketchPlugin / SketchPlugin_Feature.cpp
index f67eeeae484a45d1b47cbcd4fabc49cf2795bc2b..6a1dcefc552958f7a434c57a472b6c44a2224abe 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2014-2017  CEA/DEN, EDF R&D
+// Copyright (C) 2014-2021  CEA/DEN, EDF R&D
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
 //
 // You should have received a copy of the GNU Lesser General Public
 // License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 //
-// See http://www.salome-platform.org/ or
-// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 
 #include "SketchPlugin_Feature.h"
@@ -58,3 +57,21 @@ SketchPlugin_Sketch* SketchPlugin_Feature::sketch()
   return mySketch;
 }
 
+void SketchPlugin_Feature::keepCurrentFeature()
+{
+  FeaturePtr aCurFeature = document()->currentFeature(true);
+  std::shared_ptr<SketchPlugin_Feature> aSketchFeature =
+      std::dynamic_pointer_cast<SketchPlugin_Feature>(aCurFeature);
+  std::shared_ptr<SketchPlugin_Sketch> aSketch =
+      std::dynamic_pointer_cast<SketchPlugin_Sketch>(aCurFeature);
+  if ((!aSketchFeature || aSketchFeature->sketch() != sketch()) &&
+      (!aSketch || aSketch.get() != sketch()))
+    myCurrentFeature = aCurFeature;
+}
+
+void SketchPlugin_Feature::restoreCurrentFeature()
+{
+  if (myCurrentFeature)
+    document()->setCurrentFeature(myCurrentFeature, true);
+  myCurrentFeature = FeaturePtr();
+}