Open3D (C++ API)  0.18.0+5c982c7
ViewControlWithCustomAnimation.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - Open3D: www.open3d.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2023 www.open3d.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
7 
8 #pragma once
9 
13 
14 namespace open3d {
15 namespace visualization {
16 
18 public:
20  FreeMode = 0,
22  PlayMode = 2,
23  };
24 
25 public:
27 
28  void Reset() override;
29  void ChangeFieldOfView(double step) override;
30  void Scale(double scale) override;
31  void Rotate(double x, double y, double xo, double yo) override;
32  void Translate(double x, double y, double xo, double yo) override;
33 
35  void AddKeyFrame();
36  void UpdateKeyFrame();
37  void DeleteKeyFrame();
38  void AddSpinKeyFrames(int num_of_key_frames = 20);
40  size_t NumOfKeyFrames() const {
41  return view_trajectory_.view_status_.size();
42  }
43  size_t NumOfFrames() const { return view_trajectory_.NumOfFrames(); }
45  if (animation_mode_ == AnimationMode::FreeMode) {
47  }
48  }
49  void ChangeTrajectoryInterval(int change) {
50  if (animation_mode_ == AnimationMode::FreeMode) {
52  }
53  }
55  std::string GetStatusString() const;
56  void Step(double change);
57  void GoToFirst();
58  void GoToLast();
59  bool CaptureTrajectory(const std::string &filename = "");
60  bool LoadTrajectoryFromJsonFile(const std::string &filename);
62  const camera::PinholeCameraTrajectory &camera_trajectory);
63  bool IsPreviewing() {
64  return animation_mode_ == AnimationMode::PreviewMode;
65  }
66  bool IsPlaying() { return animation_mode_ == AnimationMode::PlayMode; }
67  bool IsPlayingEnd(size_t num) {
68  return (IsPlaying() && num >= view_trajectory_.NumOfFrames());
69  }
70  bool IsValidPinholeCameraTrajectory() const;
71 
72 protected:
73  size_t CurrentFrame() const { return (size_t)round(current_frame_); }
74  size_t CurrentKeyframe() const { return (size_t)round(current_keyframe_); }
75  double RegularizeFrameIndex(double current_frame,
76  size_t num_of_frames,
77  bool is_loop);
79 
80 protected:
81  AnimationMode animation_mode_ = AnimationMode::FreeMode;
83  double current_frame_ = 0.0;
84  double current_keyframe_ = 0.0;
85 };
86 
87 } // namespace visualization
88 } // namespace open3d
Definition: PinholeCameraTrajectory.h:21
View controller for visualizer.
Definition: ViewControl.h:23
Definition: ViewControlWithCustomAnimation.h:17
bool IsPlayingEnd(size_t num)
Definition: ViewControlWithCustomAnimation.h:67
bool IsPlaying()
Definition: ViewControlWithCustomAnimation.h:66
void Scale(double scale) override
Definition: ViewControlWithCustomAnimation.cpp:45
void GoToLast()
Definition: ViewControlWithCustomAnimation.cpp:203
void Step(double change)
Definition: ViewControlWithCustomAnimation.cpp:173
ViewTrajectory view_trajectory_
Definition: ViewControlWithCustomAnimation.h:82
bool IsValidPinholeCameraTrajectory() const
Definition: ViewControlWithCustomAnimation.cpp:270
size_t CurrentFrame() const
Definition: ViewControlWithCustomAnimation.h:73
size_t NumOfKeyFrames() const
Definition: ViewControlWithCustomAnimation.h:40
size_t CurrentKeyframe() const
Definition: ViewControlWithCustomAnimation.h:74
double RegularizeFrameIndex(double current_frame, size_t num_of_frames, bool is_loop)
Definition: ViewControlWithCustomAnimation.cpp:286
double current_keyframe_
Definition: ViewControlWithCustomAnimation.h:84
bool CaptureTrajectory(const std::string &filename="")
Definition: ViewControlWithCustomAnimation.cpp:215
bool LoadTrajectoryFromJsonFile(const std::string &filename)
Definition: ViewControlWithCustomAnimation.cpp:230
void SetAnimationMode(AnimationMode mode)
Definition: ViewControlWithCustomAnimation.cpp:69
void GoToFirst()
Definition: ViewControlWithCustomAnimation.cpp:191
double current_frame_
Definition: ViewControlWithCustomAnimation.h:83
virtual ~ViewControlWithCustomAnimation()
Definition: ViewControlWithCustomAnimation.h:26
void AddSpinKeyFrames(int num_of_key_frames=20)
Definition: ViewControlWithCustomAnimation.cpp:125
void Reset() override
Definition: ViewControlWithCustomAnimation.cpp:17
void UpdateKeyFrame()
Definition: ViewControlWithCustomAnimation.cpp:104
AnimationMode animation_mode_
Definition: ViewControlWithCustomAnimation.h:81
void ChangeTrajectoryInterval(int change)
Definition: ViewControlWithCustomAnimation.h:49
void ChangeFieldOfView(double step) override
Definition: ViewControlWithCustomAnimation.cpp:23
std::string GetStatusString() const
Definition: ViewControlWithCustomAnimation.cpp:136
void ToggleTrajectoryLoop()
Definition: ViewControlWithCustomAnimation.h:44
void DeleteKeyFrame()
Definition: ViewControlWithCustomAnimation.cpp:112
size_t NumOfFrames() const
Definition: ViewControlWithCustomAnimation.h:43
AnimationMode
Definition: ViewControlWithCustomAnimation.h:19
@ PlayMode
Definition: ViewControlWithCustomAnimation.h:22
@ PreviewMode
Definition: ViewControlWithCustomAnimation.h:21
@ FreeMode
Definition: ViewControlWithCustomAnimation.h:20
bool LoadTrajectoryFromCameraTrajectory(const camera::PinholeCameraTrajectory &camera_trajectory)
Definition: ViewControlWithCustomAnimation.cpp:242
void AddKeyFrame()
Definition: ViewControlWithCustomAnimation.cpp:87
bool IsPreviewing()
Definition: ViewControlWithCustomAnimation.h:63
void ClearAllKeyFrames()
Definition: ViewControlWithCustomAnimation.h:39
void SetViewControlFromTrajectory()
Definition: ViewControlWithCustomAnimation.cpp:310
void Rotate(double x, double y, double xo, double yo) override
Function to process rotation.
Definition: ViewControlWithCustomAnimation.cpp:51
void Translate(double x, double y, double xo, double yo) override
Function to process translation.
Definition: ViewControlWithCustomAnimation.cpp:60
int GetTrajectoryInterval() const
Definition: ViewControlWithCustomAnimation.h:54
Definition: ViewTrajectory.h:20
bool is_loop_
Definition: ViewTrajectory.h:71
int interval_
Definition: ViewTrajectory.h:72
void ChangeInterval(int change)
Definition: ViewTrajectory.h:42
std::vector< ViewParameters > view_status_
Definition: ViewTrajectory.h:70
size_t NumOfFrames() const
Definition: ViewTrajectory.h:49
const char const char value recording_handle imu_sample recording_handle uint8_t size_t data_size k4a_record_configuration_t config target_format k4a_capture_t capture_handle k4a_imu_sample_t imu_sample playback_handle k4a_logging_message_cb_t void min_level device_handle k4a_imu_sample_t timeout_in_ms capture_handle capture_handle capture_handle image_handle temperature_c k4a_image_t image_handle uint8_t image_handle image_handle image_handle image_handle image_handle timestamp_usec white_balance image_handle k4a_device_configuration_t config device_handle char size_t serial_number_size bool int32_t int32_t int32_t int32_t k4a_color_control_mode_t default_mode mode
Definition: K4aPlugin.cpp:678
Definition: PinholeCameraIntrinsic.cpp:16