Salome HOME
Merge branch 'master' into cgt/devCEA
[modules/shaper.git] / src / PartSet / PartSet_OverconstraintListener.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        PartSet_OverconstraintListener.h
4 // Created:     8 Feb 2016
5 // Author:      Natalia ERMOLAEVA
6
7
8 #ifndef PartSet_OverconstraintListener_H
9 #define PartSet_OverconstraintListener_H
10
11 #include <Events_Listener.h>
12 #include <ModelAPI_Object.h>
13
14 class ModuleBase_IWorkshop;
15 class PartSet_Module;
16
17 #include <QString>
18
19 #include <vector>
20 #include <set>
21
22 /**
23 * \ingroup GUI
24 * A class for processing overconstraint situation. It contains is a list of sketch constraints with
25 * conflicts.
26 */
27 class PartSet_OverconstraintListener : public Events_Listener
28 {
29 public:
30   /// Constructor
31   /// \param theWorkshop a current workshop to obtain AIS presentation from displayer
32   PartSet_OverconstraintListener(ModuleBase_IWorkshop* theWorkshop);
33
34   virtual ~PartSet_OverconstraintListener() {};
35
36   /// If active state is changed, update fully defined state and sketch sub-entities color
37   /// \param theActive a state
38   void setActive(const bool& theActive);
39
40   /// Returns true if the object belongs to internal container of conflicting objects
41   /// \param theObject an object to be checked
42   /// \param theColor the output container to be filled in [red, green, blue] values
43   /// \return boolean result
44   void getCustomColor(const ObjectPtr& theObject, std::vector<int>& theColor);
45
46   /// Redefinition of Events_Listener method
47   virtual void processEvent(const std::shared_ptr<Events_Message>& theMessage);
48
49 protected:
50   /// Append objects to the internal container of conflicting object, redisplay necessary objects
51   /// \param theObjects a list of new conflicting objects
52   /// \return boolean value whether the list differs from the internal list
53   bool appendConflictingObjects(const std::set<ObjectPtr>& theObjects);
54
55   /// Removes objects from internal container of conflicting object, redisplay necessary objects
56   /// \param theObjects a list of repaired objects
57   /// \return boolean value whether the list differs from the internal list
58   bool repairConflictingObjects(const std::set<ObjectPtr>& theObjects);
59
60   /// Sends update object signal for each object in the container and flush it.
61   /// \param theObjects a list of object to be redisplayed
62   void redisplayObjects(const std::set<ObjectPtr>& theObjects);
63
64 private:
65   /// Returns module
66   PartSet_Module* module() const;
67
68 #ifdef _DEBUG
69   /// Unite objects in one string information
70   /// \param theObjects a list of objects
71   /// \return a string info
72   static QString getObjectsInfo(const std::set<ObjectPtr>& theObjects);
73 #endif
74
75 private:
76   ModuleBase_IWorkshop* myWorkshop;
77   bool myIsActive; /// state if sketch is active
78   std::set<ObjectPtr> myConflictingObjects;
79   bool myIsFullyConstrained; /// state if Solver is fully constrained, DOF = 0
80 };
81
82 #endif