1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: SketchSolver_ConstraintMulti.h
5 // Author: Artem ZHIDKOV
7 #ifndef SketchSolver_ConstraintMulti_H_
8 #define SketchSolver_ConstraintMulti_H_
10 #include "SketchSolver.h"
11 #include <SketchSolver_Constraint.h>
15 /** \class SketchSolver_ConstraintMulti
17 * \brief Common base class for the Multi constraints
19 class SketchSolver_ConstraintMulti : public SketchSolver_Constraint
22 SketchSolver_ConstraintMulti(ConstraintPtr theConstraint) :
23 SketchSolver_Constraint(theConstraint),
29 virtual int getType() const
30 { return SLVS_C_UNKNOWN; }
32 /// \brief Update constraint
33 virtual void update(ConstraintPtr theConstraint = ConstraintPtr());
35 /// \brief Tries to remove constraint
36 /// \return \c false, if current constraint contains another SketchPlugin constraints (like for multiple coincidence)
37 virtual bool remove(ConstraintPtr theConstraint = ConstraintPtr());
39 /// \brief Adds a feature to constraint and create its analogue in SolveSpace
40 virtual void addFeature(FeaturePtr theFeature);
42 /// \brief Update SketchPlugin attributes using the data obtained from SolveSpace entities
43 virtual void refresh()
46 SketchSolver_Constraint::refresh();
49 /// \brief Verifies, the coincidence between points of copied entities appears or disappears,
50 /// and removes or adds fixing of corresponding points.
51 void checkCoincidence();
54 /// \brief Converts SketchPlugin constraint to a list of SolveSpace constraints
55 virtual void process()
56 { /* do nothing here */ }
58 /// \brief Collect entities and their copies, like circles and arcs
59 void processEntities(const std::vector< std::vector<Slvs_hEntity> >& theEntAndCopies);
61 /// \brief Generate list of attributes of constraint in order useful for SolveSpace constraints
62 /// \param[out] theValue numerical characteristic of constraint (e.g. distance)
63 /// \param[out] theAttributes list of attributes to be filled
64 virtual void getAttributes(double& theValue, std::vector<Slvs_hEntity>& theAttributes)
65 { /* do nothing here */ }
67 /// \brief This method is used in derived objects to check consistence of constraint.
68 virtual void adjustConstraint();
70 /// \brief Update parameters of derived classes
71 virtual void updateLocal() = 0;
73 /// \brief Returns name of NUMBER_OF_COPIES parameter for corresponding feature
74 virtual const std::string& nameNbCopies() = 0;
77 /// \brief Convert absolute coordinates to relative coordinates
78 virtual void getRelative(double theAbsX, double theAbsY, double& theRelX, double& theRelY) = 0;
79 /// \brief Convert relative coordinates to absolute coordinates
80 virtual void getAbsolute(double theRelX, double theRelY, double& theAbsX, double& theAbsY) = 0;
81 /// \brief Apply transformation for relative coordinates
82 virtual void transformRelative(double& theX, double& theY) = 0;
85 size_t myNumberOfObjects; ///< number of previous initial objects
86 size_t myNumberOfCopies; ///< number of previous copies of initial objects
88 std::vector< std::vector<Slvs_hEntity> > myPointsAndCopies; ///< list of initial points and their copies
89 std::vector< std::vector<Slvs_hEntity> > myCircsAndCopies; ///< list of circles and their copies (to change their radii together)
91 std::set<Slvs_hEntity> myPointsJustUpdated; ///< list of points touched by user
92 std::set<Slvs_hEntity> myInitialPoints; ///< list of points containing initial objects
94 bool myAdjusted; ///< the constraint is already adjusted (to not do it several times)