Review fixes.

This commit is contained in:
Daria Volvenkova 2016-07-15 19:40:50 +03:00
parent c0ce77e1df
commit 2235f312a1
7 changed files with 32 additions and 27 deletions

View file

@ -196,7 +196,7 @@ ScaleInterpolator::ScaleInterpolator(double delay, double startScale, double end
// static
double ScaleInterpolator::GetScaleDuration(double startScale, double endScale, bool isAutoZoom)
{
// Resize 2.0 times should be done for 0.2 seconds.
// Resize 2.0 times should be done for 1.5 seconds in autozoom or for 0.2 seconds in usual case.
double const kPixelSpeed = isAutoZoom ? (2.0 / 1.5) : (2.0 / 0.2);
if (startScale > endScale)

View file

@ -728,7 +728,7 @@ void FrontendRenderer::AcceptMessage(ref_ptr<Message> message)
case Message::Invalidate:
{
m_myPositionController->ResetRoutingNotFollowTimer();
m_myPositionController->ResetRoutingNotAutoZoomTimer();
m_myPositionController->ResetBlockAutoZoomTimer();
break;
}
@ -1397,7 +1397,7 @@ void FrontendRenderer::OnScaleEnded()
void FrontendRenderer::OnAnimatedScaleEnded()
{
m_myPositionController->ResetRoutingNotAutoZoomTimer();
m_myPositionController->ResetBlockAutoZoomTimer();
PullToBoundArea(false /* randomPlace */, false /* applyZoom */);
}

View file

@ -28,7 +28,7 @@ double const kMaxPendingLocationTimeSec = 60.0;
double const kMaxTimeInBackgroundSec = 60.0 * 60;
double const kMaxNotFollowRoutingTimeSec = 10.0;
double const kMaxUpdateLocationInvervalSec = 30.0;
double const kMaxNotAutoZoomRoutingTimeSec = 10.0;
double const kMaxBlockAutoZoomTimeSec = 10.0;
int const kZoomThreshold = 10;
int const kMaxScaleZoomLevel = 16;
@ -70,12 +70,12 @@ double CalculateZoomBySpeed(double speed)
{
using TSpeedScale = pair<double, double>;
static vector<TSpeedScale> scales = {
make_pair(20.0, 0.1),
make_pair(40.0, 0.25),
make_pair(60.0, 0.5),
make_pair(80.0, 0.85),
make_pair(100.0, 1.75),
make_pair(120.0, 3.5),
make_pair(20.0, 0.25),
make_pair(40.0, 0.5),
make_pair(60.0, 1.0),
make_pair(80.0, 1.75),
make_pair(100.0, 3.5),
make_pair(120.0, 7.0),
};
double const kDefaultSpeed = 80.0;
@ -89,10 +89,12 @@ double CalculateZoomBySpeed(double speed)
if (scales[i].first >= speed)
break;
double const vs = df::VisualParams::Instance().GetVisualScale();
if (i == 0)
return scales.front().second;
return scales.front().second / vs;
if (i == scales.size())
return scales.back().second;
return scales.back().second / vs;
double const minSpeed = scales[i - 1].first;
double const maxSpeed = scales[i].first;
@ -101,7 +103,6 @@ double CalculateZoomBySpeed(double speed)
double const minScale = scales[i - 1].second;
double const maxScale = scales[i].second;
double const zoom = minScale + k * (maxScale - minScale);
double const vs = df::VisualParams::Instance().GetVisualScale();
return zoom / vs;
}
@ -205,13 +206,13 @@ void MyPositionController::DragEnded(m2::PointD const & distance)
void MyPositionController::ScaleStarted()
{
m_needBlockAnimation = true;
ResetRoutingNotAutoZoomTimer();
ResetBlockAutoZoomTimer();
}
void MyPositionController::ScaleEnded()
{
m_needBlockAnimation = false;
ResetRoutingNotAutoZoomTimer();
ResetBlockAutoZoomTimer();
if (m_wasRotationInScaling)
{
m_wasRotationInScaling = false;
@ -233,12 +234,12 @@ void MyPositionController::ResetRoutingNotFollowTimer()
m_routingNotFollowTimer.Reset();
}
void MyPositionController::ResetRoutingNotAutoZoomTimer()
void MyPositionController::ResetBlockAutoZoomTimer()
{
if (m_isInRouting && m_enableAutoZoomInRouting)
{
m_needBlockAutoZoom = true;
m_routingNotAutoZoomTimer.Reset();
m_blockAutoZoomTimer.Reset();
}
}
@ -342,7 +343,7 @@ void MyPositionController::OnLocationUpdate(location::GpsInfo const & info, bool
m_errorRadius = rect.SizeX() * 0.5;
double const zoom = CalculateZoomBySpeed(info.m_speed);
m_autoScale = zoom * (rect.SizeX() / info.m_horizontalAccuracy);
m_autoScale = zoom * (m_errorRadius / info.m_horizontalAccuracy);
bool const hasBearing = info.HasBearing();
if ((isNavigable && hasBearing) ||
@ -496,7 +497,7 @@ void MyPositionController::Render(ScreenBase const & screen, ref_ptr<dp::GpuProg
if (m_shape != nullptr && IsVisible() && IsModeHasPosition())
{
if (m_needBlockAutoZoom &&
m_routingNotAutoZoomTimer.ElapsedSeconds() >= kMaxNotAutoZoomRoutingTimeSec)
m_blockAutoZoomTimer.ElapsedSeconds() >= kMaxBlockAutoZoomTimeSec)
{
m_needBlockAutoZoom = false;
m_isDirtyAutoZoom = true;
@ -559,7 +560,7 @@ void MyPositionController::SetDirection(double bearing)
void MyPositionController::ChangeMode(location::EMyPositionMode newMode)
{
if (m_isInRouting && (m_mode != newMode) && (newMode == location::FollowAndRotate))
ResetRoutingNotAutoZoomTimer();
ResetBlockAutoZoomTimer();
m_mode = newMode;
if (m_modeChangeCallback != nullptr)
@ -745,7 +746,7 @@ void MyPositionController::EnableAutoZoomInRouting(bool enableAutoZoom)
if (m_isInRouting)
{
m_enableAutoZoomInRouting = enableAutoZoom;
ResetRoutingNotAutoZoomTimer();
ResetBlockAutoZoomTimer();
}
}

View file

@ -62,7 +62,7 @@ public:
void Rotated();
void ResetRoutingNotFollowTimer();
void ResetRoutingNotAutoZoomTimer();
void ResetBlockAutoZoomTimer();
void CorrectScalePoint(m2::PointD & pt) const;
void CorrectScalePoint(m2::PointD & pt1, m2::PointD & pt2) const;
@ -152,7 +152,7 @@ private:
my::Timer m_lastGPSBearing;
my::Timer m_pendingTimer;
my::Timer m_routingNotFollowTimer;
my::Timer m_routingNotAutoZoomTimer;
my::Timer m_blockAutoZoomTimer;
my::Timer m_updateLocationTimer;
double m_lastLocationTimestamp;

View file

@ -188,7 +188,8 @@ ScreenBase const & UserEventStream::ProcessEvents(bool & modelViewChanged, bool
{
m2::PointD pt = screen.PixelRectIn3d().Center();
breakAnim = SetFollowAndRotate(screen.PtoG(screen.P3dtoP(pt)), pt,
e.m_rotate.m_targetAzimut, kDoNotChangeZoom, -1.0, true, false);
e.m_rotate.m_targetAzimut, kDoNotChangeZoom, kDoNotAutoZoom,
true /* isAnim */, false /* isAutoScale */);
}
else
{

View file

@ -21,6 +21,7 @@ namespace df
{
int const kDoNotChangeZoom = -1;
double const kDoNotAutoZoom = -1.0;
struct Touch
{
@ -134,7 +135,7 @@ struct FollowAndRotateEvent
: m_userPos(userPos)
, m_pixelZero(pixelZero)
, m_azimuth(azimuth)
, m_preferredZoomLevel(-1)
, m_preferredZoomLevel(kDoNotChangeZoom)
, m_autoScale(autoScale)
, m_isAutoScale(true)
, m_isAnim(true)
@ -147,7 +148,7 @@ struct FollowAndRotateEvent
, m_pixelZero(pixelZero)
, m_azimuth(azimuth)
, m_preferredZoomLevel(preferredZoomLevel)
, m_autoScale(-1.0)
, m_autoScale(kDoNotAutoZoom)
, m_isAutoScale(false)
, m_isAnim(isAnim)
{}

View file

@ -2565,7 +2565,9 @@ bool Framework::LoadAutoZoom()
void Framework::AllowAutoZoom(bool allowAutoZoom)
{
CallDrapeFunction(bind(&df::DrapeEngine::AllowAutoZoom, _1, allowAutoZoom));
bool const isPedestrianRoute = m_currentRouterType == RouterType::Pedestrian;
CallDrapeFunction(bind(&df::DrapeEngine::AllowAutoZoom, _1, allowAutoZoom && !isPedestrianRoute));
}
void Framework::SaveAutoZoom(bool allowAutoZoom)