src/gui/graphicsview/qgraphicstransform.cpp
changeset 3 41300fa6a67c
parent 0 1918ee327afb
child 4 3b1da2848fc7
equal deleted inserted replaced
2:56cd8111b7f7 3:41300fa6a67c
    67     When the transformation is applied to a QGraphicsItem, it will be
    67     When the transformation is applied to a QGraphicsItem, it will be
    68     projected back to a 2D QTransform.  When multiple QGraphicsTransform
    68     projected back to a 2D QTransform.  When multiple QGraphicsTransform
    69     objects are applied to a QGraphicsItem, all of the transformations
    69     objects are applied to a QGraphicsItem, all of the transformations
    70     are computed in true 3D space, with the projection back to 2D
    70     are computed in true 3D space, with the projection back to 2D
    71     only occurring after the last QGraphicsTransform is applied.
    71     only occurring after the last QGraphicsTransform is applied.
       
    72     The exception to this is QGraphicsRotation, which projects back to
       
    73     2D after each rotation to preserve the perspective effect around
       
    74     the X and Y axes.
    72 
    75 
    73     If you want to create your own configurable transformation, you can create
    76     If you want to create your own configurable transformation, you can create
    74     a subclass of QGraphicsTransform (or any or the existing subclasses), and
    77     a subclass of QGraphicsTransform (or any or the existing subclasses), and
    75     reimplement the pure virtual applyTo() function, which takes a pointer to a
    78     reimplement the pure virtual applyTo() function, which takes a pointer to a
    76     QMatrix4x4. Each operation you would like to apply should be exposed as
    79     QMatrix4x4. Each operation you would like to apply should be exposed as
    88 #include "qgraphicsitem_p.h"
    91 #include "qgraphicsitem_p.h"
    89 #include "qgraphicstransform_p.h"
    92 #include "qgraphicstransform_p.h"
    90 #include <QDebug>
    93 #include <QDebug>
    91 #include <QtCore/qmath.h>
    94 #include <QtCore/qmath.h>
    92 
    95 
       
    96 #ifndef QT_NO_GRAPHICSVIEW
    93 QT_BEGIN_NAMESPACE
    97 QT_BEGIN_NAMESPACE
    94 
       
    95 void QGraphicsTransformPrivate::setItem(QGraphicsItem *i)
    98 void QGraphicsTransformPrivate::setItem(QGraphicsItem *i)
    96 {
    99 {
    97     if (item == i)
   100     if (item == i)
    98         return;
   101         return;
    99 
   102 
   545 
   548 
   546     if (d->angle == 0. || d->axis.isNull())
   549     if (d->angle == 0. || d->axis.isNull())
   547         return;
   550         return;
   548 
   551 
   549     matrix->translate(d->origin);
   552     matrix->translate(d->origin);
   550     QMatrix4x4 m;
   553     matrix->projectedRotate(d->angle, d->axis.x(), d->axis.y(), d->axis.z());
   551     m.rotate(d->angle, d->axis.x(), d->axis.y(), d->axis.z());
       
   552     *matrix *= m.toTransform();
       
   553     matrix->translate(-d->origin);
   554     matrix->translate(-d->origin);
   554 }
   555 }
   555 
   556 
   556 /*!
   557 /*!
   557     \fn void QGraphicsRotation::axisChanged()
   558     \fn void QGraphicsRotation::axisChanged()
   562 */
   563 */
   563 
   564 
   564 #include "moc_qgraphicstransform.cpp"
   565 #include "moc_qgraphicstransform.cpp"
   565 
   566 
   566 QT_END_NAMESPACE
   567 QT_END_NAMESPACE
       
   568 #endif //QT_NO_GRAPHICSVIEW