Salome HOME
Fix for the issue #743
[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   /// updated features during this transaction: must be updated immediately
27   std::set<std::shared_ptr<ModelAPI_Object> > myJustUpdated;
28   /// features that must be additionally processed after execution of finish operation
29   std::set<std::shared_ptr<ModelAPI_Object> > myWaitForFinish;
30   /// to know that all next updates are caused by this execution
31   bool myIsExecuted;
32   /// to know execute or not automatically all update
33   bool myIsAutomatic;
34   /// to know that some parameter was changed during this operation
35   bool myIsParamUpdated;
36   /// to execute features of finish if perview is not needed
37   bool myIsFinish;
38   /// Set of already processed features in the "processOperation" method
39   std::set<std::shared_ptr<ModelAPI_Feature> > myProcessed;
40
41  public:
42   /// Is called only once, on startup of the application
43   Model_Update();
44
45   /// Processes the feature argument update: executes the results
46   MODEL_EXPORT virtual void processEvent(const std::shared_ptr<Events_Message>& theMessage);
47
48 protected:
49   /// Recoursively checks and updates the feature if needed (calls the execute method)
50   /// Returns true if feature was updated.
51   void updateFeature(std::shared_ptr<ModelAPI_Feature> theFeature);
52
53   /// Updates the selection and parametrical arguments before the later feature analysis
54   /// Returns true if something really was updated
55   void updateArguments(std::shared_ptr<ModelAPI_Feature> theFeature);
56
57   /// Sends the redisplay events for feature and results, updates the updated status
58   void redisplayWithResults(std::shared_ptr<ModelAPI_Feature> theFeature, 
59     const ModelAPI_ExecState theState);
60
61   /// On operation start/end/abort the "Just" fileds must be cleared and processed in the right way
62   /// \param theTotalUpdate force to updates everything that has been changed in this operation
63   void processOperation(const bool theTotalUpdate, const bool theFinish = false);
64
65   /// Performs the feature execution
66   /// \returns the status of execution
67   void executeFeature(std::shared_ptr<ModelAPI_Feature> theFeature);
68 };
69
70 #endif