- if (abs(myAngle) < tolerance) {
- myStorage->setNeedToResolve(false);
- return;
- }
-
- std::list<Slvs_Constraint> aCoincident = myStorage->getConstraintsByType(SLVS_C_POINTS_COINCIDENT);
- std::list<Slvs_Constraint>::const_iterator aCoIt;
-
- // Check overconstrained on rotation center (if it is coincident with other fixed point)
- Slvs_hConstraint aFixedCenter;
- if (myStorage->isPointFixed(myRotationCenter, aFixedCenter, false)) {
- Slvs_hConstraint aFixed;
- for (aCoIt = aCoincident.begin(); aCoIt != aCoincident.end(); ++aCoIt)
- if ((aCoIt->ptA == myRotationCenter && myStorage->isPointFixed(aCoIt->ptB, aFixed, true)) ||
- (aCoIt->ptB == myRotationCenter && myStorage->isPointFixed(aCoIt->ptA, aFixed, true))) {
- // Un-fix the center
- myStorage->removeConstraint(aFixedCenter);
- std::vector<Slvs_hConstraint>::iterator aSCIt = mySlvsConstraints.begin();
- for (; aSCIt != mySlvsConstraints.end(); ++aSCIt)
- if (*aSCIt == aFixedCenter) {
- mySlvsConstraints.erase(aSCIt);
- break;
- }
- }
- }
-
- // Obtain coordinates of rotation center
- Slvs_Entity aRotCenter = myStorage->getEntity(myRotationCenter);
- double aCenterXY[2];
- for (int i = 0; i < 2; i++)
- aCenterXY[i] = myStorage->getParameter(aRotCenter.param[i]).val;
-
- double cosA = cos(myAngle * PI / 180.0);
- double sinA = sin(myAngle * PI / 180.0);
-
- double aVec[2]; // coordinates of vector defining a direction from rotation center to a point
-
- // Update positions of all points to satisfy angles
- std::vector< std::vector<Slvs_hEntity> >::const_iterator aPointsIter = myPointsAndCopies.begin();
- std::vector<Slvs_hEntity>::const_iterator aCopyIter;
- for (; aPointsIter != myPointsAndCopies.end(); ++aPointsIter) {
- aCopyIter = aPointsIter->begin();
- const Slvs_Entity& anInitial = myStorage->getEntity(*aCopyIter);
- for (int i = 0; i < 2; i++)
- aVec[i] = myStorage->getParameter(anInitial.param[i]).val - aCenterXY[i];
-
- // if the point is coincident with another one which is temporary fixed (moved by user),
- // we will update its position correspondingly
- Slvs_hConstraint aFixed;
- for (aCoIt = aCoincident.begin(); aCoIt != aCoincident.end(); ++aCoIt) {
- if ((aCoIt->ptA == anInitial.h && myInitialPoints.find(aCoIt->ptB) != myInitialPoints.end()) ||
- (aCoIt->ptB == anInitial.h && myInitialPoints.find(aCoIt->ptA) != myInitialPoints.end())) {
- Slvs_hEntity anOtherId = aCoIt->ptA == anInitial.h ? aCoIt->ptB : aCoIt->ptA;
- if (!myStorage->isTemporary(aFixed) &&
- myPointsJustUpdated.find(anOtherId) == myPointsJustUpdated.end())
- continue; // nothing to change
-
- const Slvs_Entity& anOtherPnt = myStorage->getEntity(anOtherId);
- for (int i = 0; i < 2; i++) {
- Slvs_Param anInitParam = myStorage->getParameter(anInitial.param[i]);
- const Slvs_Param& anOtherParam = myStorage->getParameter(anOtherPnt.param[i]);
- anInitParam.val = anOtherParam.val;
- myStorage->updateParameter(anInitParam);
- aVec[i] = anOtherParam.val - aCenterXY[i];
- }
- }
- }
-
- // update copied points
- aCopyIter = aPointsIter->begin();
- for (++aCopyIter; aCopyIter != aPointsIter->end(); ++aCopyIter) {
- // rotate direction
- double aTemp = aVec[0] * cosA - aVec[1] * sinA;
- aVec[1] = aVec[0] * sinA + aVec[1] * cosA;
- aVec[0] = aTemp;
-
- const Slvs_Entity& aTarget = myStorage->getEntity(*aCopyIter);
- for (int i = 0; i < 2; i++) {
- Slvs_Param aParam = myStorage->getParameter(aTarget.param[i]);
- aParam.val = aCenterXY[i] + aVec[i];
- myStorage->updateParameter(aParam);
- }
- }
- }
-
- std::list<Slvs_Constraint> aDiamConstr;
- for (aPointsIter = myCircsAndCopies.begin(); aPointsIter != myCircsAndCopies.end(); ++aPointsIter) {
- aCopyIter = aPointsIter->begin();
- const Slvs_Entity& anInitial = myStorage->getEntity(*aCopyIter);
- if (anInitial.type == SLVS_E_DISTANCE) {
- const Slvs_Param& anInitRad = myStorage->getParameter(anInitial.param[0]);
- for (++aCopyIter; aCopyIter != aPointsIter->end(); ++aCopyIter) {
- const Slvs_Entity& aCopy = myStorage->getEntity(*aCopyIter);
- Slvs_Param aCopyRad = myStorage->getParameter(aCopy.param[0]);
- aCopyRad.val = anInitRad.val;
- myStorage->updateParameter(aCopyRad);
- }
- } else if (anInitial.type == SLVS_E_ARC_OF_CIRCLE) {
- const Slvs_Entity& aCenterEnt = myStorage->getEntity(anInitial.point[0]);
- const Slvs_Entity& aStartEnt = myStorage->getEntity(anInitial.point[1]);