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)
A ManipulatedFrame is a Frame that can be rotated and translated using the mouse. ...
virtual QDomElement domElement(const QString &name, QDomDocument &document) const
qreal squaredNorm() const
bool isManipulated() const
void setZoomSensitivity(qreal sensitivity)
void setGrabsMouse(bool grabs)
Quaternion deformedBallQuaternion(int x, int y, qreal cx, qreal cy, const Camera *const camera)
Constraint * previousConstraint_
virtual QDomElement domElement(const QString &name, QDomDocument &document) const
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
Vec viewDirection() const
void setRotationSensitivity(qreal sensitivity)
void setWheelSensitivity(qreal sensitivity)
void setSpinningSensitivity(qreal sensitivity)
void setConstraint(Constraint *const constraint)
Constraint * constraint() const
Abstract class for objects that grab mouse focus in a QGLViewer.
qreal rotationSensitivity() const
virtual void getOrthoWidthHeight(GLdouble &halfWidth, GLdouble &halfHeight) 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 wheelEvent(QWheelEvent *const event, Camera *const camera)
void zoom(qreal delta, const Camera *const camera)
qreal deltaWithPrevPos(QMouseEvent *const event, Camera *const camera) const
void setValue(qreal X, qreal Y, qreal Z)
virtual void mouseDoubleClickEvent(QMouseEvent *const event, Camera *const camera)
qreal wheelSensitivity() const
void projectOnLine(const Vec &origin, const Vec &direction)
static qreal qrealFromDom(const QDomElement &e, const QString &attribute, qreal defValue)
Vec rotate(const Vec &v) const
ManipulatedCameraFrame * frame() const
static qreal projectOnBall(qreal x, qreal y)
void setSpinningQuaternion(const Quaternion &spinningQuaternion)
qreal spinningSensitivity() const
A versatile 3D OpenGL viewer based on QGLWidget.
void computeMouseSpeed(const QMouseEvent *const e)
QGLViewer::MouseAction action_
A perspective or orthographic camera.
ManipulatedFrame & operator=(const ManipulatedFrame &mf)
The Quaternion class represents 3D rotations and orientations.
Quaternion spinningQuaternion() const
Quaternion orientation() const
qreal zoomSensitivity() const
void alignWithFrame(const Frame *const frame, bool move=false, qreal threshold=0.0)
virtual void stopSpinning()
Vec transformOf(const Vec &src) const
The Frame class represents a coordinate system, defined by a position and an orientation.
qreal wheelDelta(const QWheelEvent *event) const
int mouseOriginalDirection(const QMouseEvent *const e)
Frame & operator=(const Frame &frame)
Vec inverseTransformOf(const Vec &src) const
const Frame * referenceFrame() const
qreal fieldOfView() const
Vec coordinatesOf(const Vec &src) const
qreal translationSensitivity() const
virtual void mouseMoveEvent(QMouseEvent *const event, Camera *const camera)
virtual void startAction(int ma, bool withConstraint=true)
virtual void initFromDOMElement(const QDomElement &element)
virtual void startSpinning(int updateInterval)
void setTranslationSensitivity(qreal sensitivity)