]> SALOME platform Git repositories - modules/shaper.git/blob - src/Model/Model_Update.h
Salome HOME
Fix for the problem that selection of sub-elements of compsolids for concealment...
[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
21 /**\class Model_Update
22  * \ingroup DataModel
23  * \brief Updates the results of features when it is needed.
24  */
25 class Model_Update : public Events_Listener
26 {
27   /// updated features during this transaction: must be updated immediately
28   std::set<std::shared_ptr<ModelAPI_Object> > myJustUpdated;
29   /// features that must be additionally processed after execution of finish operation
30   std::set<std::shared_ptr<ModelAPI_Object> > myWaitForFinish;
31   /// to know that all next updates are caused by this execution
32   bool myIsExecuted;
33   /// to know execute or not automatically all update
34   bool myIsAutomatic;
35   /// to know that some parameter was changed during this operation
36   bool myIsParamUpdated;
37   /// to execute features of finish if perview is not needed
38   bool myIsFinish;
39   /// Set of already processed features in the "processOperation" method
40   std::set<std::shared_ptr<ModelAPI_Feature> > myProcessed;
41
42   /// internal structure that contains the updating iteration information:
43   /// which object and subobject is iterated, t ocontinue iteration
44   struct IterationItem {
45     /// the main object, subs of it are iterated
46     std::shared_ptr<ModelAPI_CompositeFeature> myMain;
47     /// the currently iterated sub-object
48     std::shared_ptr<ModelAPI_Feature> mySub;
49   };
50   /// List of iterated features: composite feature to the currently iterated sub.
51   /// The first element in the list has no "main": the root document is not feature.
52   std::list<IterationItem> myProcessIterator;
53
54  public:
55   /// Is called only once, on startup of the application
56   Model_Update();
57
58   /// Processes the feature argument update: executes the results
59   MODEL_EXPORT virtual void processEvent(const std::shared_ptr<Events_Message>& theMessage);
60
61 protected:
62   /// Recoursively checks and updates the feature if needed (calls the execute method)
63   /// Returns true if feature was updated.
64   void updateFeature(std::shared_ptr<ModelAPI_Feature> theFeature);
65
66   /// Updates the selection and parametrical arguments before the later feature analysis
67   /// Returns true if something really was updated
68   void updateArguments(std::shared_ptr<ModelAPI_Feature> theFeature);
69
70   /// Sends the redisplay events for feature and results, updates the updated status
71   void redisplayWithResults(std::shared_ptr<ModelAPI_Feature> theFeature, 
72     const ModelAPI_ExecState theState);
73
74   /// On operation start/end/abort the "Just" fileds must be cleared and processed in the right way
75   /// \param theTotalUpdate force to updates everything that has been changed in this operation
76   void processOperation(const bool theTotalUpdate, const bool theFinish = false);
77
78   /// Performs the feature execution
79   /// \returns the status of execution
80   void executeFeature(std::shared_ptr<ModelAPI_Feature> theFeature);
81
82   /// Iterates and updates features from theFeature by managing myProcessIterator.
83   /// Returns only after the iteration is finished.
84   /// \param theFeature is null for iteration of root document (which is not composite)
85   /// \returns false if this feature should not be updated: iteration was moved much upper
86   bool iterateUpdate(std::shared_ptr<ModelAPI_CompositeFeature> theFeature);
87 };
88
89 #endif