Coordinate Transformation
| world corrdinates |
=> |
window coordinates |
=> |
device coordinates |
| ( logical coordinate ) |
world change |
intermediate state coordinate |
window view transformation |
( physical coordinate ) |
By default,3Coordinate Systems are consistent.
World change
Functions directly related to world transformations:
Qpainter: setworldmatrixenabled |
Enable or disable world Transform |
Qpainter: setworldtransform |
Set world change |
Qpainter: worldtransform |
Get current |
Qpainter: resettransform |
ResetQtransform () |
4Common functions
Qpainter: Translate |
Translation |
Qpainter: Scale |
Zoom |
Qpainter: Rotate |
Rotate |
Qpainter: Shear |
Cut |
Note: they are directly calledQtransformDirectly modify the world change
Void qpainter: Scale (qreal Sx, qreal SY)
{
...
D-> state-> worldmatrix. Scale (sx, Sy );
...
}
Two world-changing vests:
Qpainter: settransform
Qpainter: Transform
Void qpainter: settransform (const qtransform & transform, bool combine)
{
Setworldtransform (transform, combine );
}
Obsolete Functions(SlaveQt4.3Start,QtransformReplacedQmatrixIs not recommended for the following functions):
Qpainter: setworldmatrix
Qpainter: worldmatrix
...
Window-view Transformation
Direct correlation:
Qpainter: setviewtransformenabled |
Enable or disable the view transform function |
Qpainter: viewtransformenabled |
Returns the status of the viewport transform. |
Qpainter: setviewport |
Set the viewport (physical coordinates) |
Qpainter: setwindow |
Set the window (the same rectangle and intermediate state coordinates as the viewport) |
This transformation is a simple linear transformation.
Compound Transformation
Combination of window-view transformation and world Transformation:
Qpainter: combinedtransform
Qtransform qpainter: combinedtransform () const
{
Q_d (const qpainter );
Return D-> state-> worldmatrix * D-> viewtransform ();
}
Typical application: converts coordinates from physical coordinatesQpainterRequired logical coordinates
Affine Transformation and transmission Transformation
Qt4.3 (Including)PreviousQmatrixOnly supports Affine Transformation(Affine transformation).
Translation(Translation)
Zoom (Scale)
Rotate (Rotation)
Cut(Shear)
QtransformTransmission transformation supported(Perspective transformation).
M11 |
M12 |
M13 |
M21 |
M22 |
M23 |
M31 DX |
M32 Dy |
M33 |
Conversion Relationship:
X' = M11 * x + m21 * Y + dx
Y' = m22 * Y + M12 * x + dy
If (is not affine)
{
W' = M13 * x + M23 * Y + M33
X'/= W'
Y'/= W'
}
Related Knowledge:
Projection Geometry, affine geometry, and differential geometry
Reference
Http://doc.qt.nokia.com/4.7/qtransform.html
Http://doc.qt.nokia.com/4.7/qpainter.html
Http://doc.qt.nokia.com/4.7/coordsys.html