31 #include <QMouseEvent> 44 : action_(
QGLViewer::NO_MOUSE_ACTION), keepsGrabbingMouse_(false)
95 const int thresold = 10;
119 QDomElement mp = document.createElement(
"ManipulatedParameters");
146 QDomElement child=element.firstChild().toElement();
147 while (!child.isNull())
149 if (child.tagName() ==
"ManipulatedParameters")
158 child = child.nextSibling().toElement();
243 const QPoint delta = (e->pos() -
prevPos_);
244 const qreal dist = sqrt(qreal(delta.x()*delta.x() + delta.y()*delta.y()));
257 static bool horiz =
true;
261 const QPoint delta = e->pos() -
pressPos_;
263 horiz = abs(delta.x()) > abs(delta.y());
279 qreal value = fabs(dx) > fabs(dy) ? dx : dy;
284 static const qreal WHEEL_SENSITIVITY_COEF = 8E-4;
335 const QPoint delta =
event->pos() -
prevPos_;
336 Vec trans(delta.x(), -delta.y(), 0.0);
338 switch (camera->
type())
370 const qreal prev_angle = atan2(
prevPos_.y()-trans[1],
prevPos_.x()-trans[0]);
371 const qreal angle = atan2(event->y()-trans[1],
event->
x()-trans[0]);
391 switch (camera->
type())
419 trans =
Vec(-rot[0], -rot[1], -rot[2]);
484 if (event->modifiers() == Qt::NoModifier)
485 switch (event->button())
523 const qreal size = 1.0;
524 const qreal size2 = size*size;
525 const qreal size_limit = size2*0.5;
527 const qreal d = x*x + y*y;
528 return d < size_limit ? sqrt(size2 - d) : size_limit/sqrt(d);
546 const Vec axis = cross(p2,p1);
virtual void initFromDOMElement(const QDomElement &element)
Vec inverseTransformOf(const Vec &src) const
A ManipulatedFrame is a Frame that can be rotated and translated using the mouse. ...
qreal fieldOfView() const
void setZoomSensitivity(qreal sensitivity)
void setGrabsMouse(bool grabs)
Quaternion deformedBallQuaternion(int x, int y, qreal cx, qreal cy, const Camera *const camera)
qreal wheelSensitivity() const
Constraint * previousConstraint_
virtual void mouseReleaseEvent(QMouseEvent *const event, Camera *const camera)
virtual void checkIfGrabsMouse(int x, int y, const Camera *const camera)
Vec projectedCoordinatesOf(const Vec &src, const Frame *frame=NULL) const
void setRotationSensitivity(qreal sensitivity)
Vec transformOf(const Vec &src) const
void setWheelSensitivity(qreal sensitivity)
void setSpinningSensitivity(qreal sensitivity)
qreal squaredNorm() const
virtual QDomElement domElement(const QString &name, QDomDocument &document) const
Vec rotate(const Vec &v) const
qreal deltaWithPrevPos(QMouseEvent *const event, Camera *const camera) const
void setConstraint(Constraint *const constraint)
Abstract class for objects that grab mouse focus in a QGLViewer.
qreal rotationSensitivity() const
ManipulatedCameraFrame * frame() const
virtual void mousePressEvent(QMouseEvent *const event, Camera *const camera)
void rotate(Quaternion &q)
The Vec class represents 3D positions and 3D vectors.
virtual void getOrthoWidthHeight(GLdouble &halfWidth, GLdouble &halfHeight) const
virtual void wheelEvent(QWheelEvent *const event, Camera *const camera)
void zoom(qreal delta, const Camera *const camera)
void setValue(qreal X, qreal Y, qreal Z)
qreal wheelDelta(const QWheelEvent *event) const
virtual void mouseDoubleClickEvent(QMouseEvent *const event, Camera *const camera)
void projectOnLine(const Vec &origin, const Vec &direction)
qreal zoomSensitivity() const
static qreal qrealFromDom(const QDomElement &e, const QString &attribute, qreal defValue)
virtual QDomElement domElement(const QString &name, QDomDocument &document) const
static qreal projectOnBall(qreal x, qreal y)
void setSpinningQuaternion(const Quaternion &spinningQuaternion)
A versatile 3D OpenGL viewer based on QGLWidget.
Vec coordinatesOf(const Vec &src) const
void computeMouseSpeed(const QMouseEvent *const e)
QGLViewer::MouseAction action_
A perspective or orthographic camera.
ManipulatedFrame & operator=(const ManipulatedFrame &mf)
qreal translationSensitivity() const
The Quaternion class represents 3D rotations and orientations.
Quaternion orientation() const
Vec viewDirection() const
Constraint * constraint() const
void alignWithFrame(const Frame *const frame, bool move=false, qreal threshold=0.0)
virtual void stopSpinning()
The Frame class represents a coordinate system, defined by a position and an orientation.
int mouseOriginalDirection(const QMouseEvent *const e)
Frame & operator=(const Frame &frame)
const Frame * referenceFrame() const
Quaternion spinningQuaternion() const
qreal spinningSensitivity() const
virtual void mouseMoveEvent(QMouseEvent *const event, Camera *const camera)
bool isManipulated() const
virtual void startAction(int ma, bool withConstraint=true)
virtual void initFromDOMElement(const QDomElement &element)
virtual void startSpinning(int updateInterval)
void setTranslationSensitivity(qreal sensitivity)