From 72604b9da2705f9030a886193ce9bb632dfda376 Mon Sep 17 00:00:00 2001 From: vsv Date: Thu, 8 Oct 2015 16:07:08 +0300 Subject: [PATCH] Method isStable is defined --- src/ModelAPI/ModelAPI_Feature.cpp | 15 +++++++++++++++ src/ModelAPI/ModelAPI_Feature.h | 10 ++++++++++ src/ModuleBase/ModuleBase_OperationFeature.cpp | 2 ++ 3 files changed, 27 insertions(+) diff --git a/src/ModelAPI/ModelAPI_Feature.cpp b/src/ModelAPI/ModelAPI_Feature.cpp index 9edfefa4c..6d17254bc 100644 --- a/src/ModelAPI/ModelAPI_Feature.cpp +++ b/src/ModelAPI/ModelAPI_Feature.cpp @@ -199,6 +199,20 @@ bool ModelAPI_Feature::isDisabled() return myIsDisabled; } +bool ModelAPI_Feature::setStable(const bool theFlag) +{ + if (myIsStable != theFlag) { + myIsStable = theFlag; + return true; + } + return false; +} + +bool ModelAPI_Feature::isStable() +{ + return myIsStable; +} + bool ModelAPI_Feature::isPreviewNeeded() const { return true; @@ -207,4 +221,5 @@ bool ModelAPI_Feature::isPreviewNeeded() const void ModelAPI_Feature::init() { myIsDisabled = false; + myIsStable = true; } diff --git a/src/ModelAPI/ModelAPI_Feature.h b/src/ModelAPI/ModelAPI_Feature.h index 2508e6a2e..af55636cb 100644 --- a/src/ModelAPI/ModelAPI_Feature.h +++ b/src/ModelAPI/ModelAPI_Feature.h @@ -28,6 +28,9 @@ class ModelAPI_Feature : public ModelAPI_Object std::list > myResults; ///< is feature disabled or not bool myIsDisabled; + ///< is feature is stable (not editing) + bool myIsStable; + public: /// Returns the unique kind of a feature (like "Point") virtual const std::string& getKind() = 0; @@ -132,6 +135,13 @@ class ModelAPI_Feature : public ModelAPI_Object /// Returns the feature by the object (result). MODELAPI_EXPORT static std::shared_ptr feature(ObjectPtr theObject); + /// Set the stable feature flag. If feature is currently editing then it is not stable. + /// \returns true if state is really changed + MODELAPI_EXPORT virtual bool setStable(const bool theFlag); + + /// Returns the feature is stable or not. + MODELAPI_EXPORT virtual bool isStable(); + // // Helper methods, aliases for data()->method() // ----------------------------------------------------------------------------------------------- diff --git a/src/ModuleBase/ModuleBase_OperationFeature.cpp b/src/ModuleBase/ModuleBase_OperationFeature.cpp index b3540002f..a6829d1bc 100755 --- a/src/ModuleBase/ModuleBase_OperationFeature.cpp +++ b/src/ModuleBase/ModuleBase_OperationFeature.cpp @@ -114,6 +114,7 @@ void ModuleBase_OperationFeature::stopOperation() if (myVisualizedObjects.find(aFeature) != myVisualizedObjects.end()) { aFeature->setDisplayed(false); } + aFeature->setStable(true); if (myVisualizedObjects.size() > 0) Events_Loop::loop()->flush(Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY)); } @@ -146,6 +147,7 @@ FeaturePtr ModuleBase_OperationFeature::createFeature(const bool theFlushMessage void ModuleBase_OperationFeature::setFeature(FeaturePtr theFeature) { myFeature = theFeature; + myFeature->setStable(false); myIsEditing = true; } -- 2.39.2