papyrus logo

Papyrus::Matrix Class Reference

This class wraps the cairo matrix class. More...

#include <matrix.h>

List of all members.

Public Types

typedef PapyrusPointer< Matrixpointer

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.
Matrixoperator= (const Cairo::Matrix &other)
 Overloaded operator= to set this matrix equal to a cairo matrix.
Matrixoperator= (const Matrix &other)
 Overloaded operator= to set this matrix equal to the specified matrix.
Matrixoperator= (const Matrix::pointer other)
 Overloaded operator= to set this matrix equal to the specified matrix.
Matrixoperator= (const char *svg_transform)
 Overloaded operator= to set this matrix equal to the SVG transform matrix.
Matrixoperator= (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.
Matrixoperator*= (const Matrix &other)
 Arithmetic assignment to multiply this matrix by the.
Matrixoperator*= (const Matrix::pointer other)
 Arithmetic assignment to multiply this matrix by the.
Matrixoperator*= (const char *svg_transform)
 Arithmetic assignment to multiply this matrix by an SVG transform string matrix.
Matrixoperator*= (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.

Detailed Description

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.

Author:
Rick L Vinyard Jr <rvinyard@cs.nmsu.edu>

Member Typedef Documentation

typedef PapyrusPointer<Matrix> Papyrus::Matrix::pointer

Constructor & Destructor Documentation

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

Member Function Documentation

Matrix::pointer Papyrus::Matrix::create ( const Glib::ustring &  svg_string  )  [static]

Constructs a matrix from an SVG transform string.

References Matrix().

Matrix::pointer Papyrus::Matrix::create ( const char *  svg_string  )  [static]

Constructs a matrix from an SVG transform string.

References Matrix().

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

Parameters:
other matrix and returns the result

References Matrix(), and operator*().

Matrix Papyrus::Matrix::operator* ( const Matrix other  )  const

Multiplies this matrix by.

Parameters:
other matrix and returns the result

References m_matrix.

Referenced by operator*().

Matrix & Papyrus::Matrix::operator*= ( const Glib::ustring &  svg_transform  ) 

Arithmetic assignment to multiply this matrix by an SVG transform string matrix.

References Matrix().

Matrix & Papyrus::Matrix::operator*= ( const char *  svg_transform  ) 

Arithmetic assignment to multiply this matrix by an SVG transform string matrix.

References Matrix().

Matrix & Papyrus::Matrix::operator*= ( const Matrix::pointer  other  ) 

Arithmetic assignment to multiply this matrix by the.

Parameters:
other matrix
Matrix & Papyrus::Matrix::operator*= ( const Matrix other  ) 

Arithmetic assignment to multiply this matrix by the.

Parameters:
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.

Matrix & Papyrus::Matrix::operator= ( const Matrix other  ) 

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:

  1. translate( cx, cy )
  2. rotate( r )
  3. translate( -cx, -cy )

References Papyrus::DEGREES, m_matrix, and m_signal_changed.

void Papyrus::Matrix::rotate ( double  r,
DegRad  degrad = RADIANS 
)
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  ) 
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:

  • matrix( a b c d e f ) : specifies a transformation matrix of six values
  • translate( tx [ty] ) : specifies a translation of tx and ty. If ty is not provided it is assumed to be zero.
  • scale( sx [sy] ) : specifies a scale operation by sx and sy. If sy is not provided it is assumed to be equal to sx.
  • rotate( r [cx cy] ) : specified a rotation of r degrees. If optional parameters cx and cy are supplied the rotation is about the point (cx, cy).
  • skewX( s ) : Specifies a skew transformation of angle s degrees along the x-axis.
  • skewY( s ) : Specifies a skew transformation of angle s degrees along the y-axis.

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

Member Data Documentation

Cairo::Matrix Papyrus::Matrix::m_matrix [protected]
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().


The documentation for this class was generated from the following files:

Generated on Fri Apr 16 12:41:08 2010 for papyrus by doxygen 1.6.1