HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GP_Frame.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: Transformation frame for pasted domains.
9  *
10  */
11 
12 #ifndef __GP_Frame_h__
13 #define __GP_Frame_h__
14 
15 #include "GP_API.h"
16 #include <iosfwd>
17 #include "GP_Xform.h"
18 
19 class GP_FrameHierarchy;
20 
21 
23 {
24  friend class GP_FrameHierarchy;
25 
26 public:
27  // Class c-tors and d-tor.
28  GP_Frame(void);
29  GP_Frame(const GP_Frame &frame);
30  GP_Frame(const GP_XformHandle &handle);
31  virtual ~GP_Frame(void);
32 
33  // Deep copy from source frame.
34  virtual void copyFrom(const GP_Frame &src);
35 
36  // I/O functions returning 0 if OK and -1 otherwise.
37  virtual int save(std::ostream &os, int binary = 0) const;
38  virtual bool load(UT_IStream &is);
39 
40  // Assignment operator:
41  GP_Frame &operator=(const GP_Frame &frame);
42 
43  // Take a point assumed to be in our frame and convert it to other
44  // frames. Return 0 if successful, else -1:
45  int toParent(GP_Point &p) const;
46  int toWorld (GP_Point &p) const;
47  int toFrame (GP_Point &p, const GP_Frame &to) const;
48 
49  // Take a matrix of points assumed to be in our frame and convert it to
50  // other frames. Return 0 if successful, else -1:
51  int toParent(GP_PointMatrix &matx) const;
52  int toWorld (GP_PointMatrix &matx) const;
53  int toFrame (GP_PointMatrix &matx,
54  const GP_Frame &to) const;
55 
56  // Take a point or matrix expressed in another frame and convert it to us.
57  // Return 0 if successful, else -1:
58  int fromParent(GP_Point &p) const;
59  int fromWorld (GP_Point &p) const;
60  int fromParent(GP_PointMatrix &matx) const;
61  int fromWorld (GP_PointMatrix &matx) const;
62 
63  // Add a translation by delta to this frame's transform:
64  void translate(float dx, float dy);
65 
66  // Query or set the dirty flag when the world xform is bad:
67  int isDirty(void) const { return myDirtyWorld; }
68  void dirty(void);
69 
70  // Change the transformation:
71  virtual void changeXform (const GP_XformHandle &handle);
72  virtual void composeXform(const GP_XformHandle &handle);
73 
74  // Query (but not change) the personal and world transforms:
75  const GP_XformHandle &personalXform() const { return myXform; }
76  const GP_XformHandle &worldXform () const { return myWorldXform; }
77 
78  // Find out what hierarchy we're in, if any:
79  GP_FrameHierarchy *hierarchy(void) const { return myHierarchy;}
80 
81  // Return our parent frame in the hierarchy, or nil.
82  const GP_Frame *parent(void) const;
83 
84 
85 protected:
86  // Constructor meant to be used only by friends:
87  GP_Frame(const GP_XformHandle &xform, const GP_XformHandle &world,
88  int dirtyworld, GP_FrameHierarchy *frames);
89 
90  // Set the parent and world transforms:
91  void personalXform(const GP_XformHandle &handle)
92  {
93  myXform = handle;
94 
95  if (myHierarchy)
96  {
97  dirty(); // will need to recompute the world xform
98  }
99  else
100  {
101  myWorldXform = handle;
102  myDirtyWorld = 0;
103  }
104  }
105  void worldXform (const GP_XformHandle &handle)
106  {
107  myWorldXform = handle; // will share the xform
108  myDirtyWorld = 0;
109  }
110  void worldXform (const GP_Xform &xform)
111  {
112  myWorldXform = xform; // copies the xform deeply
113  myDirtyWorld = 0;
114  }
115 
116  // Set the hierarchy pointer. We live in it.
118  {
119  if (h != myHierarchy)
120  {
121  myHierarchy = h;
122  myDirtyWorld = 1; // just us
123  }
124  }
125 
126  // Only friends can use these ones:
127  GP_XformHandle &personalXform(void) { return myXform; }
128  GP_XformHandle &worldXform (void) { return myWorldXform; }
129 
130 private:
131  GP_XformHandle myXform;
132  GP_XformHandle myWorldXform;
133  int myDirtyWorld;
134  GP_FrameHierarchy *myHierarchy;
135 };
136 
137 #endif
const GP_XformHandle & personalXform() const
Definition: GP_Frame.h:75
#define GP_API
Definition: GP_API.h:10
void worldXform(const GP_XformHandle &handle)
Definition: GP_Frame.h:105
const GLuint GLenum const void * binary
Definition: glcorearb.h:1923
bool load(UT_IStream &is)
int save(std::ostream &os, int binary=0) const
const GP_XformHandle & worldXform() const
Definition: GP_Frame.h:76
void worldXform(const GP_Xform &xform)
Definition: GP_Frame.h:110
void personalXform(const GP_XformHandle &handle)
Definition: GP_Frame.h:91
void copyFrom(const GP_FrameHierarchy &src)
GLfloat GLfloat GLfloat GLfloat h
Definition: glcorearb.h:2001
GP_FrameHierarchy * parent(void) const
GP_XformHandle & worldXform(void)
Definition: GP_Frame.h:128
GP_FrameHierarchy * hierarchy(void) const
Definition: GP_Frame.h:79
int isDirty(void) const
Definition: GP_Frame.h:67
void hierarchy(GP_FrameHierarchy *h=0)
Definition: GP_Frame.h:117
GP_XformHandle & personalXform(void)
Definition: GP_Frame.h:127
GLenum src
Definition: glcorearb.h:1792