X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2FSketchSolver%2FSketchSolver_Constraint.h;h=e4081174610fa7843e0bb87da9f2487a7cbf4cf6;hb=c02fae5493cc6d56c9a1db3bdcf6d872f88fea07;hp=d1ea3e1b55f788d843ac9a002ace028cab235e3a;hpb=37c59d59b17e4a7e304588fb647488457a0c7283;p=modules%2Fshaper.git diff --git a/src/SketchSolver/SketchSolver_Constraint.h b/src/SketchSolver/SketchSolver_Constraint.h index d1ea3e1b5..e40811746 100644 --- a/src/SketchSolver/SketchSolver_Constraint.h +++ b/src/SketchSolver/SketchSolver_Constraint.h @@ -1,14 +1,27 @@ -// Copyright (C) 2014-20xx CEA/DEN, EDF R&D - -// File: SketchSolver_Constraint.h -// Created: 27 May 2014 -// Author: Artem ZHIDKOV +// Copyright (C) 2014-2019 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// #ifndef SketchSolver_Constraint_H_ #define SketchSolver_Constraint_H_ -#include "SketchSolver.h" #include +#include #include @@ -27,52 +40,41 @@ class SketchSolver_Constraint protected: /// Default constructor SketchSolver_Constraint() - : myGroupID(GID_UNKNOWN), - myType(CONSTRAINT_UNKNOWN) + : myType(CONSTRAINT_UNKNOWN) {} public: /// Constructor based on SketchPlugin constraint - SKETCHSOLVER_EXPORT SketchSolver_Constraint(ConstraintPtr theConstraint); + SketchSolver_Constraint(ConstraintPtr theConstraint); virtual ~SketchSolver_Constraint() {} /// \brief Initializes parameters and start constraint creation - /// \param theStorage [in] storage where to place new constraint - /// \param theGroupID [in] group for constraint - /// \param theSketchID [in] sketch for constraint - void process(StoragePtr theStorage, const GroupID& theGroupID, const EntityID& theSketchID); + /// \param theStorage [in] storage where to place new constraint + /// \param theEventsBlocked [in] all events from this constraint should be blocked + void process(StoragePtr theStorage, bool theEvensBlocked); + + /// \brief Notify this object about the feature is changed somewhere + virtual void notify(const FeaturePtr& theFeature, PlaneGCSSolver_Update* theUpdater) {} /// \brief Update constraint - SKETCHSOLVER_EXPORT virtual void update(); + virtual void update(); /// \brief Tries to remove constraint - /// \return \c false, if current constraint contains another SketchPlugin constraints (like for multiple coincidence) - SKETCHSOLVER_EXPORT virtual bool remove(); + /// \return \c false, if current constraint contains another SketchPlugin constraints + /// (like for multiple coincidence) + virtual bool remove(); + + /// \brief Block or unblock events from this constraint + virtual void blockEvents(bool isBlocked); /// \brief Obtain a type of SketchPlugin constraint - SKETCHSOLVER_EXPORT static SketchSolver_ConstraintType TYPE(ConstraintPtr theConstraint); + static SketchSolver_ConstraintType TYPE(ConstraintPtr theConstraint); /// \brief Returns the type of constraint -//// virtual SketchSolver_ConstraintType getType() const = 0; virtual SketchSolver_ConstraintType getType() const { return myType; } - /// \brief The constraint is made temporary - void makeTemporary() const; - - /// \brief Verify the feature or any its attribute is used by constraint - bool isUsed(FeaturePtr theFeature) const; - /// \brief Verify the attribute is used by constraint - bool isUsed(AttributePtr theAttribute) const; - -//// /// \brief Checks the constraint is used by current object -//// SKETCHSOLVER_EXPORT virtual bool hasConstraint(ConstraintPtr theConstraint) const; -//// -//// /// \brief Return list of SketchPlugin constraints attached to this object -//// virtual const std::list& constraints() const -//// { return myConstraints; } - /// \brief Shows error message const std::string& error() const { return myErrorMsg; } @@ -84,12 +86,8 @@ protected: /// \brief Generate list of attributes of constraint in order useful for constraints /// \param[out] theValue numerical characteristic of constraint (e.g. distance) /// \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); + virtual void getAttributes(EntityWrapperPtr& theValue, + std::vector& theAttributes); /// \brief This method is used in derived objects to check consistency of constraint. /// E.g. the distance between line and point may be signed. @@ -101,110 +99,17 @@ protected: { myErrorMsg.clear(); } protected: - GroupID myGroupID; ///< identifier of the group, the constraint belongs to - EntityID mySketchID; ///< identifier of the sketch, the constraint belongs to ConstraintPtr myBaseConstraint; ///< base SketchPlugin constraint - StoragePtr myStorage; ///< storage, which contains all information about entities and constraints + ConstraintWrapperPtr mySolverConstraint; ///< wrapper for PlaneGCS constraint + + /// storage, which contains all information about entities and constraints + StoragePtr myStorage; SketchSolver_ConstraintType myType; ///< type of constraint + std::list myAttributes; ///< attributes of constraint std::string myErrorMsg; ///< error message }; typedef std::shared_ptr SolverConstraintPtr; - - -/////** \class SketchSolver_ConstraintParallel -//// * \ingroup Plugins -//// * \brief Convert Parallel constraint to SolveSpace structure -//// */ -////class SketchSolver_ConstraintParallel : public SketchSolver_Constraint -////{ -////public: -//// /// Constructor based on SketchPlugin constraint -//// SketchSolver_ConstraintParallel(ConstraintPtr theConstraint) : -//// SketchSolver_Constraint(theConstraint) -//// {} -//// -//// virtual int getType() const -//// { return SLVS_C_PARALLEL; } -////}; -//// -//// -/////** \class SketchSolver_ConstraintPerpendicular -//// * \ingroup Plugins -//// * \brief Convert Perpendicular constraint to SolveSpace structure -//// */ -////class SketchSolver_ConstraintPerpendicular : public SketchSolver_Constraint -////{ -////public: -//// /// Constructor based on SketchPlugin constraint -//// SketchSolver_ConstraintPerpendicular(ConstraintPtr theConstraint) : -//// SketchSolver_Constraint(theConstraint) -//// {} -//// -//// virtual int getType() const -//// { return SLVS_C_PERPENDICULAR; } -////}; -//// -//// -/////** \class SketchSolver_ConstraintHorizontal -//// * \ingroup Plugins -//// * \brief Convert Horizontal constraint to SolveSpace structure -//// */ -////class SketchSolver_ConstraintHorizontal : public SketchSolver_Constraint -////{ -////public: -//// /// Constructor based on SketchPlugin constraint -//// SketchSolver_ConstraintHorizontal(ConstraintPtr theConstraint) : -//// SketchSolver_Constraint(theConstraint) -//// {} -//// -//// virtual int getType() const -//// { return SLVS_C_HORIZONTAL; } -////}; -//// -//// -/////** \class SketchSolver_ConstraintVertical -//// * \ingroup Plugins -//// * \brief Convert Vertical constraint to SolveSpace structure -//// */ -////class SketchSolver_ConstraintVertical : public SketchSolver_Constraint -////{ -////public: -//// /// Constructor based on SketchPlugin constraint -//// SketchSolver_ConstraintVertical(ConstraintPtr theConstraint) : -//// SketchSolver_Constraint(theConstraint) -//// {} -//// -//// virtual int getType() const -//// { return SLVS_C_VERTICAL; } -////}; -//// -//// -/////** \class SketchSolver_ConstraintRadius -//// * \ingroup Plugins -//// * \brief Convert Radius constraint to SolveSpace structure -//// */ -////class SketchSolver_ConstraintRadius : public SketchSolver_Constraint -////{ -////public: -//// /// Constructor based on SketchPlugin constraint -//// SketchSolver_ConstraintRadius(ConstraintPtr theConstraint) : -//// SketchSolver_Constraint(theConstraint) -//// {} -//// -//// virtual int getType() const -//// { return SLVS_C_DIAMETER; } -//// -//// virtual void adjustConstraint() -//// { -//// AttributeDoublePtr aValueAttr = std::dynamic_pointer_cast( -//// myBaseConstraint->attribute(SketchPlugin_Constraint::VALUE())); -//// Slvs_Constraint aConstraint = myStorage->getConstraint(mySlvsConstraints.front()); -//// aConstraint.valA = 2.0 * aValueAttr->value(); -//// myStorage->updateConstraint(aConstraint); -//// } -////}; - #endif