Open3D (C++ API)
ViewControlWithCustomAnimation.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - Open3D: www.open3d.org -
3 // ----------------------------------------------------------------------------
4 // The MIT License (MIT)
5 //
6 // Copyright (c) 2018 www.open3d.org
7 //
8 // Permission is hereby granted, free of charge, to any person obtaining a copy
9 // of this software and associated documentation files (the "Software"), to deal
10 // in the Software without restriction, including without limitation the rights
11 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 // copies of the Software, and to permit persons to whom the Software is
13 // furnished to do so, subject to the following conditions:
14 //
15 // The above copyright notice and this permission notice shall be included in
16 // all copies or substantial portions of the Software.
17 //
18 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24 // IN THE SOFTWARE.
25 // ----------------------------------------------------------------------------
26 
27 #pragma once
28 
32 
33 namespace open3d {
34 namespace visualization {
35 
37 public:
39  FreeMode = 0,
41  PlayMode = 2,
42  };
43 
44 public:
46 
47  void Reset() override;
48  void ChangeFieldOfView(double step) override;
49  void Scale(double scale) override;
50  void Rotate(double x, double y, double xo, double yo) override;
51  void Translate(double x, double y, double xo, double yo) override;
52 
54  void AddKeyFrame();
55  void UpdateKeyFrame();
56  void DeleteKeyFrame();
57  void AddSpinKeyFrames(int num_of_key_frames = 20);
59  size_t NumOfKeyFrames() const {
60  return view_trajectory_.view_status_.size();
61  }
62  size_t NumOfFrames() const { return view_trajectory_.NumOfFrames(); }
64  if (animation_mode_ == AnimationMode::FreeMode) {
66  }
67  }
68  void ChangeTrajectoryInterval(int change) {
69  if (animation_mode_ == AnimationMode::FreeMode) {
71  }
72  }
74  std::string GetStatusString() const;
75  void Step(double change);
76  void GoToFirst();
77  void GoToLast();
78  bool CaptureTrajectory(const std::string &filename = "");
79  bool LoadTrajectoryFromJsonFile(const std::string &filename);
81  const camera::PinholeCameraTrajectory &camera_trajectory);
82  bool IsPreviewing() {
83  return animation_mode_ == AnimationMode::PreviewMode;
84  }
85  bool IsPlaying() { return animation_mode_ == AnimationMode::PlayMode; }
86  bool IsPlayingEnd(size_t num) {
87  return (IsPlaying() && num >= view_trajectory_.NumOfFrames());
88  }
89  bool IsValidPinholeCameraTrajectory() const;
90 
91 protected:
92  size_t CurrentFrame() const { return (size_t)round(current_frame_); }
93  size_t CurrentKeyframe() const { return (size_t)round(current_keyframe_); }
94  double RegularizeFrameIndex(double current_frame,
95  size_t num_of_frames,
96  bool is_loop);
98 
99 protected:
100  AnimationMode animation_mode_ = AnimationMode::FreeMode;
102  double current_frame_ = 0.0;
103  double current_keyframe_ = 0.0;
104 };
105 
106 } // namespace visualization
107 } // namespace open3d
AnimationMode
Definition: ViewControlWithCustomAnimation.h:38
bool IsValidPinholeCameraTrajectory() const
Definition: ViewControlWithCustomAnimation.cpp:288
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:676
void SetViewControlFromTrajectory()
Definition: ViewControlWithCustomAnimation.cpp:328
Definition: ViewTrajectory.h:39
void AddSpinKeyFrames(int num_of_key_frames=20)
Definition: ViewControlWithCustomAnimation.cpp:143
double current_frame_
Definition: ViewControlWithCustomAnimation.h:102
bool IsPlayingEnd(size_t num)
Definition: ViewControlWithCustomAnimation.h:86
void ChangeTrajectoryInterval(int change)
Definition: ViewControlWithCustomAnimation.h:68
void ChangeInterval(int change)
Definition: ViewTrajectory.h:61
bool is_loop_
Definition: ViewTrajectory.h:90
void ClearAllKeyFrames()
Definition: ViewControlWithCustomAnimation.h:58
std::vector< ViewParameters > view_status_
Definition: ViewTrajectory.h:89
size_t NumOfKeyFrames() const
Definition: ViewControlWithCustomAnimation.h:59
void Reset() override
Definition: ViewControlWithCustomAnimation.cpp:35
void ChangeFieldOfView(double step) override
Definition: ViewControlWithCustomAnimation.cpp:41
Definition: ViewControlWithCustomAnimation.h:41
virtual ~ViewControlWithCustomAnimation()
Definition: ViewControlWithCustomAnimation.h:45
View controller for visualizer.
Definition: ViewControl.h:41
Definition: ViewControlWithCustomAnimation.h:40
int GetTrajectoryInterval() const
Definition: ViewControlWithCustomAnimation.h:73
Definition: PinholeCameraTrajectory.h:40
AnimationMode animation_mode_
Definition: ViewControlWithCustomAnimation.h:100
void AddKeyFrame()
Definition: ViewControlWithCustomAnimation.cpp:105
bool CaptureTrajectory(const std::string &filename="")
Definition: ViewControlWithCustomAnimation.cpp:233
std::string GetStatusString() const
Definition: ViewControlWithCustomAnimation.cpp:154
void Scale(double scale) override
Definition: ViewControlWithCustomAnimation.cpp:63
bool LoadTrajectoryFromCameraTrajectory(const camera::PinholeCameraTrajectory &camera_trajectory)
Definition: ViewControlWithCustomAnimation.cpp:260
double RegularizeFrameIndex(double current_frame, size_t num_of_frames, bool is_loop)
Definition: ViewControlWithCustomAnimation.cpp:304
void Rotate(double x, double y, double xo, double yo) override
Function to process rotation.
Definition: ViewControlWithCustomAnimation.cpp:69
ViewTrajectory view_trajectory_
Definition: ViewControlWithCustomAnimation.h:101
void GoToLast()
Definition: ViewControlWithCustomAnimation.cpp:221
bool LoadTrajectoryFromJsonFile(const std::string &filename)
Definition: ViewControlWithCustomAnimation.cpp:248
int interval_
Definition: ViewTrajectory.h:91
void GoToFirst()
Definition: ViewControlWithCustomAnimation.cpp:209
Definition: ViewControlWithCustomAnimation.h:36
double current_keyframe_
Definition: ViewControlWithCustomAnimation.h:103
Definition: Open3DViewer.h:29
void UpdateKeyFrame()
Definition: ViewControlWithCustomAnimation.cpp:122
size_t CurrentFrame() const
Definition: ViewControlWithCustomAnimation.h:92
void Step(double change)
Definition: ViewControlWithCustomAnimation.cpp:191
size_t NumOfFrames() const
Definition: ViewTrajectory.h:68
void Translate(double x, double y, double xo, double yo) override
Function to process translation.
Definition: ViewControlWithCustomAnimation.cpp:78
void ToggleTrajectoryLoop()
Definition: ViewControlWithCustomAnimation.h:63
size_t NumOfFrames() const
Definition: ViewControlWithCustomAnimation.h:62
bool IsPreviewing()
Definition: ViewControlWithCustomAnimation.h:82
void DeleteKeyFrame()
Definition: ViewControlWithCustomAnimation.cpp:130
bool IsPlaying()
Definition: ViewControlWithCustomAnimation.h:85
void SetAnimationMode(AnimationMode mode)
Definition: ViewControlWithCustomAnimation.cpp:87
size_t CurrentKeyframe() const
Definition: ViewControlWithCustomAnimation.h:93
Definition: ViewControlWithCustomAnimation.h:39