예제 #1
0
drape_ptr<SequenceAnimation> GetPrettyMoveAnimation(ScreenBase const & screen, double startScale, double endScale,
                                                    m2::PointD const & startPt, m2::PointD const & endPt)
{
  double const moveDuration = PositionInterpolator::GetMoveDuration(startPt, endPt, screen.PixelRectIn3d(), startScale);
  ASSERT_GREATER(moveDuration, 0.0, ());

  double const scaleFactor = moveDuration / kMaxAnimationTimeSec * 2.0;

  auto sequenceAnim = make_unique_dp<SequenceAnimation>();
  sequenceAnim->SetCustomType(kPrettyMoveAnim);

  auto zoomOutAnim = make_unique_dp<MapLinearAnimation>();
  zoomOutAnim->SetScale(startScale, startScale * scaleFactor);
  zoomOutAnim->SetMaxDuration(kMaxAnimationTimeSec * 0.5);

  //TODO (in future): Pass fixed duration instead of screen.
  auto moveAnim = make_unique_dp<MapLinearAnimation>();
  moveAnim->SetMove(startPt, endPt, screen);
  moveAnim->SetMaxDuration(kMaxAnimationTimeSec);

  auto zoomInAnim = make_unique_dp<MapLinearAnimation>();
  zoomInAnim->SetScale(startScale * scaleFactor, endScale);
  zoomInAnim->SetMaxDuration(kMaxAnimationTimeSec * 0.5);

  sequenceAnim->AddAnimation(move(zoomOutAnim));
  sequenceAnim->AddAnimation(move(moveAnim));
  sequenceAnim->AddAnimation(move(zoomInAnim));
  return sequenceAnim;
}
예제 #2
0
drape_ptr<MapLinearAnimation> GetRectAnimation(ScreenBase const & startScreen, ScreenBase const & endScreen)
{
  auto anim = make_unique_dp<MapLinearAnimation>();

  anim->SetRotate(startScreen.GetAngle(), endScreen.GetAngle());
  anim->SetMove(startScreen.GetOrg(), endScreen.GetOrg(),
                startScreen.PixelRectIn3d(), (startScreen.GetScale() + endScreen.GetScale()) / 2.0);
  anim->SetScale(startScreen.GetScale(), endScreen.GetScale());
  anim->SetMaxScaleDuration(kMaxAnimationTimeSec);

  return anim;
}
예제 #3
0
void FrontendRenderer::OnResize(ScreenBase const & screen)
{
  m2::RectD const viewportRect = screen.isPerspective() ? screen.PixelRectIn3d() : screen.PixelRect();

  m_myPositionController->UpdatePixelPosition(screen);
  m_myPositionController->OnNewPixelRect();

  m_viewport.SetViewport(0, 0, viewportRect.SizeX(), viewportRect.SizeY());
  m_contextFactory->getDrawContext()->resize(viewportRect.SizeX(), viewportRect.SizeY());
  RefreshProjection(screen);
  RefreshPivotTransform(screen);

  m_framebuffer->SetSize(viewportRect.SizeX(), viewportRect.SizeY());
}
예제 #4
0
drape_ptr<SequenceAnimation> GetPrettyFollowAnimation(ScreenBase const & startScreen, m2::PointD const & userPos, double targetScale,
                                                      double targetAngle, m2::PointD const & endPixelPos)
{
  auto sequenceAnim = make_unique_dp<SequenceAnimation>();
  sequenceAnim->SetCustomType(kPrettyFollowAnim);

  m2::RectD const viewportRect = startScreen.PixelRectIn3d();

  ScreenBase tmp = startScreen;
  tmp.SetAngle(targetAngle);
  tmp.MatchGandP3d(userPos, viewportRect.Center());

  double const moveDuration = PositionInterpolator::GetMoveDuration(startScreen.GetOrg(), tmp.GetOrg(), startScreen);
  ASSERT_GREATER(moveDuration, 0.0, ());

  double const scaleFactor = moveDuration / kMaxAnimationTimeSec * 2.0;

  tmp = startScreen;

  if (moveDuration > 0.0)
  {
    tmp.SetScale(startScreen.GetScale() * scaleFactor);

    auto zoomOutAnim = make_unique_dp<MapLinearAnimation>();
    zoomOutAnim->SetScale(startScreen.GetScale(), tmp.GetScale());
    zoomOutAnim->SetMaxDuration(kMaxAnimationTimeSec * 0.5);
    sequenceAnim->AddAnimation(move(zoomOutAnim));

    tmp.MatchGandP3d(userPos, viewportRect.Center());

    auto moveAnim = make_unique_dp<MapLinearAnimation>();
    moveAnim->SetMove(startScreen.GetOrg(), tmp.GetOrg(), viewportRect, tmp.GetScale());
    moveAnim->SetMaxDuration(kMaxAnimationTimeSec);
    sequenceAnim->AddAnimation(move(moveAnim));
  }

  auto followAnim = make_unique_dp<MapFollowAnimation>(tmp, userPos, endPixelPos,
                                                       tmp.GetScale(), targetScale,
                                                       tmp.GetAngle(), targetAngle,
                                                       false /* isAutoZoom */);
  followAnim->SetMaxDuration(kMaxAnimationTimeSec * 0.5);
  sequenceAnim->AddAnimation(move(followAnim));
  return sequenceAnim;
}
예제 #5
0
void MyPositionController::UpdatePixelPosition(ScreenBase const & screen)
{
  m_pixelRect = screen.isPerspective() ? screen.PixelRectIn3d() : screen.PixelRect();
  m_positionYOffset = screen.isPerspective() ? kPositionOffsetYIn3D : kPositionOffsetY;
}