Terminate HereView when closing HereManager
[platform/core/location/maps-plugin-here.git] / inc / here_view.h
1 /*
2  * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #ifndef HERE_VIEW_H
18 #define HERE_VIEW_H
19
20 #include <deque>
21
22 //plug-in header
23 #include "here_manager.h"
24 #include "here_base.h"
25 #include "here_view_objects.h"
26
27 //maps-service header
28 #include <maps_service.h>
29 #include <maps_view.h>
30 #include <maps_view_plugin.h>
31
32 //map engine header
33 #include <maps/GeoTiledMap.h>
34 #include <Ecore.h>
35 #include <Ecore_Evas.h>
36 #include <graphic/Grp_Util.h>
37 #include <maps/GeoMapObjectMarker.h>
38 #include <maps/GeoMapObjectPolygon.h>
39 #include <maps/GeoMapObjectPolyline.h>
40
41 HERE_PLUGIN_BEGIN_NAMESPACE
42
43 using namespace HERE_MAPS_NAMESPACE_PREFIX;
44
45 class HereView
46 : public HereBase
47 {
48 public:
49         HereView();
50         ~HereView();
51
52         here_error_e init(maps_view_h view, maps_plugin_map_view_ready_cb callback);
53         here_error_e close(maps_view_h view);
54         here_error_e renderMap(maps_view_h view, const maps_coordinates_h coord, double zoom, double angle);
55         here_error_e moveCenter(maps_view_h view, int delta_x, int delta_y);
56         here_error_e getCenter(maps_view_h view, maps_coordinates_h *center);
57         here_error_e setScalebarEnabled(maps_view_h view, bool enable);
58         here_error_e getScalebarEnabled(maps_view_h view, bool *enabled);
59         here_error_e convertScreenToGeolocation(maps_view_h view, int x, int y, maps_coordinates_h *coord);
60         here_error_e convertGeolocationToScreen(maps_view_h view,
61                                                                 const maps_coordinates_h coord, int *x, int *y);
62         here_error_e captureSnapshot(maps_view_h view, void **data, int *width, int *height,
63                                                                 maps_view_colorspace_type_e *cs);
64
65         here_error_e getMinZoomLevel(maps_view_h view, int *zoom);
66         here_error_e getMaxZoomLevel(maps_view_h view, int *zoom);
67         here_error_e onViewObject(maps_view_h view, const maps_view_object_h object,
68                                                                 maps_view_object_operation_e operation);
69         here_error_e getViewScale(maps_view_h view, double *scale);
70         here_error_e setViewScale(maps_view_h view, double scale);
71         void TerminateService();
72
73 private:
74         here_error_e initOpenGL();
75         here_error_e initOpenGLSurface(maps_view_h view);
76         here_error_e initMap(maps_view_h view, maps_plugin_map_view_ready_cb callback);
77         void setMapType(maps_view_h view);
78         static void __readyMapCb(maps_view_h view);
79         static Eina_Bool __idlerCb(void *data);
80         static void __renderingCb(void *data);
81         static void __pixelGetCb(void *data, Evas_Object *obj);
82         static void __processViewObject(maps_view_h view, const maps_view_object_h object,
83                                                                 maps_view_object_operation_e operation);
84
85 private:
86         Here::Maps::GeoTiledMap *__map;
87
88         Evas_Object     *__img;
89         Evas_GL_Context *__ctx;
90         Evas_GL_Surface *__sfc;
91         Evas_GL_Config  *__cfg;
92         Evas_GL         *__gl;
93         Evas_GL_API     *__api;
94
95         bool __isInitialized;
96         bool __isShutdown;
97
98         int __x, __y, __w, __h;
99
100         HereViewObjects __visualObjects;
101         PendingObjects __pendingObjects;
102         Ecore_Idler *__idler;
103         bool __redraw;
104
105         maps_plugin_map_view_ready_cb __readyCb;
106 };
107
108 HERE_PLUGIN_END_NAMESPACE
109
110 #endif