]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Create custom action for sketch plane update.
authorazv <azv@opencascade.com>
Thu, 30 May 2019 10:51:53 +0000 (13:51 +0300)
committerazv <azv@opencascade.com>
Thu, 30 May 2019 10:52:08 +0000 (13:52 +0300)
src/SketchPlugin/SketchPlugin_Sketch.cpp
src/SketchPlugin/SketchPlugin_Sketch.h

index 852213ba7621f3e2a2554b05b9c990d93277fb48..811ccb0bf602b6c22026c2080d35f89fc481b36b 100644 (file)
@@ -48,6 +48,7 @@
 #include <SketchPlugin_SketchEntity.h>
 #include <SketchPlugin_Tools.h>
 
+#include <Events_InfoMessage.h>
 #include <Events_Loop.h>
 
 #include <memory>
@@ -369,3 +370,21 @@ std::shared_ptr<GeomAPI_Ax3> SketchPlugin_Sketch::plane(SketchPlugin_Sketch* the
 
   return std::shared_ptr<GeomAPI_Ax3>(new GeomAPI_Ax3(anOrigin->pnt(), aDirX->dir(), aNorm->dir()));
 }
+
+bool SketchPlugin_Sketch::customAction(const std::string& theActionId)
+{
+  bool isOk = false;
+  if (theActionId == ACTION_REMOVE_EXTERNAL())
+    isOk = removeLinksToExternal();
+  else {
+    std::string aMsg = "Error: Feature \"%1\" does not support action \"%2\".";
+    Events_InfoMessage("SketchPlugin_Sketch", aMsg).arg(getKind()).arg(theActionId).send();
+  }
+  return isOk;
+}
+
+bool SketchPlugin_Sketch::removeLinksToExternal()
+{
+  // TODO
+  return true;
+}
index b38b69b90f8d88b165dc83354eba42ba0e16d0bb..d94893db0e90a12c930b3d26dc2412098254b35d 100644 (file)
@@ -90,6 +90,13 @@ class SketchPlugin_Sketch : public ModelAPI_CompositeFeature, public GeomAPI_ICu
     return MY_SOLVER_DOF;
   }
 
+  /// Action ID to remove links to external entities while changing the sketch plane.
+  inline static const std::string& ACTION_REMOVE_EXTERNAL()
+  {
+    static const std::string MY_ACTION_REMOVE_EXTERNAL("RemoveExternalLinks");
+    return MY_ACTION_REMOVE_EXTERNAL;
+  }
+
   /// Returns the kind of a feature
   SKETCHPLUGIN_EXPORT virtual const std::string& getKind()
   {
@@ -205,6 +212,11 @@ class SketchPlugin_Sketch : public ModelAPI_CompositeFeature, public GeomAPI_ICu
 
   SKETCHPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID);
 
+  /// Performs some custom feature specific functionality (normally called by some GUI button)
+  /// \param theActionId an action key
+  /// \return a boolean value about it is performed
+  SKETCHPLUGIN_EXPORT virtual bool customAction(const std::string& theActionId);
+
   /// \brief Create a result for the point in the attribute if the attribute is initialized
   /// \param theFeature a source feature
   /// \param theSketch a sketch intance
@@ -242,6 +254,10 @@ class SketchPlugin_Sketch : public ModelAPI_CompositeFeature, public GeomAPI_ICu
     return isCustomized;
   }
 
+private:
+  /// Substitute all links to external objects by newly created features.
+  /// \return \c true, if all links updated.
+  bool removeLinksToExternal();
 };
 
 #endif