Salome HOME
31d532da516fe38bd0ece5048025097635ed8b4b
[modules/shaper.git] / src / Model / Model_Update.h
1 // File:        Model_Update.hxx
2 // Created:     25 Jun 2014
3 // Author:      Mikhail PONIKAROV
4
5 #ifndef Model_Update_H_
6 #define Model_Update_H_
7
8 #include "Model.h"
9 #include "Events_Listener.h"
10 #include <memory>
11 #include <set>
12 #include <map>
13
14 class ModelAPI_Object;
15 class ModelAPI_Feature;
16
17 /**\class Model_Update
18  * \ingroup DataModel
19  * \brief Updates the results of features when it is needed.
20  */
21 class Model_Update : public Events_Listener
22 {
23   /// initial set of updated features that must be processed
24   std::set<std::shared_ptr<ModelAPI_Object> > myInitial;
25   /// already updated and processed features and modificated feature flag
26   std::map<std::shared_ptr<ModelAPI_Object>, bool> myUpdated;
27   /// to know that all next updates are caused by this execution
28   bool isExecuted;
29   /// to know execute or not automatically all update
30   bool isAutomatic;
31   /// just created features: they must be updated immideately even in not-automatic mode for 
32   /// preview; cleared on commit operations
33   std::set<std::shared_ptr<ModelAPI_Object> > myJustCreatedOrUpdated;
34
35  public:
36   /// Is called only once, on startup of the application
37   Model_Update();
38
39   /// Processes the feature argument update: executes the results
40   MODEL_EXPORT virtual void processEvent(const std::shared_ptr<Events_Message>& theMessage);
41
42  protected:
43   /// Recoursively checks and updates the feature if needed (calls the execute method)
44   /// Returns true if feature was updated.
45   bool updateFeature(std::shared_ptr<ModelAPI_Feature> theFeature);
46
47   /// Recoursively checks and updates the object (result or feature) if needed (calls updateFeature)
48   /// Returns true if object was updated.
49   bool updateObject(std::shared_ptr<ModelAPI_Object> theObject, const bool theCyclic = true);
50   /// Sends the redisplay events for feature and results, updates the updated status
51   void redisplayWithResults(std::shared_ptr<ModelAPI_Feature> theFeature);
52 };
53
54 #endif