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
27   std::set<std::shared_ptr<ModelAPI_Object> > myInitial;
28   /// already updated and processed features and modificated feature flag
29   std::map<std::shared_ptr<ModelAPI_Object>, bool> myUpdated;
30   /// to know that all next updates are caused by this execution
31   bool isExecuted;
32   /// to know execute or not automatically all update
33   bool isAutomatic;
34   /// just created features: they must be updated immideately even in not-automatic mode for 
35   /// preview; cleared on commit operations
36   std::set<std::shared_ptr<ModelAPI_Object> > myJustCreatedOrUpdated;
37
38  public:
39   /// Is called only once, on startup of the application
40   Model_Update();
41
42   /// Processes the feature argument update: executes the results
43   MODEL_EXPORT virtual void processEvent(const std::shared_ptr<Events_Message>& theMessage);
44
45 protected:
46   /// updates all features in the document and then - in sub-documents
47   void updateInDoc(std::shared_ptr<ModelAPI_Document> theDoc);
48   /// Recoursively checks and updates the feature if needed (calls the execute method)
49   /// Returns true if feature was updated.
50   bool updateFeature(std::shared_ptr<ModelAPI_Feature> theFeature);
51
52   /// Recoursively checks and updates the object (result or feature) if needed (calls updateFeature)
53   /// Returns true if object was updated.
54   bool updateObject(std::shared_ptr<ModelAPI_Object> theObject, const bool theCyclic = true);
55   /// Sends the redisplay events for feature and results, updates the updated status
56   void redisplayWithResults(std::shared_ptr<ModelAPI_Feature> theFeature, 
57     const ModelAPI_ExecState theState);
58 };
59
60 #endif