papyrus logo

matrix.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2007 by Rick L. Vinyard, Jr.                            *
00003  *   rvinyard@cs.nmsu.edu                                                  *
00004  *                                                                         *
00005  *   This file is part of the papyrus library.                             *
00006  *                                                                         *
00007  *   papyrus is free software; you can redistribute it and/or modify       *
00008  *   it under the terms of the GNU Lesser General Public License           *
00009  *   version 3.0 as published by the Free Software Foundation.             *
00010  *                                                                         *
00011  *   papyrus is distributed in the hope that it will be useful,            *
00012  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00013  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00014  *   GNU Lesser General Public License version 3.0 for more details.       *
00015  *                                                                         *
00016  *   You should have received a copy of the GNU Lesser General Public      *
00017  *   License along with the papyrus library. If not, see                   *
00018  *   <http://www.gnu.org/licenses/>.                                       *
00019  ***************************************************************************/
00020 #ifndef PAPYRUSMATRIX_H
00021 #define PAPYRUSMATRIX_H
00022 
00023 #include <sigc++/sigc++.h>
00024 #include <glibmm.h>
00025 #include <cairomm/cairomm.h>
00026 
00027 #include <papyrus/pointer.h>
00028 #include <papyrus/enums.h>
00029 
00030 namespace Papyrus
00031 {
00032 
00042   class Matrix : public sigc::trackable
00043   {
00044     public:
00045 
00046       typedef PapyrusPointer<Matrix> pointer;
00047 
00049       Matrix();
00050 
00052       Matrix ( double tx, double ty, double sx = 1.0, double sy = 1.0, double r = 0.0 );
00053 
00055       Matrix ( double xx, double yx, double xy, double yy, double x0, double y0 );
00056 
00058       Matrix ( const Cairo::Matrix& matrix );
00059 
00064       Matrix ( const Matrix& other );
00065 
00069       Matrix ( const char* svg_transform );
00070 
00074       Matrix ( const Glib::ustring& svg_transform );
00075 
00077       static pointer create();
00078 
00080       static pointer create ( double tx, double ty = 0.0, double sx = 1.0, double sy = 1.0, double r = 0.0 );
00081 
00083       static pointer create ( double xx, double yx, double xy, double yy, double x0, double y0 );
00084 
00086       static pointer create ( const Cairo::Matrix& matrix );
00087 
00089       static pointer create ( const Matrix& other );
00090 
00092       static pointer create ( const char* svg_string );
00093 
00095       static pointer create ( const Glib::ustring& svg_string );
00096 
00097       static Matrix Identity;
00098 
00099       ~Matrix();
00100 
00102       void translate ( double tx, double ty );
00103 
00105       void scale ( double s );
00106 
00108       void scale ( double scale_x, double scale_y );
00109 
00111       void rotate ( double r, DegRad degrad = RADIANS );
00112 
00122       void rotate( double r, double cx, double cy, DegRad degrad = RADIANS );
00123 
00125       void skew ( double s, DegRad degrad = RADIANS );
00126 
00128       void skew ( double skewx, double skewy, DegRad degrad = RADIANS );
00129 
00131       void skew_x( double s, DegRad degrad = RADIANS );
00132 
00134       void skew_y( double s, DegRad degrad = RADIANS );
00135 
00137       void invert();
00138       
00140       Matrix inverse() const;
00141 
00143       void transform_distance ( double& dx, double& dy ) const;
00144 
00146       void transform_distance_inverse ( double& dx, double& dy ) const;
00147 
00149       void transform_point ( double& x, double& y ) const;
00150 
00152       void transform_point_inverse ( double& x, double& y ) const;
00153 
00155       Matrix& operator= ( const Cairo::Matrix& other );
00156 
00158       Matrix& operator= ( const Matrix& other );
00159 
00161       Matrix& operator= ( const Matrix::pointer other );
00162 
00164       Matrix& operator= ( const char* svg_transform );
00165 
00167       Matrix& operator= ( const Glib::ustring& svg_transform );
00168 
00170       Matrix operator* ( const Matrix& other ) const;
00171 
00173       Matrix operator* ( const Matrix::pointer other ) const;
00174 
00176       Matrix operator* ( const char* svg_transform ) const;
00177 
00179       Matrix operator* ( const Glib::ustring& svg_transform ) const;
00180 
00182       Matrix& operator*= ( const Matrix& other );
00183       
00185       Matrix& operator*= ( const Matrix::pointer other );
00186 
00188       Matrix& operator*= ( const char* svg_transform );
00189 
00191       Matrix& operator*= ( const Glib::ustring& svg_transform );
00192 
00194       bool operator==( const Matrix& other ) const;
00195 
00197       bool operator!=( const Matrix& other ) const;
00198       
00200       bool operator==( const pointer other ) const;
00201 
00203       bool operator!=( const pointer other ) const;
00204 
00206       operator const Cairo::Matrix&() const;
00207 
00225       bool set(const Glib::ustring& s);
00226 
00228       void set_identity();
00229 
00231       Glib::ustring svg() const;
00232 
00234       sigc::signal<void> signal_changed();
00235 
00236     protected:
00238       Cairo::Matrix m_matrix;
00239 
00241       sigc::signal<void> m_signal_changed;
00242 
00243   };
00244 
00245 }
00246 
00247   bool operator==( const Papyrus::Matrix::pointer m1, const Papyrus::Matrix& m2);
00248 
00249   bool operator!=( const Papyrus::Matrix::pointer m1, const Papyrus::Matrix& m2);
00250 
00251 
00252 #endif

Generated on Fri Apr 16 12:40:10 2010 for papyrus by doxygen 1.6.1