ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
ViewControlWithCustomAnimation.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - CloudViewer: www.cloudViewer.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2024 www.cloudViewer.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
7 
8 #pragma once
9 
13 
14 namespace cloudViewer {
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 cloudViewer
std::string filename
bool LoadTrajectoryFromCameraTrajectory(const camera::PinholeCameraTrajectory &camera_trajectory)
void Rotate(double x, double y, double xo, double yo) override
Function to process rotation.
double RegularizeFrameIndex(double current_frame, size_t num_of_frames, bool is_loop)
void Translate(double x, double y, double xo, double yo) override
Function to process translation.
View controller for visualizer.
Definition: ViewControl.h:25
std::vector< ViewParameters > view_status_
Generic file read and write utility for python interface.