[drape] review fix

This commit is contained in:
ExMix 2015-05-21 13:49:40 +03:00 committed by r.kuznetsov
parent b7c2a7a2e8
commit e6f3c14976
11 changed files with 55 additions and 50 deletions

View file

@ -448,7 +448,7 @@ void Framework::SetMyPositionModeListener(location::TMyPositionModeChanged const
m_myPositionModeSignal = fn;
}
location::EMyPositionMode Framework::GetMyPositionMode()
location::EMyPositionMode Framework::GetMyPositionMode() const
{
return m_currentMode;
}

View file

@ -143,7 +143,7 @@ namespace android
void RemoveActiveMapsListener(int slotID);
void SetMyPositionModeListener(location::TMyPositionModeChanged const & fn);
location::EMyPositionMode GetMyPositionMode();
location::EMyPositionMode GetMyPositionMode() const;
// Fills mapobject's metadata from UserMark
void InjectMetadata(JNIEnv * env, jclass clazz, jobject const mapObject, UserMark const * userMark);

View file

@ -1,5 +1,4 @@
#include "drape_frontend/drape_engine.hpp"
#include "drape_frontend/message_subclasses.hpp"
#include "drape_frontend/visual_params.hpp"
@ -8,9 +7,8 @@
#include "drape/texture_manager.hpp"
#include "platform/settings.hpp"
#include "platform/platform.hpp"
#include "platform/settings.hpp"
#include "std/bind.hpp"

View file

@ -1,7 +1,7 @@
#pragma once
#include "drape_frontend/frontend_renderer.hpp"
#include "drape_frontend/backend_renderer.hpp"
#include "drape_frontend/frontend_renderer.hpp"
#include "drape_frontend/threads_commutator.hpp"
#include "drape/pointers.hpp"

View file

@ -27,6 +27,8 @@ SOURCES += \
memory_feature_index.cpp \
message_acceptor.cpp \
message_queue.cpp \
my_position.cpp \
my_position_controller.cpp \
navigator.cpp \
path_symbol_shape.cpp \
path_text_shape.cpp \
@ -44,13 +46,11 @@ SOURCES += \
tile_tree.cpp \
tile_tree_builder.cpp \
tile_utils.cpp \
user_event_stream.cpp \
user_mark_shapes.cpp \
user_marks_provider.cpp \
viewport.cpp \
visual_params.cpp \
my_position.cpp \
user_event_stream.cpp \
my_position_controller.cpp
HEADERS += \
animation/base_interpolator.hpp \
@ -75,6 +75,8 @@ HEADERS += \
message_acceptor.hpp \
message_queue.hpp \
message_subclasses.hpp \
my_position.hpp \
my_position_controller.hpp \
navigator.hpp \
path_symbol_shape.hpp \
path_text_shape.hpp \
@ -93,10 +95,8 @@ HEADERS += \
tile_tree.hpp \
tile_tree_builder.hpp \
tile_utils.hpp \
user_event_stream.hpp \
user_mark_shapes.hpp \
user_marks_provider.hpp \
viewport.hpp \
visual_params.hpp \
my_position.hpp \
user_event_stream.hpp \
my_position_controller.hpp

View file

@ -202,10 +202,10 @@ void FrontendRenderer::AcceptMessage(ref_ptr<Message> message)
m_myPositionController->Invalidate();
break;
case ChangeMyPositionModeMessage::TYPE_CANCEL:
m_myPositionController->TurnOf();
m_myPositionController->TurnOff();
break;
default:
ASSERT(false, ());
ASSERT(false, ("Unknown change type:", static_cast<int>(msg->GetChangeType())));
break;
}
break;

View file

@ -302,7 +302,7 @@ public:
TYPE_INVALIDATE
};
ChangeMyPositionModeMessage(EChangeType changeType)
explicit ChangeMyPositionModeMessage(EChangeType changeType)
: m_changeType(changeType)
{
}
@ -311,7 +311,7 @@ public:
Type GetType() const override { return Message::ChangeMyPostitionMode; }
private:
EChangeType m_changeType;
EChangeType const m_changeType;
};
class CompassInfoMessage : public Message
@ -325,7 +325,7 @@ public:
location::CompassInfo const & GetInfo() const { return m_info; }
private:
location::CompassInfo m_info;
location::CompassInfo const m_info;
};
class GpsInfoMessage : public Message
@ -343,9 +343,9 @@ public:
location::RouteMatchingInfo const & GetRouteInfo() const { return m_routeInfo; }
private:
location::GpsInfo m_info;
bool m_isNavigable;
location::RouteMatchingInfo m_routeInfo;
location::GpsInfo const m_info;
bool const m_isNavigable;
location::RouteMatchingInfo const m_routeInfo;
};
} // namespace df

