Salome HOME
Make the expressions in double attributes and points updated after the parameter...
[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_Constraint.h>
12
13 /** \class   SketchSolver_ConstraintMultiTranslation
14  *  \ingroup Plugins
15  *  \brief   Convert translated features to the list of SolveSpace constraints
16  */
17 class SketchSolver_ConstraintMultiTranslation : public SketchSolver_Constraint
18 {
19 public:
20   SketchSolver_ConstraintMultiTranslation(ConstraintPtr theConstraint) :
21       SketchSolver_Constraint(theConstraint),
22       myNumberOfObjects(0),
23       myNumberOfCopies(0)
24   {}
25
26   virtual int getType() const
27   { return SLVS_C_MULTI_TRANSLATION; }
28
29   /// \brief Update constraint
30   virtual void update(ConstraintPtr theConstraint = ConstraintPtr());
31
32   /// \brief Tries to remove constraint
33   /// \return \c false, if current constraint contains another SketchPlugin constraints (like for multiple coincidence)
34   virtual bool remove(ConstraintPtr theConstraint = ConstraintPtr());
35
36 protected:
37   /// \brief Converts SketchPlugin constraint to a list of SolveSpace constraints
38   virtual void process();
39
40   /// \brief Generate list of attributes of constraint in order useful for SolveSpace constraints
41   /// \param[out] theValue      numerical characteristic of constraint (e.g. distance)
42   /// \param[out] theAttributes list of attributes to be filled
43   virtual void getAttributes(double& theValue, std::vector<Slvs_hEntity>& theAttributes)
44   { /* do nothing here */ }
45
46   /// \brief Generate list of translated entities
47   /// \param[out] theStartPoint ID of start point of translation
48   /// \param[out] theEndPoint   ID of final point of translation
49   /// \param[out] thePoints     list of IDs of initial points and their translated copies
50   /// \param[out] theCircular   list of IDs of arcs and circles and their copies
51   void getAttributes(Slvs_hEntity& theStartPoint, Slvs_hEntity& theEndPoint,
52                      std::vector<std::vector<Slvs_hEntity> >& thePoints,
53                      std::vector<std::vector<Slvs_hEntity> >& theCircular);
54
55   /// \brief This method is used in derived objects to check consistence of constraint.
56   virtual void adjustConstraint();
57
58 private:
59   size_t myNumberOfObjects; ///< number of previous initial objects
60   size_t myNumberOfCopies;  ///< number of previous copies of initial objects
61   Slvs_hEntity myTranslationLine; ///< ID of translation line
62 };
63
64 #endif