- SketchSolver_Storage();
-
- /** \brief Add new parameter to the current group
- * \param[in] theParam SolveSpace parameter
- * \return the ID of added parameter
- */
- Slvs_hParam addParameter(const Slvs_Param& theParam);
- /** \brief Updates parameter in the current group. If the ID of parameter is zero, the new item will be added
- * \param[in] theParam SolveSpace parameter
- * \return the ID of updated/added parameter
- */
- Slvs_hParam updateParameter(const Slvs_Param& theParam);
- /** \brief Removes the parameter by its ID
- * \param[in] theParamID index of parameter to be removed
- * \return \c true if the parameter was successfully removed
- */
- bool removeParameter(const Slvs_hParam& theParamID);
- /// \brief Returns the parameter by its ID
- const Slvs_Param& getParameter(const Slvs_hParam& theParamID) const;
-
- /** \brief Add new entity to the current group
- * \param[in] theEntity SolveSpace entity
- * \return the ID of added entity
- */
- Slvs_hEntity addEntity(const Slvs_Entity& theEntity);
- /** \brief Updates entity in the current group. If the ID of entity is zero, the new item will be added
- * \param[in] theEntity SolveSpace entity
- * \return the ID of updated/added entity
- */
- Slvs_hEntity updateEntity(const Slvs_Entity& theEntity);
- /** \brief Removes the entity by its ID. All parameters used in this entity,
- * and not used in other constraints, will be removed too.
- * \param[in] theEntityID index of entity to be removed
- * \return \c true if the entity was successfully removed
- */
- bool removeEntity(const Slvs_hEntity& theEntityID);
- /// \brief Returns the entity by its ID
- const Slvs_Entity& getEntity(const Slvs_hEntity& theEntityID) const;
- /// \brief Makes a full copy of the given entity
- Slvs_hEntity copyEntity(const Slvs_hEntity& theCopied);
- /// \brief Copy one entity to another
- void copyEntity(const Slvs_hEntity& theFrom, const Slvs_hEntity& theTo);
-
- /// \brief Verifies the current point or another coincident one is fixed
- /// \param[in] thePointID entity to be checked fixed
- /// \param[out] theFixed ID of constraint
- /// \param[in] theAccurate if \c true, the calculation will be made for all type of constraints,
- /// if \c false, only the point is verified
- /// \return \c true if the point is fixed
- bool isPointFixed(const Slvs_hEntity& thePointID, Slvs_hConstraint& theFixed, bool theAccurate = false) const;
- /// \brief Verifies the current entity is fully fixed (may not be changed by constraints)
- /// \param[in] theEntityID entity to be checked fixed
- /// \param[in] theAccurate if \c true, the calculation will be made for all type of constraints,
- /// if \c false, only points are verified
- /// \return \c true if the entity is fixed
- bool isEntityFixed(const Slvs_hEntity& theEntityID, bool theAccurate = false) const;
-
- /** \brief Add new constraint to the current group
- * \param[in] theConstraint SolveSpace's constraint
- * \return the ID of added constraint
- */
- Slvs_hConstraint addConstraint(const Slvs_Constraint& theConstraint);
- /** \brief Updates constraint in the current group.
- * If the ID of constraint is zero, the new item will be added
- * \param[in] theConstraint SolveSpace constraint
- * \return the ID of updated/added constraint
- */
- Slvs_hConstraint updateConstraint(const Slvs_Constraint& theConstraint);
- /** \brief Removes the constraint by its ID. All entities and parameters depending on this
- * constraint, which are not used in other constraints, will be removed too.
- * \param[in] theConstraintID index of constraint to be removed
- * \return \c true if the constraint was successfully removed
- */
- bool removeConstraint(const Slvs_hConstraint& theConstraintID);
- /// \brief Returns the constraint by its ID
- const Slvs_Constraint& getConstraint(const Slvs_hConstraint& theConstraintID) const;
- /// \brief Returns list of constraints of specified type
- std::list<Slvs_Constraint> getConstraintsByType(int theConstraintType) const;
-
- /// \brief Attach constraint SLVS_C_WHERE_DRAGGED to this storage. It need to make precise calculations
- void addConstraintWhereDragged(const Slvs_hConstraint& theConstraintID);
-
- /// \brief Add transient constraint
- void addTemporaryConstraint(const Slvs_hConstraint& theConstraintID);
- /// \brief Remove all transient constraints
- void removeTemporaryConstraints();
- /// \brief Remove first temporary constraint
- /// \return Number of remaining temporary constraints
- int removeFirstTemporaryConstraint();
- /// \brief Checks the constraint is temporary
- bool isTemporary(const Slvs_hConstraint& theConstraintID) const;
+ SketchSolver_Storage(SolverPtr theSolver);
+
+ /// \brief Change mapping between constraint from SketchPlugin and
+ /// a constraint applicable for corresponding solver.
+ /// \param theConstraint [in] original SketchPlugin constraint
+ /// \param theSolverConstraint [in] solver's constraint
+ virtual void addConstraint(ConstraintPtr theConstraint,
+ ConstraintWrapperPtr theSolverConstraint);
+
+ /// \brief Add a movement constraint which will be destroyed
+ /// after the next solving of the set of constraints.
+ /// \param theSolverConstraint [in] solver's constraint
+ virtual void addMovementConstraint(const ConstraintWrapperPtr& theSolverConstraint) = 0;
+
+ /// \brief Change mapping feature from SketchPlugin and
+ /// the entity applicable for corresponding solver.
+ /// \param theFeature [in] original SketchPlugin feature
+ /// \param theSolverEntity [in] solver's entity, created outside
+ void addEntity(FeaturePtr theFeature,
+ EntityWrapperPtr theSolverEntity);
+
+ /// \brief Change mapping attribute of a feature and the entity
+ /// applicable for corresponding solver.
+ /// \param theAttribute [in] original attribute
+ /// \param theSolverEntity [in] solver's entity, created outside
+ void addEntity(AttributePtr theAttribute,
+ EntityWrapperPtr theSolverEntity);
+
+ /// \brief Convert feature to the form applicable for specific solver and map it
+ /// \param theFeature [in] feature to convert
+ /// \param theForce [in] forced feature creation
+ /// \return \c true if the feature has been created or updated
+ virtual bool update(FeaturePtr theFeature, bool theForce = false) = 0;
+
+ /// \brief Convert attribute to the form applicable for specific solver and map it
+ /// \param theAttribute [in] attribute to convert
+ /// \param theForce [in] forced feature creation
+ /// \return \c true if the attribute has been created or updated
+ virtual bool update(AttributePtr theAttribute, bool theForce = false) = 0;
+
+ /// \brief Returns constraint related to corresponding constraint
+ const ConstraintWrapperPtr& constraint(const ConstraintPtr& theConstraint) const;
+
+ /// \brief Returns entity related to corresponding feature
+ const EntityWrapperPtr& entity(const FeaturePtr& theFeature) const;
+ /// \brief Returns entity related to corresponding attribute
+ const EntityWrapperPtr& entity(const AttributePtr& theAttribute) const;
+
+ /// \brief Make entity external
+ virtual void makeExternal(const EntityWrapperPtr& theEntity) = 0;
+ /// \brief Make entity non-external
+ virtual void makeNonExternal(const EntityWrapperPtr& theEntity) = 0;
+
+ /// \brief Removes constraint from the storage
+ /// \return \c true if the constraint and all its parameters are removed successfully
+ virtual bool removeConstraint(ConstraintPtr theConstraint) = 0;
+ /// \brief Removes feature from the storage
+ void removeFeature(FeaturePtr theFeature);
+ /// \brief Removes attribute from the storage
+ void removeAttribute(AttributePtr theAttribute);
+
+ /// \brief Remove all features became invalid
+ virtual void removeInvalidEntities() = 0;
+
+ /// \brief Check the features have not been removed
+ bool areFeaturesValid() const;
+
+ /// \brief Check the storage has constraints
+ virtual bool isEmpty() const
+ { return myConstraintMap.empty(); }