fixes according to code review.

This commit is contained in:
rachytski 2012-08-23 12:42:58 +03:00 committed by Alex Zolotarev
parent 0ba56f8945
commit bd1102592a
5 changed files with 30 additions and 13 deletions

View file

@ -1,6 +1,7 @@
#include "controller.hpp"
#include "task.hpp"
#include "../base/assert.hpp"
#include "../base/timer.hpp"
#include "../std/bind.hpp"
@ -20,7 +21,7 @@ namespace anim
m_tasks.PushBack(task);
}
void Controller::CopyTasks(TTasks & from, TTasks & to)
void Controller::CopyAndClearTasks(TTasks & from, TTasks & to)
{
to.clear();
swap(from, to);
@ -43,15 +44,13 @@ namespace anim
int Controller::LockCount()
{
if (m_LockCount < 0)
LOG(LWARNING, ("Lock/Unlock is unbalanced! LockCount < 0!"));
ASSERT(m_LockCount >=0, ("Lock/Unlock is unbalanced! LockCount < 0!"));
return m_LockCount;
}
void Controller::PerformStep()
{
m_tasks.ProcessList(bind(&Controller::CopyTasks, this, _1, ref(m_tasksList)));
m_tasks.ProcessList(bind(&Controller::CopyAndClearTasks, _1, ref(m_tasksList)));
double ts = my::Timer::LocalTime();
@ -76,6 +75,6 @@ namespace anim
}
}
m_tasks.ProcessList(bind(&Controller::CopyTasks, this, ref(l), _1));
m_tasks.ProcessList(bind(&Controller::CopyAndClearTasks, ref(l), _1));
}
}

View file

@ -23,7 +23,7 @@ namespace anim
int m_LockCount;
void CopyTasks(list<shared_ptr<Task> > & from, list<shared_ptr<Task> > & to);
static void CopyAndClearTasks(list<shared_ptr<Task> > & from, list<shared_ptr<Task> > & to);
public:
// Constructor

View file

@ -989,7 +989,18 @@ void Framework::PrepareSearch(bool hasPt, double lat, double lon)
bool Framework::Search(search::SearchParams const & params)
{
return GetSearchEngine()->Search(params, GetCurrentViewport());
#ifdef FIXED_LOCATION
search::SearchParams rParams(params);
if (params.m_validPos)
{
m_fixedPos.GetLat(rParams.m_lat);
m_fixedPos.GetLon(rParams.m_lon);
}
#else
search::SearchParams const & rParams = params;
#endif
return GetSearchEngine()->Search(rParams, GetCurrentViewport());
}
bool Framework::GetCurrentPosition(double & lat, double & lon) const
@ -1030,6 +1041,12 @@ void Framework::GetDistanceAndAzimut(search::Result const & res,
double lat, double lon, double north,
string & distance, double & azimut)
{
#ifdef FIXED_LOCATION
m_fixedPos.GetLat(lat);
m_fixedPos.GetLon(lon);
m_fixedPos.GetNorth(north);
#endif
m2::PointD const center = res.GetFeatureCenter();
double const d = ms::DistanceOnEarth(lat, lon,

View file

@ -403,8 +403,8 @@ namespace location
double period = 2 * math::pi;
startAngle -= floor(startAngle / period) * period;
endAngle -= floor(endAngle / period) * period;
startAngle = fmod(startAngle, period);
endAngle = fmod(endAngle, period);
if (fabs(startAngle - endAngle) > 20.0 / 180.0 * math::pi)
{

View file

@ -526,9 +526,10 @@ void Navigator::DoScale(m2::PointD const & pt1, m2::PointD const & pt2, double /
double aThresh = 10.0 / 180.0 * math::pi;
double sThresh = 1.2;
if ((1 / s < sThresh)
&& (s < sThresh)
&& (fabs(a) > aThresh))
bool isScalingInBounds = (1 / s < sThresh) || (s < sThresh);
bool isRotationOutBounds = fabs(a) > aThresh;
if (isScalingInBounds && isRotationOutBounds)
m_IsRotatingDuringScale = true;
}