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 /// Constructor based on SketchPlugin constraint
23 SketchSolver_ConstraintMulti(ConstraintPtr theConstraint) :
24 SketchSolver_Constraint(theConstraint),
31 /// \brief Update constraint
32 virtual void update();
33 /// \brief Update constraint
34 void update(bool isForce);
36 /// \brief Tries to remove constraint
37 /// \return \c false, if current constraint contains another SketchPlugin
38 /// constraints (like for multiple coincidence)
39 virtual bool remove();
41 /// \brief Check the feature is a source or a copy of Multi-constraint
42 virtual bool isUsed(FeaturePtr theFeature) const;
43 /// \brief Check the attribute is used in Multi-constraint
44 virtual bool isUsed(AttributePtr theAttribute) const;
47 /// \brief Converts SketchPlugin constraint to a list of SolveSpace constraints
48 virtual void process()
49 { /* do nothing here */ }
51 /// \brief Collect entities which translated or rotated (not their copies)
52 void getEntities(std::list<EntityWrapperPtr>& theEntities);
54 /// \brief Generate list of attributes of constraint in order useful for SolveSpace constraints
55 /// \param[out] theValue numerical characteristic of constraint (e.g. distance)
56 /// \param[out] theAttributes list of attributes to be filled
57 virtual void getAttributes(double& theValue, std::vector<EntityWrapperPtr>& theAttributes)
58 { /* do nothing here */ }
60 /// \brief This method is used in derived objects to check consistence of constraint.
61 virtual void adjustConstraint();
63 /// \brief Update parameters of derived classes
64 virtual void updateLocal() = 0;
66 /// \brief Returns name of NUMBER_OF_COPIES parameter for corresponding feature
67 virtual const std::string& nameNbObjects() = 0;
70 /// \brief Convert absolute coordinates to relative coordinates
71 virtual void getRelative(double theAbsX, double theAbsY, double& theRelX, double& theRelY) = 0;
72 /// \brief Convert relative coordinates to absolute coordinates
73 virtual void getAbsolute(double theRelX, double theRelY, double& theAbsX, double& theAbsY) = 0;
74 /// \brief Apply transformation for relative coordinates
75 virtual void transformRelative(double& theX, double& theY) = 0;
78 int myNumberOfObjects; ///< number of previous initial objects
79 int myNumberOfCopies; ///< number of previous copies of initial objects
80 bool myIsFullValue; ///< value whether the angle/distance is a full or single for objects
82 bool myAdjusted; ///< the constraint is already adjusted (to not do it several times)
84 /// list of features and their copies to find whether some of them are disappeared
85 std::set<FeaturePtr> myFeatures;