54b37f7e377b2d65b96c989d1a061b5c748edc71
[platform/core/api/maps-service.git] / src / view / inertial_camera.h
1 /* Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
2  *
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15
16 #ifndef __MAPS_VIEW_INERTIAL_CAMERA_H__
17 #define __MAPS_VIEW_INERTIAL_CAMERA_H__
18
19
20 #include "maps_view.h"
21
22 namespace view
23 {
24         class inertial_camera {
25         protected:
26                 maps_view_h _view;
27
28                 /* Targets */
29                 double target_zoom_factor;
30                 double target_rotation_angle;
31                 maps_coordinates_h target_center;
32
33                 /* Current state of transition (or begining) */
34                 double cur_zoom_factor;
35                 double cur_rotation_angle;
36                 maps_coordinates_h cur_center;
37
38                 /* Is transition performing right now */
39                 bool transiting;
40         protected:
41 #if (__cplusplus >= 201103L)
42                 static constexpr double __GEO_ACCURACY = 0.00001;
43                 static constexpr double __ZOOM_ACCURACY = 0.1;
44                 static constexpr double __ROTATE_ACCURACY = 0.5;
45 #else
46                 static const double __GEO_ACCURACY = 0.00001;
47                 static const double __ZOOM_ACCURACY = 0.1;
48                 static const double __ROTATE_ACCURACY = 0.5;
49 #endif
50         public:
51                 inertial_camera(maps_view_h view);
52                 ~inertial_camera();
53         private:
54                 inertial_camera(const inertial_camera &src);
55                 inertial_camera &operator=(const inertial_camera &src);
56         public:
57                 void set_targets(const maps_coordinates_h center,
58                                  const double &zoom_factor,
59                                  const double &rotation_angle);
60                 void set_center_target(const maps_coordinates_h center);
61                 void set_zoom_target(const double &zoom_factor);
62                 void set_rotation_target(const double &rotation_angle);
63
64                 bool next_transition_step();
65
66                 bool is_transiting() const { return transiting; }
67                 void set_transiting(bool b) { transiting = b; }
68                 maps_coordinates_h get_cur_center() const { return cur_center; }
69                 double get_cur_zoom_factor() const { return cur_zoom_factor; }
70                 double get_cur_rotation_angle() const {
71                         return cur_rotation_angle; }
72
73         protected:
74                 double calc_next_step(const double &start,
75                                      const double &finish,
76                                      const double step_ratio) const;
77                 double calc_next_step_lon(const double &start,
78                                      const double &finish,
79                                      const double step_ratio) const;
80                 void set_cur_state();
81         };
82 };
83
84 #endif /* __MAPS_VIEW_INERTIAL_CAMERA_H__ */