Struct qt_gui::QTransform
source · #[repr(C)]pub struct QTransform { /* private fields */ }
Expand description
The QTransform class specifies 2D transformations of a coordinate system.
C++ class: QTransform
.
The QTransform class specifies 2D transformations of a coordinate system.
A transformation specifies how to translate, scale, shear, rotate or project the coordinate system, and is typically used when rendering graphics.
QTransform differs from QMatrix in that it is a true 3x3 matrix, allowing perspective transformations. QTransform's toAffine() method allows casting QTransform to QMatrix. If a perspective transformation has been specified on the matrix, then the conversion will cause loss of data.
QTransform is the recommended transformation class in Qt.
A QTransform object can be built using the setMatrix(), scale(), rotate(), translate() and shear() functions. Alternatively, it can be built by applying basic matrix operations. The matrix can also be defined when constructed, and it can be reset to the identity matrix (the default) using the reset() function.
The QTransform class supports mapping of graphic primitives: A given point, line, polygon, region, or painter path can be mapped to the coordinate system defined by this matrix using the map() function. In case of a rectangle, its coordinates can be transformed using the mapRect() function. A rectangle can also be transformed into a polygon (mapped to the coordinate system defined by this matrix), using the mapToPolygon() function.
QTransform provides the isIdentity() function which returns true
if the matrix is the identity matrix, and the isInvertible() function which returns true
if the matrix is non-singular (i.e. AB = BA = I). The inverted() function returns an inverted copy of this matrix if it is invertible (otherwise it returns the identity matrix), and adjoint() returns the matrix's classical adjoint. In addition, QTransform provides the determinant() function which returns the matrix's determinant.
Finally, the QTransform class supports matrix multiplication, addition and subtraction, and objects of the class can be streamed as well as compared.
Implementations§
source§impl QTransform
impl QTransform
sourcepub unsafe fn add_assign(&self, div: c_double) -> Ref<QTransform>
pub unsafe fn add_assign(&self, div: c_double) -> Ref<QTransform>
This is an overloaded function.
Calls C++ function: QTransform& QTransform::operator+=(double div)
.
This is an overloaded function.
Returns the matrix obtained by adding the given scalar to each element of this matrix.
sourcepub unsafe fn adjoint(&self) -> CppBox<QTransform>
pub unsafe fn adjoint(&self) -> CppBox<QTransform>
Returns the adjoint of this matrix.
Calls C++ function: QTransform QTransform::adjoint() const
.
Returns the adjoint of this matrix.
sourcepub unsafe fn copy_from(
&self,
arg1: impl CastInto<Ref<QTransform>>
) -> Ref<QTransform>
pub unsafe fn copy_from( &self, arg1: impl CastInto<Ref<QTransform>> ) -> Ref<QTransform>
Assigns the given matrix's values to this matrix.
Calls C++ function: QTransform& QTransform::operator=(const QTransform& arg1)
.
Assigns the given matrix’s values to this matrix.
sourcepub unsafe fn det(&self) -> c_double
pub unsafe fn det(&self) -> c_double
Returns the matrix's determinant. Use determinant() instead.
Calls C++ function: double QTransform::det() const
.
Returns the matrix’s determinant. Use determinant() instead.
sourcepub unsafe fn determinant(&self) -> c_double
pub unsafe fn determinant(&self) -> c_double
Returns the matrix's determinant.
Calls C++ function: double QTransform::determinant() const
.
Returns the matrix’s determinant.
sourcepub unsafe fn div_assign(&self, div: c_double) -> Ref<QTransform>
pub unsafe fn div_assign(&self, div: c_double) -> Ref<QTransform>
This is an overloaded function.
Calls C++ function: QTransform& QTransform::operator/=(double div)
.
This is an overloaded function.
Returns the result of performing an element-wise division of this matrix by the given scalar.
sourcepub unsafe fn dx(&self) -> c_double
pub unsafe fn dx(&self) -> c_double
Returns the horizontal translation factor.
Calls C++ function: double QTransform::dx() const
.
Returns the horizontal translation factor.
See also m31(), translate(), and Basic Matrix Operations.
sourcepub unsafe fn dy(&self) -> c_double
pub unsafe fn dy(&self) -> c_double
Returns the vertical translation factor.
Calls C++ function: double QTransform::dy() const
.
Returns the vertical translation factor.
See also translate() and Basic Matrix Operations.
sourcepub unsafe fn from_scale(dx: c_double, dy: c_double) -> CppBox<QTransform>
pub unsafe fn from_scale(dx: c_double, dy: c_double) -> CppBox<QTransform>
Creates a matrix which corresponds to a scaling of sx horizontally and sy vertically. This is the same as QTransform().scale(sx, sy) but slightly faster.
Calls C++ function: static QTransform QTransform::fromScale(double dx, double dy)
.
Creates a matrix which corresponds to a scaling of sx horizontally and sy vertically. This is the same as QTransform().scale(sx, sy) but slightly faster.
This function was introduced in Qt 4.5.
sourcepub unsafe fn from_translate(dx: c_double, dy: c_double) -> CppBox<QTransform>
pub unsafe fn from_translate(dx: c_double, dy: c_double) -> CppBox<QTransform>
Creates a matrix which corresponds to a translation of dx along the x axis and dy along the y axis. This is the same as QTransform().translate(dx, dy) but slightly faster.
Calls C++ function: static QTransform QTransform::fromTranslate(double dx, double dy)
.
Creates a matrix which corresponds to a translation of dx along the x axis and dy along the y axis. This is the same as QTransform().translate(dx, dy) but slightly faster.
This function was introduced in Qt 4.5.
sourcepub unsafe fn inverted_1a(&self, invertible: *mut bool) -> CppBox<QTransform>
pub unsafe fn inverted_1a(&self, invertible: *mut bool) -> CppBox<QTransform>
Returns an inverted copy of this matrix.
Calls C++ function: QTransform QTransform::inverted(bool* invertible = …) const
.
Returns an inverted copy of this matrix.
If the matrix is singular (not invertible), the returned matrix is the identity matrix. If invertible is valid (i.e. not 0), its value is set to true if the matrix is invertible, otherwise it is set to false.
See also isInvertible().
sourcepub unsafe fn inverted_0a(&self) -> CppBox<QTransform>
pub unsafe fn inverted_0a(&self) -> CppBox<QTransform>
Returns an inverted copy of this matrix.
Calls C++ function: QTransform QTransform::inverted() const
.
Returns an inverted copy of this matrix.
If the matrix is singular (not invertible), the returned matrix is the identity matrix. If invertible is valid (i.e. not 0), its value is set to true if the matrix is invertible, otherwise it is set to false.
See also isInvertible().
sourcepub unsafe fn is_affine(&self) -> bool
pub unsafe fn is_affine(&self) -> bool
Returns true
if the matrix represent an affine transformation, otherwise returns false
.
Calls C++ function: bool QTransform::isAffine() const
.
Returns true
if the matrix represent an affine transformation, otherwise returns false
.
sourcepub unsafe fn is_identity(&self) -> bool
pub unsafe fn is_identity(&self) -> bool
Returns true
if the matrix is the identity matrix, otherwise returns false
.
Calls C++ function: bool QTransform::isIdentity() const
.
Returns true
if the matrix is the identity matrix, otherwise returns false
.
See also reset().
sourcepub unsafe fn is_invertible(&self) -> bool
pub unsafe fn is_invertible(&self) -> bool
Returns true
if the matrix is invertible, otherwise returns false
.
Calls C++ function: bool QTransform::isInvertible() const
.
Returns true
if the matrix is invertible, otherwise returns false
.
See also inverted().
sourcepub unsafe fn is_rotating(&self) -> bool
pub unsafe fn is_rotating(&self) -> bool
Returns true
if the matrix represents some kind of a rotating transformation, otherwise returns false
.
Calls C++ function: bool QTransform::isRotating() const
.
Returns true
if the matrix represents some kind of a rotating transformation, otherwise returns false
.
Note: A rotation transformation of 180 degrees and/or 360 degrees is treated as a scaling transformation.
See also reset().
sourcepub unsafe fn is_scaling(&self) -> bool
pub unsafe fn is_scaling(&self) -> bool
Returns true
if the matrix represents a scaling transformation, otherwise returns false
.
Calls C++ function: bool QTransform::isScaling() const
.
Returns true
if the matrix represents a scaling transformation, otherwise returns false
.
See also reset().
sourcepub unsafe fn is_translating(&self) -> bool
pub unsafe fn is_translating(&self) -> bool
Returns true
if the matrix represents a translating transformation, otherwise returns false
.
Calls C++ function: bool QTransform::isTranslating() const
.
Returns true
if the matrix represents a translating transformation, otherwise returns false
.
See also reset().
sourcepub unsafe fn m11(&self) -> c_double
pub unsafe fn m11(&self) -> c_double
Returns the horizontal scaling factor.
Calls C++ function: double QTransform::m11() const
.
Returns the horizontal scaling factor.
See also scale() and Basic Matrix Operations.
sourcepub unsafe fn m12(&self) -> c_double
pub unsafe fn m12(&self) -> c_double
Returns the vertical shearing factor.
Calls C++ function: double QTransform::m12() const
.
Returns the vertical shearing factor.
See also shear() and Basic Matrix Operations.
sourcepub unsafe fn m13(&self) -> c_double
pub unsafe fn m13(&self) -> c_double
Returns the horizontal projection factor.
Calls C++ function: double QTransform::m13() const
.
Returns the horizontal projection factor.
See also translate() and Basic Matrix Operations.
sourcepub unsafe fn m21(&self) -> c_double
pub unsafe fn m21(&self) -> c_double
Returns the horizontal shearing factor.
Calls C++ function: double QTransform::m21() const
.
Returns the horizontal shearing factor.
See also shear() and Basic Matrix Operations.
sourcepub unsafe fn m22(&self) -> c_double
pub unsafe fn m22(&self) -> c_double
Returns the vertical scaling factor.
Calls C++ function: double QTransform::m22() const
.
Returns the vertical scaling factor.
See also scale() and Basic Matrix Operations.
sourcepub unsafe fn m23(&self) -> c_double
pub unsafe fn m23(&self) -> c_double
Returns the vertical projection factor.
Calls C++ function: double QTransform::m23() const
.
Returns the vertical projection factor.
See also translate() and Basic Matrix Operations.
sourcepub unsafe fn m31(&self) -> c_double
pub unsafe fn m31(&self) -> c_double
Returns the horizontal translation factor.
Calls C++ function: double QTransform::m31() const
.
Returns the horizontal translation factor.
See also dx(), translate(), and Basic Matrix Operations.
sourcepub unsafe fn m32(&self) -> c_double
pub unsafe fn m32(&self) -> c_double
Returns the vertical translation factor.
Calls C++ function: double QTransform::m32() const
.
Returns the vertical translation factor.
See also dy(), translate(), and Basic Matrix Operations.
sourcepub unsafe fn m33(&self) -> c_double
pub unsafe fn m33(&self) -> c_double
Returns the division factor.
Calls C++ function: double QTransform::m33() const
.
Returns the division factor.
See also translate() and Basic Matrix Operations.
sourcepub unsafe fn map_q_point(
&self,
p: impl CastInto<Ref<QPoint>>
) -> CppBox<QPoint>
pub unsafe fn map_q_point( &self, p: impl CastInto<Ref<QPoint>> ) -> CppBox<QPoint>
This is an overloaded function.
Calls C++ function: QPoint QTransform::map(const QPoint& p) const
.
This is an overloaded function.
Creates and returns a QPoint object that is a copy of the given point, mapped into the coordinate system defined by this matrix. Note that the transformed coordinates are rounded to the nearest integer.
sourcepub unsafe fn map_q_point_f(
&self,
p: impl CastInto<Ref<QPointF>>
) -> CppBox<QPointF>
pub unsafe fn map_q_point_f( &self, p: impl CastInto<Ref<QPointF>> ) -> CppBox<QPointF>
This is an overloaded function.
Calls C++ function: QPointF QTransform::map(const QPointF& p) const
.
This is an overloaded function.
Creates and returns a QPointF object that is a copy of the given point, p, mapped into the coordinate system defined by this matrix.
sourcepub unsafe fn map_q_line(&self, l: impl CastInto<Ref<QLine>>) -> CppBox<QLine>
pub unsafe fn map_q_line(&self, l: impl CastInto<Ref<QLine>>) -> CppBox<QLine>
This is an overloaded function.
Calls C++ function: QLine QTransform::map(const QLine& l) const
.
This is an overloaded function.
Creates and returns a QLineF object that is a copy of the given line, l, mapped into the coordinate system defined by this matrix.
sourcepub unsafe fn map_q_line_f(
&self,
l: impl CastInto<Ref<QLineF>>
) -> CppBox<QLineF>
pub unsafe fn map_q_line_f( &self, l: impl CastInto<Ref<QLineF>> ) -> CppBox<QLineF>
This is an overloaded function.
Calls C++ function: QLineF QTransform::map(const QLineF& l) const
.
This is an overloaded function.
Creates and returns a QLine object that is a copy of the given line, mapped into the coordinate system defined by this matrix. Note that the transformed coordinates are rounded to the nearest integer.
sourcepub unsafe fn map_q_polygon_f(
&self,
a: impl CastInto<Ref<QPolygonF>>
) -> CppBox<QPolygonF>
pub unsafe fn map_q_polygon_f( &self, a: impl CastInto<Ref<QPolygonF>> ) -> CppBox<QPolygonF>
This is an overloaded function.
Calls C++ function: QPolygonF QTransform::map(const QPolygonF& a) const
.
This is an overloaded function.
Creates and returns a QPolygonF object that is a copy of the given polygon, mapped into the coordinate system defined by this matrix.
sourcepub unsafe fn map_q_polygon(
&self,
a: impl CastInto<Ref<QPolygon>>
) -> CppBox<QPolygon>
pub unsafe fn map_q_polygon( &self, a: impl CastInto<Ref<QPolygon>> ) -> CppBox<QPolygon>
This is an overloaded function.
Calls C++ function: QPolygon QTransform::map(const QPolygon& a) const
.
This is an overloaded function.
Creates and returns a QPolygon object that is a copy of the given polygon, mapped into the coordinate system defined by this matrix. Note that the transformed coordinates are rounded to the nearest integer.
sourcepub unsafe fn map_q_region(
&self,
r: impl CastInto<Ref<QRegion>>
) -> CppBox<QRegion>
pub unsafe fn map_q_region( &self, r: impl CastInto<Ref<QRegion>> ) -> CppBox<QRegion>
This is an overloaded function.
Calls C++ function: QRegion QTransform::map(const QRegion& r) const
.
This is an overloaded function.
Creates and returns a QRegion object that is a copy of the given region, mapped into the coordinate system defined by this matrix.
Calling this method can be rather expensive if rotations or shearing are used.
sourcepub unsafe fn map_q_painter_path(
&self,
p: impl CastInto<Ref<QPainterPath>>
) -> CppBox<QPainterPath>
pub unsafe fn map_q_painter_path( &self, p: impl CastInto<Ref<QPainterPath>> ) -> CppBox<QPainterPath>
This is an overloaded function.
Calls C++ function: QPainterPath QTransform::map(const QPainterPath& p) const
.
This is an overloaded function.
Creates and returns a QPainterPath object that is a copy of the given path, mapped into the coordinate system defined by this matrix.
sourcepub unsafe fn map_2_int2_int(
&self,
x: c_int,
y: c_int,
tx: *mut c_int,
ty: *mut c_int
)
pub unsafe fn map_2_int2_int( &self, x: c_int, y: c_int, tx: *mut c_int, ty: *mut c_int )
This is an overloaded function.
Calls C++ function: void QTransform::map(int x, int y, int* tx, int* ty) const
.
This is an overloaded function.
Maps the given coordinates x and y into the coordinate system defined by this matrix. The resulting values are put in *tx and *ty, respectively. Note that the transformed coordinates are rounded to the nearest integer.
sourcepub unsafe fn map_2_double2_double(
&self,
x: c_double,
y: c_double,
tx: *mut c_double,
ty: *mut c_double
)
pub unsafe fn map_2_double2_double( &self, x: c_double, y: c_double, tx: *mut c_double, ty: *mut c_double )
Maps the given coordinates x and y into the coordinate system defined by this matrix. The resulting values are put in *tx and *ty, respectively.
Calls C++ function: void QTransform::map(double x, double y, double* tx, double* ty) const
.
Maps the given coordinates x and y into the coordinate system defined by this matrix. The resulting values are put in *tx and *ty, respectively.
The coordinates are transformed using the following formulas:
x’ = m11x + m21y + dx y’ = m22y + m12x + dy if (is not affine) { w’ = m13x + m23y + m33 x’ /= w’ y’ /= w’ }
The point (x, y) is the original point, and (x', y') is the transformed point.
See also Basic Matrix Operations.
sourcepub unsafe fn map_rect_q_rect(
&self,
arg1: impl CastInto<Ref<QRect>>
) -> CppBox<QRect>
pub unsafe fn map_rect_q_rect( &self, arg1: impl CastInto<Ref<QRect>> ) -> CppBox<QRect>
This is an overloaded function.
Calls C++ function: QRect QTransform::mapRect(const QRect& arg1) const
.
This is an overloaded function.
Creates and returns a QRect object that is a copy of the given rectangle, mapped into the coordinate system defined by this matrix. Note that the transformed coordinates are rounded to the nearest integer.
sourcepub unsafe fn map_rect_q_rect_f(
&self,
arg1: impl CastInto<Ref<QRectF>>
) -> CppBox<QRectF>
pub unsafe fn map_rect_q_rect_f( &self, arg1: impl CastInto<Ref<QRectF>> ) -> CppBox<QRectF>
Creates and returns a QRectF object that is a copy of the given rectangle, mapped into the coordinate system defined by this matrix.
Calls C++ function: QRectF QTransform::mapRect(const QRectF& arg1) const
.
Creates and returns a QRectF object that is a copy of the given rectangle, mapped into the coordinate system defined by this matrix.
The rectangle's coordinates are transformed using the following formulas:
x’ = m11x + m21y + dx y’ = m22y + m12x + dy if (is not affine) { w’ = m13x + m23y + m33 x’ /= w’ y’ /= w’ }
If rotation or shearing has been specified, this function returns the bounding rectangle. To retrieve the exact region the given rectangle maps to, use the mapToPolygon() function instead.
See also mapToPolygon() and Basic Matrix Operations.
sourcepub unsafe fn map_to_polygon(
&self,
r: impl CastInto<Ref<QRect>>
) -> CppBox<QPolygon>
pub unsafe fn map_to_polygon( &self, r: impl CastInto<Ref<QRect>> ) -> CppBox<QPolygon>
Creates and returns a QPolygon representation of the given rectangle, mapped into the coordinate system defined by this matrix.
Calls C++ function: QPolygon QTransform::mapToPolygon(const QRect& r) const
.
Creates and returns a QPolygon representation of the given rectangle, mapped into the coordinate system defined by this matrix.
The rectangle's coordinates are transformed using the following formulas:
x’ = m11x + m21y + dx y’ = m22y + m12x + dy if (is not affine) { w’ = m13x + m23y + m33 x’ /= w’ y’ /= w’ }
Polygons and rectangles behave slightly differently when transformed (due to integer rounding), so matrix.map(QPolygon(rectangle))
is not always the same as matrix.mapToPolygon(rectangle)
.
See also mapRect() and Basic Matrix Operations.
sourcepub unsafe fn mul_assign_q_transform(
&self,
arg1: impl CastInto<Ref<QTransform>>
) -> Ref<QTransform>
pub unsafe fn mul_assign_q_transform( &self, arg1: impl CastInto<Ref<QTransform>> ) -> Ref<QTransform>
This is an overloaded function.
Calls C++ function: QTransform& QTransform::operator*=(const QTransform& arg1)
.
This is an overloaded function.
Returns the result of multiplying this matrix by the given matrix.
sourcepub unsafe fn mul_assign_double(&self, div: c_double) -> Ref<QTransform>
pub unsafe fn mul_assign_double(&self, div: c_double) -> Ref<QTransform>
This is an overloaded function.
Calls C++ function: QTransform& QTransform::operator*=(double div)
.
This is an overloaded function.
Returns the result of performing an element-wise multiplication of this matrix with the given scalar.
sourcepub unsafe fn new_0a() -> CppBox<QTransform>
pub unsafe fn new_0a() -> CppBox<QTransform>
Constructs an identity matrix.
Calls C++ function: [constructor] void QTransform::QTransform()
.
Constructs an identity matrix.
All elements are set to zero except m11
and m22
(specifying the scale) and m33
which are set to 1.
See also reset().
sourcepub unsafe fn new_9a(
h11: c_double,
h12: c_double,
h13: c_double,
h21: c_double,
h22: c_double,
h23: c_double,
h31: c_double,
h32: c_double,
h33: c_double
) -> CppBox<QTransform>
pub unsafe fn new_9a( h11: c_double, h12: c_double, h13: c_double, h21: c_double, h22: c_double, h23: c_double, h31: c_double, h32: c_double, h33: c_double ) -> CppBox<QTransform>
Constructs a matrix with the elements, m11, m12, m13, m21, m22, m23, m31, m32, m33.
Calls C++ function: [constructor] void QTransform::QTransform(double h11, double h12, double h13, double h21, double h22, double h23, double h31, double h32, double h33 = …)
.
Constructs a matrix with the elements, m11, m12, m13, m21, m22, m23, m31, m32, m33.
See also setMatrix().
sourcepub unsafe fn new_6a(
h11: c_double,
h12: c_double,
h21: c_double,
h22: c_double,
dx: c_double,
dy: c_double
) -> CppBox<QTransform>
pub unsafe fn new_6a( h11: c_double, h12: c_double, h21: c_double, h22: c_double, dx: c_double, dy: c_double ) -> CppBox<QTransform>
Constructs a matrix with the elements, m11, m12, m21, m22, dx and dy.
Calls C++ function: [constructor] void QTransform::QTransform(double h11, double h12, double h21, double h22, double dx, double dy)
.
Constructs a matrix with the elements, m11, m12, m21, m22, dx and dy.
See also setMatrix().
sourcepub unsafe fn new_1a(mtx: impl CastInto<Ref<QMatrix>>) -> CppBox<QTransform>
pub unsafe fn new_1a(mtx: impl CastInto<Ref<QMatrix>>) -> CppBox<QTransform>
Constructs a matrix that is a copy of the given matrix. Note that the m13
, m23
, and m33
elements are set to 0, 0, and 1 respectively.
Calls C++ function: [constructor] void QTransform::QTransform(const QMatrix& mtx)
.
Constructs a matrix that is a copy of the given matrix. Note that the m13
, m23
, and m33
elements are set to 0, 0, and 1 respectively.
sourcepub unsafe fn new_8a(
h11: c_double,
h12: c_double,
h13: c_double,
h21: c_double,
h22: c_double,
h23: c_double,
h31: c_double,
h32: c_double
) -> CppBox<QTransform>
pub unsafe fn new_8a( h11: c_double, h12: c_double, h13: c_double, h21: c_double, h22: c_double, h23: c_double, h31: c_double, h32: c_double ) -> CppBox<QTransform>
Constructs a matrix with the elements, m11, m12, m13, m21, m22, m23, m31, m32, m33.
Calls C++ function: [constructor] void QTransform::QTransform(double h11, double h12, double h13, double h21, double h22, double h23, double h31, double h32)
.
Constructs a matrix with the elements, m11, m12, m13, m21, m22, m23, m31, m32, m33.
See also setMatrix().
sourcepub unsafe fn new_copy(
other: impl CastInto<Ref<QTransform>>
) -> CppBox<QTransform>
pub unsafe fn new_copy( other: impl CastInto<Ref<QTransform>> ) -> CppBox<QTransform>
Copy constructor.
Calls C++ function: [constructor] void QTransform::QTransform(const QTransform& other)
.
Copy constructor.
sourcepub unsafe fn quad_to_quad(
one: impl CastInto<Ref<QPolygonF>>,
two: impl CastInto<Ref<QPolygonF>>,
result: impl CastInto<Ref<QTransform>>
) -> bool
pub unsafe fn quad_to_quad( one: impl CastInto<Ref<QPolygonF>>, two: impl CastInto<Ref<QPolygonF>>, result: impl CastInto<Ref<QTransform>> ) -> bool
Creates a transformation matrix, trans, that maps a four-sided polygon, one, to another four-sided polygon, two. Returns true
if the transformation is possible; otherwise returns false.
Calls C++ function: static bool QTransform::quadToQuad(const QPolygonF& one, const QPolygonF& two, QTransform& result)
.
Creates a transformation matrix, trans, that maps a four-sided polygon, one, to another four-sided polygon, two. Returns true
if the transformation is possible; otherwise returns false.
This is a convenience method combining quadToSquare() and squareToQuad() methods. It allows the input quad to be transformed into any other quad.
See also squareToQuad() and quadToSquare().
sourcepub unsafe fn quad_to_square(
quad: impl CastInto<Ref<QPolygonF>>,
result: impl CastInto<Ref<QTransform>>
) -> bool
pub unsafe fn quad_to_square( quad: impl CastInto<Ref<QPolygonF>>, result: impl CastInto<Ref<QTransform>> ) -> bool
Creates a transformation matrix, trans, that maps a four-sided polygon, quad, to a unit square. Returns true
if the transformation is constructed or false if such a transformation does not exist.
Calls C++ function: static bool QTransform::quadToSquare(const QPolygonF& quad, QTransform& result)
.
Creates a transformation matrix, trans, that maps a four-sided polygon, quad, to a unit square. Returns true
if the transformation is constructed or false if such a transformation does not exist.
See also squareToQuad() and quadToQuad().
sourcepub unsafe fn reset(&self)
pub unsafe fn reset(&self)
Resets the matrix to an identity matrix, i.e. all elements are set to zero, except m11
and m22
(specifying the scale) and m33
which are set to 1.
Calls C++ function: void QTransform::reset()
.
Resets the matrix to an identity matrix, i.e. all elements are set to zero, except m11
and m22
(specifying the scale) and m33
which are set to 1.
See also QTransform(), isIdentity(), and Basic Matrix Operations.
sourcepub unsafe fn rotate_2a(&self, a: c_double, axis: Axis) -> Ref<QTransform>
pub unsafe fn rotate_2a(&self, a: c_double, axis: Axis) -> Ref<QTransform>
Rotates the coordinate system counterclockwise by the given angle about the specified axis and returns a reference to the matrix.
Calls C++ function: QTransform& QTransform::rotate(double a, Qt::Axis axis = …)
.
Rotates the coordinate system counterclockwise by the given angle about the specified axis and returns a reference to the matrix.
Note that if you apply a QTransform to a point defined in widget coordinates, the direction of the rotation will be clockwise because the y-axis points downwards.
The angle is specified in degrees.
See also setMatrix().
sourcepub unsafe fn rotate_1a(&self, a: c_double) -> Ref<QTransform>
pub unsafe fn rotate_1a(&self, a: c_double) -> Ref<QTransform>
Rotates the coordinate system counterclockwise by the given angle about the specified axis and returns a reference to the matrix.
Calls C++ function: QTransform& QTransform::rotate(double a)
.
Rotates the coordinate system counterclockwise by the given angle about the specified axis and returns a reference to the matrix.
Note that if you apply a QTransform to a point defined in widget coordinates, the direction of the rotation will be clockwise because the y-axis points downwards.
The angle is specified in degrees.
See also setMatrix().
sourcepub unsafe fn rotate_radians_2a(
&self,
a: c_double,
axis: Axis
) -> Ref<QTransform>
pub unsafe fn rotate_radians_2a( &self, a: c_double, axis: Axis ) -> Ref<QTransform>
Rotates the coordinate system counterclockwise by the given angle about the specified axis and returns a reference to the matrix.
Calls C++ function: QTransform& QTransform::rotateRadians(double a, Qt::Axis axis = …)
.
Rotates the coordinate system counterclockwise by the given angle about the specified axis and returns a reference to the matrix.
Note that if you apply a QTransform to a point defined in widget coordinates, the direction of the rotation will be clockwise because the y-axis points downwards.
The angle is specified in radians.
See also setMatrix().
sourcepub unsafe fn rotate_radians_1a(&self, a: c_double) -> Ref<QTransform>
pub unsafe fn rotate_radians_1a(&self, a: c_double) -> Ref<QTransform>
Rotates the coordinate system counterclockwise by the given angle about the specified axis and returns a reference to the matrix.
Calls C++ function: QTransform& QTransform::rotateRadians(double a)
.
Rotates the coordinate system counterclockwise by the given angle about the specified axis and returns a reference to the matrix.
Note that if you apply a QTransform to a point defined in widget coordinates, the direction of the rotation will be clockwise because the y-axis points downwards.
The angle is specified in radians.
See also setMatrix().
sourcepub unsafe fn scale(&self, sx: c_double, sy: c_double) -> Ref<QTransform>
pub unsafe fn scale(&self, sx: c_double, sy: c_double) -> Ref<QTransform>
Scales the coordinate system by sx horizontally and sy vertically, and returns a reference to the matrix.
Calls C++ function: QTransform& QTransform::scale(double sx, double sy)
.
Scales the coordinate system by sx horizontally and sy vertically, and returns a reference to the matrix.
See also setMatrix().
sourcepub unsafe fn set_matrix(
&self,
m11: c_double,
m12: c_double,
m13: c_double,
m21: c_double,
m22: c_double,
m23: c_double,
m31: c_double,
m32: c_double,
m33: c_double
)
pub unsafe fn set_matrix( &self, m11: c_double, m12: c_double, m13: c_double, m21: c_double, m22: c_double, m23: c_double, m31: c_double, m32: c_double, m33: c_double )
Sets the matrix elements to the specified values, m11, m12, m13 m21, m22, m23 m31, m32 and m33. Note that this function replaces the previous values. QTransform provides the translate(), rotate(), scale() and shear() convenience functions to manipulate the various matrix elements based on the currently defined coordinate system.
Calls C++ function: void QTransform::setMatrix(double m11, double m12, double m13, double m21, double m22, double m23, double m31, double m32, double m33)
.
Sets the matrix elements to the specified values, m11, m12, m13 m21, m22, m23 m31, m32 and m33. Note that this function replaces the previous values. QTransform provides the translate(), rotate(), scale() and shear() convenience functions to manipulate the various matrix elements based on the currently defined coordinate system.
See also QTransform().
sourcepub unsafe fn shear(&self, sh: c_double, sv: c_double) -> Ref<QTransform>
pub unsafe fn shear(&self, sh: c_double, sv: c_double) -> Ref<QTransform>
Shears the coordinate system by sh horizontally and sv vertically, and returns a reference to the matrix.
Calls C++ function: QTransform& QTransform::shear(double sh, double sv)
.
Shears the coordinate system by sh horizontally and sv vertically, and returns a reference to the matrix.
See also setMatrix().
sourcepub unsafe fn square_to_quad(
square: impl CastInto<Ref<QPolygonF>>,
result: impl CastInto<Ref<QTransform>>
) -> bool
pub unsafe fn square_to_quad( square: impl CastInto<Ref<QPolygonF>>, result: impl CastInto<Ref<QTransform>> ) -> bool
Creates a transformation matrix, trans, that maps a unit square to a four-sided polygon, quad. Returns true
if the transformation is constructed or false if such a transformation does not exist.
Calls C++ function: static bool QTransform::squareToQuad(const QPolygonF& square, QTransform& result)
.
Creates a transformation matrix, trans, that maps a unit square to a four-sided polygon, quad. Returns true
if the transformation is constructed or false if such a transformation does not exist.
See also quadToSquare() and quadToQuad().
sourcepub unsafe fn sub_assign(&self, div: c_double) -> Ref<QTransform>
pub unsafe fn sub_assign(&self, div: c_double) -> Ref<QTransform>
This is an overloaded function.
Calls C++ function: QTransform& QTransform::operator-=(double div)
.
This is an overloaded function.
Returns the matrix obtained by subtracting the given scalar from each element of this matrix.
sourcepub unsafe fn to_affine(&self) -> Ref<QMatrix>
pub unsafe fn to_affine(&self) -> Ref<QMatrix>
Returns the QTransform as an affine matrix.
Calls C++ function: const QMatrix& QTransform::toAffine() const
.
Returns the QTransform as an affine matrix.
Warning: If a perspective transformation has been specified, then the conversion will cause loss of data.
sourcepub unsafe fn to_q_variant(&self) -> CppBox<QVariant>
pub unsafe fn to_q_variant(&self) -> CppBox<QVariant>
sourcepub unsafe fn translate(&self, dx: c_double, dy: c_double) -> Ref<QTransform>
pub unsafe fn translate(&self, dx: c_double, dy: c_double) -> Ref<QTransform>
Moves the coordinate system dx along the x axis and dy along the y axis, and returns a reference to the matrix.
Calls C++ function: QTransform& QTransform::translate(double dx, double dy)
.
Moves the coordinate system dx along the x axis and dy along the y axis, and returns a reference to the matrix.
See also setMatrix().
sourcepub unsafe fn transposed(&self) -> CppBox<QTransform>
pub unsafe fn transposed(&self) -> CppBox<QTransform>
Returns the transpose of this matrix.
Calls C++ function: QTransform QTransform::transposed() const
.
Returns the transpose of this matrix.
sourcepub unsafe fn type_(&self) -> TransformationType
pub unsafe fn type_(&self) -> TransformationType
Returns the transformation type of this matrix.
Calls C++ function: QTransform::TransformationType QTransform::type() const
.
Returns the transformation type of this matrix.
The transformation type is the highest enumeration value capturing all of the matrix's transformations. For example, if the matrix both scales and shears, the type would be TxShear
, because TxShear
has a higher enumeration value than TxScale
.
Knowing the transformation type of a matrix is useful for optimization: you can often handle specific types more optimally than handling the generic case.
Trait Implementations§
source§impl Add<f64> for &QTransform
impl Add<f64> for &QTransform
source§fn add(self, n: c_double) -> CppBox<QTransform>
fn add(self, n: c_double) -> CppBox<QTransform>
Calls C++ function: QTransform operator+(const QTransform& a, double n)
.
§type Output = CppBox<QTransform>
type Output = CppBox<QTransform>
+
operator.source§impl CppDeletable for QTransform
impl CppDeletable for QTransform
source§unsafe fn delete(&self)
unsafe fn delete(&self)
The QTransform class specifies 2D transformations of a coordinate system.
Calls C++ function: [destructor] void QTransform::~QTransform()
.
The QTransform class specifies 2D transformations of a coordinate system.
A transformation specifies how to translate, scale, shear, rotate or project the coordinate system, and is typically used when rendering graphics.
QTransform differs from QMatrix in that it is a true 3x3 matrix, allowing perspective transformations. QTransform's toAffine() method allows casting QTransform to QMatrix. If a perspective transformation has been specified on the matrix, then the conversion will cause loss of data.
QTransform is the recommended transformation class in Qt.
A QTransform object can be built using the setMatrix(), scale(), rotate(), translate() and shear() functions. Alternatively, it can be built by applying basic matrix operations. The matrix can also be defined when constructed, and it can be reset to the identity matrix (the default) using the reset() function.
The QTransform class supports mapping of graphic primitives: A given point, line, polygon, region, or painter path can be mapped to the coordinate system defined by this matrix using the map() function. In case of a rectangle, its coordinates can be transformed using the mapRect() function. A rectangle can also be transformed into a polygon (mapped to the coordinate system defined by this matrix), using the mapToPolygon() function.
QTransform provides the isIdentity() function which returns true
if the matrix is the identity matrix, and the isInvertible() function which returns true
if the matrix is non-singular (i.e. AB = BA = I). The inverted() function returns an inverted copy of this matrix if it is invertible (otherwise it returns the identity matrix), and adjoint() returns the matrix's classical adjoint. In addition, QTransform provides the determinant() function which returns the matrix's determinant.
Finally, the QTransform class supports matrix multiplication, addition and subtraction, and objects of the class can be streamed as well as compared.
source§impl Div<f64> for &QTransform
impl Div<f64> for &QTransform
source§fn div(self, n: c_double) -> CppBox<QTransform>
fn div(self, n: c_double) -> CppBox<QTransform>
Calls C++ function: QTransform operator/(const QTransform& a, double n)
.
§type Output = CppBox<QTransform>
type Output = CppBox<QTransform>
/
operator.source§impl Mul<Ref<QTransform>> for &QTransform
impl Mul<Ref<QTransform>> for &QTransform
source§fn mul(self, o: Ref<QTransform>) -> CppBox<QTransform>
fn mul(self, o: Ref<QTransform>) -> CppBox<QTransform>
Returns the result of multiplying this matrix by the given matrix.
Calls C++ function: QTransform QTransform::operator*(const QTransform& o) const
.
Returns the result of multiplying this matrix by the given matrix.
Note that matrix multiplication is not commutative, i.e. a*b != b*a.
§type Output = CppBox<QTransform>
type Output = CppBox<QTransform>
*
operator.source§impl Mul<f64> for &QTransform
impl Mul<f64> for &QTransform
source§fn mul(self, n: c_double) -> CppBox<QTransform>
fn mul(self, n: c_double) -> CppBox<QTransform>
Calls C++ function: QTransform operator*(const QTransform& a, double n)
.
§type Output = CppBox<QTransform>
type Output = CppBox<QTransform>
*
operator.source§impl PartialEq<Ref<QTransform>> for QTransform
impl PartialEq<Ref<QTransform>> for QTransform
source§impl Sub<f64> for &QTransform
impl Sub<f64> for &QTransform
source§fn sub(self, n: c_double) -> CppBox<QTransform>
fn sub(self, n: c_double) -> CppBox<QTransform>
Calls C++ function: QTransform operator-(const QTransform& a, double n)
.
§type Output = CppBox<QTransform>
type Output = CppBox<QTransform>
-
operator.