X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2FSketchSolver%2FSketchSolver_Constraint.h;h=8589dc19bb7d5b3d2e23e48a71950db084f71e5b;hb=e94feebdafb664910b36c3a2e526b06cd7dd3fdc;hp=b7925d66c9c400190818c55426f0709d29d8efcf;hpb=bc06873747d5ea9bc0e8d6bd56641eebe33ac08d;p=modules%2Fshaper.git diff --git a/src/SketchSolver/SketchSolver_Constraint.h b/src/SketchSolver/SketchSolver_Constraint.h index b7925d66c..8589dc19b 100644 --- a/src/SketchSolver/SketchSolver_Constraint.h +++ b/src/SketchSolver/SketchSolver_Constraint.h @@ -51,6 +51,9 @@ public: /// \brief Returns the type of constraint virtual int getType() const = 0; + /// \brief The constraint is made temporary + void makeTemporary() const; + /// \brief Checks the constraint is used by current object virtual bool hasConstraint(ConstraintPtr theConstraint) const { return theConstraint == myBaseConstraint; } @@ -63,6 +66,9 @@ public: /// \brief Return identifier of SolveSpace entity relating to the attribute Slvs_hEntity getId(AttributePtr theAttribute) const; + /// \brief Adds a feature to constraint and create its analogue in SolveSpace + virtual void addFeature(FeaturePtr theFeature); + /// \brief Shows error message const std::string& error() const { return myErrorMsg; } @@ -76,6 +82,16 @@ protected: /// \param[out] theAttributes list of attributes to be filled virtual void getAttributes(double& theValue, std::vector& theAttributes); + /// \brief Verify the attributes of constraint are changed (and constraint need to rebuild) + /// \param[in] theConstraint constraint, which attributes should be checked (if NULL, the myBaseConstraint is used) + /// \return \c true if some attributes are changed + virtual bool checkAttributesChanged(ConstraintPtr theConstraint); + + /// \brief This method is used in derived objects to check consistency of constraint. + /// E.g. the distance between line and point may be signed. + virtual void adjustConstraint() + {} + /// \brief Create or change SlveSpace entity according to the given attribute /// \param[in] theAttribute reference to the entity to be changed /// \param[out] theType type of created entity @@ -86,6 +102,14 @@ protected: /// \brief Create or change SlveSpace entity according to the given feature Slvs_hEntity changeEntity(FeaturePtr theFeature, int& theType); + /// \brief Calculate middle point on the specified entity + /// \param[in] theEntity arc or line + /// \param[in] theCoeff is a value in [0.0, 1.0] which shows the position of the point on the entity (0.0 - start point, 1.0 - end point) + /// \param[out] theX X coordinate of middle point + /// \param[out] theY Y coordinate of middle point + void calculateMiddlePoint(const Slvs_Entity& theEntity, double theCoeff, + double& theX, double& theY) const; + /// \brief Removes the links to unused entities void cleanRemovedEntities(); @@ -93,6 +117,10 @@ protected: void cleanErrorMsg() { myErrorMsg.clear(); } +private: + /// \brief Sets error, if the attribute is not initialized + bool isInitialized(AttributePtr theAttribute); + protected: SketchSolver_Group* myGroup; ///< the group which contains current constraint ConstraintPtr myBaseConstraint; ///< SketchPlugin constraint @@ -109,22 +137,6 @@ typedef std::shared_ptr SolverConstraintPtr; -/** \class SketchSolver_ConstraintDistance - * \ingroup Plugins - * \brief Convert distance constraint to SolveSpace structure - */ -class SketchSolver_ConstraintDistance : public SketchSolver_Constraint -{ -public: - SketchSolver_ConstraintDistance(ConstraintPtr theConstraint) : - SketchSolver_Constraint(theConstraint) - {} - - virtual int getType() const - { return SLVS_C_PT_PT_DISTANCE; } -}; - - /** \class SketchSolver_ConstraintParallel * \ingroup Plugins * \brief Convert Parallel constraint to SolveSpace structure @@ -188,4 +200,27 @@ public: { return SLVS_C_VERTICAL; } }; + +/** \class SketchSolver_ConstraintRadius + * \ingroup Plugins + * \brief Convert Radius constraint to SolveSpace structure + */ +class SketchSolver_ConstraintRadius : public SketchSolver_Constraint +{ +public: + SketchSolver_ConstraintRadius(ConstraintPtr theConstraint) : + SketchSolver_Constraint(theConstraint) + {} + + virtual int getType() const + { return SLVS_C_DIAMETER; } + + virtual void adjustConstraint() + { + Slvs_Constraint aConstraint = myStorage->getConstraint(mySlvsConstraints.front()); + aConstraint.valA *= 2.0; + myStorage->updateConstraint(aConstraint); + } +}; + #endif