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