Struct qt_gui::QMatrix

source ·
#[repr(C)]
pub struct QMatrix { /* private fields */ }
Expand description

The QMatrix class specifies 2D transformations of a coordinate system.

C++ class: QMatrix.

C++ documentation:

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

source

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).

C++ documentation:

Assigns the given matrix’s values to this matrix.

source

pub unsafe fn determinant(&self) -> c_double

Returns the matrix's determinant.

Calls C++ function: double QMatrix::determinant() const.

C++ documentation:

Returns the matrix’s determinant.

This function was introduced in Qt 4.6.

source

pub unsafe fn dx(&self) -> c_double

Returns the horizontal translation factor.

Calls C++ function: double QMatrix::dx() const.

C++ documentation:

Returns the horizontal translation factor.

See also translate() and Basic Matrix Operations.

source

pub unsafe fn dy(&self) -> c_double

Returns the vertical translation factor.

Calls C++ function: double QMatrix::dy() const.

C++ documentation:

Returns the vertical translation factor.

See also translate() and Basic Matrix Operations.

source

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.

C++ documentation:

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().

source

pub unsafe fn inverted_0a(&self) -> CppBox<QMatrix>

Returns an inverted copy of this matrix.

Calls C++ function: QMatrix QMatrix::inverted() const.

C++ documentation:

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().

source

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.

C++ documentation:

Returns true if the matrix is the identity matrix, otherwise returns false.

See also reset().

source

pub unsafe fn is_invertible(&self) -> bool

Returns true if the matrix is invertible, otherwise returns false.

Calls C++ function: bool QMatrix::isInvertible() const.

C++ documentation:

Returns true if the matrix is invertible, otherwise returns false.

See also inverted().

source

pub unsafe fn m11(&self) -> c_double

Returns the horizontal scaling factor.

Calls C++ function: double QMatrix::m11() const.

C++ documentation:

Returns the horizontal scaling factor.

See also scale() and Basic Matrix Operations.

source

pub unsafe fn m12(&self) -> c_double

Returns the vertical shearing factor.

Calls C++ function: double QMatrix::m12() const.

C++ documentation:

Returns the vertical shearing factor.

See also shear() and Basic Matrix Operations.

source

pub unsafe fn m21(&self) -> c_double

Returns the horizontal shearing factor.

Calls C++ function: double QMatrix::m21() const.

C++ documentation:

Returns the horizontal shearing factor.

See also shear() and Basic Matrix Operations.

source

pub unsafe fn m22(&self) -> c_double

Returns the vertical scaling factor.

Calls C++ function: double QMatrix::m22() const.

C++ documentation:

Returns the vertical scaling factor.

See also scale() and Basic Matrix Operations.

source

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.

C++ documentation:

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.

source

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.

C++ documentation:

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.

source

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.

C++ documentation:

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.

source

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.

C++ documentation:

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.

source

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.

C++ documentation:

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.

source

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.

C++ documentation:

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.

source

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.

C++ documentation:

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.

source

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.

C++ documentation:

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.

source

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.

C++ documentation:

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.

source

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.

C++ documentation:

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.

source

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.

C++ documentation:

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.

source

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.

C++ documentation:

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.

source

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.

C++ documentation:

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.

source

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).

C++ documentation:

This is an overloaded function.

Returns the result of multiplying this matrix by the given matrix.

source

pub unsafe fn new_0a() -> CppBox<QMatrix>

Constructs an identity matrix.

Calls C++ function: [constructor] void QMatrix::QMatrix().

C++ documentation:

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().

source

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).

C++ documentation:

Constructs a matrix with the elements, m11, m12, m21, m22, dx and dy.

See also setMatrix().

source

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).

C++ documentation:

Constructs a matrix that is a copy of the given matrix.

source

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().

C++ documentation:

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.

source

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).

C++ documentation:

Rotates the coordinate system the given degrees counterclockwise.

Note that if you apply a QMatrix to a point defined in widget coordinates, the direction of the rotation will be clockwise because the y-axis points downwards.

Returns a reference to the matrix.

See also setMatrix().

source

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).

C++ documentation:

Scales the coordinate system by sx horizontally and sy vertically, and returns a reference to the matrix.

See also setMatrix().

source

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).

C++ documentation:

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().

source

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).

C++ documentation:

Shears the coordinate system by sh horizontally and sv vertically, and returns a reference to the matrix.

See also setMatrix().

source

pub unsafe fn to_q_variant(&self) -> CppBox<QVariant>

Returns the matrix as a QVariant.

Calls C++ function: QVariant QMatrix::operator QVariant() const.

C++ documentation:

Returns the matrix as a QVariant.

This function was introduced in Qt 4.2.

source

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).

C++ documentation:

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

source§

unsafe fn delete(&self)

The QMatrix class specifies 2D transformations of a coordinate system.

Calls C++ function: [destructor] void QMatrix::~QMatrix().

C++ documentation:

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

source§

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.

C++ documentation:

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<QMatrix>

The resulting type after applying the * operator.
source§

impl PartialEq<Ref<QMatrix>> for QMatrix

source§

fn eq(&self, arg1: &Ref<QMatrix>) -> bool

Returns true if this matrix is equal to the given matrix, otherwise returns false.

Calls C++ function: bool QMatrix::operator==(const QMatrix& arg1) const.

C++ documentation:

Returns true if this matrix is equal to the given matrix, otherwise returns false.

1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T, U> CastInto<U> for T
where U: CastFrom<T>,

source§

unsafe fn cast_into(self) -> U

Performs the conversion. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> StaticUpcast<T> for T

source§

unsafe fn static_upcast(ptr: Ptr<T>) -> Ptr<T>

Convert type of a const pointer. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.