Пример #1
0
void Navigator::DoScale(m2::PointD const & pt1, m2::PointD const & pt2, double /*timeInSec*/)
{
  if (m_LastPt1 == pt1 && m_LastPt2 == pt2)
    return;
  if (pt1 == pt2)
    return;

  ScreenBase PrevScreen = m_Screen;
  m_Screen = m_StartScreen;

  // Checking for rotation threshold.
  if (m_DoCheckRotationThreshold)
  {
    double s = pt1.Length(pt2) / m_StartPt1.Length(m_StartPt2);
    double a = ang::AngleTo(pt1, pt2) - ang::AngleTo(m_StartPt1, m_StartPt2);

    double aThresh = 10.0 / 180.0 * math::pi;
    double sThresh = 1.2;

    bool isScalingInBounds = (s > 1 / sThresh) && (s < sThresh);
    bool isRotationOutBounds = fabs(a) > aThresh;

    if (isScalingInBounds)
    {
      if (isRotationOutBounds)
      {
        m_IsRotatingDuringScale = true;
        m_DoCheckRotationThreshold = false;
      }
    }
    else
    {
      m_IsRotatingDuringScale = false;
      m_DoCheckRotationThreshold = false;
    }
  }

  m_Screen = PrevScreen;

  if (!ScaleImpl(pt1, pt2,
                 m_LastPt1, m_LastPt2,
                 pt1.Length(pt2) > m_LastPt1.Length(m_LastPt2),
                 m_IsRotatingDuringScale))
  {
    m_Screen = PrevScreen;
  }

  m_LastPt1 = pt1;
  m_LastPt2 = pt2;
}
Пример #2
0
void MyPositionController::DragEnded(m2::PointD const & distance)
{
  float const kBindingDistance = 0.1;
  m_needBlockAnimation = false;
  if (distance.Length() > kBindingDistance * min(m_pixelRect.SizeX(), m_pixelRect.SizeY()))
    StopLocationFollow();

  UpdateViewport(kDoNotChangeZoom);
}
Пример #3
0
  void operator() (m2::PointD const & p)
  {
    m2::PointD const pt(this->convert_point(p));

    if (m_exist)
      m_length += pt.Length(m_prevPt);

    m_exist = true;
    m_prevPt = pt;
  }
Пример #4
0
ScreenBase::MatrixT const
ScreenBase::CalcTransform(m2::PointD const & oldPt1, m2::PointD const & oldPt2,
                          m2::PointD const & newPt1, m2::PointD const & newPt2,
                          bool allowRotate)
{
  double const s = newPt1.Length(newPt2) / oldPt1.Length(oldPt2);
  double const a = allowRotate ? ang::AngleTo(newPt1, newPt2) - ang::AngleTo(oldPt1, oldPt2) : 0.0;

  MatrixT m =
      math::Shift(
          math::Scale(
              math::Rotate(
                  math::Shift(
                      math::Identity<double, 3>(),
                      -oldPt1.x, -oldPt1.y
                      ),
                  a
                  ),
              s, s
              ),
          newPt1.x, newPt1.y
          );
  return m;
}
Пример #5
0
void cut_path_intervals::operator()(m2::PointD const & pt)
{
  if (m_hasPrevPt)
  {
    double const segLen = pt.Length(m_prev);

    for (; m_pos != m_intervals->size(); m_pos += 2)
    {
      double const start = (*m_intervals)[m_pos];
      if (start >= m_length + segLen)
        break;

      m2::PointD const dir = (pt - m_prev) / segLen;

      if (start >= m_length)
      {
        m_points.push_back(PathInfo(start));
        push_point(m_prev + dir * (start - m_length));
      }

      double const end = (*m_intervals)[m_pos+1];
      if (end >= m_length + segLen)
      {
        push_point(pt);
        break;
      }

      if (end < m_length + segLen)
      {
        push_point(m_prev + dir * (end - m_length));
#ifdef DEBUG
        double const len = m_points.back().GetLength();
        ASSERT_LESS_OR_EQUAL ( fabs(len - (end - start)), 1.0E-4, (len, end - start) );
#endif
      }
    }

    m_prev = pt;
    m_length += segLen;
  }
  else
  {
    m_hasPrevPt = true;
    m_prev = pt;
  }
}