}
}
+void SketchSolver_Constraint::makeTemporary() const
+{
+ std::vector<Slvs_hConstraint>::const_iterator anIt = mySlvsConstraints.begin();
+ for (; anIt != mySlvsConstraints.end(); anIt++)
+ myStorage->addTemporaryConstraint(*anIt);
+}
+
/// \brief Returns the type of constraint
virtual int getType() const = 0;
+ /// \brief The constraint is made temoparary
+ void makeTemporary() const;
+
/// \brief Checks the constraint is used by current object
virtual bool hasConstraint(ConstraintPtr theConstraint) const
{ return theConstraint == myBaseConstraint; }
if (*anEntIter == SLVS_E_UNKNOWN)
continue;
Slvs_hConstraint aConstrID = myStorage->isPointFixed(*anEntIter);
- bool isForceUpdate = (aConstrID != SLVS_E_UNKNOWN && !myBaseConstraint);
+ bool isForceUpdate = (aConstrID != SLVS_E_UNKNOWN && !myBaseConstraint &&
+ myStorage->isTemporary(aConstrID));
if (isEmpty && !isForceUpdate) { // create new constraint
if (aConstrID != SLVS_E_UNKNOWN)
continue; // the coincident point is already fixed
aConstraint.h = myStorage->addConstraint(aConstraint);
mySlvsConstraints.push_back(aConstraint.h);
if (!myBaseConstraint)
- myStorage->addTemporaryConstraint(aConstraint.h);
+ myStorage->addConstraintWhereDragged(aConstraint.h);
} else { // update already existent constraint
if (aConstrID == SLVS_E_UNKNOWN || myBaseConstraint)
aConstrID = *aConstrIter;
aConstraint.ptA = *anEntIter;
myStorage->addConstraint(aConstraint);
if (!myBaseConstraint)
- myStorage->addTemporaryConstraint(aConstraint.h);
+ myStorage->addConstraintWhereDragged(aConstraint.h);
if (!isEmpty) {
aConstrIter++;
isEmpty = aConstrIter == mySlvsConstraints.end();
aConstraint.h = myStorage->addConstraint(aConstraint);
mySlvsConstraints.push_back(aConstraint.h);
if (!myBaseConstraint)
- myStorage->addTemporaryConstraint(aConstraint.h);
+ myStorage->addConstraintWhereDragged(aConstraint.h);
}
}
aConstraint.h = myStorage->addConstraint(aConstraint);
mySlvsConstraints.push_back(aConstraint.h);
if (!myBaseConstraint)
- myStorage->addTemporaryConstraint(aConstraint.h);
+ myStorage->addConstraintWhereDragged(aConstraint.h);
}
// Fix radius of the arc
aConstraint.h = myStorage->addConstraint(aConstraint);
mySlvsConstraints.push_back(aConstraint.h);
if (!myBaseConstraint)
- myStorage->addTemporaryConstraint(aConstraint.h);
+ myStorage->addConstraintWhereDragged(aConstraint.h);
}
}
continue;
aConstraint->setGroup(this);
aConstraint->setStorage(myStorage);
- myTempConstraints.insert(aConstraint);
+ setTemporary(aConstraint);
}
}
// Fix base features for mirror
return;
aConstraint->setGroup(this);
aConstraint->setStorage(myStorage);
- myTempConstraints.insert(aConstraint);
+ setTemporary(aConstraint);
}
// ============================================================================
continue;
aConstraint->setGroup(this);
aConstraint->setStorage(myStorage);
- myTempConstraints.insert(aConstraint);
+ setTemporary(aConstraint);
}
}
void SketchSolver_Group::removeTemporaryConstraints()
{
myTempConstraints.clear();
+ myStorage->removeTemporaryConstraints();
// Clean lists of removed entities in the storage
std::set<Slvs_hParam> aRemPar;
std::set<Slvs_hEntity> aRemEnt;
theConstraint->getKind() == SketchPlugin_ConstraintTangent::ID();
}
+// ============================================================================
+// Function: setTemporary
+// Class: SketchSolver_Group
+// Purpose: append given constraint to th group of temporary constraints
+// ============================================================================
+void SketchSolver_Group::setTemporary(SolverConstraintPtr theConstraint)
+{
+ theConstraint->makeTemporary();
+ myTempConstraints.insert(theConstraint);
+}
+
/// \brief Apply temporary rigid constraints for the list of features
void fixFeaturesList(AttributeRefListPtr theList);
+ /// \brief Append given constraint to th group of temporary constraints
+ void setTemporary(SolverConstraintPtr theConstraint);
+
private:
Slvs_hGroup myID; ///< Index of the group
Slvs_hEntity myWorkplaneID; ///< Index of workplane, the group is based on
}
-void SketchSolver_Storage::addTemporaryConstraint(const Slvs_hConstraint& theConstraintID)
+void SketchSolver_Storage::addConstraintWhereDragged(const Slvs_hConstraint& theConstraintID)
{
if (myFixed != SLVS_E_UNKNOWN)
return; // the point is already fixed
myFixed = theConstraintID;
}
+void SketchSolver_Storage::addTemporaryConstraint(const Slvs_hConstraint& theConstraintID)
+{
+ myTemporaryConstraints.insert(theConstraintID);
+}
+
+void SketchSolver_Storage::removeTemporaryConstraints()
+{
+ myTemporaryConstraints.clear();
+}
+
+bool SketchSolver_Storage::isTemporary(const Slvs_hConstraint& theConstraintID) const
+{
+ return myTemporaryConstraints.find(theConstraintID) != myTemporaryConstraints.end();
+}
+
+
void SketchSolver_Storage::getRemoved(
std::set<Slvs_hParam>& theParameters,
std::set<Slvs_hEntity>& theEntities,
/// \brief Returns list of constraints of specified type
std::list<Slvs_Constraint> getConstraintsByType(int theConstraintType) const;
- /// \brief Attach temporary constraint to this storage. It need to make precise calculations
+ /// \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 Checks the constraint is temporary
+ bool isTemporary(const Slvs_hConstraint& theConstraintID) const;
/// \brief Shows the sketch should be resolved
bool isNeedToResolve() const
bool myNeedToResolve; ///< parameters are changed and group needs to be resolved
+ std::set<Slvs_hConstraint> myTemporaryConstraints; ///< list of transient constraints
std::set<Slvs_hParam> myRemovedParameters; ///< list of just removed parameters (cleared when returning to applicant)
std::set<Slvs_hEntity> myRemovedEntities; ///< list of just removed entities (cleared when returning to applicant)
std::set<Slvs_hConstraint> myRemovedConstraints; ///< list of just removed constraints (cleared when returning to applicant)