]> SALOME platform Git repositories - modules/shaper.git/blob - src/Model/Model_Update.h
Salome HOME
c9fe39ab7178ee1e1f01d07e215b22eafd17b654
[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 class ModelAPI_CompositeFeature;
20 class Model_Objects;
21
22 /**\class Model_Update
23  * \ingroup DataModel
24  * \brief Updates the results of features when it is needed.
25  */
26 class Model_Update : public Events_Listener
27 {
28   /// Features and results that were modified and not yet processed.
29   /// The second set is the objects that causes this object is modified
30   std::map<std::shared_ptr<ModelAPI_Feature>, std::set<std::shared_ptr<ModelAPI_Feature> > >
31     myModified;
32   /// features that must be additionally processed after execution of finish operation
33   std::set<std::shared_ptr<ModelAPI_Feature> > myWaitForFinish;
34   /// to know that some parameter was changed during this operation (to enable update expressions)
35   bool myIsParamUpdated;
36   /// to execute features on finish if preview is needed only on finish operation
37   bool myIsFinish;
38   /// try if processing is currently performed
39   bool myIsProcessed;
40   /// set that contains features that must be executed only on finish of the operation
41   std::set<std::shared_ptr<ModelAPI_Feature> > myProcessOnFinish;
42   /// to avoid infinitive cycling: feature -> count of the processing periods during this update
43   std::map<std::shared_ptr<ModelAPI_Feature>, int > myProcessed;
44
45  public:
46   /// Is called only once, on startup of the application
47   Model_Update();
48
49   /// Processes the feature argument update: executes the results
50   MODEL_EXPORT virtual void processEvent(const std::shared_ptr<Events_Message>& theMessage);
51
52 protected:
53   /// Appends the new modified feature to the myModified, clears myProcessed if needed
54   /// Returns true if some feature really was marked as modified
55   /// theReason is the object that causes modification of this feature
56   /// returns true if something reallsy was added to the modified and must be processed
57   bool addModified(
58     std::shared_ptr<ModelAPI_Feature> theFeature, std::shared_ptr<ModelAPI_Feature> theReason);
59
60   /// Recoursively checks and updates features if needed (calls the execute method)
61   /// Returns true if feature was updated.
62   bool processFeature(std::shared_ptr<ModelAPI_Feature> theFeature);
63
64   /// Updates the selection and parametrical arguments before the later feature analysis
65   /// Returns true if something really was updated
66   void updateArguments(std::shared_ptr<ModelAPI_Feature> theFeature);
67
68   /// Sends the redisplay events for feature and results, updates the updated status
69   void redisplayWithResults(std::shared_ptr<ModelAPI_Feature> theFeature, 
70     const ModelAPI_ExecState theState);
71
72   /// On operation start/end/abort the "Just" fileds must be cleared and processed in the right way
73   /// \param theFinish is true for start, close or abort transaction: all objects must be processed
74   void processFeatures();
75
76   /// Performs the feature execution
77   /// \returns the status of execution
78   void executeFeature(std::shared_ptr<ModelAPI_Feature> theFeature);
79
80   /// Updates the properties of object because of stability state changes
81   void updateStability(void* theSender);
82
83   /// Returns true if theFeature modification was caused by theReason (may be feature of result of this feature)
84   bool isReason(
85     std::shared_ptr<ModelAPI_Feature>& theFeature, std::shared_ptr<ModelAPI_Object> theReason);
86 };
87
88 #endif