27 #include <QMouseEvent> 38 : driveSpeed_(0.0), sceneUpVector_(0.0, 1.0, 0.0), rotatesAroundUpVector_(false), zoomsOnPivotPoint_(false)
82 static Vec flyDisp(0.0, 0.0, 0.0);
107 qWarning(
"flyUpVector() is deprecated. Use sceneUpVector() instead.");
112 qWarning(
"setFlyUpVector() is deprecated. Use setSceneUpVector() instead.");
145 QDomElement mcp = document.createElement(
"ManipulatedCameraParameters");
146 mcp.setAttribute(
"flySpeed", QString::number(
flySpeed()));
165 QDomElement child=element.firstChild().toElement();
166 while (!child.isNull())
168 if (child.tagName() ==
"ManipulatedCameraParameters")
174 QDomElement schild=child.firstChild().toElement();
175 while (!schild.isNull())
177 if (schild.tagName() ==
"sceneUpVector")
180 schild = schild.nextSibling().toElement();
183 child = child.nextSibling().toElement();
218 if (direction.
norm() > 0.02 * sceneRadius || delta > 0.0)
222 Vec trans(0.0, 0.0, -coef * delta);
240 const QPoint delta =
prevPos_ -
event->pos();
241 Vec trans(delta.x(), -delta.y(), 0.0);
243 switch (camera->
type())
328 const qreal angle = atan2(event->y() - trans[1],
event->
x() - trans[0]) - atan2(
prevPos_.y()-trans[1],
prevPos_.x()-trans[0]);
358 switch (camera->
type())
442 const int finalDrawAfterWheelEventDelay = 400;
446 flyTimer_.start(finalDrawAfterWheelEventDelay);
virtual void initFromDOMElement(const QDomElement &element)
The ManipulatedCameraFrame class represents a ManipulatedFrame with Camera specific mouse bindings...
Vec inverseTransformOf(const Vec &src) const
A ManipulatedFrame is a Frame that can be rotated and translated using the mouse. ...
void setRotatesAroundUpVector(bool constrained)
qreal fieldOfView() const
virtual void mouseMoveEvent(QMouseEvent *const event, Camera *const camera)
Quaternion deformedBallQuaternion(int x, int y, qreal cx, qreal cy, const Camera *const camera)
Quaternion pitchYawQuaternion(int x, int y, const Camera *const camera)
Constraint * previousConstraint_
virtual void mouseReleaseEvent(QMouseEvent *const event, Camera *const camera)
Vec projectedCoordinatesOf(const Vec &src, const Frame *frame=NULL) const
Vec transformOf(const Vec &src) const
bool zoomsOnPivotPoint() const
ManipulatedCameraFrame & operator=(const ManipulatedCameraFrame &mcf)
void setFlyUpVector(const Vec &up)
bool constrainedRotationIsReversed_
qreal deltaWithPrevPos(QMouseEvent *const event, Camera *const camera) const
void setConstraint(Constraint *const constraint)
qreal rotationSensitivity() const
void updateSceneUpVector()
ManipulatedCameraFrame * frame() const
void fitScreenRegion(const QRect &rectangle)
void rotate(Quaternion &q)
void zoom(qreal delta, const Camera *const camera)
qreal sceneRadius() const
The Vec class represents 3D positions and 3D vectors.
virtual void getOrthoWidthHeight(GLdouble &halfWidth, GLdouble &halfHeight) const
Quaternion turnQuaternion(int x, const Camera *const camera)
void setValue(qreal X, qreal Y, qreal Z)
qreal wheelDelta(const QWheelEvent *event) const
static void setBoolAttribute(QDomElement &element, const QString &attribute, bool value)
static qreal qrealFromDom(const QDomElement &e, const QString &attribute, qreal defValue)
virtual QDomElement domElement(const QString &name, QDomDocument &document) const
virtual void wheelEvent(QWheelEvent *const event, Camera *const camera)
void setSpinningQuaternion(const Quaternion &spinningQuaternion)
Vec coordinatesOf(const Vec &src) const
void computeMouseSpeed(const QMouseEvent *const e)
Vec sceneUpVector() const
QGLViewer::MouseAction action_
bool rotatesAroundUpVector() const
A perspective or orthographic camera.
virtual void initFromDOMElement(const QDomElement &element)
ManipulatedFrame & operator=(const ManipulatedFrame &mf)
qreal translationSensitivity() const
The Quaternion class represents 3D rotations and orientations.
static bool boolFromDom(const QDomElement &e, const QString &attribute, bool defValue)
virtual void startAction(int ma, bool withConstraint=true)
virtual void mouseReleaseEvent(QMouseEvent *const event, Camera *const camera)
void setFlySpeed(qreal speed)
int mouseOriginalDirection(const QMouseEvent *const e)
Quaternion spinningQuaternion() const
bool rotatesAroundUpVector_
void removeFromMouseGrabberPool()
Vec localInverseTransformOf(const Vec &src) const
void setZoomsOnPivotPoint(bool enabled)
void setSceneUpVector(const Vec &up)
virtual QDomElement domElement(const QString &name, QDomDocument &document) const
virtual void startAction(int ma, bool withConstraint=true)
void rotateAroundPoint(Quaternion &rotation, const Vec &point)