View file

@ -51,9 +51,9 @@ dp::BindingInfo GetBindingInfo()
MyPosition::MyPosition(ref_ptr<dp::TextureManager> mng)
: m_position(m2::PointF::Zero())
, m_azimut(0.0f)
, m_azimuth(0.0f)
, m_accuracy(0.0f)
, m_showAzimut(false)
, m_showAzimuth(false)
{
m_parts.resize(3);
CacheAccuracySector(mng);
@ -65,14 +65,14 @@ void MyPosition::SetPosition(m2::PointF const & pt)
m_position = pt;
}
void MyPosition::SetAzimut(float azimut)
void MyPosition::SetAzimuth(float azimut)
{
m_azimut = azimut;
m_azimuth = azimut;
}
void MyPosition::SetIsValidAzimut(bool isValid)
void MyPosition::SetIsValidAzimuth(bool isValid)
{
m_showAzimut = isValid;
m_showAzimuth = isValid;
}
void MyPosition::SetAccuracy(float accuracy)
@ -98,8 +98,8 @@ void MyPosition::Render(ScreenBase const & screen,
{
dp::UniformValuesStorage arrowUniforms = uniforms;
arrowUniforms.SetFloatValue("u_position", m_position.x, m_position.y, dp::depth::MY_POSITION_MARK);
arrowUniforms.SetFloatValue("u_azimut", -(m_azimut + screen.GetAngle()));
RenderPart(mng, arrowUniforms, (m_showAzimut == true) ? MY_POSITION_ARROW : MY_POSITION_POINT);
arrowUniforms.SetFloatValue("u_azimut", -(m_azimuth + screen.GetAngle()));
RenderPart(mng, arrowUniforms, (m_showAzimuth == true) ? MY_POSITION_ARROW : MY_POSITION_POINT);
}
}

View file

