Salome HOME
Issue #17347: B-Splines in Sketcher
[modules/shaper.git] / src / SketchSolver / SketchSolver_ConstraintMovement.h
1 // Copyright (C) 2017-2019  CEA/DEN, EDF R&D
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 // File:    SketchSolver_ConstraintMovement.h
21 // Created: 15 Jun 2015
22 // Author:  Artem ZHIDKOV
23
24 #ifndef SketchSolver_ConstraintMovement_H_
25 #define SketchSolver_ConstraintMovement_H_
26
27 #include <SketchSolver_ConstraintFixed.h>
28
29 class GeomAPI_Pnt2d;
30
31 /** \class   SketchSolver_ConstraintMovement
32  *  \ingroup Plugins
33  *  \brief   Stores data to the Fixed constraint for the moved feature only
34  */
35 class SketchSolver_ConstraintMovement : public SketchSolver_ConstraintFixed
36 {
37 public:
38   /// Creates movement constraint based on feature
39   SketchSolver_ConstraintMovement(FeaturePtr theFeature);
40
41   /// Creates movement constraint based on point
42   SketchSolver_ConstraintMovement(AttributePtr theMovedAttribute, const int thePointIndex = -1);
43
44   /// \brief Set coordinates of the start point of the movement
45   void startPoint(const std::shared_ptr<GeomAPI_Pnt2d>& theStartPoint);
46
47   /// \brief Set coordinates of fixed feature to the values where it has been dragged.
48   ///        Useful when the feature is being moved.
49   void moveTo(const std::shared_ptr<GeomAPI_Pnt2d>& theDestinationPoint);
50
51   /// \brief Block or unblock events from this constraint
52   virtual void blockEvents(bool isBlocked);
53
54   /// \brief Returns moved feature
55   FeaturePtr movedFeature() const
56   { return myMovedFeature; }
57
58 protected:
59   /// \brief Converts SketchPlugin constraint to a list of SolveSpace constraints
60   virtual void process();
61
62   /// \brief Create Fixed constraint for the feature basing on its type and moved point
63   /// \return Fixed constraint
64   ConstraintWrapperPtr initMovement();
65
66   /// \brief Create constraint to fix moved arc extremity
67   ConstraintWrapperPtr fixArcExtremity(const EntityWrapperPtr& theArcExtremity);
68
69   /// \brief Create constraint to fix moved point on circle/arc
70   ConstraintWrapperPtr fixPointOnCircle(const EntityWrapperPtr& theCircular);
71
72   /// \brief Create constraint to fix moved point on ellipse/elliptic arc
73   ConstraintWrapperPtr fixPointOnEllipse(const EntityWrapperPtr& theConic);
74
75 private:
76   FeaturePtr       myMovedFeature; ///< fixed feature (if set, myBaseConstraint should be NULL)
77   AttributePtr     myDraggedAttribute; ///< one of the feature points which has been moved
78   int              myDraggedPointIndex; ///< index of the point if the moved attribute is an array
79   std::shared_ptr<GeomAPI_Pnt2d> myStartPoint; ///< start point of the movement
80
81   bool mySimpleMove; ///< simple move, thus all parameters should be increased by movement delta
82 };
83
84 #endif