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