SHAPER  9.12.0
PartSet_OverconstraintListener.h
1 // Copyright (C) 2014-2023 CEA, EDF
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 
20 #ifndef PartSet_OverconstraintListener_H
21 #define PartSet_OverconstraintListener_H
22 
23 #include <Events_Listener.h>
24 #include <ModelAPI_Object.h>
25 
27 class PartSet_Module;
28 
29 #include <QString>
30 
31 #include <vector>
32 #include <set>
33 
40 {
41 public:
45 
46  virtual ~PartSet_OverconstraintListener() {};
47 
50  void setActive(const bool& theActive);
51 
56  void getCustomColor(const ObjectPtr& theObject, std::vector<int>& theColor);
57 
59  virtual void processEvent(const std::shared_ptr<Events_Message>& theMessage);
60 
61 
62  bool isConflictingObject(const ObjectPtr& theObject) const
63  {
64  return (myConflictingObjects.find(theObject) != myConflictingObjects.end());
65  }
66 
67  const std::set<ObjectPtr>& conflictingObjects() const
68  {
69  return myConflictingObjects;
70  }
71 
72  const std::set<ObjectPtr>& objectsToRemove() const
73  {
74  return myObjectsToRemove;
75  }
76 
77  bool isFullyConstrained() const { return myIsFullyConstrained; }
78 
79 protected:
83  bool appendConflictingObjects(const std::set<ObjectPtr>& theObjects);
84 
88  bool repairConflictingObjects(const std::set<ObjectPtr>& theObjects);
89 
92  void redisplayObjects(const std::set<ObjectPtr>& theObjects);
93 
94 private:
96  PartSet_Module* module() const;
97 
98 #ifdef _DEBUG
102  static QString getObjectsInfo(const std::set<ObjectPtr>& theObjects);
103 #endif
104 
105 private:
106  ModuleBase_IWorkshop* myWorkshop;
107  bool myIsActive;
108  std::set<ObjectPtr> myConflictingObjects;
109  std::set<ObjectPtr> myObjectsToRemove;
110  bool myIsFullyConstrained;
111 };
112 
113 #endif
Base interface for any event listener.
Definition: Events_Listener.h:37
Class which provides access to Workshop object services.
Definition: ModuleBase_IWorkshop.h:48
Implementation of Partset module.
Definition: PartSet_Module.h:69
A class for processing overconstraint situation.
Definition: PartSet_OverconstraintListener.h:40
void setActive(const bool &theActive)
If active state is changed, update fully defined state and sketch sub-entities color.
Definition: PartSet_OverconstraintListener.cpp:74
void getCustomColor(const ObjectPtr &theObject, std::vector< int > &theColor)
Returns true if the object belongs to internal container of conflicting objects.
Definition: PartSet_OverconstraintListener.cpp:97
virtual void processEvent(const std::shared_ptr< Events_Message > &theMessage)
Redefinition of Events_Listener method.
Definition: PartSet_OverconstraintListener.cpp:121
void redisplayObjects(const std::set< ObjectPtr > &theObjects)
Sends update object signal for each object in the container and flush it.
Definition: PartSet_OverconstraintListener.cpp:334
bool appendConflictingObjects(const std::set< ObjectPtr > &theObjects)
Append objects to the internal container of conflicting object, redisplay necessary objects.
Definition: PartSet_OverconstraintListener.cpp:271
bool repairConflictingObjects(const std::set< ObjectPtr > &theObjects)
Removes objects from internal container of conflicting object, redisplay necessary objects.
Definition: PartSet_OverconstraintListener.cpp:313
PartSet_OverconstraintListener(ModuleBase_IWorkshop *theWorkshop)
Constructor.
Definition: PartSet_OverconstraintListener.cpp:59