Salome HOME
SketchSolver Refactoring: Eliminate SolveSpace as a sketch solver.
[modules/shaper.git] / src / SketchSolver / SketchSolver_ConstraintMultiTranslation.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:    SketchSolver_ConstraintMultiTranslation.h
4 // Created: 1 Apr 2015
5 // Author:  Artem ZHIDKOV
6
7 #ifndef SketchSolver_ConstraintMultiTranslation_H_
8 #define SketchSolver_ConstraintMultiTranslation_H_
9
10 #include "SketchSolver.h"
11 #include <SketchSolver_ConstraintMulti.h>
12
13 #include "GeomDataAPI_Point2D.h"
14
15 /** \class   SketchSolver_ConstraintMultiTranslation
16  *  \ingroup Plugins
17  *  \brief   Convert translated features to the list of SolveSpace constraints
18  */
19 class SketchSolver_ConstraintMultiTranslation : public SketchSolver_ConstraintMulti
20 {
21 public:
22   /// Constructor based on SketchPlugin constraint
23   SketchSolver_ConstraintMultiTranslation(ConstraintPtr theConstraint) :
24       SketchSolver_ConstraintMulti(theConstraint)
25   {}
26
27 protected:
28   /// \brief Converts SketchPlugin constraint to a list of SolveSpace constraints
29   virtual void process() override;
30
31   /// \brief Generate list of translated entities
32   /// \param[out] theStartPoint start point of translation
33   /// \param[out] theEndPoint   final point of translation
34   /// \param[out] theFullValue  applying translation using the distance as a full or single value
35   /// \param[out] theEntities   list of base entities
36   void getAttributes(EntityWrapperPtr& theStartPoint, EntityWrapperPtr& theEndPoint,
37                      bool& theFullValue, std::list<EntityWrapperPtr>& theEntities);
38
39   /// \brief This method is used in derived objects to check consistence of constraint.
40   virtual void adjustConstraint() override;
41
42   /// \brief Update parameters (called from base class)
43   virtual void updateLocal() override;
44
45 private:
46   /// \brief Convert absolute coordinates to relative coordinates
47   virtual void getRelative(double theAbsX, double theAbsY,
48                            double& theRelX, double& theRelY) override;
49   /// \brief Convert relative coordinates to absolute coordinates
50   virtual void getAbsolute(double theRelX, double theRelY,
51                            double& theAbsX, double& theAbsY) override;
52   /// \brief Apply transformation for relative coordinates
53   virtual void transformRelative(double& theX, double& theY) override;
54
55   /// \brief Returns name of NUMBER_OF_COPIES parameter for corresponding feature
56   virtual const std::string& nameNbObjects() override;
57
58 private:
59   AttributePoint2DPtr myStartPointAttribute;
60   AttributePoint2DPtr myEndPointAttribute;
61
62   double myDelta[2]; ///< increment of translation
63 };
64
65 #endif