-// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+// Copyright (C) 2015-20xx CEA/DEN, EDF R&D
// File: SketchSolver_ConstraintMovement.h
// Created: 15 Jun 2015
#ifndef SketchSolver_ConstraintMovement_H_
#define SketchSolver_ConstraintMovement_H_
-#include "SketchSolver.h"
-#include <SketchSolver_ConstraintRigid.h>
+#include <SketchSolver_ConstraintFixed.h>
-#include <GeomDataAPI_Point2D.h>
+class GeomAPI_Pnt2d;
/** \class SketchSolver_ConstraintMovement
* \ingroup Plugins
- * \brief Stores data of Rigid (Fixed) constraint for the moved feature only
+ * \brief Stores data to the Fixed constraint for the moved feature only
*/
-class SketchSolver_ConstraintMovement : public SketchSolver_ConstraintRigid
+class SketchSolver_ConstraintMovement : public SketchSolver_ConstraintFixed
{
-private:
- /// Creates constraint to manage the given constraint from plugin
- SketchSolver_ConstraintMovement(ConstraintPtr theConstraint)
- : SketchSolver_ConstraintRigid(theConstraint)
- {}
-
public:
- /// Creates temporary constraint based on feature
+ /// Creates movement constraint based on feature
SketchSolver_ConstraintMovement(FeaturePtr theFeature);
+ /// Creates movement constraint based on point
+ SketchSolver_ConstraintMovement(AttributePtr thePoint);
+
+ /// \brief Set coordinates of the start point of the movement
+ void startPoint(const std::shared_ptr<GeomAPI_Pnt2d>& theStartPoint)
+ { myStartPoint = theStartPoint; }
+
+ /// \brief Set coordinates of fixed feature to the values where it has been dragged.
+ /// Useful when the feature is being moved.
+ void moveTo(const std::shared_ptr<GeomAPI_Pnt2d>& theDestinationPoint);
+
+ /// \brief Block or unblock events from this constraint
+ virtual void blockEvents(bool isBlocked);
+
+ /// \brief Returns moved feature
+ FeaturePtr movedFeature() const
+ { return myMovedFeature; }
+
protected:
/// \brief Converts SketchPlugin constraint to a list of SolveSpace constraints
virtual void process();
- /// \brief Generate list of attributes of constraint in order useful for SolveSpace constraints
- /// \param[out] theValue numerical characteristic of constraint (e.g. distance)
- /// \param[out] theAttributes list of attributes to be filled
- /// \param[out] theIsFullyMoved shows that the feature is moved, in other case only one point of the feature is shifted
- virtual void getAttributes(double& theValue, std::vector<Slvs_hEntity>& theAttributes, bool& theIsFullyMoved);
-
- /// \brief Fixed feature basing on its type
- virtual void fixFeature();
+ /// \brief Obtain entity to be fixed
+ virtual EntityWrapperPtr entityToFix();
private:
- /// \brief Check the coordinates of point are differ than coordinates of correponding SolveSpace entity
- bool isMoved(std::shared_ptr<GeomDataAPI_Point2D> thePoint, const Slvs_Entity& theEntity);
+ FeaturePtr myMovedFeature; ///< fixed feature (when it is set, myBaseConstraint should be NULL)
+ AttributePtr myDraggedPoint; ///< one of the feature points which has been moved
+ std::shared_ptr<GeomAPI_Pnt2d> myStartPoint; ///< start point of the movement
};
#endif