*
* @see maps_view_create()
*/
- int maps_view_set_maps_plugin_view_handle(maps_view_h hView, void *maps_plugin_view_handle);
+ int maps_view_set_maps_plugin_view_handle(maps_view_h view, void *maps_plugin_view_handle);
+/**
+ * @brief Set the position of provider's logo.
+ * @details This function sets the position of provider's logo on screen.
+ *
+ * @param[in] view The view handle
+ * @param[in] x_factor The propotional x-position of the logo [0.0~1.0]
+ * @param[in] y_factor The propotional y-position of the logo [0.0~1.0]
+ * @return 0 on success, otherwise a negative error value
+ * @retval #MAPS_ERROR_NONE Successful
+ * @retval #MAPS_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MAPS_ERROR_SERVICE_NOT_AVAILABLE Service not available
+ * @retval #MAPS_ERROR_NOT_SUPPORTED Not supported
+ *
+ * @pre @a view is created using maps_view_create().
+ *
+ * @see maps_view_create()
+ */
+int maps_view_set_logo_position(maps_view_h view, double x_factor, double y_factor);
+
#ifdef __cplusplus
}
#endif
return MAPS_ERROR_NONE;
}
- } while(0);
+EXPORT_API int maps_view_object_polyline_append_point(maps_view_object_h polyline,
+ maps_coordinates_h point)
+{
+ if (!polyline || !point)
+ return MAPS_ERROR_INVALID_PARAMETER;
+
+ /* Get the polyline data pointer */
+ maps_view_polyline_data_s *p = __get_polyline_data(polyline);
+ if (!p)
+ return MAPS_ERROR_INVALID_PARAMETER;
+
+ /* Set new polyline trajectory */
+ int error = MAPS_ERROR_NONE;
+ do {
+ if (!p->points) {
+ error = maps_coordinates_list_create(&p->points);
+ if (error != MAPS_ERROR_NONE)
+ break;
+ }
+
+ error = maps_coordinates_list_append(p->points, point);
+ if (error != MAPS_ERROR_NONE)
+ break;
+
+ /* Notify view, that the object specific preferences is changed */
+ _maps_view_on_object_operation(__get_view(polyline), polyline, MAPS_VIEW_OBJECT_CHANGE);
++ } while (0);
+
+ return error;
+}
+
EXPORT_API int maps_view_object_polyline_foreach_point(maps_view_object_h polyline,
maps_coordinates_cb callback, void *user_data)
{
cmd->set_merged();
}
}
-
+
+/*----------------------------------------------------------------------------*/
+
+int session::command_view_tilt_angle::run()
+{
+ MAPS_LOGD("session::command_view_tilt_angle::run angle = %f", tilt_angle);
+
+ if (!v)
+ return MAPS_ERROR_INVALID_PARAMETER;
+
+ const int ret = _maps_view_set_tilt_angle(v, tilt_angle);
+
+ destroy();
+ return ret;
+}
+
+session::command_type_e session::command_view_tilt_angle::get_type() const
+{
+ return MAPS_VIEW_TILT_COMMAND;
+}
+
+int session::command_view_tilt_angle::get_priority() const
+{
+ return 2;
+}
+
+void session::command_view_tilt_angle::merge(const command *c)
+{
+ if (!c || (get_type() != c->get_type())) return;
+ command_view_tilt_angle *cmd = (command_view_tilt_angle *)c;
+ if (v == cmd->v) {
+ tilt_angle = cmd->tilt_angle;
+ cmd->set_merged();
+ }
+}
, _current_state(STATE_NONE)
, is_rotating(false)
, is_zoomming(false)
+ , is_2fingers_panning(false)
+ , is_tilting(false)
{
for(int i = 0; i < MAX_FINGERS; i ++)
is_panning[i] = false;
if(event != FINGER_MOVE && event != FINGER2_MOVE) {
finish_zoomming();
finish_rotating();
+ finish_2fingers_panning();
+ finish_tilting();
}
switch(event) {
if(event != FINGER_MOVE && event != FINGER2_MOVE) {
finish_zoomming();
finish_rotating();
+ finish_2fingers_panning();
+ finish_tilting();
_info._start_view_state.capture(_view);
}
{
if (!is_gesture_available(MAPS_VIEW_GESTURE_ZOOM)
&& !is_gesture_available(MAPS_VIEW_GESTURE_ROTATE)
- && !is_gesture_available(MAPS_VIEW_GESTURE_SCROLL))
++ && !is_gesture_available(MAPS_VIEW_GESTURE_SCROLL)
+ && !is_gesture_available(MAPS_VIEW_GESTURE_TILT))
return;
- log("GESTURE ZOOM ROTATE DETECTED", FG_GREEN);
+ log("GESTURE 2FINGERS PAN DETECTED", FG_GREEN);
- #if 1
+
bool zoom_changed = false;
bool rotation_changed = false;
+ bool panning_changed = false;
double zoom_factor = .0;
double rotation_angle = .0;
+ int panning_x = 0;
+ int panning_y = 0;
- zoom_changed = _gp.on_zoom(is_zoomming, is_rotating, zoom_factor);
- if (zoom_changed)
- start_zoomming();
+ if (!is_zoomming && !is_rotating) {
+ if (_gp.on_tilt()) {
+ start_tilting();
+ return;
+ }
+ }
- rotation_changed = _gp.on_rotate(is_zoomming, is_rotating, rotation_angle);
- if (rotation_changed)
- start_rotating();
+ if (!is_tilting) {
- zoom_changed = _gp.on_zoom(is_zoomming, zoom_factor);
++ zoom_changed = _gp.on_zoom(is_zoomming, is_rotating, zoom_factor);
+ if (zoom_changed)
+ start_zoomming();
- rotation_changed = _gp.on_rotate(is_rotating, rotation_angle);
+
- panning_changed = _gp.on_two_fingers_pan(is_2fingers_panning, &panning_x, &panning_y);
- if (panning_changed)
- start_2fingers_panning();
++ rotation_changed = _gp.on_rotate(is_zoomming, is_rotating, rotation_angle);
+ if (rotation_changed)
+ start_rotating();
- _gp.on_zoom_rotate(zoom_changed, zoom_factor, rotation_changed, rotation_angle);
- _gp.on_zoom_rotate(zoom_changed, zoom_factor, rotation_changed, rotation_angle, panning_changed, panning_x, panning_y);
++ panning_changed = _gp.on_two_fingers_pan(is_2fingers_panning, &panning_x, &panning_y);
++ if (panning_changed)
++ start_2fingers_panning();
++
++ _gp.on_zoom_rotate(zoom_changed, zoom_factor, rotation_changed, rotation_angle, panning_changed, panning_x, panning_y);
+ }
- #else
- _gp.on_zoom_rotate();
- #endif
}
-void view::gesture_detector_statemachine::detected_2finger_tap() /* 2Finger Tap */
+void view::gesture_detector_statemachine::detected_2fingers_tap() /* 2Finger Tap */
{
if (!is_gesture_available(MAPS_VIEW_GESTURE_2_FINGER_TAP))
return;
bool is_panning[MAX_FINGERS];
bool is_rotating;
bool is_zoomming;
+ bool is_2fingers_panning;
+ bool is_tilting;
public:
gesture_detector_statemachine(maps_view_h v);
void finish_rotating() { is_rotating = false; }
void start_zoomming() { is_zoomming = true; }
void finish_zoomming() { is_zoomming = false; }
+ void start_2fingers_panning() { is_2fingers_panning = true; }
+ void finish_2fingers_panning() { is_2fingers_panning = false; }
+ void start_tilting() { is_tilting = true; }
+ void finish_tilting() { is_tilting = false; }
private:
void log_state(view_event_e event, detector_states_e state);
_new_rotation_angle = (angle / M_PI * 180.);
_rotation_happend = true;
} else if (curl > 0) {
- _new_rotation_angle = 360 - (angle / M_PI * 180.);
+ _new_rotation_angle = -(angle / M_PI * 180.);
_rotation_happend = true;
}
+
+ /* Calculating the tilt angle */
+ const double tilt_angle = atan2(cur_dy, cur_dx) / M_PI * 180. + 180.0;
+ MAPS_LOGD("tilt_angle = %f, cur_dx=%d, cur_dy=%d, angle=%f", tilt_angle, cur_dx, cur_dy, angle);
+ if (tilt_angle >= 340 || tilt_angle <= 20 || (tilt_angle >= 160 && tilt_angle <= 200)) {
+ _new_tilt_pixels = ((_cur_tp_f1._y - _start_tp_f1._y) + (_cur_tp_f2._y - _start_tp_f2._y)) / 2;
+ _tilt_happend = true;
+ }
}
zoom_changed, zoom_factor, rotation_changed, rotation_angle));
maps_coordinates_destroy(center);
- #else
- const touch_point start_tp_f1 = _gd->_info._finger_down[0];
- const touch_point cur_tp_f1 = _gd->_info._finger_move[0];
-
- /* Second finger effective way by now */
- const touch_point start_tp_f2 = _gd->_info._finger_down[1];
- const touch_point cur_tp_f2 = _gd->_info._finger_move[1];
-
- /* Calcurating center position */
- const touch_point start_center = calc_center(start_tp_f1, start_tp_f2);
- const touch_point cur_center = calc_center(cur_tp_f1, cur_tp_f2);
-
- /* a. Find delta in screen coordinates */
- const int delta_x = cur_center._x - start_center._x;
- const int delta_y = cur_center._y - start_center._y;
-
- /* b. Get the initial screen coordinates of the center */
- int center_x = 0;
- int center_y = 0;
- double lat, lon;
- maps_coordinates_get_latitude_longitude(_gd->_info._start_view_state._center, &lat, &lon);
- maps_view_geolocation_to_screen(_gd->_view, _gd->_info._start_view_state._center, ¢er_x, ¢er_y);
-
- /* c. Apply the delta to the intital center coordinates */
- center_x -= delta_x;
- center_y -= delta_y;
-
- /* d. Converting screent coordinates of new center to
- * the geographical */
- maps_coordinates_h new_center = NULL;
- maps_view_screen_to_geolocation(_gd->_view, center_x, center_y, &new_center);
-
- /* e. Enque the command to move the center */
- q()->push(new session::command_view_set_center(get_maps(), _gd->_view, new_center));
-
- /* f. Enqueue the detected zomm command */
- maps_view_gesture_e gesture = (zoom_changed ? MAPS_VIEW_GESTURE_ZOOM : MAPS_VIEW_GESTURE_ROTATE);
- q()->push(construct_gesture_command(gesture, new_center,
- zoom_changed, zoom_factor, rotation_changed, rotation_angle));
-
- maps_coordinates_destroy(new_center);
- #endif
}
- new_tilt_angle += 45 * ((double)zc.get_tilt_pixels() / maps_get_display_dpi());
+bool view::gesture_processor::on_tilt()
+{
+ gesture_detector::log("view::gesture_processor::on_tilt", gesture_detector::FG_LITE_GREEN);
+ /* Assumed that we can zoom&rotate using only a pair of fingers */
+
+ /* First finger effective way by now */
+ const touch_point start_tp_f1 = _gd->_info._finger_down[0];
+ const touch_point cur_tp_f1 = _gd->_info._finger_move[0];
+
+ /* Second finger effective way by now */
+ const touch_point start_tp_f2 = _gd->_info._finger_down[1];
+ const touch_point cur_tp_f2 = _gd->_info._finger_move[1];
+
+ /***********************/
+ MAPS_LOGI("%c[%d;%d;%dm"
+ "Finger1: start(%d, %d), cur(%d, %d)\t"
+ "Finger2: start(%d, %d), cur(%d, %d)\t"
+ "%c[%d;%d;%dm",
+ 0x1B, 1, 0, gesture_detector::FG_YELLOW,
+ start_tp_f1._x, start_tp_f1._y, cur_tp_f1._x, cur_tp_f1._y,
+ start_tp_f2._x, start_tp_f2._y, cur_tp_f2._x, cur_tp_f2._y,
+ 0x1B, 0, 0, 0);
+ /***********************/
+
+ /* Calcurating center position */
+ const touch_point cur_center = calc_center(cur_tp_f1, cur_tp_f2);
+
+ /* Calculating the current zoom factor, accordingly to effecitve ways of fingers */
+ zoom_calculator zc(start_tp_f1, cur_tp_f1, start_tp_f2, cur_tp_f2);
+ double old_tilt_angle = _gd->_info._start_view_state._tilt_angle;
+ double new_tilt_angle = _gd->_info._start_view_state._tilt_angle;
+
+ /* Analyse zoom factor changes */
+ if (zc.tilt_happend()) {
++ int dpi;
+ /* Apply newly calculated tilt angle */
+ /* Panning 1 inch on the screen, tilt angle will be changed 45 dgree */
++ if (maps_get_screen_dpi(&dpi) == MAPS_ERROR_NONE)
++ new_tilt_angle += 45 * ((double)zc.get_tilt_pixels() / dpi);
+
+ /* Correct the zoom factor accordingly to allowed limits */
+ _maps_view_trim_tilt_angle(_gd->_view, new_tilt_angle, &new_tilt_angle);
+ maps_view_set_tilt_angle(_gd->_view, new_tilt_angle);
+ }
+
+ if (old_tilt_angle != new_tilt_angle) {
+ /* d. Send event data */
+ maps_coordinates_h c = _gd->_info._start_view_state._center;
+
+ /* Enqueue the detected command */
+ q()->push(construct_gesture_command(MAPS_VIEW_GESTURE_TILT, c, false, .0, false, .0));
+
+ /* Invoke user registered event callback */
+ maps_view_event_data_h ed = _maps_view_create_event_data(MAPS_VIEW_EVENT_GESTURE);
+ if (ed) {
+ _maps_view_event_data_set_gesture_type(ed, MAPS_VIEW_GESTURE_TILT);
+ _maps_view_event_data_set_tilt_angle(ed, new_tilt_angle);
+ _maps_view_event_data_set_position(ed, cur_center._x, cur_center._y);
+ _maps_view_event_data_set_coordinates(ed, c);
+ _maps_view_event_data_set_fingers(ed, 2);
+ _maps_view_invoke_event_callback(_gd->_view, ed);
+ maps_view_event_data_destroy(ed);
+ }
+ }
+
+ return zc.tilt_happend();
+}
/* ---------------------------------------------------------------------------*/
/* VIEW EVENT STREAM */
void on_two_finger_tap();
void on_pan(int finger_no);
void on_panning_finished(int finger_no);
- bool on_zoom(bool zoom_changed, double &zoom_factor);
- bool on_rotate(bool rotation_changed, double &rotation_angle);
- void on_zoom_rotate(bool zoom_changed, double zoom_factor, bool rotation_changed, double rotation_angle);
+ bool on_zoom(bool zoom_changed, bool rotation_changed, double &zoom_factor);
+ bool on_rotate(bool zoom_changed, bool rotation_changed, double &rotation_angle);
+ bool on_two_fingers_pan(bool panning_changed, int *delta_x, int *delta_y);
+ void on_zoom_rotate(bool zoom_changed, double zoom_factor, bool rotation_changed, double rotation_angle, bool panning_changed, int panning_x, int panning_y);
+ bool on_tilt(void);
private:
session::command_queue *q();
void *get_maps();
_zoom_factor = .1;
_rotation_angle = .0;
+ _tilt_angle = .0;
_prev_zoom_factor = .1;
_prev_rotation_angle = .0;
+ _prev_tilt_angle = .0;
+ /*
MAPS_LOGI("%c[%d;%d;%dm"
"central coordinates: RESET"
"%c[%d;%d;%dm",