Fixed bugs that the center of map works wrong when two-fingers are acossed over bound... 94/70994/2 submit/tizen/20160524.001307
authorchanywa <cbible.kim@samsung.com>
Mon, 23 May 2016 13:55:03 +0000 (22:55 +0900)
committerchanywa <cbible.kim@samsung.com>
Mon, 23 May 2016 22:11:07 +0000 (07:11 +0900)
Change-Id: Ic2567756b5d05daa2fb7f41c9fdcd0924a62517b

src/view/inertial_camera.cpp
src/view/inertial_camera.h
src/view/inertial_gesture.cpp

index a9e3486..4babe4c 100644 (file)
@@ -162,6 +162,45 @@ double view::inertial_camera::calc_next_step(const double &start,
        return new_pos;
 }
 
+double view::inertial_camera::calc_next_step_lon(const double &start,
+                                            const double &finish,
+                                            const double step_ratio) const
+{
+       if(start == finish)
+               return start;
+
+       double _f = finish;
+       double _s = start;
+       if (_f < 0) _f += 360;
+       if (_s < 0) _s += 360;
+
+       double gap, gap1, gap2;
+       if (_f > _s) {
+               gap1 = _f - _s;
+               gap2 = (360 - _f) + _s;
+               if (gap1 < gap2)
+                       gap = gap1;
+               else
+                       gap = gap2 * -1;
+       } else {
+               gap1 = _s - _f;
+               gap2 = (360 - _s) + _f;
+               if (gap1 < gap2)
+                       gap = gap1 * -1;
+               else
+                       gap = gap2;
+       }
+
+       double step = gap * step_ratio;
+       double new_pos = start + step;
+       if (new_pos > 180)
+               new_pos -= 360;
+       else if (new_pos < -180)
+               new_pos += 360;
+
+       return new_pos;
+}
+
 bool view::inertial_camera::next_transition_step()
 {
        if(!_view)
@@ -180,7 +219,7 @@ bool view::inertial_camera::next_transition_step()
        double next_lat = calc_next_step(prev_lat, target_lat, .15);
        if (next_lat != prev_lat) transiting = true;
 
-       double next_lon = calc_next_step(prev_lon, target_lon, .15);
+       double next_lon = calc_next_step_lon(prev_lon, target_lon, .15);
        if (next_lon != prev_lon) transiting = true;
 
        if (transiting)
index a412f4d..29ef53a 100644 (file)
@@ -68,6 +68,9 @@ namespace view
                double calc_next_step(const double &start,
                                     const double &finish,
                                     const double step_ratio) const;
+               double calc_next_step_lon(const double &start,
+                                    const double &finish,
+                                    const double step_ratio) const;
                void set_cur_state();
        };
 };
index e036902..09e5092 100644 (file)
@@ -72,12 +72,10 @@ void view::inertial_gesture::tap(int finger_no, const touch_point &tp)
                        if(!transiting_part[i])
                                continue;
 
-                       unsigned int timestamp = _last[i]._timestamp
-                               + get_transition_time(i);
+                       unsigned int timestamp = _last[i]._timestamp + get_transition_time(i);
 
                        const touch_point tp(_cur_x[i], _cur_y[i], timestamp);
-                       MAPS_LOGI("TRANSITION finger %d up FAKE BRAKE time: %d",
-                                 i, tp._timestamp);
+                       MAPS_LOGI("TRANSITION finger %d up FAKE BRAKE time: %d", i, tp._timestamp);
                        _d->up(i, tp);
                }
 
@@ -118,8 +116,7 @@ void view::inertial_gesture::up(int finger_no, const touch_point &tp)
 
        const int delta_x = _last[finger_no]._x - _prev[finger_no]._x;
        const int delta_y = _last[finger_no]._y - _prev[finger_no]._y;
-       unsigned int dt =
-               _last[finger_no]._timestamp - _prev[finger_no]._timestamp;
+       unsigned int dt = _last[finger_no]._timestamp - _prev[finger_no]._timestamp;
 
        int trajectory = get_trajectory_effective_length(_down[finger_no], tp);
        MAPS_LOGD("trajectory=%d", trajectory);
@@ -153,37 +150,25 @@ bool view::inertial_gesture::next_transition_step()
                transiting_part[i] = false;
 
                if(ABS(_derivative_x[i]) > __ACCURACY) {
-                       _cur_x[i] = get_next_point(_cur_x[i],
-                                                  _derivative_x[i],
-                                                  _dt[i]);
-                       _derivative_x[i] = get_next_derivative(_derivative_x[i],
-                                                              _dt[i]);
-                       transiting_part[i] |=
-                               ABS(_derivative_x[i]) > __ACCURACY;
+                       _cur_x[i] = get_next_point(_cur_x[i], _derivative_x[i], _dt[i]);
+                       _derivative_x[i] = get_next_derivative(_derivative_x[i], _dt[i]);
+                       transiting_part[i] |= ABS(_derivative_x[i]) > __ACCURACY;
                }
 
                if(ABS(_derivative_y[i]) > __ACCURACY) {
-                       _cur_y[i] = get_next_point(_cur_y[i],
-                                                  _derivative_y[i],
-                                                  _dt[i]);
-                       _derivative_y[i] =
-                               get_next_derivative(_derivative_y[i],
-                                                   _dt[i]);
-                       transiting_part[i] |=
-                               ABS(_derivative_y[i]) > __ACCURACY;
+                       _cur_y[i] = get_next_point(_cur_y[i], _derivative_y[i], _dt[i]);
+                       _derivative_y[i] = get_next_derivative(_derivative_y[i], _dt[i]);
+                       transiting_part[i] |= ABS(_derivative_y[i]) > __ACCURACY;
                }
 
-               unsigned int timestamp = _last[i]._timestamp
-                       + get_transition_time(i);
+               unsigned int timestamp = _last[i]._timestamp + get_transition_time(i);
 
                const touch_point tp(_cur_x[i], _cur_y[i], timestamp);
                if(transiting_part[i]) {
-                       MAPS_LOGI("TRANSITION finger %d move FAKE time: %d",
-                                 i, tp._timestamp);
+                       MAPS_LOGI("TRANSITION finger %d move FAKE time: %d", i, tp._timestamp);
                        _d->move(i, tp);
                } else {
-                       MAPS_LOGI("TRANSITION finger %d up FAKE time: %d",
-                                 i, tp._timestamp);
+                       MAPS_LOGI("TRANSITION finger %d up FAKE time: %d", i, tp._timestamp);
                        _d->up(i, tp);
                }