30 #if QT_VERSION >= 0x040000 31 # include <QMouseEvent> 45 : action_(
QGLViewer::NO_MOUSE_ACTION), keepsGrabbingMouse_(false)
93 const int thresold = 10;
117 QDomElement mp = document.createElement(
"ManipulatedParameters");
143 QDomElement child=element.firstChild().toElement();
144 while (!child.isNull())
146 if (child.tagName() ==
"ManipulatedParameters")
154 child = child.nextSibling().toElement();
239 const QPoint delta = (e->pos() -
prevPos_);
240 const float dist = sqrt(static_cast<float>(delta.x()*delta.x() + delta.y()*delta.y()));
253 static bool horiz =
true;
257 const QPoint delta = e->pos() -
pressPos_;
259 horiz = abs(delta.x()) > abs(delta.y());
310 const QPoint delta =
event->pos() -
prevPos_;
311 Vec trans(static_cast<float>(delta.x()), static_cast<float>(-delta.y()), 0.0);
313 switch (camera->
type())
351 const double prev_angle = atan2(
prevPos_.y()-trans[1],
prevPos_.x()-trans[0]);
352 const double angle = atan2(event->y()-trans[1],
event->
x()-trans[0]);
372 switch (camera->
type())
400 trans =
Vec(-rot[0], -rot[1], -rot[2]);
456 #if QT_VERSION >= 0x040000 457 if (event->modifiers() == Qt::NoModifier)
459 if (event->state() == Qt::NoButton)
461 switch (event->button())
478 const float wheelSensitivityCoef = 8E-4f;
506 const float size = 1.0f;
507 const float size2 = size*size;
508 const float size_limit = size2*0.5;
510 const float d = x*x + y*y;
511 return d < size_limit ? sqrt(size2 - d) : size_limit/sqrt(d);
529 const Vec axis = cross(p2,p1);
void setValue(double X, double Y, double Z)
virtual void initFromDOMElement(const QDomElement &element)
void setTranslationSensitivity(float sensitivity)
Vec inverseTransformOf(const Vec &src) const
A ManipulatedFrame is a Frame that can be rotated and translated using the mouse. ...
void setWheelSensitivity(float sensitivity)
void setGrabsMouse(bool grabs)
static float projectOnBall(float x, float y)
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
float translationSensitivity() const
Vec transformOf(const Vec &src) const
virtual QDomElement domElement(const QString &name, QDomDocument &document) const
Vec rotate(const Vec &v) const
void setRotationSensitivity(float sensitivity)
void setConstraint(Constraint *const constraint)
Abstract class for objects that grab mouse focus in a QGLViewer.
float wheelSensitivity() 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)
float rotationSensitivity() const
float spinningSensitivity() const
virtual void mouseDoubleClickEvent(QMouseEvent *const event, Camera *const camera)
void projectOnLine(const Vec &origin, const Vec &direction)
virtual QDomElement domElement(const QString &name, QDomDocument &document) const
void setSpinningQuaternion(const Quaternion &spinningQuaternion)
double squaredNorm() const
A versatile 3D OpenGL viewer based on QGLWidget.
void setSpinningSensitivity(float sensitivity)
Vec coordinatesOf(const Vec &src) const
void computeMouseSpeed(const QMouseEvent *const e)
A perspective or orthographic camera.
ManipulatedFrame & operator=(const ManipulatedFrame &mf)
The Quaternion class represents 3D rotations and orientations.
Quaternion orientation() const
Constraint * constraint() const
virtual void stopSpinning()
The Frame class represents a coordinate system, defined by a position and an orientation.
float fieldOfView() const
int mouseOriginalDirection(const QMouseEvent *const e)
Quaternion deformedBallQuaternion(int x, int y, float cx, float cy, const Camera *const camera)
Frame & operator=(const Frame &frame)
const Frame * referenceFrame() const
Quaternion spinningQuaternion() const
virtual void mouseMoveEvent(QMouseEvent *const event, Camera *const camera)
bool isManipulated() const
Vec viewDirection() const
void alignWithFrame(const Frame *const frame, bool move=false, float threshold=0.85f)
static float floatFromDom(const QDomElement &e, const QString &attribute, float defValue)
virtual void startAction(int ma, bool withConstraint=true)
virtual void initFromDOMElement(const QDomElement &element)
virtual void startSpinning(int updateInterval)