1 // Copyright (C) 2014-2019 CEA/DEN, EDF R&D
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #ifndef PartSet_OverconstraintListener_H
21 #define PartSet_OverconstraintListener_H
23 #include <Events_Listener.h>
24 #include <ModelAPI_Object.h>
26 class ModuleBase_IWorkshop;
36 * A class for processing overconstraint situation. It contains is a list of sketch constraints with
39 class PartSet_OverconstraintListener : public Events_Listener
43 /// \param theWorkshop a current workshop to obtain AIS presentation from displayer
44 PartSet_OverconstraintListener(ModuleBase_IWorkshop* theWorkshop);
46 virtual ~PartSet_OverconstraintListener() {};
48 /// If active state is changed, update fully defined state and sketch sub-entities color
49 /// \param theActive a state
50 void setActive(const bool& theActive);
52 /// Returns true if the object belongs to internal container of conflicting objects
53 /// \param theObject an object to be checked
54 /// \param theColor the output container to be filled in [red, green, blue] values
55 /// \return boolean result
56 void getCustomColor(const ObjectPtr& theObject, std::vector<int>& theColor);
58 /// Redefinition of Events_Listener method
59 virtual void processEvent(const std::shared_ptr<Events_Message>& theMessage);
62 bool isConflictingObject(const ObjectPtr& theObject) const
64 return (myConflictingObjects.find(theObject) != myConflictingObjects.end());
67 const std::set<ObjectPtr>& conflictingObjects() const
69 return myConflictingObjects;
72 bool isFullyConstrained() const { return myIsFullyConstrained; }
75 /// Append objects to the internal container of conflicting object, redisplay necessary objects
76 /// \param theObjects a list of new conflicting objects
77 /// \return boolean value whether the list differs from the internal list
78 bool appendConflictingObjects(const std::set<ObjectPtr>& theObjects);
80 /// Removes objects from internal container of conflicting object, redisplay necessary objects
81 /// \param theObjects a list of repaired objects
82 /// \return boolean value whether the list differs from the internal list
83 bool repairConflictingObjects(const std::set<ObjectPtr>& theObjects);
85 /// Sends update object signal for each object in the container and flush it.
86 /// \param theObjects a list of object to be redisplayed
87 void redisplayObjects(const std::set<ObjectPtr>& theObjects);
91 PartSet_Module* module() const;
94 /// Unite objects in one string information
95 /// \param theObjects a list of objects
96 /// \return a string info
97 static QString getObjectsInfo(const std::set<ObjectPtr>& theObjects);
101 ModuleBase_IWorkshop* myWorkshop;
102 bool myIsActive; /// state if sketch is active
103 std::set<ObjectPtr> myConflictingObjects;
104 bool myIsFullyConstrained; /// state if Solver is fully constrained, DOF = 0