Salome HOME
Issue #2133: Edge with middle node constraint can be moved
[modules/shaper.git] / src / SketchSolver / SketchSolver_ConstraintFixed.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:    SketchSolver_ConstraintFixed.h
4 // Created: 30 Mar 2015
5 // Author:  Artem ZHIDKOV
6
7 #ifndef SketchSolver_ConstraintFixed_H_
8 #define SketchSolver_ConstraintFixed_H_
9
10 #include <SketchSolver_Constraint.h>
11
12 /** \class   SketchSolver_ConstraintFixed
13  *  \ingroup Plugins
14  *  \brief   Stores data of the Fixed constraint
15  *
16  *  Fixed constraint may have NULL basic SketchPlugin constraint,
17  *  because the Fixed constraint may be temporary for correct moving of objects.
18  */
19 class SketchSolver_ConstraintFixed : public SketchSolver_Constraint
20 {
21 public:
22   /// Creates constraint to manage the given constraint from plugin
23   SketchSolver_ConstraintFixed(ConstraintPtr theConstraint);
24   /// Creates temporary constraint based on feature (useful while the feature is being moved)
25   SketchSolver_ConstraintFixed(FeaturePtr theFeature);
26
27   /// \brief Block or unblock events from this constraint
28   virtual void blockEvents(bool isBlocked);
29
30   /// \brief Set coordinates of fixed feature to the values where it has been dragged.
31   ///        Useful when the feature is being moved.
32   void moveFeature();
33
34 protected:
35   /// \brief Converts SketchPlugin constraint to a list of SolveSpace constraints
36   virtual void process();
37
38   /// \brief Generate list of attributes of constraint in order useful for constraints
39   /// \param[out] theBaseEntity  the entity which coordinates should be fixed
40   /// \param[out] theFixedEntity the entity containing fixed values
41   virtual void getAttributes(EntityWrapperPtr& theBaseEntity,
42                              EntityWrapperPtr& theFixedEntity);
43
44   /// \brief Fixed feature basing on its type
45   /// \param theFeature [in]  feature, converted to solver specific format
46   virtual void fixFeature(EntityWrapperPtr theFeature);
47
48 private:
49   FeaturePtr myBaseFeature; ///< fixed feature (when it is set, myBaseConstraint should be NULL)
50
51   ConstraintWrapperPtr myConstraint;
52   std::vector<double> myFixedValues;
53   EntityWrapperPtr    myFixedEntity;
54 };
55
56 #endif