1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: SketchSolver_IConstraintWrapper.h
4 // Created: 30 Nov 2015
5 // Author: Artem ZHIDKOV
7 #ifndef SketchSolver_IConstraintWrapper_H_
8 #define SketchSolver_IConstraintWrapper_H_
10 #include <SketchSolver_IEntityWrapper.h>
12 #include <SketchPlugin_Constraint.h>
17 /// Types of constraints
18 enum SketchSolver_ConstraintType {
19 CONSTRAINT_UNKNOWN = 0,
20 CONSTRAINT_COINCIDENCE, // base coincidence if we don't know exact type yet
21 CONSTRAINT_PT_PT_COINCIDENT,
22 CONSTRAINT_PT_ON_LINE,
23 CONSTRAINT_PT_ON_CIRCLE,
24 CONSTRAINT_DISTANCE, // base distance if we don't know the measured objects yet
25 CONSTRAINT_PT_PT_DISTANCE,
26 CONSTRAINT_PT_LINE_DISTANCE,
30 CONSTRAINT_HORIZONTAL,
33 CONSTRAINT_PERPENDICULAR,
35 CONSTRAINT_EQUAL, // base equality if we don't know the measured objects yet
36 CONSTRAINT_EQUAL_LINES,
37 CONSTRAINT_EQUAL_LINE_ARC,
38 CONSTRAINT_EQUAL_RADIUS,
39 CONSTRAINT_TANGENT, // base tangency if we don't know the measured objects yet
40 CONSTRAINT_TANGENT_ARC_LINE,
41 CONSTRAINT_TANGENT_ARC_ARC,
42 CONSTRAINT_MULTI_TRANSLATION,
43 CONSTRAINT_MULTI_ROTATION
47 * Wrapper providing operations with constraints regardless the solver.
49 class SketchSolver_IConstraintWrapper
52 virtual ~SketchSolver_IConstraintWrapper() {}
54 /// \brief Return base feature
55 const ConstraintPtr& baseConstraint() const
56 { return myBaseConstraint; }
58 /// \brief Return ID of current entity
59 virtual ConstraintID id() const = 0;
61 /// \brief Change group for the constraint
62 virtual void setGroup(const GroupID& theGroup) = 0;
63 /// \brief Return identifier of the group the constraint belongs to
64 virtual GroupID group() const = 0;
66 /// \brief Return type of current entity
67 virtual SketchSolver_ConstraintType type() const = 0;
69 /// \brief Assign list of constrained objects
70 void setEntities(const std::list<EntityWrapperPtr>& theEntities)
71 { myConstrained = theEntities; }
72 /// \brief Return list of constrained objects
73 const std::list<EntityWrapperPtr>& entities() const
74 { return myConstrained; }
76 /// \brief Assign numeric parameter of constraint
77 virtual void setValue(const double& theValue)
78 { myValue = theValue; }
79 /// \brief Return numeric parameter of constraint
80 const double& value() const
83 /// \brief Verify the feature is used in the constraint
84 virtual bool isUsed(FeaturePtr theFeature) const = 0;
85 /// \brief Verify the attribute is used in the constraint
86 virtual bool isUsed(AttributePtr theAttribute) const = 0;
88 /// \brief Compare current constraint with other
89 virtual bool isEqual(const std::shared_ptr<SketchSolver_IConstraintWrapper>& theOther) = 0;
91 /// \brief Update values of parameters of this constraint by the parameters of given one
92 /// \return \c true if some parameters change their values
93 virtual bool update(const std::shared_ptr<SketchSolver_IConstraintWrapper>& theOther) = 0;
96 ConstraintPtr myBaseConstraint;
97 std::list<EntityWrapperPtr> myConstrained;
101 typedef std::shared_ptr<SketchSolver_IConstraintWrapper> ConstraintWrapperPtr;