Loading [MathJax]/extensions/TeX/AMSsymbols.js
Open3D (C++ API)  0.14.1
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
MatrixInteractorLogic.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-2021 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 
31 
32 namespace open3d {
33 namespace visualization {
34 namespace rendering {
35 
40 public:
41  virtual ~MatrixInteractorLogic();
42 
43  void SetViewSize(int width, int height);
44  int GetViewWidth() const;
45  int GetViewHeight() const;
46 
48  virtual void SetBoundingBox(const geometry::AxisAlignedBoundingBox& bounds);
49 
50  Eigen::Vector3f GetCenterOfRotation() const;
51 
52  void SetMouseDownInfo(const Camera::Transform& matrix,
53  const Eigen::Vector3f& center_of_rotation);
54 
55  const Camera::Transform& GetMatrix() const;
56 
61  virtual void Rotate(int dx, int dy);
62 
65  virtual void RotateWorld(int dx,
66  int dy,
67  const Eigen::Vector3f& x_axis,
68  const Eigen::Vector3f& y_axis);
69 
71  virtual void RotateZ(int dx, int dy);
72 
73  virtual void RotateZWorld(int dx, int dy, const Eigen::Vector3f& forward);
74 
75  enum class DragType { MOUSE, WHEEL, TWO_FINGER };
76 
79  virtual void Dolly(float dy, DragType drag_type);
80  virtual void Dolly(float z_dist, Camera::Transform matrix);
81 
82 private:
83  Camera::Transform matrix_;
84 
85 protected:
86  int view_width_ = 1;
87  int view_height_ = 1;
88  double model_size_ = 20.0;
90  Eigen::Vector3f center_of_rotation_;
91 
94 
95  void SetMatrix(const Camera::Transform& matrix);
96  float CalcRotateRadians(int dx, int dy);
97  float CalcRotateZRadians(int dx, int dy);
98  float CalcDollyDist(float dy,
99  DragType drag_type,
100  const Camera::Transform& matrix);
101 };
102 
103 } // namespace rendering
104 } // namespace visualization
105 } // namespace open3d
virtual void RotateZWorld(int dx, int dy, const Eigen::Vector3f &forward)
Definition: MatrixInteractorLogic.cpp:165
int height
Definition: FilePCD.cpp:72
virtual void RotateZ(int dx, int dy)
Rotates about the forward axis of the matrix.
Definition: MatrixInteractorLogic.cpp:154
void SetMouseDownInfo(const Camera::Transform &matrix, const Eigen::Vector3f &center_of_rotation)
Definition: MatrixInteractorLogic.cpp:59
float CalcRotateRadians(int dx, int dy)
Definition: MatrixInteractorLogic.cpp:149
Eigen::Vector3f center_of_rotation_at_mouse_down_
Definition: MatrixInteractorLogic.h:93
virtual void Rotate(int dx, int dy)
Definition: MatrixInteractorLogic.cpp:77
A bounding box that is aligned along the coordinate axes.
Definition: BoundingVolume.h:150
float CalcDollyDist(float dy, DragType drag_type, const Camera::Transform &matrix)
Definition: MatrixInteractorLogic.cpp:210
const geometry::AxisAlignedBoundingBox & GetBoundingBox() const
Definition: MatrixInteractorLogic.cpp:44
virtual void RotateWorld(int dx, int dy, const Eigen::Vector3f &x_axis, const Eigen::Vector3f &y_axis)
Definition: MatrixInteractorLogic.cpp:122
Camera::Transform matrix_at_mouse_down_
Definition: MatrixInteractorLogic.h:92
int GetViewWidth() const
Definition: MatrixInteractorLogic.cpp:40
void SetViewSize(int width, int height)
Definition: MatrixInteractorLogic.cpp:35
void SetMatrix(const Camera::Transform &matrix)
Definition: MatrixInteractorLogic.cpp:69
virtual ~MatrixInteractorLogic()
Definition: MatrixInteractorLogic.cpp:33
virtual void Dolly(float dy, DragType drag_type)
Definition: MatrixInteractorLogic.cpp:184
Eigen::Transform< float, 3, Eigen::Affine > Transform
Definition: Camera.h:44
int view_width_
Definition: MatrixInteractorLogic.h:86
Eigen::Vector3f center_of_rotation_
Definition: MatrixInteractorLogic.h:90
const Camera::Transform & GetMatrix() const
Definition: MatrixInteractorLogic.cpp:73
DragType
Definition: MatrixInteractorLogic.h:75
geometry::AxisAlignedBoundingBox model_bounds_
Definition: MatrixInteractorLogic.h:89
Definition: MatrixInteractorLogic.h:39
Definition: PinholeCameraIntrinsic.cpp:35
int view_height_
Definition: MatrixInteractorLogic.h:87
Eigen::Vector3f GetCenterOfRotation() const
Definition: MatrixInteractorLogic.cpp:55
int GetViewHeight() const
Definition: MatrixInteractorLogic.cpp:42
virtual void SetBoundingBox(const geometry::AxisAlignedBoundingBox &bounds)
Definition: MatrixInteractorLogic.cpp:49
double model_size_
Definition: MatrixInteractorLogic.h:88
float CalcRotateZRadians(int dx, int dy)
Definition: MatrixInteractorLogic.cpp:178
int width
Definition: FilePCD.cpp:71