]> granicus.if.org Git - graphviz/commitdiff
Smyrna changes
authorarif <devnull@localhost>
Thu, 17 Sep 2009 19:30:24 +0000 (19:30 +0000)
committerarif <devnull@localhost>
Thu, 17 Sep 2009 19:30:24 +0000 (19:30 +0000)
1-new 3d engine
2-gui new layout
3-some improvements and changes(cameras removed , mouse interrraction has ben improved etc)

22 files changed:
cmd/smyrna/Makefile.am
cmd/smyrna/arcball.c [new file with mode: 0644]
cmd/smyrna/arcball.h [new file with mode: 0644]
cmd/smyrna/glexpose.c
cmd/smyrna/glexpose.h
cmd/smyrna/glmotion.c
cmd/smyrna/gltemplate.c
cmd/smyrna/smyrna.vcproj
cmd/smyrna/smyrnadefs.h
cmd/smyrna/topview.c
cmd/smyrna/viewport.c
cmd/smyrna/viewport.h
cmd/smyrna/viewportcamera.c
lib/glcomp/glcompbutton.c
lib/glcomp/glcompbutton.h
lib/glcomp/glcompdefs.h
lib/glcomp/glcomplabel.c
lib/glcomp/glcomppanel.c
lib/glcomp/glcompset.c
lib/glcomp/glcompset.h
lib/glcomp/glutils.c
lib/glcomp/glutils.h

index 84b37c51a375e677f6fbf7ebc0d43f7846a778e6..6ce75eef99ad5a3daeb77bd43c8a86c093e12f34 100644 (file)
@@ -30,14 +30,14 @@ noinst_HEADERS = btree.h draw.h filter.h glexpose.h glmotion.h gltemplate.h \
        topfisheyeview.h viewportcamera.h gvprpipe.h \
        gui/callbacks.h gui/datalistcallbacks.h gui/filterscallbacks.h \
        gui/glmenu.h gui/gui.h gui/menucallbacks.h gui/toolboxcallbacks.h md5.h \
-       gui/topviewsettings.h gui/beacon.h drawxdot.h
+       gui/topviewsettings.h gui/beacon.h drawxdot.h arcball.h
 
 smyrna_SOURCES = btree.c draw.c filter.c glexpose.c glmotion.c gltemplate.c \
        hier.c main.c selection.c support.c template.c topview.c topviewdata.c \
        topfisheyeview.c trackball.c tvnodes.c viewport.c viewportcamera.c \
     gvprpipe.c gui/beacon.c gui/callbacks.c gui/datalistcallbacks.c \
     gui/filterscallbacks.c gui/glmenu.c gui/gui.c gui/menucallbacks.c \
-    gui/toolboxcallbacks.c gui/topviewsettings.c md5.c drawxdot.c
+    gui/toolboxcallbacks.c gui/topviewsettings.c md5.c drawxdot.c arcball.c
 
 smyrna_LDADD = $(top_builddir)/lib/cgraph/libcgraph_C.la \
                $(top_builddir)/lib/cdt/libcdt_C.la \
