#[repr(C)]pub struct QMatrix { /* private fields */ }
Expand description
The QMatrix class specifies 2D transformations of a coordinate system.
C++ class: QMatrix
.
The QMatrix class specifies 2D transformations of a coordinate system.
A matrix specifies how to translate, scale, shear or rotate the coordinate system, and is typically used when rendering graphics. QMatrix, in contrast to QTransform, does not allow perspective transformations. QTransform is the recommended transformation class in Qt.
A QMatrix 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 QMatrix 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.
QMatrix 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). In addition, QMatrix provides the determinant() function returning the matrix's determinant.
Finally, the QMatrix class supports matrix multiplication, and objects of the class can be streamed as well as compared.
Implementations§
source§impl QMatrix
impl QMatrix
sourcepub unsafe fn copy_from(
&self,
arg1: impl CastInto<Ref<QMatrix>>
) -> Ref<QMatrix>
pub unsafe fn copy_from( &self, arg1: impl CastInto<Ref<QMatrix>> ) -> Ref<QMatrix>
Assigns the given matrix's values to this matrix.
Calls C++ function: QMatrix& QMatrix::operator=(const QMatrix& arg1)
.
Assigns the given matrix’s values to this matrix.
sourcepub unsafe fn determinant(&self) -> c_double
pub unsafe fn determinant(&self) -> c_double
Returns the matrix's determinant.
Calls C++ function: double QMatrix::determinant() const
.
Returns the matrix’s determinant.
This function was introduced in Qt 4.6.
sourcepub unsafe fn dx(&self) -> c_double
pub unsafe fn dx(&self) -> c_double
Returns the horizontal translation factor.
Calls C++ function: double QMatrix::dx() const
.
Returns the horizontal translation factor.
See also 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 QMatrix::dy() const
.
Returns the vertical translation factor.
See also translate() and Basic Matrix Operations.
sourcepub unsafe fn inverted_1a(&self, invertible: *mut bool) -> CppBox<QMatrix>
pub unsafe fn inverted_1a(&self, invertible: *mut bool) -> CppBox<QMatrix>
Returns an inverted copy of this matrix.
Calls C++ function: QMatrix QMatrix::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<QMatrix>
pub unsafe fn inverted_0a(&self) -> CppBox<QMatrix>
Returns an inverted copy of this matrix.
Calls C++ function: QMatrix QMatrix::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_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 QMatrix::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 QMatrix::isInvertible() const
.
Returns true
if the matrix is invertible, otherwise returns false
.
See also inverted().
sourcepub unsafe fn m11(&self) -> c_double
pub unsafe fn m11(&self) -> c_double
Returns the horizontal scaling factor.
Calls C++ function: double QMatrix::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 QMatrix::m12() const
.
Returns the vertical shearing factor.
See also shear() 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 QMatrix::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 QMatrix::m22() const
.
Returns the vertical scaling factor.
See also scale() and Basic Matrix Operations.
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 QMatrix::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 QMatrix::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
The point (x, y) is the original point, and (x', y') is the transformed point.
See also 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 QMatrix::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 QMatrix::map(const QPointF& p) const
.
This is an overloaded function.
Creates and returns a QPointF object that is a copy of the given point, 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 QMatrix::map(const QLine& 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_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 QMatrix::map(const QLineF& l) const
.
This is an overloaded function.
Creates and returns a QLineF object that is a copy of the given line, mapped into the coordinate system defined by this matrix.
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 QMatrix::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 QMatrix::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 QMatrix::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 QMatrix::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_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 QMatrix::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 QMatrix::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 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 QMatrix::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
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(
&self,
arg1: impl CastInto<Ref<QMatrix>>
) -> Ref<QMatrix>
pub unsafe fn mul_assign( &self, arg1: impl CastInto<Ref<QMatrix>> ) -> Ref<QMatrix>
This is an overloaded function.
Calls C++ function: QMatrix& QMatrix::operator*=(const QMatrix& arg1)
.
This is an overloaded function.
Returns the result of multiplying this matrix by the given matrix.
sourcepub unsafe fn new_0a() -> CppBox<QMatrix>
pub unsafe fn new_0a() -> CppBox<QMatrix>
Constructs an identity matrix.
Calls C++ function: [constructor] void QMatrix::QMatrix()
.
Constructs an identity matrix.
All elements are set to zero except m11
and m22
(specifying the scale), which are set to 1.
See also reset().
sourcepub unsafe fn new_6a(
m11: c_double,
m12: c_double,
m21: c_double,
m22: c_double,
dx: c_double,
dy: c_double
) -> CppBox<QMatrix>
pub unsafe fn new_6a( m11: c_double, m12: c_double, m21: c_double, m22: c_double, dx: c_double, dy: c_double ) -> CppBox<QMatrix>
Constructs a matrix with the elements, m11, m12, m21, m22, dx and dy.
Calls C++ function: [constructor] void QMatrix::QMatrix(double m11, double m12, double m21, double m22, double dx, double dy)
.
Constructs a matrix with the elements, m11, m12, m21, m22, dx and dy.
See also setMatrix().
sourcepub unsafe fn new_copy(other: impl CastInto<Ref<QMatrix>>) -> CppBox<QMatrix>
pub unsafe fn new_copy(other: impl CastInto<Ref<QMatrix>>) -> CppBox<QMatrix>
Constructs a matrix that is a copy of the given matrix.
Calls C++ function: [constructor] void QMatrix::QMatrix(const QMatrix& other)
.
Constructs a matrix that is a copy of the given matrix.
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) which are set to 1.
Calls C++ function: void QMatrix::reset()
.
Resets the matrix to an identity matrix, i.e. all elements are set to zero, except m11
and m22
(specifying the scale) which are set to 1.
See also QMatrix(), isIdentity(), and Basic Matrix Operations.
sourcepub unsafe fn rotate(&self, a: c_double) -> Ref<QMatrix>
pub unsafe fn rotate(&self, a: c_double) -> Ref<QMatrix>
Rotates the coordinate system the given degrees counterclockwise.
Calls C++ function: QMatrix& QMatrix::rotate(double a)
.
sourcepub unsafe fn scale(&self, sx: c_double, sy: c_double) -> Ref<QMatrix>
pub unsafe fn scale(&self, sx: c_double, sy: c_double) -> Ref<QMatrix>
Scales the coordinate system by sx horizontally and sy vertically, and returns a reference to the matrix.
Calls C++ function: QMatrix& QMatrix::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,
m21: c_double,
m22: c_double,
dx: c_double,
dy: c_double
)
pub unsafe fn set_matrix( &self, m11: c_double, m12: c_double, m21: c_double, m22: c_double, dx: c_double, dy: c_double )
Sets the matrix elements to the specified values, m11, m12, m21, m22, dx and dy.
Calls C++ function: void QMatrix::setMatrix(double m11, double m12, double m21, double m22, double dx, double dy)
.
Sets the matrix elements to the specified values, m11, m12, m21, m22, dx and dy.
Note that this function replaces the previous values. QMatrix provide the translate(), rotate(), scale() and shear() convenience functions to manipulate the various matrix elements based on the currently defined coordinate system.
See also QMatrix().
sourcepub unsafe fn shear(&self, sh: c_double, sv: c_double) -> Ref<QMatrix>
pub unsafe fn shear(&self, sh: c_double, sv: c_double) -> Ref<QMatrix>
Shears the coordinate system by sh horizontally and sv vertically, and returns a reference to the matrix.
Calls C++ function: QMatrix& QMatrix::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 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<QMatrix>
pub unsafe fn translate(&self, dx: c_double, dy: c_double) -> Ref<QMatrix>
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: QMatrix& QMatrix::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().
Trait Implementations§
source§impl CppDeletable for QMatrix
impl CppDeletable for QMatrix
source§unsafe fn delete(&self)
unsafe fn delete(&self)
The QMatrix class specifies 2D transformations of a coordinate system.
Calls C++ function: [destructor] void QMatrix::~QMatrix()
.
The QMatrix class specifies 2D transformations of a coordinate system.
A matrix specifies how to translate, scale, shear or rotate the coordinate system, and is typically used when rendering graphics. QMatrix, in contrast to QTransform, does not allow perspective transformations. QTransform is the recommended transformation class in Qt.
A QMatrix 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 QMatrix 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.
QMatrix 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). In addition, QMatrix provides the determinant() function returning the matrix's determinant.
Finally, the QMatrix class supports matrix multiplication, and objects of the class can be streamed as well as compared.
source§impl Mul<Ref<QMatrix>> for &QMatrix
impl Mul<Ref<QMatrix>> for &QMatrix
source§fn mul(self, o: Ref<QMatrix>) -> CppBox<QMatrix>
fn mul(self, o: Ref<QMatrix>) -> CppBox<QMatrix>
Returns the result of multiplying this matrix by the given matrix.
Calls C++ function: QMatrix QMatrix::operator*(const QMatrix& 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.