mirror of
https://github.com/introlab/rtabmap.git
synced 2026-09-02 01:20:25 +08:00
Tango: removed seekbar for FOV(use pinch zoom instead), show UI on single tap instead of swipe down
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
<!-- BEGIN_INCLUDE(manifest) -->
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.introlab.rtabmap"
|
||||
android:versionCode="54"
|
||||
android:versionCode="55"
|
||||
android:versionName="@RTABMAP_VERSION@">
|
||||
|
||||
<uses-permission android:name="android.permission.CAMERA" />
|
||||
|
||||
@@ -63,11 +63,8 @@ GestureCamera::~GestureCamera() { delete cam_parent_transform_; }
|
||||
|
||||
void GestureCamera::OnTouchEvent(int touch_count, TouchEvent event, float x0,
|
||||
float y0, float x1, float y1) {
|
||||
if (camera_type_ == kFirstPerson) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (touch_count == 1) {
|
||||
if (camera_type_!=kFirstPerson && touch_count == 1) {
|
||||
switch (event) {
|
||||
case kTouch0Down: {
|
||||
cam_start_angle_ = cam_cur_angle_;
|
||||
@@ -100,6 +97,7 @@ void GestureCamera::OnTouchEvent(int touch_count, TouchEvent event, float x0,
|
||||
float abs_y = y0 - y1;
|
||||
start_touch_dist_ = std::sqrt(abs_x * abs_x + abs_y * abs_y);
|
||||
cam_start_dist_ = GetPosition().z;
|
||||
cam_start_fov_ = this->getFOV();
|
||||
|
||||
// center touch
|
||||
touch0_start_position_.x = (x0+x1)/2.0f;
|
||||
@@ -111,25 +109,31 @@ void GestureCamera::OnTouchEvent(int touch_count, TouchEvent event, float x0,
|
||||
float abs_y = y0 - y1;
|
||||
float dist = start_touch_dist_ - std::sqrt(abs_x * abs_x + abs_y * abs_y);
|
||||
|
||||
cam_cur_dist_ = tango_gl::util::Clamp(cam_start_dist_ + dist * kZoomSpeed,
|
||||
kCamViewMinDist, kCamViewMaxDist);
|
||||
|
||||
this->SetOrthoMode(camera_type_ == kTopOrtho);
|
||||
if(camera_type_ == kTopOrtho)
|
||||
if(camera_type_ == kFirstPerson)
|
||||
{
|
||||
this->SetOrthoScale(cam_cur_dist_);
|
||||
this->SetFieldOfView(tango_gl::util::Clamp(cam_start_fov_ + dist * kZoomSpeed*10.0f, 45, 90));
|
||||
}
|
||||
else
|
||||
{
|
||||
cam_cur_dist_ = tango_gl::util::Clamp(cam_start_dist_ + dist * kZoomSpeed,
|
||||
kCamViewMinDist, kCamViewMaxDist);
|
||||
|
||||
glm::vec2 touch_center_position((x0+x1)/2.0f, (y0+y1)/2.0f);
|
||||
glm::vec2 offset;
|
||||
offset.x = (touch_center_position.x - touch0_start_position_.x) * kMoveSpeed;
|
||||
offset.y = (touch_center_position.y - touch0_start_position_.y) * kMoveSpeed;
|
||||
touch0_start_position_ = touch_center_position;
|
||||
this->SetOrthoMode(camera_type_ == kTopOrtho);
|
||||
if(camera_type_ == kTopOrtho)
|
||||
{
|
||||
this->SetOrthoScale(cam_cur_dist_);
|
||||
}
|
||||
|
||||
StartCameraToCurrentTransform();
|
||||
glm::vec2 touch_center_position((x0+x1)/2.0f, (y0+y1)/2.0f);
|
||||
glm::vec2 offset;
|
||||
offset.x = (touch_center_position.x - touch0_start_position_.x) * kMoveSpeed;
|
||||
offset.y = (touch_center_position.y - touch0_start_position_.y) * kMoveSpeed;
|
||||
touch0_start_position_ = touch_center_position;
|
||||
|
||||
anchor_offset_ += glm::rotate(cam_parent_transform_->GetRotation(), glm::vec3(-offset.x, offset.y, 0));
|
||||
StartCameraToCurrentTransform();
|
||||
|
||||
anchor_offset_ += glm::rotate(cam_parent_transform_->GetRotation(), glm::vec3(-offset.x, offset.y, 0));
|
||||
}
|
||||
break;
|
||||
}
|
||||
default: { break; }
|
||||
|
||||
@@ -81,6 +81,7 @@ class GestureCamera : public Camera {
|
||||
glm::quat cam_cur_target_rot_;
|
||||
|
||||
float cam_start_dist_;
|
||||
float cam_start_fov_;
|
||||
float cam_cur_dist_;
|
||||
glm::vec3 anchor_offset_;
|
||||
|
||||
|
||||
@@ -118,7 +118,7 @@
|
||||
android:text="@string/close_visualization" />
|
||||
|
||||
<SeekBar
|
||||
android:id="@+id/seekBar_fov"
|
||||
android:id="@+id/seekBar_ortho_cut"
|
||||
android:layout_width="200dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:rotation="270"
|
||||
|
||||
@@ -193,7 +193,7 @@ public class RTABMapActivity extends Activity implements OnClickListener, OnItem
|
||||
private Button mButtonCloseVisualization;
|
||||
private Button mButtonSaveOnDevice;
|
||||
private Button mButtonShareOnSketchfab;
|
||||
private SeekBar mSeekBarFov;
|
||||
private SeekBar mSeekBarOrthoCut;
|
||||
private SeekBar mSeekBarGrid;
|
||||
|
||||
private String mOpenedDatabasePath = "";
|
||||
@@ -309,20 +309,13 @@ public class RTABMapActivity extends Activity implements OnClickListener, OnItem
|
||||
}
|
||||
});
|
||||
|
||||
mSeekBarFov = (SeekBar)findViewById(R.id.seekBar_fov);
|
||||
mSeekBarFov.setMax(45);
|
||||
mSeekBarFov.setProgress(20);
|
||||
mSeekBarFov.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
|
||||
mSeekBarOrthoCut = (SeekBar)findViewById(R.id.seekBar_ortho_cut);
|
||||
mSeekBarOrthoCut.setMax(120);
|
||||
mSeekBarOrthoCut.setProgress(80);
|
||||
mSeekBarOrthoCut.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
|
||||
@Override
|
||||
public void onProgressChanged(SeekBar seekBar, int progressValue, boolean fromUser) {
|
||||
if(mButtonCameraView.getSelectedItemPosition() == 0)
|
||||
{
|
||||
RTABMapLib.setFOV((float)progressValue+45.0f);
|
||||
}
|
||||
else if(mButtonCameraView.getSelectedItemPosition() == 3)
|
||||
{
|
||||
RTABMapLib.setOrthoCropFactor((float)(120-progressValue)/20.0f - 3.0f);
|
||||
}
|
||||
RTABMapLib.setOrthoCropFactor((float)(120-progressValue)/20.0f - 3.0f);
|
||||
resetNoTouchTimer();
|
||||
}
|
||||
|
||||
@@ -743,17 +736,12 @@ public class RTABMapActivity extends Activity implements OnClickListener, OnItem
|
||||
|
||||
RTABMapLib.setCamera(type);
|
||||
mButtonCameraView.setSelection(type, true);
|
||||
mSeekBarFov.setVisibility(type!=0 && type!=3?View.INVISIBLE:View.VISIBLE);
|
||||
mSeekBarOrthoCut.setVisibility(type!=3?View.INVISIBLE:View.VISIBLE);
|
||||
mSeekBarGrid.setVisibility(mSeekBarGrid.isEnabled() && type==3?View.VISIBLE:View.INVISIBLE);
|
||||
if(type==0)
|
||||
{
|
||||
mSeekBarFov.setMax(45);
|
||||
mSeekBarFov.setProgress(20);
|
||||
}
|
||||
if(type==3)
|
||||
{
|
||||
mSeekBarFov.setMax(120);
|
||||
mSeekBarFov.setProgress(80);
|
||||
mSeekBarOrthoCut.setMax(120);
|
||||
mSeekBarOrthoCut.setProgress(80);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -761,6 +749,9 @@ public class RTABMapActivity extends Activity implements OnClickListener, OnItem
|
||||
public void onClick(View v) {
|
||||
// Handle button clicks.
|
||||
switch (v.getId()) {
|
||||
case R.id.gl_surface_view:
|
||||
|
||||
break;
|
||||
case R.id.pause_button:
|
||||
pauseMapping();
|
||||
break;
|
||||
@@ -830,22 +821,17 @@ public class RTABMapActivity extends Activity implements OnClickListener, OnItem
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean onFling(
|
||||
MotionEvent e1,
|
||||
MotionEvent e2,
|
||||
float velocityX,
|
||||
float velocityY) {
|
||||
if(!DISABLE_LOG) Log.i(TAG, String.format("onFling velocityY=%f", velocityY));
|
||||
if(velocityY < -1000)
|
||||
{
|
||||
notouchHandler.removeCallbacks(notouchCallback);
|
||||
notouchHandler.postDelayed(notouchCallback, 0);
|
||||
}
|
||||
else if(velocityY > 1000)
|
||||
{
|
||||
resetNoTouchTimer(true);
|
||||
}
|
||||
|
||||
public boolean onSingleTapConfirmed(MotionEvent event) {
|
||||
if(!DISABLE_LOG) Log.i(TAG, "onSingleTapConfirmed");
|
||||
if(mHudVisible)
|
||||
{
|
||||
notouchHandler.removeCallbacks(notouchCallback);
|
||||
notouchHandler.postDelayed(notouchCallback, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
resetNoTouchTimer(true);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1484,7 +1470,7 @@ public class RTABMapActivity extends Activity implements OnClickListener, OnItem
|
||||
}
|
||||
mButtonCameraView.setVisibility(mHudVisible?View.VISIBLE:View.INVISIBLE);
|
||||
mButtonBackfaceShown.setVisibility(mHudVisible && (mItemRenderingMesh.isChecked() || mItemRenderingTextureMesh.isChecked())?View.VISIBLE:View.INVISIBLE);
|
||||
mSeekBarFov.setVisibility(mHudVisible && (mButtonCameraView.getSelectedItemPosition() == 0 || mButtonCameraView.getSelectedItemPosition() == 3)?View.VISIBLE:View.INVISIBLE);
|
||||
mSeekBarOrthoCut.setVisibility(mHudVisible && mButtonCameraView.getSelectedItemPosition() == 3?View.VISIBLE:View.INVISIBLE);
|
||||
mSeekBarGrid.setVisibility(mHudVisible && mSeekBarGrid.isEnabled() && mButtonCameraView.getSelectedItemPosition() == 3?View.VISIBLE:View.INVISIBLE);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user