SHAPER  9.12.0
SketchSolver_Constraint.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 SketchSolver_Constraint_H_
21 #define SketchSolver_Constraint_H_
22 
23 #include <SketchSolver_Storage.h>
24 #include <PlaneGCSSolver_Update.h>
25 
26 #include <SketchPlugin_Constraint.h>
27 
28 #include <ModelAPI_AttributeDouble.h>
29 #include <ModelAPI_AttributeRefAttr.h>
30 
31 #include <string>
32 #include <vector>
33 
39 {
40 protected:
43  : myType(CONSTRAINT_UNKNOWN)
44  {}
45 
46 public:
48  SketchSolver_Constraint(ConstraintPtr theConstraint);
49 
50  virtual ~SketchSolver_Constraint() {}
51 
55  void process(StoragePtr theStorage, bool theEvensBlocked);
56 
58  virtual void notify(const FeaturePtr& theFeature, PlaneGCSSolver_Update* theUpdater) {}
59 
61  virtual void update();
62 
66  virtual bool remove();
67 
69  virtual void blockEvents(bool isBlocked);
70 
72  static SketchSolver_ConstraintType TYPE(ConstraintPtr theConstraint);
73 
75  virtual SketchSolver_ConstraintType getType() const
76  { return myType; }
77 
79  const std::string& error() const
80  { return myErrorMsg; }
81 
82 protected:
84  virtual void process();
85 
89  virtual void getAttributes(EntityWrapperPtr& theValue,
90  std::vector<EntityWrapperPtr>& theAttributes);
91 
94  virtual void adjustConstraint()
95  {}
96 
99  { myErrorMsg.clear(); }
100 
101 protected:
102  ConstraintPtr myBaseConstraint;
103  ConstraintWrapperPtr mySolverConstraint;
104 
106  StoragePtr myStorage;
107  SketchSolver_ConstraintType myType;
108  std::list<EntityWrapperPtr> myAttributes;
109 
110  std::string myErrorMsg;
111 };
112 
113 typedef std::shared_ptr<SketchSolver_Constraint> SolverConstraintPtr;
114 
115 #endif
Send events to listeners about changing a feature.
Definition: PlaneGCSSolver_Update.h:38
Converts SketchPlugin constraint to the constraint applicable for solver.
Definition: SketchSolver_Constraint.h:39
const std::string & error() const
Shows error message.
Definition: SketchSolver_Constraint.h:79
virtual SketchSolver_ConstraintType getType() const
Returns the type of constraint.
Definition: SketchSolver_Constraint.h:75
SketchSolver_ConstraintType myType
type of constraint
Definition: SketchSolver_Constraint.h:107
ConstraintWrapperPtr mySolverConstraint
wrapper for PlaneGCS constraint
Definition: SketchSolver_Constraint.h:103
virtual void process()
Converts SketchPlugin constraint to a list of solver's constraints.
Definition: SketchSolver_Constraint.cpp:114
virtual void blockEvents(bool isBlocked)
Block or unblock events from this constraint.
Definition: SketchSolver_Constraint.cpp:71
virtual bool remove()
Tries to remove constraint.
Definition: SketchSolver_Constraint.cpp:190
virtual void adjustConstraint()
This method is used in derived objects to check consistency of constraint.
Definition: SketchSolver_Constraint.h:94
SketchSolver_Constraint()
Default constructor.
Definition: SketchSolver_Constraint.h:42
void cleanErrorMsg()
Removes last error.
Definition: SketchSolver_Constraint.h:98
virtual void getAttributes(EntityWrapperPtr &theValue, std::vector< EntityWrapperPtr > &theAttributes)
Generate list of attributes of constraint in order useful for constraints.
Definition: SketchSolver_Constraint.cpp:198
ConstraintPtr myBaseConstraint
base SketchPlugin constraint
Definition: SketchSolver_Constraint.h:102
std::list< EntityWrapperPtr > myAttributes
attributes of constraint
Definition: SketchSolver_Constraint.h:108
StoragePtr myStorage
storage, which contains all information about entities and constraints
Definition: SketchSolver_Constraint.h:106
virtual void update()
Update constraint.
Definition: SketchSolver_Constraint.cpp:147
static SketchSolver_ConstraintType TYPE(ConstraintPtr theConstraint)
Obtain a type of SketchPlugin constraint.
Definition: SketchSolver_Constraint.cpp:77
virtual void notify(const FeaturePtr &theFeature, PlaneGCSSolver_Update *theUpdater)
Notify this object about the feature is changed somewhere.
Definition: SketchSolver_Constraint.h:58
std::string myErrorMsg
error message
Definition: SketchSolver_Constraint.h:110