1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: Model_Update.hxx
4 // Created: 25 Jun 2014
5 // Author: Mikhail PONIKAROV
7 #ifndef Model_Update_H_
8 #define Model_Update_H_
11 #include <ModelAPI_Data.h>
12 #include "Events_Listener.h"
17 class ModelAPI_Object;
18 class ModelAPI_Feature;
19 class ModelAPI_CompositeFeature;
22 /**\class Model_Update
24 * \brief Updates the results of features when it is needed.
26 class Model_Update : public Events_Listener
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> > >
32 /// Features which arguments were modified by not-persistent changes.
33 /// So, these referencing arguments must be updated due to these features info also before execution).
34 std::map<std::shared_ptr<ModelAPI_Feature>, std::set<std::shared_ptr<ModelAPI_Feature> > >
36 /// features that must be additionally processed after execution of finish operation
37 std::set<std::shared_ptr<ModelAPI_Feature> > myWaitForFinish;
38 /// to know that some parameter was changed during this operation (to enable update expressions)
39 bool myIsParamUpdated;
40 /// to execute features on finish if preview is needed only on finish operation
42 /// try if processing is currently performed
44 /// set that contains features that must be executed only on finish of the operation
45 std::set<std::shared_ptr<ModelAPI_Feature> > myProcessOnFinish;
46 /// to avoid infinitive cycling: feature -> count of the processing periods during this update
47 std::map<std::shared_ptr<ModelAPI_Feature>, int > myProcessed;
48 /// if preview in hte property panel is blocked and any update is postponed until the end of operation
49 bool myIsPreviewBlocked;
52 /// Is called only once, on startup of the application
55 /// Processes the feature argument update: executes the results
56 MODEL_EXPORT virtual void processEvent(const std::shared_ptr<Events_Message>& theMessage);
59 /// Appends the new modified feature to the myModified, clears myProcessed if needed
60 /// Returns true if some feature really was marked as modified
61 /// theReason is the object that causes modification of this feature
62 /// returns true if something reallsy was added to the modified and must be processed
64 std::shared_ptr<ModelAPI_Feature> theFeature, std::shared_ptr<ModelAPI_Feature> theReason);
66 /// Recoursively checks and updates features if needed (calls the execute method)
67 /// Returns true if feature was updated.
68 bool processFeature(std::shared_ptr<ModelAPI_Feature> theFeature);
70 /// Updates the selection and parametrical arguments before the later feature analysis
71 /// Returns true if something really was updated
72 void updateArguments(std::shared_ptr<ModelAPI_Feature> theFeature);
74 /// Sends the redisplay events for feature and results, updates the updated status
75 void redisplayWithResults(std::shared_ptr<ModelAPI_Feature> theFeature,
76 const ModelAPI_ExecState theState);
78 /// On operation start/end/abort the "Just" fileds must be cleared and processed in the right way
79 //! \param theFlushRedisplay a boolean value if the redisplay signal should be flushed
80 void processFeatures(const bool theFlushRedisplay = true);
82 /// Performs the feature execution
83 /// \returns the status of execution
84 void executeFeature(std::shared_ptr<ModelAPI_Feature> theFeature);
86 /// Updates the properties of object because of stability state changes
87 void updateStability(void* theSender);
89 /// Returns true if theFeature modification was caused by theReason (may be feature of result of this feature)
91 std::shared_ptr<ModelAPI_Feature>& theFeature, std::shared_ptr<ModelAPI_Object> theReason);