ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
GamepadInput.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 // # #
11 // # CLOUDCOMPARE #
12 // # #
13 // # This program is free software; you can redistribute it and/or modify #
14 // # it under the terms of the GNU General Public License as published by #
15 // # the Free Software Foundation; version 2 or later of the License. #
16 // # #
17 // # This program is distributed in the hope that it will be useful, #
18 // # but WITHOUT ANY WARRANTY; without even the implied warranty of #
19 // # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
20 // # GNU General Public License for more details. #
21 // # #
22 // # COPYRIGHT: Daniel Girardeau-Montaut #
23 // # #
24 // ##########################################################################
25 
26 #include "CVAppCommon.h"
27 
28 // cloudViewer
29 #include <CVConst.h>
30 
31 // qCC_db
32 #include <ecvGLMatrix.h>
33 
34 // Qt
35 #include <QGamepad>
36 #include <QTimer>
37 
38 class QMainWindow;
39 
41 class CVAPPCOMMON_LIB_API GamepadInput : public QGamepad {
42  Q_OBJECT
43 
44 public:
46  explicit GamepadInput(QObject* parent = nullptr);
48  virtual ~GamepadInput();
49 
50  void start();
51  void stop();
52 
54  void update(QMainWindow* win);
55 
56 Q_SIGNALS:
57 
58  void updated();
59 
60 protected:
61  void updateInternalState();
62 
63 private:
65  QTimer m_timer;
66 
68  CCVector3 m_panning;
69  bool m_hasPanning;
70  CCVector3 m_translation;
71  bool m_hasTranslation;
72  ccGLMatrixd m_rotation;
73  bool m_hasRotation;
74  float m_zoom;
75 };
ecvViewportParameters::computeWidthAtFocalDist
double computeWidthAtFocalDist() const
Computes the object 'width' at the 'focal' distance.
Definition: ecvViewportParameters.cpp:321
ecvDisplayTools::RotateBaseViewMat
static void RotateBaseViewMat(const ccGLMatrixd &rotMat)
Rotates the base view matrix.
Definition: ecvDisplayTools.cpp:1341
GamepadInput::~GamepadInput
virtual ~GamepadInput()
Destructor.
Definition: GamepadInput.cpp:28
Vector3Tpl::normalize
void normalize()
Sets vector norm to unity.
Definition: CVGeom.h:428
x
normal_z x
Definition: my_point_types.h:165
GamepadInput::stop
void stop()
Definition: GamepadInput.cpp:32
Tuple3Tpl::x
Type x
Definition: CVGeom.h:137
GamepadInput
Gaempad handler.
Definition: GamepadInput.h:41
CVConst.h
ccGLMatrixd
Double version of ccGLMatrixTpl.
Definition: ecvGLMatrix.h:56
ccGLMatrixTpl::toIdentity
virtual void toIdentity()
Sets matrix to identity.
Definition: ecvGLMatrixTpl.h:622
ecvViewportParameters
Standard parameters for GL displays/viewports.
Definition: ecvViewportParameters.h:18
ecvDisplayTools.h
GamepadInput::start
void start()
Definition: GamepadInput.cpp:30
CCVector3
Vector3Tpl< PointCoordinateType > CCVector3
Default 3D Vector.
Definition: CVGeom.h:798
CCVector3d
Vector3Tpl< double > CCVector3d
Double 3D Vector.
Definition: CVGeom.h:804
CVAppCommon.h
Vector3Tpl< double >
cloudViewer::GreaterThanEpsilon
bool GreaterThanEpsilon(float x)
Test a floating point number against our epsilon (a very small number).
Definition: CVMath.h:37
s_gamepadRotSpeed
static double s_gamepadRotSpeed
Definition: GamepadInput.cpp:88
ccGLMatrixTpl::initFromParameters
void initFromParameters(T alpha_rad, const Vector3Tpl< T > &axis3D, const Vector3Tpl< T > &t3D)
Inits transformation from a rotation axis, an angle and a translation.
Definition: ecvGLMatrixTpl.h:648
s_gamepadSpeed
static double s_gamepadSpeed
Definition: GamepadInput.cpp:87
ecvDisplayTools::GetViewportParameters
static const ecvViewportParameters & GetViewportParameters()
Definition: ecvDisplayTools.cpp:2636
Tuple3Tpl::z
Type z
Definition: CVGeom.h:137
ecvViewportParameters::objectCenteredView
bool objectCenteredView
Definition: ecvViewportParameters.h:130
cloudViewer::DegreesToRadians
float DegreesToRadians(int degrees)
Convert degrees to radians.
Definition: CVMath.h:98
ecvViewportParameters::perspectiveView
bool perspectiveView
Perspective view state.
Definition: ecvViewportParameters.h:125
CVAPPCOMMON_LIB_API
#define CVAPPCOMMON_LIB_API
Definition: CVAppCommon.h:15
ecvViewportParameters::computeDistanceToHalfWidthRatio
double computeDistanceToHalfWidthRatio() const
Computes the ratio 'distance to half width' (based on the current FOV)
Definition: ecvViewportParameters.cpp:312
GamepadInput::updated
void updated()
Tuple3Tpl::y
Type y
Definition: CVGeom.h:137
ecvDisplayTools::RedrawDisplay
static void RedrawDisplay(bool only2D=false, bool forceRedraw=true)
Definition: ecvDisplayTools.cpp:2883
GamepadInput.h
ccGLMatrixTpl< double >::FromToRotation
static ccGLMatrixTpl< double > FromToRotation(const Vector3Tpl< double > &from, const Vector3Tpl< double > &to)
Creates a transformation matrix that rotates a vector to another.
Definition: ecvGLMatrixTpl.h:230
ecvDisplayTools::MoveCamera
static void MoveCamera(float dx, float dy, float dz)
Displaces camera.
Definition: ecvDisplayTools.cpp:1203
GamepadInput::update
void update(QMainWindow *win)
Updates a window with the current gamepad state.
Definition: GamepadInput.cpp:34
X
void * X
Definition: SmallVector.cpp:45
z
normal_z z
Definition: my_point_types.h:165
ecvGLMatrix.h
GamepadInput::GamepadInput
GamepadInput(QObject *parent=nullptr)
Default constructor.
Definition: GamepadInput.cpp:19