All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
RouteSimulationSession.h
1 // Copyright eeGeo Ltd (2012-2014), All Rights Reserved
2 
3 #pragma once
4 
5 #include "Types.h"
6 #include "Routes.h"
7 #include "RouteSample.h"
8 #include "Streaming.h"
9 #include "VectorMath.h"
10 #include <vector>
11 
12 namespace Eegeo
13 {
14  namespace Routes
15  {
16  namespace Simulation
17  {
19  {
20  public:
21  enum RouteSimulationSessionState
22  {
23  InactiveState,
24  PausedState,
25  ActiveState
26  };
27 
28  enum RouteSimulationPlaybackDirection
29  {
30  PlaybackDirectionForward,
31  PlaybackDirectionReverse
32  };
33 
34  enum RouteSimulationPlaybackSpeed
35  {
36  PlaybackSpeedUseLinkSpeedValue,
37  PlaybackSpeedUseLinkSpeedMultiplier,
38  PlaybackSpeedUseCustomSpeed
39  };
40 
41  private:
42 
43  const Route& m_route;
44 
45 
46  RouteSimulationSessionState m_state;
47  RouteSimulationPlaybackDirection m_playbackDirection;
48  RouteSimulationPlaybackSpeed m_playbackSpeed;
49  float m_linkSpeedMultiplier;
50  float m_customSpeed;
51  bool m_routeCompleted;
52  bool m_drivesOnRight;
53 
54 
55  typedef std::vector<IRouteSimulationSessionObserver*> TSessionObservers;
56  TSessionObservers m_observers;
57 
58  double m_currentRouteParam;
59 
60 
61 
62  RouteSampler* m_routeSampler;
63 
64  RouteSample* m_currentRouteSample;
65  RouteSample m_routeSampleAllocation;
66 
67 
68  int m_currentRouteIndex;
69 
70 
71  void InvalidateRouteSample()
72  {
73  m_currentRouteSample = NULL;
74  }
75 
76  void SetRouteSample(const RouteSample& v)
77  {
78  m_currentRouteSample = &m_routeSampleAllocation;
79  *m_currentRouteSample = v;
80  }
81 
82  public:
83  RouteSimulationSession(const Route& route,
84  RouteSamplerFactory& routeSamplerFactory);
85 
87 
88  void InvalidateCachedFittedRouteForKey(const Eegeo::Streaming::MortonKey& key);
89 
90 
91  RouteVertexClassification GetCurrentLinkClassification() const;
92  v3 GetCurrentDirection() const;
93 
94  dv3 GetCurrentPositionEcef() const;
95 
96  const Route& GetRoute() const;
97 
98  double GetDistanceFromStartInMetres() const;
99 
100  RouteSimulationSessionState GetSessionState() const;
101 
102  RouteSimulationPlaybackDirection GetPlaybackDirection() const;
103 
104  double GetCurrentParam() const;
105 
106  RouteSimulationPlaybackSpeed GetPlaybackSpeedType() const;
107 
108  bool IsRouteCompleted() const;
109 
110  void SetCurrentPositionSnappedToRoute(const Eegeo::dv3& targetEcef);
111 
112  void StartPlaybackFromBeginning();
113 
114  void EndPlayback();
115 
116  void Pause();
117 
118  void Unpause();
119 
120  void SetReversePlaybackDirection();
121 
122  void SetForwardPlaybackDirection();
123 
124  void TogglePlaybackDirection();
125 
126  void Update(float dt);
127 
128  void UseCustomSpeedValue(float customSpeedValue);
129 
130  void UseLinkSpeedValueWithMultiplier(float linkSpeedMultiplier);
131 
132  void UseLinkSpeedValue();
133 
134  bool GetDrivesOnRight() const;
135 
136  void SetDrivesOnRight(bool drivesOnRight);
137 
138  void AddSessionObserver(IRouteSimulationSessionObserver& observer);
139 
140  void RemoveSessionObserver(IRouteSimulationSessionObserver& observer);
141 
142  bool IsForRoute(const Route* pRoute) const
143  {
144  return &m_route == pRoute;
145  }
146 
147  void UpdatePositionStateFromRouteParam(const double routeParam);
148 
149  private:
150  float GetSpeed() const;
151  };
152  }
153  }
154 }