00001 /* 00002 * PROPRIETARY INFORMATION. This software is proprietary to 00003 * Side Effects Software Inc., and is not to be reproduced, 00004 * transmitted, or disclosed in any way without written permission. 00005 * 00006 * Produced by: 00007 * Cristin Barghiel 00008 * Side Effects Software Inc. 00009 * 477 Richmond Street West 00010 * Toronto, Ontario 00011 * Canada M5V 3E7 00012 * 416-504-9876 00013 * 00014 * NAME: Domain pasting Library (C++) 00015 * 00016 * COMMENTS: Linear domain transformation class. 00017 * 00018 */ 00019 00020 #ifndef __GP_LinearXform_h__ 00021 #define __GP_LinearXform_h__ 00022 00023 #include "GP_API.h" 00024 #include <UT/UT_Matrix2.h> 00025 #include "GP_Xform.h" 00026 00027 class GP_API GP_LinearXform : public GP_Xform 00028 { 00029 public: 00030 // Class c-tors and d-tor. 00031 GP_LinearXform(void); 00032 GP_LinearXform(const GP_LinearXform &xform); 00033 GP_LinearXform(const GP_Point &orig,const UT_Matrix2 &basis); 00034 GP_LinearXform(const UT_BoundingRect &from, 00035 const UT_BoundingRect &to); 00036 virtual ~GP_LinearXform(void); 00037 00038 // Apply this transformation to the data forward or backward: 00039 // Return 0 if OK and -1 if error (eg. can't invert). 00040 virtual int forward (GP_Point &p) const; 00041 virtual int forward (GP_PointMatrix &m) const; 00042 virtual int backward(GP_Point &p) const; 00043 virtual int backward(GP_PointMatrix &m) const; 00044 00045 // Set the transformation to identity: 00046 virtual void reset(void); 00047 00048 // Add a translation by delta to this transform: 00049 virtual void translate(float dx, float dy); 00050 00051 // Compose us with the given transformation. Return 0 if we cannot compress 00052 // the composition. Otherwise return a pointer to the transformation, which 00053 // will be us or a new xform of a different type. 00054 virtual GP_Xform *compose(const GP_Xform &xform, 00055 const UT_BoundingRect *brect = 0); 00056 virtual GP_Xform *composeInverse(const GP_Xform &xform, 00057 const UT_BoundingRect *brect = 0); 00058 00059 // Copy your data from the other guy if both xforms have the same type. 00060 // Return 0 if same type, else -1. 00061 virtual int copyFrom(const GP_Xform &xform); 00062 00063 // Return an inverse transformation. The first method allocates 00064 // space for the object and return 0 if it fails somewhere. The second 00065 // method returns the inverse in the reference provided as long as it's 00066 // the appropriate type, and returns 0. If the xform is not the right type, 00067 // or the inverse can't be computed, it returns -1. 00068 virtual GP_Xform *inverse(void); 00069 virtual int inverse(GP_Xform &); 00070 00071 // Each derived class has its own name and id: 00072 virtual const char *getName(void) const; 00073 virtual unsigned int getType(void) const; 00074 00075 // I/O functions returning 0 if OK and -1 otherwise. 00076 virtual int save(ostream &os, int binary = 0) const; 00077 virtual bool load(UT_IStream &is); 00078 00079 // Assignment operator defined for a transform of the same type: 00080 GP_LinearXform &operator=(const GP_LinearXform &xform); 00081 00082 00083 protected: 00084 GP_LinearXform(const GP_Point &orig, const UT_Matrix2 &basis, 00085 const UT_Matrix2 &invbasis); 00086 00087 // Build the inverse matrix whether dirty or not. Return 0 upon success 00088 // and -1 otherwise. 00089 int computeInverse(void); 00090 00091 private: 00092 GP_Point myOrigin; 00093 UT_Matrix2 myBasis; 00094 UT_Matrix2 myInverse; 00095 int myInverseOK; 00096 }; 00097 00098 #endif
1.5.9