Qt 4.8
Signals | Public Functions | Properties | List of all members
QGraphicsRotation Class Reference

The QGraphicsRotation class provides a rotation transformation around a given axis. More...

#include <qgraphicstransform.h>

Inheritance diagram for QGraphicsRotation:
QGraphicsTransform QObject

Signals

void angleChanged ()
 This signal is emitted whenever the angle has changed. More...
 
void axisChanged ()
 This signal is emitted whenever the axis of the object changes. More...
 
void originChanged ()
 This signal is emitted whenever the origin has changed. More...
 
- Signals inherited from QObject
void destroyed (QObject *=0)
 This signal is emitted immediately before the object obj is destroyed, and can not be blocked. More...
 

Public Functions

qreal angle () const
 
void applyTo (QMatrix4x4 *matrix) const
 Reimplemented Function More...
 
QVector3D axis () const
 
QVector3D origin () const
 
 QGraphicsRotation (QObject *parent=0)
 Constructs a new QGraphicsRotation with the given parent. More...
 
void setAngle (qreal)
 
void setAxis (const QVector3D &axis)
 
void setAxis (Qt::Axis axis)
 Convenience function to set the axis to axis. More...
 
void setOrigin (const QVector3D &point)
 
 ~QGraphicsRotation ()
 Destroys the graphics rotation. More...
 
- Public Functions inherited from QGraphicsTransform
 QGraphicsTransform (QObject *parent=0)
 Constructs a new QGraphicsTransform with the given parent. More...
 
 ~QGraphicsTransform ()
 Destroys the graphics transform. More...
 
- Public Functions inherited from QObject
bool blockSignals (bool b)
 If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it). More...
 
const QObjectListchildren () const
 Returns a list of child objects. More...
 
bool connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const
 
bool disconnect (const char *signal=0, const QObject *receiver=0, const char *member=0)
 
bool disconnect (const QObject *receiver, const char *member=0)
 
void dumpObjectInfo ()
 Dumps information about signal connections, etc. More...
 
void dumpObjectTree ()
 Dumps a tree of children to the debug output. More...
 
QList< QByteArraydynamicPropertyNames () const
 Returns the names of all properties that were dynamically added to the object using setProperty(). More...
 
virtual bool event (QEvent *)
 This virtual function receives events to an object and should return true if the event e was recognized and processed. More...
 
virtual bool eventFilter (QObject *, QEvent *)
 Filters events if this object has been installed as an event filter for the watched object. More...
 
template<typename T >
findChild (const QString &aName=QString()) const
 Returns the child of this object that can be cast into type T and that is called name, or 0 if there is no such object. More...
 
template<typename T >
QList< T > findChildren (const QString &aName=QString()) const
 Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects. More...
 
template<typename T >
QList< T > findChildren (const QRegExp &re) const
 
bool inherits (const char *classname) const
 Returns true if this object is an instance of a class that inherits className or a QObject subclass that inherits className; otherwise returns false. More...
 
void installEventFilter (QObject *)
 Installs an event filter filterObj on this object. More...
 
bool isWidgetType () const
 Returns true if the object is a widget; otherwise returns false. More...
 
void killTimer (int id)
 Kills the timer with timer identifier, id. More...
 
virtual const QMetaObjectmetaObject () const
 Returns a pointer to the meta-object of this object. More...
 
void moveToThread (QThread *thread)
 Changes the thread affinity for this object and its children. More...
 
QString objectName () const
 
QObjectparent () const
 Returns a pointer to the parent object. More...
 
QVariant property (const char *name) const
 Returns the value of the object's name property. More...
 
Q_INVOKABLE QObject (QObject *parent=0)
 Constructs an object with parent object parent. More...
 
void removeEventFilter (QObject *)
 Removes an event filter object obj from this object. More...
 
void setObjectName (const QString &name)
 
void setParent (QObject *)
 Makes the object a child of parent. More...
 
bool setProperty (const char *name, const QVariant &value)
 Sets the value of the object's name property to value. More...
 
void setUserData (uint id, QObjectUserData *data)
 
bool signalsBlocked () const
 Returns true if signals are blocked; otherwise returns false. More...
 
int startTimer (int interval)
 Starts a timer and returns a timer identifier, or returns zero if it could not start a timer. More...
 
QThreadthread () const
 Returns the thread in which the object lives. More...
 
QObjectUserDatauserData (uint id) const
 
virtual ~QObject ()
 Destroys the object, deleting all its child objects. More...
 

Properties

qreal angle
 the angle for clockwise rotation, in degrees. More...
 
QVector3D axis
 a rotation axis, specified by a vector in 3D space. More...
 
QVector3D origin
 the origin of the rotation in 3D space. More...
 

Additional Inherited Members

- Public Slots inherited from QObject
void deleteLater ()
 Schedules this object for deletion. More...
 
- Static Public Functions inherited from QObject
static bool connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
 Creates a connection of the given type from the signal in the sender object to the method in the receiver object. More...
 
static bool connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member)
 Disconnects signal in object sender from method in object receiver. More...
 
static bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member)
 
static uint registerUserData ()
 
static QString tr (const char *sourceText, const char *comment=0, int n=-1)
 
static QString trUtf8 (const char *sourceText, const char *comment=0, int n=-1)
 
- Static Public Variables inherited from QObject
static const QMetaObject staticMetaObject
 This variable stores the meta-object for the class. More...
 
- Protected Slots inherited from QGraphicsTransform
void update ()
 Notifies that this transform operation has changed its parameters in such a way that applyTo() will return a different result than before. More...
 
- Protected Functions inherited from QGraphicsTransform
 QGraphicsTransform (QGraphicsTransformPrivate &p, QObject *parent)
 
- Protected Functions inherited from QObject
virtual void childEvent (QChildEvent *)
 This event handler can be reimplemented in a subclass to receive child events. More...
 
virtual void connectNotify (const char *signal)
 This virtual function is called when something has been connected to signal in this object. More...
 
virtual void customEvent (QEvent *)
 This event handler can be reimplemented in a subclass to receive custom events. More...
 
virtual void disconnectNotify (const char *signal)
 This virtual function is called when something has been disconnected from signal in this object. More...
 
 QObject (QObjectPrivate &dd, QObject *parent=0)
 
int receivers (const char *signal) const
 Returns the number of receivers connected to the signal. More...
 
QObjectsender () const
 Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; otherwise it returns 0. More...
 
int senderSignalIndex () const
 
virtual void timerEvent (QTimerEvent *)
 This event handler can be reimplemented in a subclass to receive timer events for the object. More...
 
- Protected Variables inherited from QObject
QScopedPointer< QObjectDatad_ptr
 
- Static Protected Variables inherited from QObject
static const QMetaObject staticQtMetaObject
 

Detailed Description

The QGraphicsRotation class provides a rotation transformation around a given axis.

Since
4.6

You can provide the desired axis by assigning a QVector3D to the axis property or by passing a member if Qt::Axis to the setAxis convenience function. By default the axis is (0, 0, 1) i.e., rotation around the Z axis.

The angle property, which is provided by QGraphicsRotation, now describes the number of degrees to rotate around this axis.

QGraphicsRotation provides certain parameters to help control how the rotation should be applied.

The origin is the point that the item is rotated around (i.e., it stays fixed relative to the parent as the rest of the item is rotated). By default the origin is QPointF(0, 0).

The angle property provides the number of degrees to rotate the item clockwise around the origin. This value also be negative, indicating a counter-clockwise rotation. For animation purposes it may also be useful to provide rotation angles exceeding (-360, 360) degrees, for instance to animate how an item rotates several times.

Note: the final rotation is the combined effect of a rotation in 3D space followed by a projection back to 2D. If several rotations are performed in succession, they will not behave as expected unless they were all around the Z axis.

See also
QGraphicsTransform, QGraphicsItem::setRotation(), QTransform::rotate()

Definition at line 122 of file qgraphicstransform.h.

Constructors and Destructors

◆ QGraphicsRotation()

QGraphicsRotation::QGraphicsRotation ( QObject parent = 0)

Constructs a new QGraphicsRotation with the given parent.

Definition at line 462 of file qgraphicstransform.cpp.

464 {
465 }
QGraphicsTransform(QObject *parent=0)
Constructs a new QGraphicsTransform with the given parent.

◆ ~QGraphicsRotation()

QGraphicsRotation::~QGraphicsRotation ( )

Destroys the graphics rotation.

Definition at line 470 of file qgraphicstransform.cpp.

471 {
472 }

Functions

◆ angle()

qreal QGraphicsRotation::angle ( ) const

Referenced by setAngle(), and setOrigin().

◆ angleChanged

void QGraphicsRotation::angleChanged ( )
signal

This signal is emitted whenever the angle has changed.

See also
QGraphicsRotation::angle

Referenced by setAngle().

◆ applyTo()

void QGraphicsRotation::applyTo ( QMatrix4x4 matrix) const
virtual

Reimplemented Function

Implements QGraphicsTransform.

Definition at line 625 of file qgraphicstransform.cpp.

626 {
627  Q_D(const QGraphicsRotation);
628 
629  if (d->angle == 0. || d->axis.isNull() || qIsNaN(d->angle))
630  return;
631 
632  matrix->translate(d->origin);
633  matrix->projectedRotate(d->angle, d->axis.x(), d->axis.y(), d->axis.z());
634  matrix->translate(-d->origin);
635 }
void translate(const QVector3D &vector)
Multiplies this matrix by another that translates coordinates by the components of vector...
Definition: qmatrix4x4.cpp:944
double d
Definition: qnumeric_p.h:62
void projectedRotate(qreal angle, qreal x, qreal y, qreal z)
#define Q_D(Class)
Definition: qglobal.h:2482
Q_CORE_EXPORT bool qIsNaN(double d)
Returns true if the double {d} is not a number (NaN).
Definition: qnumeric.cpp:55
The QGraphicsRotation class provides a rotation transformation around a given axis.

