matrix.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
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