diff --git a/cmd/smyrna/arcball.c b/cmd/smyrna/arcball.c
new file mode 100644 (file)
index 0000000..8f6a927
--- /dev/null
@@ -0,0 +1,210 @@
+
+#include "glcompdefs.h"
+#include "arcball.h"
+#include "smyrnadefs.h"
+
+
+
+
+
+
+
+
+void setBounds(ArcBall_t* a,GLfloat NewWidth, GLfloat NewHeight)
+{
+       assert((NewWidth > 1.0f) && (NewHeight > 1.0f));
+               //Set adjustment factor for width/height
+       a->AdjustWidth  = 1.0f / ((NewWidth  - 1.0f) * 0.5f);
+       a->AdjustHeight = 1.0f / ((NewHeight - 1.0f) * 0.5f);
+}
+
+
+/*void _mapToSphere(const Point2fT* NewPt, Vector3fT* NewVec) const;
+void init_arcBall(ArcBall_t* a,GLfloat NewWidth, GLfloat NewHeight);
+void setBounds(ArcBall_t* a,GLfloat NewWidth, GLfloat NewHeight);
+void click(ArcBall_t* a,const Point2fT* NewPt);
+void drag(ArcBall_t* a,const Point2fT* NewPt, Quat4fT* NewRot);*/
+
+
+
+
+
+void _mapToSphere(ArcBall_t* a,const Point2fT* NewPt, Vector3fT* NewVec)
+{
+    Point2fT TempPt;
+    GLfloat length;
+
+    //Copy paramter into temp point
+    TempPt = *NewPt;
+
+    //Adjust point coords and scale down to range of [-1 ... 1]
+    TempPt.s.X  =        (TempPt.s.X * a->AdjustWidth)  - 1.0f;
+    TempPt.s.Y  = 1.0f - (TempPt.s.Y * a->AdjustHeight);
+
+    //Compute the square of the length of the vector to the point from the center
+    length      = (TempPt.s.X * TempPt.s.X) + (TempPt.s.Y * TempPt.s.Y);
+
+    //If the point is mapped outside of the sphere... (length > radius squared)
+    if (length > 1.0f)
+    {
+        GLfloat norm;
+
+        //Compute a normalizing factor (radius / sqrt(length))
+        norm    = 1.0f / FuncSqrt(length);
+
+        //Return the "normalized" vector, a point on the sphere
+        NewVec->s.X = TempPt.s.X * norm;
+        NewVec->s.Y = TempPt.s.Y * norm;
+        NewVec->s.Z = 0.0f;
+    }
+    else    //Else it's on the inside
+    {
+        //Return a vector to a point mapped inside the sphere sqrt(radius squared - length)
+        NewVec->s.X = TempPt.s.X;
+        NewVec->s.Y = TempPt.s.Y;
+        NewVec->s.Z = FuncSqrt(1.0f - length);
+    }
+}
+
+//Create/Destroy
+void init_arcBall(ArcBall_t* a,GLfloat NewWidth, GLfloat NewHeight)
+{
+
+       Matrix4fT   Transform   = {  1.0f,  0.0f,  0.0f,  0.0f,                         // NEW: Final Transform
+                             0.0f,  1.0f,  0.0f,  0.0f,
+                             0.0f,  0.0f,  1.0f,  0.0f,
+                             0.0f,  0.0f,  0.0f,  1.0f };
+
+       Matrix3fT   LastRot     = {  1.0f,  0.0f,  0.0f,                                        // NEW: Last Rotation
+                             0.0f,  1.0f,  0.0f,
+                             0.0f,  0.0f,  1.0f };
+
+       Matrix3fT   ThisRot     = {  1.0f,  0.0f,  0.0f,                                        // NEW: This Rotation
+                             0.0f,  1.0f,  0.0f,
+                             0.0f,  0.0f,  1.0f };
+       
+       
+       a->Transform=Transform;
+       a->LastRot=LastRot;
+       a->ThisRot=ThisRot;
+       //Clear initial values
+    a->StVec.s.X     =
+    a->StVec.s.Y     = 
+    a->StVec.s.Z     = 
+
+    a->EnVec.s.X     =
+    a->EnVec.s.Y     = 
+    a->EnVec.s.Z     = 0.0f;
+
+    //Set initial bounds
+    setBounds(a,NewWidth, NewHeight);
+
+       a->isClicked  = 0;                                                                      
+       a->isRClicked = 0;                                                                      
+       a->isDragging = 0;                                                      
+}
+
+//Mouse down
+void click(ArcBall_t* a,const Point2fT* NewPt)
+
+{
+    //Map the point to the sphere
+    _mapToSphere(a,NewPt, &a->StVec);
+}
+
+//Mouse drag, calculate rotation
+void drag(ArcBall_t* a,const Point2fT* NewPt, Quat4fT* NewRot)
+{
+    //Map the point to the sphere
+    _mapToSphere(a,NewPt, &a->EnVec);
+
+    //Return the quaternion equivalent to the rotation
+    if (NewRot)
+    {
+        Vector3fT  Perp;
+
+        //Compute the vector perpendicular to the begin and end vectors
+        Vector3fCross(&Perp, &a->StVec, &a->EnVec);
+
+        //Compute the length of the perpendicular vector
+        if (Vector3fLength(&Perp) > Epsilon)    //if its non-zero
+        {
+            //We're ok, so return the perpendicular vector as the transform after all
+            NewRot->s.X = Perp.s.X;
+            NewRot->s.Y = Perp.s.Y;
+            NewRot->s.Z = Perp.s.Z;
+            //In the quaternion values, w is cosine (theta / 2), where theta is rotation angle
+            NewRot->s.W= Vector3fDot(&a->StVec, &a->EnVec);
+        }
+        else                                    //if its zero
+        {
+            //The begin and end vectors coincide, so return an identity transform
+            NewRot->s.X = 
+            NewRot->s.Y = 
+            NewRot->s.Z = 
+            NewRot->s.W = 0.0f;
+        }
+    }
+}
+
+void arcmouseRClick(ViewInfo* v)
+{
+               Matrix3fSetIdentity(&view->arcball->LastRot);                                                           // Reset Rotation
+               Matrix3fSetIdentity(&view->arcball->ThisRot);                                                           // Reset Rotation
+        Matrix4fSetRotationFromMatrix3f(&view->arcball->Transform, &view->arcball->ThisRot);           // Reset Rotation
+
+}
+void arcmouseClick(ViewInfo* v)
+{
+       view->arcball->isDragging = 1;                                                                          // Prepare For Dragging
+       view->arcball->LastRot = view->arcball->ThisRot;                                                                                // Set Last Static Rotation To Last Dynamic One
+       click(view->arcball,&view->arcball->MousePt);   
+
+}
+void arcmouseDrag(ViewInfo* v)
+{
+       Quat4fT     ThisQuat;
+       drag(view->arcball, &view->arcball->MousePt,&ThisQuat);
+       Matrix3fSetRotationFromQuat4f(&view->arcball->ThisRot, &ThisQuat);              // Convert Quaternion Into Matrix3fT
+       Matrix3fMulMatrix3f(&view->arcball->ThisRot, &view->arcball->LastRot);                          // Accumulate Last Rotation Into This One
+       Matrix4fSetRotationFromMatrix3f(&view->arcball->Transform, &view->arcball->ThisRot);    // Set Our Final Transform's Rotation From This One
+
+}
+
+void Update (ViewInfo* view)
+{
+
+       if (view->arcball->isRClicked)                                                                                                  // If Right Mouse Clicked, Reset All Rotations
+    {
+               Matrix3fSetIdentity(&view->arcball->LastRot);                                                           // Reset Rotation
+               Matrix3fSetIdentity(&view->arcball->ThisRot);                                                           // Reset Rotation
+        Matrix4fSetRotationFromMatrix3f(&view->arcball->Transform, &view->arcball->ThisRot);           // Reset Rotation
+    }
+
+    if (!view->arcball->isDragging)                                                                                            // Not Dragging
+    {
+        if (view->arcball->isClicked)                                                                                          // First Click
+        {
+                       view->arcball->isDragging = 1;                                                                          // Prepare For Dragging
+                       view->arcball->LastRot = view->arcball->ThisRot;                                                                                // Set Last Static Rotation To Last Dynamic One
+                       click(view->arcball,&view->arcball->MousePt);   
+        }
+    }
+    else
+    {
+        if (view->arcball->isClicked)                                                                                          // Still Clicked, So Still Dragging
+        {
+            Quat4fT     ThisQuat;
+
+                       drag(view->arcball, &view->arcball->MousePt,&ThisQuat);
+            Matrix3fSetRotationFromQuat4f(&view->arcball->ThisRot, &ThisQuat);         // Convert Quaternion Into Matrix3fT
+            Matrix3fMulMatrix3f(&view->arcball->ThisRot, &view->arcball->LastRot);                             // Accumulate Last Rotation Into This One
+            Matrix4fSetRotationFromMatrix3f(&view->arcball->Transform, &view->arcball->ThisRot);       // Set Our Final Transform's Rotation From This One
+        }
+        else                                                                                                           // No Longer Dragging
+            view->arcball->isDragging = 0;
+    }
+}
+
+
+
diff --git a/cmd/smyrna/arcball.h b/cmd/smyrna/arcball.h
new file mode 100644 (file)
index 0000000..15ce8dd
--- /dev/null
@@ -0,0 +1,463 @@
+/** KempoApi: The Turloc Toolkit *****************************/
+/** *    *                                                  **/
+/** **  **  Filename: ArcBall.h                             **/
+/**   **    Version:  Common                                **/
+/**   **                                                    **/
+/**                                                         **/
+/**  Arcball class for mouse manipulation.                  **/
+/**                                                         **/
+/**                                                         **/
+/**                                                         **/
+/**                                                         **/
+/**                              (C) 1999-2003 Tatewake.com **/
+/**   History:                                              **/
+/**   08/17/2003 - (TJG) - Creation                         **/
+/**   09/23/2003 - (TJG) - Bug fix and optimization         **/
+/**   09/25/2003 - (TJG) - Version for NeHe Basecode users  **/
+/**                                                         **/
+/*************************************************************/
+
+#ifndef _ArcBall_h
+#define _ArcBall_h
+
+
+
+
+// 8<--Snip here if you have your own math types/funcs-->8 
+
+//Only support assertions in debug builds
+#ifdef _DEBUG
+# include "assert.h"
+#else
+# define assert(x) { }
+#endif
+
+//Math types derived from the KempoApi tMath library
+    typedef union Tuple2f_t
+    {
+        struct
+        {
+            GLfloat X, Y;
+        } s;
+
+        GLfloat T[2];
+    } Tuple2fT;      //A generic 2-element tuple that is represented by single-precision floating point x,y coordinates. 
+
+    typedef union Tuple3f_t
+    {
+        struct
+        {
+            GLfloat X, Y, Z;
+        } s;
+
+        GLfloat T[3];
+    } Tuple3fT;      //A generic 3-element tuple that is represented by single precision-floating point x,y,z coordinates. 
+
+    typedef union Tuple4f_t
+    {
+        struct
+        {
+            GLfloat X, Y, Z, W;
+        } s;
+
+        GLfloat T[4];
+    } Tuple4fT;      //A 4-element tuple represented by single-precision floating point x,y,z,w coordinates. 
+
+    typedef union Matrix3f_t
+    {
+            struct
+            {
+                //column major
+                union { GLfloat M00; GLfloat XX; GLfloat SX; };  //XAxis.X and Scale X
+                union { GLfloat M10; GLfloat XY;             };  //XAxis.Y
+                union { GLfloat M20; GLfloat XZ;             };  //XAxis.Z
+                union { GLfloat M01; GLfloat YX;             };  //YAxis.X
+                union { GLfloat M11; GLfloat YY; GLfloat SY; };  //YAxis.Y and Scale Y
+                union { GLfloat M21; GLfloat YZ;             };  //YAxis.Z
+                union { GLfloat M02; GLfloat ZX;             };  //ZAxis.X
+                union { GLfloat M12; GLfloat ZY;             };  //ZAxis.Y
+                union { GLfloat M22; GLfloat ZZ; GLfloat SZ; };  //ZAxis.Z and Scale Z
+            } s;
+            GLfloat M[9];
+    } Matrix3fT;     //A single precision floating point 3 by 3 matrix. 
+
+    typedef union Matrix4f_t
+    {
+            struct
+            {
+                //column major
+                union { GLfloat M00; GLfloat XX; GLfloat SX; };  //XAxis.X and Scale X
+                union { GLfloat M10; GLfloat XY;             };  //XAxis.Y
+                union { GLfloat M20; GLfloat XZ;             };  //XAxis.Z
+                union { GLfloat M30; GLfloat XW;             };  //XAxis.W
+                union { GLfloat M01; GLfloat YX;             };  //YAxis.X
+                union { GLfloat M11; GLfloat YY; GLfloat SY; };  //YAxis.Y and Scale Y
+                union { GLfloat M21; GLfloat YZ;             };  //YAxis.Z
+                union { GLfloat M31; GLfloat YW;             };  //YAxis.W
+                union { GLfloat M02; GLfloat ZX;             };  //ZAxis.X
+                union { GLfloat M12; GLfloat ZY;             };  //ZAxis.Y
+                union { GLfloat M22; GLfloat ZZ; GLfloat SZ; };  //ZAxis.Z and Scale Z
+                union { GLfloat M32; GLfloat ZW;             };  //ZAxis.W
+                union { GLfloat M03; GLfloat TX;             };  //Trans.X
+                union { GLfloat M13; GLfloat TY;             };  //Trans.Y
+                union { GLfloat M23; GLfloat TZ;             };  //Trans.Z
+                union { GLfloat M33; GLfloat TW; GLfloat SW; };  //Trans.W and Scale W
+            } s;
+            GLfloat M[16];
+    } Matrix4fT;     //A single precision floating point 4 by 4 matrix. 
+
+
+//"Inherited" types
+#define Point2fT    Tuple2fT   //A 2 element point that is represented by single precision floating point x,y coordinates. 
+
+#define Quat4fT     Tuple4fT   //A 4 element unit quaternion represented by single precision floating point x,y,z,w coordinates. 
+
+#define Vector2fT   Tuple2fT   //A 2-element vector that is represented by single-precision floating point x,y coordinates. 
+#define Vector3fT   Tuple3fT   //A 3-element vector that is represented by single-precision floating point x,y,z coordinates. 
+
+//Custom math, or speed overrides
+#define FuncSqrt    sqrtf
+
+//utility macros
+//assuming IEEE-754(GLfloat), which i believe has max precision of 7 bits
+# define Epsilon 1.0e-5
+
+//Math functions
+
+    /**
+     * Sets the value of this tuple to the vector sum of itself and tuple t1.
+     * @param t1  the other tuple
+     */
+    static void Point2fAdd(Point2fT* NewObj, const Tuple2fT* t1)
+    {
+        assert(NewObj && t1);
+
+        NewObj->s.X += t1->s.X;
+        NewObj->s.Y += t1->s.Y;
+    }
+
+    /**
+      * Sets the value of this tuple to the vector difference of itself and tuple t1 (this = this - t1).
+      * @param t1 the other tuple
+      */
+    
+    static void Point2fSub(Point2fT* NewObj, const Tuple2fT* t1)
+    {
+        assert(NewObj && t1);
+
+        NewObj->s.X -= t1->s.X;
+        NewObj->s.Y -= t1->s.Y;
+    }
+
+    /**
+      * Sets this vector to be the vector cross product of vectors v1 and v2.
+      * @param v1 the first vector
+      * @param v2 the second vector
+      */
+    
+    static void Vector3fCross(Vector3fT* NewObj, const Vector3fT* v1, const Vector3fT* v2)
+    {
+        Vector3fT Result; //safe not to initialize
+
+        assert(NewObj && v1 && v2);
+
+        // store on stack once for aliasing-safty
+        // i.e. safe when a.cross(a, b)
+
+        Result.s.X = (v1->s.Y * v2->s.Z) - (v1->s.Z * v2->s.Y);
+        Result.s.Y = (v1->s.Z * v2->s.X) - (v1->s.X * v2->s.Z);
+        Result.s.Z = (v1->s.X * v2->s.Y) - (v1->s.Y * v2->s.X);
+
+        //copy result back
+        *NewObj = Result;
+    }
+
+    /**
+      * Computes the dot product of the this vector and vector v1.
+      * @param  v1 the other vector
+      */
+    
+    static GLfloat Vector3fDot(const Vector3fT* NewObj, const Vector3fT* v1)
+    {
+        assert(NewObj && v1);
+
+        return  (NewObj->s.X * v1->s.X) +
+                (NewObj->s.Y * v1->s.Y) +
+                (NewObj->s.Z * v1->s.Z);
+    }
+
+    /**
+      * Returns the squared length of this vector.
+      * @return the squared length of this vector
+      */
+    
+    static GLfloat Vector3fLengthSquared(const Vector3fT* NewObj)
+    {
+        assert(NewObj);
+
+        return  (NewObj->s.X * NewObj->s.X) +
+                (NewObj->s.Y * NewObj->s.Y) +
+                (NewObj->s.Z * NewObj->s.Z);
+    }
+
+    /**
+      * Returns the length of this vector.
+      * @return the length of this vector
+      */
+    
+    static GLfloat Vector3fLength(const Vector3fT* NewObj)
+    {
+        assert(NewObj);
+
+        return FuncSqrt(Vector3fLengthSquared(NewObj));
+    }
+
+    
+    static void Matrix3fSetZero(Matrix3fT* NewObj)
+    {
+        NewObj->s.M00 = NewObj->s.M01 = NewObj->s.M02 = 
+        NewObj->s.M10 = NewObj->s.M11 = NewObj->s.M12 = 
+        NewObj->s.M20 = NewObj->s.M21 = NewObj->s.M22 = 0.0f;
+    }
+
+    /**
+     * Sets this Matrix3 to identity.
+     */
+    
+    static void Matrix3fSetIdentity(Matrix3fT* NewObj)
+    {
+        Matrix3fSetZero(NewObj);
+
+        //then set diagonal as 1
+        NewObj->s.M00 = 
+        NewObj->s.M11 = 
+        NewObj->s.M22 = 1.0f;
+    }
+
+    /**
+      * Sets the value of this matrix to the matrix conversion of the
+      * quaternion argument. 
+      * @param q1 the quaternion to be converted 
+      */
+    //$hack this can be optimized some(if s == 0)
+    
+    static void Matrix3fSetRotationFromQuat4f(Matrix3fT* NewObj, const Quat4fT* q1)
+    {
+        GLfloat n, s;
+        GLfloat xs, ys, zs;
+        GLfloat wx, wy, wz;
+        GLfloat xx, xy, xz;
+        GLfloat yy, yz, zz;
+
+        assert(NewObj && q1);
+
+        n = (q1->s.X * q1->s.X) + (q1->s.Y * q1->s.Y) + (q1->s.Z * q1->s.Z) + (q1->s.W * q1->s.W);
+        s = (n > 0.0f) ? (2.0f / n) : 0.0f;
+
+        xs = q1->s.X * s;  ys = q1->s.Y * s;  zs = q1->s.Z * s;
+        wx = q1->s.W * xs; wy = q1->s.W * ys; wz = q1->s.W * zs;
+        xx = q1->s.X * xs; xy = q1->s.X * ys; xz = q1->s.X * zs;
+        yy = q1->s.Y * ys; yz = q1->s.Y * zs; zz = q1->s.Z * zs;
+
+        NewObj->s.XX = 1.0f - (yy + zz); NewObj->s.YX =         xy - wz;  NewObj->s.ZX =         xz + wy;
+        NewObj->s.XY =         xy + wz;  NewObj->s.YY = 1.0f - (xx + zz); NewObj->s.ZY =         yz - wx;
+        NewObj->s.XZ =         xz - wy;  NewObj->s.YZ =         yz + wx;  NewObj->s.ZZ = 1.0f - (xx + yy);
+    }
+
+    /**
+     * Sets the value of this matrix to the result of multiplying itself
+     * with matrix m1. 
+     * @param m1 the other matrix 
+     */
+    
+    static void Matrix3fMulMatrix3f(Matrix3fT* NewObj, const Matrix3fT* m1)
+    {
+        Matrix3fT Result; //safe not to initialize
+
+        assert(NewObj && m1);
+
+        // alias-safe way.
+        Result.s.M00 = (NewObj->s.M00 * m1->s.M00) + (NewObj->s.M01 * m1->s.M10) + (NewObj->s.M02 * m1->s.M20);
+        Result.s.M01 = (NewObj->s.M00 * m1->s.M01) + (NewObj->s.M01 * m1->s.M11) + (NewObj->s.M02 * m1->s.M21);
+        Result.s.M02 = (NewObj->s.M00 * m1->s.M02) + (NewObj->s.M01 * m1->s.M12) + (NewObj->s.M02 * m1->s.M22);
+
+        Result.s.M10 = (NewObj->s.M10 * m1->s.M00) + (NewObj->s.M11 * m1->s.M10) + (NewObj->s.M12 * m1->s.M20);
+        Result.s.M11 = (NewObj->s.M10 * m1->s.M01) + (NewObj->s.M11 * m1->s.M11) + (NewObj->s.M12 * m1->s.M21);
+        Result.s.M12 = (NewObj->s.M10 * m1->s.M02) + (NewObj->s.M11 * m1->s.M12) + (NewObj->s.M12 * m1->s.M22);
+
+        Result.s.M20 = (NewObj->s.M20 * m1->s.M00) + (NewObj->s.M21 * m1->s.M10) + (NewObj->s.M22 * m1->s.M20);
+        Result.s.M21 = (NewObj->s.M20 * m1->s.M01) + (NewObj->s.M21 * m1->s.M11) + (NewObj->s.M22 * m1->s.M21);
+        Result.s.M22 = (NewObj->s.M20 * m1->s.M02) + (NewObj->s.M21 * m1->s.M12) + (NewObj->s.M22 * m1->s.M22);
+
+        //copy result back to this
+        *NewObj = Result;
+    }
+
+    
+    static void Matrix4fSetRotationScaleFromMatrix4f(Matrix4fT* NewObj, const Matrix4fT* m1)
+    {
+        assert(NewObj && m1);
+
+        NewObj->s.XX = m1->s.XX; NewObj->s.YX = m1->s.YX; NewObj->s.ZX = m1->s.ZX;
+        NewObj->s.XY = m1->s.XY; NewObj->s.YY = m1->s.YY; NewObj->s.ZY = m1->s.ZY;
+        NewObj->s.XZ = m1->s.XZ; NewObj->s.YZ = m1->s.YZ; NewObj->s.ZZ = m1->s.ZZ;
+    }
+
+    /**
+      * Performs SVD on this matrix and gets scale and rotation.
+      * Rotation is placed into rot3, and rot4.
+      * @param rot3 the rotation factor(Matrix3d). if null, ignored
+      * @param rot4 the rotation factor(Matrix4) only upper 3x3 elements are changed. if null, ignored
+      * @return scale factor
+      */
+    
+    static GLfloat Matrix4fSVD(const Matrix4fT* NewObj, Matrix3fT* rot3, Matrix4fT* rot4)
+    {
+        GLfloat s, n;
+
+        assert(NewObj);
+
+        // this is a simple svd.
+        // Not complete but fast and reasonable.
+        // See comment in Matrix3d.
+
+        s = FuncSqrt(
+                ( (NewObj->s.XX * NewObj->s.XX) + (NewObj->s.XY * NewObj->s.XY) + (NewObj->s.XZ * NewObj->s.XZ) + 
+                  (NewObj->s.YX * NewObj->s.YX) + (NewObj->s.YY * NewObj->s.YY) + (NewObj->s.YZ * NewObj->s.YZ) +
+                  (NewObj->s.ZX * NewObj->s.ZX) + (NewObj->s.ZY * NewObj->s.ZY) + (NewObj->s.ZZ * NewObj->s.ZZ) ) / 3.0f );
+
+        if (rot3)   //if pointer not null
+        {
+            //this->getRotationScale(rot3);
+            rot3->s.XX = NewObj->s.XX; rot3->s.XY = NewObj->s.XY; rot3->s.XZ = NewObj->s.XZ;
+            rot3->s.YX = NewObj->s.YX; rot3->s.YY = NewObj->s.YY; rot3->s.YZ = NewObj->s.YZ;
+            rot3->s.ZX = NewObj->s.ZX; rot3->s.ZY = NewObj->s.ZY; rot3->s.ZZ = NewObj->s.ZZ;
+
+            // zero-div may occur.
+
+            n = 1.0f / FuncSqrt( (NewObj->s.XX * NewObj->s.XX) +
+                                      (NewObj->s.XY * NewObj->s.XY) +
+                                      (NewObj->s.XZ * NewObj->s.XZ) );
+            rot3->s.XX *= n;
+            rot3->s.XY *= n;
+            rot3->s.XZ *= n;
+
+            n = 1.0f / FuncSqrt( (NewObj->s.YX * NewObj->s.YX) +
+                                      (NewObj->s.YY * NewObj->s.YY) +
+                                      (NewObj->s.YZ * NewObj->s.YZ) );
+            rot3->s.YX *= n;
+            rot3->s.YY *= n;
+            rot3->s.YZ *= n;
+
+            n = 1.0f / FuncSqrt( (NewObj->s.ZX * NewObj->s.ZX) +
+                                      (NewObj->s.ZY * NewObj->s.ZY) +
+                                      (NewObj->s.ZZ * NewObj->s.ZZ) );
+            rot3->s.ZX *= n;
+            rot3->s.ZY *= n;
+            rot3->s.ZZ *= n;
+        }
+
+        if (rot4)   //if pointer not null
+        {
+            if (rot4 != NewObj)
+            {
+                Matrix4fSetRotationScaleFromMatrix4f(rot4, NewObj);  // private method
+            }
+
+            // zero-div may occur.
+
+            n = 1.0f / FuncSqrt( (NewObj->s.XX * NewObj->s.XX) +
+                                      (NewObj->s.XY * NewObj->s.XY) +
+                                      (NewObj->s.XZ * NewObj->s.XZ) );
+            rot4->s.XX *= n;
+            rot4->s.XY *= n;
+            rot4->s.XZ *= n;
+
+            n = 1.0f / FuncSqrt( (NewObj->s.YX * NewObj->s.YX) +
+                                      (NewObj->s.YY * NewObj->s.YY) +
+                                      (NewObj->s.YZ * NewObj->s.YZ) );
+            rot4->s.YX *= n;
+            rot4->s.YY *= n;
+            rot4->s.YZ *= n;
+
+            n = 1.0f / FuncSqrt( (NewObj->s.ZX * NewObj->s.ZX) +
+                                      (NewObj->s.ZY * NewObj->s.ZY) +
+                                      (NewObj->s.ZZ * NewObj->s.ZZ) );
+            rot4->s.ZX *= n;
+            rot4->s.ZY *= n;
+            rot4->s.ZZ *= n;
+        }
+
+        return s;
+    }
+
+    
+    static void Matrix4fSetRotationScaleFromMatrix3f(Matrix4fT* NewObj, const Matrix3fT* m1)
+    {
+        assert(NewObj && m1);
+
+        NewObj->s.XX = m1->s.XX; NewObj->s.YX = m1->s.YX; NewObj->s.ZX = m1->s.ZX;
+        NewObj->s.XY = m1->s.XY; NewObj->s.YY = m1->s.YY; NewObj->s.ZY = m1->s.ZY;
+        NewObj->s.XZ = m1->s.XZ; NewObj->s.YZ = m1->s.YZ; NewObj->s.ZZ = m1->s.ZZ;
+    }
+
+    
+    static void Matrix4fMulRotationScale(Matrix4fT* NewObj, GLfloat scale)
+    {
+        assert(NewObj);
+
+        NewObj->s.XX *= scale; NewObj->s.YX *= scale; NewObj->s.ZX *= scale;
+        NewObj->s.XY *= scale; NewObj->s.YY *= scale; NewObj->s.ZY *= scale;
+        NewObj->s.XZ *= scale; NewObj->s.YZ *= scale; NewObj->s.ZZ *= scale;
+    }
+
+    /**
+      * Sets the rotational component (upper 3x3) of this matrix to the matrix
+      * values in the T precision Matrix3d argument; the other elements of
+      * this matrix are unchanged; a singular value decomposition is performed
+      * on this object's upper 3x3 matrix to factor out the scale, then this
+      * object's upper 3x3 matrix components are replaced by the passed rotation
+      * components, and then the scale is reapplied to the rotational
+      * components.
+      * @param m1 T precision 3x3 matrix
+      */
+    
+    static void Matrix4fSetRotationFromMatrix3f(Matrix4fT* NewObj, const Matrix3fT* m1)
+    {
+        GLfloat scale;
+
+        assert(NewObj && m1);
+
+        scale = Matrix4fSVD(NewObj, NULL, NULL);
+
+        Matrix4fSetRotationScaleFromMatrix3f(NewObj, m1);
+        Matrix4fMulRotationScale(NewObj, scale);
+    }
+
+// 8<--Snip here if you have your own math types/funcs-->8 
+typedef struct _ArcBall_t 
+{
+       Vector3fT   StVec; 
+       Vector3fT   EnVec; 
+       GLfloat     AdjustWidth; 
+       GLfloat     AdjustHeight; 
+       Matrix4fT   Transform;
+       Matrix3fT   LastRot;
+       Matrix3fT   ThisRot;
+       Point2fT    MousePt;
+       int        isClicked;
+       int        isRClicked;
+       int        isDragging;
+} ArcBall_t;
+
+       
+void _mapToSphere(ArcBall_t* a,const Point2fT* NewPt, Vector3fT* NewVec);
+void init_arcBall(ArcBall_t* a,GLfloat NewWidth, GLfloat NewHeight);
+void setBounds(ArcBall_t* a,GLfloat NewWidth, GLfloat NewHeight);
+void click(ArcBall_t* a,const Point2fT* NewPt);
+void drag(ArcBall_t* a,const Point2fT* NewPt, Quat4fT* NewRot);
+
+
+
+#endif
+
index 63d5fd170eee3ba2496af1b2618939cfb3b2634a..ad0fdfcea787d902be9a54f4f45f3006dabbfbcb 100644 (file)
 #include "topfisheyeview.h"
 #include "glcomptext.h"
 #include "gui/toolboxcallbacks.h"
