Salome HOME
772d00987a8ec81eb3fe825566acdbfa8e2a9fd3
[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 XGUI_Workshop;
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   /// Set erroneous color for the presentation of object if the object is in the conflicting list
37   /// \param theObject an object to be settled
38   /// \param theUpdateViewer a boolean state whether the current viewer should be updated
39   //bool customizeObject(ObjectPtr theObject, const bool theUpdateViewer);
40
41   /// Returns true if the object belongs to internal container of conflicting objects
42   /// \param theObject an object to be checked
43   /// \return boolean result
44   bool isConflictingObject(const ObjectPtr& theObject);
45   
46   /// Returns values of conflicting color
47   /// \param theColor the output container to be filled in [red, green, blue] values
48   void getConflictingColor(std::vector<int>& theColor);
49
50   /// Redefinition of Events_Listener method
51   virtual void processEvent(const std::shared_ptr<Events_Message>& theMessage);
52
53 protected:
54   /// Append objects to the internal container of conflicting object, redisplay necessary objects
55   /// \param theObjects a list of new conflicting objects
56   /// \return boolean value whether the list differs from the internal list
57   bool appendConflictingObjects(const std::set<ObjectPtr>& theObjects);
58
59   /// Removes objects from internal container of conflicting object, redisplay necessary objects
60   /// \param theObjects a list of repaired objects
61   /// \return boolean value whether the list differs from the internal list
62   bool repairConflictingObjects(const std::set<ObjectPtr>& theObjects);
63
64   /// Obtains the object custom AIS presentation and change conflicting state if it exists
65   /// \param theObject the object which presentation error state should be changed
66   /// \param theConflicting if true, the object state is erroneous, else correct
67   void setConflictingObject(const ObjectPtr& theObject, const bool theConflicting);
68
69   /// Sends update object signal for each object in the container and flush it.
70   /// \param theObjects a list of object to be redisplayed
71   void redisplayObjects(const std::set<ObjectPtr>& theObjects);
72
73 private:
74   /// Returns workshop
75   XGUI_Workshop* workshop() const;
76
77   /// Unite objects in one string information
78   /// \param theObjects a list of objects
79   /// \return a string info
80   static QString getObjectsInfo(const std::set<ObjectPtr>& theObjects);
81
82 private:
83   std::set<ObjectPtr> myConflictingObjects;
84   ModuleBase_IWorkshop* myWorkshop;
85 };
86
87 #endif