This class wraps the cairo matrix class. More...
#include <matrix.h>
Public Types | |
typedef PapyrusPointer< Matrix > | pointer |
Public Member Functions | |
Matrix () | |
Constructs an identity matrix. | |
Matrix (double tx, double ty, double sx=1.0, double sy=1.0, double r=0.0) | |
Constructor that applies an initial translate/scale/rotate matrix. | |
Matrix (double xx, double yx, double xy, double yy, double x0, double y0) | |
Initializes the matrix to the specified values. | |
Matrix (const Cairo::Matrix &matrix) | |
Constructs a matrix identical to the supplied matrix. | |
Matrix (const Matrix &other) | |
Copy constructor Ensures that both matrices have independent signals. | |
Matrix (const char *svg_transform) | |
Construct a matrix from an SVG transform string. | |
Matrix (const Glib::ustring &svg_transform) | |
Construct a matrix from an SVG transform string. | |
~Matrix () | |
void | translate (double tx, double ty) |
Translate current position by (tx, ty). | |
void | scale (double s) |
Scales the current x and y dimensions by s. | |
void | scale (double scale_x, double scale_y) |
Scales the current x dimension by sx and the y dimension by sy. | |
void | rotate (double r, DegRad degrad=RADIANS) |
Rotate by r radians. | |
void | rotate (double r, double cx, double cy, DegRad degrad=RADIANS) |
Rotate by r radians about the point cx, cy. | |
void | skew (double s, DegRad degrad=RADIANS) |
Skew the x and y axes uniformly. | |
void | skew (double skewx, double skewy, DegRad degrad=RADIANS) |
Skew the x and y axes independently. | |
void | skew_x (double s, DegRad degrad=RADIANS) |
Skew only the x axis. | |
void | skew_y (double s, DegRad degrad=RADIANS) |
Skew only the y axis. | |
void | invert () |
Invert the matrix. | |
Matrix | inverse () const |
Return an inverse matrix. | |
void | transform_distance (double &dx, double &dy) const |
Transforms the distance vector (dx,dy) by the matrix. | |
void | transform_distance_inverse (double &dx, double &dy) const |
Transforms the distance vector (dx,dy) by the inverse of this matrix. | |
void | transform_point (double &x, double &y) const |
Transforms the point (x,y) by the matrix. | |
void | transform_point_inverse (double &x, double &y) const |
Transforms the point (x,y) by the inverse of this matrix. | |
Matrix & | operator= (const Cairo::Matrix &other) |
Overloaded operator= to set this matrix equal to a cairo matrix. | |
Matrix & | operator= (const Matrix &other) |
Overloaded operator= to set this matrix equal to the specified matrix. | |
Matrix & | operator= (const Matrix::pointer other) |
Overloaded operator= to set this matrix equal to the specified matrix. | |
Matrix & | operator= (const char *svg_transform) |
Overloaded operator= to set this matrix equal to the SVG transform matrix. | |
Matrix & | operator= (const Glib::ustring &svg_transform) |
Overloaded operator= to set this matrix equal to the SVG transform matrix. | |
Matrix | operator* (const Matrix &other) const |
Multiplies this matrix by. | |
Matrix | operator* (const Matrix::pointer other) const |
Multiplies this matrix by. | |
Matrix | operator* (const char *svg_transform) const |
Multiplies this matrix by a SVG transform string and returns the result. | |
Matrix | operator* (const Glib::ustring &svg_transform) const |
Multiplies this matrix by a SVG transform string and returns the result. | |
Matrix & | operator*= (const Matrix &other) |
Arithmetic assignment to multiply this matrix by the. | |
Matrix & | operator*= (const Matrix::pointer other) |
Arithmetic assignment to multiply this matrix by the. | |
Matrix & | operator*= (const char *svg_transform) |
Arithmetic assignment to multiply this matrix by an SVG transform string matrix. | |
Matrix & | operator*= (const Glib::ustring &svg_transform) |
Arithmetic assignment to multiply this matrix by an SVG transform string matrix. | |
bool | operator== (const Matrix &other) const |
Tests equality of two matrices. | |
bool | operator!= (const Matrix &other) const |
Tests inequality of two matrices. | |
bool | operator== (const pointer other) const |
Tests equality of two matrices. | |
bool | operator!= (const pointer other) const |
Tests inequality of two matrices. | |
operator const Cairo::Matrix & () const | |
Return this matrix as a cairo matrix. | |
bool | set (const Glib::ustring &s) |
Sets the matrix to string s formatted according to the SVG syntax for transform attributes. | |
void | set_identity () |
Set the transformation matrix to the identity matrix. | |
Glib::ustring | svg () const |
Returns the SVG transform string of this matrix. | |
sigc::signal< void > | signal_changed () |
Signal emitted when the matrix is modified. | |
Static Public Member Functions | |
static pointer | create () |
Constructs an identity matrix. | |
static pointer | create (double tx, double ty=0.0, double sx=1.0, double sy=1.0, double r=0.0) |
Constructor that applies an initial translate/scale/rotate matrix. | |
static pointer | create (double xx, double yx, double xy, double yy, double x0, double y0) |
Initializes the matrix to the specified values. | |
static pointer | create (const Cairo::Matrix &matrix) |
Constructs a matrix identical to the supplied matrix. | |
static pointer | create (const Matrix &other) |
Constructs a matrix identical to the supplied matrix. | |
static pointer | create (const char *svg_string) |
Constructs a matrix from an SVG transform string. | |
static pointer | create (const Glib::ustring &svg_string) |
Constructs a matrix from an SVG transform string. | |
Static Public Attributes | |
static Matrix | Identity = Matrix() |
Protected Attributes | |
Cairo::Matrix | m_matrix |
The cairo matrix maintained by this controller. | |
sigc::signal< void > | m_signal_changed |
Signal emitted when this matrix is changed. |
This class wraps the cairo matrix class.
Although the affine transform methods are convenient, the primary motivation behind this class is to provide a signal that is emitted when the matrix is modified.
typedef PapyrusPointer<Matrix> Papyrus::Matrix::pointer |
Papyrus::Matrix::Matrix | ( | ) |
Constructs an identity matrix.
References m_matrix.
Referenced by create(), operator*(), operator*=(), and set().
Papyrus::Matrix::Matrix | ( | double | tx, | |
double | ty, | |||
double | sx = 1.0 , |
|||
double | sy = 1.0 , |
|||
double | r = 0.0 | |||
) |
Constructor that applies an initial translate/scale/rotate matrix.
References m_matrix.
Papyrus::Matrix::Matrix | ( | double | xx, | |
double | yx, | |||
double | xy, | |||
double | yy, | |||
double | x0, | |||
double | y0 | |||
) |
Initializes the matrix to the specified values.
References m_matrix.
Papyrus::Matrix::Matrix | ( | const Cairo::Matrix & | matrix | ) |
Constructs a matrix identical to the supplied matrix.
Papyrus::Matrix::Matrix | ( | const Matrix & | other | ) |
Copy constructor Ensures that both matrices have independent signals.
Papyrus::Matrix::Matrix | ( | const char * | svg_transform | ) |
Construct a matrix from an SVG transform string.
Papyrus::Matrix::Matrix | ( | const Glib::ustring & | svg_transform | ) |
Construct a matrix from an SVG transform string.
Papyrus::Matrix::~Matrix | ( | ) |
Matrix::pointer Papyrus::Matrix::create | ( | const Glib::ustring & | svg_string | ) | [static] |
Matrix::pointer Papyrus::Matrix::create | ( | const char * | svg_string | ) | [static] |
Matrix::pointer Papyrus::Matrix::create | ( | const Matrix & | other | ) | [static] |
Constructs a matrix identical to the supplied matrix.
Matrix::pointer Papyrus::Matrix::create | ( | const Cairo::Matrix & | matrix | ) | [static] |
Constructs a matrix identical to the supplied matrix.
Matrix::pointer Papyrus::Matrix::create | ( | double | xx, | |
double | yx, | |||
double | xy, | |||
double | yy, | |||
double | x0, | |||
double | y0 | |||
) | [static] |
Initializes the matrix to the specified values.
Matrix::pointer Papyrus::Matrix::create | ( | double | tx, | |
double | ty = 0.0 , |
|||
double | sx = 1.0 , |
|||
double | sy = 1.0 , |
|||
double | r = 0.0 | |||
) | [static] |
Constructor that applies an initial translate/scale/rotate matrix.
Matrix::pointer Papyrus::Matrix::create | ( | ) | [static] |
Constructs an identity matrix.
References Matrix().
Referenced by set(), and Papyrus::Drawable::set().
Matrix Papyrus::Matrix::inverse | ( | ) | const |
Return an inverse matrix.
References invert().
Referenced by transform_distance_inverse(), and transform_point_inverse().
void Papyrus::Matrix::invert | ( | ) |
Invert the matrix.
References m_matrix, and m_signal_changed.
Referenced by Papyrus::Drawable::distance_global_to_local(), Papyrus::Drawable::global_to_local(), and inverse().
Papyrus::Matrix::operator const Cairo::Matrix & | ( | ) | const |
Return this matrix as a cairo matrix.
References m_matrix.
bool Papyrus::Matrix::operator!= | ( | const pointer | other | ) | const |
Tests inequality of two matrices.
bool Papyrus::Matrix::operator!= | ( | const Matrix & | other | ) | const |
Tests inequality of two matrices.
Matrix Papyrus::Matrix::operator* | ( | const Glib::ustring & | svg_transform | ) | const |
Multiplies this matrix by a SVG transform string and returns the result.
References Matrix(), and operator*().
Matrix Papyrus::Matrix::operator* | ( | const char * | svg_transform | ) | const |
Multiplies this matrix by a SVG transform string and returns the result.
References Matrix(), and operator*().
Matrix Papyrus::Matrix::operator* | ( | const Matrix::pointer | other | ) | const |
Multiplies this matrix by.
other | matrix and returns the result |
References Matrix(), and operator*().
Multiplies this matrix by.
other | matrix and returns the result |
References m_matrix.
Referenced by operator*().
Matrix & Papyrus::Matrix::operator*= | ( | const Glib::ustring & | svg_transform | ) |
Matrix & Papyrus::Matrix::operator*= | ( | const char * | svg_transform | ) |
Matrix & Papyrus::Matrix::operator*= | ( | const Matrix::pointer | other | ) |
Arithmetic assignment to multiply this matrix by the.
other | matrix |
Arithmetic assignment to multiply this matrix by the.
other | matrix |
References m_matrix, and m_signal_changed.
Referenced by set().
Matrix & Papyrus::Matrix::operator= | ( | const Glib::ustring & | svg_transform | ) |
Overloaded operator= to set this matrix equal to the SVG transform matrix.
Matrix & Papyrus::Matrix::operator= | ( | const char * | svg_transform | ) |
Overloaded operator= to set this matrix equal to the SVG transform matrix.
Matrix & Papyrus::Matrix::operator= | ( | const Matrix::pointer | other | ) |
Overloaded operator= to set this matrix equal to the specified matrix.
References m_matrix, and m_signal_changed.
Overloaded operator= to set this matrix equal to the specified matrix.
References m_matrix, and m_signal_changed.
Matrix & Papyrus::Matrix::operator= | ( | const Cairo::Matrix & | other | ) |
Overloaded operator= to set this matrix equal to a cairo matrix.
References m_matrix, and m_signal_changed.
bool Papyrus::Matrix::operator== | ( | const pointer | other | ) | const |
Tests equality of two matrices.
bool Papyrus::Matrix::operator== | ( | const Matrix & | other | ) | const |
Tests equality of two matrices.
References m_matrix.
void Papyrus::Matrix::rotate | ( | double | r, | |
double | cx, | |||
double | cy, | |||
DegRad | degrad = RADIANS | |||
) |
Rotate by r radians about the point cx, cy.
Inspired by the SVG transform rotate( r [cx cy] ) this is equivalent to the follow series of transforms:
References Papyrus::DEGREES, m_matrix, and m_signal_changed.
void Papyrus::Matrix::rotate | ( | double | r, | |
DegRad | degrad = RADIANS | |||
) |
Rotate by r radians.
References Papyrus::DEGREES, m_matrix, and m_signal_changed.
Referenced by Papyrus::Reference::calculate_composed_matrix(), Papyrus::Drawable::calculate_composed_matrix(), Papyrus::Canvas::calculate_composed_matrix(), Papyrus::AffineController::recalculate_matrix(), and set().
void Papyrus::Matrix::scale | ( | double | scale_x, | |
double | scale_y | |||
) |
Scales the current x dimension by sx and the y dimension by sy.
References m_matrix, and m_signal_changed.
void Papyrus::Matrix::scale | ( | double | s | ) |
Scales the current x and y dimensions by s.
References m_matrix, and m_signal_changed.
Referenced by Papyrus::Reference::calculate_composed_matrix(), Papyrus::Drawable::calculate_composed_matrix(), Papyrus::Canvas::calculate_composed_matrix(), Papyrus::AffineController::recalculate_matrix(), set(), and Papyrus::Viewbox::transformation_matrix().
bool Papyrus::Matrix::set | ( | const Glib::ustring & | s | ) |
Sets the matrix to string s formatted according to the SVG syntax for transform attributes.
The string can consist of list of transform definitions that are applied in the order listed. Individual transforms can be separated by whitespace or commas.
The recognized transforms are:
References create(), Papyrus::DEGREES, Papyrus::has_digit(), Matrix(), operator*=(), REGEX_transform_list, rotate(), scale(), set_identity(), skew_x(), skew_y(), translate(), Papyrus::which_transform(), Papyrus::XFORM_MATRIX, Papyrus::XFORM_NONE, Papyrus::XFORM_ROTATE, Papyrus::XFORM_SCALE, Papyrus::XFORM_SKEWX, Papyrus::XFORM_SKEWY, and Papyrus::XFORM_TRANSLATE.
void Papyrus::Matrix::set_identity | ( | ) |
Set the transformation matrix to the identity matrix.
References m_matrix, and m_signal_changed.
Referenced by Papyrus::Reference::calculate_composed_matrix(), Papyrus::Drawable::calculate_composed_matrix(), Papyrus::Canvas::calculate_composed_matrix(), and set().
sigc::signal< void > Papyrus::Matrix::signal_changed | ( | ) |
Signal emitted when the matrix is modified.
References m_signal_changed.
Referenced by Papyrus::Gradient::Gradient().
void Papyrus::Matrix::skew | ( | double | skewx, | |
double | skewy, | |||
DegRad | degrad = RADIANS | |||
) |
Skew the x and y axes independently.
References Papyrus::DEGREES, m_matrix, and m_signal_changed.
void Papyrus::Matrix::skew | ( | double | s, | |
DegRad | degrad = RADIANS | |||
) |
Skew the x and y axes uniformly.
References m_matrix, and m_signal_changed.
Referenced by Papyrus::Reference::calculate_composed_matrix(), Papyrus::Drawable::calculate_composed_matrix(), Papyrus::Canvas::calculate_composed_matrix(), and Papyrus::AffineController::recalculate_matrix().
void Papyrus::Matrix::skew_x | ( | double | s, | |
DegRad | degrad = RADIANS | |||
) |
Skew only the x axis.
References Papyrus::DEGREES, m_matrix, and m_signal_changed.
Referenced by set().
void Papyrus::Matrix::skew_y | ( | double | s, | |
DegRad | degrad = RADIANS | |||
) |
Skew only the y axis.
References Papyrus::DEGREES, m_matrix, and m_signal_changed.
Referenced by set().
Glib::ustring Papyrus::Matrix::svg | ( | ) | const |
Returns the SVG transform string of this matrix.
References m_matrix.
Referenced by Papyrus::Drawable::svg_transform().
void Papyrus::Matrix::transform_distance | ( | double & | dx, | |
double & | dy | |||
) | const |
Transforms the distance vector (dx,dy) by the matrix.
References m_matrix.
Referenced by Papyrus::Drawable::distance_global_to_local(), Papyrus::Drawable::distance_local_to_global(), and transform_distance_inverse().
void Papyrus::Matrix::transform_distance_inverse | ( | double & | dx, | |
double & | dy | |||
) | const |
Transforms the distance vector (dx,dy) by the inverse of this matrix.
References inverse(), and transform_distance().
void Papyrus::Matrix::transform_point | ( | double & | x, | |
double & | y | |||
) | const |
Transforms the point (x,y) by the matrix.
References m_matrix.
Referenced by Papyrus::Rectangle::calculate_extents(), Papyrus::Circle::calculate_extents(), Papyrus::Drawable::global_to_local(), Papyrus::Drawable::local_to_global(), Papyrus::Region::transform(), and transform_point_inverse().
void Papyrus::Matrix::transform_point_inverse | ( | double & | x, | |
double & | y | |||
) | const |
Transforms the point (x,y) by the inverse of this matrix.
References inverse(), and transform_point().
Referenced by Papyrus::Group::inside(), and Papyrus::Group::select().
void Papyrus::Matrix::translate | ( | double | tx, | |
double | ty | |||
) |
Translate current position by (tx, ty).
References m_matrix, and m_signal_changed.
Referenced by Papyrus::Reference::calculate_composed_matrix(), Papyrus::Drawable::calculate_composed_matrix(), Papyrus::Canvas::calculate_composed_matrix(), Papyrus::AffineController::recalculate_matrix(), set(), and Papyrus::Viewbox::transformation_matrix().
Matrix Papyrus::Matrix::Identity = Matrix() [static] |
Cairo::Matrix Papyrus::Matrix::m_matrix [protected] |
The cairo matrix maintained by this controller.
Referenced by invert(), Matrix(), operator const Cairo::Matrix &(), operator*(), operator*=(), operator=(), operator==(), rotate(), scale(), set_identity(), skew(), skew_x(), skew_y(), svg(), transform_distance(), transform_point(), and translate().
sigc::signal<void> Papyrus::Matrix::m_signal_changed [protected] |
Signal emitted when this matrix is changed.
Referenced by invert(), operator*=(), operator=(), rotate(), scale(), set_identity(), signal_changed(), skew(), skew_x(), skew_y(), and translate().