Mouse6dofInput.h 2.47 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12
/**
 * @file
 *   @brief Definition of 3dConnexion 3dMouse interface for QGroundControl
 *
 *   @author Matthias Krebs <makrebs@student.ethz.ch>
 *
 */

#ifndef MOUSE6DOFINPUT_H
#define MOUSE6DOFINPUT_H

#include <QThread>
13

14
#ifdef QGC_MOUSE_ENABLED_WIN
15
#include "Mouse3DInput.h"
16
#endif //QGC_MOUSE_ENABLED_WIN
17

18 19
#include "UAS.h"
#include "Vehicle.h"
20 21 22 23 24 25

class Mouse6dofInput : public QThread
{
    Q_OBJECT

public:
26
#ifdef QGC_MOUSE_ENABLED_WIN
27
    Mouse6dofInput(Mouse3DInput* mouseInput);
28 29
#endif //QGC_MOUSE_ENABLED_WIN
#ifdef QGC_MOUSE_ENABLED_LINUX
30
    Mouse6dofInput(QWidget* parent);
31
#endif //QGC_MOUSE_ENABLED_LINUX
32

33 34 35 36 37 38 39 40
    ~Mouse6dofInput();
    void run();

    const double mouse3DMax;

protected:
    void init();

41
    UAS* uas;
42
    bool done;
43
    bool mouseActive;
44 45
    bool translationActive;
    bool rotationActive;
46 47 48 49 50 51 52 53

    double xValue;
    double yValue;
    double zValue;
    double aValue;
    double bValue;
    double cValue;

54

55 56 57 58 59 60 61 62 63 64 65 66 67
signals:
    /**
     * @brief Input of the 3d mouse has changed
     *
     * @param x Input x direction, range [-1, 1]
     * @param y Input y direction, range [-1, 1]
     * @param z Input z direction, range [-1, 1]
     * @param a Input x rotation,  range [-1, 1]
     * @param b Input y rotation,  range [-1, 1]
     * @param c Input z rotation,  range [-1, 1]
     */
    void mouse6dofChanged(double x, double y, double z, double a, double b, double c);

68 69 70 71 72 73 74 75 76 77 78 79
   /**
     * @brief Activity of translational 3DMouse inputs changed
     * @param translationEnable, true: translational inputs active; false: translational inputs ingored
     */
    void mouseTranslationActiveChanged(bool translationEnable);

   /**
     * @brief Activity of rotational 3DMouse inputs changed
     * @param rotationEnable, true: rotational inputs active; false: rotational inputs ingored
     */
    void mouseRotationActiveChanged(bool rotationEnable);

80
public slots:
81
#ifdef QGC_MOUSE_ENABLED_WIN
82
    /** @brief Get a motion input from 3DMouse */
83
    void motion3DMouse(std::vector<float> &motionData);
84 85
    /** @brief Get a button input from 3DMouse */
    void button3DMouseDown(int button);
86 87
#endif //QGC_MOUSE_ENABLED_WIN
#ifdef QGC_MOUSE_ENABLED_LINUX
88 89
    /** @brief Get an XEvent to check it for an 3DMouse event (motion or button) */
    void handleX11Event(XEvent* event);
90
#endif //QGC_MOUSE_ENABLED_LINUX
91

92 93
private slots:
    void _activeVehicleChanged(Vehicle* vehicle);
94 95 96
};

#endif // MOUSE6DOFINPUT_H