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),
29 myIsEventsBlocked(false)
32 /// \brief Update constraint
33 virtual void update();
35 /// \brief Notify this object about the feature is changed somewhere
36 virtual void notify(const FeaturePtr& theFeature, PlaneGCSSolver_Update*);
38 /// \brief Tries to remove constraint
39 /// \return \c false, if current constraint contains another SketchPlugin
40 /// constraints (like for multiple coincidence)
41 virtual bool remove();
43 /// \brief Block or unblock events from this constraint
44 virtual void blockEvents(bool isBlocked);
47 /// \brief Converts SketchPlugin constraint to a list of SolveSpace constraints
48 virtual void process()
49 { /* do nothing here */ }
51 /// \brief Collect entities which are 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 virtual void getAttributes(EntityWrapperPtr&, std::vector<EntityWrapperPtr>&)
56 { /* do nothing here */ }
58 /// \brief This method is used in derived objects to check consistence of constraint.
59 virtual void adjustConstraint();
61 /// \brief Update parameters of derived classes
62 virtual void updateLocal() = 0;
64 /// \brief Returns name of NUMBER_OF_COPIES parameter for corresponding feature
65 virtual const std::string& nameNbObjects() = 0;
68 /// \brief Convert absolute coordinates to relative coordinates
69 virtual void getRelative(double theAbsX, double theAbsY, double& theRelX, double& theRelY) = 0;
70 /// \brief Convert relative coordinates to absolute coordinates
71 virtual void getAbsolute(double theRelX, double theRelY, double& theAbsX, double& theAbsY) = 0;
72 /// \brief Apply transformation for relative coordinates
73 virtual void transformRelative(double& theX, double& theY) = 0;
76 int myNumberOfObjects; ///< number of previous initial objects
77 int myNumberOfCopies; ///< number of previous copies of initial objects
78 bool myIsFullValue; ///< value whether the angle/distance is a full or single for objects
80 bool myAdjusted; ///< the constraint is already adjusted (to not do it several times)
82 /// list of features and their copies to find whether some of them are disappeared
83 std::set<FeaturePtr> myFeatures;
85 bool myIsEventsBlocked;