HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GP_LinearXform.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: Domain pasting Library (C++)
7  *
8  * COMMENTS: Linear domain transformation class.
9  *
10  */
11 
12 #ifndef __GP_LinearXform_h__
13 #define __GP_LinearXform_h__
14 
15 #include "GP_API.h"
16 #include <UT/UT_Matrix2.h>
17 #include "GP_Xform.h"
18 #include <iosfwd>
19 
21 {
22 public:
23  // Class c-tors and d-tor.
24  GP_LinearXform(void);
25  GP_LinearXform(const GP_LinearXform &xform);
26  GP_LinearXform(const GP_Point &orig,const UT_Matrix2 &basis);
27  GP_LinearXform(const UT_BoundingRect &from,
28  const UT_BoundingRect &to);
29  virtual ~GP_LinearXform(void);
30 
31  // Apply this transformation to the data forward or backward:
32  // Return 0 if OK and -1 if error (eg. can't invert).
33  virtual int forward (GP_Point &p) const;
34  virtual int forward (GP_PointMatrix &m) const;
35  virtual int backward(GP_Point &p) const;
36  virtual int backward(GP_PointMatrix &m) const;
37 
38  // Set the transformation to identity:
39  virtual void reset(void);
40 
41  // Add a translation by delta to this transform:
42  virtual void translate(float dx, float dy);
43 
44  // Compose us with the given transformation. Return 0 if we cannot compress
45  // the composition. Otherwise return a pointer to the transformation, which
46  // will be us or a new xform of a different type.
47  virtual GP_Xform *compose(const GP_Xform &xform,
48  const UT_BoundingRect *brect = 0);
49  virtual GP_Xform *composeInverse(const GP_Xform &xform,
50  const UT_BoundingRect *brect = 0);
51 
52  // Copy your data from the other guy if both xforms have the same type.
53  // Return 0 if same type, else -1.
54  virtual int copyFrom(const GP_Xform &xform);
55 
56  // Return an inverse transformation. The first method allocates
57  // space for the object and return 0 if it fails somewhere. The second
58  // method returns the inverse in the reference provided as long as it's
59  // the appropriate type, and returns 0. If the xform is not the right type,
60  // or the inverse can't be computed, it returns -1.
61  virtual GP_Xform *inverse(void);
62  virtual int inverse(GP_Xform &);
63 
64  // Each derived class has its own name and id:
65  virtual const char *getName(void) const;
66  virtual unsigned int getType(void) const;
67  virtual const char *getJSONToken(void) const;
68 
69  // I/O functions returning 0 if OK and -1 otherwise.
70  virtual int save(std::ostream &os, int binary = 0) const;
71  virtual bool load(UT_IStream &is);
72 
73  virtual bool save(UT_JSONWriter &w) const;
74  virtual bool load(UT_JSONParser &p, UT_JSONParser::traverser &it);
75 
76  // Assignment operator defined for a transform of the same type:
77  GP_LinearXform &operator=(const GP_LinearXform &xform);
78 
79 
80 protected:
81  GP_LinearXform(const GP_Point &orig, const UT_Matrix2 &basis,
82  const UT_Matrix2 &invbasis);
83 
84  // Build the inverse matrix whether dirty or not. Return 0 upon success
85  // and -1 otherwise.
86  int computeInverse(void);
87 
88 private:
89  GP_Point myOrigin;
91  UT_Matrix2 myInverse;
92  int myInverseOK;
93 };
94 
95 #endif
virtual int save(std::ostream &os, int binary=0) const =0
#define GP_API
Definition: GP_API.h:10
virtual const char * getJSONToken(void) const =0
virtual bool load(UT_IStream &is)=0
const GLuint GLenum const void * binary
Definition: glcorearb.h:1923
virtual void reset(void)=0
JSON reader class which handles parsing of JSON or bJSON files.
Definition: UT_JSONParser.h:72
Class which writes ASCII or binary JSON streams.
Definition: UT_JSONWriter.h:32
virtual int forward(GP_Point &p) const =0
virtual int copyFrom(const GP_Xform &xform)=0
Traverse an array object in the parser.
virtual GP_Xform * inverse(void)=0
GT_Basis myBasis
Definition: GT_CurveEval.h:262
virtual GP_Xform * compose(const GP_Xform &xform, const UT_BoundingRect *brect=0)=0
virtual const char * getName(void) const =0
GLubyte GLubyte GLubyte GLubyte w
Definition: glcorearb.h:856
virtual int backward(GP_Point &p) const =0
virtual unsigned int getType(void) const =0
virtual void translate(float dx, float dy)=0
virtual GP_Xform * composeInverse(const GP_Xform &xform, const UT_BoundingRect *brect=0)=0