@ -18,8 +18,8 @@ public:
///@param pt = mercator point
void SetPosition(m2::PointF const & pt);
void SetAzimut(float azimut);
void SetIsValidAzimut(bool isValid);
void SetAzimuth(float azimut);
void SetIsValidAzimuth(bool isValid);
void SetAccuracy(float accuracy);
void Render(ScreenBase const & screen,
@ -59,9 +59,9 @@ private:
private:
m2::PointF m_position;
float m_azimut;
float m_azimuth;
float m_accuracy;
bool m_showAzimut;
bool m_showAzimuth;
using TPart = pair<dp::IndicesRange, size_t>;

View file

@ -10,19 +10,20 @@ namespace df
namespace
{
static const double GPS_BEARING_LIFETIME_S = 5.0;
double const GPS_BEARING_LIFETIME_S = 5.0;
double const MIN_SPEED_THRESHOLD_MPS = 1.0;
uint16_t IncludeModeBit(uint16_t mode, uint16_t bit)
uint16_t SetModeBit(uint16_t mode, uint16_t bit)
{
return mode | bit;
}
//uint16_t ExcludeModeBit(uint16_t mode, uint16_t bit)
//uint16_t ResetModeBit(uint16_t mode, uint16_t bit)
//{
// return mode & (~bit);
//}
location::EMyPositionMode ExcludeAllBits(uint16_t mode)
location::EMyPositionMode ResetAllModeBits(uint16_t mode)
{
return (location::EMyPositionMode)(mode & 0xF);
}
@ -81,7 +82,7 @@ void MyPositionController::SetRenderShape(drape_ptr<MyPosition> && shape)
void MyPositionController::SetFixedZoom()
{
SetModeInfo(IncludeModeBit(m_modeInfo, FixedZoomBit));
SetModeInfo(SetModeBit(m_modeInfo, FixedZoomBit));
}
void MyPositionController::NextMode()
@ -125,12 +126,14 @@ void MyPositionController::NextMode()
}
}
else
{
newMode = IsRotationActive() ? location::MODE_ROTATE_AND_FOLLOW : location::MODE_FOLLOW;
}
SetModeInfo(ChangeMode(m_modeInfo, newMode));
}
void MyPositionController::TurnOf()
void MyPositionController::TurnOff()
{
StopLocationFollow();
SetModeInfo(location::MODE_UNKNOWN_POSITION);
@ -166,7 +169,9 @@ void MyPositionController::OnLocationUpdate(location::GpsInfo const & info, bool
m_afterPendingMode = location::MODE_FOLLOW;
}
else
{
AnimateFollow();
}
}
void MyPositionController::OnCompassUpdate(location::CompassInfo const & info)
@ -187,8 +192,8 @@ void MyPositionController::Render(ScreenBase const & screen, ref_ptr<dp::GpuProg
if (m_shape != nullptr && IsVisible() && GetMode() > location::MODE_PENDING_POSITION)
{
m_shape->SetPosition(m_position);
m_shape->SetAzimut(m_drawDirection);
m_shape->SetIsValidAzimut(IsRotationActive());
m_shape->SetAzimuth(m_drawDirection);
m_shape->SetIsValidAzimuth(IsRotationActive());
m_shape->SetAccuracy(m_errorRadius);
m_shape->Render(screen, mng, commonUniforms);
}
@ -196,12 +201,12 @@ void MyPositionController::Render(ScreenBase const & screen, ref_ptr<dp::GpuProg
void MyPositionController::AnimateStateTransition(location::EMyPositionMode oldMode, location::EMyPositionMode newMode)
{
//TODO UVR (rakhuba) restore viewport animation logic
}
void MyPositionController::AnimateFollow()
{
//TODO UVR (rakhuba) restore viewport animation logic
}
void MyPositionController::Assign(location::GpsInfo const & info, bool isNavigable)
@ -213,8 +218,8 @@ void MyPositionController::Assign(location::GpsInfo const & info, bool isNavigab
m_errorRadius = rect.SizeX() / 2;
bool const hasBearing = info.HasBearing();
if ((isNavigable && hasBearing)
|| (!isNavigable && hasBearing && info.HasSpeed() && info.m_speed > 1.0))
if ((isNavigable && hasBearing) ||
(!isNavigable && hasBearing && info.HasSpeed() && info.m_speed > MIN_SPEED_THRESHOLD_MPS))
{
SetDirection(my::DegToRad(info.m_bearing));
m_lastGPSBearing.Reset();
@ -225,7 +230,9 @@ bool MyPositionController::Assign(location::CompassInfo const & info)
{
if ((IsInRouting() && GetMode() >= location::MODE_FOLLOW) ||
(m_lastGPSBearing.ElapsedSeconds() < GPS_BEARING_LIFETIME_S))
{
return false;
}
SetDirection(info.m_bearing);
return true;
@ -234,12 +241,12 @@ bool MyPositionController::Assign(location::CompassInfo const & info)
void MyPositionController::SetDirection(double bearing)
{
m_drawDirection = bearing;
SetModeInfo(IncludeModeBit(m_modeInfo, KnownDirectionBit));
SetModeInfo(SetModeBit(m_modeInfo, KnownDirectionBit));
}
void MyPositionController::SetModeInfo(uint16_t modeInfo, bool force)
{
location::EMyPositionMode const newMode = ExcludeAllBits(modeInfo);
location::EMyPositionMode const newMode = ResetAllModeBits(modeInfo);
location::EMyPositionMode const oldMode = GetMode();
m_modeInfo = modeInfo;
if (newMode != oldMode || force)
@ -251,13 +258,13 @@ void MyPositionController::SetModeInfo(uint16_t modeInfo, bool force)
location::EMyPositionMode MyPositionController::GetMode() const
{
return ExcludeAllBits(m_modeInfo);
return ResetAllModeBits(m_modeInfo);
}
void MyPositionController::CallModeListener(uint16_t mode)
{
if (m_modeChangeCallback != nullptr)
m_modeChangeCallback(ExcludeAllBits(mode));
m_modeChangeCallback(ResetAllModeBits(mode));
}
bool MyPositionController::IsInRouting() const

View file

@ -30,7 +30,7 @@ public:
void SetFixedZoom();
void NextMode();
void TurnOf();
void TurnOff();
void Invalidate();
void OnLocationUpdate(location::GpsInfo const & info, bool isNavigable);
@ -80,7 +80,7 @@ private:
double m_errorRadius; //< error radius in mercator
m2::PointD m_position; //< position in mercator
double m_drawDirection;
my::Timer m_lastGPSBearing;
my::HighResTimer m_lastGPSBearing;
bool m_isVisible;
};