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: Transformation frame for pasted domains. 00017 * 00018 */ 00019 00020 #ifndef __GP_Frame_h__ 00021 #define __GP_Frame_h__ 00022 00023 #include "GP_API.h" 00024 #include <iostream.h> 00025 #include "GP_Xform.h" 00026 00027 class GP_FrameHierarchy; 00028 00029 00030 class GP_API GP_Frame 00031 { 00032 friend class GP_FrameHierarchy; 00033 00034 public: 00035 // Class c-tors and d-tor. 00036 GP_Frame(void); 00037 GP_Frame(const GP_Frame &frame); 00038 GP_Frame(const GP_XformHandle &handle); 00039 virtual ~GP_Frame(void); 00040 00041 // Deep copy from source frame. 00042 virtual void copyFrom(const GP_Frame &src); 00043 00044 // I/O functions returning 0 if OK and -1 otherwise. 00045 virtual int save(ostream &os, int binary = 0) const; 00046 virtual bool load(UT_IStream &is); 00047 00048 // Assignment operator: 00049 GP_Frame &operator=(const GP_Frame &frame); 00050 00051 // Take a point assumed to be in our frame and convert it to other 00052 // frames. Return 0 if successful, else -1: 00053 int toParent(GP_Point &p) const; 00054 int toWorld (GP_Point &p) const; 00055 int toFrame (GP_Point &p, const GP_Frame &to) const; 00056 00057 // Take a matrix of points assumed to be in our frame and convert it to 00058 // other frames. Return 0 if successful, else -1: 00059 int toParent(GP_PointMatrix &matx) const; 00060 int toWorld (GP_PointMatrix &matx) const; 00061 int toFrame (GP_PointMatrix &matx, 00062 const GP_Frame &to) const; 00063 00064 // Take a point or matrix expressed in another frame and convert it to us. 00065 // Return 0 if successful, else -1: 00066 int fromParent(GP_Point &p) const; 00067 int fromWorld (GP_Point &p) const; 00068 int fromParent(GP_PointMatrix &matx) const; 00069 int fromWorld (GP_PointMatrix &matx) const; 00070 00071 // Add a translation by delta to this frame's transform: 00072 void translate(float dx, float dy); 00073 00074 // Query or set the dirty flag when the world xform is bad: 00075 int isDirty(void) const { return myDirtyWorld; } 00076 void dirty(void); 00077 00078 // Change the transformation: 00079 virtual void changeXform (const GP_XformHandle &handle); 00080 virtual void composeXform(const GP_XformHandle &handle); 00081 00082 // Query (but not change) the personal and world transforms: 00083 const GP_XformHandle &personalXform() const { return myXform; } 00084 const GP_XformHandle &worldXform () const { return myWorldXform; } 00085 00086 // Find out what hierarchy we're in, if any: 00087 GP_FrameHierarchy *hierarchy(void) const { return myHierarchy;} 00088 00089 // Return our parent frame in the hierarchy, or nil. 00090 const GP_Frame *parent(void) const; 00091 00092 00093 protected: 00094 // Constructor meant to be used only by friends: 00095 GP_Frame(const GP_XformHandle &xform, const GP_XformHandle &world, 00096 int dirtyworld, GP_FrameHierarchy *frames); 00097 00098 // Set the parent and world transforms: 00099 void personalXform(const GP_XformHandle &handle) 00100 { 00101 myXform = handle; 00102 00103 if (myHierarchy) 00104 { 00105 dirty(); // will need to recompute the world xform 00106 } 00107 else 00108 { 00109 myWorldXform = handle; 00110 myDirtyWorld = 0; 00111 } 00112 } 00113 void worldXform (const GP_XformHandle &handle) 00114 { 00115 myWorldXform = handle; // will share the xform 00116 myDirtyWorld = 0; 00117 } 00118 void worldXform (const GP_Xform &xform) 00119 { 00120 myWorldXform = xform; // copies the xform deeply 00121 myDirtyWorld = 0; 00122 } 00123 00124 // Set the hierarchy pointer. We live in it. 00125 void hierarchy(GP_FrameHierarchy *h = 0) 00126 { 00127 if (h != myHierarchy) 00128 { 00129 myHierarchy = h; 00130 myDirtyWorld = 1; // just us 00131 } 00132 } 00133 00134 // Only friends can use these ones: 00135 GP_XformHandle &personalXform(void) { return myXform; } 00136 GP_XformHandle &worldXform (void) { return myWorldXform; } 00137 00138 private: 00139 GP_XformHandle myXform; 00140 GP_XformHandle myWorldXform; 00141 int myDirtyWorld; 00142 GP_FrameHierarchy *myHierarchy; 00143 }; 00144 00145 #endif
1.5.9