-
-
+void drawRotatingAxis(void);
+void draw_cube()
+{
+       
+glBegin(GL_QUADS);             // Draw The Cube Using quads
+    glColor3f(0.0f,100.0f,0.0f);       // Color Blue
+    glVertex3f( 100.0f, 100.0f,-100.0f);       // Top Right Of The Quad (Top)
+    glVertex3f(-100.0f, 100.0f,-100.0f);       // Top Left Of The Quad (Top)
+    glVertex3f(-100.0f, 100.0f, 100.0f);       // Bottom Left Of The Quad (Top)
+    glVertex3f( 100.0f, 100.0f, 100.0f);       // Bottom Right Of The Quad (Top)
+    glColor3f(100.0f,0.5f,0.0f);       // Color Orange
+    glVertex3f( 100.0f,-100.0f, 100.0f);       // Top Right Of The Quad (Bottom)
+    glVertex3f(-100.0f,-100.0f, 100.0f);       // Top Left Of The Quad (Bottom)
+    glVertex3f(-100.0f,-100.0f,-100.0f);       // Bottom Left Of The Quad (Bottom)
+    glVertex3f( 100.0f,-100.0f,-100.0f);       // Bottom Right Of The Quad (Bottom)
+    glColor3f(100.0f,0.0f,0.0f);       // Color Red    
+    glVertex3f( 100.0f, 100.0f, 100.0f);       // Top Right Of The Quad (Front)
+    glVertex3f(-100.0f, 100.0f, 100.0f);       // Top Left Of The Quad (Front)
+    glVertex3f(-100.0f,-100.0f, 100.0f);       // Bottom Left Of The Quad (Front)
+    glVertex3f( 100.0f,-100.0f, 100.0f);       // Bottom Right Of The Quad (Front)
+    glColor3f(100.0f,100.0f,0.0f);     // Color Yellow
+    glVertex3f( 100.0f,-100.0f,-100.0f);       // Top Right Of The Quad (Back)
+    glVertex3f(-100.0f,-100.0f,-100.0f);       // Top Left Of The Quad (Back)
+    glVertex3f(-100.0f, 100.0f,-100.0f);       // Bottom Left Of The Quad (Back)
+    glVertex3f( 100.0f, 100.0f,-100.0f);       // Bottom Right Of The Quad (Back)
+    glColor3f(0.0f,0.0f,100.0f);       // Color Blue
+    glVertex3f(-100.0f, 100.0f, 100.0f);       // Top Right Of The Quad (Left)
+    glVertex3f(-100.0f, 100.0f,-100.0f);       // Top Left Of The Quad (Left)
+    glVertex3f(-100.0f,-100.0f,-100.0f);       // Bottom Left Of The Quad (Left)
+    glVertex3f(-100.0f,-100.0f, 100.0f);       // Bottom Right Of The Quad (Left)
+    glColor3f(100.0f,0.0f,100.0f);     // Color Violet
+    glVertex3f( 100.0f, 100.0f,-100.0f);       // Top Right Of The Quad (Right)
+    glVertex3f( 100.0f, 100.0f, 100.0f);       // Top Left Of The Quad (Right)
+    glVertex3f( 100.0f,-100.0f, 100.0f);       // Bottom Left Of The Quad (Right)
+    glVertex3f( 100.0f,-100.0f,-100.0f);       // Bottom Right Of The Quad (Right)
+  glEnd();     
+}
 
 /*
        refreshes camera settings using view parameters such as pan zoom etc
@@ -33,7 +68,6 @@
 int glupdatecamera(ViewInfo * view)
 {
 
-       glLoadIdentity();
        if (view->active_camera==-1)
        {
                gluLookAt(view->panx, view->pany, 20, view->panx,
@@ -44,24 +78,11 @@ int glupdatecamera(ViewInfo * view)
        /*toggle to active camera*/
        else
        {
-               /*gluLookAt(view->cameras[view->active_camera]->x,view->cameras[view->active_camera]->y,view->cameras[view->active_camera]->z,
-               view->cameras[view->active_camera]->targetx,view->cameras[view->active_camera]->targety,view->cameras[view->active_camera]->targetz,
-               view->cameras[view->active_camera]->camera_vectorx,
-               view->cameras[view->active_camera]->camera_vectory,
-               view->cameras[view->active_camera]->camera_vectorz);*/
                gluLookAt(view->cameras[view->active_camera]->targetx, view->cameras[view->active_camera]->targety, 20, view->cameras[view->active_camera]->targetx,
                view->cameras[view->active_camera]->targety, 0.0, 0.0, 1.0, 0.0);
-//                     glTranslatef(view->cameras[view->active_camera]->targetx/pow(view->cameras[view->active_camera]->r,0.125),view->cameras[view->active_camera]->targety/pow(view->cameras[view->active_camera]->r,0.125),0);
-/*                     glRotatef(view->cameras[view->active_camera]->angley,1,0,0);
-                       glRotatef(view->cameras[view->active_camera]->anglex,0,1,0);
-                       glRotatef(view->cameras[view->active_camera]->anglez,0,0,1);*/
-
-                       glRotatef(view->cameras[view->active_camera]->angley,1,0,0);
-                       glRotatef(view->cameras[view->active_camera]->anglex,0,1,0);
-                       glRotatef(view->cameras[view->active_camera]->anglez,0,0,1);
-
-
+               glMultMatrixf(view->arcball->Transform.M); /*arcball transformations , experimental*/
        }
