Salome HOME
Do not allow user to move fixed entities (issue #1043)
[modules/shaper.git] / src / SketchSolver / SketchSolver_ConstraintRigid.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:    SketchSolver_ConstraintRigid.h
4 // Created: 30 Mar 2015
5 // Author:  Artem ZHIDKOV
6
7 #ifndef SketchSolver_ConstraintRigid_H_
8 #define SketchSolver_ConstraintRigid_H_
9
10 #include "SketchSolver.h"
11 #include <SketchSolver_Constraint.h>
12
13 /** \class   SketchSolver_ConstraintRigid
14  *  \ingroup Plugins
15  *  \brief   Stores data of Rigid (Fixed) constraint
16  *
17  *  Rigid constraint may have NULL basic SketchPlugin constraint,
18  *  because the Rigid constraint may be temporary for correct moving of objects.
19  *
20  *  Rigid constraint does not create a constraint, but builds the entities in separate group,
21  *  so they will not be moved while resolving the set of constraints.
22  */
23 class SketchSolver_ConstraintRigid : public SketchSolver_Constraint
24 {
25 public:
26   /// Creates constraint to manage the given constraint from plugin
27   SketchSolver_ConstraintRigid(ConstraintPtr theConstraint)
28     : SketchSolver_Constraint(theConstraint)
29   {}
30   /// Creates temporary constraint based on feature
31   SketchSolver_ConstraintRigid(FeaturePtr theFeature);
32
33   /// \brief Update constraint
34   virtual void update(ConstraintPtr theConstraint = ConstraintPtr());
35
36   /// \brief Tries to remove constraint
37   /// \return \c false, if current constraint contains another SketchPlugin constraints (like for multiple coincidence)
38   virtual bool remove(ConstraintPtr theConstraint = ConstraintPtr());
39
40   /// \brief Returns the type of constraint
41   virtual int getType() const
42   { return SLVS_C_WHERE_DRAGGED; }
43
44 protected:
45   /// \brief Converts SketchPlugin constraint to a list of SolveSpace constraints
46   virtual void process();
47
48   /// \brief Generate list of attributes of constraint in order useful for SolveSpace constraints
49   /// \param[out] theValue      numerical characteristic of constraint (e.g. distance)
50   /// \param[out] theAttributes list of attributes to be filled
51   virtual void getAttributes(double& theValue, std::vector<Slvs_hEntity>& theAttributes);
52
53   /// \brief Fixed feature basing on its type
54   virtual void fixFeature();
55
56   /// \brief Fix given point
57   /// \return ID of the Fixed constraint
58   Slvs_hConstraint fixPoint(const Slvs_hEntity& thePointID);
59
60   /// \brief Returns ID of fixed entity
61   Slvs_hEntity fixedEntity() const;
62
63   /// \brief Fixing line position (start and end points)
64   void fixLine(const Slvs_Entity& theLine);
65   /// \brief Fixing circle (center and radius)
66   void fixCircle(const Slvs_Entity& theCircle);
67   /// \brief The arc is fixed differently to avoid SolveSpace problems (overconstraint)
68   ///
69   /// There will be fixed start and end points and the radius of the arc.
70   void fixArc(const Slvs_Entity& theArc);
71
72 protected:
73   FeaturePtr myBaseFeature; ///< fixed feature (when it is set, myBaseConstraint should be NULL)
74 };
75
76 #endif