- aSlvsConstraint.other = false;
- for (int i = 0; i < 2; i++)
- if (aLine[i]->direction()->dot(aDir[i]) < 0.0)
- aSlvsConstraint.other = !aSlvsConstraint.other;
-
- // Recalculate positions of lines to avoid conflicting constraints
- // while changing angle value several times
- double cosA = cos(aConstraint->value() * PI / 180.0);
- double sinA = sin(aConstraint->value() * PI / 180.0);
- if (aDir[0]->cross(aDir[1]) < 0.0)
- sinA *= -1.0;
- int aLineToUpd = 1;
- if (isFixed[1][0] && isFixed[1][1]) {
- sinA *= -1.0;
- aLineToUpd = 0;
- }
- double x = aDir[1-aLineToUpd]->x() * cosA - aDir[1-aLineToUpd]->y() * sinA;
- double y = aDir[1-aLineToUpd]->x() * sinA + aDir[1-aLineToUpd]->y() * cosA;
-
- std::shared_ptr<GeomAPI_Pnt2d> aNewPoints[2];
- for (int i = 0; i < 2; i++) {
- aNewPoints[i] = std::shared_ptr<GeomAPI_Pnt2d>(
- new GeomAPI_Pnt2d(anIntersection->x() + x * aDist[aLineToUpd][i],
- anIntersection->y() + y * aDist[aLineToUpd][i]));
- }
-
- std::shared_ptr<GeomAPI_XY> aDelta;
- if (isFixed[aLineToUpd][0] && !isFixed[aLineToUpd][1])
- aDelta = aPoints[aLineToUpd][0]->xy()->decreased(aNewPoints[0]->xy());
- else if (!isFixed[aLineToUpd][0] && isFixed[aLineToUpd][1])
- aDelta = aPoints[aLineToUpd][1]->xy()->decreased(aNewPoints[1]->xy());
- if (aDelta) {
- for (int i = 0; i < 2; i++) {
- aNewPoints[i]->setX(aNewPoints[i]->x() + aDelta->x());
- aNewPoints[i]->setY(aNewPoints[i]->y() + aDelta->y());
- }
- }
-
- // Update positions of points
- std::list<EntityWrapperPtr>::const_iterator anUpdLine = aConstrLines.begin();
- if (aLineToUpd > 0) ++anUpdLine;
- const std::list<EntityWrapperPtr>& anUpdPoints = (*anUpdLine)->subEntities();
- std::list<EntityWrapperPtr>::const_iterator aPIt = anUpdPoints.begin();
- for (int i = 0; aPIt != anUpdPoints.end(); ++aPIt, ++i) {
- double aCoord[2] = {aNewPoints[i]->x(), aNewPoints[i]->y()};
- const std::list<ParameterWrapperPtr>& aParams = (*aPIt)->parameters();
- std::list<ParameterWrapperPtr>::const_iterator aParIt = aParams.begin();
- for (int j = 0; aParIt != aParams.end(); ++j, ++aParIt)
- (*aParIt)->setValue(aCoord[j]);
- }