- Slvs_Entity aTranslationLine = myStorage->getEntity(myTranslationLine);
- Slvs_hConstraint aFixed; // temporary variable
- // Set the translation line unchanged during constraint recalculation
- for (int i = 0; i < 2; i++) {
- if (myStorage->isPointFixed(aTranslationLine.point[i], aFixed, true))
- continue;
- Slvs_Constraint aConstraint = Slvs_MakeConstraint(
- SLVS_E_UNKNOWN, myGroup->getId(), SLVS_C_WHERE_DRAGGED, myGroup->getWorkplaneId(), 0.0,
- aTranslationLine.point[i], SLVS_E_UNKNOWN, SLVS_E_UNKNOWN, SLVS_E_UNKNOWN);
- aConstraint.h = myStorage->addConstraint(aConstraint);
- myStorage->addTemporaryConstraint(aConstraint.h);
- }
+ return SketchPlugin_MultiTranslation::NUMBER_OF_OBJECTS_ID();
+}
+
+void SketchSolver_ConstraintMultiTranslation::updateLocal()
+{
+ DataPtr aData = myBaseConstraint->data();
+ AttributePoint2DPtr aStartPointAttribute = GeomDataAPI_Point2D::getPoint2D(aData,
+ SketchPlugin_MultiTranslation::START_POINT_ID());
+ AttributePoint2DPtr anEndPointAttribute = GeomDataAPI_Point2D::getPoint2D(aData,
+ SketchPlugin_MultiTranslation::END_POINT_ID());
+ AttributeStringPtr aMethodTypeAttr = aData->string(SketchPlugin_MultiTranslation::VALUE_TYPE());
+ bool aFullValue = aMethodTypeAttr->value() != "SingleValue";
+
+ bool aStartPointChanged = aStartPointAttribute != myStartPointAttribute;
+ bool anEndPointChanged = anEndPointAttribute != myEndPointAttribute;
+ bool isMethodChanged = aFullValue != myIsFullValue;
+
+ if (aStartPointChanged)
+ myStartPointAttribute = aStartPointAttribute;
+ if (aStartPointChanged)
+ myEndPointAttribute = anEndPointAttribute;
+ if (isMethodChanged)
+ myIsFullValue = aFullValue;
+
+ if (aStartPointChanged || anEndPointChanged || isMethodChanged) {
+ DataPtr aData = myBaseConstraint->data();
+ std::list<ConstraintWrapperPtr> aConstraints = myStorage->constraint(myBaseConstraint);
+ std::list<ConstraintWrapperPtr>::const_iterator anIt = aConstraints.begin(),
+ aLast = aConstraints.end();
+ std::list<EntityWrapperPtr> anEntities;
+ for (; anIt != aLast; anIt++) {
+ ConstraintWrapperPtr aConstraint = *anIt;
+ aConstraint->setIsFullValue(myIsFullValue);
+ anEntities.clear();
+
+ const std::list<EntityWrapperPtr>& aConstraintEntities = aConstraint->entities();
+ std::list<EntityWrapperPtr>::const_iterator aSIt = aConstraintEntities.begin(),
+ aSLast = aConstraintEntities.end();
+ EntityWrapperPtr aStartEntity = *aSIt++;
+ if (aStartPointChanged) {
+ AttributePtr aStartPointAttr = aData->attribute(SketchPlugin_MultiTranslation::START_POINT_ID());
+ myStorage->update(aStartPointAttr);
+ aStartEntity = myStorage->entity(aStartPointAttr);
+ }
+ anEntities.push_back(aStartEntity);
+
+ EntityWrapperPtr anEndEntity = *aSIt++;
+ if (anEndPointChanged) {
+ AttributePtr anEndPointAttr = aData->attribute(SketchPlugin_MultiTranslation::END_POINT_ID());
+ myStorage->update(anEndPointAttr);
+ anEndEntity = myStorage->entity(anEndPointAttr);
+ }
+ anEntities.push_back(anEndEntity);
+
+ for (; aSIt != aSLast; ++aSIt)
+ anEntities.push_back(*aSIt);
+
+ aConstraint->setEntities(anEntities);
+ }
+ myStorage->addConstraint(myBaseConstraint, aConstraints);