// Pan left/right/up/down without rotating about the object.
void QGLGraphicsNavigationItemPrivate::pan(qreal deltax, qreal deltay)
{
    QGLCamera *camera = viewportItem->camera();
    QPointF delta = viewDelta(deltax, deltay);
    QVector3D t = camera->translation(delta.x(), -delta.y(), 0.0f);

    // Technically panning the eye left should make the object appear to
    // move off to the right, but this looks weird on-screen where the user
    // actually thinks they are picking up the object and dragging it rather
    // than moving the eye.  We therefore apply the inverse of the translation
    // to make it "look right".
    camera->setEye(camera->eye() - t);
    camera->setCenter(camera->center() - t);
}
Exemple #2
0
QDebug operator<<(QDebug dbg, const QGLCamera &cam)
{
    dbg << "QGLCamera";
    if (!cam.objectName().isEmpty())
        dbg << cam.objectName();
    dbg << "\n";
    dbg << "   projection:" << ( cam.projectionType() == QGLCamera::Perspective ?
                                     "Perspective" : "Orthographic" );
    dbg << "-- viewsize:" << cam.viewSize().width() << "x" << cam.viewSize().height() << "\n";
    dbg << "   near-plane:" << cam.nearPlane() << "-- far-plane:" << cam.farPlane();
    dbg << "-- field-of-view:" << cam.fieldOfView() << "\n";
    dbg << "   rotation:" << cam.screenRotation() << " -- motion adjust:" <<
           cam.motionAdjustment() << " -- aspect adjust:" << cam.adjustForAspectRatio() << "\n";
    dbg << "   eye:" << cam.eye() << "-- center:" << cam.center();
    dbg << "-- up:" << cam.upVector() << "\n";
    return dbg;
}