+
        GetOGLPosRef(1, view->h - 5, &(view->clipX1), &(view->clipY1),
                 &(view->clipZ1));
     GetOGLPosRef(view->w - 1, 1, &(view->clipX2), &(view->clipY2),
@@ -90,6 +111,7 @@ int glexpose_main(ViewInfo * view)
        static int doonce=0;
        if (!glupdatecamera(view))
        return 0;
+
        if (view->activeGraph >= 0)
        {
                if(!doonce)
@@ -106,7 +128,9 @@ int glexpose_main(ViewInfo * view)
     glexpose_drawgraph(view);
     draw_selection_box(view);
     drawBorders(view);
-       drawRotatingTools();
+//     drawRotatingTools();
+//     draw_cube();
+       drawRotatingAxis();
 //             draw_stuff();
 //     test_color_pallete();
 
@@ -193,10 +217,6 @@ int glexpose_drawgraph(ViewInfo * view)
                        {
                                drawtopologicalfisheye(view->Topview);
                        }
-//                     glCompDrawBegin();
-//                     OtkUpdateCheck();
-//                     glCompDrawEnd();
-//                     OtkDrawAll_scene( 0);
 
 //             }
 //             else
@@ -207,6 +227,53 @@ int glexpose_drawgraph(ViewInfo * view)
        return 0;
 }
 
+void drawRotatingAxis(void)
+{
+       float x,y;
+       float x1,y1,z1;
+       float x2,y2,z2;
+       float R1,R2;
+       static GLUquadricObj *quadratic=(GLUquadricObj*)0;
+       if (!quadratic)
+       {
+               quadratic=gluNewQuadric();                                                                              // Create A Pointer To The Quadric Object
+               gluQuadricNormals(quadratic, GLU_SMOOTH);                                               // Create Smooth Normals
+//             gluQuadricTexture(quadratic, GL_TRUE);                                                  // Create Texture Coords
+               gluQuadricDrawStyle (quadratic,GLU_LINE);
+
+
+       }
+
+       if ((view->mouse.mouse_mode == MM_ROTATE) && (view->active_camera >=0))
+       {
+               float AL=45;
+               glPushMatrix();
+               glLoadIdentity();
+               glMultMatrixf(view->arcball->Transform.M); /*arcball transformations , experimental*/
+               glLineWidth(3);
+               glBegin(GL_LINES);
+                       glColor3f(1,1,0);
+       
+                       glVertex3f(0,0,0);
+                       glVertex3f(0,AL,0);
+
+                       glVertex3f(0,0,0);
+                       glVertex3f(AL,0,0);
+
+                       glVertex3f(0,0,0);
+                       glVertex3f(0,0,AL);
+
+               glEnd();
+               glColor4f(0,1,0,0.3);
+               gluSphere(quadratic,45,20,20);
+               glLineWidth(1);
+               glPopMatrix();
+
+       }
+
+}
+
+
 void drawRotatingTools(void)
 {
        float x,y;
index e49ceb39cbba7cf4ec70ac6a604a2f7343289cde..5e3cba43af1c4d404a76166ba547d03b6fb75c69 100644 (file)
@@ -23,6 +23,7 @@ void glexpose_grid(ViewInfo * v);
 int glexpose_drawgraph(ViewInfo * view);
 void drawRotatingTools(void);
 void drawtestpoly(void);
+void draw_cube(void);
 
 
 #endif
index 049474228ef5207a027e3f849e4e69e5666706f9..275b964a08f95f8188c00e79623b7bbcd4e062da 100644 (file)
@@ -184,8 +184,10 @@ static float mod_angle(float angle)
 #endif
 void glmotion_rotate(ViewInfo * v)
 {
-       if(v->mouse.rotate_axis==MOUSE_ROTATE_XY)
+/*     if(v->mouse.rotate_axis==MOUSE_ROTATE_XY)
        {
+               v->arcball
+
                v->cameras[v->active_camera]->angley-=v->mouse.dy/7;
                v->cameras[v->active_camera]->anglex-=v->mouse.dx/7;
        }
@@ -201,5 +203,5 @@ void glmotion_rotate(ViewInfo * v)
        {
                v->cameras[v->active_camera]->anglez-=v->mouse.dx/7;
                v->cameras[v->active_camera]->anglez-=v->mouse.dy/7;
-       }
+       }*/
 }
index 84c0508000991bb8eb97aec7781e054226f911c6..0ea573cd7c4c3fede44b2d6f0c564dd3e904345e 100755 (executable)
@@ -30,6 +30,7 @@
 #include "glcompset.h"
 #include "viewportcamera.h"
 #include "gui/menucallbacks.h"
+#include "arcball.h"
 static float begin_x = 0.0;
 static float begin_y = 0.0;
 static float dx = 0.0;
@@ -187,6 +188,10 @@ static gboolean configure_event(GtkWidget * widget,
     GdkGLDrawable *gldrawable = gtk_widget_get_gl_drawable(widget);
     view->w = widget->allocation.width;
     view->h = widget->allocation.height;
+       if (view->widgets)
+               glcompsetUpdateBorder(view->widgets, view->w, view->h);
+
+
        /*** OpenGL BEGIN ***/
     if (!gdk_gl_drawable_gl_begin(gldrawable, glcontext))
        return FALSE;
@@ -196,6 +201,9 @@ static gboolean configure_event(GtkWidget * widget,
     /* setup various opengl things that we need */
     glMatrixMode(GL_PROJECTION);
     glLoadIdentity();
+       if (widget->allocation.width > 1)
+               init_arcBall(view->arcball,(GLfloat)view->w,(GLfloat)view->h);
+
     if (view->w > view->h) {
        aspect = (float) view->w / (float) view->h;
        glOrtho(-aspect * GL_VIEWPORT_FACTOR, aspect * GL_VIEWPORT_FACTOR,
@@ -299,7 +307,7 @@ static gboolean button_press_event(GtkWidget * widget,
        }
     if (event->button == 1)    //left click
     {
-               view->prevpanx = view->panx;
+
                view->prevpany = view->pany;
                view->mouse.mouse_down = 1;
                view->mouse.button = leftmousebutton;
@@ -311,6 +319,7 @@ static gboolean button_press_event(GtkWidget * widget,
                        expose_event(view->drawing_area, NULL, NULL);
                }
     }
+       /*experimental code for arcball, init first click */
     return FALSE;
 }
 
@@ -323,7 +332,7 @@ static gboolean button_release_event(GtkWidget * widget,
                                     GdkEventButton * event, gpointer data)
 {
        view->FontSizeConst=GetOGLDistance(14);
-
+       view->arcball->isDragging=0;
 
        if (event->button == 1) //left click release
     {
@@ -422,7 +431,7 @@ static gboolean motion_notify_event(GtkWidget * widget,
     /* float h = (float)widget->allocation.height; */
     float x = (float) event->x;
     float y = (float) event->y;
-
+       
 
     gboolean redraw = FALSE;
 
@@ -445,7 +454,23 @@ static gboolean motion_notify_event(GtkWidget * widget,
     /*rotating, only in 3d view */
     if ((view->active_camera >= 0) && (view->mouse.mouse_mode == MM_ROTATE)
        && (event->state & GDK_BUTTON1_MASK)) {
-               glmotion_main(view, event, widget);
+
+                       view->arcball->MousePt.s.X = (GLfloat)x;
+                       view->arcball->MousePt.s.Y = (GLfloat)y;
+
+               if (!view->arcball->isDragging)
+               {
+                       arcmouseClick(view);
+                       view->arcball->isDragging=1;
+
+               }
+               else
+               {
+                       arcmouseDrag(view);
+
+               }
+
+//             glmotion_main(view, event, widget);
            redraw = TRUE;
     }
     /*zooming */
index 2c91a836e831cdf0c1009b442e82bc239b69cd57..ed540fcd03899a364a4ceca506f4f529502de231 100644 (file)
                        Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
                        UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
                        >
+                       <File
+                               RelativePath=".\arcball.c"
+                               >
+                       </File>
                        <File
                                RelativePath=".\gui\beacon.c"
                                >
index a751836cc0ed75e147cd9e4ae780623d67c6ad03..0cd9e74a14ffb4025576bea2cde23a9073448537 100644 (file)
@@ -38,6 +38,8 @@
 #include "glcompset.h"
 #include "hier.h"
 #include "md5.h"
+#include "glutils.h"
+#include "arcball.h"
 
 #define IS_TEST_MODE_ON                                                        0
 #define        DEFAULT_MAGNIFIER_WIDTH                                 300
@@ -121,6 +123,7 @@ typedef enum {
     VT_TOPFISH,
 } viewtype_t;
 
+
 typedef enum { 
     GVE_NONE = -1, 
     GVE_GRAPH,
@@ -139,6 +142,19 @@ typedef enum {
     GVK_SFDP/* keep last */
 } gvk_layout;
 
+typedef struct {
+       int anglex;
+       int angley;
+       int anglez;
+} rotation;
+
+typedef struct {
+       int anglex;
+       int angley;
+       int anglez;
+} gl3DNav;
+
+
 typedef struct {
     GtkButton **gtkhostbtn;
     int gtkhostbtncount;
@@ -411,11 +427,7 @@ typedef struct _fisheye_magnifier {
     int fisheye_distortion_fac;
 } fisheye_magnifier;
 
-typedef struct
-{
-       float x1,y1,x2,y2;
 
-}line;
 
 typedef struct _ViewInfo
 {
@@ -580,8 +592,13 @@ typedef struct _ViewInfo
        gvprscript* scripts;
        int script_count;  /*# of scripts*/
        GtkComboBox* graphComboBox;/*pointer to graph combo box at top right*/
+       ArcBall_t* arcball;
 
 } ViewInfo;
+/*rotation steps*/
+
+
+
 
 extern ViewInfo *view;
 extern GtkMessageDialog *Dlg;
index 215f9c7d63ecaed8b5bd2e713706ca5def7fe0d5..9b00aacc3b4627f6096a4b1a48dfc66d8042bfaa 100755 (executable)
@@ -380,7 +380,6 @@ void update_topview(Agraph_t * g, topview * t,int init)
                                append_textview((GtkTextView*) glade_xml_get_widget(xml,"mainconsole"),str,strlen(str));        
                }
        }
-
        
 
        /*end of temp code*/
@@ -474,11 +473,6 @@ void preparetopview(Agraph_t * g, topview * t)
 
        /*create glcomp menu system*/
        view->widgets =glcreate_gl_topview_menu();
-
-
-       /*for 3d graphs , camera controlling widget extension*/
-       attach_camera_widget(view);
-
        /*for grouped data , group data viewing buttons extension*/     
 //     load_host_buttons(t, g, view->widgets);
        /*set topologilca fisheye to NULL*/
@@ -494,6 +488,10 @@ void preparetopview(Agraph_t * g, topview * t)
        t->picked_edge_count = 0;
     t->picked_edges = '\0';
 
+       /*hide stupid console window*/
+       gtk_widget_hide(glade_xml_get_widget(xml, "vbox13"));
+
+
 }
 
 
@@ -1442,13 +1440,23 @@ static void menu_click_control(void *p)
     glCompSet *s;
     int ind = 0;
     s = ((glCompButton *) p)->parentset;
-    for (ind = 0; ind < s->panelcount; ind++) {
-       if (s->panels[ind]->data > 0)
-           glCompPanelHide(s->panels[ind]);    //hide all panels
-       if (s->panels[ind]->data == 1)  //control panel
+    for (ind = 0; ind < s->panelcount; ind++) 
        {
-           glCompPanelShow(s->panels[ind]);
-       }
+               if (s->panels[ind]->data == 1)  //control panel
+               {
+                       if (s->panels[ind]->visible)
+                       {
+                               glCompPanelHide(s->panels[ind]);
+                               glCompButtonSetText(p,"Controls");
+                       }
+                       else
+                       {
+                               glCompPanelShow(s->panels[ind]);
+                               glCompButtonSetText(p,"Hide");
+
+                       }
+
+               }
     }
 }
 
@@ -1467,16 +1475,6 @@ static void menu_click_data(void *p)
     }
 }
 
-static void menu_click_hide(void *p)
-{
-    glCompSet *s;
-    int ind = 0;
-    s = ((glCompButton *) p)->parentset;
-    for (ind = 0; ind < s->panelcount; ind++) {
-       if (s->panels[ind]->data > 0)
-           glCompPanelHide(s->panels[ind]);    //hide all panels
-    }
-}
 
 static void menu_click_pan(void *p)
 {
@@ -1516,41 +1514,28 @@ static void menu_click_alpha_plus(void *p)
 }
 #endif
 
-static void menu_click_3d_view(void *p)
-{
-    glCompSet *s;
-    int ind = 0;
-    s = ((glCompButton *) p)->parentset;
-    for (ind = 0; ind < s->panelcount; ind++) {
-       if (s->panels[ind]->data > 0)
-           glCompPanelHide(s->panels[ind]);    //hide all panels
-       if (s->panels[ind]->data == 3)  //cameras panel
-       {
-           glCompPanelShow(s->panels[ind]);
-       }
-    }
 
-}
 
-static void menu_switch_to_normal_mode(void *p)
+static void menu_switch_to_fisheye(void *p)
 {
-    view->Topview->is_top_fisheye = 0;
-
-       g_timer_stop(view->timer);
+       if (!view->Topview->is_top_fisheye == 1)
+       {
+               if (!view->Topview->h) 
+               {
+                       prepare_topological_fisheye(view->Topview);
+                       g_timer_start(view->timer);
+               }
+               view->Topview->is_top_fisheye = 1;
+               glCompButtonSetText(p,"Normal");
 
-}
+       }
+       else
+       {
+               view->Topview->is_top_fisheye = 0;
+               glCompButtonSetText(p,"Fisheye");
+               g_timer_stop(view->timer);
+       }
 
-static void menu_switch_to_fisheye(void *p)
-{
-    if (!view->Topview->h) {
-       prepare_topological_fisheye(view->Topview);
-       g_timer_start(view->timer);
-    }
-    view->Topview->is_top_fisheye = 1;
-/*    char* str;
-       int value;
-       str = agget(view->g[view->activeGraph], "topologicalfisheyelabelfinenodes");
-       value = (float) atof(str);*/
 
 }
 
@@ -1560,33 +1545,6 @@ static void menu_click_rotate(void *p)
        view->mouse.mouse_mode = MM_ROTATE;
 }
 
-static void menu_click_rotate_x(void *p)
-{
-       switch_Mouse(NULL,MM_ROTATE);
-
-       view->mouse.rotate_axis = MOUSE_ROTATE_X;
-}
-
-static void menu_click_rotate_y(void *p)
-{
-       switch_Mouse(NULL,MM_ROTATE);
-
-       view->mouse.rotate_axis = MOUSE_ROTATE_Y;
-}
-
-static void menu_click_rotate_xy(void *p)
-{
-       switch_Mouse(NULL,MM_ROTATE);
-
-       view->mouse.rotate_axis = MOUSE_ROTATE_XY;
-}
-
-static void menu_click_rotate_z(void *p)
-{
-       switch_Mouse(NULL,MM_ROTATE);
-
-       view->mouse.rotate_axis = MOUSE_ROTATE_Z;
-}
 
 static void menu_click_center(void *p)
 {
@@ -1602,14 +1560,39 @@ static void menu_click_center(void *p)
 
        }
 }
+static glCompPanel *controlPanel;
+static glCompButton *rotatebutton;
 
-/*1) 3D select or identify.
-2) Should 3D nodes have a size? (Strange behavior: some 3D views have large node sizes. Why the difference?)
-3) Sanity button - if I get lost in 3D, reset the viewpoint so that I have a good view of the graph
-4) Additional selection options when selecting nodes - at present, we do union - nice to have intersection, subtraction
-5) User control of alpha, so I can fade out the edges.
+static void switch2D3D(void *p)
+{
+       if (view->active_camera == -1)
+       {
+
+               if (view->camera_count == 0)
+               {
+                       menu_click_add_camera(p);
+               }
+               else
+               {
+                       view->active_camera = 0 ;       /*set to camera*/
+               }
+               glCompButtonSetText(p,"2D");
+               controlPanel->height +=72;
+               rotatebutton->visible=1;
+
+       }
+       else /*switch to 2d*/
+       {
+                       view->active_camera = -1 ;      /*set to camera*/
+                       glCompButtonSetText(p,"3D");
+
+                       controlPanel->height -=72;
+                       rotatebutton->visible=0;
+
+
+       }
+}
 
