| 217 | } |
| 218 | |
| 219 | void Navigator::DoScale(m2::PointD const & pt1, m2::PointD const & pt2) |
| 220 | { |
| 221 | double const threshold = df::VisualParams::Instance().GetScaleThreshold(); |
| 222 | double const deltaPt1 = (pt1 - m_LastPt1).Length(); |
| 223 | double const deltaPt2 = (pt2 - m_LastPt2).Length(); |
| 224 | |
| 225 | if (deltaPt1 < threshold && deltaPt2 < threshold) |
| 226 | return; |
| 227 | if (pt1 == pt2) |
| 228 | return; |
| 229 | |
| 230 | ScreenBase PrevScreen = m_Screen; |
| 231 | m_Screen = m_StartScreen; |
| 232 | |
| 233 | // Checking for rotation threshold. |
| 234 | if (m_DoCheckRotationThreshold) |
| 235 | { |
| 236 | double s = pt1.Length(pt2) / m_StartPt1.Length(m_StartPt2); |
| 237 | double a = ang::AngleTo(pt1, pt2) - ang::AngleTo(m_StartPt1, m_StartPt2); |
| 238 | |
| 239 | double aThresh = 10.0 / 180.0 * math::pi; |
| 240 | double sThresh = 1.2; |
| 241 | |
| 242 | bool isScalingInBounds = (s > 1 / sThresh) && (s < sThresh); |
| 243 | bool isRotationOutBounds = fabs(a) > aThresh; |
| 244 | |
| 245 | if (isScalingInBounds) |
| 246 | { |
| 247 | if (isRotationOutBounds) |
| 248 | { |
| 249 | m_IsRotatingDuringScale = true; |
| 250 | m_DoCheckRotationThreshold = false; |
| 251 | } |
| 252 | } |
| 253 | else |
| 254 | { |
| 255 | m_IsRotatingDuringScale = false; |
| 256 | m_DoCheckRotationThreshold = false; |
| 257 | } |
| 258 | } |
| 259 | |
| 260 | m_Screen = PrevScreen; |
| 261 | |
| 262 | if (!ScaleImpl(pt1, pt2, m_LastPt1, m_LastPt2, pt1.Length(pt2) > m_LastPt1.Length(m_LastPt2), m_IsRotatingDuringScale, |
| 263 | m_Screen)) |
| 264 | { |
| 265 | m_Screen = PrevScreen; |
| 266 | } |
| 267 | |
| 268 | m_LastPt1 = pt1; |
| 269 | m_LastPt2 = pt2; |
| 270 | } |
| 271 | |
| 272 | void Navigator::StopScale(m2::PointD const & pt1, m2::PointD const & pt2) |
| 273 | { |
no test coverage detected