◆ axis()

QVector3D QGraphicsRotation::axis ( ) const

Referenced by setAngle(), and setAxis().

◆ axisChanged

void QGraphicsRotation::axisChanged ( )
signal

This signal is emitted whenever the axis of the object changes.

See also
QGraphicsRotation::axis

Referenced by setAxis().

◆ origin()

QVector3D QGraphicsRotation::origin ( ) const

Referenced by ~QGraphicsRotation().

◆ originChanged

QGraphicsRotation::originChanged ( )
signal

This signal is emitted whenever the origin has changed.

See also
QGraphicsRotation::origin

Referenced by setOrigin().

◆ setAngle()

void QGraphicsRotation::setAngle ( qreal  angle)

Definition at line 522 of file qgraphicstransform.cpp.

523 {
525  if (d->angle == angle)
526  return;
527  d->angle = angle;
528  update();
529  emit angleChanged();
530 }
double d
Definition: qnumeric_p.h:62
void update()
Notifies that this transform operation has changed its parameters in such a way that applyTo() will r...
qreal angle() const
void angleChanged()
This signal is emitted whenever the angle has changed.
#define Q_D(Class)
Definition: qglobal.h:2482
#define emit
Definition: qobjectdefs.h:76
The QGraphicsRotation class provides a rotation transformation around a given axis.

◆ setAxis() [1/2]

void QGraphicsRotation::setAxis ( const QVector3D axis)

Definition at line 574 of file qgraphicstransform.cpp.

Referenced by setAxis().

575 {
577  if (d->axis == axis)
578  return;
579  d->axis = axis;
580  update();
581  emit axisChanged();
582 }
double d
Definition: qnumeric_p.h:62
void update()
Notifies that this transform operation has changed its parameters in such a way that applyTo() will r...
#define Q_D(Class)
Definition: qglobal.h:2482
void axisChanged()
This signal is emitted whenever the axis of the object changes.
#define emit
Definition: qobjectdefs.h:76
The QGraphicsRotation class provides a rotation transformation around a given axis.
QVector3D axis() const

◆ setAxis() [2/2]

void QGraphicsRotation::setAxis ( Qt::Axis  axis)

Convenience function to set the axis to axis.

Note: the Qt::YAxis rotation for QTransform is inverted from the correct mathematical rotation in 3D space. The QGraphicsRotation class implements a correct mathematical rotation. The following two sequences of code will perform the same transformation:

Definition at line 606 of file qgraphicstransform.cpp.

607 {
608  switch (axis)
609  {
610  case Qt::XAxis:
611  setAxis(QVector3D(1, 0, 0));
612  break;
613  case Qt::YAxis:
614  setAxis(QVector3D(0, 1, 0));
615  break;
616  case Qt::ZAxis:
617  setAxis(QVector3D(0, 0, 1));
618  break;
619  }
620 }
The QVector3D class represents a vector or vertex in 3D space.
Definition: qvector3d.h:60
void setAxis(const QVector3D &axis)
QVector3D axis() const

◆ setOrigin()

void QGraphicsRotation::setOrigin ( const QVector3D point)

Definition at line 491 of file qgraphicstransform.cpp.

492 {
494  if (d->origin == point)
495  return;
496  d->origin = point;
497  update();
499 }
double d
Definition: qnumeric_p.h:62
void update()
Notifies that this transform operation has changed its parameters in such a way that applyTo() will r...
#define Q_D(Class)
Definition: qglobal.h:2482
#define emit
Definition: qobjectdefs.h:76
The QGraphicsRotation class provides a rotation transformation around a given axis.
void originChanged()
This signal is emitted whenever the origin has changed.

Properties

◆ angle

qreal QGraphicsRotation::angle
private

the angle for clockwise rotation, in degrees.

The angle can be any real number; the default value is 0.0. A value of 180 will rotate 180 degrees, clockwise. If you provide a negative number, the item will be rotated counter-clockwise. Normally the rotation angle will be in the range (-360, 360), but you can also provide numbers outside of this range (e.g., a angle of 370 degrees gives the same result as 10 degrees). Setting the angle to NaN results in no rotation.

See also
origin

Definition at line 127 of file qgraphicstransform.h.

◆ axis

QVector3D QGraphicsRotation::axis
private

a rotation axis, specified by a vector in 3D space.

This can be any axis in 3D space. By default the axis is (0, 0, 1), which is aligned with the Z axis. If you provide another axis, QGraphicsRotation will provide a transformation that rotates around this axis. For example, if you would like to rotate an item around its X axis, you could pass (1, 0, 0) as the axis.

See also
QTransform, QGraphicsRotation::angle

Definition at line 128 of file qgraphicstransform.h.

◆ origin

QVector3D QGraphicsRotation::origin
private

the origin of the rotation in 3D space.

All rotations will be done relative to this point (i.e., this point will stay fixed, relative to the parent, when the item is rotated).

See also
angle

Definition at line 126 of file qgraphicstransform.h.


The documentation for this class was generated from the following files: