ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
MatrixInteractorLogic.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 
10 #include <ecvBBox.h>
11 
13 
14 namespace cloudViewer {
15 namespace visualization {
16 namespace rendering {
17 
22 public:
23  virtual ~MatrixInteractorLogic();
24 
25  void SetViewSize(int width, int height);
26  int GetViewWidth() const;
27  int GetViewHeight() const;
28 
29  const ccBBox& GetBoundingBox() const;
30  virtual void SetBoundingBox(const ccBBox& bounds);
31 
32  Eigen::Vector3f GetCenterOfRotation() const;
33 
34  void SetMouseDownInfo(const Camera::Transform& matrix,
35  const Eigen::Vector3f& center_of_rotation);
36 
37  const Camera::Transform& GetMatrix() const;
38 
43  virtual void Rotate(int dx, int dy);
44 
47  virtual void RotateWorld(int dx,
48  int dy,
49  const Eigen::Vector3f& x_axis,
50  const Eigen::Vector3f& y_axis);
51 
53  virtual void RotateZ(int dx, int dy);
54 
55  virtual void RotateZWorld(int dx, int dy, const Eigen::Vector3f& forward);
56 
57  enum class DragType { MOUSE, WHEEL, TWO_FINGER };
58 
61  virtual void Dolly(float dy, DragType drag_type);
62  virtual void Dolly(float z_dist, Camera::Transform matrix);
63 
64 private:
65  Camera::Transform matrix_;
66 
67 protected:
68  int view_width_ = 1;
69  int view_height_ = 1;
70  double model_size_ = 20.0;
72  Eigen::Vector3f center_of_rotation_;
73 
76 
77  void SetMatrix(const Camera::Transform& matrix);
78  float CalcRotateRadians(int dx, int dy);
79  float CalcRotateZRadians(int dx, int dy);
80  float CalcDollyDist(float dy,
81  DragType drag_type,
82  const Camera::Transform& matrix);
83 };
84 
85 } // namespace rendering
86 } // namespace visualization
87 } // namespace cloudViewer
int width
int height
Bounding box structure.
Definition: ecvBBox.h:25
Eigen::Transform< float, 3, Eigen::Affine > Transform
Definition: Camera.h:29
void SetMouseDownInfo(const Camera::Transform &matrix, const Eigen::Vector3f &center_of_rotation)
virtual void RotateZ(int dx, int dy)
Rotates about the forward axis of the matrix.
float CalcDollyDist(float dy, DragType drag_type, const Camera::Transform &matrix)
virtual void RotateZWorld(int dx, int dy, const Eigen::Vector3f &forward)
virtual void RotateWorld(int dx, int dy, const Eigen::Vector3f &x_axis, const Eigen::Vector3f &y_axis)
Generic file read and write utility for python interface.