From db0ff8b5e15498f4e995e8cdea97e4c77f3958d9 Mon Sep 17 00:00:00 2001 From: mpv Date: Tue, 4 Sep 2018 10:48:51 +0300 Subject: [PATCH] Issue #2612 : Re-calculate model after modification of parameters Preparation for GUI access --- src/Model/Model_Session.cpp | 17 +++++++++++++++++ src/Model/Model_Session.h | 10 ++++++++++ src/ModelAPI/ModelAPI_Session.h | 6 ++++++ 3 files changed, 33 insertions(+) diff --git a/src/Model/Model_Session.cpp b/src/Model/Model_Session.cpp index c0dde0f28..d150d44f9 100644 --- a/src/Model/Model_Session.cpp +++ b/src/Model/Model_Session.cpp @@ -424,6 +424,7 @@ Model_Session::Model_Session() myPluginsInfoLoaded = false; myCheckTransactions = true; myOperationAttachedToNext = false; + myIsAutoUpdateBlocked = false; ModelAPI_Session::setSession(std::shared_ptr(this)); // register the configuration reading listener Events_Loop* aLoop = Events_Loop::loop(); @@ -577,3 +578,19 @@ int Model_Session::transactionID() { return ROOT_DOC->transactionID(); } + +void Model_Session::blockAutoUpdate(const bool theBlock) +{ + if (myIsAutoUpdateBlocked != theBlock) { + static Events_Loop* aLoop = Events_Loop::loop(); + if (theBlock) { + static const Events_ID kAutoOff = aLoop->eventByName(EVENT_AUTOMATIC_RECOMPUTATION_DISABLE); + std::shared_ptr aMsg(new Events_Message(kAutoOff)); + aLoop->send(aMsg); + } else { + static const Events_ID kAutoOn = aLoop->eventByName(EVENT_AUTOMATIC_RECOMPUTATION_ENABLE); + std::shared_ptr aMsg(new Events_Message(kAutoOn)); + aLoop->send(aMsg); + } + } +} diff --git a/src/Model/Model_Session.h b/src/Model/Model_Session.h index 7342ae2d3..11655c8a3 100644 --- a/src/Model/Model_Session.h +++ b/src/Model/Model_Session.h @@ -50,6 +50,7 @@ class Model_Session : public ModelAPI_Session, public Events_Listener /// if true, generates error if document is updated outside of transaction bool myCheckTransactions; bool myOperationAttachedToNext; ///< the current operation must be committed twice, with nested + bool myIsAutoUpdateBlocked; ///< the current state of the auto-update flag in the application public: //! Loads the OCAF document from the file. @@ -144,6 +145,15 @@ class Model_Session : public ModelAPI_Session, public Events_Listener /// Returns the global identifier of the current transaction (needed for the update algo) MODEL_EXPORT virtual int transactionID(); + + /// Returns true if auto-update in the application is blocked + MODEL_EXPORT virtual bool isAutoUpdateBlocked() const { + return myIsAutoUpdateBlocked; + } + + /// Set state of the auto-update of features result in the application + MODEL_EXPORT virtual void blockAutoUpdate(const bool theBlock); + protected: /// Loads (if not done yet) the information about the features and plugins void LoadPluginsInfo(); diff --git a/src/ModelAPI/ModelAPI_Session.h b/src/ModelAPI/ModelAPI_Session.h index 7b2d7dd1b..91f3b8bbc 100644 --- a/src/ModelAPI/ModelAPI_Session.h +++ b/src/ModelAPI/ModelAPI_Session.h @@ -129,6 +129,12 @@ class MODELAPI_EXPORT ModelAPI_Session /// Returns the global identifier of the current transaction (needed for the update algo) virtual int transactionID() = 0; + /// Returns true if auto-update in the application is blocked + virtual bool isAutoUpdateBlocked() const = 0; + + /// Set state of the auto-update of features result in the application + virtual void blockAutoUpdate(const bool theBlock) = 0; + protected: /// Sets the session interface implementation (once per application launch) static void setSession(std::shared_ptr theManager); -- 2.39.2