1 // Copyright (C) 2017-2019 CEA/DEN, EDF R&D
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 // File: SketchSolver_ConstraintMovement.h
21 // Created: 15 Jun 2015
22 // Author: Artem ZHIDKOV
24 #ifndef SketchSolver_ConstraintMovement_H_
25 #define SketchSolver_ConstraintMovement_H_
27 #include <SketchSolver_ConstraintFixed.h>
31 /** \class SketchSolver_ConstraintMovement
33 * \brief Stores data to the Fixed constraint for the moved feature only
35 class SketchSolver_ConstraintMovement : public SketchSolver_ConstraintFixed
38 /// Creates movement constraint based on feature
39 SketchSolver_ConstraintMovement(FeaturePtr theFeature);
41 /// Creates movement constraint based on point
42 SketchSolver_ConstraintMovement(AttributePtr thePoint);
44 /// \brief Set coordinates of the start point of the movement
45 void startPoint(const std::shared_ptr<GeomAPI_Pnt2d>& theStartPoint);
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);
51 /// \brief Block or unblock events from this constraint
52 virtual void blockEvents(bool isBlocked);
54 /// \brief Returns moved feature
55 FeaturePtr movedFeature() const
56 { return myMovedFeature; }
59 /// \brief Converts SketchPlugin constraint to a list of SolveSpace constraints
60 virtual void process();
62 /// \brief Create Fixed constraint for the feature basing on its type and moved point
63 /// \return Fixed constraint
64 ConstraintWrapperPtr initMovement();
66 /// \brief Create constraint to fix moved arc extremity
67 ConstraintWrapperPtr fixArcExtremity(const EntityWrapperPtr& theArcExtremity);
69 /// \brief Create constraint to fix moved point on circle/arc
70 ConstraintWrapperPtr fixPointOnCircle(const EntityWrapperPtr& theCircular);
72 /// \brief Create constraint to fix moved point on ellipse/elliptic arc
73 ConstraintWrapperPtr fixPointOnEllipse(const EntityWrapperPtr& theConic);
76 FeaturePtr myMovedFeature; ///< fixed feature (if set, myBaseConstraint should be NULL)
77 AttributePtr myDraggedPoint; ///< one of the feature points which has been moved
78 std::shared_ptr<GeomAPI_Pnt2d> myStartPoint; ///< start point of the movement
80 bool mySimpleMove; ///< simple move, thus all parameters should be increased by movement delta