1 #ifndef _LIBGNOMECANVASMM_AFFINETRANS_H
2 #define _LIBGNOMECANVASMM_AFFINETRANS_H
9 * Copyright (C) 1999 The gnomemm Development Team
11 * This library is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Library General Public
13 * License as published by the Free Software Foundation; either
14 * version 2 of the License, or (at your option) any later version.
16 * This library is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Library General Public License for more details.
21 * You should have received a copy of the GNU Library General Public
22 * License along with this library; if not, write to the Free
23 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 #include <glibmm/containers.h>
27 #include <libgnomecanvasmm/point.h>
35 //: Used by CanvasItem.
39 //: Initialize the affine as unit matrix, with a scaling factor
40 AffineTrans(double scale = 1.0);
43 explicit AffineTrans(const double aff[6]);
45 AffineTrans(const AffineTrans& src);
46 AffineTrans& operator=(const AffineTrans& src);
49 double& operator[](unsigned int idx);
50 const double& operator[](unsigned int idx) const;
53 const double* gobj() const;
55 //: Apply the affine to a given point
56 //: e.g. Point dst = affine.apply(Point(x,y));
58 //: dst.x = x * affine[0] + y * affine[2] + affine[4];
59 //: dst.y = x * affine[1] + y * affine[3] + affine[5];
60 Point apply_to(const Point& p) const;
62 //: Apply the affine to a given point
63 Point operator*(const Point& p) const;
65 //: Compose two affines
66 AffineTrans operator*(const AffineTrans& aff2);
68 //: Apply other affine to the affine
69 AffineTrans const & operator*=(AffineTrans& other);
71 bool operator==(const AffineTrans& other) const;
72 bool operator!=(const AffineTrans& other) const;
74 //: Give the inverse of the affine
77 //: Flip horizontally and/or vertically the affine
78 void flip(bool horiz, bool vert);
80 //: Determine whether the affine is rectilinear (rotates 0, 90, 180 or 270 degrees)
81 bool rectilinear() const;
83 //: Find the affine's "expansion factor", i.e. the scale amount
84 double expansion() const;
86 //: Set up the identity matrix
87 static AffineTrans identity();
89 //: Set up a scaling matrix
90 static AffineTrans scaling(double s);
92 //: Set up a scaling matrix
93 static AffineTrans scaling(double sx, double sy);
95 //: Set up a rotation matrix; theta is given in degrees
96 static AffineTrans rotation(double theta);
98 //: Set up a shearing matrix; theta given in degrees
99 static AffineTrans shearing(double theta);
101 //: Set up a translation matrix
102 static AffineTrans translation(double dx, double dy);
104 //: Set up a translation matrix
105 static AffineTrans translation(const Point& p);
107 Glib::ustring to_string() const;
115 } /* namespace Gnome */
117 std::ostream& operator<<(std::ostream& out, const Gnome::Art::AffineTrans& aff);
119 #endif // _GNOMEMM_AFFINETRANS_H