Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Zolotarev <deathbaba@gmail.com>2011-10-23 05:24:51 +0400
committerAlex Zolotarev <alex@maps.me>2015-09-23 01:26:35 +0300
commitbf559047229bf85e109d30b49ac7dd9d4b10a85f (patch)
treed3af6d4b3d0bc109aa2e876c16084f79ea162e4b
parent175ec47793aa169b2d237fee2ed2383971189679 (diff)
Removed unnecessary device orientation support in framework.
[ios] Fixed orientation bug when map controller didn't receive orientation change event if another modal controller was on the top @TODO [ios] Set correct angle in compass events using UIDeviceOrientationChanged notification
-rw-r--r--geometry/screenbase.cpp2
-rw-r--r--geometry/screenbase.hpp12
-rw-r--r--iphone/Maps/Classes/MapViewController.mm30
-rw-r--r--map/events.hpp31
-rw-r--r--map/framework.cpp46
-rw-r--r--map/framework.hpp3
-rw-r--r--map/location_state.cpp29
-rw-r--r--map/location_state.hpp2
-rw-r--r--map/navigator.cpp30
-rw-r--r--map/navigator.hpp8
10 files changed, 39 insertions, 154 deletions
diff --git a/geometry/screenbase.cpp b/geometry/screenbase.cpp
index 4b789f82a2..d1a6f00fe9 100644
--- a/geometry/screenbase.cpp
+++ b/geometry/screenbase.cpp
@@ -6,8 +6,6 @@
#include "transformations.hpp"
#include "angles.hpp"
-#include "../base/start_mem_debug.hpp"
-
ScreenBase::ScreenBase() :
m_PixelRect(0, 0, 640, 480),
m_Scale(0.1),
diff --git a/geometry/screenbase.hpp b/geometry/screenbase.hpp
index 46f50ac0e5..d23d9c00f4 100644
--- a/geometry/screenbase.hpp
+++ b/geometry/screenbase.hpp
@@ -6,16 +6,6 @@
#include "../base/math.hpp"
-#include "../base/start_mem_debug.hpp"
-
-enum EOrientation
-{
- EOrientation0,
- EOrientation90,
- EOrientation180,
- EOrientation270
-};
-
class ScreenBase
{
m2::RectD m_PixelRect;
@@ -134,5 +124,3 @@ public:
/// checking whether the s1 transforms into s2 without scaling, only with shift and rotation
bool IsPanningAndRotate(ScreenBase const & s1, ScreenBase const & s2);
-
-#include "../base/stop_mem_debug.hpp"
diff --git a/iphone/Maps/Classes/MapViewController.mm b/iphone/Maps/Classes/MapViewController.mm
index 53072cb65f..e7560e2fd5 100644
--- a/iphone/Maps/Classes/MapViewController.mm
+++ b/iphone/Maps/Classes/MapViewController.mm
@@ -156,18 +156,19 @@ NSInteger compareAddress(id l, id r, void * context)
{
NSSet * allTouches = [event allTouches];
- CGFloat const scaleFactor = self.view.contentScaleFactor;
+ UIView * v = self.view;
+ CGFloat const scaleFactor = v.contentScaleFactor;
if ([allTouches count] == 1)
{
- CGPoint const pt = [[[allTouches allObjects] objectAtIndex:0] locationInView:nil];
+ CGPoint const pt = [[[allTouches allObjects] objectAtIndex:0] locationInView:v];
m_Pt1 = m2::PointD(pt.x * scaleFactor, pt.y * scaleFactor);
}
else
{
NSArray * sortedTouches = [[allTouches allObjects] sortedArrayUsingFunction:compareAddress context:NULL];
- CGPoint const pt1 = [[sortedTouches objectAtIndex:0] locationInView:nil];
- CGPoint const pt2 = [[sortedTouches objectAtIndex:1] locationInView:nil];
+ CGPoint const pt1 = [[sortedTouches objectAtIndex:0] locationInView:v];
+ CGPoint const pt2 = [[sortedTouches objectAtIndex:1] locationInView:v];
m_Pt1 = m2::PointD(pt1.x * scaleFactor, pt1.y * scaleFactor);
m_Pt2 = m2::PointD(pt2.x * scaleFactor, pt2.y * scaleFactor);
@@ -298,23 +299,9 @@ NSInteger compareAddress(id l, id r, void * context)
[super viewDidUnload];
}
-- (void) didRotateFromInterfaceOrientation: (UIInterfaceOrientation) fromInterfaceOrientation
-{
- EOrientation newOrientation = EOrientation0;
- switch (self.interfaceOrientation)
- {
- case UIInterfaceOrientationPortrait: newOrientation = EOrientation0;break;
- case UIInterfaceOrientationPortraitUpsideDown: newOrientation = EOrientation180; break;
- case UIInterfaceOrientationLandscapeLeft: newOrientation = EOrientation90; break;
- case UIInterfaceOrientationLandscapeRight: newOrientation = EOrientation270; break;
- }
- m_framework->SetOrientation(newOrientation);
-}
-
- (void) OnTerminate
{
- if (m_framework)
- m_framework->SaveState();
+ m_framework->SaveState();
}
- (void) Invalidate
@@ -323,6 +310,11 @@ NSInteger compareAddress(id l, id r, void * context)
m_framework->Invalidate();
}
+- (void) didRotateFromInterfaceOrientation: (UIInterfaceOrientation) fromInterfaceOrientation
+{
+ [self Invalidate];
+}
+
- (void) OnEnterBackground
{
// save world rect for next launch
diff --git a/map/events.hpp b/map/events.hpp
index 6c8ad98dfb..e7adbfce4b 100644
--- a/map/events.hpp
+++ b/map/events.hpp
@@ -1,25 +1,15 @@
#pragma once
-#include "../geometry/point2d.hpp"
-
-#include "../std/shared_ptr.hpp"
#include "../base/commands_queue.hpp"
-#include "../base/start_mem_debug.hpp"
-
-
-class Event
-{
-public:
- Event() {}
-};
+#include "../geometry/point2d.hpp"
class DragEvent
{
m2::PointD m_pt;
public:
DragEvent(double x, double y) : m_pt(x, y) {}
- m2::PointD Pos() const { return m_pt; }
+ inline m2::PointD const & Pos() const { return m_pt; }
};
class RotateEvent
@@ -36,10 +26,7 @@ public:
m_Angle = atan2(dy, dx);
}
- double Angle() const
- {
- return m_Angle;
- }
+ inline double Angle() const { return m_Angle; }
};
class ScaleEvent
@@ -47,8 +34,8 @@ class ScaleEvent
m2::PointD m_Pt1, m_Pt2;
public:
ScaleEvent(double x1, double y1, double x2, double y2) : m_Pt1(x1, y1), m_Pt2(x2, y2) {}
- m2::PointD Pt1() const { return m_Pt1; }
- m2::PointD Pt2() const { return m_Pt2; }
+ inline m2::PointD const & Pt1() const { return m_Pt1; }
+ inline m2::PointD const & Pt2() const { return m_Pt2; }
};
class ScaleToPointEvent
@@ -57,13 +44,13 @@ class ScaleToPointEvent
double m_factor;
public:
ScaleToPointEvent(double x1, double y1, double factor) : m_Pt1(x1, y1), m_factor(factor) {}
- m2::PointD Pt() const { return m_Pt1; }
- double ScaleFactor() const { return m_factor; }
+ inline m2::PointD const & Pt() const { return m_Pt1; }
+ inline double ScaleFactor() const { return m_factor; }
};
class DrawerYG;
-class PaintEvent : public Event
+class PaintEvent
{
DrawerYG * m_drawer;
@@ -95,5 +82,3 @@ public:
return m_isCancelled;
}
};
-
-#include "../base/stop_mem_debug.hpp"
diff --git a/map/framework.cpp b/map/framework.cpp
index c2c3eb2b6d..c007d5ea1a 100644
--- a/map/framework.cpp
+++ b/map/framework.cpp
@@ -284,15 +284,6 @@ bool Framework<TModel>::SetUpdatesEnabled(bool doEnable)
return m_windowHandle->setUpdatesEnabled(doEnable);
}
-/// respond to device orientation changes
-template <typename TModel>
-void Framework<TModel>::SetOrientation(EOrientation orientation)
-{
- m_navigator.SetOrientation(orientation);
- m_locationState.SetOrientation(orientation);
- Invalidate();
-}
-
template <typename TModel>
double Framework<TModel>::GetCurrentScale() const
{
@@ -478,14 +469,12 @@ void Framework<TModel>::InvalidateRect(m2::RectD const & rect)
template <typename TModel>
void Framework<TModel>::StartDrag(DragEvent const & e)
{
- m2::PointD pos = m_navigator.OrientPoint(e.Pos());
-
#ifdef DRAW_TOUCH_POINTS
- m_informationDisplay.setDebugPoint(0, pos);
+ m_informationDisplay.setDebugPoint(0, e.Pos());
#endif
- m_navigator.StartDrag(pos, m_timer.ElapsedSeconds());
- m_renderPolicy->StartDrag(pos, m_timer.ElapsedSeconds());
+ m_navigator.StartDrag(e.Pos(), m_timer.ElapsedSeconds());
+ m_renderPolicy->StartDrag(e.Pos(), m_timer.ElapsedSeconds());
}
template <typename TModel>
@@ -493,29 +482,25 @@ void Framework<TModel>::DoDrag(DragEvent const & e)
{
m_centeringMode = EDoNothing;
- m2::PointD pos = m_navigator.OrientPoint(e.Pos());
-
#ifdef DRAW_TOUCH_POINTS
- m_informationDisplay.setDebugPoint(0, pos);
+ m_informationDisplay.setDebugPoint(0, e.Pos());
#endif
- m_navigator.DoDrag(pos, m_timer.ElapsedSeconds());
+ m_navigator.DoDrag(e.Pos(), m_timer.ElapsedSeconds());
- m_renderPolicy->DoDrag(pos, m_timer.ElapsedSeconds());
+ m_renderPolicy->DoDrag(e.Pos(), m_timer.ElapsedSeconds());
}
template <typename TModel>
void Framework<TModel>::StopDrag(DragEvent const & e)
{
- m2::PointD pos = m_navigator.OrientPoint(e.Pos());
-
- m_navigator.StopDrag(pos, m_timer.ElapsedSeconds(), true);
+ m_navigator.StopDrag(e.Pos(), m_timer.ElapsedSeconds(), true);
#ifdef DRAW_TOUCH_POINTS
m_informationDisplay.setDebugPoint(0, m2::PointD(0, 0));
#endif
- m_renderPolicy->StopDrag(pos, m_timer.ElapsedSeconds());
+ m_renderPolicy->StopDrag(e.Pos(), m_timer.ElapsedSeconds());
}
template <typename TModel>
@@ -564,8 +549,7 @@ template <typename TModel>
void Framework<TModel>::ScaleToPoint(ScaleToPointEvent const & e)
{
m2::PointD const pt = (m_centeringMode == EDoNothing)
- ? m_navigator.OrientPoint(e.Pt())
- : m_navigator.Screen().PixelRect().Center();
+ ? e.Pt() : m_navigator.Screen().PixelRect().Center();
m_navigator.ScaleToPoint(pt, e.ScaleFactor(), m_timer.ElapsedSeconds());
@@ -590,8 +574,8 @@ void Framework<TModel>::Scale(double scale)
template <typename TModel>
void Framework<TModel>::StartScale(ScaleEvent const & e)
{
- m2::PointD pt1 = m_navigator.OrientPoint(e.Pt1());
- m2::PointD pt2 = m_navigator.OrientPoint(e.Pt2());
+ m2::PointD pt1 = e.Pt1();
+ m2::PointD pt2 = e.Pt2();
if ((m_locationState & location::State::EGps) && (m_centeringMode == ECenterOnly))
{
@@ -613,8 +597,8 @@ void Framework<TModel>::StartScale(ScaleEvent const & e)
template <typename TModel>
void Framework<TModel>::DoScale(ScaleEvent const & e)
{
- m2::PointD pt1 = m_navigator.OrientPoint(e.Pt1());
- m2::PointD pt2 = m_navigator.OrientPoint(e.Pt2());
+ m2::PointD pt1 = e.Pt1();
+ m2::PointD pt2 = e.Pt2();
if ((m_locationState & location::State::EGps) && (m_centeringMode == ECenterOnly))
{
@@ -636,8 +620,8 @@ void Framework<TModel>::DoScale(ScaleEvent const & e)
template <typename TModel>
void Framework<TModel>::StopScale(ScaleEvent const & e)
{
- m2::PointD pt1 = m_navigator.OrientPoint(e.Pt1());
- m2::PointD pt2 = m_navigator.OrientPoint(e.Pt2());
+ m2::PointD pt1 = e.Pt1();
+ m2::PointD pt2 = e.Pt2();
if ((m_locationState & location::State::EGps) && (m_centeringMode == ECenterOnly))
{
diff --git a/map/framework.hpp b/map/framework.hpp
index 48660f3edc..58415838aa 100644
--- a/map/framework.hpp
+++ b/map/framework.hpp
@@ -200,9 +200,6 @@ public:
bool SetUpdatesEnabled(bool doEnable);
- /// respond to device orientation changes
- void SetOrientation(EOrientation orientation);
-
double GetCurrentScale() const;
m2::PointD GetViewportCenter() const;
diff --git a/map/location_state.cpp b/map/location_state.cpp
index b874fcf5db..72e888928e 100644
--- a/map/location_state.cpp
+++ b/map/location_state.cpp
@@ -8,7 +8,7 @@
namespace location
{
- State::State() : m_deviceOrientation(-math::pi / 2), m_flags(ENone)
+ State::State() : m_flags(ENone)
{
}
@@ -33,25 +33,6 @@ namespace location
m_headingAccuracyRad = info.m_accuracy / 180 * math::pi;
}
- void State::SetOrientation(EOrientation orientation)
- {
- switch (orientation)
- {
- case EOrientation0:
- m_deviceOrientation = -math::pi / 2;
- break;
- case EOrientation90:
- m_deviceOrientation = math::pi;
- break;
- case EOrientation180:
- m_deviceOrientation = math::pi / 2;
- break;
- case EOrientation270:
- m_deviceOrientation = 0;
- break;
- }
- }
-
void State::DrawMyPosition(DrawerYG & drawer, ScreenBase const & screen)
{
double pxErrorRadius;
@@ -77,14 +58,14 @@ namespace location
if (m_flags & State::ECompass)
{
drawer.screen()->drawSector(pxPosition,
- m_deviceOrientation + m_headingRad - m_headingAccuracyRad,
- m_deviceOrientation + m_headingRad + m_headingAccuracyRad,
+ m_headingRad - m_headingAccuracyRad,
+ m_headingRad + m_headingAccuracyRad,
pxErrorRadius,
yg::Color(255, 255, 255, 192),
yg::maxDepth);
drawer.screen()->fillSector(pxPosition,
- m_deviceOrientation + m_headingRad - m_headingAccuracyRad,
- m_deviceOrientation + m_headingRad + m_headingAccuracyRad,
+ m_headingRad - m_headingAccuracyRad,
+ m_headingRad + m_headingAccuracyRad,
pxErrorRadius,
yg::Color(255, 255, 255, 96),
yg::maxDepth - 1);
diff --git a/map/location_state.hpp b/map/location_state.hpp
index 416cc47fcb..6abfbc54b9 100644
--- a/map/location_state.hpp
+++ b/map/location_state.hpp
@@ -15,7 +15,6 @@ namespace location
double m_errorRadiusMercator;
m2::PointD m_positionMercator;
- double m_deviceOrientation;
double m_headingRad;
double m_headingAccuracyRad;
@@ -37,7 +36,6 @@ namespace location
void TurnOff() { m_flags = ENone; }
void UpdateGps(GpsInfo const & info);
void UpdateCompass(CompassInfo const & info);
- void SetOrientation(EOrientation orientation);
void DrawMyPosition(DrawerYG & drawer, ScreenBase const & screen);
operator int() const
diff --git a/map/navigator.cpp b/map/navigator.cpp
index fb7d54ad5e..3f1ff4a20e 100644
--- a/map/navigator.cpp
+++ b/map/navigator.cpp
@@ -21,7 +21,6 @@
Navigator::Navigator()
: m_worldRect(MercatorBounds::minX, MercatorBounds::minY, MercatorBounds::maxX, MercatorBounds::maxY),
m_InAction(false),
- m_orientation(EOrientation0),
m_doSupportRotation(false)
{
}
@@ -31,7 +30,6 @@ Navigator::Navigator(ScreenBase const & screen)
m_StartScreen(screen),
m_Screen(screen),
m_InAction(false),
- m_orientation(EOrientation0),
m_doSupportRotation(false)
{
}
@@ -497,34 +495,6 @@ bool Navigator::Update(double timeInSec)
return false;
}
-void Navigator::SetOrientation(EOrientation orientation)
-{
- m_orientation = orientation;
-}
-
-EOrientation Navigator::Orientation() const
-{
- return m_orientation;
-}
-
-m2::PointD const Navigator::OrientPoint(m2::PointD const & pt) const
-{
- m2::PointD ptShift(m_Screen.PixelRect().minX(), m_Screen.PixelRect().minY());
-
- switch (m_orientation)
- {
- case EOrientation90:
- return m2::PointD(m_Screen.GetWidth() - pt.y, pt.x) + ptShift;
- case EOrientation180:
- return m2::PointD(m_Screen.GetWidth() - pt.x, m_Screen.GetHeight() - pt.y) + ptShift;
- case EOrientation270:
- return m2::PointD(pt.y, m_Screen.GetHeight() - pt.x) + ptShift;
- case EOrientation0:
- return pt + ptShift;
- };
- return ptShift;
-}
-
void Navigator::SetSupportRotation(bool flag)
{
m_doSupportRotation = flag;
diff --git a/map/navigator.hpp b/map/navigator.hpp
index 865b496c09..d4ef3a393a 100644
--- a/map/navigator.hpp
+++ b/map/navigator.hpp
@@ -55,12 +55,6 @@ public:
bool InAction() const;
- void SetOrientation(EOrientation orientation);
- EOrientation Orientation() const;
-
- // Do appropriate coordinate axes swapping according to orientation
- m2::PointD const OrientPoint(m2::PointD const & pt) const;
-
void SetSupportRotation(bool flag);
private:
@@ -105,8 +99,6 @@ private:
math::Matrix<float, 3, 3> m_DeltaMatrix;
// Flag, which indicates, whether we are in the middle of some action.
bool m_InAction;
- // Device orientation
- EOrientation m_orientation;
// Does Navigator supports screen rotation.
bool m_doSupportRotation;
// Used in DoScale and ScaleByPoint