SHAPER  9.15.0
SketchSolver_Manager.h
1 // Copyright (C) 2014-2025 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 SketchSolver_Manager_H_
21 #define SketchSolver_Manager_H_
22 
23 #include <SketchSolver_Group.h>
24 
25 #include <Events_Listener.h>
26 
27 #include <list>
28 #include <set>
29 
30 class GeomAPI_Pnt2d;
34 
43 {
44 public:
49 
53  virtual void processEvent(const std::shared_ptr<Events_Message>& theMessage);
54 
59  virtual bool groupMessages();
60 
61 protected:
64 
69  bool updateFeature(const std::shared_ptr<SketchPlugin_Feature>& theFeature);
70 
75  bool updateSketch(const std::shared_ptr<ModelAPI_CompositeFeature>& theSketch);
76 
83  bool moveFeature(const std::shared_ptr<SketchPlugin_Feature>& theMovedFeature,
84  const std::shared_ptr<GeomAPI_Pnt2d>& theFromPoint,
85  const std::shared_ptr<GeomAPI_Pnt2d>& theToPoint);
86 
94  bool moveAttribute(const std::shared_ptr<ModelAPI_Attribute>& theMovedAttribute,
95  const int theMovedPointIndex,
96  const std::shared_ptr<GeomAPI_Pnt2d>& theFromPoint,
97  const std::shared_ptr<GeomAPI_Pnt2d>& theToPoint);
98 
103  bool removeConstraint(std::shared_ptr<SketchPlugin_Constraint> theConstraint);
104 
109  bool resolveConstraints();
110 
111 private:
116  SketchGroupPtr findGroup(std::shared_ptr<SketchPlugin_Feature> theFeature);
121  SketchGroupPtr findGroup(std::shared_ptr<ModelAPI_CompositeFeature> theSketch);
122 
125  bool stopSendUpdate() const;
127  void allowSendUpdate() const;
128 
130  void releaseFeaturesIfEventsBlocked() const;
131 
132 private:
133  std::list<SketchGroupPtr> myGroups;
136  bool myIsComputed;
137 };
138 
139 #endif
Base interface for any event listener.
Definition: Events_Listener.h:37
2D point defined by two coordinates
Definition: GeomAPI_Pnt2d.h:36
Attribute that contains 2D point coordinates.
Definition: GeomDataAPI_Point2D.h:37
Feature that consists of other features: like sketcher with edges inside.
Definition: ModelAPI_CompositeFeature.h:33
Abstract interface to the SketchPlugin_ConstraintBase For more info see: SketchPlugin_ConstraintBase....
Definition: SketchPlugin_Constraint.h:37
Listens the changes of SketchPlugin features and transforms the Constraint feature into the format un...
Definition: SketchSolver_Manager.h:43
bool moveAttribute(const std::shared_ptr< ModelAPI_Attribute > &theMovedAttribute, const int theMovedPointIndex, const std::shared_ptr< GeomAPI_Pnt2d > &theFromPoint, const std::shared_ptr< GeomAPI_Pnt2d > &theToPoint)
Move feature using its moved attribute.
Definition: SketchSolver_Manager.cpp:365
bool updateFeature(const std::shared_ptr< SketchPlugin_Feature > &theFeature)
Adds or updates a constraint or an entity in the suitable group.
Definition: SketchSolver_Manager.cpp:309
bool updateSketch(const std::shared_ptr< ModelAPI_CompositeFeature > &theSketch)
Updates the sketch and related constraints, if the sketch plane is changed.
Definition: SketchSolver_Manager.cpp:290
virtual void processEvent(const std::shared_ptr< Events_Message > &theMessage)
Implementation of Event Listener method.
Definition: SketchSolver_Manager.cpp:148
bool removeConstraint(std::shared_ptr< SketchPlugin_Constraint > theConstraint)
Removes a constraint from the manager.
virtual bool groupMessages()
The solver needs all the updated objects are transferred in one group, not one by one.
Definition: SketchSolver_Manager.cpp:139
bool resolveConstraints()
Goes through the list of groups and solve the constraints.
Definition: SketchSolver_Manager.cpp:439
bool moveFeature(const std::shared_ptr< SketchPlugin_Feature > &theMovedFeature, const std::shared_ptr< GeomAPI_Pnt2d > &theFromPoint, const std::shared_ptr< GeomAPI_Pnt2d > &theToPoint)
Move feature.
Definition: SketchSolver_Manager.cpp:334
static SketchSolver_Manager * instance()
Main method to create constraint manager.
Definition: SketchSolver_Manager.cpp:109