Open3D (C++ API)  0.17.0
MatrixInteractorLogic.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 
12 
13 namespace open3d {
14 namespace visualization {
15 namespace rendering {
16 
21 public:
22  virtual ~MatrixInteractorLogic();
23 
24  void SetViewSize(int width, int height);
25  int GetViewWidth() const;
26  int GetViewHeight() const;
27 
29  virtual void SetBoundingBox(const geometry::AxisAlignedBoundingBox& bounds);
30 
31  Eigen::Vector3f GetCenterOfRotation() const;
32 
33  void SetMouseDownInfo(const Camera::Transform& matrix,
34  const Eigen::Vector3f& center_of_rotation);
35 
36  const Camera::Transform& GetMatrix() const;
37 
42  virtual void Rotate(int dx, int dy);
43 
46  virtual void RotateWorld(int dx,
47  int dy,
48  const Eigen::Vector3f& x_axis,
49  const Eigen::Vector3f& y_axis);
50 
52  virtual void RotateZ(int dx, int dy);
53 
54  virtual void RotateZWorld(int dx, int dy, const Eigen::Vector3f& forward);
55 
56  enum class DragType { MOUSE, WHEEL, TWO_FINGER };
57 
60  virtual void Dolly(float dy, DragType drag_type);
61  virtual void Dolly(float z_dist, Camera::Transform matrix);
62 
63 private:
64  Camera::Transform matrix_;
65 
66 protected:
67  int view_width_ = 1;
68  int view_height_ = 1;
69  double model_size_ = 20.0;
71  Eigen::Vector3f center_of_rotation_;
72 
75 
76  void SetMatrix(const Camera::Transform& matrix);
77  float CalcRotateRadians(int dx, int dy);
78  float CalcRotateZRadians(int dx, int dy);
79  float CalcDollyDist(float dy,
80  DragType drag_type,
81  const Camera::Transform& matrix);
82 };
83 
84 } // namespace rendering
85 } // namespace visualization
86 } // namespace open3d
A bounding box that is aligned along the coordinate axes.
Definition: BoundingVolume.h:159
Eigen::Transform< float, 3, Eigen::Affine > Transform
Definition: Camera.h:25
Definition: MatrixInteractorLogic.h:20
virtual void RotateZ(int dx, int dy)
Rotates about the forward axis of the matrix.
Definition: MatrixInteractorLogic.cpp:135
double model_size_
Definition: MatrixInteractorLogic.h:69
const Camera::Transform & GetMatrix() const
Definition: MatrixInteractorLogic.cpp:54
virtual void RotateWorld(int dx, int dy, const Eigen::Vector3f &x_axis, const Eigen::Vector3f &y_axis)
Definition: MatrixInteractorLogic.cpp:103
float CalcRotateRadians(int dx, int dy)
Definition: MatrixInteractorLogic.cpp:130
Eigen::Vector3f center_of_rotation_at_mouse_down_
Definition: MatrixInteractorLogic.h:74
virtual void RotateZWorld(int dx, int dy, const Eigen::Vector3f &forward)
Definition: MatrixInteractorLogic.cpp:146
Camera::Transform matrix_at_mouse_down_
Definition: MatrixInteractorLogic.h:73
virtual void SetBoundingBox(const geometry::AxisAlignedBoundingBox &bounds)
Definition: MatrixInteractorLogic.cpp:30
const geometry::AxisAlignedBoundingBox & GetBoundingBox() const
Definition: MatrixInteractorLogic.cpp:25
float CalcDollyDist(float dy, DragType drag_type, const Camera::Transform &matrix)
Definition: MatrixInteractorLogic.cpp:191
int view_width_
Definition: MatrixInteractorLogic.h:67
geometry::AxisAlignedBoundingBox model_bounds_
Definition: MatrixInteractorLogic.h:70
virtual void Rotate(int dx, int dy)
Definition: MatrixInteractorLogic.cpp:58
DragType
Definition: MatrixInteractorLogic.h:56
int GetViewWidth() const
Definition: MatrixInteractorLogic.cpp:21
int view_height_
Definition: MatrixInteractorLogic.h:68
Eigen::Vector3f GetCenterOfRotation() const
Definition: MatrixInteractorLogic.cpp:36
Eigen::Vector3f center_of_rotation_
Definition: MatrixInteractorLogic.h:71
float CalcRotateZRadians(int dx, int dy)
Definition: MatrixInteractorLogic.cpp:159
int GetViewHeight() const
Definition: MatrixInteractorLogic.cpp:23
void SetMouseDownInfo(const Camera::Transform &matrix, const Eigen::Vector3f &center_of_rotation)
Definition: MatrixInteractorLogic.cpp:40
virtual ~MatrixInteractorLogic()
Definition: MatrixInteractorLogic.cpp:14
void SetMatrix(const Camera::Transform &matrix)
Definition: MatrixInteractorLogic.cpp:50
void SetViewSize(int width, int height)
Definition: MatrixInteractorLogic.cpp:16
virtual void Dolly(float dy, DragType drag_type)
Definition: MatrixInteractorLogic.cpp:165
int width
Definition: FilePCD.cpp:52
int height
Definition: FilePCD.cpp:53
Definition: PinholeCameraIntrinsic.cpp:16