-I'll see if I can track down the color bug.*/
 
 
 
@@ -1621,10 +1604,11 @@ static char *smyrna_icon_zoomminus;
 static char *smyrna_icon_fisheye;
 static char *smyrna_icon_rotate;
 
+
 glCompSet *glcreate_gl_topview_menu(void)
 {
 
-    glCompSet *s = glCompSetNew();
+       glCompSet *s = glCompSetNew(view->w,view->h);
     glCompPanel *p;
     glCompButton *b;
     glCompLabel *l;
@@ -1667,109 +1651,38 @@ glCompSet *glcreate_gl_topview_menu(void)
      */
 
     //small panel left bottom
-    p = glCompPanelNew(25, 25, 325, 40,scientific_y);
+    p = glCompPanelNew(25, 25, 82, 40,scientific_y);
     p->data = 0;
     glCompSetAddPanel(s, p);
 
-    b = glCompButtonNew(5, 7, 75, 25, "BROWSE", '\0', 0, 0,scientific_y);
-    b->panel = p;
-    b->groupid = 1;
-    b->customptr = view;
-    glCompSetAddButton(s, b);
-    b->callbackfunc = menu_click_control;
 
-
-    b = glCompButtonNew(85, 7, 75, 25, "SHOW", '\0', 0, 0,scientific_y);
+    b = glCompButtonNew(5, 7, 72, 25, "Controls", '\0', 0, 0,scientific_y);
     b->panel = p;
+    b->groupid = 0;
     b->customptr = view;
-    b->groupid = 1;
-    b->callbackfunc = menu_click_data;
-    glCompSetAddButton(s, b);
-
-
-    b = glCompButtonNew(165, 7, 75, 25, "CAMERAS", '\0', 0, 0,scientific_y);
-    b->customptr = view;
-    b->panel = p;
-    b->groupid = 1;
-    b->callbackfunc = menu_click_3d_view;
     glCompSetAddButton(s, b);
+    b->callbackfunc = menu_click_control;
 
-    b = glCompButtonNew(245, 7, 75, 25, "HIDE", '\0', 0, 0,scientific_y);
-    b->color.R = 1;
-    b->customptr = view;
-    b->panel = p;
-    b->groupid = 1;
-    b->callbackfunc = menu_click_hide;
-    glCompSetAddButton(s, b);
 
-    //Fisheye control panel
-//     p = glCompPanelNew(     25, view->h-40, 165, 40,scientific_y);
-  //  p->data = 1;             //control panel
-  //  glCompSetAddPanel(s, p);
 
-       //control panel
-    p = glCompPanelNew(25, 75, 165, 277,scientific_y);
+    p = glCompPanelNew(25, 75, 82, 305,scientific_y);
     p->data = 1;               //control panel
     glCompSetAddPanel(s, p);
+       controlPanel=p;
 
-    //view mode normal button
-    b = glCompButtonNew(5, 7, 75, 25, "NORMAL", '\0', 0, 0,scientific_y);
-    b->color.R = 0;
-    b->color.G = 1;
-    b->color.B = (float) 0.1;
-    b->customptr = view;
-    b->panel = p;
-    b->groupid = 2;
-    b->callbackfunc = menu_switch_to_normal_mode;
-
-    glCompSetAddButton(s, b);
-    //view mode fisheye button
-    b = glCompButtonNew(85, 7, 75, 25, "FISHEYE", '\0', 0, 0,scientific_y);
-    b->color.R = 0;
-    b->color.G = 1;
-    b->color.B = (float) 0.1;
-    b->customptr = view;
-    b->panel = p;
-    b->groupid = 2;
-    b->callbackfunc = menu_switch_to_fisheye;
-    glCompSetAddButton(s, b);
 
-    //rotate
-    b = glCompButtonNew(5, 197, 72, 72, "", smyrna_icon_rotate, 72, 72,scientific_y);
+   //rotate
+    b = glCompButtonNew(5, 302, 72, 72, "", smyrna_icon_rotate, 72, 72,scientific_y);
     b->groupid = 3;
     b->customptr = view;
+       b->visible=0;
     b->panel = p;
     b->callbackfunc = menu_click_rotate;
-    glCompSetAddButton(s, b);
-
-    b = glCompButtonNew(80, 251, 40, 20, "X", '\0', 0, 0,scientific_y);
-    b->customptr = view;
-    b->panel = p;
-    b->groupid = 1;
-    b->callbackfunc = menu_click_rotate_x;
-    glCompSetAddButton(s, b);
-    b = glCompButtonNew(125, 251, 40, 20, "Y", '\0', 0, 0,scientific_y);
-    b->customptr = view;
-    b->panel = p;
-    b->groupid = 1;
-    b->callbackfunc = menu_click_rotate_y;
-    glCompSetAddButton(s, b);
-    b = glCompButtonNew(80, 231, 40, 20, "XY", '\0', 0, 0,scientific_y);
-    b->customptr = view;
-    b->panel = p;
-    b->groupid = 1;
-    b->callbackfunc = menu_click_rotate_xy;
-
-       glCompSetAddButton(s, b);
-    b = glCompButtonNew(125, 231, 40, 20, "Z", '\0', 0, 0,scientific_y);
-    b->customptr = view;
-    b->panel = p;
-    b->groupid = 1;
-    b->callbackfunc = menu_click_rotate_z;
+       rotatebutton=b;
     glCompSetAddButton(s, b);
 
        //sanity button to center the drawing and fit it in the screen
-    b = glCompButtonNew(80, 201, 90, 20, "center", '\0', 0, 0,scientific_y);
+    b = glCompButtonNew(5, 5, 72, 20, "center", '\0', 0, 0,scientific_y);
     b->customptr = view;
     b->panel = p;
     b->groupid = 0;
@@ -1783,7 +1696,7 @@ glCompSet *glcreate_gl_topview_menu(void)
 
 
     //pan button
-    b = glCompButtonNew(5, 120, 72, 72, "adasasds", smyrna_icon_pan, 72,
+    b = glCompButtonNew(5, 148, 72, 72, "adasasds", smyrna_icon_pan, 72,
                        72,scientific_y);
     b->groupid = 3;
     b->customptr = view;
@@ -1792,7 +1705,7 @@ glCompSet *glcreate_gl_topview_menu(void)
     glCompSetAddButton(s, b);
 
     //zoom
-    b = glCompButtonNew(85, 120, 72, 72, "adasasds", smyrna_icon_zoom, 72,
+    b = glCompButtonNew(5, 71, 72, 72, "adasasds", smyrna_icon_zoom, 72,
                        72,scientific_y);
     b->groupid = 3;
     b->customptr = view;
@@ -1800,7 +1713,7 @@ glCompSet *glcreate_gl_topview_menu(void)
     b->callbackfunc = menu_click_zoom;
     glCompSetAddButton(s, b);
     //zoom +
-    b = glCompButtonNew(85, 82, 36, 36, "adasasds", smyrna_icon_zoomplus,
+    b = glCompButtonNew(42, 30, 36, 36, "adasasds", smyrna_icon_zoomplus,
                        36, 36,scientific_y);
     b->groupid = 0;
     b->customptr = view;
@@ -1808,7 +1721,7 @@ glCompSet *glcreate_gl_topview_menu(void)
     b->callbackfunc = menu_click_zoom_plus;
     glCompSetAddButton(s, b);
     //zoom -
-    b = glCompButtonNew(121, 82, 36, 36, "adasasds", smyrna_icon_zoomminus,
+    b = glCompButtonNew(7, 30, 30, 36, "adasasds", smyrna_icon_zoomminus,
                        36, 36,scientific_y);
     b->groupid = 0;
     b->panel = p;
@@ -1816,25 +1729,41 @@ glCompSet *glcreate_gl_topview_menu(void)
     b->callbackfunc = menu_click_zoom_minus;
     glCompSetAddButton(s, b);
 
-    b = glCompButtonNew(5, 45, 72, 72, "adasasds", smyrna_icon_fisheye, 72,
+    b = glCompButtonNew(5, 225, 72, 72, "adasasds", smyrna_icon_fisheye, 72,
                        72,scientific_y);
     b->groupid = 3;
     b->panel = p;
     b->customptr = view;
     b->callbackfunc = menu_click_fisheye_magnifier;
     glCompSetAddButton(s, b);
-    //zoom percantage label
-    l = glCompLabelNew(100, 45, 24, "100",scientific_y);
-    l->panel = p;
-    l->fontsizefactor = (float) 0.4;
-    glCompSetAddLabel(s, l);
-    view->Topview->customptr = l;
-    l = glCompLabelNew(93, 65, 20, "zoom",scientific_y);
-    l->panel = p;
-    l->fontsizefactor = (float) 0.4;
-    glCompSetAddLabel(s, l);
-
-    glCompPanelHide(p);
+       glCompPanelHide(p);
+
+    //small panel left bottom
+    p = glCompPanelNew(5, 5, 137, 35,inverted_y);
+    p->data = 0;
+    glCompSetAddPanel(s, p);
+       
+
+
+    b = glCompButtonNew(5, 5, 50, 25, "3D", '\0', 0, 0,scientific_y);
+    b->panel = p;
+    b->groupid = 0;
+    b->customptr = view;
+    glCompSetAddButton(s, b);
+    b->callbackfunc = switch2D3D;
+
+
+    b = glCompButtonNew(57, 5, 75, 25, "Fisheye", '\0', 0, 0,scientific_y);
+    b->panel = p;
+    b->groupid = 0;
+       b->customptr = view;
+    glCompSetAddButton(s, b);
+    b->callbackfunc = menu_switch_to_fisheye;
+
+
+
+
+
 
 
        
index 0f68df2844b786287ccc3fe5c152c07483513101..4ed53efeb9292b2198fd4f572673df0f6f475736 100755 (executable)
@@ -59,6 +59,18 @@ static int mapbool(char *p)
     return atoi(p);
 }
 #endif
+static Dtdisc_t qDisc = {
+    offsetof(xdot,ops),
+    sizeof(xdot_op*),
+    -1,
+    NIL(Dtmake_f),
+    NIL(Dtfree_f),
+    NIL(Dtcompar_f),
+    NIL(Dthash_f),
+    NIL(Dtmemory_f),
+    NIL(Dtevent_f)
+};
+
 
 void clear_viewport(ViewInfo * view)
 {
@@ -336,8 +348,6 @@ get_data_dir()
 void init_viewport(ViewInfo * view)
 {
     FILE *input_file=NULL;
-
-       
     get_data_dir();
 
     input_file = fopen(view->template_file, "rb");
@@ -470,8 +480,8 @@ void init_viewport(ViewInfo * view)
        view->Topview->Graphdata.Modified=0;
        view->colschms=NULL;
        view->flush=1;
-
-
+       view->arcball=NEW(ArcBall_t);
+       /*add default camera*/
        //create fontset
 }
 
index 9490744f345ba53ee7c60d3c0f8d1b08dd257862..d9f1684a4ac2ea64a6a63ce7fc0958d8a8929b87 100755 (executable)
 #include "xdot.h"
 #include "cgraph.h"
 
+void arcmouseRClick(ViewInfo* v);
+void arcmouseClick(ViewInfo* v);
+void arcmouseDrag(ViewInfo* v);
+
+
 
 void init_viewport(ViewInfo * view);
 void set_viewport_settings_from_template(ViewInfo * view, Agraph_t *);
index 682488d8b28d4ba4226d9551967e2994473c5a31..4d0775427468013d5762aa0f72dde86d7fbfca08 100644 (file)
@@ -125,9 +125,7 @@ void menu_click_add_camera(void *p)
 
     c->r = view->zoom * -1;
 //      set_camera_x_y(c);
-    attach_camera_widget(view);
-
-
+//    attach_camera_widget(view);
 }
 
 int blocksignal = 0;
index 38f73b88608b957f665a8f7de2ac0a905f16b10a..4490cefb3a2b62748ffac29124b99ae9884674c4 100644 (file)
 #include "glcompbutton.h"
 #include "glcomptexture.h"
 #include "glcomptext.h"
+#include "glutils.h"
 #include <string.h>
 #include <GL/glut.h>
 
+
 glCompButton *glCompButtonNew(GLfloat x, GLfloat y, GLfloat w, GLfloat h,
                              char *caption, char *glyphfile,
                              int glyphwidth, int glyphheight,glCompOrientation orientation)
@@ -103,163 +105,139 @@ int glCompSetRemoveButton(glCompSet * s, glCompButton * p)
 
 int glCompDrawButton(glCompButton * p)
 {
-    float color_fac;
+       int kts,kts2;
+       GLfloat tempX,tempY;
+       GLfloat h,h2;   /*container widget height*/
+       float color_fac;
     float thickness = p->thickness;
     float fontx, fonty;
        GLfloat fontwidth;
-    if (!p->visible)
-       return 0;
-    if (p->panel) {
-       p->pos.x = p->panel->pos.x + p->pos.x;
-       p->pos.y = p->panel->pos.y + p->pos.y;
-    }
-    if (p->status == 1) {
-       color_fac = GLCOMPSET_BUTTON_BEVEL_BRIGHTNESS;
-       glColor4f(p->color.R / (GLfloat) 1.2, p->color.G / (GLfloat) 1.2,
-                 p->color.B / (GLfloat) 1.2, p->color.A);
-       p->thickness = p->thickness / (GLfloat) 1.2;
 
+       if (p->orientation==1){ kts=1; h=0;}else{kts=-1; h=((glCompSet*)p->parentset)->h;}
+       if (p->panel->orientation==1){  kts2=1; h2=0;}else
+       {
+               kts2=-1; h2=((glCompSet*)p->panel->parentset)->h;
+       }
+       if ((!p->visible) || (!p->panel->visible))
+               return 0;
+    if (p->panel)
+       {
+               tempX=p->pos.x;
+               tempY=p->pos.y;
+               p->pos.x = p->panel->pos.x + p->pos.x;
+               p->pos.y = p->panel->pos.y*kts2*kts+h2 + p->pos.y-h;
+               if (p->panel->orientation==0)
+                       p->pos.y = p->pos.y - p->panel->height;
+    }
+    if (p->status == 1) 
+       {
+               color_fac = GLCOMPSET_BUTTON_BEVEL_BRIGHTNESS;
+               glColor4f(p->color.R / (GLfloat) 1.2, p->color.G / (GLfloat) 1.2, p->color.B / (GLfloat) 1.2, p->color.A);
+               p->thickness = p->thickness / (GLfloat) 1.2;
     }
 
-    else {
-       color_fac = 1 / GLCOMPSET_BUTTON_BEVEL_BRIGHTNESS;
-       glColor4f(p->color.R, p->color.G, p->color.B, p->color.A);
-       p->thickness = p->thickness * (GLfloat) 1.2;
+    else 
+       {
+               color_fac = 1 / GLCOMPSET_BUTTON_BEVEL_BRIGHTNESS;
+               glColor4f(p->color.R, p->color.G, p->color.B, p->color.A);
+               p->thickness = p->thickness * (GLfloat) 1.2;
     }
     if (!p->hasglyph) 
        {
-       glBegin(GL_POLYGON);
-       glVertex3f(p->pos.x + p->thickness, p->pos.y + p->thickness,
-                  p->bevel);
-       glVertex3f(p->pos.x + p->width - p->thickness,
-                  p->pos.y + p->thickness, p->bevel);
-       glVertex3f(p->pos.x + p->width - p->thickness,
-                  p->pos.y + p->height - p->thickness, p->bevel);
-       glVertex3f(p->pos.x + p->thickness,
-                  p->pos.y + p->height - p->thickness, p->bevel);
-       glVertex3f(p->pos.x + p->thickness, p->pos.y + p->thickness,
-                  p->bevel);
-       glEnd();
-       //buttom thickness
-       glColor4f(p->color.R * color_fac, p->color.G * color_fac,
-                 p->color.B * color_fac, p->color.A);
-       glBegin(GL_POLYGON);
-       glVertex3f(p->pos.x + p->thickness, p->pos.y + p->thickness,
-                  p->bevel);
-       glVertex3f(p->pos.x + p->width - p->thickness,
-                  p->pos.y + p->thickness, p->bevel);
-       glVertex3f(p->pos.x + p->width, p->pos.y, p->bevel);
-       glVertex3f(p->pos.x, p->pos.y, p->bevel);
-       glVertex3f(p->pos.x + p->thickness, p->pos.y + p->thickness,
-                  p->bevel);
-       glEnd();
-       //left thickness
-       glBegin(GL_POLYGON);
-       glVertex3f(p->pos.x + p->width, p->pos.y + p->height, p->bevel);
-       glVertex3f(p->pos.x + p->width - p->thickness,
-                  p->pos.y + p->height - p->thickness, p->bevel);
-       glVertex3f(p->pos.x + p->width - p->thickness,
-                  p->pos.y + p->thickness, p->bevel);
-       glVertex3f(p->pos.x + p->width, p->pos.y, p->bevel);
-       glVertex3f(p->pos.x + p->width, p->pos.y + p->height, p->bevel);
-       glEnd();
-
-       glColor4f(p->color.R / color_fac, p->color.G / color_fac,
-                 p->color.B / color_fac, p->color.A);
-       glBegin(GL_POLYGON);
-       glVertex3f(p->pos.x + p->thickness, p->pos.y + p->thickness,
-                  p->bevel);
-       glVertex3f(p->pos.x + p->thickness,
-                  p->pos.y + p->height - p->thickness, p->bevel);
-       glVertex3f(p->pos.x, p->pos.y + p->height, p->bevel);
-       glVertex3f(p->pos.x, p->pos.y, p->bevel);
-       glVertex3f(p->pos.x + p->thickness, p->pos.y + p->thickness,
-                  p->bevel);
-       glEnd();
-       //left thickness
-       glBegin(GL_POLYGON);
-       glVertex3f(p->pos.x + p->thickness,
-                  p->pos.y + p->height - p->thickness, p->bevel);
-       glVertex3f(p->pos.x, p->pos.y + p->height, p->bevel);
-       glVertex3f(p->pos.x + p->width, p->pos.y + p->height, p->bevel);
-       glVertex3f(p->pos.x + p->width - p->thickness,
-                  p->pos.y + p->height - p->thickness, p->bevel);
-       glVertex3f(p->pos.x + p->thickness,
-                  p->pos.y + p->height - p->thickness, p->bevel);
-       glEnd();
-       //draw caption
-       fontColor(p->font,p->fontcolor.R, p->fontcolor.G, p->fontcolor.B, p->fontcolor.A);
-       /*get the string length*/
-       fontwidth=(GLfloat)glutBitmapLength(GLUT_BITMAP_HELVETICA_12,(unsigned char*)p->caption);
-
-
-       fontx =
-           (p->width - p->thickness * (GLfloat) 2 -
-            fontwidth )/ (GLfloat) 2.0 + p->pos.x +
-           p->thickness;
-       fonty =
-           (p->height - p->thickness * (GLfloat) 2 -
-            p->fontsize) / (GLfloat) 2.0 + p->pos.y + p->thickness;
-
-               
-       glprintf(p->font, fontx,fonty, p->bevel,fontwidth,p->caption);
+               glBegin(GL_POLYGON);
+                       glVertex3f(p->pos.x + p->thickness, (p->pos.y*kts+h) + p->thickness, p->bevel);
+                       glVertex3f(p->pos.x + p->width - p->thickness,(p->pos.y*kts+h) + p->thickness, p->bevel);
+                       glVertex3f(p->pos.x + p->width - p->thickness,(p->pos.y*kts+h) + p->height*kts - p->thickness, p->bevel);
+                       glVertex3f(p->pos.x + p->thickness,(p->pos.y*kts+h) + p->height*kts - p->thickness, p->bevel);
+                       glVertex3f(p->pos.x + p->thickness, (p->pos.y*kts+h) + p->thickness,p->bevel);
+               glEnd();
+               //buttom thickness
+               glColor4f(p->color.R * color_fac, p->color.G * color_fac,p->color.B * color_fac, p->color.A);
+               glBegin(GL_POLYGON);
+                       glVertex3f(p->pos.x + p->thickness, (p->pos.y*kts+h) + p->thickness,p->bevel);
+                       glVertex3f(p->pos.x + p->width - p->thickness,(p->pos.y*kts+h) + p->thickness, p->bevel);
+                       glVertex3f(p->pos.x + p->width, (p->pos.y*kts+h), p->bevel);
+                       glVertex3f(p->pos.x, (p->pos.y*kts+h), p->bevel);
+                       glVertex3f(p->pos.x + p->thickness, (p->pos.y*kts+h) + p->thickness,p->bevel);
+               glEnd();
+               //left thickness
+               glBegin(GL_POLYGON);
+                       glVertex3f(p->pos.x + p->width, (p->pos.y*kts+h) + p->height*kts, p->bevel);
+                       glVertex3f(p->pos.x + p->width - p->thickness,(p->pos.y*kts+h) + p->height*kts - p->thickness, p->bevel);
+                       glVertex3f(p->pos.x + p->width - p->thickness,(p->pos.y*kts+h) + p->thickness, p->bevel);
+                       glVertex3f(p->pos.x + p->width, (p->pos.y*kts+h), p->bevel);
+                       glVertex3f(p->pos.x + p->width, (p->pos.y*kts+h) + p->height*kts, p->bevel);
+               glEnd();
+               glColor4f(p->color.R / color_fac, p->color.G / color_fac, p->color.B / color_fac, p->color.A);
+               glBegin(GL_POLYGON);
+                       glVertex3f(p->pos.x + p->thickness, (p->pos.y*kts+h) + p->thickness,p->bevel);
+                       glVertex3f(p->pos.x + p->thickness,(p->pos.y*kts+h) + p->height*kts - p->thickness, p->bevel);
+                       glVertex3f(p->pos.x, (p->pos.y*kts+h) + p->height*kts, p->bevel);
+                       glVertex3f(p->pos.x, (p->pos.y*kts+h), p->bevel);
+                       glVertex3f(p->pos.x + p->thickness, (p->pos.y*kts+h) + p->thickness,p->bevel);
+               glEnd();
+               //left thickness
+               glBegin(GL_POLYGON);
+                       glVertex3f(p->pos.x + p->thickness,
+                       (p->pos.y*kts+h) + p->height*kts - p->thickness, p->bevel);
+                       glVertex3f(p->pos.x, (p->pos.y*kts+h) + p->height*kts, p->bevel);
+                       glVertex3f(p->pos.x + p->width, (p->pos.y*kts+h) + p->height*kts, p->bevel);
+                       glVertex3f(p->pos.x + p->width - p->thickness,(p->pos.y*kts+h) + p->height*kts - p->thickness, p->bevel);
+                       glVertex3f(p->pos.x + p->thickness,
+                       (p->pos.y*kts+h) + p->height*kts - p->thickness, p->bevel);
+               glEnd();
+               //draw caption
+               fontColor(p->font,p->fontcolor.R, p->fontcolor.G, p->fontcolor.B, p->fontcolor.A);
+               /*get the string length*/
+               fontwidth=(GLfloat)glutBitmapLength(GLUT_BITMAP_HELVETICA_12,(unsigned char*)p->caption);
+               fontx =(p->width - p->thickness * (GLfloat) 2 -  fontwidth )/ (GLfloat) 2.0 + p->pos.x + p->thickness;
+               fonty =(p->height*kts - p->thickness * (GLfloat) 2 -p->fontsize) / (GLfloat) 2.0 + (p->pos.y*kts+h) + p->thickness;
+               glprintf(p->font, fontx,fonty, p->bevel,fontwidth,p->caption);
        }
     //put glyph
     else 
        {
+               glEnable(GL_TEXTURE_2D);
+               fontx =(p->width - p->thickness * (GLfloat) 2 - p->glyphwidth) / (GLfloat) 2.0 + p->pos.x + p->thickness;
+               fonty =(p->height*kts - p->thickness * (GLfloat) 2 - p->glyphheight) / (GLfloat) 2.0 + (p->pos.y*kts+h) + p->thickness;
+               glBindTexture(GL_TEXTURE_2D, p->glyph->id);
+               glColor4f(1, 1, 1, 1);
+               glBegin(GL_QUADS);
+                       glTexCoord2d(0.0f, 1.0f);
+                       glVertex3d(fontx, fonty, p->bevel + GLCOMPSET_BEVEL_DIFF);
+                       glTexCoord2d(1.0f, 1.0f);
+                       glVertex3d(fontx + p->glyph->w, fonty,
+                       p->bevel + GLCOMPSET_BEVEL_DIFF);
+                       glTexCoord2d(1.0f, 0.0f);
+                       glVertex3d(fontx + p->glyph->w, fonty + p->glyph->h,
+                       p->bevel + GLCOMPSET_BEVEL_DIFF);
+                       glTexCoord2d(0.0f, 0.0f);
+                       glVertex3d(fontx, fonty + p->glyph->h,
+                       p->bevel + GLCOMPSET_BEVEL_DIFF);
+                       glTexCoord2d(fontx,fonty); glVertex3d(fontx,fonty,p->bevel+GLCOMPSET_BEVEL_DIFF);
+               glEnd();
+               glDisable(GL_TEXTURE_2D);
+               if (p->status == 1) 
+               {
+                       glColor4f(p->color.R * color_fac, p->color.G * color_fac,p->color.B * color_fac, p->color.A / 2);
+                       glBegin(GL_POLYGON);
+                               glVertex3d(fontx - p->thickness, fonty - p->thickness,p->bevel + GLCOMPSET_BEVEL_DIFF * 2);
+                               glVertex3d(fontx + p->glyph->w + p->thickness,fonty - p->thickness,p->bevel + GLCOMPSET_BEVEL_DIFF * 2);
+                               glVertex3d(fontx + p->glyph->w + p->thickness,fonty + p->glyph->h + p->thickness,p->bevel + GLCOMPSET_BEVEL_DIFF * 2);
+                               glVertex3d(fontx - p->thickness,fonty + p->glyph->h + p->thickness,p->bevel + GLCOMPSET_BEVEL_DIFF * 2);
+                       glEnd();
 
-       glEnable(GL_TEXTURE_2D);
-       fontx =
-           (p->width - p->thickness * (GLfloat) 2 -
-            p->glyphwidth) / (GLfloat) 2.0 + p->pos.x + p->thickness;
-       fonty =
-           (p->height - p->thickness * (GLfloat) 2 -
-            p->glyphheight) / (GLfloat) 2.0 + p->pos.y + p->thickness;
-       glBindTexture(GL_TEXTURE_2D, p->glyph->id);
-       glColor4f(1, 1, 1, 1);
-       glBegin(GL_QUADS);
-       glTexCoord2d(0.0f, 1.0f);
-       glVertex3d(fontx, fonty, p->bevel + GLCOMPSET_BEVEL_DIFF);
-       glTexCoord2d(1.0f, 1.0f);
-       glVertex3d(fontx + p->glyph->w, fonty,
-                  p->bevel + GLCOMPSET_BEVEL_DIFF);
-       glTexCoord2d(1.0f, 0.0f);
-       glVertex3d(fontx + p->glyph->w, fonty + p->glyph->h,
-                  p->bevel + GLCOMPSET_BEVEL_DIFF);
-       glTexCoord2d(0.0f, 0.0f);
-       glVertex3d(fontx, fonty + p->glyph->h,
-                  p->bevel + GLCOMPSET_BEVEL_DIFF);
-              glTexCoord2d(fontx,fonty); glVertex3d(fontx,fonty,p->bevel+GLCOMPSET_BEVEL_DIFF);
-
-       glEnd();
-       glDisable(GL_TEXTURE_2D);
-       if (p->status == 1) {
-           glColor4f(p->color.R * color_fac, p->color.G * color_fac,
-                     p->color.B * color_fac, p->color.A / 2);
-           glBegin(GL_POLYGON);
-           glVertex3d(fontx - p->thickness, fonty - p->thickness,
-                      p->bevel + GLCOMPSET_BEVEL_DIFF * 2);
-           glVertex3d(fontx + p->glyph->w + p->thickness,
-                      fonty - p->thickness,
-                      p->bevel + GLCOMPSET_BEVEL_DIFF * 2);
-           glVertex3d(fontx + p->glyph->w + p->thickness,
-                      fonty + p->glyph->h + p->thickness,
-                      p->bevel + GLCOMPSET_BEVEL_DIFF * 2);
-           glVertex3d(fontx - p->thickness,
-                      fonty + p->glyph->h + p->thickness,
-                      p->bevel + GLCOMPSET_BEVEL_DIFF * 2);
-           glEnd();
-
+               }
        }
-
-    }
     p->thickness = thickness;
-    if (p->panel) {
-       p->pos.x = p->pos.x - p->panel->pos.x;
-       p->pos.y = p->pos.y - p->panel->pos.y;
-    }
 
-    return 1;
+    if (p->panel)
+       {
+               p->pos.x=tempX;
+               p->pos.y=tempY;
+    }
+       
+       return 1;
 
 
 }
@@ -289,4 +267,9 @@ void glCompButtonClick(glCompButton * p)
 
 }
 
+void glCompButtonSetText(glCompButton * p,char* str)
+{
+       replacestr(str,&p->caption);
+}
+
 
index ab79478e4aa1694f58e39f4369b4daf42f610ccb..d63768002b446aa2fcc5af5d1723b49fbdadde92 100644 (file)
@@ -21,7 +21,7 @@ extern int glCompSetAddButton(glCompSet * s, glCompButton * p);
 extern int glCompSetRemoveButton(glCompSet * s, glCompButton * p);
 extern int glCompDrawButton(glCompButton * p);
 extern void glCompButtonClick(glCompButton * p);
-
+extern void glCompButtonSetText(glCompButton * p,char* str);
 
 
 #endif
index 5f21cb22e322480dda197005b23d76e60355f791..2151646ebcb3607fe94aa5e9c10cf96ece72af1f 100644 (file)
@@ -173,6 +173,7 @@ typedef struct _glCompLabel {
     GLfloat bevel;
     glCompColor color;
     int visible;
+    void *parentset;           //parent compset
     char *text;
     GLfloat fontsizefactor;
     glCompPanel *panel;                //container panel
@@ -212,6 +213,7 @@ typedef struct {
     glCompPanel **panels;
     glCompButton **buttons;
     glCompLabel **labels;
+       int groupCount ; /*group id counter*/
 
     int panelcount;
     int buttoncount;
@@ -219,6 +221,7 @@ typedef struct {
     int active;                        //0 dont draw, 1 draw
     int enabled;               //0 disabled 1 enabled(allow mouse interaction)
     GLfloat clickedX, clickedY;
+       GLfloat w,h; /*parent widget width and height , needs to be updated each time window is resized*/
        fontset_t* fontset; /*font repository*/
 } glCompSet;
 
index 99585d89537ca527fab6122937585042e1de2963..9fa4e47dc00c070751da92be9a085bcb67635fee 100644 (file)
@@ -41,6 +41,7 @@ int glCompSetAddLabel(glCompSet * s, glCompLabel * p)
     s->labels = realloc(s->labels, sizeof(glCompLabel *) * s->labelcount);
     s->labels[s->labelcount - 1] = p;
        p->font=s->fontset->fonts[s->fontset->activefont];
+    p->parentset = s;
     return 1;
 }
 
@@ -69,21 +70,40 @@ int glCompSetRemoveLabel(glCompSet * s, glCompLabel * p)
 
 int glCompDrawLabel(glCompLabel * p)
 {
-    if (p->visible) {
-       if (p->panel) {
-           p->pos.x = p->pos.x + p->panel->pos.x;
-           p->pos.y = p->pos.y + p->panel->pos.y;
+
+       int kts,kts2;
+       GLfloat tempX,tempY;
+       GLfloat h,h2;   /*container widget height*/
+       float color_fac;
+    float fontx, fonty;
+       GLfloat fontwidth;
+
+       if (p->orientation==1){ kts=1; h=0;}else{kts=-1; h=((glCompSet*)p->parentset)->h;}
+       if (p->panel->orientation==1){  kts2=1; h2=0;}else
+       {
+               kts2=-1; h2=((glCompSet*)p->panel->parentset)->h;
        }
+       if ((!p->visible) || (!p->panel->visible))
+               return 0;
+       if (p->panel)
+       {
+               tempX=p->pos.x;
+               tempY=p->pos.y;
+               p->pos.x = p->panel->pos.x + p->pos.x;
+               p->pos.y = p->panel->pos.y*kts2*kts+h2 + p->pos.y-h;
+               if (p->panel->orientation==0)
+                       p->pos.y = p->pos.y - p->panel->height;
+    }
+       printf ("kts:%d h:%f kts2:%d h2:%d \n", kts , h , kts2, h2);
 
        p->font->fontheight=p->size;
        fontColor(p->font,p->color.R, p->color.G, p->color.B, p->color.A);
 
        glprintf(p->font, p->pos.x,  p->pos.y,p->panel->bevel,(p->size * p->fontsizefactor *strlen(p->text)), p->text);
        if (p->panel) {
-           p->pos.x = p->pos.x - p->panel->pos.x;
-           p->pos.y = p->pos.y - p->panel->pos.y;
-       }
-       return 1;
+           p->pos.x = tempX;
+           p->pos.y = tempY;
+               return 1;
     }
     return 0;
 }
index 9f4b0d3b620ee3e7760956fea745bd878bff3cf7..79c51a9c346cdef8459f1d5e65e33c14b857bf36 100644 (file)
@@ -46,39 +46,42 @@ void glCompSetPanelText(glCompPanel * p,char* t)
 
 int glCompDrawPanel(glCompPanel * p)
 {
-    if (!p->visible)
+       int kts;
+       GLfloat h;      /*container widget height*/
+       if (p->orientation==1){ kts=1; h=0;}else{kts=-1; h=((glCompSet*)p->parentset)->h;}
+       if (!p->visible)
        return 0;
     glColor4f(p->color.R, p->color.G, p->color.B, p->color.A);
     glBegin(GL_POLYGON);
-    glVertex3f(p->pos.x, p->pos.y, p->bevel);
-    glVertex3f(p->pos.x + p->width, p->pos.y, p->bevel);
-    glVertex3f(p->pos.x + p->width, p->pos.y + p->height, p->bevel);
-    glVertex3f(p->pos.x, p->pos.y + p->height, p->bevel);
-    glVertex3f(p->pos.x, p->pos.y, p->bevel);
+    glVertex3f(p->pos.x, (p->pos.y*kts+h), p->bevel);
+    glVertex3f(p->pos.x + p->width, (p->pos.y*kts+h), p->bevel);
+    glVertex3f(p->pos.x + p->width, (p->pos.y*kts+h) + p->height*kts, p->bevel);
+    glVertex3f(p->pos.x, (p->pos.y*kts+h) + p->height*kts, p->bevel);
+    glVertex3f(p->pos.x, (p->pos.y*kts+h), p->bevel);
     glEnd();
     glBegin(GL_LINE_STRIP);
     glColor4f(p->shadowcolor.R, p->shadowcolor.G, p->shadowcolor.B,
              p->color.A);
-    glVertex3f(p->pos.x, p->pos.y,
+    glVertex3f(p->pos.x, (p->pos.y*kts+h),
               p->bevel + (GLfloat) GLCOMPSET_BEVEL_DIFF);
-    glVertex3f(p->pos.x + p->width, p->pos.y,
+    glVertex3f(p->pos.x + p->width, (p->pos.y*kts+h),
               p->bevel + (GLfloat) GLCOMPSET_BEVEL_DIFF);
-    glVertex3f(p->pos.x + p->width, p->pos.y + p->height,
+    glVertex3f(p->pos.x + p->width, (p->pos.y*kts+h) + p->height*kts,
               p->bevel + (GLfloat) GLCOMPSET_BEVEL_DIFF);
-    glVertex3f(p->pos.x, p->pos.y + p->height,
+    glVertex3f(p->pos.x, (p->pos.y*kts+h) + p->height*kts,
               p->bevel + (GLfloat) GLCOMPSET_BEVEL_DIFF);
-    glVertex3f(p->pos.x, p->pos.y, p->bevel);
+    glVertex3f(p->pos.x, (p->pos.y*kts+h), p->bevel);
     glEnd();
     glLineWidth(p->shadowwidth);
     glBegin(GL_LINE_STRIP);
     glColor4f((GLfloat) p->shadowcolor.R, (GLfloat) p->shadowcolor.G,
              (GLfloat) p->shadowcolor.B, (GLfloat) p->shadowcolor.A);
     glVertex3f(p->pos.x + p->shadowwidth / ((GLfloat) 2.0),
-              p->pos.y - p->shadowwidth / ((GLfloat) 2.0), p->bevel);
+              (p->pos.y*kts+h) - p->shadowwidth / ((GLfloat) 2.0), p->bevel);
     glVertex3f(p->pos.x + p->shadowwidth / (GLfloat) 2.0 + p->width,
-              p->pos.y - p->shadowwidth / (GLfloat) 2.0, p->bevel);
+              (p->pos.y*kts+h) - p->shadowwidth / (GLfloat) 2.0, p->bevel);
     glVertex3f(p->pos.x + p->shadowwidth / (GLfloat) 2.0 + p->width,
-              p->pos.y - p->shadowwidth / (GLfloat) 2.0 + p->height,
+              (p->pos.y*kts+h) - p->shadowwidth / (GLfloat) 2.0 + p->height*kts,
               p->bevel);
     glEnd();
     glLineWidth(1);
@@ -125,15 +128,6 @@ int glCompSetRemovePanel(glCompSet * s, glCompPanel * p)
 int glCompPanelHide(glCompPanel * p)
 {
     int ind = 0;
-    for (ind = 0; ind < ((glCompSet *) p->parentset)->buttoncount; ind++) {
-       if (((glCompSet *) p->parentset)->buttons[ind]->panel == p)
-           ((glCompSet *) p->parentset)->buttons[ind]->visible = 0;
-    }
-
-    for (ind = 0; ind < ((glCompSet *) p->parentset)->labelcount; ind++) {
-       if (((glCompSet *) p->parentset)->labels[ind]->panel == p)
-           ((glCompSet *) p->parentset)->labels[ind]->visible = 0;
-    }
     p->visible = 0;
     return 1;
 
@@ -143,15 +137,6 @@ int glCompPanelHide(glCompPanel * p)
 int glCompPanelShow(glCompPanel * p)
 {
     int ind = 0;
-    for (ind = 0; ind < ((glCompSet *) p->parentset)->buttoncount; ind++) {
-       if (((glCompSet *) p->parentset)->buttons[ind]->panel == p)
-           ((glCompSet *) p->parentset)->buttons[ind]->visible = 1;
-    }
-
-    for (ind = 0; ind < ((glCompSet *) p->parentset)->labelcount; ind++) {
-       if (((glCompSet *) p->parentset)->labels[ind]->panel == p)
-           ((glCompSet *) p->parentset)->labels[ind]->visible = 1;
-    }
     p->visible = 1;
     return 1;
 
index 8a05687e1655431652aa2c09505bb7eb1595a0c5..7db688a6c5cf9f112ae441660faf979dd6e78cc3 100644 (file)
@@ -65,10 +65,6 @@ static void glCompSetGetPos(int x, int y, float *X, float *Y, float *Z)
     *Z = (float) posZ;
 }
 
-
-
-
-
 void glCompDrawBegin(void)             //pushes a gl stack 
 {
     int vPort[4];
@@ -104,6 +100,10 @@ void glCompDrawEnd(void)           //pops the gl stack
 
 
 
+
+
+
+
 static int glCompSetDrawPanels(glCompSet * s)
 {
     int ind = 0;
@@ -153,18 +153,34 @@ int glCompSetShow(glCompSet * s)
 }
 static int glCompPointInButton(glCompButton * p, float x, float y)
 {
-    float button_x, button_y;
-    if (p->panel) {
-       button_x = p->pos.x + p->panel->pos.x;
-       button_y = p->pos.y + p->panel->pos.y;
+       int kts,kts2;
+       GLfloat tempX,tempY;
+       GLfloat h,h2;   /*container widget height*/
+       float color_fac;
+    float thickness = p->thickness;
+    float fontx, fonty;
+       GLfloat fontwidth;
+       float button_x, button_y;
+
+       if (p->orientation==1){ kts=1; h=0;}else{kts=-1; h=((glCompSet*)p->parentset)->h;}
+       if (p->panel->orientation==1){  kts2=1; h2=0;}else
+       {
+               kts2=-1; h2=((glCompSet*)p->panel->parentset)->h;
+       }
+    if (!p->visible)
+               return 0;
+    if (p->panel)
+       {
+               button_x = p->panel->pos.x + p->pos.x;
+               button_y = p->panel->pos.y*kts2*kts+h2 + p->pos.y-h;
+               if (p->panel->orientation==0)
+                       button_y = button_y - p->panel->height;
     }
 
-    if ((x >= button_x) &&
-       (x <= button_x + p->width) &&
-       (y >= button_y) && (y <= button_y + p->height))
-       return 1;
+    if ((x >= button_x) &&     (x <= button_x + p->width) &&   (y >= button_y) && (y <= button_y + p->height))
+               return 1;
     else
-       return 0;
+               return 0;
 
 }
 
@@ -246,9 +262,12 @@ void glCompSetClear(glCompSet * s)
     free(s);
 }
 
-glCompSet* glCompSetNew()
+glCompSet* glCompSetNew( int w, int h)
 {
     glCompSet *s = NEW(glCompSet);
+       s->w=(GLfloat)w;
+       s->h=(GLfloat)h;
+       s->groupCount=0;
     return s;
 }
 
@@ -259,6 +278,27 @@ int glCompSetDraw(glCompSet * s)
     glCompDrawEnd();
     return 1;
 }
+
+void glcompsetUpdateBorder(glCompSet * s, int w, int h)
+{
+       if ( w > 0 && h > 0)
+       {
+               s->w=(GLfloat)w;
+               s->h=(GLfloat)h;
+       }
+}
+extern int glcompsetGetGroupId(glCompSet *s)
+{
+       return s->groupCount;
+}
+extern int glcompsetNextGroupId(glCompSet *s)
+{
+       int rv= s->groupCount;
+       s->groupCount++;
+       return rv;
+}
+
+
 #if 0
 static void change_fonts(glCompSet * s,const texFont_t* sourcefont)
 {
index a3e5d524b36b83f8271bc35eedb461c28f0bf0fe..140c572d3ad7f68e3e688601cd220fd006240888 100644 (file)
 #include "glcomptexture.h"
 
 
-extern glCompSet* glCompSetNew(void);
+extern glCompSet* glCompSetNew( int w, int h);
 extern void glCompSetClear(glCompSet * s);
 extern int glCompSetDraw(glCompSet * s);
 extern int glCompSetHide(glCompSet * s);
 extern int glCompSetShow(glCompSet * s);
 extern int glCompSetClick(glCompSet * s, int x, int y);
 extern int glCompSetRelease(glCompSet * s, int x, int y);
+extern void glcompsetUpdateBorder(glCompSet * s, int w, int h);
+extern int glcompsetNextGroupId(glCompSet *s);
+extern int glcompsetGetGroupId(glCompSet *s);
 
 extern void glCompDrawBegin(void);
 extern void glCompDrawEnd(void);
index 85c0380198f2eef301162d680f072403d9ceb721..6937986320abfb7d1a03f875105bfb8a07e79787 100644 (file)
@@ -267,14 +267,6 @@ int glreversecamera(ViewInfo * view)
 #endif
 #include <math.h>
 
-typedef struct {
-  point3f u, v;
-} line;
-
-typedef struct {
-  point3f N;   /* normal */
-  double d;  /* offset */
-} plane;
 
 
 static point3f add (point3f p, point3f q)
@@ -384,6 +376,50 @@ double point_to_lineseg_dist (point3f p, point3f a, point3f b)
 
     return dist(p, q);
 
+}
+/*
+       Calculates the parameters of a plane via given 3 points on it
+*/
+
+
+void make_plane(point3f a,point3f b,point3f c,plane* P)
+{
+       P->N.x=a.y*(b.z-c.z)+b.y*(c.z-a.z)+c.y*(a.z-b.z);//+
+       P->N.y=a.z*(b.x-c.x)+b.z*(c.x-a.x)+c.z*(a.x-b.x);//+
+       P->N.z=a.x*(b.y-c.y)+b.x*(c.y-a.y)+c.x*(a.y-b.y);//+
+       P->d=(a.x*(b.y*c.z-c.y*b.z)+b.x*(c.y*a.z-a.y*c.z)+c.x*(a.y*b.z-b.y*a.z))*-1;
+}
+void replacestr(char *source,char **target)
+{
+
+       if (*target)
+               free(*target);
+       *target =strdup(source);
+}
+/*
+       move a point on the great circle of it (spherical)
+
+*/
+
+#define G_PI    3.1415926535897932384626433832795028841971693993751
+#define DEG2RAD  G_PI/180
+int rot_spherex(plane J,double tet,point3f P,point3f* P2)
+{
+       if (tet > 0)
+       {
+               tet=5;
+               tet=DEG2RAD * tet;
+               P2->x=(float)(J.N.x * J.N.x + cos(tet) * (1-J.N.x*J.N.x))*P.x + (J.N.x*J.N.y*(1-cos(tet)) - J.N.z*sin(tet))
+                       + (J.N.z * J.N.x*(1-cos(tet)) + J.N.y * sin(tet))* P.z;
+               P2->y=(float)(J.N.x * J.N.y*(1-cos(tet)) + J.N.z*sin(tet))*P.x + (J.N.y*J.N.y + cos(tet)*(1-J.N.y * J.N.y))* P.y
+                       + (J.N.y*J.N.z*(1-cos(tet)) - J.N.x * sin(tet)) * P.z;
+               P2->z=(float)(J.N.z*J.N.x*(1-cos(tet)) - J.N.y *sin(tet))*P.x + (J.N.y*J.N.z*(1-cos(tet)) + J.N.x*sin(tet))*P.y
+                       + (J.N.z*J.N.z+cos(tet)*(1-J.N.z*J.N.z))*P.z;
+               return 1;
+       }
+       else
+               return 0;
+
 }
 
 #ifdef DEBUG
index dafa07a9c29cc2ff4f3fddca20ac5e9ffebd1d22..9275515f3beb3abf00f9229fba415c83e8962a75 100644 (file)
 typedef struct {
     float x, y, z;
 } point3f;
+typedef struct {
+  point3f u, v;
+} line;
+typedef struct {
+  point3f N;   /* normal */
+  double d;  /* offset */
+} plane;
+
 
 int GetFixedOGLPos(int, int, float, GLfloat*, GLfloat*, GLfloat * Z);
 int GetOGLPosRef(int x, int y, float *X, float *Y, float *Z);
@@ -34,5 +42,7 @@ void to3D(int x, int y, GLfloat * X, GLfloat * Y,GLfloat * Z);
 void linear_interplotate (float,float,float,float,float,float*);
 double point_to_line_dist(point3f p, point3f u, point3f v);
 double point_to_lineseg_dist (point3f p, point3f a, point3f b);
-
+int rot_spherex(plane J,double tet,point3f P,point3f* P2);
+void make_plane(point3f a,point3f b,point3f c,plane* P);
+void replacestr(char *source,char **target);
 #endif