Open3D (C++ API)
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 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 
34 namespace visualization {
35 
40 public:
41  virtual ~MatrixInteractorLogic();
42 
43  void SetViewSize(int width, int height);
44 
46  virtual void SetBoundingBox(const geometry::AxisAlignedBoundingBox& bounds);
47 
48  void SetMouseDownInfo(const Camera::Transform& matrix,
49  const Eigen::Vector3f& center_of_rotation);
50 
51  const Camera::Transform& GetMatrix() const;
52 
57  virtual void Rotate(int dx, int dy);
58 
61  virtual void RotateWorld(int dx,
62  int dy,
63  const Eigen::Vector3f& x_axis,
64  const Eigen::Vector3f& y_axis);
65 
67  virtual void RotateZ(int dx, int dy);
68 
69  virtual void RotateZWorld(int dx, int dy, const Eigen::Vector3f& forward);
70 
71  enum class DragType { MOUSE, WHEEL, TWO_FINGER };
72 
75  virtual void Dolly(int dy, DragType drag_type);
76  virtual void Dolly(float z_dist, Camera::Transform matrix);
77 
78 private:
79  Camera::Transform matrix_;
80 
81 protected:
82  int view_width_ = 1;
83  int view_height_ = 1;
84  double model_size_ = 20.0;
86  Eigen::Vector3f center_of_rotation_;
87 
90 
91  void SetMatrix(const Camera::Transform& matrix);
92  double CalcRotateRadians(int dx, int dy);
93  double CalcRotateZRadians(int dx, int dy);
94  float CalcDollyDist(int dy, DragType drag_type);
95 };
96 
97 } // namespace visualization
98 } // namespace open3d
Eigen::Vector3f center_of_rotation_at_mouse_down_
Definition: MatrixInteractorLogic.h:89
Definition: MatrixInteractorLogic.h:39
float CalcDollyDist(int dy, DragType drag_type)
Definition: MatrixInteractorLogic.cpp:200
virtual void Rotate(int dx, int dy)
Definition: MatrixInteractorLogic.cpp:68
virtual ~MatrixInteractorLogic()
Definition: MatrixInteractorLogic.cpp:32
A bounding box that is aligned along the coordinate axes.
Definition: BoundingVolume.h:164
void SetViewSize(int width, int height)
Definition: MatrixInteractorLogic.cpp:34
double model_size_
Definition: MatrixInteractorLogic.h:84
virtual void Dolly(int dy, DragType drag_type)
Definition: MatrixInteractorLogic.cpp:175
const geometry::AxisAlignedBoundingBox & GetBoundingBox() const
Definition: MatrixInteractorLogic.cpp:39
geometry::AxisAlignedBoundingBox model_bounds_
Definition: MatrixInteractorLogic.h:85
Camera::Transform matrix_at_mouse_down_
Definition: MatrixInteractorLogic.h:88
virtual void RotateWorld(int dx, int dy, const Eigen::Vector3f &x_axis, const Eigen::Vector3f &y_axis)
Definition: MatrixInteractorLogic.cpp:113
void SetMouseDownInfo(const Camera::Transform &matrix, const Eigen::Vector3f &center_of_rotation)
Definition: MatrixInteractorLogic.cpp:50
int view_height_
Definition: MatrixInteractorLogic.h:83
double CalcRotateZRadians(int dx, int dy)
Definition: MatrixInteractorLogic.cpp:169
virtual void SetBoundingBox(const geometry::AxisAlignedBoundingBox &bounds)
Definition: MatrixInteractorLogic.cpp:44
Eigen::Vector3f center_of_rotation_
Definition: MatrixInteractorLogic.h:86
double CalcRotateRadians(int dx, int dy)
Definition: MatrixInteractorLogic.cpp:140
Definition: Open3DViewer.h:29
const Camera::Transform & GetMatrix() const
Definition: MatrixInteractorLogic.cpp:64
void SetMatrix(const Camera::Transform &matrix)
Definition: MatrixInteractorLogic.cpp:60
int height
Definition: FilePCD.cpp:70
virtual void RotateZ(int dx, int dy)
Rotates about the forward axis of the matrix.
Definition: MatrixInteractorLogic.cpp:145
virtual void RotateZWorld(int dx, int dy, const Eigen::Vector3f &forward)
Definition: MatrixInteractorLogic.cpp:156
int view_width_
Definition: MatrixInteractorLogic.h:82
Eigen::Transform< float, 3, Eigen::Affine > Transform
Definition: Camera.h:38
DragType
Definition: MatrixInteractorLogic.h:71
int width
Definition: FilePCD.cpp:69