From: azv Date: Thu, 30 May 2019 10:51:53 +0000 (+0300) Subject: Create custom action for sketch plane update. X-Git-Tag: VEDF2019Lot4~114^2~15 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=13e9077f3588ddad483da25d9b9c20b56569f582;p=modules%2Fshaper.git Create custom action for sketch plane update. --- diff --git a/src/SketchPlugin/SketchPlugin_Sketch.cpp b/src/SketchPlugin/SketchPlugin_Sketch.cpp index 852213ba7..811ccb0bf 100644 --- a/src/SketchPlugin/SketchPlugin_Sketch.cpp +++ b/src/SketchPlugin/SketchPlugin_Sketch.cpp @@ -48,6 +48,7 @@ #include #include +#include #include #include @@ -369,3 +370,21 @@ std::shared_ptr SketchPlugin_Sketch::plane(SketchPlugin_Sketch* the return std::shared_ptr(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; +} diff --git a/src/SketchPlugin/SketchPlugin_Sketch.h b/src/SketchPlugin/SketchPlugin_Sketch.h index b38b69b90..d94893db0 100644 --- a/src/SketchPlugin/SketchPlugin_Sketch.h +++ b/src/SketchPlugin/SketchPlugin_Sketch.h @@ -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