trackball.h Example File
graphicsview/boxes/trackball.h
#ifndef TRACKBALL_H
#define TRACKBALL_H
#include <QtWidgets>
#include <QtGui/qvector3d.h>
#include <QtGui/qquaternion.h>
class TrackBall
{
public:
enum TrackMode
{
Plane,
Sphere,
};
TrackBall(TrackMode mode = Sphere);
TrackBall(float angularVelocity, const QVector3D& axis, TrackMode mode = Sphere);
void push(const QPointF& p, const QQuaternion &transformation);
void move(const QPointF& p, const QQuaternion &transformation);
void release(const QPointF& p, const QQuaternion &transformation);
void start();
void stop();
QQuaternion rotation() const;
private:
QQuaternion m_rotation;
QVector3D m_axis;
float m_angularVelocity;
QPointF m_lastPos;
QTime m_lastTime;
bool m_paused;
bool m_pressed;
TrackMode m_mode;
};
#endif