Merge tizen branch into devel 34/97534/3
authorchanywa <cbible.kim@samsung.com>
Mon, 14 Nov 2016 11:08:29 +0000 (20:08 +0900)
committerchanywa <cbible.kim@samsung.com>
Wed, 16 Nov 2016 11:58:11 +0000 (20:58 +0900)
Change-Id: I4977d194d6db1660cbd58a3ba41667fc3794e0f8

13 files changed:
1  2 
include/maps_view_plugin.h
src/api/maps_service.cpp
src/api/maps_view.cpp
src/api/maps_view_object.cpp
src/plugin/module.cpp
src/session/command.h
src/session/commands.cpp
src/session/commands.h
src/view/gesture_detector_statemachine.cpp
src/view/gesture_detector_statemachine.h
src/view/gesture_processor.cpp
src/view/gesture_processor.h
src/view/runtime_data.cpp

index 1f5c37e642069a6af92e3bb2e81999832176a119,c6bf17f38409e4281afd6a32cc187bf73ffd605a..8cec74fb58ca69168935623f70f17f0315909dc3
@@@ -132,27 -132,8 +132,27 @@@ int maps_view_get_maps_plugin_view_hand
   *
   * @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
Simple merge
Simple merge
index b6857b09edf4903009b4268ee40ae78b31c6dd9a,ae24ea258b04cec1f6d28088a2f70f07347bed42..96260d9890c1f3a5f8c477ca7226fe05302ee09a
@@@ -627,37 -629,6 +629,37 @@@ EXPORT_API int maps_view_object_polylin
        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)
  {
Simple merge
Simple merge
index 2b64a0b8a49fd2f42ae5e727cefd1bd8becda55b,40a8f61b8c697a7b6d7c427ab7294964a3dd139e..731e7a04b401155fee3477c7121409ade692809a
@@@ -1613,39 -1553,3 +1651,38 @@@ void session::command_view_zoom_rotate:
                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();
 +      }
 +}
Simple merge
index f538902838a3631f8a32c677741f2b9078fc72f7,322c5e50002e170e325ad4c2ab8cf7430acd8c95..585190d88898b65c42fcbf59d20481038fcd5c59
@@@ -24,7 -24,7 +24,8 @@@ view::gesture_detector_statemachine::ge
        , _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;
@@@ -460,7 -460,7 +461,8 @@@ void view::gesture_detector_statemachin
                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);
                }
  
@@@ -679,39 -679,35 +682,45 @@@ void view::gesture_detector_statemachin
  {
        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;
index 772eae6c75be75333f5e022346035054dcf2fdda,24e33781c480e684c8c6f2b51caf6d416f43f2ff..fd405cac45cfb5a9a855f905656b3c393f3b3690
@@@ -91,7 -91,7 +91,8 @@@ namespace vie
                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);
index 46f44b7441764a8638e26e0afa04b130917632af,3100dd12a075c53171452b5fc716d05e66ed13f7..44c8af2ff1c3eb64a45069ecf4e85557bbd9b8bf
@@@ -99,17 -107,9 +111,17 @@@ view::zoom_calculator::zoom_calculator(
                _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;
 +      }
  }
  
  
@@@ -710,115 -691,8 +709,75 @@@ void view::gesture_processor::on_zoom_r
                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, &center_x, &center_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                                                       */
index 351a1660eca849cdc20066c6a63f21d1eb3eda92,594c04b9ddccf6388ecbbc6cc7c533cc143a524c..6cb46d1a08a08398be1de6de63b756333eb655f8
@@@ -110,10 -101,10 +110,11 @@@ namespace vie
                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();
index 6345e0aa50c898361e9fd9e3e1ffe4fe247c5eb4,bbc26f4ba4a20972a11c1ba543cba3ff04321f7a..cb46bdeed8c0aca9572624263878ddcb17dbf093
@@@ -130,11 -127,10 +130,12 @@@ void view::map_state::reset(
  
        _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",