Salome HOME
Issue #1860: fix end lines with spaces
[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 which arguments were modified by not-persistent changes.
33   /// So, these referencing arguments must be updated
34   /// due to these features info also before execution).
35   std::map<std::shared_ptr<ModelAPI_Feature>, std::set<std::shared_ptr<ModelAPI_Feature> > >
36     myNotPersistentRefs;
37   /// features that must be additionally processed after execution of finish operation
38   std::set<std::shared_ptr<ModelAPI_Feature> > myWaitForFinish;
39   /// to know that some parameter was changed during this operation (to enable update expressions)
40   bool myIsParamUpdated;
41   /// to execute features on finish if preview is needed only on finish operation
42   bool myIsFinish;
43   /// try if processing is currently performed
44   bool myIsProcessed;
45   /// set that contains features that must be executed only on finish of the operation
46   std::set<std::shared_ptr<ModelAPI_Feature> > myProcessOnFinish;
47   /// to avoid infinitive cycling: feature -> count of the processing periods during this update
48   std::map<std::shared_ptr<ModelAPI_Feature>, int > myProcessed;
49   /// if preview in hte property panel is blocked and
50   /// any update is postponed until the end of operation
51   bool myIsPreviewBlocked;
52
53  public:
54   /// Is called only once, on startup of the application
55   Model_Update();
56
57   /// Processes the feature argument update: executes the results
58   MODEL_EXPORT virtual void processEvent(const std::shared_ptr<Events_Message>& theMessage);
59
60 protected:
61   /// Appends the new modified feature to the myModified, clears myProcessed if needed
62   /// Returns true if some feature really was marked as modified
63   /// theReason is the object that causes modification of this feature
64   /// returns true if something reallsy was added to the modified and must be processed
65   bool addModified(
66     std::shared_ptr<ModelAPI_Feature> theFeature, std::shared_ptr<ModelAPI_Feature> theReason);
67
68   /// Recoursively checks and updates features if needed (calls the execute method)
69   /// Returns true if feature was updated.
70   bool processFeature(std::shared_ptr<ModelAPI_Feature> theFeature);
71
72   /// Updates the selection and parametrical arguments before the later feature analysis
73   /// Returns true if something really was updated
74   void updateArguments(std::shared_ptr<ModelAPI_Feature> theFeature);
75
76   /// Sends the redisplay events for feature and results, updates the updated status
77   void redisplayWithResults(std::shared_ptr<ModelAPI_Feature> theFeature,
78     const ModelAPI_ExecState theState);
79
80   /// On operation start/end/abort the "Just" fileds must be cleared and processed in the right way
81   //! \param theFlushRedisplay a boolean value if the redisplay signal should be flushed
82   void processFeatures(const bool theFlushRedisplay = true);
83
84   /// Performs the feature execution
85   /// \returns the status of execution
86   void executeFeature(std::shared_ptr<ModelAPI_Feature> theFeature);
87
88   /// Updates the properties of object because of stability state changes
89   void updateStability(void* theSender);
90
91   /// Returns true if theFeature modification was caused by theReason
92   /// (may be feature of result of this feature)
93   bool isReason(
94     std::shared_ptr<ModelAPI_Feature>& theFeature, std::shared_ptr<ModelAPI_Object> theReason);
95
96   /// Updates a selection attributes for the features that possible were affected by creation
97   /// or reorder of features upper in the history line (issue #1757)
98   void updateSelection(const std::set<std::shared_ptr<ModelAPI_Object> >& theObjects);
99
100 };
101
102 #endif