+/* $Id$Revision: */
+/* vim:set shiftwidth=4 ts=8: */
+
+/**********************************************************
+* This software is part of the graphviz package *
+* http://www.graphviz.org/ *
+* *
+* Copyright (c) 1994-2007 AT&T Corp. *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Corp. *
+* *
+* Information and Software Systems Research *
+* AT&T Research, Florham Park NJ *
+**********************************************************/
+
#include "glcompdefs.h"
#define ARCBALL_C
-#include "arcball.h"
#include "smyrnadefs.h"
+#include "arcball.h"
-void setBounds(ArcBall_t* a,GLfloat NewWidth, GLfloat NewHeight)
+static 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);
+ 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)
+static void mapToSphere(ArcBall_t * a, const Point2fT * NewPt,
+ Vector3fT * NewVec)
{
Point2fT TempPt;
GLfloat length;
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);
+ 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);
+ 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;
+ if (length > 1.0f) {
+ GLfloat norm;
- //Compute a normalizing factor (radius / sqrt(length))
- norm = 1.0f / FuncSqrt(length);
+ //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 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);
+ //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);
}
}
-static 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 }};
+static 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}
+};
-static Matrix3fT LastRot = {{ 1.0f, 0.0f, 0.0f, // NEW: Last Rotation
- 0.0f, 1.0f, 0.0f,
- 0.0f, 0.0f, 1.0f }};
+static Matrix3fT LastRot = { {1.0f, 0.0f, 0.0f, // NEW: Last Rotation
+ 0.0f, 1.0f, 0.0f,
+ 0.0f, 0.0f, 1.0f}
+};
-static Matrix3fT ThisRot = {{ 1.0f, 0.0f, 0.0f, // NEW: This Rotation
- 0.0f, 1.0f, 0.0f,
- 0.0f, 0.0f, 1.0f }};
+static Matrix3fT ThisRot = { {1.0f, 0.0f, 0.0f, // NEW: This Rotation
+ 0.0f, 1.0f, 0.0f,
+ 0.0f, 0.0f, 1.0f}
+};
//Create/Destroy
-void init_arcBall(ArcBall_t* a,GLfloat NewWidth, GLfloat NewHeight)
+void init_arcBall(ArcBall_t * a, GLfloat NewWidth, GLfloat NewHeight)
{
- 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;
+ 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);
+ setBounds(a, NewWidth, NewHeight);
- a->isClicked = 0;
- a->isRClicked = 0;
- a->isDragging = 0;
+ a->isClicked = 0;
+ a->isRClicked = 0;
+ a->isDragging = 0;
}
//Mouse down
-void click(ArcBall_t* a,const Point2fT* NewPt)
-
+static void click(ArcBall_t * a, const Point2fT * NewPt)
{
//Map the point to the sphere
- _mapToSphere(a,NewPt, &a->StVec);
+ mapToSphere(a, NewPt, &a->StVec);
}
//Mouse drag, calculate rotation
-void drag(ArcBall_t* a,const Point2fT* NewPt, Quat4fT* NewRot)
+static void drag(ArcBall_t * a, const Point2fT * NewPt, Quat4fT * NewRot)
{
//Map the point to the sphere
- _mapToSphere(a,NewPt, &a->EnVec);
+ 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;
- }
+ 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)
+#ifdef UNUSED
+static 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
+ 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)
+#endif
+
+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);
+ 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)
+
+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
+ 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)
+#ifdef UNUSED
+void Update(ViewInfo * view)
{
- if (view->arcball->isRClicked) // If Right Mouse Clicked, Reset All Rotations
+ 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
+ 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->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;
+ 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;
}
}
-
-
-
+#endif
+/* $Id$Revision: */
+/* vim:set shiftwidth=4 ts=8: */
+
/** KempoApi: The Turloc Toolkit *****************************/
/** * * **/
/** ** ** Filename: ArcBall.h **/
#ifndef _ArcBall_h
#define _ArcBall_h
-
-
-
// 8<--Snip here if you have your own math types/funcs-->8
# include "assert.h"
//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
- {
- GLfloat M[9];
- 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;
- } Matrix3fT; //A single precision floating point 3 by 3 matrix.
-
- typedef union Matrix4f_t
- {
- GLfloat M[16];
- 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;
- } Matrix4fT; //A single precision floating point 4 by 4 matrix.
+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 {
+ GLfloat M[9];
+ 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;
+} Matrix3fT; //A single precision floating point 3 by 3 matrix.
+
+typedef union Matrix4f_t {
+ GLfloat M[16];
+ 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;
+} 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 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 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.
+#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
* 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);
+static void Point2fAdd(Point2fT * NewObj, const Tuple2fT * t1)
+{
+ assert(NewObj && t1);
- NewObj->s.X += t1->s.X;
- NewObj->s.Y += t1->s.Y;
- }
+ 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;
- }
+static void Point2fSub(Point2fT * NewObj, const Tuple2fT * t1)
+{
+ assert(NewObj && t1);
+
+ NewObj->s.X -= t1->s.X;
+ NewObj->s.Y -= t1->s.Y;
+}
#endif
/**
* 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);
+static void Vector3fCross(Vector3fT * NewObj, const Vector3fT * v1,
+ const Vector3fT * v2)
+{
+ Vector3fT Result; //safe not to initialize
- // store on stack once for aliasing-safty
- // i.e. safe when a.cross(a, b)
+ assert(NewObj && v1 && v2);
- 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);
+ // store on stack once for aliasing-safty
+ // i.e. safe when a.cross(a, b)
- //copy result back
- *NewObj = Result;
- }
+ 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);
- }
+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);
- }
+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 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;
- }
+
+#ifdef UNUSED
+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;
- }
+static void Matrix3fSetIdentity(Matrix3fT * NewObj)
+{
+ Matrix3fSetZero(NewObj);
+
+ //then set diagonal as 1
+ NewObj->s.M00 = NewObj->s.M11 = NewObj->s.M22 = 1.0f;
+}
+#endif
/**
* Sets the value of this matrix to the matrix conversion of the
* @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);
- }
+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;
- }
+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.
* @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)
+
+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
{
- 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;
+ //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;
}
-
- static void Matrix4fSetRotationScaleFromMatrix3f(Matrix4fT* NewObj, const Matrix3fT* m1)
+ if (rot4) //if pointer not null
{
- 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;
+ 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;
}
-
- static void Matrix4fMulRotationScale(Matrix4fT* NewObj, GLfloat scale)
- {
- assert(NewObj);
+ return s;
+}
- 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;
- }
+
+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
* components.
* @param m1 T precision 3x3 matrix
*/
-
- static void Matrix4fSetRotationFromMatrix3f(Matrix4fT* NewObj, const Matrix3fT* m1)
- {
- GLfloat scale;
- assert(NewObj && m1);
+static void Matrix4fSetRotationFromMatrix3f(Matrix4fT * NewObj,
+ const Matrix3fT * m1)
+{
+ GLfloat scale;
- scale = Matrix4fSVD(NewObj, NULL, NULL);
+ assert(NewObj && m1);
- Matrix4fSetRotationScaleFromMatrix3f(NewObj, m1);
- Matrix4fMulRotationScale(NewObj, scale);
- }
+ scale = Matrix4fSVD(NewObj, NULL, NULL);
+
+ Matrix4fSetRotationScaleFromMatrix3f(NewObj, m1);
+ Matrix4fMulRotationScale(NewObj, scale);
+}
#endif
// 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);
-
-
+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;
+};
+
+
+void init_arcBall(ArcBall_t * a, GLfloat NewWidth, GLfloat NewHeight);
+void arcmouseClick(ViewInfo * v);
+void arcmouseDrag(ViewInfo * v);
#endif
-
{
parent_n->child_count++;
parent_n->childs = RALLOC(parent_n->child_count, parent_n->childs,
- btree_node *);
+ btree_node *);
parent_n->childs[parent_n->child_count - 1] = n;
n->rank = parent_n->rank + 1;
n->parent = parent_n;
int delete_node(btree_node * n)
{
- btree_node* parent = n->parent;
+ btree_node *parent = n->parent;
int i = 0;
int child_found = 0;
//rmeove from parent's child list
parent->childs[i] = parent->childs[i + 1];
}
}
- parent->childs = RALLOC(parent->child_count,parent->childs, btree_node *);
+ parent->childs =
+ RALLOC(parent->child_count, parent->childs, btree_node *);
delete_node_recursive(n);
return 1;
}
while (*c_cursor != '\0') {
if (kp_open) {
if ((*c_cursor == ',') || ((*c_cursor == ']') && (!qt_open))) {
- attrs = RALLOC(attrs_count + 1, attrs, char*);
+ attrs = RALLOC(attrs_count + 1, attrs, char *);
attrs[attrs_count] = strdup(buff_attr);
attrs_count++;
- values =
- RALLOC(values_count + 1, values, char*);
+ values = RALLOC(values_count + 1, values, char *);
values[values_count] = strdup(buff_value);
values_count++;
buff_attr[0] = '\0';
#ifndef BTREE_H
#define BTREE_H
+
#include "tvnodes.h"
#ifdef WIN32
#include "regex_win32.h"
#endif
-btree_node *new_node(char *attribute, char *regex, float min, float max);
-int insert_node(btree_node * parent_n, btree_node * n);
-int delete_node(btree_node * n);
-int delete_node_recursive(btree_node * n); //internal function
-btree_node *look_up_node_with_string(btree_node * n,
- char *string_to_lookup);
-int validate_lookup(btree_node * n, char *string_to_lookup); //it can be anything, in this case attr_name
-int print_tree(btree_node * root);
-int print_children(btree_node * n);
-btree_node *tree_from_filter_string(char *filter_string);
-int evaluate_filter_atom(char *string, btree_node * Nodes[], char *op);
-int evaluate_expresions(tv_node * Node, btree_node * root);
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ btree_node *new_node(char *attribute, char *regex, float min,
+ float max);
+ int insert_node(btree_node * parent_n, btree_node * n);
+ int delete_node(btree_node * n);
+ int delete_node_recursive(btree_node * n); //internal function
+ btree_node *look_up_node_with_string(btree_node * n,
+ char *string_to_lookup);
+ int validate_lookup(btree_node * n, char *string_to_lookup); //it can be anything, in this case attr_name
+ int print_tree(btree_node * root);
+ int print_children(btree_node * n);
+ btree_node *tree_from_filter_string(char *filter_string);
+ int evaluate_filter_atom(char *string, btree_node * Nodes[], char *op);
+ int evaluate_expresions(tv_node * Node, btree_node * root);
+
+#ifdef __cplusplus
+} /* end extern "C" */
+#endif
#endif
GLubyte rasters[24] = {
0xc0, 0x00, 0xc0, 0x00, 0xc0, 0x00, 0xc0, 0x00, 0xc0, 0x00, 0xff, 0x00,
- 0xff, 0x00,
+ 0xff, 0x00,
0xc0, 0x00, 0xc0, 0x00, 0xc0, 0x00, 0xff, 0xc0, 0xff, 0xc0
};
-void DrawBezier(GLfloat * xp, GLfloat * yp, GLfloat * zp, int filled, int param)
+void DrawBezier(GLfloat * xp, GLfloat * yp, GLfloat * zp, int filled,
+ int param)
{
/*copied from NEHE */
/*Written by: David Nikdel ( ogapo@ithink.net ) */
Z = Az * a * a * a + Bz * 3 * a * a * b + Cz * 3 * a * b * b +
Dz * b * b * b;
// Draw the line from point to point (assuming OGL is set up properly)
- glVertex3d(X, Y, Z+globalz);
+ glVertex3d(X, Y, Z + globalz);
// Change the variable
a -= 0.05;
b = 1.0 - a;
if ((param == 1) && (view->mouse.mouse_mode == 10) && (view->mouse.mouse_down == 1)) //selected, if there is move, move it
{
- dx = view->GLx - view->GLx2;
- dy = view->GLy - view->GLy2;
- } else
- {
- dx = 0;
- dy = 0;
+ dx = view->GLx - view->GLx2;
+ dy = view->GLy - view->GLy2;
+ } else {
+ dx = 0;
+ dy = 0;
}
}
//convert degrees into radians
float degInRad = (float) (i * DEG2RAD);
glVertex3f((GLfloat) (x + cos(degInRad) * xradius),
- (GLfloat) (y + sin(degInRad) * yradius),globalz);
+ (GLfloat) (y + sin(degInRad) * yradius), globalz);
}
glEnd();
}
for (i = 0; i < op->u.polygon.cnt; i = i + 1) {
glVertex3f((GLfloat) op->u.polygon.pts[i].x - dx,
(GLfloat) op->u.polygon.pts[i].y - dy,
- (GLfloat) op->u.polygon.pts[i].z+globalz);
+ (GLfloat) op->u.polygon.pts[i].z + globalz);
}
- glVertex3f((GLfloat) op->u.polygon.pts[0].x - dx, (GLfloat) op->u.polygon.pts[0].y - dy, (GLfloat) op->u.polygon.pts[0].z+globalz); //close the polygon
+ glVertex3f((GLfloat) op->u.polygon.pts[0].x - dx, (GLfloat) op->u.polygon.pts[0].y - dy, (GLfloat) op->u.polygon.pts[0].z + globalz); //close the polygon
glEnd();
}
for (i = 0; i < op->u.polyline.cnt; i = i + 1) {
glVertex3f((GLfloat) op->u.polyline.pts[i].x - dx,
(GLfloat) op->u.polyline.pts[i].y - dy,
- (GLfloat) op->u.polyline.pts[i].z+globalz);
+ (GLfloat) op->u.polyline.pts[i].z + globalz);
}
glEnd();
}
static void SetFont(xdot_op * op, int param)
{
- //activate the right font
+ //activate the right font
/* view->widgets->fontset->activefont=add_font(view->widgets->fontset,op->u.font.name);//load or set active font
view->FontSize = op->u.font.size;*/
}
void InsertImage(xdot_op * op, int param)
{
- // SelectImage((sdot_op *) op);
+ // SelectImage((sdot_op *) op);
}
void EmbedText(xdot_op * op, int param)
{
- /*use gl pango fonts*/
+ /*use gl pango fonts */
#ifdef UNUSED
- GLfloat x;
+ GLfloat x;
// SelectText((sdot_op *) op);
set_options((sdot_op *) op, param);
if (op->u.text.align == 1)
x = (GLfloat) op->u.text.x;
if (op->u.text.align == -1)
x = (GLfloat) op->u.text.x + op->u.text.width;
- view->widgets->fontset->fonts[view->widgets->fontset->activefont]->fontheight=view->FontSize;
+ view->widgets->fontset->fonts[view->widgets->fontset->activefont]->
+ fontheight = view->FontSize;
if (param == 0)
- fontColor(view->widgets->fontset->fonts[view->widgets->fontset->activefont],view->penColor.R, view->penColor.G, view->penColor.B,1);
+ fontColor(view->widgets->fontset->
+ fonts[view->widgets->fontset->activefont],
+ view->penColor.R, view->penColor.G, view->penColor.B, 1);
if (param == 1) //selected
- fontColor(view->widgets->fontset->fonts[view->widgets->fontset->activefont],view->selectedNodeColor.R, view->selectedNodeColor.G,
- view->selectedNodeColor.B,1);
- glprintf(view->widgets->fontset->fonts[view->widgets->fontset->activefont], (x - dx), (GLfloat)op->u.text.y - dy,(GLfloat)0,
- (GLfloat)op->u.text.width, op->u.text.text);
+ fontColor(view->widgets->fontset->
+ fonts[view->widgets->fontset->activefont],
+ view->selectedNodeColor.R, view->selectedNodeColor.G,
+ view->selectedNodeColor.B, 1);
+ glprintf(view->widgets->fontset->
+ fonts[view->widgets->fontset->activefont], (x - dx),
+ (GLfloat) op->u.text.y - dy, (GLfloat) 0,
+ (GLfloat) op->u.text.width, op->u.text.text);
#endif
}
}
glBegin(GL_LINE_STRIP);
glVertex3f((GLfloat) view->GLx, (GLfloat) view->GLy,
- (GLfloat) 0.001+globalz);
+ (GLfloat) 0.001 + globalz);
glVertex3f((GLfloat) view->GLx, (GLfloat) view->GLy2,
- (GLfloat) 0.001+globalz);
+ (GLfloat) 0.001 + globalz);
glVertex3f((GLfloat) view->GLx2, (GLfloat) view->GLy2,
- (GLfloat) 0.001+globalz);
+ (GLfloat) 0.001 + globalz);
glVertex3f((GLfloat) view->GLx2, (GLfloat) view->GLy,
- (GLfloat) 0.001+globalz);
+ (GLfloat) 0.001 + globalz);
glVertex3f((GLfloat) view->GLx, (GLfloat) view->GLy,
- (GLfloat) 0.001+globalz);
+ (GLfloat) 0.001 + globalz);
glEnd();
if (view->mouse.mouse_mode == 5)
glDisable(GL_LINE_STIPPLE);
//converting screen pixel distaances to GL distances
view->mg.GLwidth = GetOGLDistance(view->mg.width) / (float) 2.0;
view->mg.GLheight = GetOGLDistance(view->mg.height) / (float) 2.0;
- GetOGLPosRef((int)view->mouse.mouse_X, (int)view->mouse.mouse_Y, &mg_x, &mg_y, &mg_z); //retrieving mouse coords as GL coordinates
+ GetOGLPosRef((int) view->mouse.mouse_X, (int) view->mouse.mouse_Y, &mg_x, &mg_y, &mg_z); //retrieving mouse coords as GL coordinates
view->mg.x = mg_x;
view->mg.y = mg_y;
glLineWidth(4);
angle += (float) 0.1) {
vectorX = originX + radius * (float) sin(angle);
vectorY = originY + radius * (float) cos(angle);
- glVertex3d(vectorX1, vectorY1,globalz);
+ glVertex3d(vectorX1, vectorY1, globalz);
vectorY1 = vectorY;
vectorX1 = vectorX;
}
}
-GLUquadric* fisheyesphere;
+GLUquadric *fisheyesphere;
void draw_fisheye_magnifier(ViewInfo * view)
{
if ((view->mouse.mouse_mode == 21) && (view->mouse.mouse_down)) {
GLfloat mg_x, mg_y, mg_z;
a = GetOGLDistance((int) view->fmg.constantR);
view->fmg.R = (int) a;
- GetOGLPosRef((int)view->mouse.mouse_X, (int)view->mouse.mouse_Y, &mg_x,
- &mg_y, &mg_z);
+ GetOGLPosRef((int) view->mouse.mouse_X, (int) view->mouse.mouse_Y,
+ &mg_x, &mg_y, &mg_z);
glColor4f((GLfloat) 0.3, (GLfloat) 0.1, (GLfloat) 0.8,
(GLfloat) 1);
- if (((view->fmg.x != mg_x) || (view->fmg.y != mg_y))&&(view->active_camera==-1)) {
- fisheye_polar(mg_x, mg_y, view->Topview);
+ if (((view->fmg.x != mg_x) || (view->fmg.y != mg_y))
+ && (view->active_camera == -1)) {
+ fisheye_polar(mg_x, mg_y, view->Topview);
draw_circle(mg_x, mg_y, a);
}
- if (((view->fmg.x != mg_x) || (view->fmg.y != mg_y))&&(view->active_camera>-1)) {
- fisheye_spherical(mg_x, mg_y,0.00,view->Topview);
-
-
- if(!fisheyesphere)
- fisheyesphere=gluNewQuadric();
- gluQuadricDrawStyle ( fisheyesphere, GLU_LINE );
- glColor4f((GLfloat) 0.3, (GLfloat) 0.1, (GLfloat) 0.8,(GLfloat)0.05);
- glTranslatef(mg_x,mg_y,0);
- gluSphere(fisheyesphere,a,30,30);
- glTranslatef(-mg_x,-mg_y,0);
+ if (((view->fmg.x != mg_x) || (view->fmg.y != mg_y))
+ && (view->active_camera > -1)) {
+ fisheye_spherical(mg_x, mg_y, 0.00, view->Topview);
+
+
+ if (!fisheyesphere)
+ fisheyesphere = gluNewQuadric();
+ gluQuadricDrawStyle(fisheyesphere, GLU_LINE);
+ glColor4f((GLfloat) 0.3, (GLfloat) 0.1, (GLfloat) 0.8,
+ (GLfloat) 0.05);
+ glTranslatef(mg_x, mg_y, 0);
+ gluSphere(fisheyesphere, a, 30, 30);
+ glTranslatef(-mg_x, -mg_y, 0);
}
void drawBorders(ViewInfo * view)
{
if (view->bdVisible) {
- glColor4f(view->borderColor.R,view->borderColor.B,view->borderColor.G,view->borderColor.A);
+ glColor4f(view->borderColor.R, view->borderColor.B,
+ view->borderColor.G, view->borderColor.A);
glLineWidth(2);
glBegin(GL_LINE_STRIP);
glVertex2d(view->bdxLeft, view->bdyBottom);
static void drawXdotwithattrs(void *e, int param)
{
- /* drawXdotwithattr(e, "_draw_", param);
- drawXdotwithattr(e, "_ldraw_", param);
- drawXdotwithattr(e, "_hdraw_", param);
- drawXdotwithattr(e, "_tdraw_", param);
- drawXdotwithattr(e, "_hldraw_", param);
- drawXdotwithattr(e, "_tldraw_", param);*/
+ /* drawXdotwithattr(e, "_draw_", param);
+ drawXdotwithattr(e, "_ldraw_", param);
+ drawXdotwithattr(e, "_hdraw_", param);
+ drawXdotwithattr(e, "_tdraw_", param);
+ drawXdotwithattr(e, "_hldraw_", param);
+ drawXdotwithattr(e, "_tldraw_", param); */
}
#endif
sdot_op *ops = (sdot_op *) (xDot->ops);
sdot_op *op;
- for (id = 0; id < xDot->cnt; id++)
- {
- op = ops + id;
- op->obj = p;
- if (op->op.kind==xd_font)
- {
-// add_font(view->widgets->fontset,op->op.u.font.name,op->op.u.font.size);//load or set active font
- }
+ for (id = 0; id < xDot->cnt; id++) {
+ op = ops + id;
+ op->obj = p;
+ if (op->op.kind == xd_font) {
+// add_font(view->widgets->fontset,op->op.u.font.name,op->op.u.font.size);//load or set active font
+ }
}
}
static void scanXdotwithattr(void *p, char *attr)
{
xdot *xDot;
- if ((xDot = parseXDotF(agget(p, attr), OpFns, sizeof(sdot_op))))
- {
- scanXdot(xDot, p);
- freeXDot(xDot);
+ if ((xDot = parseXDotF(agget(p, attr), OpFns, sizeof(sdot_op)))) {
+ scanXdot(xDot, p);
+ freeXDot(xDot);
}
}
{
Agnode_t *v;
Agedge_t *e;
- for (v = agfstnode(g); v; v = agnxtnode(g, v))
- {
- scanXdotwithattr(v, "_draw_");
- scanXdotwithattr(v, "_ldraw_");
- for (e = agfstout(g, v); e; e = agnxtout(g, e))
- {
- scanXdotwithattrs(e);
- }
+ for (v = agfstnode(g); v; v = agnxtnode(g, v)) {
+ scanXdotwithattr(v, "_draw_");
+ scanXdotwithattr(v, "_ldraw_");
+ for (e = agfstout(g, v); e; e = agnxtout(g, e)) {
+ scanXdotwithattrs(e);
+ }
}
}
float degInRad = (float) (i * DEG2RAD);
glVertex3f((GLfloat) (x + cos(degInRad) * radius),
(GLfloat) (y + sin(degInRad) * radius),
- (GLfloat) zdepth+globalz);
+ (GLfloat) zdepth + globalz);
}
glEnd();
{
gvcolor_t cl;
RGBColor c;
- if (color != '\0')
- {
- colorxlate(color, &cl, RGBA_DOUBLE);
- c.R = (float) cl.u.RGBA[0];
- c.G = (float) cl.u.RGBA[1];
- c.B = (float) cl.u.RGBA[2];
- c.A = (float) cl.u.RGBA[3];
- } else
- {
- c.R = view->penColor.R;
- c.G = view->penColor.G;
- c.B = view->penColor.B;
- c.A = view->penColor.A;
+ if (color != '\0') {
+ colorxlate(color, &cl, RGBA_DOUBLE);
+ c.R = (float) cl.u.RGBA[0];
+ c.G = (float) cl.u.RGBA[1];
+ c.B = (float) cl.u.RGBA[2];
+ c.A = (float) cl.u.RGBA[3];
+ } else {
+ c.R = view->penColor.R;
+ c.G = view->penColor.G;
+ c.B = view->penColor.B;
+ c.A = view->penColor.A;
}
return c;
}
-void drawEllipse(float xradius, float yradius,int angle1,int angle2)
+void drawEllipse(float xradius, float yradius, int angle1, int angle2)
{
- int i;
- glBegin(GL_LINE_STRIP);
+ int i;
+ glBegin(GL_LINE_STRIP);
- for (i=angle1; i<=angle2; i++)
- {
- //convert degrees into radians
- float degInRad = (float)i*(float)DEG2RAD;
- glVertex3f((GLfloat)(cos(degInRad)*xradius),(GLfloat)(sin(degInRad)*yradius),globalz);
- }
-
- glEnd();
-}
-int draw_node_hintbox_gl_polygon(GLfloat x,GLfloat y,GLfloat z,GLfloat fs,char* text)
+ for (i = angle1; i <= angle2; i++) {
+ //convert degrees into radians
+ float degInRad = (float) i * (float) DEG2RAD;
+ glVertex3f((GLfloat) (cos(degInRad) * xradius),
+ (GLfloat) (sin(degInRad) * yradius), globalz);
+ }
+ glEnd();
+}
+int draw_node_hintbox_gl_polygon(GLfloat x, GLfloat y, GLfloat z,
+ GLfloat fs, char *text)
{
- GLfloat X,Y,Z,pad;
- pad=fs/(GLfloat)5.0;
- X=x;Y=y;Z=z+(GLfloat)0.0005;
- glBegin(GL_POLYGON);
- glVertex3f(X,Y,Z);
- Y=Y + fs;
- glVertex3f(X,Y,Z);
- X=X+fs;
- glVertex3f(X,Y,Z);
- X=x;y=y;
- glVertex3f(X,Y,Z);
- glEnd();
+ GLfloat X, Y, Z, pad;
+ pad = fs / (GLfloat) 5.0;
+ X = x;
+ Y = y;
+ Z = z + (GLfloat) 0.0005;
+ glBegin(GL_POLYGON);
+ glVertex3f(X, Y, Z);
+ Y = Y + fs;
+ glVertex3f(X, Y, Z);
+ X = X + fs;
+ glVertex3f(X, Y, Z);
+ X = x;
+ y = y;
+ glVertex3f(X, Y, Z);
+ glEnd();
- X=x;Y=y+fs;
- glBegin(GL_POLYGON);
- glVertex3f(X,Y,Z);
- X=x;Y=Y+fs+2*pad;
- glVertex3f(X,Y,Z);
- X=x+strlen(text)*fs/(GLfloat)2.0+(GLfloat)2.0*pad;
- glVertex3f(X,Y,Z);
- Y=y+fs;
- glVertex3f(X,Y,Z);
- X=x;
- glVertex3f(X,Y,Z);
- glEnd();
+ X = x;
+ Y = y + fs;
+ glBegin(GL_POLYGON);
+ glVertex3f(X, Y, Z);
+ X = x;
+ Y = Y + fs + 2 * pad;
+ glVertex3f(X, Y, Z);
+ X = x + strlen(text) * fs / (GLfloat) 2.0 + (GLfloat) 2.0 *pad;
+ glVertex3f(X, Y, Z);
+ Y = y + fs;
+ glVertex3f(X, Y, Z);
+ X = x;
+ glVertex3f(X, Y, Z);
+ glEnd();
- return 1;
+ return 1;
}
-int draw_node_hintbox_gl_line(GLfloat x,GLfloat y,GLfloat z,GLfloat fs,char* text)
+int draw_node_hintbox_gl_line(GLfloat x, GLfloat y, GLfloat z, GLfloat fs,
+ char *text)
{
- GLfloat X,Y,Z,pad;
- pad=fs/(GLfloat)5.0;
- X=x;Y=y;Z=z+(GLfloat)0.001;
- glBegin(GL_LINE_STRIP);
- glVertex3f(X,Y,Z);
- Y=Y + 2*fs+2*pad;
- glVertex3f(X,Y,Z);
- X=X+2*pad+strlen(text)*fs/(GLfloat)2.0;
- glVertex3f(X,Y,Z);
- Y=y+fs;
- glVertex3f(X,Y,Z);
- X=x+fs;
- glVertex3f(X,Y,Z);
- X=x;Y=y;
- glVertex3f(X,Y,Z);
- glEnd();
+ GLfloat X, Y, Z, pad;
+ pad = fs / (GLfloat) 5.0;
+ X = x;
+ Y = y;
+ Z = z + (GLfloat) 0.001;
+ glBegin(GL_LINE_STRIP);
+ glVertex3f(X, Y, Z);
+ Y = Y + 2 * fs + 2 * pad;
+ glVertex3f(X, Y, Z);
+ X = X + 2 * pad + strlen(text) * fs / (GLfloat) 2.0;
+ glVertex3f(X, Y, Z);
+ Y = y + fs;
+ glVertex3f(X, Y, Z);
+ X = x + fs;
+ glVertex3f(X, Y, Z);
+ X = x;
+ Y = y;
+ glVertex3f(X, Y, Z);
+ glEnd();
- return 1;
+ return 1;
}
-int draw_node_hintbox(GLfloat x,GLfloat y,GLfloat z,GLfloat fs,char* text)
+int draw_node_hintbox(GLfloat x, GLfloat y, GLfloat z, GLfloat fs,
+ char *text)
{
-
- glColor3f(1,1,0);
- draw_node_hintbox_gl_polygon(x,y,z,fs,text);
- glColor3f(0,0,1);
- draw_node_hintbox_gl_line(x,y,z,fs,text);
- return 1;
+
+ glColor3f(1, 1, 0);
+ draw_node_hintbox_gl_polygon(x, y, z, fs, text);
+ glColor3f(0, 0, 1);
+ draw_node_hintbox_gl_line(x, y, z, fs, text);
+ return 1;
}
-static GLUquadric* sphere;
-void draw_sphere(float x,float y,float z,float r)
+static GLUquadric *sphere;
+void draw_sphere(float x, float y, float z, float r)
{
- if(!sphere)
- fisheyesphere=gluNewQuadric();
- gluQuadricDrawStyle ( fisheyesphere, GLU_FILL );
- glTranslatef(x,y,z);
- gluSphere(fisheyesphere,r,SPHERE_SLICE_COUNT,SPHERE_SLICE_COUNT);
- glTranslatef(-x,-y,-z);
+ if (!sphere)
+ fisheyesphere = gluNewQuadric();
+ gluQuadricDrawStyle(fisheyesphere, GLU_FILL);
+ glTranslatef(x, y, z);
+ gluSphere(fisheyesphere, r, SPHERE_SLICE_COUNT, SPHERE_SLICE_COUNT);
+ glTranslatef(-x, -y, -z);
}
#ifdef UNUSED
-void draw_xdot_set(xdot_set* s)
-{
- int ind=0;
- int ind2=0;
- for (ind=0;ind < s->cnt ; ind ++)
- {
- for (ind2=0;ind2 < s->xdots[ind]->cnt ; ind2 ++)
- {
- xdot_op* op;
- op=&s->xdots[ind]->ops[ind2];
- if(op->drawfunc)
- op->drawfunc(op,0);
- }
+void draw_xdot_set(xdot_set * s)
+{
+ int ind = 0;
+ int ind2 = 0;
+ for (ind = 0; ind < s->cnt; ind++) {
+ for (ind2 = 0; ind2 < s->xdots[ind]->cnt; ind2++) {
+ xdot_op *op;
+ op = &s->xdots[ind]->ops[ind2];
+ if (op->drawfunc)
+ op->drawfunc(op, 0);
}
+ }
}
#endif
-
-
#include <string.h>
#include <math.h>
-typedef struct {
- xdot_op op;
- void *obj;
- void *font; //pointer to font in view->fontset
- int size;
-} sdot_op;
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ typedef struct {
+ xdot_op op;
+ void *obj;
+ void *font; //pointer to font in view->fontset
+ int size;
+ } sdot_op;
/* DRAWING FUNCTIONS
* these are opengl based xdot drawing functions
* topview drawings are not here
*/
-extern drawfunc_t OpFns[];
-extern void drawGraph(Agraph_t * g);
-void scanGraph(Agraph_t * g);
-void draw_selection_box(ViewInfo * view);
-void draw_magnifier(ViewInfo * view);
-void draw_fisheye_magnifier(ViewInfo * view);
-extern int randomize_color(RGBColor * c, int brightness);
-extern void drawCircle(float x, float y, float radius, float zdepth);
-extern RGBColor GetRGBColor(char *color);
-extern void drawBorders(ViewInfo * view);
-void drawEllipse(float xradius, float yradius,int angle1,int angle2);
-int draw_node_hintbox(GLfloat x,GLfloat y,GLfloat z,GLfloat fs,char* text);
-void DrawBezier(GLfloat * xp, GLfloat * yp, GLfloat * zp, int filled, int param);
-
-
-void draw_sphere(float x,float y,float z,float r);
-
+ extern drawfunc_t OpFns[];
+ extern void drawGraph(Agraph_t * g);
+ void scanGraph(Agraph_t * g);
+ void draw_selection_box(ViewInfo * view);
+ void draw_magnifier(ViewInfo * view);
+ void draw_fisheye_magnifier(ViewInfo * view);
+ extern int randomize_color(RGBColor * c, int brightness);
+ extern void drawCircle(float x, float y, float radius, float zdepth);
+ extern RGBColor GetRGBColor(char *color);
+ extern void drawBorders(ViewInfo * view);
+ void drawEllipse(float xradius, float yradius, int angle1, int angle2);
+ int draw_node_hintbox(GLfloat x, GLfloat y, GLfloat z, GLfloat fs,
+ char *text);
+ void DrawBezier(GLfloat * xp, GLfloat * yp, GLfloat * zp, int filled,
+ int param);
+
+
+ void draw_sphere(float x, float y, float z, float r);
+
+#ifdef __cplusplus
+} /* end extern "C" */
+#endif
#endif
-
if ((param == 1) && (view->mouse.mouse_mode == 10) && (view->mouse.mouse_down == 1)) //selected, if there is move, move it
{
- dx = view->GLx - view->GLx2;
- dy = view->GLy - view->GLy2;
- } else
- {
- dx = 0;
- dy = 0;
+ dx = view->GLx - view->GLx2;
+ dy = view->GLy - view->GLy2;
+ } else {
+ dx = 0;
+ dy = 0;
}
}
static void SetFont(xdot_op * op, int param)
{
- //activate the right font
- view->fontset->activefont=add_font(view->fontset,op->u.font.name);//load or set active font
- view->FontSize = (int) op->u.font.size;
+ //activate the right font
+ view->fontset->activefont = add_font(view->fontset, op->u.font.name); //load or set active font
+ view->FontSize = (int) op->u.font.size;
}
static void relocate_spline(sdot_op * sop, int param)
Agnode_t *hn; //head node
int i = 0;
xdot_op *op = &sop->op;
- if (AGTYPE(sop->obj) == AGEDGE)
- {
- e = sop->obj;
- tn = agtail(e);
- hn = aghead(e);
- if ((OD_Selected(hn) == 1) && (OD_Selected(tn) == 0))
- {
- set_options(sop, 1);
- for (i = 1; i < op->u.bezier.cnt - 1; i = i + 1)
- {
- if ((dx != 0) || (dy != 0))
- {
- op->u.bezier.pts[i].x =
- op->u.bezier.pts[i].x -
- (int) (dx * (float) i /
- (float) (op->u.bezier.cnt));
- op->u.bezier.pts[i].y =
- op->u.bezier.pts[i].y -
- (int) (dy * (float) i /
- (float) (op->u.bezier.cnt));
- }
- }
- if ((dx != 0) || (dy != 0))
- {
- op->u.bezier.pts[op->u.bezier.cnt - 1].x =
- op->u.bezier.pts[op->u.bezier.cnt - 1].x - (int) dx;
- op->u.bezier.pts[op->u.bezier.cnt - 1].y =
- op->u.bezier.pts[op->u.bezier.cnt - 1].y - (int) dy;
- }
+ if (AGTYPE(sop->obj) == AGEDGE) {
+ e = sop->obj;
+ tn = agtail(e);
+ hn = aghead(e);
+ if ((OD_Selected(hn) == 1) && (OD_Selected(tn) == 0)) {
+ set_options(sop, 1);
+ for (i = 1; i < op->u.bezier.cnt - 1; i = i + 1) {
+ if ((dx != 0) || (dy != 0)) {
+ op->u.bezier.pts[i].x =
+ op->u.bezier.pts[i].x -
+ (int) (dx * (float) i /
+ (float) (op->u.bezier.cnt));
+ op->u.bezier.pts[i].y =
+ op->u.bezier.pts[i].y -
+ (int) (dy * (float) i /
+ (float) (op->u.bezier.cnt));
}
- else if ((OD_Selected(hn) == 0) && (OD_Selected(tn) == 1))
- {
- set_options(sop, 1);
- for (i = op->u.bezier.cnt - 1; i > 0; i = i - 1)
- {
- if ((dx != 0) || (dy != 0))
- {
- op->u.bezier.pts[i].x =
- op->u.bezier.pts[i].x -
- (int) (dx * (float) (op->u.bezier.cnt - i) /
- (float) (op->u.bezier.cnt));
- op->u.bezier.pts[i].y =
- op->u.bezier.pts[i].y -
- (int) (dy * (float) (op->u.bezier.cnt - i) /
- (float) (op->u.bezier.cnt));
- }
- }
- if ((dx != 0) || (dy != 0))
- {
- op->u.bezier.pts[0].x = op->u.bezier.pts[0].x - (int) dx;
- op->u.bezier.pts[0].y = op->u.bezier.pts[0].y - (int) dy;
- }
+ }
+ if ((dx != 0) || (dy != 0)) {
+ op->u.bezier.pts[op->u.bezier.cnt - 1].x =
+ op->u.bezier.pts[op->u.bezier.cnt - 1].x - (int) dx;
+ op->u.bezier.pts[op->u.bezier.cnt - 1].y =
+ op->u.bezier.pts[op->u.bezier.cnt - 1].y - (int) dy;
+ }
+ } else if ((OD_Selected(hn) == 0) && (OD_Selected(tn) == 1)) {
+ set_options(sop, 1);
+ for (i = op->u.bezier.cnt - 1; i > 0; i = i - 1) {
+ if ((dx != 0) || (dy != 0)) {
+ op->u.bezier.pts[i].x =
+ op->u.bezier.pts[i].x -
+ (int) (dx * (float) (op->u.bezier.cnt - i) /
+ (float) (op->u.bezier.cnt));
+ op->u.bezier.pts[i].y =
+ op->u.bezier.pts[i].y -
+ (int) (dy * (float) (op->u.bezier.cnt - i) /
+ (float) (op->u.bezier.cnt));
}
- else if ((OD_Selected(hn) == 1) && (OD_Selected(tn) == 1))
- {
- set_options(sop, 1);
- for (i = 0; i < op->u.bezier.cnt; i = i + 1)
- {
- if ((dx != 0) || (dy != 0))
- {
- op->u.bezier.pts[i].x =
- op->u.bezier.pts[i].x - (int) dx;
- op->u.bezier.pts[i].y =
- op->u.bezier.pts[i].y - (int) dy;
- }
- }
+ }
+ if ((dx != 0) || (dy != 0)) {
+ op->u.bezier.pts[0].x = op->u.bezier.pts[0].x - (int) dx;
+ op->u.bezier.pts[0].y = op->u.bezier.pts[0].y - (int) dy;
+ }
+ } else if ((OD_Selected(hn) == 1) && (OD_Selected(tn) == 1)) {
+ set_options(sop, 1);
+ for (i = 0; i < op->u.bezier.cnt; i = i + 1) {
+ if ((dx != 0) || (dy != 0)) {
+ op->u.bezier.pts[i].x =
+ op->u.bezier.pts[i].x - (int) dx;
+ op->u.bezier.pts[i].y =
+ op->u.bezier.pts[i].y - (int) dy;
}
+ }
}
+ }
}
static void DrawBeziers(xdot_op * op, int param)
int id;
sdot_op *ops = (sdot_op *) (xDot->ops);
sdot_op *op;
- //to avoid the overlapping , z is slightly increased for each xdot of a particular object
- if (AGTYPE(p)==AGEDGE)
- globalz=1;
- else
- globalz=0;
-
- for (id = 0; id < xDot->cnt; id++)
- {
- globalz += GLOBAL_Z_OFFSET;
- op = ops + id;
- op->obj = p;
- op->op.drawfunc(&(op->op), param);
+ //to avoid the overlapping , z is slightly increased for each xdot of a particular object
+ if (AGTYPE(p) == AGEDGE)
+ globalz = 1;
+ else
+ globalz = 0;
+
+ for (id = 0; id < xDot->cnt; id++) {
+ globalz += GLOBAL_Z_OFFSET;
+ op = ops + id;
+ op->obj = p;
+ op->op.drawfunc(&(op->op), param);
}
}
static void drawXdotwithattr(void *p, char *attr, int param)
{
xdot *xDot;
- if ((xDot = parseXDotF(agget(p, attr), OpFns, sizeof(sdot_op))))
- {
- drawXdot(xDot, param, p);
- freeXDot(xDot);
+ if ((xDot = parseXDotF(agget(p, attr), OpFns, sizeof(sdot_op)))) {
+ drawXdot(xDot, param, p);
+ freeXDot(xDot);
}
}
Agedge_t *e;
Agraph_t *s;
int param = 0;
- for (s = agfstsubg(g); s; s = agnxtsubg(s))
- {
+ for (s = agfstsubg(g); s; s = agnxtsubg(s)) {
/* OD_SelFlag(s) = 0;
if (OD_Selected(s) == 1)
param = 1;
else*/
- param = 0;
- drawXdotwithattrs(s, param);
+ param = 0;
+ drawXdotwithattrs(s, param);
}
- for (v = agfstnode(g); v; v = agnxtnode(g, v))
- {
+ for (v = agfstnode(g); v; v = agnxtnode(g, v)) {
/* if (OD_Selected(v) == 1)
param = 1;
else*/
- param = 0;
-// OD_SelFlag(v) = 0;
- drawXdotwithattr(v, "_draw_", param); //draw primitives
- drawXdotwithattr(v, "_ldraw_", param);//label drawing
- for (e = agfstout(g, v); e; e = agnxtout(g, e))
- {
+ param = 0;
+// OD_SelFlag(v) = 0;
+ drawXdotwithattr(v, "_draw_", param); //draw primitives
+ drawXdotwithattr(v, "_ldraw_", param); //label drawing
+ for (e = agfstout(g, v); e; e = agnxtout(g, e)) {
/* OD_SelFlag(e) = 0;
if (OD_Selected(e) == 1)
param = 1;
else*/
- param = 0;
- drawXdotwithattrs(e, param);
- }
+ param = 0;
+ drawXdotwithattrs(e, param);
+ }
}
- if ((view->Selection.Active > 0) && (!view->SignalBlock))
- {
- view->Selection.Active = 0;
- drawGraph(g);
- view->SignalBlock = 1;
- glexpose();
- view->SignalBlock = 0;
+ if ((view->Selection.Active > 0) && (!view->SignalBlock)) {
+ view->Selection.Active = 0;
+ drawGraph(g);
+ view->SignalBlock = 1;
+ glexpose();
+ view->SignalBlock = 0;
}
}
for (id = 0; id < xDot->cnt; id++) {
op = ops + id;
op->obj = p;
- if (op->op.kind==xd_font) {
- add_font(view->fontset,op->op.u.font.name);//load or set active font
+ if (op->op.kind == xd_font) {
+ add_font(view->fontset, op->op.u.font.name); //load or set active font
}
}
}
{
Agnode_t *v;
Agedge_t *e;
- for (v = agfstnode(g); v; v = agnxtnode(g, v))
- {
- scanXdotwithattr(v, "_draw_");
- scanXdotwithattr(v, "_ldraw_");
- for (e = agfstout(g, v); e; e = agnxtout(g, e))
- {
- scanXdotwithattrs(e);
- }
+ for (v = agfstnode(g); v; v = agnxtnode(g, v)) {
+ scanXdotwithattr(v, "_draw_");
+ scanXdotwithattr(v, "_ldraw_");
+ for (e = agfstout(g, v); e; e = agnxtout(g, e)) {
+ scanXdotwithattrs(e);
+ }
}
}
#ifdef UNUSED
-char* create_us_map()
+char *create_us_map()
{
- float x1,y1,x2,y2;
- float ox1,oy1,ox2,oy2;
- static const char filename[] = "file.txt";
- FILE *file = fopen ( filename, "r" );
- char line [ 128 ]; /* or other suitable maximum line size */
- int firstline=1;
- while ( fgets ( line, sizeof line, file ) != NULL ) /* read a line */
- {
- fputs ( line, stdout ); /* write the line */
- sscanf(line,"%f %f %f %f",&x1,&y1,&x2,&y2);
-
- if (firstline)
- {
- ox1=x1;
- oy1=y1;
- ox2=x2;
- oy2=y2;
- firstline=0;
- }
- else if ( (x1==ox1) && (y1==oy1) && (x2==ox2) && (y2==oy2) ) /*polygon is closed here*/
- {
+ float x1, y1, x2, y2;
+ float ox1, oy1, ox2, oy2;
+ static const char filename[] = "file.txt";
+ FILE *file = fopen(filename, "r");
+ char line[128]; /* or other suitable maximum line size */
+ int firstline = 1;
+ while (fgets(line, sizeof line, file) != NULL) { /* read a line */
+ fputs(line, stdout); /* write the line */
+ sscanf(line, "%f %f %f %f", &x1, &y1, &x2, &y2);
+
+ if (firstline) {
+ ox1 = x1;
+ oy1 = y1;
+ ox2 = x2;
+ oy2 = y2;
+ firstline = 0;
+ } else if ((x1 == ox1) && (y1 == oy1) && (x2 == ox2) && (y2 == oy2)) { /*polygon is closed here */
- }
-
-
}
- fclose ( file );
- return 0;
+
+
+ }
+ fclose(file);
+ return 0;
}
#endif
#define DRAWXDOT_H
// code here
-#endif
\ No newline at end of file
+#endif
int add_filter_to_filters(tv_filters * filters, tv_filter * filter)
{
filters->filters =
- RALLOC(filters->filter_count + 1, filters->filters, tv_filter*);
+ RALLOC(filters->filter_count + 1, filters->filters, tv_filter *);
filters->filters[filters->filter_count] = filter;
filters->filter_count++;
return 1;
#define FILTER_H
#include "btree.h"
-typedef struct _tv_filters {
- tv_filter **filters;
- int filter_count;
-} tv_filters;
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ typedef struct _tv_filters {
+ tv_filter **filters;
+ int filter_count;
+ } tv_filters;
-int clear_filter(tv_filter * f);
-int init_filters(tv_filters * filters);
-int add_filter_to_filters(tv_filters * filters, tv_filter * filter);
-int clear_filters(tv_filters * filters);
-int union_filter(tv_filter * f1, tv_filter * f2);
-int intersect_filter(tv_filter * f1, tv_filter * f2);
+ int clear_filter(tv_filter * f);
+ int init_filters(tv_filters * filters);
+ int add_filter_to_filters(tv_filters * filters, tv_filter * filter);
+ int clear_filters(tv_filters * filters);
+ int union_filter(tv_filter * f1, tv_filter * f2);
+ int intersect_filter(tv_filter * f1, tv_filter * f2);
+#ifdef __cplusplus
+} /* end extern "C" */
+#endif
#endif
+/* $Id$Revision: */
/* vim:set shiftwidth=4 ts=8: */
/**********************************************************
#include "topview.h"
#include "topfisheyeview.h"
#include "gui/toolboxcallbacks.h"
+#include "arcball.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)
+
+ 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); // 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); // 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();
+ 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();
}
void drawRotatingAxis(void)
{
#ifdef UNUSED
- float x,y;
- float x1,y1,z1;
- float x2,y2,z2;
- float R1,R2;
+ float x, y;
+ float x1, y1, z1;
+ float x2, y2, z2;
+ float R1, R2;
#endif
- 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);
+ 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);
+ 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);
- glEnd();
- glColor4f(0,1,0,0.3);
- gluSphere(quadratic,AL,20,20);
- glLineWidth(1);
- glPopMatrix();
+ 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, AL, 20, 20);
+ glLineWidth(1);
+ glPopMatrix();
+
+ }
}
*/
int glupdatecamera(ViewInfo * view)
{
- if (view->active_camera==-1)
- glTranslatef(-view->panx,-view->pany,view->panz);
+ if (view->active_camera == -1)
+ glTranslatef(-view->panx, -view->pany, view->panz);
- /*toggle to active camera*/
- else
- {
- glMultMatrixf(view->arcball->Transform.M); /*arcball transformations , experimental*/
- glTranslatef(-view->cameras[view->active_camera]->targetx,-view->cameras[view->active_camera]->targety,0);
- }
+ /*toggle to active camera */
+ else {
+ glMultMatrixf(view->arcball->Transform.M); /*arcball transformations , experimental */
+ glTranslatef(-view->cameras[view->active_camera]->targetx,
+ -view->cameras[view->active_camera]->targety, 0);
+ }
- GetOGLPosRef(1, view->h - 5, &(view->clipX1), &(view->clipY1),
+ GetOGLPosRef(1, view->h - 5, &(view->clipX1), &(view->clipY1),
&(view->clipZ1));
GetOGLPosRef(view->w - 1, 1, &(view->clipX2), &(view->clipY2),
&(view->clipZ2));
- if (view->active_camera==-1)
- {
- glScalef(1/view->zoom*-1,1/view->zoom*-1,1/view->zoom*-1);
- }
- else
- {
- glScalef(1/view->cameras[view->active_camera]->r,1/view->cameras[view->active_camera]->r,1/view->cameras[view->active_camera]->r);
- }
+ if (view->active_camera == -1) {
+ glScalef(1 / view->zoom * -1, 1 / view->zoom * -1,
+ 1 / view->zoom * -1);
+ } else {
+ glScalef(1 / view->cameras[view->active_camera]->r,
+ 1 / view->cameras[view->active_camera]->r,
+ 1 / view->cameras[view->active_camera]->r);
+ }
- return 1;
+ return 1;
}
/*
*/
int glexpose_main(ViewInfo * view)
{
- static int doonce=0;
- if (!glupdatecamera(view))
+ static int doonce = 0;
+ if (!glupdatecamera(view))
return 0;
- if (view->activeGraph >= 0)
- {
- if(!doonce)
- {
- doonce=1;
- btnToolZoomFit_clicked(NULL,NULL);
- btnToolZoomFit_clicked(NULL,NULL);
- }
+ if (view->activeGraph >= 0) {
+ if (!doonce) {
+ doonce = 1;
+ btnToolZoomFit_clicked(NULL, NULL);
+ btnToolZoomFit_clicked(NULL, NULL);
}
+ }
- glexpose_grid(view);
+ glexpose_grid(view);
draw_fisheye_magnifier(view);
draw_magnifier(view);
glexpose_drawgraph(view);
draw_selection_box(view);
drawBorders(view);
-// drawRotatingTools();
-// draw_cube();
- drawRotatingAxis();
-// draw_stuff();
-// test_color_pallete();
+// drawRotatingTools();
+// draw_cube();
+ drawRotatingAxis();
+// draw_stuff();
+// test_color_pallete();
-// drawtestpoly();
- /*DEBUG*/
+// drawtestpoly();
+ /*DEBUG*/
/* if (view->mouse.mouse_mode == MM_PAN)
{
glBegin(GL_LINE_STRIP);
glEnd();
}*/
-
- /*DEBUG*/
-
- return 1;
+ /*DEBUG*/ return 1;
}
/*
*/
void drawtestpoly(void)
{
- glEnable(GL_TEXTURE_2D);
- glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
-// glTexEnvf(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE , GL_DECAL);
-// glBindTexture(GL_TEXTURE_2D,view->widgets->fontset->fonts[view->widgets->fontset->activefont]->texId);
- glBindTexture(GL_TEXTURE_2D,1);
- glColor4f(1,1,1,1);
- glBegin(GL_QUADS);
- glTexCoord2f(0.0,0.0);glVertex3f(0.0,0.0,0.0);
- glTexCoord2f(0.0,1.0);glVertex3f(0.0,256.0,0.0);
- glTexCoord2f(1.0,1.0);glVertex3f(256.0,256.0,0.0);
- glTexCoord2f(1.0,0.0);glVertex3f(256.0,0.0,0.0);
- glTexCoord2f(0.0,0.0);glVertex3f(0.0,0.0,0.0);
- glEnd();
- glDisable(GL_TEXTURE_2D);
+ glEnable(GL_TEXTURE_2D);
+ glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
+// glTexEnvf(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE , GL_DECAL);
+// glBindTexture(GL_TEXTURE_2D,view->widgets->fontset->fonts[view->widgets->fontset->activefont]->texId);
+ glBindTexture(GL_TEXTURE_2D, 1);
+ glColor4f(1, 1, 1, 1);
+ glBegin(GL_QUADS);
+ glTexCoord2f(0.0, 0.0);
+ glVertex3f(0.0, 0.0, 0.0);
+ glTexCoord2f(0.0, 1.0);
+ glVertex3f(0.0, 256.0, 0.0);
+ glTexCoord2f(1.0, 1.0);
+ glVertex3f(256.0, 256.0, 0.0);
+ glTexCoord2f(1.0, 0.0);
+ glVertex3f(256.0, 0.0, 0.0);
+ glTexCoord2f(0.0, 0.0);
+ glVertex3f(0.0, 0.0, 0.0);
+ glEnd();
+ glDisable(GL_TEXTURE_2D);
}
*/
int glexpose_drawgraph(ViewInfo * view)
{
-
- if (view->activeGraph > -1)
- {
-// if (GD_TopView(view->g[view->activeGraph]))
-// {
- if(!view->Topview->is_top_fisheye)
- drawTopViewGraph(view->g[view->activeGraph]); //view->Topview style dots and straight lines
- else
- {
- drawtopologicalfisheye(view->Topview);
- }
-
-// }
-// else
-// drawGraph(view->g[view->activeGraph]); //xdot based drawing functions
- glCompSetDraw(view->widgets);
- return 1;
+
+ if (view->activeGraph > -1) {
+// if (GD_TopView(view->g[view->activeGraph]))
+// {
+ if (!view->Topview->is_top_fisheye)
+ drawTopViewGraph(view->g[view->activeGraph]); //view->Topview style dots and straight lines
+ else {
+ drawtopologicalfisheye(view->Topview);
+ }
+
+// }
+// else
+// drawGraph(view->g[view->activeGraph]); //xdot based drawing functions
+ glCompSetDraw(view->widgets);
+ return 1;
}
- return 0;
+ return 0;
}
void drawRotatingTools(void)
{
- float x,y;
- float x1,y1,z1;
- float x2,y2,z2;
- float R1,R2;
- if ((view->mouse.mouse_mode == MM_ROTATE) && (view->active_camera >=0))
- {
- R1=25;
- R2=200;
- glCompDrawBegin();
- GetOGLPosRef(1, view->h - 5, &x1, &y1,&z1);
- GetOGLPosRef(view->w - 1, 1, &x2,&y2,&z2);
- x=(x2-x1)/(float)2.0;
- y=(y2-y1)/(float)2.0;
- glTranslatef(x,y,0);
- if ((view->mouse.rotate_axis==MOUSE_ROTATE_X) || (view->mouse.rotate_axis==MOUSE_ROTATE_XY))
- {
- glLineWidth(2);
- glColor4f(0,1,0,0.5);
- }
- else
- {
- glLineWidth(1);
- glColor4f(1,0,0,0.5);
- }
- drawEllipse(R1,R2,90,270);
- if ((view->mouse.rotate_axis==MOUSE_ROTATE_Y) || (view->mouse.rotate_axis==MOUSE_ROTATE_XY))
- {
- glLineWidth(2);
- glColor4f(0,1,0,0.5);
- }
- else
- {
- glLineWidth(1);
- glColor4f(1,0,0,0.5);
- }
- drawEllipse(R2, R1,0,180);
- if (view->mouse.rotate_axis==MOUSE_ROTATE_Z)
- {
- glLineWidth(2);
- glColor4f(0,1,0,0.5);
- }
- else
- {
- glLineWidth(1);
- glColor4f(1,0,0,0.5);
- }
-
- drawEllipse(R2, R2,0,360);
- glCompDrawEnd();
+ float x, y;
+ float x1, y1, z1;
+ float x2, y2, z2;
+ float R1, R2;
+ if ((view->mouse.mouse_mode == MM_ROTATE)
+ && (view->active_camera >= 0)) {
+ R1 = 25;
+ R2 = 200;
+ glCompDrawBegin();
+ GetOGLPosRef(1, view->h - 5, &x1, &y1, &z1);
+ GetOGLPosRef(view->w - 1, 1, &x2, &y2, &z2);
+ x = (x2 - x1) / (float) 2.0;
+ y = (y2 - y1) / (float) 2.0;
+ glTranslatef(x, y, 0);
+ if ((view->mouse.rotate_axis == MOUSE_ROTATE_X)
+ || (view->mouse.rotate_axis == MOUSE_ROTATE_XY)) {
+ glLineWidth(2);
+ glColor4f(0, 1, 0, 0.5);
+ } else {
+ glLineWidth(1);
+ glColor4f(1, 0, 0, 0.5);
+ }
+ drawEllipse(R1, R2, 90, 270);
+ if ((view->mouse.rotate_axis == MOUSE_ROTATE_Y)
+ || (view->mouse.rotate_axis == MOUSE_ROTATE_XY)) {
+ glLineWidth(2);
+ glColor4f(0, 1, 0, 0.5);
+ } else {
+ glLineWidth(1);
+ glColor4f(1, 0, 0, 0.5);
+ }
+ drawEllipse(R2, R1, 0, 180);
+ if (view->mouse.rotate_axis == MOUSE_ROTATE_Z) {
+ glLineWidth(2);
+ glColor4f(0, 1, 0, 0.5);
+ } else {
+ glLineWidth(1);
+ glColor4f(1, 0, 0, 0.5);
}
-}
+ drawEllipse(R2, R2, 0, 360);
+ glCompDrawEnd();
+ }
+}
+/* $Id$Revision: */
/* vim:set shiftwidth=4 ts=8: */
/**********************************************************
#define GLEXPOSE_H
#include "viewport.h"
-int glupdatecamera(ViewInfo * v);
-int glexpose_main(ViewInfo * v);
-void glexpose_grid(ViewInfo * v);
-int glexpose_drawgraph(ViewInfo * view);
-void drawRotatingTools(void);
-void drawtestpoly(void);
-void draw_cube(void);
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ int glupdatecamera(ViewInfo * v);
+ int glexpose_main(ViewInfo * v);
+ void glexpose_grid(ViewInfo * v);
+ int glexpose_drawgraph(ViewInfo * view);
+ void drawRotatingTools(void);
+ void drawtestpoly(void);
+ void draw_cube(void);
+#ifdef __cplusplus
+} /* end extern "C" */
+#endif
#endif
+/* $Id$Revision: */
/* vim:set shiftwidth=4 ts=8: */
/**********************************************************
gboolean redraw = FALSE;
-void glmotion_main(ViewInfo * v,GdkEventMotion * event,GtkWidget * widget)
+void glmotion_main(ViewInfo * v, GdkEventMotion * event,
+ GtkWidget * widget)
{
-
- redraw = FALSE;
- view->FontSizeConst=GetOGLDistance(14);
- /*panning */
- if ((event->state & GDK_BUTTON1_MASK)&& (v->mouse.mouse_mode == MM_PAN))
- glmotion_pan(v);
-
- /*rotating, only in 3d v */
- if ((v->active_camera >=0)&&(v->mouse.mouse_mode == MM_ROTATE))
- glmotion_rotate(v);
-
- /*zooming */
- if ((event->state & GDK_BUTTON1_MASK)&& (v->mouse.mouse_mode == MM_ZOOM))
- glmotion_zoom(v);
-
- /*selection rect */
+
+ redraw = FALSE;
+ view->FontSizeConst = GetOGLDistance(14);
+ /*panning */
+ if ((event->state & GDK_BUTTON1_MASK)
+ && (v->mouse.mouse_mode == MM_PAN))
+ glmotion_pan(v);
+
+ /*rotating, only in 3d v */
+ if ((v->active_camera >= 0) && (v->mouse.mouse_mode == MM_ROTATE))
+ glmotion_rotate(v);
+
+ /*zooming */
+ if ((event->state & GDK_BUTTON1_MASK)
+ && (v->mouse.mouse_mode == MM_ZOOM))
+ glmotion_zoom(v);
+
+ /*selection rect */
if ((event->state & GDK_BUTTON1_MASK)
&& ((v->mouse.mouse_mode == MM_RECTANGULAR_SELECT)
- || (v->mouse.mouse_mode == 5)))
- {
- GetFixedOGLPos((int) event->x, (int)event->y, v->GLDepth, &(v->GLx2),
- &(v->GLy2), &(v->GLz2));
- redraw = TRUE;
+ || (v->mouse.mouse_mode == 5))) {
+ GetFixedOGLPos((int) event->x, (int) event->y, v->GLDepth,
+ &(v->GLx2), &(v->GLy2), &(v->GLz2));
+ redraw = TRUE;
}
if ((event->state & GDK_BUTTON1_MASK)
&& (v->mouse.mouse_mode == MM_MOVE)) {
- GetFixedOGLPos((int)event->x, (int) event->y, v->GLDepth, &(v->GLx2),
- &(v->GLy2), &(v->GLz2));
+ GetFixedOGLPos((int) event->x, (int) event->y, v->GLDepth,
+ &(v->GLx2), &(v->GLy2), &(v->GLz2));
redraw = TRUE;
}
if ((event->state & GDK_BUTTON1_MASK)
&& ((v->mouse.mouse_mode == MM_MAGNIFIER)
- || (v->mouse.mouse_mode == MM_FISHEYE_MAGNIFIER)))
- {
- v->mouse.mouse_X = (float)event->x;
- v->mouse.mouse_Y = (float)event->y;
- redraw = TRUE;
+ || (v->mouse.mouse_mode == MM_FISHEYE_MAGNIFIER))) {
+ v->mouse.mouse_X = (float) event->x;
+ v->mouse.mouse_Y = (float) event->y;
+ redraw = TRUE;
}
if (redraw)
}
void glmotion_zoom_inc(int zoomin)
{
- float inc_value;
- inc_value=(float)(view->Topview->fitin_zoom * MAX_ZOOM*-1-view->Topview->fitin_zoom *MIN_ZOOM*-1)/ZOOM_STEPS;
- if (zoomin) /*zooming in , zoom value should be decreased*/
- graph_zoom(view->zoom-view->zoom*0.25 );
- else
- graph_zoom(view->zoom+view->zoom*0.25); /*zoom out*/
- glexpose();
+ float inc_value;
+ inc_value =
+ (float) (view->Topview->fitin_zoom * MAX_ZOOM * -1 -
+ view->Topview->fitin_zoom * MIN_ZOOM * -1) / ZOOM_STEPS;
+ if (zoomin) /*zooming in , zoom value should be decreased */
+ graph_zoom(view->zoom - view->zoom * 0.25);
+ else
+ graph_zoom(view->zoom + view->zoom * 0.25); /*zoom out */
+ glexpose();
}
+
/*real zoom in out is done here, all other functions send this one what they desire, it is not guranteed,*/
void graph_zoom(float real_zoom)
{
- float old_zoom;
-
- if (view->active_camera == -1)
- old_zoom = view->zoom;
- else
- old_zoom = view->cameras[view->active_camera]->r;
-
- if (real_zoom < view->Topview->fitin_zoom * MAX_ZOOM)
- real_zoom = (float) view->Topview->fitin_zoom * MAX_ZOOM;
- if (real_zoom > view->Topview->fitin_zoom *MIN_ZOOM)
- real_zoom = (float) view->Topview->fitin_zoom *MIN_ZOOM;
- if(view->active_camera==-1)
- view->zoom = real_zoom;
- else
- view->cameras[view->active_camera]->r=real_zoom*-1;
- /*adjust pan values*/
- view->panx = old_zoom * view->panx / real_zoom;
- view->pany = old_zoom * view->pany / real_zoom;
-
- /*set label to new zoom value */
+ float old_zoom;
+
+ if (view->active_camera == -1)
+ old_zoom = view->zoom;
+ else
+ old_zoom = view->cameras[view->active_camera]->r;
+
+ if (real_zoom < view->Topview->fitin_zoom * MAX_ZOOM)
+ real_zoom = (float) view->Topview->fitin_zoom * MAX_ZOOM;
+ if (real_zoom > view->Topview->fitin_zoom * MIN_ZOOM)
+ real_zoom = (float) view->Topview->fitin_zoom * MIN_ZOOM;
+ if (view->active_camera == -1)
+ view->zoom = real_zoom;
+ else
+ view->cameras[view->active_camera]->r = real_zoom * -1;
+ /*adjust pan values */
+ view->panx = old_zoom * view->panx / real_zoom;
+ view->pany = old_zoom * view->pany / real_zoom;
+
+ /*set label to new zoom value */
#ifdef UNUSED
- xx = ((float) 100.0 - (float) 1.0) * (v->zoom -
- (float) MIN_ZOOM) / ((float) MAX_ZOOM - (float) MIN_ZOOM) + (float) 1.0;
- sprintf(buf, "%i", (int) xx);
+ xx = ((float) 100.0 - (float) 1.0) * (v->zoom -
+ (float) MIN_ZOOM) /
+ ((float) MAX_ZOOM - (float) MIN_ZOOM) + (float) 1.0;
+ sprintf(buf, "%i", (int) xx);
#endif
/* if (v->Topview->customptr)
glCompLabelSetText((glCompLabel *) v->Topview->customptr, buf);*/
void glmotion_zoom(ViewInfo * v)
{
- float real_zoom;
- if (view->active_camera == -1) {
- real_zoom = view->zoom + view->mouse.dx / 10 * (view->zoom * -1 / 20);
- }
- else
- {
- real_zoom =
- (view->cameras[view->active_camera]->r +
- view->mouse.dx / 10 * (view->cameras[view->active_camera]->r / 20)) *
- -1;
- }
- graph_zoom(real_zoom);
+ float real_zoom;
+ if (view->active_camera == -1) {
+ real_zoom =
+ view->zoom + view->mouse.dx / 10 * (view->zoom * -1 / 20);
+ } else {
+ real_zoom =
+ (view->cameras[view->active_camera]->r +
+ view->mouse.dx / 10 * (view->cameras[view->active_camera]->r /
+ 20)) * -1;
+ }
+ graph_zoom(real_zoom);
}
+
void glmotion_pan(ViewInfo * v)
{
- float gldx,gldy;
- if(v->active_camera ==-1)
- {
- gldx=GetOGLDistance((int)v->mouse.dx)/v->zoom*-1;
- gldy=GetOGLDistance((int)v->mouse.dy)/v->zoom*-1;
- v->panx=v->panx-gldx;
- v->pany=v->pany+gldy;
- }
- else
- {
- gldx=GetOGLDistance((int)v->mouse.dx)/v->cameras[v->active_camera]->r;
- gldy=GetOGLDistance((int)v->mouse.dy)/v->cameras[v->active_camera]->r;
- v->cameras[v->active_camera]->x-=gldx;
- v->cameras[v->active_camera]->y-=gldy;
- v->cameras[v->active_camera]->targetx-=gldx;
- v->cameras[v->active_camera]->targety+=gldy;
- }
-
- redraw = TRUE;
+ float gldx, gldy;
+ if (v->active_camera == -1) {
+ gldx = GetOGLDistance((int) v->mouse.dx) / v->zoom * -1;
+ gldy = GetOGLDistance((int) v->mouse.dy) / v->zoom * -1;
+ v->panx = v->panx - gldx;
+ v->pany = v->pany + gldy;
+ } else {
+ gldx =
+ GetOGLDistance((int) v->mouse.dx) /
+ v->cameras[v->active_camera]->r;
+ gldy =
+ GetOGLDistance((int) v->mouse.dy) /
+ v->cameras[v->active_camera]->r;
+ v->cameras[v->active_camera]->x -= gldx;
+ v->cameras[v->active_camera]->y -= gldy;
+ v->cameras[v->active_camera]->targetx -= gldx;
+ v->cameras[v->active_camera]->targety += gldy;
+ }
+
+ redraw = TRUE;
}
-void glmotion_adjust_pan(ViewInfo* v,float panx,float pany)
+void glmotion_adjust_pan(ViewInfo * v, float panx, float pany)
{
- float gldx,gldy;
- if(v->active_camera ==-1)
- {
- gldx=GetOGLDistance((int)panx)/v->zoom*-1;
- gldy=GetOGLDistance((int)pany)/v->zoom*-1;
- v->panx=v->panx-gldx;
- v->pany=v->pany+gldy;
- }
- else
- {
- gldx=GetOGLDistance((int)panx)/v->cameras[v->active_camera]->r;
- gldy=GetOGLDistance((int)pany)/v->cameras[v->active_camera]->r;
- v->cameras[v->active_camera]->x-=gldx;
- v->cameras[v->active_camera]->y-=gldy;
- v->cameras[v->active_camera]->targetx-=gldx;
- v->cameras[v->active_camera]->targety+=gldy;
- }
-
- redraw = TRUE;
+ float gldx, gldy;
+ if (v->active_camera == -1) {
+ gldx = GetOGLDistance((int) panx) / v->zoom * -1;
+ gldy = GetOGLDistance((int) pany) / v->zoom * -1;
+ v->panx = v->panx - gldx;
+ v->pany = v->pany + gldy;
+ } else {
+ gldx =
+ GetOGLDistance((int) panx) / v->cameras[v->active_camera]->r;
+ gldy =
+ GetOGLDistance((int) pany) / v->cameras[v->active_camera]->r;
+ v->cameras[v->active_camera]->x -= gldx;
+ v->cameras[v->active_camera]->y -= gldy;
+ v->cameras[v->active_camera]->targetx -= gldx;
+ v->cameras[v->active_camera]->targety += gldy;
+ }
+
+ redraw = TRUE;
}
+
#ifdef UNUSED
static float mod_angle(float angle)
{
-// if (angle > 360)
+// if (angle > 360)
}
#endif
+/* $Id$Revision: */
/* vim:set shiftwidth=4 ts=8: */
/**********************************************************
#include "viewport.h"
-void glmotion_main(ViewInfo * v,GdkEventMotion * event,GtkWidget * widget);
-void glmotion_zoom(ViewInfo * v);
-void glmotion_pan(ViewInfo * v);
-void glmotion_rotate(ViewInfo * v);
-void glmotion_adjust_pan(ViewInfo* v,float panx,float pany);
-void graph_zoom(float real_zoom);
-void glmotion_zoom_inc(int zoomin);
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ void glmotion_main(ViewInfo * v, GdkEventMotion * event,
+ GtkWidget * widget);
+ void glmotion_zoom(ViewInfo * v);
+ void glmotion_pan(ViewInfo * v);
+ void glmotion_rotate(ViewInfo * v);
+ void glmotion_adjust_pan(ViewInfo * v, float panx, float pany);
+ void graph_zoom(float real_zoom);
+ void glmotion_zoom_inc(int zoomin);
+#ifdef __cplusplus
+} /* end extern "C" */
+#endif
#endif
/*mouse mode mapping funvtion from gtk to glcomp*/
static glMouseButtonType getGlCompMouseType(int n)
{
- switch (n)
- {
- case 1:
- return glMouseLeftButton;
- case 3:
- return glMouseRightButton;
- }
+ switch (n) {
+ case 1:
+ return glMouseLeftButton;
+ case 3:
+ default:
+ return glMouseRightButton;
+ }
}
GLfloat lmodel_ambient[] = { 0.2f, 0.2f, 0.2f, 1.0f };
GLfloat local_view[] = { 0.0 };
- static char *smyrna_font;
+ /* static char *smyrna_font; */
/*** OpenGL BEGIN ***/
return;
glClearColor(view->bgColor.R, view->bgColor.G, view->bgColor.B, view->bgColor.A); //background color
- glClearDepth(1.0);
- glClear(GL_COLOR_BUFFER_BIT);
+ glClearDepth(1.0);
+ glClear(GL_COLOR_BUFFER_BIT);
glLightfv(GL_LIGHT0, GL_AMBIENT, ambient);
static gboolean configure_event(GtkWidget * widget,
GdkEventConfigure * event, gpointer data)
{
- /* static int doonce=0; */
- int vPort[4];
+ /* static int doonce=0; */
+ int vPort[4];
float aspect;
GdkGLContext *glcontext = gtk_widget_get_gl_context(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);
+ if (view->widgets)
+ glcompsetUpdateBorder(view->widgets, view->w, view->h);
/*** OpenGL BEGIN ***/
/* 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 (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;
/*** OpenGL END ***/
- return TRUE;
+ return TRUE;
}
/*
GdkGLDrawable *gldrawable = gtk_widget_get_gl_drawable(widget);
/*** OpenGL BEGIN ***/
- if (!gdk_gl_drawable_gl_begin(gldrawable, glcontext))
- return FALSE;
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
- glLoadIdentity();
- glexpose_main(view); //draw all stuff
+ if (!gdk_gl_drawable_gl_begin(gldrawable, glcontext))
+ return FALSE;
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+ glLoadIdentity();
+ glexpose_main(view); //draw all stuff
/* Swap buffers */
- if (gdk_gl_drawable_is_double_buffered(gldrawable))
- gdk_gl_drawable_swap_buffers(gldrawable);
- else
- glFlush();
- gdk_gl_drawable_gl_end(gldrawable);
+ if (gdk_gl_drawable_is_double_buffered(gldrawable))
+ gdk_gl_drawable_swap_buffers(gldrawable);
+ else
+ glFlush();
+ gdk_gl_drawable_gl_end(gldrawable);
/*** OpenGL END ***/
- if (view->initFile)
- {
- view->initFile=0;
- if (view->activeGraph == 0)
- close_graph(view,0);
- add_graph_to_viewport_from_file(view->initFileName);
- }
- return TRUE;
+ if (view->initFile) {
+ view->initFile = 0;
+ if (view->activeGraph == 0)
+ close_graph(view, 0);
+ add_graph_to_viewport_from_file(view->initFileName);
+ }
+ return TRUE;
}
/*
{
begin_x = (float) event->x;
begin_y = (float) event->y;
- view->widgets->common.functions.mousedown(view->widgets,(GLfloat)event->x,(GLfloat)event->y,getGlCompMouseType(event->button));
+ view->widgets->common.functions.mousedown(view->widgets,
+ (GLfloat) event->x,
+ (GLfloat) event->y,
+ getGlCompMouseType(event->
+ button));
+
+ if ((event->button == 1) || (event->button == 3)) {
+ GetOGLPosRef((int) begin_x, (int) begin_y, &(view->GLx),
+ &(view->GLy), &(view->GLz));
+ view->Selection.X = view->GLx;
+ view->Selection.Y = view->GLy;
- if ((event->button == 1) || (event->button == 3))
- {
- GetOGLPosRef ((int) begin_x, (int) begin_y, &(view->GLx), &(view->GLy),&(view->GLz));
- view->Selection.X = view->GLx;
- view->Selection.Y = view->GLy;
+ }
- }
-
- if (event->button == 3) //right click
- {
- view->mouse.button = rightmousebutton;
- expose_event(view->drawing_area, NULL, NULL);
+ if (event->button == 3) //right click
+ {
+ view->mouse.button = rightmousebutton;
+ expose_event(view->drawing_area, NULL, NULL);
- }
+ }
if (event->button == 1) //left click
{
- view->prevpany = view->pany;
- view->mouse.mouse_down = 1;
- view->mouse.button = leftmousebutton;
- if (view->mouse.mouse_mode == MM_SINGLE_SELECT) //single select
- {
- view->Selection.Active = 1;
- view->Selection.Type = 0;
- view->Selection.AlreadySelected = 0;
- expose_event(view->drawing_area, NULL, NULL);
- }
+ view->prevpany = view->pany;
+ view->mouse.mouse_down = 1;
+ view->mouse.button = leftmousebutton;
+ if (view->mouse.mouse_mode == MM_SINGLE_SELECT) //single select
+ {
+ view->Selection.Active = 1;
+ view->Selection.Type = 0;
+ view->Selection.AlreadySelected = 0;
+ expose_event(view->drawing_area, NULL, NULL);
+ }
}
- expose_event(view->drawing_area, NULL, NULL);
+ expose_event(view->drawing_area, NULL, NULL);
return FALSE;
}
static gboolean button_release_event(GtkWidget * widget,
GdkEventButton * event, gpointer data)
{
- view->FontSizeConst=GetOGLDistance(14);
- view->arcball->isDragging=0;
- view->widgets->common.functions.mouseup(view->widgets,(GLfloat)event->x,(GLfloat)event->y,getGlCompMouseType(event->button));
+ view->FontSizeConst = GetOGLDistance(14);
+ view->arcball->isDragging = 0;
+ view->widgets->common.functions.mouseup(view->widgets,
+ (GLfloat) event->x,
+ (GLfloat) event->y,
+ getGlCompMouseType(event->
+ button));
- if (event->button == 1) //left click release
+ if (event->button == 1) //left click release
{
- view->mouse.mouse_down = 0;
- if ((view->mouse.mouse_mode == MM_RECTANGULAR_SELECT)
- || (view->mouse.mouse_mode == MM_RECTANGULAR_X_SELECT))
- {
- if (view->GLx <= view->GLx2)
- view->Selection.X = view->GLx;
- else
- view->Selection.X = view->GLx2;
- if (view->GLy <= view->GLy2)
- view->Selection.Y = view->GLy;
- else
- view->Selection.Y = view->GLy2;
- view->Selection.W = view->GLx2 - view->GLx;
- if (view->Selection.W < 0)
- view->Selection.W = view->Selection.W * -1;
- view->Selection.H = view->GLy2 - view->GLy;
- if (view->Selection.H < 0)
- view->Selection.H = view->Selection.H * -1;
- if (view->mouse.mouse_mode == 4)
- view->Selection.Type = 1;
- else
- view->Selection.Type = 2;
- view->Selection.Active = 1;
- expose_event(view->drawing_area, NULL, NULL);
- }
-
- if (view->mouse.mouse_mode == MM_MOVE)
- move_TVnodes();
-
- if ((view->mouse.mouse_mode == MM_FISHEYE_MAGNIFIER) || (view->mouse.mouse_mode == MM_MAGNIFIER)) //fisheye mag mouse release, stop distortion
- {
- originate_distorded_coordinates(view->Topview);
- expose_event(view->drawing_area, NULL, NULL);
- }
- if (view->mouse.mouse_mode==MM_PAN)
- expose_event(view->drawing_area, NULL, NULL);
+ view->mouse.mouse_down = 0;
+ if ((view->mouse.mouse_mode == MM_RECTANGULAR_SELECT)
+ || (view->mouse.mouse_mode == MM_RECTANGULAR_X_SELECT)) {
+ if (view->GLx <= view->GLx2)
+ view->Selection.X = view->GLx;
+ else
+ view->Selection.X = view->GLx2;
+ if (view->GLy <= view->GLy2)
+ view->Selection.Y = view->GLy;
+ else
+ view->Selection.Y = view->GLy2;
+ view->Selection.W = view->GLx2 - view->GLx;
+ if (view->Selection.W < 0)
+ view->Selection.W = view->Selection.W * -1;
+ view->Selection.H = view->GLy2 - view->GLy;
+ if (view->Selection.H < 0)
+ view->Selection.H = view->Selection.H * -1;
+ if (view->mouse.mouse_mode == 4)
+ view->Selection.Type = 1;
+ else
+ view->Selection.Type = 2;
+ view->Selection.Active = 1;
+ expose_event(view->drawing_area, NULL, NULL);
}
- if (event->button == 3) //right click
+
+ if (view->mouse.mouse_mode == MM_MOVE)
+ move_TVnodes();
+
+ if ((view->mouse.mouse_mode == MM_FISHEYE_MAGNIFIER) || (view->mouse.mouse_mode == MM_MAGNIFIER)) //fisheye mag mouse release, stop distortion
{
- to3D(view->mouse.mouse_X,view->mouse.mouse_Y, &view->mouse.GLX, &view->mouse.GLY,&view->mouse.GLZ);
- pick_node_from_coords(view->mouse.GLX,view->mouse.GLY,view->mouse.GLZ);
-
- if (view->activeGraph >= 0)
- {
- if(view->Topview->is_top_fisheye)
- {
- GetFixedOGLPoslocal((int) event->x, (int) event->y, &(view->GLx2),&(view->GLy2), &(view->GLz2));
- changetopfishfocus(view->Topview, &view->GLx2, &view->GLy2, 0,1);
- }
- }
- expose_event(view->drawing_area, NULL, NULL);
+ originate_distorded_coordinates(view->Topview);
+ expose_event(view->drawing_area, NULL, NULL);
+ }
+ if (view->mouse.mouse_mode == MM_PAN)
+ expose_event(view->drawing_area, NULL, NULL);
+ }
+ if (event->button == 3) //right click
+ {
+ to3D(view->mouse.mouse_X, view->mouse.mouse_Y, &view->mouse.GLX,
+ &view->mouse.GLY, &view->mouse.GLZ);
+ pick_node_from_coords(view->mouse.GLX, view->mouse.GLY,
+ view->mouse.GLZ);
+
+ if (view->activeGraph >= 0) {
+ if (view->Topview->is_top_fisheye) {
+ GetFixedOGLPoslocal((int) event->x, (int) event->y,
+ &(view->GLx2), &(view->GLy2),
+ &(view->GLz2));
+ changetopfishfocus(view->Topview, &view->GLx2, &view->GLy2,
+ 0, 1);
+ }
}
+ expose_event(view->drawing_area, NULL, NULL);
+ }
dx = 0.0;
dy = 0.0;
static gboolean
scroll_event(GtkWidget * widget, GdkEventScroll * event, gpointer data)
{
- gdouble seconds;
+ gdouble seconds;
+
+ seconds = g_timer_elapsed(view->timer2, NULL);
+ if (seconds > 0.005) {
+ g_timer_stop(view->timer2);
+ if (event->direction == 0)
+ view->mouse.dx = -30;
+ if (event->direction == 1)
+ view->mouse.dx = +30;
+ glmotion_zoom(view);
+ glexpose();
+ g_timer_start(view->timer2);
- seconds=g_timer_elapsed(view->timer2,NULL);
- if (seconds > 0.005)
- {
- g_timer_stop(view->timer2);
- if(event->direction==0)
- view->mouse.dx=-30;
- if(event->direction==1)
- view->mouse.dx=+30;
- glmotion_zoom(view);
- glexpose();
- g_timer_start(view->timer2);
-
- }
- return TRUE;
+ }
+ return TRUE;
}
/*
float y = (float) event->y;
gboolean redraw = FALSE;
- view->widgets->common.functions.mouseover(view->widgets,(GLfloat)x,(GLfloat)y);
+ view->widgets->common.functions.mouseover(view->widgets, (GLfloat) x,
+ (GLfloat) y);
-
- dx = x - begin_x;
+
+ dx = x - begin_x;
dy = y - begin_y;
view->mouse.dx = dx;
view->mouse.dy = dy;
- view->mouse.mouse_X = x;
- view->mouse.mouse_Y = y;
+ view->mouse.mouse_X = x;
+ view->mouse.mouse_Y = y;
- /*panning */
+ /*panning */
if ((event->state & GDK_BUTTON1_MASK)
- && (view->mouse.mouse_mode == MM_PAN))
- {
- glmotion_main(view, event, widget);
- redraw = TRUE;
+ && (view->mouse.mouse_mode == MM_PAN)) {
+ glmotion_main(view, event, widget);
+ redraw = TRUE;
}
/*rotating, only in 3d view */
if ((view->active_camera >= 0) && (view->mouse.mouse_mode == MM_ROTATE)
&& (event->state & GDK_BUTTON1_MASK)) {
- view->arcball->MousePt.s.X = (GLfloat)x;
- view->arcball->MousePt.s.Y = (GLfloat)y;
+ view->arcball->MousePt.s.X = (GLfloat) x;
+ view->arcball->MousePt.s.Y = (GLfloat) y;
- if (!view->arcball->isDragging)
- {
- arcmouseClick(view);
- view->arcball->isDragging=1;
+ if (!view->arcball->isDragging) {
+ arcmouseClick(view);
+ view->arcball->isDragging = 1;
- }
- else
- {
- arcmouseDrag(view);
+ } else {
+ arcmouseDrag(view);
- }
+ }
-// glmotion_main(view, event, widget);
- redraw = TRUE;
+// glmotion_main(view, event, widget);
+ redraw = TRUE;
}
/*zooming */
if ((event->state & GDK_BUTTON1_MASK)
- && (view->mouse.mouse_mode == MM_ZOOM))
- {
+ && (view->mouse.mouse_mode == MM_ZOOM)) {
- glmotion_main(view, event, widget);
- redraw = TRUE;
- }
+ glmotion_main(view, event, widget);
+ redraw = TRUE;
+ }
/*selection rect */
if ((event->state & GDK_BUTTON1_MASK)
*/
void switch_Mouse(GtkMenuItem * menuitem, int mouse_mode)
{
- switch (mouse_mode)
- {
+ switch (mouse_mode) {
- case -1:
- change_cursor(GDK_TOP_LEFT_ARROW);
- break;
- case 0:
- change_cursor(GDK_HAND2);
- break;
- case 1:
- change_cursor(GDK_SIZING);
- break;
- case 3:
- change_cursor(GDK_CROSS);
- break;
- case 4:
- change_cursor(GDK_TCROSS);
- break;
- case 5:
- change_cursor(GDK_CROSSHAIR);
- break;
- case 10:
- change_cursor(GDK_FLEUR);
- break;
- case MM_ROTATE:
- change_cursor(GDK_EXCHANGE);
- break;
- default:
- break;
- };
- view->mouse.mouse_mode = mouse_mode;
+ case -1:
+ change_cursor(GDK_TOP_LEFT_ARROW);
+ break;
+ case 0:
+ change_cursor(GDK_HAND2);
+ break;
+ case 1:
+ change_cursor(GDK_SIZING);
+ break;
+ case 3:
+ change_cursor(GDK_CROSS);
+ break;
+ case 4:
+ change_cursor(GDK_TCROSS);
+ break;
+ case 5:
+ change_cursor(GDK_CROSSHAIR);
+ break;
+ case 10:
+ change_cursor(GDK_FLEUR);
+ break;
+ case MM_ROTATE:
+ change_cursor(GDK_EXCHANGE);
+ break;
+ default:
+ break;
+ };
+ view->mouse.mouse_mode = mouse_mode;
}
gtk_widget_add_events(view->drawing_area,
// GDK_BUTTON_MOTION_MASK = 1 << 4,
GDK_BUTTON_MOTION_MASK |
- GDK_POINTER_MOTION_MASK|
- GDK_BUTTON_PRESS_MASK |GDK_KEY_PRESS |
+ GDK_POINTER_MOTION_MASK |
+ GDK_BUTTON_PRESS_MASK | GDK_KEY_PRESS |
GDK_BUTTON_RELEASE_MASK |
- GDK_SCROLL |
- GDK_VISIBILITY_NOTIFY_MASK);
+ GDK_SCROLL | GDK_VISIBILITY_NOTIFY_MASK);
g_signal_connect_after(G_OBJECT(view->drawing_area), "realize",
G_CALLBACK(realize), NULL);
g_signal_connect(G_OBJECT(view->drawing_area), "scroll_event",
G_CALLBACK(scroll_event), NULL);
- g_signal_connect(G_OBJECT(view->drawing_area), "motion_notify_event",
+ g_signal_connect(G_OBJECT(view->drawing_area), "motion_notify_event",
G_CALLBACK(motion_notify_event), NULL);
#include <gtk/gtkgl.h>
#include <gdk/gdkcursor.h>
-void examine_gl_config_attrib(GdkGLConfig * glconfig);
-void print_gl_config_attrib(GdkGLConfig * glconfig,
- const gchar * attrib_str, int attrib,
- gboolean is_boolean);
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ void examine_gl_config_attrib(GdkGLConfig * glconfig);
+ void print_gl_config_attrib(GdkGLConfig * glconfig,
+ const gchar * attrib_str, int attrib,
+ gboolean is_boolean);
/* static void realize (GtkWidget *widget,gpointer data); */
/* static gboolean configure_event (GtkWidget *widget,GdkEventConfigure *event, gpointer data); */
-gboolean expose_event(GtkWidget * widget, GdkEventExpose * event,
- gpointer data);
+ gboolean expose_event(GtkWidget * widget, GdkEventExpose * event,
+ gpointer data);
/* static gboolean button_press_event (GtkWidget *widget,GdkEventButton *event,gpointer data); */
/* static gboolean button_release_event (GtkWidget *widget,GdkEventButton *event,gpointer data); */
/* static gboolean motion_notify_event (GtkWidget *widget,GdkEventMotion *event,gpointer data); */
/* static gboolean key_press_event (GtkWidget *widget, GdkEventKey *event,gpointer data); */
-void switch_Mouse(GtkMenuItem * menuitem, int mouse_mode);
+ void switch_Mouse(GtkMenuItem * menuitem, int mouse_mode);
/* static gboolean button_press_event_popup_menu (GtkWidget *widget,GdkEventButton *event,gpointer data); */
-extern GdkGLConfig *configure_gl(void);
-void create_window(GdkGLConfig * glconfig, GtkWidget * vbox);
+ extern GdkGLConfig *configure_gl(void);
+ void create_window(GdkGLConfig * glconfig, GtkWidget * vbox);
+
+#ifdef __cplusplus
+} /* end extern "C" */
+#endif
#endif
{
int ind = 0;
int found = 0;
- for (; ind < view->Topview->picked_edge_count; ind++)
- {
- if ((view->Topview->picked_edges[ind] == e) && (!found))
- found = 1;
- if ((found) && (ind < (view->Topview->picked_edge_count - 1)))
- {
- view->Topview->picked_edges[ind] = view->Topview->picked_edges[ind + 1];
- }
+ for (; ind < view->Topview->picked_edge_count; ind++) {
+ if ((view->Topview->picked_edges[ind] == e) && (!found))
+ found = 1;
+ if ((found) && (ind < (view->Topview->picked_edge_count - 1))) {
+ view->Topview->picked_edges[ind] =
+ view->Topview->picked_edges[ind + 1];
+ }
}
- if (found)
- {
- view->Topview->picked_edge_count--;
- view->Topview->picked_edges =realloc(view->Topview->picked_edges,sizeof(topview_edge *) *view->Topview->picked_edge_count);
- return 1;
+ if (found) {
+ view->Topview->picked_edge_count--;
+ view->Topview->picked_edges =
+ realloc(view->Topview->picked_edges,
+ sizeof(topview_edge *) *
+ view->Topview->picked_edge_count);
+ return 1;
}
return 0;
}
static int add_edge_to_pick_list(topview_edge * e)
{
view->Topview->picked_edge_count++;
- view->Topview->picked_edges =realloc(view->Topview->picked_edges,sizeof(topview_edge *) * view->Topview->picked_edge_count);
+ view->Topview->picked_edges =
+ realloc(view->Topview->picked_edges,
+ sizeof(topview_edge *) * view->Topview->picked_edge_count);
view->Topview->picked_edges[view->Topview->picked_edge_count - 1] = e;
return 1;
}
return 0;
}
-void pick_node_from_coords(float x,float y,float z)
+void pick_node_from_coords(float x, float y, float z)
{
- topview_node* n;
- topview_node* sn; /*selected node , closest node*/
- topview_edge* e;
- topview_edge* se;/*selected edge , closest one*/
- GLfloat closest_dif = 100000000;
- GLfloat closest_dif2 = 100000000;
- float a, b,c;
- double d;
- int ind;
- sn=(topview_node*)0;
- se=(topview_edge*)0;
-
- for (ind = 0; ind < view->Topview->Nodecount; ind++)
- {
- n = &view->Topview->Nodes[ind];
- if (!n->data.Visible)
- continue;
-
- a = ABS(n->distorted_x - view->mouse.GLX);
- b = ABS(n->distorted_y - view->mouse.GLY);
- c = ABS(n->distorted_z - view->mouse.GLZ);
- a = (float) pow((a * a + b * b+ c*c), (float) 0.5);
- if (a < closest_dif)
- {
- sn=n;
- closest_dif=a;
- }
+ topview_node *n;
+ topview_node *sn; /*selected node , closest node */
+ topview_edge *e;
+ topview_edge *se; /*selected edge , closest one */
+ GLfloat closest_dif = 100000000;
+ GLfloat closest_dif2 = 100000000;
+ float a, b, c;
+ double d;
+ int ind;
+ sn = (topview_node *) 0;
+ se = (topview_edge *) 0;
+
+ for (ind = 0; ind < view->Topview->Nodecount; ind++) {
+ n = &view->Topview->Nodes[ind];
+ if (!n->data.Visible)
+ continue;
+
+ a = ABS(n->distorted_x - view->mouse.GLX);
+ b = ABS(n->distorted_y - view->mouse.GLY);
+ c = ABS(n->distorted_z - view->mouse.GLZ);
+ a = (float) pow((a * a + b * b + c * c), (float) 0.5);
+ if (a < closest_dif) {
+ sn = n;
+ closest_dif = a;
}
+ }
+
+ for (ind = 0; ind < view->Topview->Edgecount; ind++) {
+ point3f p1, p2, p3;
+ e = &view->Topview->Edges[ind];
+ if (!e->data.Visible)
+ continue;
+
+ p1.x = e->Node1->distorted_x;
+ p1.y = e->Node1->distorted_y;
+ p1.z = e->Node1->distorted_z;
- for (ind = 0; ind < view->Topview->Edgecount; ind++)
- {
- point3f p1,p2,p3;
- e = &view->Topview->Edges[ind];
- if (!e->data.Visible)
- continue;
-
- p1.x=e->Node1->distorted_x;
- p1.y=e->Node1->distorted_y;
- p1.z=e->Node1->distorted_z;
-
- p2.x=e->Node2->distorted_x;
- p2.y=e->Node2->distorted_y;
- p2.z=e->Node2->distorted_z;
-
- p3.x=view->mouse.GLX;
- p3.y=view->mouse.GLY;
- p3.z=view->mouse.GLZ;
- d = point_to_lineseg_dist(p3, p1, p2);
-
- if (d < closest_dif2 ) {
- se=e;
- closest_dif2=d;
- }
+ p2.x = e->Node2->distorted_x;
+ p2.y = e->Node2->distorted_y;
+ p2.z = e->Node2->distorted_z;
+
+ p3.x = view->mouse.GLX;
+ p3.y = view->mouse.GLY;
+ p3.z = view->mouse.GLZ;
+ d = point_to_lineseg_dist(p3, p1, p2);
+
+ if (d < closest_dif2) {
+ se = e;
+ closest_dif2 = d;
}
+ }
- if (closest_dif < closest_dif2 * 3)
- {
- if (sn)
- {
- if (!is_node_picked(sn))
- add_to_pick_list(sn);
- else
- remove_from_pick_list(sn);
- }
+ if (closest_dif < closest_dif2 * 3) {
+ if (sn) {
+ if (!is_node_picked(sn))
+ add_to_pick_list(sn);
+ else
+ remove_from_pick_list(sn);
}
- else
- {
- if (se)
- {
- if (!is_edge_picked(se))
- add_edge_to_pick_list(se);
- else
- remove_edge_from_pick_list(se);
- }
+ } else {
+ if (se) {
+ if (!is_edge_picked(se))
+ add_edge_to_pick_list(se);
+ else
+ remove_edge_from_pick_list(se);
}
+ }
}
{
int ind = 0;
int found = 0;
- for (; ind < view->Topview->picked_node_count; ind++) {
+ for (; ind < view->Topview->picked_node_count; ind++) {
if ((view->Topview->picked_nodes[ind] == n) && (!found))
found = 1;
if ((found) && (ind < (view->Topview->picked_node_count - 1))) {
int add_to_pick_list(topview_node * n)
{
view->Topview->picked_node_count++;
- view->Topview->picked_nodes =realloc(view->Topview->picked_nodes,sizeof(topview_node *) * view->Topview->picked_node_count);
+ view->Topview->picked_nodes =
+ realloc(view->Topview->picked_nodes,
+ sizeof(topview_node *) * view->Topview->picked_node_count);
view->Topview->picked_nodes[view->Topview->picked_node_count - 1] = n;
return 1;
}
int draw_node_hint_boxes(void)
{
int ind;
- float del=0.01;
+ float del = 0.01;
float fs = GetOGLDistance(12);
- char* lbl;
- topview_node* n;
- topview_edge* e;
+ char *lbl;
+ topview_node *n;
+ topview_edge *e;
double dx, dy, dz;
- char buf[512]; /* FIX!!! static buffer */
+ char buf[512]; /* FIX!!! static buffer */
// view->widgets->fontset->fonts[view->widgets->fontset->activefont]->fontheight=fs;
- for (ind = 0; ind < view->Topview->picked_node_count; ind++)
- {
- n = view->Topview->picked_nodes[ind];
- lbl = agget(n->Node,"hint");
- if((!lbl) || (strlen(lbl)==0))
- lbl=agnameof(n->Node);
- dx = n->distorted_x;
- dy = n->distorted_y;
- dz = n->distorted_z+0.001;
+ for (ind = 0; ind < view->Topview->picked_node_count; ind++) {
+ n = view->Topview->picked_nodes[ind];
+ lbl = agget(n->Node, "hint");
+ if ((!lbl) || (strlen(lbl) == 0))
+ lbl = agnameof(n->Node);
+ dx = n->distorted_x;
+ dy = n->distorted_y;
+ dz = n->distorted_z + 0.001;
- /*blue font color*/
- glColor4f(0, 0, 1, 1);
- glprintfglut (GLUT_BITMAP_HELVETICA_12, dx,dy,dz+del,"[");
- glprintfglut (GLUT_BITMAP_HELVETICA_12, dx,(dy+fs+fs/(GLfloat)5.0),dz+del,lbl);
-// glprintfglut (GLUT_BITMAP_HELVETICA_12, dx,(dy+fs+fs/(GLfloat)5.0),dz,"aaaaaaaa");
-// ffs=(dy+fs+fs/(GLfloat)5.0)-GetOGLDistance(14)/view->zoom*-1;
-// glprintfglut (GLUT_BITMAP_HELVETICA_12, dx,ffs,dz,"bbbbbbbbbb");
+ /*blue font color */
+ glColor4f(0, 0, 1, 1);
+ glprintfglut(GLUT_BITMAP_HELVETICA_12, dx, dy, dz + del, "[");
+ glprintfglut(GLUT_BITMAP_HELVETICA_12, dx,
+ (dy + fs + fs / (GLfloat) 5.0), dz + del, lbl);
+// glprintfglut (GLUT_BITMAP_HELVETICA_12, dx,(dy+fs+fs/(GLfloat)5.0),dz,"aaaaaaaa");
+// ffs=(dy+fs+fs/(GLfloat)5.0)-GetOGLDistance(14)/view->zoom*-1;
+// glprintfglut (GLUT_BITMAP_HELVETICA_12, dx,ffs,dz,"bbbbbbbbbb");
#if UNUSED
- char* buf;
- char* nc;
- buf = malloc (sizeof(char)*512);
+ char *buf;
+ char *nc;
+ buf = malloc(sizeof(char) * 512);
if (!bf)
- return;
+ return;
if (strlen(bf) > 512)
- return;
- strcpy(buf,bf);
- nc=buf;
-
- for (nc;*nc != NULL ; nc ++)
- {
- if (*nc == '\n')
- {
- int a=glutBitmapWidth(font,buf);
- *nc=NULL;
- glRasterPos3f(xpos,ypos,zpos+0.001);
- print_bitmap_string(font,buf);
- nc++;
- buf=nc;
- ypos=ypos-14.00;
- }
+ return;
+ strcpy(buf, bf);
+ nc = buf;
+
+ for (nc; *nc != NULL; nc++) {
+ if (*nc == '\n') {
+ int a = glutBitmapWidth(font, buf);
+ *nc = NULL;
+ glRasterPos3f(xpos, ypos, zpos + 0.001);
+ print_bitmap_string(font, buf);
+ nc++;
+ buf = nc;
+ ypos = ypos - 14.00;
+ }
}
- glRasterPos3f(xpos,ypos,zpos+0.001);
- print_bitmap_string(font,buf);
+ glRasterPos3f(xpos, ypos, zpos + 0.001);
+ print_bitmap_string(font, buf);
#endif
}
- glColor4f(0, 1, 0, 0.5);
- glLineWidth(2);
- glBegin(GL_LINES);
- for (ind = 0; ind < view->Topview->picked_edge_count; ind++)
- {
- float x1,x2,y1,y2,z1,z2;
- e = view->Topview->picked_edges[ind];
- x1=e->Node1->distorted_x;
- x2=e->Node2->distorted_x;
- y1=e->Node1->distorted_y;
- y2=e->Node2->distorted_y;
- z1=e->Node1->distorted_z;
- z2=e->Node2->distorted_z;
+ glColor4f(0, 1, 0, 0.5);
+ glLineWidth(2);
+ glBegin(GL_LINES);
+ for (ind = 0; ind < view->Topview->picked_edge_count; ind++) {
+ float x1, x2, y1, y2, z1, z2;
+ e = view->Topview->picked_edges[ind];
+ x1 = e->Node1->distorted_x;
+ x2 = e->Node2->distorted_x;
+ y1 = e->Node1->distorted_y;
+ y2 = e->Node2->distorted_y;
+ z1 = e->Node1->distorted_z;
+ z2 = e->Node2->distorted_z;
- dx = (x1+x2)/2.0;
- dy = (y1+y2)/2.0;
- dz = (z1+z2)/2.0;
+ dx = (x1 + x2) / 2.0;
+ dy = (y1 + y2) / 2.0;
+ dz = (z1 + z2) / 2.0;
- glVertex3f(x1,y1,z1);
- glVertex3f(x2,y2,z2);
+ glVertex3f(x1, y1, z1);
+ glVertex3f(x2, y2, z2);
}
- glEnd();
- glLineWidth(1);
- for (ind = 0; ind < view->Topview->picked_edge_count; ind++) {
- float x1,x2,y1,y2,z1,z2;
- char* s;
- glColor4f(0, 1, 0, 0.5);
- e = view->Topview->picked_edges[ind];
- x1=e->Node1->distorted_x;
- x2=e->Node2->distorted_x;
- y1=e->Node1->distorted_y;
- y2=e->Node2->distorted_y;
- z1=e->Node1->distorted_z;
- z2=e->Node2->distorted_z;
- if ((s = agget(e->Edge,"hint")) && s[0])
- strcpy (buf,s);
- else
- {
- strcpy(buf,agnameof(e->Node1->Node));
- strcat(buf," - ");
- strcat(buf,agnameof(e->Node2->Node));
- }
- dx = (x1+x2)/2.0;
- dy = (y1+y2)/2.0;
- dz = (z1+z2)/2.0;
-
-
-
- glColor4f(0, 0, 1, 1);
-
- /*blue font color*/
- glprintfglut (GLUT_BITMAP_HELVETICA_12, dx,dy,dz+del,"|");
- glprintfglut (GLUT_BITMAP_HELVETICA_12, dx,(dy+fs+fs/(GLfloat)5.0),dz+del,buf);
+ glEnd();
+ glLineWidth(1);
+ for (ind = 0; ind < view->Topview->picked_edge_count; ind++) {
+ float x1, x2, y1, y2, z1, z2;
+ char *s;
+ glColor4f(0, 1, 0, 0.5);
+ e = view->Topview->picked_edges[ind];
+ x1 = e->Node1->distorted_x;
+ x2 = e->Node2->distorted_x;
+ y1 = e->Node1->distorted_y;
+ y2 = e->Node2->distorted_y;
+ z1 = e->Node1->distorted_z;
+ z2 = e->Node2->distorted_z;
+ if ((s = agget(e->Edge, "hint")) && s[0])
+ strcpy(buf, s);
+ else {
+ strcpy(buf, agnameof(e->Node1->Node));
+ strcat(buf, " - ");
+ strcat(buf, agnameof(e->Node2->Node));
+ }
+ dx = (x1 + x2) / 2.0;
+ dy = (y1 + y2) / 2.0;
+ dz = (z1 + z2) / 2.0;
+
+
+
+ glColor4f(0, 0, 1, 1);
+
+ /*blue font color */
+ glprintfglut(GLUT_BITMAP_HELVETICA_12, dx, dy, dz + del, "|");
+ glprintfglut(GLUT_BITMAP_HELVETICA_12, dx,
+ (dy + fs + fs / (GLfloat) 5.0), dz + del, buf);
}
return 1;
}
-
#define BEACON_H
#include "smyrnadefs.h"
-extern int pick_node(topview_node * n);
-extern int is_node_picked(topview_node * n);
-extern int remove_from_pick_list(topview_node * n);
-extern int add_to_pick_list(topview_node * n);
-extern int draw_node_hint_boxes(void);
-extern void pick_node_from_coords(float x,float y,float z);
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ extern int pick_node(topview_node * n);
+ extern int is_node_picked(topview_node * n);
+ extern int remove_from_pick_list(topview_node * n);
+ extern int add_to_pick_list(topview_node * n);
+ extern int draw_node_hint_boxes(void);
+ extern void pick_node_from_coords(float x, float y, float z);
+#ifdef __cplusplus
+} /* end extern "C" */
+#endif
#endif
}
void btn_dot_clicked(GtkWidget * widget, gpointer user_data)
{
- btn_clicked (widget, GVK_DOT);
+ btn_clicked(widget, GVK_DOT);
}
void btn_neato_clicked(GtkWidget * widget, gpointer user_data)
{
- btn_clicked (widget, GVK_NEATO);
+ btn_clicked(widget, GVK_NEATO);
}
void btn_twopi_clicked(GtkWidget * widget, gpointer user_data)
{
- btn_clicked (widget, GVK_TWOPI);
+ btn_clicked(widget, GVK_TWOPI);
}
void btn_circo_clicked(GtkWidget * widget, gpointer user_data)
{
- btn_clicked (widget, GVK_CIRCO);
+ btn_clicked(widget, GVK_CIRCO);
}
void btn_fdp_clicked(GtkWidget * widget, gpointer user_data)
{
- btn_clicked (widget, GVK_FDP);
+ btn_clicked(widget, GVK_FDP);
}
//test call back function delete later
void attr_widgets_modifiedSlot(GtkWidget * widget, gpointer user_data)
{
- attr_widgets_modified[*(int*)user_data] = 1;
- g_print("attr changed signal..incoming data : %i\n", *(int*)user_data);
+ attr_widgets_modified[*(int *) user_data] = 1;
+ g_print("attr changed signal..incoming data : %i\n",
+ *(int *) user_data);
}
{
//call function to update object values
// update_object_properties(frmObjectTypeIndex, frmObjectg);
- set_update_required(view->Topview);
- deselect_all(view->g[view->activeGraph]);
+ set_update_required(view->Topview);
+ deselect_all(view->g[view->activeGraph]);
gtk_widget_hide(glade_xml_get_widget(xml, "frmObject"));
}
/*console output widgets*/
_BB void on_clearconsolebtn_clicked(GtkWidget * widget, gpointer user_data)
{
- gtk_text_buffer_set_text (gtk_text_view_get_buffer((GtkTextView*) glade_xml_get_widget(xml,"mainconsole")),"",0);
+ gtk_text_buffer_set_text(gtk_text_view_get_buffer
+ ((GtkTextView *)
+ glade_xml_get_widget(xml, "mainconsole")),
+ "", 0);
}
_BB void on_hideconsolebtn_clicked(GtkWidget * widget, gpointer user_data)
{
_BB void on_consoledecbtn_clicked(GtkWidget * widget, gpointer user_data)
{
- int w,h;
- gtk_widget_get_size_request((GtkTextView*) glade_xml_get_widget(xml,"scrolledwindow7"),&w,&h);
- w=w-5;
- gtk_widget_set_size_request(((GtkTextView*) glade_xml_get_widget(xml,"scrolledwindow7")),
- w,0);
+ int w, h;
+ gtk_widget_get_size_request((GtkTextView *)
+ glade_xml_get_widget(xml,
+ "scrolledwindow7"),
+ &w, &h);
+ w = w - 5;
+ gtk_widget_set_size_request(((GtkTextView *)
+ glade_xml_get_widget(xml,
+ "scrolledwindow7")),
+ w, 0);
}
_BB void on_consoleincbtn_clicked(GtkWidget * widget, gpointer user_data)
{
- int w,h;
- gtk_widget_get_size_request((GtkTextView*) glade_xml_get_widget(xml,"scrolledwindow7"),&w,&h);
- w=w+5;
- gtk_widget_set_size_request(((GtkTextView*) glade_xml_get_widget(xml,"scrolledwindow7")),
- w,0);
+ int w, h;
+ gtk_widget_get_size_request((GtkTextView *)
+ glade_xml_get_widget(xml,
+ "scrolledwindow7"),
+ &w, &h);
+ w = w + 5;
+ gtk_widget_set_size_request(((GtkTextView *)
+ glade_xml_get_widget(xml,
+ "scrolledwindow7")),
+ w, 0);
}
-
-
* Information and Software Systems Research *
* AT&T Research, Florham Park NJ *
**********************************************************/
+#ifndef CALLBACKS_H
+#define CALLBACKS_H 1
#include <gtk/gtk.h>
#include "toolboxcallbacks.h"
#include "gui.h"
-
-
-
+#ifdef __cplusplus
+extern "C" {
+#endif
#ifdef WIN32 //this shit is needed on WIN32 to get libglade see the callback
#define _BB __declspec(dllexport)
#define _BB
#endif
-_BB void new_graph_clicked(GtkWidget * widget, gpointer user_data);
-_BB void open_graph_clicked(GtkWidget * widget, gpointer user_data);
-_BB void save_graph_clicked(GtkWidget * widget, gpointer user_data);
-_BB void save_as_graph_clicked(GtkWidget * widget, gpointer user_data);
-_BB void remove_graph_clicked(GtkWidget * widget, gpointer user_data);
-void on_newNode(GtkWidget * button, gpointer user_data);
-void dlgOpenGraph_OK_Clicked(GtkWidget * button, gpointer data);
-_BB void btn_dot_clicked(GtkWidget * widget, gpointer user_data);
-_BB void btn_neato_clicked(GtkWidget * widget, gpointer user_data);
-_BB void btn_twopi_clicked(GtkWidget * widget, gpointer user_data);
-_BB void btn_circo_clicked(GtkWidget * widget, gpointer user_data);
-_BB void btn_fdp_clicked(GtkWidget * widget, gpointer user_data);
+ _BB void new_graph_clicked(GtkWidget * widget, gpointer user_data);
+ _BB void open_graph_clicked(GtkWidget * widget, gpointer user_data);
+ _BB void save_graph_clicked(GtkWidget * widget, gpointer user_data);
+ _BB void save_as_graph_clicked(GtkWidget * widget, gpointer user_data);
+ _BB void remove_graph_clicked(GtkWidget * widget, gpointer user_data);
+ void on_newNode(GtkWidget * button, gpointer user_data);
+ void dlgOpenGraph_OK_Clicked(GtkWidget * button, gpointer data);
+ _BB void btn_dot_clicked(GtkWidget * widget, gpointer user_data);
+ _BB void btn_neato_clicked(GtkWidget * widget, gpointer user_data);
+ _BB void btn_twopi_clicked(GtkWidget * widget, gpointer user_data);
+ _BB void btn_circo_clicked(GtkWidget * widget, gpointer user_data);
+ _BB void btn_fdp_clicked(GtkWidget * widget, gpointer user_data);
-_BB void graph_select_change(GtkWidget * widget, gpointer user_data);
-_BB void mGraphPropertiesSlot(GtkWidget * widget, gpointer user_data);
+ _BB void graph_select_change(GtkWidget * widget, gpointer user_data);
+ _BB void mGraphPropertiesSlot(GtkWidget * widget, gpointer user_data);
//dlgOpenGraph btnOK clicked
-_BB void on_dlgOpenGraph_btnOK_clicked(GtkWidget * widget,
- gpointer user_data);
-//dlgOpenGraph btncancelclicked
-_BB void on_dlgOpenGraph_btncancel_clicked(GtkWidget * widget,
+ _BB void on_dlgOpenGraph_btnOK_clicked(GtkWidget * widget,
gpointer user_data);
+//dlgOpenGraph btncancelclicked
+ _BB void on_dlgOpenGraph_btncancel_clicked(GtkWidget * widget,
+ gpointer user_data);
//MENU
//frm Object OK button
//hides frmObject , set changed values to selected objects
-_BB void frmObjectBtnOK_clicked(GtkWidget * widget, gpointer user_data);
+ _BB void frmObjectBtnOK_clicked(GtkWidget * widget,
+ gpointer user_data);
//frm Object Cancel button
//hides frmObject , ignores changed values
-_BB void frmObjectBtnCancel_clicked(GtkWidget * widget,
- gpointer user_data);
+ _BB void frmObjectBtnCancel_clicked(GtkWidget * widget,
+ gpointer user_data);
-_BB void attr_widgets_modifiedSlot(GtkWidget * widget, gpointer user_data);
+ _BB void attr_widgets_modifiedSlot(GtkWidget * widget,
+ gpointer user_data);
/*console output widgets*/
-_BB void on_clearconsolebtn_clicked(GtkWidget * widget, gpointer user_data);
-_BB void on_hideconsolebtn_clicked(GtkWidget * widget, gpointer user_data);
-_BB void on_consoledecbtn_clicked(GtkWidget * widget, gpointer user_data);
-_BB void on_consoleincbtn_clicked(GtkWidget * widget, gpointer user_data);
+ _BB void on_clearconsolebtn_clicked(GtkWidget * widget,
+ gpointer user_data);
+ _BB void on_hideconsolebtn_clicked(GtkWidget * widget,
+ gpointer user_data);
+ _BB void on_consoledecbtn_clicked(GtkWidget * widget,
+ gpointer user_data);
+ _BB void on_consoleincbtn_clicked(GtkWidget * widget,
+ gpointer user_data);
+
+#ifdef __cplusplus
+} /* end extern "C" */
+#endif
+#endif
// gtk_dialog_set_response_sensitive (glade_xml_get_widget(xml, "dlgOpenGraph"),1,1);
// gtk_dialog_set_response_sensitive (glade_xml_get_widget(xml, "dlgOpenGraph"),2,1);
- respond =
- gtk_dialog_run((GtkDialog *)
- glade_xml_get_widget(xml, "dlgTVFilter"));
+ respond = gtk_dialog_run((GtkDialog *)
+ glade_xml_get_widget(xml, "dlgTVFilter"));
// respond=gtk_dialog_run (glade_xml_get_widget(xml, "dlgFilters"));
gtk_widget_hide(glade_xml_get_widget(xml, "dlgTVFilter"));
if (respond == 1)
{
}
-void cgbTVHighlighted_toggled_cb(GtkWidget * widget,
- gpointer user_data)
+void cgbTVHighlighted_toggled_cb(GtkWidget * widget, gpointer user_data)
{
}
{
tv_hide_all();
}
+
void btnTVSaveAs_clicked_cb(GtkWidget * widget, gpointer user_data)
{
- tv_save_as();
-}
\ No newline at end of file
+ tv_save_as();
+}
#include "gui.h"
#include "tvnodes.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
-
-
-_BB void btnTVEdit_clicked_cb(GtkWidget * widget, gpointer user_data);
-_BB void btnTVDelete_clicked_cb(GtkWidget * widget, gpointer user_data);
-_BB void btnTVFilter_clicked_cb(GtkWidget * widget, gpointer user_data);
-_BB void btnTVFirst_clicked_cb(GtkWidget * widget, gpointer user_data);
-_BB void btnTVPrevious_clicked_cb(GtkWidget * widget, gpointer user_data);
-_BB void btnTVNext_clicked_cb(GtkWidget * widget, gpointer user_data);
-_BB void btnTVLast_clicked_cb(GtkWidget * widget, gpointer user_data);
-_BB void btnTVGotopage_clicked_cb(GtkWidget * widget, gpointer user_data);
-_BB void btnTVCancel_clicked_cb(GtkWidget * widget, gpointer user_data);
-_BB void btnTVOK_clicked_cb(GtkWidget * widget, gpointer user_data);
-_BB void btnTVReverse_clicked_cb(GtkWidget * widget, gpointer user_data);
-_BB void cgbTVSelect_toggled_cb(GtkWidget * widget, gpointer user_data);
-_BB void btnTVFilterApply_clicked_cb(GtkWidget * widget,
+ _BB void btnTVEdit_clicked_cb(GtkWidget * widget, gpointer user_data);
+ _BB void btnTVDelete_clicked_cb(GtkWidget * widget,
+ gpointer user_data);
+ _BB void btnTVFilter_clicked_cb(GtkWidget * widget,
+ gpointer user_data);
+ _BB void btnTVFirst_clicked_cb(GtkWidget * widget, gpointer user_data);
+ _BB void btnTVPrevious_clicked_cb(GtkWidget * widget,
+ gpointer user_data);
+ _BB void btnTVNext_clicked_cb(GtkWidget * widget, gpointer user_data);
+ _BB void btnTVLast_clicked_cb(GtkWidget * widget, gpointer user_data);
+ _BB void btnTVGotopage_clicked_cb(GtkWidget * widget,
+ gpointer user_data);
+ _BB void btnTVCancel_clicked_cb(GtkWidget * widget,
+ gpointer user_data);
+ _BB void btnTVOK_clicked_cb(GtkWidget * widget, gpointer user_data);
+ _BB void btnTVReverse_clicked_cb(GtkWidget * widget,
gpointer user_data);
-_BB void btnTVFilterClear_clicked_cb(GtkWidget * widget,
+ _BB void cgbTVSelect_toggled_cb(GtkWidget * widget,
+ gpointer user_data);
+ _BB void btnTVFilterApply_clicked_cb(GtkWidget * widget,
+ gpointer user_data);
+ _BB void btnTVFilterClear_clicked_cb(GtkWidget * widget,
+ gpointer user_data);
+ _BB void btnTVSelectAll_clicked_cb(GtkWidget * widget,
+ gpointer user_data);
+ _BB void btnTVUnselectAll_clicked_cb(GtkWidget * widget,
+ gpointer user_data);
+ _BB void btnTVHighlightAll_clicked_cb(GtkWidget * widget,
+ gpointer user_data);
+ _BB void btnTVUnhighlightAll_clicked_cb(GtkWidget * widget,
+ gpointer user_data);
+ _BB void cgbTVSelect_toggled_cb(GtkWidget * widget,
+ gpointer user_data);
+ _BB void cgbTVVisible_toggled_cb(GtkWidget * widget,
gpointer user_data);
-_BB void btnTVSelectAll_clicked_cb(GtkWidget * widget, gpointer user_data);
-_BB void btnTVUnselectAll_clicked_cb(GtkWidget * widget,
+ _BB void cgbTVHighlighted_toggled_cb(GtkWidget * widget,
+ gpointer user_data);
+ _BB void btnTVShowAll_clicked_cb(GtkWidget * widget,
gpointer user_data);
-_BB void btnTVHighlightAll_clicked_cb(GtkWidget * widget,
- gpointer user_data);
-_BB void btnTVUnhighlightAll_clicked_cb(GtkWidget * widget,
- gpointer user_data);
-_BB void cgbTVSelect_toggled_cb(GtkWidget * widget, gpointer user_data);
-_BB void cgbTVVisible_toggled_cb(GtkWidget * widget, gpointer user_data);
-_BB void cgbTVHighlighted_toggled_cb(GtkWidget * widget,
+ _BB void btnTVHideAll_clicked_cb(GtkWidget * widget,
gpointer user_data);
-_BB void btnTVShowAll_clicked_cb(GtkWidget * widget, gpointer user_data);
-_BB void btnTVHideAll_clicked_cb(GtkWidget * widget, gpointer user_data);
-_BB void btnTVSaveAs_clicked_cb(GtkWidget * widget, gpointer user_data);
+ _BB void btnTVSaveAs_clicked_cb(GtkWidget * widget,
+ gpointer user_data);
+#ifdef __cplusplus
+} /* end extern "C" */
+#endif
#endif
+/* $Id$Revision: */
+/* vim:set shiftwidth=4 ts=8: */
+
+/**********************************************************
+* This software is part of the graphviz package *
+* http://www.graphviz.org/ *
+* *
+* Copyright (c) 1994-2004 AT&T Corp. *
+* and is licensed under the *
+* Common Public License, Version 1.0 *
+* by AT&T Corp. *
+* *
+* Information and Software Systems Research *
+* AT&T Research, Florham Park NJ *
+**********************************************************/
+
#include "glcompui.h"
#include "glcompbutton.h"
#include "glcomppanel.h"
/* static glCompPanel *controlPanel; */
/* static glCompButton *rotatebutton; */
-static glCompPanel* sel=NULL;
-static glCompButton* to3DBtn;
-static glCompButton* to2DBtn;
-static glCompButton* rotateBtn;
-static glCompButton* toFisheye;
-static glCompButton* toNormal;
-static glCompImage* imgFisheye;
-static glCompButton* img3D;
-static glCompButton* panBtn;
-
-
-static void menu_click_pan(void* obj,GLfloat x,GLfloat y,glMouseButtonType t)
+static glCompPanel *sel = NULL;
+static glCompButton *to3DBtn;
+static glCompButton *to2DBtn;
+static glCompButton *rotateBtn;
+static glCompButton *toFisheye;
+static glCompButton *toNormal;
+static glCompImage *imgFisheye;
+static glCompButton *img3D;
+static glCompButton *panBtn;
+
+
+static void menu_click_pan(void *obj, GLfloat x, GLfloat y,
+ glMouseButtonType t)
{
- switch_Mouse(NULL,MM_PAN);
+ switch_Mouse(NULL, MM_PAN);
}
#ifdef UNUSED
-static void menu_click_zoom(void* obj,GLfloat x,GLfloat y,glMouseButtonType t)
+static void menu_click_zoom(void *obj, GLfloat x, GLfloat y,
+ glMouseButtonType t)
{
- switch_Mouse(NULL,MM_ZOOM);
+ switch_Mouse(NULL, MM_ZOOM);
}
#endif
-static void menu_click_fisheye_magnifier(void* obj,GLfloat x,GLfloat y,glMouseButtonType t)
+static void menu_click_fisheye_magnifier(void *obj, GLfloat x, GLfloat y,
+ glMouseButtonType t)
{
view->mouse.mouse_mode = MM_FISHEYE_MAGNIFIER;
}
-static void menu_click_zoom_minus(void* obj,GLfloat x,GLfloat y,glMouseButtonType t)
+static void menu_click_zoom_minus(void *obj, GLfloat x, GLfloat y,
+ glMouseButtonType t)
{
- glmotion_zoom_inc(0);
+ glmotion_zoom_inc(0);
}
-static void menu_click_zoom_plus(void* obj,GLfloat x,GLfloat y,glMouseButtonType t)
+static void menu_click_zoom_plus(void *obj, GLfloat x, GLfloat y,
+ glMouseButtonType t)
{
- glmotion_zoom_inc(1);
+ glmotion_zoom_inc(1);
}
-
-static void menu_switch_to_fisheye(void* obj,GLfloat x,GLfloat y,glMouseButtonType t)
+static void menu_switch_to_fisheye(void *obj, GLfloat x, GLfloat y,
+ glMouseButtonType t)
{
- 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;
- glCompButtonShow(toNormal);
- glCompButtonHide(toFisheye);
- imgFisheye->common.visible=1;
+ 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;
+ glCompButtonShow(toNormal);
+ glCompButtonHide(toFisheye);
+ imgFisheye->common.visible = 1;
- }
- else
- {
- view->Topview->is_top_fisheye = 0;
- g_timer_stop(view->timer);
- glCompButtonHide(toNormal);
- glCompButtonShow(toFisheye);
- imgFisheye->common.visible=0;
+ } else {
+ view->Topview->is_top_fisheye = 0;
+ g_timer_stop(view->timer);
+ glCompButtonHide(toNormal);
+ glCompButtonShow(toFisheye);
+ imgFisheye->common.visible = 0;
- }
+ }
}
-static void menu_click_rotate(void* obj,GLfloat x,GLfloat y,glMouseButtonType t)
+static void menu_click_rotate(void *obj, GLfloat x, GLfloat y,
+ glMouseButtonType t)
{
- switch_Mouse(NULL,MM_ROTATE);
- view->mouse.mouse_mode = MM_ROTATE;
+ switch_Mouse(NULL, MM_ROTATE);
+ view->mouse.mouse_mode = MM_ROTATE;
}
-static void menu_click_center(void* obj,GLfloat x,GLfloat y,glMouseButtonType t)
+static void menu_click_center(void *obj, GLfloat x, GLfloat y,
+ glMouseButtonType t)
{
- if (view->active_camera == -1) /*2D mode*/
- {
- btnToolZoomFit_clicked(NULL,NULL);
- }
- else /*there is active camera , adjust it to look at the center*/
- {
- view->cameras[view->active_camera]->targetx=0;
- view->cameras[view->active_camera]->targety=0;
- view->cameras[view->active_camera]->r=20;
+ if (view->active_camera == -1) { /*2D mode */
+ btnToolZoomFit_clicked(NULL, NULL);
+ } else { /*there is active camera , adjust it to look at the center */
- }
+ view->cameras[view->active_camera]->targetx = 0;
+ view->cameras[view->active_camera]->targety = 0;
+ view->cameras[view->active_camera]->r = 20;
+
+ }
}
-static void switch2D3D(void* obj,GLfloat x,GLfloat y,glMouseButtonType t)
+static void switch2D3D(void *obj, GLfloat x, GLfloat y,
+ glMouseButtonType t)
{
- if(t==glMouseLeftButton)
- {
-
- if (view->active_camera == -1)
- {
-
- if (view->camera_count == 0)
- {
- menu_click_add_camera(obj);
- }
- else
- {
- view->active_camera = 0 ; /*set to camera*/
- }
- glCompButtonShow(to2DBtn);
- glCompButtonHide(to3DBtn);
- glCompButtonShow(rotateBtn);
- img3D->common.visible=1;
- }
- else /*switch to 2d*/
- {
- view->active_camera = -1 ; /*set to camera*/
- glCompButtonShow(to3DBtn);
- glCompButtonHide(to2DBtn);
- glCompButtonHide(rotateBtn);
- panBtn->common.callbacks.click(panBtn,(GLfloat)0,(GLfloat)0,(glMouseButtonType)0);
- img3D->common.visible=0;
-
-
- }
+ if (t == glMouseLeftButton) {
+
+ if (view->active_camera == -1) {
+
+ if (view->camera_count == 0) {
+ menu_click_add_camera(obj);
+ } else {
+ view->active_camera = 0; /*set to camera */
+ }
+ glCompButtonShow(to2DBtn);
+ glCompButtonHide(to3DBtn);
+ glCompButtonShow(rotateBtn);
+ img3D->common.visible = 1;
+ } else { /*switch to 2d */
+
+ view->active_camera = -1; /*set to camera */
+ glCompButtonShow(to3DBtn);
+ glCompButtonHide(to2DBtn);
+ glCompButtonHide(rotateBtn);
+ panBtn->common.callbacks.click(panBtn, (GLfloat) 0,
+ (GLfloat) 0,
+ (glMouseButtonType) 0);
+ img3D->common.visible = 0;
+
+
}
+ }
}
-void CBglCompMouseUp (void* obj,GLfloat x,GLfloat y,glMouseButtonType t)
+void CBglCompMouseUp(void *obj, GLfloat x, GLfloat y, glMouseButtonType t)
{
- /* glCompMouse* m=&((glCompSet*)obj)->mouse; */
- sel->common.visible=0;
- sel->common.pos.x=-5000;
+ /* glCompMouse* m=&((glCompSet*)obj)->mouse; */
+ sel->common.visible = 0;
+ sel->common.pos.x = -5000;
}
-void CBglCompMouseRightClick (void* obj,GLfloat x,GLfloat y,glMouseButtonType t)
+void CBglCompMouseRightClick(void *obj, GLfloat x, GLfloat y,
+ glMouseButtonType t)
{
- if(t==glMouseRightButton)
- {
- GLfloat X,Y,Z=0;
- to3D((int)x,(int)y,&X,&Y,&Z);
- }
+ if (t == glMouseRightButton) {
+ GLfloat X, Y, Z = 0;
+ to3D((int) x, (int) y, &X, &Y, &Z);
+ }
}
-void glCompMouseMove (void* obj,GLfloat x,GLfloat y)
+void glCompMouseMove(void *obj, GLfloat x, GLfloat y)
{
- glCompMouse* m=&((glCompSet*)obj)->mouse;
+ glCompMouse *m = &((glCompSet *) obj)->mouse;
- sel->common.visible=1;
+ sel->common.visible = 1;
- if((m->down) &&(m->t==glMouseRightButton))
- {
- sel->common.pos.x=m->pos.x-m->dragX;
- sel->common.pos.y=m->pos.y-m->dragY;
- sel->common.width=m->dragX;
- sel->common.height=m->dragY;
- glexpose();
- }
+ if ((m->down) && (m->t == glMouseRightButton)) {
+ sel->common.pos.x = m->pos.x - m->dragX;
+ sel->common.pos.y = m->pos.y - m->dragY;
+ sel->common.width = m->dragX;
+ sel->common.height = m->dragY;
+ glexpose();
+ }
}
glCompSet *glcreate_gl_topview_menu(void)
{
- /* static char* icondir[512]; */
- /* int ind=0; */
- GLfloat y=5;
- GLfloat off=43;
- glCompSet *s = glCompSetNew(view->w,view->h);
- glCompPanel *p=NULL;
- glCompButton *b=NULL;
+ /* static char* icondir[512]; */
+ /* int ind=0; */
+ GLfloat y = 5;
+ GLfloat off = 43;
+ glCompSet *s = glCompSetNew(view->w, view->h);
+ glCompPanel *p = NULL;
+ glCompButton *b = NULL;
/* glCompLabel *l=NULL; */
- glCompImage *i=NULL;
- glCompColor c;
- s->common.callbacks.click=CBglCompMouseRightClick;
+ glCompImage *i = NULL;
+ glCompColor c;
+ s->common.callbacks.click = CBglCompMouseRightClick;
- p = glCompPanelNew((glCompObj*)s,25, 25, 53, 47);
- p->common.align=glAlignLeft;
+ p = glCompPanelNew((glCompObj *) s, 25, 25, 53, 47);
+ p->common.align = glAlignLeft;
p->common.data = 0;
- /*pan*/
- b=glCompButtonNew((glCompObj*)p,1,y,42,42,"");
- glCompButtonAddPngGlyph(b,smyrnaPath("pan.png"));
- b->common.callbacks.click=menu_click_pan;
- panBtn=b;
+ /*pan */
+ b = glCompButtonNew((glCompObj *) p, 1, y, 42, 42, "");
+ glCompButtonAddPngGlyph(b, smyrnaPath("pan.png"));
+ b->common.callbacks.click = menu_click_pan;
+ panBtn = b;
+
+ b->groupid = 1;
+ y = y + off;
- b->groupid=1;
- y=y+off;
+ b = glCompButtonNew((glCompObj *) p, 1, y, 42, 42, "");
+ glCompButtonAddPngGlyph(b, smyrnaPath("magnifier.png"));
+ b->common.callbacks.click = menu_click_fisheye_magnifier;
+ b->groupid = 1;
- b=glCompButtonNew((glCompObj*)p,1,y,42,42,"");
- glCompButtonAddPngGlyph(b,smyrnaPath("magnifier.png"));
- b->common.callbacks.click=menu_click_fisheye_magnifier;
- b->groupid=1;
+ y = y + off;
- y=y+off;
+ b = glCompButtonNew((glCompObj *) p, 1, y, 42, 42, "");
+ glCompButtonAddPngGlyph(b, smyrnaPath("rotate.png"));
+ b->groupid = 1;
+ b->common.callbacks.click = menu_click_rotate;
+ glCompButtonHide(b);
+ rotateBtn = b;
- b=glCompButtonNew((glCompObj*)p,1,y,42,42,"");
- glCompButtonAddPngGlyph(b,smyrnaPath("rotate.png"));
- b->groupid=1;
- b->common.callbacks.click=menu_click_rotate;
- glCompButtonHide(b);
- rotateBtn=b;
-
- p = glCompPanelNew((glCompObj*)p,1, 25, 80, 225);
- p->common.align=glAlignTop;
+ p = glCompPanelNew((glCompObj *) p, 1, 25, 80, 225);
+ p->common.align = glAlignTop;
p->common.data = 0;
- p->common.borderWidth=1;
- p->shadowwidth=0;
+ p->common.borderWidth = 1;
+ p->shadowwidth = 0;
+
+ c.R = 0.80;
+ c.G = 0.6;
+ c.B = 0.6;
+ c.A = 1.6;
- c.R=0.80;
- c.G=0.6;
- c.B=0.6;
- c.A=1.6;
-
- y=1;
- b=glCompButtonNew((glCompObj*)p,1,y,42,42,"");
- glCompButtonAddPngGlyph(b,smyrnaPath("zoomin.png"));
- b->groupid=0;
- b->common.callbacks.click=menu_click_zoom_plus;
+ y = 1;
+ b = glCompButtonNew((glCompObj *) p, 1, y, 42, 42, "");
+ glCompButtonAddPngGlyph(b, smyrnaPath("zoomin.png"));
+ b->groupid = 0;
+ b->common.callbacks.click = menu_click_zoom_plus;
- copy_glcomp_color(&c,&b->common.color);
- y=y+off;
+ copy_glcomp_color(&c, &b->common.color);
+ y = y + off;
- b=glCompButtonNew((glCompObj*)p,1,y,42,42,"");
- glCompButtonAddPngGlyph(b,smyrnaPath("zoomout.png"));
- b->common.callbacks.click=menu_click_zoom_minus;
+ b = glCompButtonNew((glCompObj *) p, 1, y, 42, 42, "");
+ glCompButtonAddPngGlyph(b, smyrnaPath("zoomout.png"));
+ b->common.callbacks.click = menu_click_zoom_minus;
- y=y+off;
- copy_glcomp_color(&c,&b->common.color);
+ y = y + off;
+ copy_glcomp_color(&c, &b->common.color);
- b=glCompButtonNew((glCompObj*)p,1,y,42,42,"");
- glCompButtonAddPngGlyph(b,smyrnaPath("fit.png"));
- copy_glcomp_color(&c,&b->common.color);
+ b = glCompButtonNew((glCompObj *) p, 1, y, 42, 42, "");
+ glCompButtonAddPngGlyph(b, smyrnaPath("fit.png"));
+ copy_glcomp_color(&c, &b->common.color);
- y=y+off;
+ y = y + off;
- b=glCompButtonNew((glCompObj*)p,1,y,42,42,"");
- glCompButtonAddPngGlyph(b,smyrnaPath("center.png"));
- b->common.callbacks.click=menu_click_center;
- copy_glcomp_color(&c,&b->common.color);
+ b = glCompButtonNew((glCompObj *) p, 1, y, 42, 42, "");
+ glCompButtonAddPngGlyph(b, smyrnaPath("center.png"));
+ b->common.callbacks.click = menu_click_center;
+ copy_glcomp_color(&c, &b->common.color);
- y=y+off;
+ y = y + off;
- b=glCompButtonNew((glCompObj*)p,1,y,42,42,"");
- glCompButtonAddPngGlyph(b,smyrnaPath("3D.png"));
- b->common.callbacks.click=switch2D3D;
- copy_glcomp_color(&c,&b->common.color);
- to3DBtn=b;
+ b = glCompButtonNew((glCompObj *) p, 1, y, 42, 42, "");
+ glCompButtonAddPngGlyph(b, smyrnaPath("3D.png"));
+ b->common.callbacks.click = switch2D3D;
+ copy_glcomp_color(&c, &b->common.color);
+ to3DBtn = b;
- b=glCompButtonNew((glCompObj*)p,1,y,42,42,"");
- glCompButtonAddPngGlyph(b,smyrnaPath("2D.png"));
- b->common.callbacks.click=switch2D3D;
- glCompButtonHide(b);
- copy_glcomp_color(&c,&b->common.color);
- to2DBtn=b;
+ b = glCompButtonNew((glCompObj *) p, 1, y, 42, 42, "");
+ glCompButtonAddPngGlyph(b, smyrnaPath("2D.png"));
+ b->common.callbacks.click = switch2D3D;
+ glCompButtonHide(b);
+ copy_glcomp_color(&c, &b->common.color);
+ to2DBtn = b;
- p = glCompPanelNew((glCompObj*)s,-250, 550, 150, 175);
- p->common.borderWidth=0;
- p->shadowwidth=0;
- p->common.color.R=0;
- p->common.color.G=0;
- p->common.color.B=1;
- p->common.color.A=0.2;
- p->common.visible=0;
- sel=p;
+ p = glCompPanelNew((glCompObj *) s, -250, 550, 150, 175);
+ p->common.borderWidth = 0;
+ p->shadowwidth = 0;
+ p->common.color.R = 0;
+ p->common.color.G = 0;
+ p->common.color.B = 1;
+ p->common.color.A = 0.2;
+ p->common.visible = 0;
+ sel = p;
- s->common.callbacks.mouseover=glCompMouseMove;
- s->common.callbacks.mouseup=CBglCompMouseUp;
+ s->common.callbacks.mouseover = glCompMouseMove;
+ s->common.callbacks.mouseup = CBglCompMouseUp;
- p = glCompPanelNew((glCompObj*)s,25, 25, 52, 47);
- p->common.align=glAlignRight;
+ p = glCompPanelNew((glCompObj *) s, 25, 25, 52, 47);
+ p->common.align = glAlignRight;
p->common.data = 0;
- p->common.color.A=0;
+ p->common.color.A = 0;
- /*switch to fisheye*/
- b=glCompButtonNew((glCompObj*)p,2,1,42,42,"");
- glCompButtonAddPngGlyph(b,smyrnaPath("fisheye.png"));
- b->common.callbacks.click=menu_switch_to_fisheye;
- toFisheye=b;
+ /*switch to fisheye */
+ b = glCompButtonNew((glCompObj *) p, 2, 1, 42, 42, "");
+ glCompButtonAddPngGlyph(b, smyrnaPath("fisheye.png"));
+ b->common.callbacks.click = menu_switch_to_fisheye;
+ toFisheye = b;
- /*switch to normal mode*/
- b=glCompButtonNew((glCompObj*)p,2,1,42,42,"");
- glCompButtonAddPngGlyph(b,smyrnaPath("no_fisheye.png"));
- b->common.callbacks.click=menu_switch_to_fisheye;
- b->common.visible=0;
- toNormal=b;
+ /*switch to normal mode */
+ b = glCompButtonNew((glCompObj *) p, 2, 1, 42, 42, "");
+ glCompButtonAddPngGlyph(b, smyrnaPath("no_fisheye.png"));
+ b->common.callbacks.click = menu_switch_to_fisheye;
+ b->common.visible = 0;
+ toNormal = b;
- p = glCompPanelNew((glCompObj*)p,25, 0, 52, 110);
- p->common.align=glAlignTop;
+ p = glCompPanelNew((glCompObj *) p, 25, 0, 52, 110);
+ p->common.align = glAlignTop;
p->common.data = 0;
- p->common.color.A=0;
- p->shadowwidth=0;
-
- i=glCompImageNew((glCompObj*)p,0,0);
- glCompImageLoadPng(i,smyrnaPath("mod_fisheye.png"));
- imgFisheye=i;
- i->common.visible=0;
-
- i=glCompImageNew((glCompObj*)p,0,52);
- glCompImageLoadPng(i,smyrnaPath("mod_3D.png"));
- img3D=i;
- i->common.visible=0;
- return s;
+ p->common.color.A = 0;
+ p->shadowwidth = 0;
+
+ i = glCompImageNew((glCompObj *) p, 0, 0);
+ glCompImageLoadPng(i, smyrnaPath("mod_fisheye.png"));
+ imgFisheye = i;
+ i->common.visible = 0;
+
+ i = glCompImageNew((glCompObj *) p, 0, 52);
+ glCompImageLoadPng(i, smyrnaPath("mod_3D.png"));
+ img3D = i;
+ i->common.visible = 0;
+ return s;
}
-int getIconsDirectory(char* bf)
+int getIconsDirectory(char *bf)
{
#ifdef WIN32
- int a=GetCurrentDirectory(512,bf);
- if ((a > 512) || (a==0))
- return 0;
+ int a = GetCurrentDirectory(512, bf);
+ if ((a > 512) || (a == 0))
+ return 0;
#else
- //code *nix implementation to retrieve the icon directory, possibly some /share dir.
+ //code *nix implementation to retrieve the icon directory, possibly some /share dir.
/* FIXME */
#endif
- return 1;
+ return 1;
}
#ifndef GLCOMPUI_H
#define GLCOMPUI_H
#include "smyrnadefs.h"
-extern glCompSet *glcreate_gl_topview_menu(void);
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ extern glCompSet *glcreate_gl_topview_menu(void);
+
+#ifdef __cplusplus
+} /* end extern "C" */
+#endif
#endif
+/* $Id$Revision: */
/* vim:set shiftwidth=4 ts=8: */
/**********************************************************
menu_item = gtk_menu_item_new_with_label("Pan");
gtk_menu_shell_append(GTK_MENU_SHELL(actions_menu), menu_item);
g_signal_connect(G_OBJECT(menu_item), "activate",
- G_CALLBACK(switch_Mouse), (gpointer) &mm);
+ G_CALLBACK(switch_Mouse), (gpointer) & mm);
gtk_widget_show(menu_item);
/**********/
//ZOOM
menu_item = gtk_menu_item_new_with_label("Zoom");
gtk_menu_shell_append(GTK_MENU_SHELL(actions_menu), menu_item);
g_signal_connect(G_OBJECT(menu_item), "activate",
- G_CALLBACK(switch_Mouse), (gpointer) &mm);
+ G_CALLBACK(switch_Mouse), (gpointer) & mm);
gtk_widget_show(menu_item);
/**********/
//ROTATE
menu_item = gtk_menu_item_new_with_label("rotate");
gtk_menu_shell_append(GTK_MENU_SHELL(actions_menu), menu_item);
g_signal_connect(G_OBJECT(menu_item), "activate",
- G_CALLBACK(switch_Mouse), (gpointer) &mm);
+ G_CALLBACK(switch_Mouse), (gpointer) & mm);
gtk_widget_show(menu_item);
/**********/
/**********/
menu_item = gtk_menu_item_new_with_label("select");
gtk_menu_shell_append(GTK_MENU_SHELL(actions_menu), menu_item);
g_signal_connect(G_OBJECT(menu_item), "activate",
- G_CALLBACK(switch_Mouse), (gpointer) &mm);
+ G_CALLBACK(switch_Mouse), (gpointer) & mm);
gtk_widget_show(menu_item);
/**********/
//Rectangle Select
menu_item = gtk_menu_item_new_with_label("rect select");
gtk_menu_shell_append(GTK_MENU_SHELL(actions_menu), menu_item);
g_signal_connect(G_OBJECT(menu_item), "activate",
- G_CALLBACK(switch_Mouse), (gpointer) &mm);
+ G_CALLBACK(switch_Mouse), (gpointer) & mm);
gtk_widget_show(menu_item);
/**********/
/**********/
menu_item = gtk_menu_item_new_with_label("rect-x select");
gtk_menu_shell_append(GTK_MENU_SHELL(actions_menu), menu_item);
g_signal_connect(G_OBJECT(menu_item), "activate",
- G_CALLBACK(switch_Mouse), (gpointer) &mm);
+ G_CALLBACK(switch_Mouse), (gpointer) & mm);
gtk_widget_show(menu_item);
/**********/
/**********/
menu_item = gtk_menu_item_new_with_label("Move");
gtk_menu_shell_append(GTK_MENU_SHELL(actions_menu), menu_item);
g_signal_connect(G_OBJECT(menu_item), "activate",
- G_CALLBACK(switch_Mouse), (gpointer) &mm);
+ G_CALLBACK(switch_Mouse), (gpointer) & mm);
gtk_widget_show(menu_item);
/**********/
//activate magnifier
menu_item = gtk_menu_item_new_with_label("Magnifier");
gtk_menu_shell_append(GTK_MENU_SHELL(actions_menu), menu_item);
g_signal_connect(G_OBJECT(menu_item), "activate",
- G_CALLBACK(switch_Mouse), (gpointer) &mm);
+ G_CALLBACK(switch_Mouse), (gpointer) & mm);
gtk_widget_show(menu_item);
/**********/
//activate fisheye magnifier
menu_item = gtk_menu_item_new_with_label("Fisheye Magnifier");
gtk_menu_shell_append(GTK_MENU_SHELL(actions_menu), menu_item);
g_signal_connect(G_OBJECT(menu_item), "activate",
- G_CALLBACK(switch_Mouse), (gpointer) &mm);
+ G_CALLBACK(switch_Mouse), (gpointer) & mm);
gtk_widget_show(menu_item);
/**********/
editing_menu = gtk_menu_new();
#define GLMENU_H
#include "viewport.h"
-GtkWidget *create_popup_menu(GtkWidget * drawing_area);
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ GtkWidget *create_popup_menu(GtkWidget * drawing_area);
+
+#ifdef __cplusplus
+} /* end extern "C" */
+#endif
#endif
view->Topview->Graphdata.GraphFileName) != 0) {
- if ((file =
- fopen(gtk_entry_get_text
- ((GtkEntry *)
- glade_xml_get_widget(xml, "entryGraphFileName")),
- "r"))) {
+ if ((file = fopen(gtk_entry_get_text((GtkEntry *)
+ glade_xml_get_widget(xml,
+ "entryGraphFileName")),
+ "r"))) {
fclose(file);
Dlg = (GtkMessageDialog *) gtk_message_dialog_new(NULL,
GTK_DIALOG_MODAL,
return 0;
}
//now check if filename is legal, try to open it to write
- if ((file =
- fopen(gtk_entry_get_text
- ((GtkEntry *)
- glade_xml_get_widget(xml, "entryGraphFileName")),
- "w")))
+ if ((file = fopen(gtk_entry_get_text((GtkEntry *)
+ glade_xml_get_widget(xml,
+ "entryGraphFileName")),
+ "w")))
fclose(file);
else {
Dlg = (GtkMessageDialog *) gtk_message_dialog_new(NULL,
}
-
//if it comes so far graph deserves new values
- view->Topview->Graphdata.GraphFileName =
+ view->Topview->Graphdata.GraphFileName =
(char *) gtk_entry_get_text((GtkEntry *)
glade_xml_get_widget(xml,
"entryGraphFileName"));
char *get_attribute_string_value_from_widget(attribute * att)
{
GdkColor color;
- switch (att->Type)
- {
- case 'F':
- sprintf(guibuffer, "%f",gtk_spin_button_get_value((GtkSpinButton *) att->attrWidget));
- return guibuffer;
- break;
- case 'C':
- gtk_color_button_get_color((GtkColorButton *) att->attrWidget,&color);
- sprintf(guibuffer, "#%x%x%x", color.red / 255, color.green / 255,color.blue / 255);
- return guibuffer;
- break;
- default:
- strcpy(guibuffer,gtk_entry_get_text((GtkEntry *) att->attrWidget));
- return guibuffer;
+ switch (att->Type) {
+ case 'F':
+ sprintf(guibuffer, "%f",
+ gtk_spin_button_get_value((GtkSpinButton *) att->
+ attrWidget));
+ return guibuffer;
+ break;
+ case 'C':
+ gtk_color_button_get_color((GtkColorButton *) att->attrWidget,
+ &color);
+ sprintf(guibuffer, "#%x%x%x", color.red / 255, color.green / 255,
+ color.blue / 255);
+ return guibuffer;
+ break;
+ default:
+ strcpy(guibuffer,
+ gtk_entry_get_text((GtkEntry *) att->attrWidget));
+ return guibuffer;
}
}
void change_selected_graph_attributes(Agraph_t * g, char *attrname,
char *attrvalue)
{
agattr(g, AGRAPH, attrname, "");
- agset(view->g[view->activeGraph],attrname,attrvalue);
+ agset(view->g[view->activeGraph], attrname, attrvalue);
}
{
int ind = 0;
agattr(g, AGNODE, attrname, "");
- for (ind = 0; ind < view->Topview->Nodecount; ind++)
- {
- if (view->Topview->Nodes[ind].data.Selected==1)
- agset(view->Topview->Nodes[ind].Node, attrname, attrvalue);
+ for (ind = 0; ind < view->Topview->Nodecount; ind++) {
+ if (view->Topview->Nodes[ind].data.Selected == 1)
+ agset(view->Topview->Nodes[ind].Node, attrname, attrvalue);
}
}
void change_selected_edge_attributes(Agraph_t * g, char *attrname,
int ind = 0;
agattr(g, AGEDGE, attrname, "");
- for (ind = 0; ind < view->Topview->Edgecount; ind++)
- {
- if (view->Topview->Edges[ind].data.Selected==1)
- agset(view->Topview->Edges[ind].Edge, attrname, attrvalue);
+ for (ind = 0; ind < view->Topview->Edgecount; ind++) {
+ if (view->Topview->Edges[ind].data.Selected == 1)
+ agset(view->Topview->Edges[ind].Edge, attrname, attrvalue);
}
}
char *pch;
int ind = 0;
int attrcount = 0;
- static char* smyrna_attrs;
+ static char *smyrna_attrs;
if (!smyrna_attrs) {
- smyrna_attrs = smyrnaPath ("attrs.txt");
+ smyrna_attrs = smyrnaPath("attrs.txt");
}
-
//loads attributes from a text file
file = fopen(smyrna_attrs, "r");
- if (file != NULL)
- {
- while (fgets(line, sizeof line, file) != NULL)
- {
- pch = strtok(line, ",");
- ind = 0;
- while (pch != NULL)
- {
- ss = strdup(pch);
- // ABRemove(&ss,'\"');
- // ABRemove(&ss,' ');
- pch = strtok(NULL, ",");
- switch (ind)
- {
- case 0:
- attr[attrcount].Type = ss[0];
- break;
- case 1:
- attr[attrcount].Name = strdup(ss);
- break;
- case 2:
- attr[attrcount].Default = strdup(ss);
- break;
- case 3:
- if (strstr(ss, "ANY_ELEMENT"))
- {
- attr[attrcount].ApplyTo[GVE_GRAPH] = 1;
- attr[attrcount].ApplyTo[GVE_CLUSTER] = 1;
- attr[attrcount].ApplyTo[GVE_NODE] = 1;
- attr[attrcount].ApplyTo[GVE_EDGE] = 1;
- }
- else
- {
- attr[attrcount].ApplyTo[GVE_GRAPH] =
- strstr(ss, "GRAPH") ? 1 : 0;
- attr[attrcount].ApplyTo[GVE_CLUSTER] =
- strstr(ss, "CLUSTER") ? 1 : 0;
- attr[attrcount].ApplyTo[GVE_NODE] =
- strstr(ss, "NODE") ? 1 : 0;
- attr[attrcount].ApplyTo[GVE_EDGE] =
- strstr(ss, "EDGE") ? 1 : 0;
- }
- break;
- case 4:
- if (strstr(ss, "ALL_ENGINES"))
- {
- attr[attrcount].Engine[GVK_DOT] = 1;
- attr[attrcount].Engine[GVK_NEATO] = 1;
- attr[attrcount].Engine[GVK_TWOPI] = 1;
- attr[attrcount].Engine[GVK_CIRCO] = 1;
- attr[attrcount].Engine[GVK_FDP] = 1;
- }
- else
- {
- attr[attrcount].Engine[GVK_DOT] =
- strstr(ss, "DOT") ? 1 : 0;
- attr[attrcount].Engine[GVK_NEATO] =
- strstr(ss, "NEATO") ? 1 : 0;
- attr[attrcount].Engine[GVK_TWOPI] =
- strstr(ss, "TWOPI") ? 1 : 0;
- attr[attrcount].Engine[GVK_CIRCO] =
- strstr(ss, "CIRCO") ? 1 : 0;
- attr[attrcount].Engine[GVK_FDP] =
- strstr(ss, "FDP") ? 1 : 0;
- }
- break;
- default:
- attr[attrcount].ComboValues =RALLOC(attr[attrcount].ComboValuesCount, attr[attrcount].ComboValues, char*);
- attr[attrcount].ComboValues[attr[attrcount].ComboValuesCount] = strdup(ss);
- attr[attrcount].ComboValuesCount++;
- break;
- }
- ind++;
- }
- attrcount++;
+ if (file != NULL) {
+ while (fgets(line, sizeof line, file) != NULL) {
+ pch = strtok(line, ",");
+ ind = 0;
+ while (pch != NULL) {
+ ss = strdup(pch);
+ // ABRemove(&ss,'\"');
+ // ABRemove(&ss,' ');
+ pch = strtok(NULL, ",");
+ switch (ind) {
+ case 0:
+ attr[attrcount].Type = ss[0];
+ break;
+ case 1:
+ attr[attrcount].Name = strdup(ss);
+ break;
+ case 2:
+ attr[attrcount].Default = strdup(ss);
+ break;
+ case 3:
+ if (strstr(ss, "ANY_ELEMENT")) {
+ attr[attrcount].ApplyTo[GVE_GRAPH] = 1;
+ attr[attrcount].ApplyTo[GVE_CLUSTER] = 1;
+ attr[attrcount].ApplyTo[GVE_NODE] = 1;
+ attr[attrcount].ApplyTo[GVE_EDGE] = 1;
+ } else {
+ attr[attrcount].ApplyTo[GVE_GRAPH] =
+ strstr(ss, "GRAPH") ? 1 : 0;
+ attr[attrcount].ApplyTo[GVE_CLUSTER] =
+ strstr(ss, "CLUSTER") ? 1 : 0;
+ attr[attrcount].ApplyTo[GVE_NODE] =
+ strstr(ss, "NODE") ? 1 : 0;
+ attr[attrcount].ApplyTo[GVE_EDGE] =
+ strstr(ss, "EDGE") ? 1 : 0;
+ }
+ break;
+ case 4:
+ if (strstr(ss, "ALL_ENGINES")) {
+ attr[attrcount].Engine[GVK_DOT] = 1;
+ attr[attrcount].Engine[GVK_NEATO] = 1;
+ attr[attrcount].Engine[GVK_TWOPI] = 1;
+ attr[attrcount].Engine[GVK_CIRCO] = 1;
+ attr[attrcount].Engine[GVK_FDP] = 1;
+ } else {
+ attr[attrcount].Engine[GVK_DOT] =
+ strstr(ss, "DOT") ? 1 : 0;
+ attr[attrcount].Engine[GVK_NEATO] =
+ strstr(ss, "NEATO") ? 1 : 0;
+ attr[attrcount].Engine[GVK_TWOPI] =
+ strstr(ss, "TWOPI") ? 1 : 0;
+ attr[attrcount].Engine[GVK_CIRCO] =
+ strstr(ss, "CIRCO") ? 1 : 0;
+ attr[attrcount].Engine[GVK_FDP] =
+ strstr(ss, "FDP") ? 1 : 0;
+ }
+ break;
+ default:
+ attr[attrcount].ComboValues =
+ RALLOC(attr[attrcount].ComboValuesCount,
+ attr[attrcount].ComboValues, char *);
+ attr[attrcount].ComboValues[attr[attrcount].
+ ComboValuesCount] =
+ strdup(ss);
+ attr[attrcount].ComboValuesCount++;
+ break;
}
+ ind++;
+ }
+ attrcount++;
+ }
}
}
-void show_gui_warning (char* str)
+void show_gui_warning(char *str)
{
- Dlg = (GtkMessageDialog *) gtk_message_dialog_new(NULL,
- GTK_DIALOG_MODAL,
- GTK_MESSAGE_WARNING,
- GTK_BUTTONS_OK,
- str);
+ Dlg = (GtkMessageDialog *) gtk_message_dialog_new(NULL,
+ GTK_DIALOG_MODAL,
+ GTK_MESSAGE_WARNING,
+ GTK_BUTTONS_OK, str);
- respond = gtk_dialog_run((GtkDialog *) Dlg);
- gtk_object_destroy((GtkObject *) Dlg);
+ respond = gtk_dialog_run((GtkDialog *) Dlg);
+ gtk_object_destroy((GtkObject *) Dlg);
}
Generic Open File dialog, if a file is selected and return value is 1, else 0
file name is copied to char* filename,which should be allocated before using the function
*/
-int openfiledlg(int filtercnt,char** filters,agxbuf* xbuf)
+int openfiledlg(int filtercnt, char **filters, agxbuf * xbuf)
{
GtkWidget *dialog;
GtkFileFilter *filter;
- int id,rv;
+ int id, rv;
filter = gtk_file_filter_new();
- if(filtercnt >= 1)
- {
- for (id=0;id < filtercnt; id ++)
- {
- gtk_file_filter_add_pattern(filter, filters[id]);
- }
+ if (filtercnt >= 1) {
+ for (id = 0; id < filtercnt; id++) {
+ gtk_file_filter_add_pattern(filter, filters[id]);
}
-
+ }
+
dialog = gtk_file_chooser_dialog_new("Open File",
NULL,
GTK_FILE_CHOOSER_ACTION_OPEN,
GTK_STOCK_OPEN,
GTK_RESPONSE_ACCEPT, NULL);
- if(filtercnt >= 1)
- gtk_file_chooser_set_filter((GtkFileChooser *) dialog, filter);
- if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT)
- {
- agxbput (xbuf, gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog)));
- rv=1;
- }
- else
- rv=0;
+ if (filtercnt >= 1)
+ gtk_file_chooser_set_filter((GtkFileChooser *) dialog, filter);
+ if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) {
+ agxbput(xbuf,
+ gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog)));
+ rv = 1;
+ } else
+ rv = 0;
- gtk_widget_destroy(dialog);
- return rv;
+ gtk_widget_destroy(dialog);
+ return rv;
}
-int savefiledlg(int filtercnt,char** filters,agxbuf* xbuf)
+int savefiledlg(int filtercnt, char **filters, agxbuf * xbuf)
{
GtkWidget *dialog;
GtkFileFilter *filter;
- int id,rv;
+ int id, rv;
filter = gtk_file_filter_new();
- if(filtercnt >= 1)
- {
- for (id=0;id < filtercnt; id ++)
- {
- gtk_file_filter_add_pattern(filter, filters[id]);
- }
+ if (filtercnt >= 1) {
+ for (id = 0; id < filtercnt; id++) {
+ gtk_file_filter_add_pattern(filter, filters[id]);
}
-
+ }
+
dialog = gtk_file_chooser_dialog_new("Save File",
NULL,
GTK_FILE_CHOOSER_ACTION_OPEN,
GTK_STOCK_OPEN,
GTK_RESPONSE_ACCEPT, NULL);
- if(filtercnt >= 1)
- gtk_file_chooser_set_filter((GtkFileChooser *) dialog, filter);
- if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT)
- {
- agxbput (xbuf, gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog)));
- rv=1;
- }
- else
- rv=0;
+ if (filtercnt >= 1)
+ gtk_file_chooser_set_filter((GtkFileChooser *) dialog, filter);
+ if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) {
+ agxbput(xbuf,
+ gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog)));
+ rv = 1;
+ } else
+ rv = 0;
- gtk_widget_destroy(dialog);
- return rv;
+ gtk_widget_destroy(dialog);
+ return rv;
}
+
/*
this function is designed to return a GtkTextView object's text in agxbuf
send an initialized agxbuf and a GtkTextView object
null termination is taken care by agxbuf
*/
-void get_gtktextview_text(GtkTextView* w,agxbuf* xbuf)
+void get_gtktextview_text(GtkTextView * w, agxbuf * xbuf)
{
- int charcnt;
- GtkTextBuffer * gtkbuf;
- GtkTextIter startit;
- GtkTextIter endit;
- gtkbuf=gtk_text_view_get_buffer(w);
- charcnt=gtk_text_buffer_get_char_count (gtkbuf);
- gtk_text_buffer_get_start_iter (gtkbuf,&startit);
- gtk_text_buffer_get_end_iter (gtkbuf,&endit);
-
- agxbput (xbuf,gtk_text_buffer_get_text(gtkbuf,&startit,&endit,0));
+ int charcnt;
+ GtkTextBuffer *gtkbuf;
+ GtkTextIter startit;
+ GtkTextIter endit;
+ gtkbuf = gtk_text_view_get_buffer(w);
+ charcnt = gtk_text_buffer_get_char_count(gtkbuf);
+ gtk_text_buffer_get_start_iter(gtkbuf, &startit);
+ gtk_text_buffer_get_end_iter(gtkbuf, &endit);
+
+ agxbput(xbuf, gtk_text_buffer_get_text(gtkbuf, &startit, &endit, 0));
}
-void append_textview(GtkTextView* textv, const char* s, size_t bytes)
+void append_textview(GtkTextView * textv, const char *s, size_t bytes)
{
GtkTextIter endit;
- GtkTextBuffer * gtkbuf;
- /*get text view buffer*/
- gtkbuf = gtk_text_view_get_buffer(textv);
- /*set iterator to the end of the buffer*/
- gtk_text_buffer_get_end_iter (gtkbuf,&endit);
- /* insert buf to the end */
- gtk_text_buffer_insert(gtkbuf,&endit,s,bytes);
+ GtkTextBuffer *gtkbuf;
+ /*get text view buffer */
+ gtkbuf = gtk_text_view_get_buffer(textv);
+ /*set iterator to the end of the buffer */
+ gtk_text_buffer_get_end_iter(gtkbuf, &endit);
+ /* insert buf to the end */
+ gtk_text_buffer_insert(gtkbuf, &endit, s, bytes);
}
-
-
#include <glade/glade.h>
#include "callbacks.h"
#include "cgraph.h"
-#include <agxbuf.h>
-
-
+#include <agxbuf.h>
#define MAXIMUM_WIDGET_COUNT 97
+#ifdef __cplusplus
+extern "C" {
+#endif
+
//GtkWidget *window1; //main window
-extern GdkWindow *window1;
-extern GtkWidget *statusbar1;
-
-extern GladeXML *xml; //global libglade vars
-extern GtkWidget *gladewidget;
-
-extern gve_element frmObjectTypeIndex;
-extern Agraph_t *frmObjectg;
-
-extern GtkComboBox *cbSelectGraph; //combo at top left
-
-extern GtkWidget *AttrWidgets[MAXIMUM_WIDGET_COUNT];
-extern GtkWidget *AttrLabels[MAXIMUM_WIDGET_COUNT];
-extern int attr_widgets_modified[MAXIMUM_WIDGET_COUNT];
-extern int widgetcounter; //number of attributes counted dynamically, might be removed in the future
-extern attribute attr[MAXIMUM_WIDGET_COUNT];
-
-
-void create_object_properties(void); //creates general purpose object properties template
-void object_properties_node_init(void); //customize window for Nodes
-void object_properties_edge_init(void); //customize window for Edges
-void object_properties_cluster_init(void); //customize window for Cluster
-void object_properties_graph_init(void); //customize window for Graph , this shows the graph default values
-void graph_properties_init(int newgraph); //initialize little open graph dialog
-GtkComboBox *get_SelectGraph(void); //freaking GLADE!!!!!
-int update_graph_properties(Agraph_t * graph); //updates graph from gui
-void load_graph_properties(Agraph_t * graph); //load from graph to gui
-
-void update_object_properties(int typeIndex, Agraph_t * g); //updates objects from gui(node ,edge, cluster)
-int load_object_properties(gve_element typeIndex, Agraph_t * g);
-void load_attributes(void); //loads attributes from a text file
-void change_selected_graph_attributes(Agraph_t * g, char *attrname,
- char *attrvalue);
-void change_selected_node_attributes(Agraph_t * g, char *attrname,
- char *attrvalue);
-void change_selected_edge_attributes(Agraph_t * g, char *attrname,
- char *attrvalue);
-char *get_attribute_string_value_from_widget(attribute * att);
+ extern GdkWindow *window1;
+ extern GtkWidget *statusbar1;
+
+ extern GladeXML *xml; //global libglade vars
+ extern GtkWidget *gladewidget;
+
+ extern gve_element frmObjectTypeIndex;
+ extern Agraph_t *frmObjectg;
+
+ extern GtkComboBox *cbSelectGraph; //combo at top left
+
+ extern GtkWidget *AttrWidgets[MAXIMUM_WIDGET_COUNT];
+ extern GtkWidget *AttrLabels[MAXIMUM_WIDGET_COUNT];
+ extern int attr_widgets_modified[MAXIMUM_WIDGET_COUNT];
+ extern int widgetcounter; //number of attributes counted dynamically, might be removed in the future
+ extern attribute attr[MAXIMUM_WIDGET_COUNT];
+
+
+ void create_object_properties(void); //creates general purpose object properties template
+ void object_properties_node_init(void); //customize window for Nodes
+ void object_properties_edge_init(void); //customize window for Edges
+ void object_properties_cluster_init(void); //customize window for Cluster
+ void object_properties_graph_init(void); //customize window for Graph , this shows the graph default values
+ void graph_properties_init(int newgraph); //initialize little open graph dialog
+ GtkComboBox *get_SelectGraph(void); //freaking GLADE!!!!!
+ int update_graph_properties(Agraph_t * graph); //updates graph from gui
+ void load_graph_properties(Agraph_t * graph); //load from graph to gui
+
+ void update_object_properties(int typeIndex, Agraph_t * g); //updates objects from gui(node ,edge, cluster)
+ int load_object_properties(gve_element typeIndex, Agraph_t * g);
+ void load_attributes(void); //loads attributes from a text file
+ void change_selected_graph_attributes(Agraph_t * g, char *attrname,
+ char *attrvalue);
+ void change_selected_node_attributes(Agraph_t * g, char *attrname,
+ char *attrvalue);
+ void change_selected_edge_attributes(Agraph_t * g, char *attrname,
+ char *attrvalue);
+ char *get_attribute_string_value_from_widget(attribute * att);
//GTK helpre functions
//void Color_Widget_bg (int r, int g, int b, GtkWidget *widget); //change background color
-void Color_Widget_bg(char *colorstring, GtkWidget * widget);
+ void Color_Widget_bg(char *colorstring, GtkWidget * widget);
/*generic warning pop up*/
-void show_gui_warning (char* str);
+ void show_gui_warning(char *str);
/*generic open file dialog*/
-int openfiledlg(int filtercnt,char** filters,agxbuf* xbuf);
+ int openfiledlg(int filtercnt, char **filters, agxbuf * xbuf);
/*generic save file dialog*/
-int savefiledlg(int filtercnt,char** filters,agxbuf* xbuf);
-void append_textview(GtkTextView* textv, const char* s, size_t bytes);
+ int savefiledlg(int filtercnt, char **filters, agxbuf * xbuf);
+ void append_textview(GtkTextView * textv, const char *s, size_t bytes);
+
+#ifdef __cplusplus
+} /* end extern "C" */
+#endif
#endif
#include "topviewsettings.h"
#include "gltemplate.h"
#include "memory.h"
-#include <const.h>
-#include <agxbuf.h>
-#include <assert.h>
-#include <ctype.h>
+#include <const.h>
+#include <agxbuf.h>
+#include <assert.h>
+#include <ctype.h>
//file
char buf[255];
{
GtkWidget *dialog;
GtkFileFilter *filter;
- int i=0;
+ int i = 0;
filter = gtk_file_filter_new();
gtk_file_filter_add_pattern(filter, "*.gv");
/* if (view->activeGraph == 0)
close_graph(view,0);*/
- i=view->SignalBlock;
- view->SignalBlock=1;
+ i = view->SignalBlock;
+ view->SignalBlock = 1;
add_graph_to_viewport_from_file(filename);
g_free(filename);
- view->SignalBlock=i;
+ view->SignalBlock = i;
- }
+ }
gtk_widget_destroy(dialog);
}
{
save_as_graph(); //save with prompt
}
+
void mCloseSlot(GtkWidget * widget, gpointer user_data)
{
- if (view->activeGraph == 0)
- close_graph(view,0);
+ if (view->activeGraph == 0)
+ close_graph(view, 0);
}
void mOptionsSlot(GtkWidget * widget, gpointer user_data)
void mQuitSlot(GtkWidget * widget, gpointer user_data)
{
- if (close_graph(view,view->activeGraph));
- gtk_main_quit();
+ if (close_graph(view, view->activeGraph));
+ gtk_main_quit();
}
int show_close_nosavedlg(void)
{
- GtkWidget *dialog;
- char buf[512];
- int rv; /*return value*/
- sprintf(buf,"%s has been modified. Do you want to save it before closing?",view->Topview->Graphdata.GraphFileName);
- dialog = gtk_message_dialog_new(NULL,
- GTK_DIALOG_MODAL,
- GTK_MESSAGE_QUESTION,
- GTK_BUTTONS_NONE,
- buf);
-
- gtk_window_set_title(GTK_WINDOW(dialog), "Smyrna Warning");
- gtk_dialog_add_button((GtkDialog*)dialog,"Yes",0);
- gtk_dialog_add_button((GtkDialog*)dialog,"No",1);
- gtk_dialog_add_button((GtkDialog*)dialog,"Cancel",2);
- rv=gtk_dialog_run(GTK_DIALOG(dialog));
- gtk_widget_destroy(dialog);
- return rv;
+ GtkWidget *dialog;
+ char buf[512];
+ int rv; /*return value */
+ sprintf(buf,
+ "%s has been modified. Do you want to save it before closing?",
+ view->Topview->Graphdata.GraphFileName);
+ dialog =
+ gtk_message_dialog_new(NULL, GTK_DIALOG_MODAL,
+ GTK_MESSAGE_QUESTION, GTK_BUTTONS_NONE,
+ buf);
+
+ gtk_window_set_title(GTK_WINDOW(dialog), "Smyrna Warning");
+ gtk_dialog_add_button((GtkDialog *) dialog, "Yes", 0);
+ gtk_dialog_add_button((GtkDialog *) dialog, "No", 1);
+ gtk_dialog_add_button((GtkDialog *) dialog, "Cancel", 2);
+ rv = gtk_dialog_run(GTK_DIALOG(dialog));
+ gtk_widget_destroy(dialog);
+ return rv;
}
{
-if(!gtk_widget_set_gl_capability (glade_xml_get_widget(xml, "glfixed"), configure_gl(),gtk_widget_get_gl_context(view->drawing_area),0,0))
+ if (!gtk_widget_set_gl_capability
+ (glade_xml_get_widget(xml, "glfixed"), configure_gl(),
+ gtk_widget_get_gl_context(view->drawing_area), 0, 0))
printf("glwidget creation failed \n");
-
+
}
void mMenuPan(GtkWidget * widget, gpointer user_data)
{
- view->mouse.mouse_mode = MM_PAN;
+ view->mouse.mouse_mode = MM_PAN;
}
+
void mMenuZoom(GtkWidget * widget, gpointer user_data)
{
- view->mouse.mouse_mode = MM_ZOOM;
+ view->mouse.mouse_mode = MM_ZOOM;
}
+
void mShowConsoleSlot(GtkWidget * widget, gpointer user_data)
{
gtk_widget_show(glade_xml_get_widget(xml, "vbox13"));
}
+
void mHideConsoleSlot(GtkWidget * widget, gpointer user_data)
{
gtk_widget_hide(glade_xml_get_widget(xml, "vbox13"));
glade_xml_get_widget(xml,
"dlgOpenGraph"),
2, 1);
- respond =
- gtk_dialog_run((GtkDialog *)
- glade_xml_get_widget(xml, "dlgOpenGraph"));
+ respond = gtk_dialog_run((GtkDialog *)
+ glade_xml_get_widget(xml,
+ "dlgOpenGraph"));
//need to hide the dialog , again freaking GTK!!!!
gtk_widget_hide(glade_xml_get_widget(xml, "dlgOpenGraph"));
}
void mNodeFindSlot(GtkWidget * widget, gpointer user_data)
{
- if(view->activeGraph !=-1)
- {
-
- gtk_dialog_set_response_sensitive((GtkDialog *)
- glade_xml_get_widget(xml,
- "findDialog"),
- 1, 1);
- gtk_dialog_set_response_sensitive((GtkDialog *)
- glade_xml_get_widget(xml,
- "findDialog"),
- 2, 1);
-
-
- respond =
- gtk_dialog_run((GtkDialog *)
- glade_xml_get_widget(xml, "findDialog"));
-
- gtk_widget_hide(glade_xml_get_widget(xml, "findDialog"));
- if (respond ==1)
- select_with_regex((gchar*)
- gtk_entry_get_text((GtkEntry*) glade_xml_get_widget(xml,"findText"))
- );
- }
+ if (view->activeGraph != -1) {
+
+ gtk_dialog_set_response_sensitive((GtkDialog *)
+ glade_xml_get_widget(xml,
+ "findDialog"),
+ 1, 1);
+ gtk_dialog_set_response_sensitive((GtkDialog *)
+ glade_xml_get_widget(xml,
+ "findDialog"),
+ 2, 1);
+
+
+ respond = gtk_dialog_run((GtkDialog *)
+ glade_xml_get_widget(xml, "findDialog"));
+
+ gtk_widget_hide(glade_xml_get_widget(xml, "findDialog"));
+ if (respond == 1)
+ select_with_regex((gchar *)
+ gtk_entry_get_text((GtkEntry *)
+ glade_xml_get_widget(xml,
+ "findText"))
+ );
+ }
}
static void mPropertiesSlot(gve_element element)
{
- if (view->activeGraph >=0 )
+ if (view->activeGraph >= 0)
gtk_widget_hide(glade_xml_get_widget(xml, "frmObject"));
- gtk_widget_show(glade_xml_get_widget(xml, "frmObject"));
-// load_object_properties(element, view->g[view->activeGraph]);
+ gtk_widget_show(glade_xml_get_widget(xml, "frmObject"));
+// load_object_properties(element, view->g[view->activeGraph]);
}
+
void mClusterPropertiesSlot(GtkWidget * widget, gpointer user_data)
{
- mPropertiesSlot (GVE_CLUSTER);
+ mPropertiesSlot(GVE_CLUSTER);
}
+
void mNodePropertiesSlot(GtkWidget * widget, gpointer user_data)
{
- mPropertiesSlot (GVE_NODE);
+ mPropertiesSlot(GVE_NODE);
}
+
void mEdgePropertiesSlot(GtkWidget * widget, gpointer user_data)
{
- mPropertiesSlot (GVE_EDGE);
+ mPropertiesSlot(GVE_EDGE);
}
void mShowCodeSlot(GtkWidget * widget, gpointer user_data)
{
}
-static void mSlot (GtkWidget * widget, gpointer user_data, gvk_layout layout, int doCursor)
+static void mSlot(GtkWidget * widget, gpointer user_data,
+ gvk_layout layout, int doCursor)
{
/* GdkCursor *cursor; */
/* GdkWindow *w; */
if (respond == GTK_RESPONSE_YES)
do_graph_layout(view->g[view->activeGraph], layout, 0);
gtk_object_destroy((GtkObject *) Dlg);*/
- return;
+ return;
}
void mDotSlot(GtkWidget * widget, gpointer user_data)
{
- mSlot (widget, user_data, GVK_DOT, 1);
+ mSlot(widget, user_data, GVK_DOT, 1);
}
void mNeatoSlot(GtkWidget * widget, gpointer user_data)
{
- mSlot (widget, user_data, GVK_NEATO, 0);
+ mSlot(widget, user_data, GVK_NEATO, 0);
}
void mTwopiSlot(GtkWidget * widget, gpointer user_data)
{
- mSlot (widget, user_data, GVK_TWOPI, 0);
+ mSlot(widget, user_data, GVK_TWOPI, 0);
}
void mCircoSlot(GtkWidget * widget, gpointer user_data)
{
- mSlot (widget, user_data, GVK_CIRCO, 0);
+ mSlot(widget, user_data, GVK_CIRCO, 0);
}
void mFdpSlot(GtkWidget * widget, gpointer user_data)
{
- mSlot (widget, user_data, GVK_FDP, 0);
+ mSlot(widget, user_data, GVK_FDP, 0);
}
void mSfdpSlot(GtkWidget * widget, gpointer user_data)
{
- mSlot (widget, user_data, GVK_SFDP, 0);
+ mSlot(widget, user_data, GVK_SFDP, 0);
}
{
GdkCursor *cursor;
- GdkWindow * w;
+ GdkWindow *w;
cursor = gdk_cursor_new(C);
w = (GdkWindow *) glade_xml_get_widget(xml, "frmMain");
- gdk_window_set_cursor((GdkWindow *) view->drawing_area->window, cursor);
+ gdk_window_set_cursor((GdkWindow *) view->drawing_area->window,
+ cursor);
gdk_cursor_destroy(cursor);
}
#if OLD
-static const char*
-endQuote (const char* args, agxbuf* xb, char endc)
+static const char *endQuote(const char *args, agxbuf * xb, char endc)
{
int more = 1;
char c;
while (more) {
c = *args++;
- if (c == endc) more = 0;
+ if (c == endc)
+ more = 0;
else if (c == '\0') {
more = 0;
args--;
- }
- else if (c == '\\') {
+ } else if (c == '\\') {
c = *args++;
- if (c == '\0') args--;
- else agxbputc (xb,c);
- }
- else
- agxbputc (xb,c);
+ if (c == '\0')
+ args--;
+ else
+ agxbputc(xb, c);
+ } else
+ agxbputc(xb, c);
}
return args;
}
-static const char*
-skipWS (const char* args)
+static const char *skipWS(const char *args)
{
char c;
while ((c = *args)) {
- if (isspace(c)) args++;
- else break;
+ if (isspace(c))
+ args++;
+ else
+ break;
}
return args;
}
-static const char*
-getTok (const char* args, agxbuf* xb)
+static const char *getTok(const char *args, agxbuf * xb)
{
char c;
int more = 1;
args = skipWS(args);
- if (*args == '\0') return 0;
+ if (*args == '\0')
+ return 0;
while (more) {
c = *args++;
- if (isspace(c)) more = 0;
+ if (isspace(c))
+ more = 0;
else if (c == '\0') {
more = 0;
args--;
- }
- else if ((c == '"') || (c == '\'')) {
- args = endQuote (args, xb, c);
- }
- else if (c == '\\') {
+ } else if ((c == '"') || (c == '\'')) {
+ args = endQuote(args, xb, c);
+ } else if (c == '\\') {
c = *args++;
- if (c == '\0') args--;
- else agxbputc (xb,c);
- }
- else
- agxbputc (xb,c);
+ if (c == '\0')
+ args--;
+ else
+ agxbputc(xb, c);
+ } else
+ agxbputc(xb, c);
}
return args;
}
-static char**
-splitArgs (const char* args, int* argcp)
+static char **splitArgs(const char *args, int *argcp)
{
- char** argv;
+ char **argv;
int argc;
int asize;
agxbuf xbuf;
asize = 0;
argv = 0;
agxbinit(&xbuf, SMALLBUF, buf);
- while ((args = getTok (args, &xbuf))) {
+ while ((args = getTok(args, &xbuf))) {
if (asize <= argc) {
asize += 10;
- argv = ALLOC(asize,argv,char*);
+ argv = ALLOC(asize, argv, char *);
}
argv[argc++] = strdup(agxbuse(&xbuf));
}
- agxbfree (&xbuf);
+ agxbfree(&xbuf);
*argcp = argc;
return argv;
}
void mTestgvpr(GtkWidget * widget, gpointer user_data)
{
- char* bf2;
- GtkTextBuffer * gtkbuf;
+ char *bf2;
+ GtkTextBuffer *gtkbuf;
GtkTextIter startit;
GtkTextIter endit;
- const char* args;
+ const char *args;
int i, j, argc, cloneGraph;
- char** argv;
+ char **argv;
#if OLD
- char** inargv;
+ char **inargv;
int inargc;
#endif
- args = gtk_entry_get_text ((GtkEntry *)glade_xml_get_widget(xml, "gvprargs"));
- gtkbuf = gtk_text_view_get_buffer((GtkTextView*) glade_xml_get_widget(xml,"gvprtextinput"));
- gtk_text_buffer_get_start_iter (gtkbuf,&startit);
- gtk_text_buffer_get_end_iter (gtkbuf,&endit);
- bf2 = gtk_text_buffer_get_text(gtkbuf,&startit,&endit,0);
+ args =
+ gtk_entry_get_text((GtkEntry *)
+ glade_xml_get_widget(xml, "gvprargs"));
+ gtkbuf =
+ gtk_text_view_get_buffer((GtkTextView *)
+ glade_xml_get_widget(xml,
+ "gvprtextinput"));
+ gtk_text_buffer_get_start_iter(gtkbuf, &startit);
+ gtk_text_buffer_get_end_iter(gtkbuf, &endit);
+ bf2 = gtk_text_buffer_get_text(gtkbuf, &startit, &endit, 0);
if ((*args == '\0') && (*bf2 == '\0'))
- return;
+ return;
#if OLD
- inargv = splitArgs (args, &inargc);
+ inargv = splitArgs(args, &inargc);
argc = inargc + 1;
#else
argc = 1;
- if (*args != '\0') argc += 2;
+ if (*args != '\0')
+ argc += 2;
#endif
- if (*bf2 != '\0') argc++;
- if (gtk_toggle_button_get_active((GtkToggleButton *) glade_xml_get_widget(xml, "gvprapplycb"))) {
+ if (*bf2 != '\0')
+ argc++;
+ if (gtk_toggle_button_get_active
+ ((GtkToggleButton *) glade_xml_get_widget(xml, "gvprapplycb"))) {
cloneGraph = 1;
argc++;
- }
- else
+ } else
cloneGraph = 0;
- argv = N_NEW(argc+1, char*);
+ argv = N_NEW(argc + 1, char *);
j = 0;
argv[j++] = "smyrna";
if (cloneGraph)
- argv[j++] = strdup ("-C");
+ argv[j++] = strdup("-C");
#if OLD
for (i = 0; i < inargc; i++)
argv[j++] = inargv[i];
- free (inargv);
+ free(inargv);
#else
if (*args != '\0') {
- argv[j++] = strdup ("-a");
- argv[j++] = strdup (args);
+ argv[j++] = strdup("-a");
+ argv[j++] = strdup(args);
}
#endif
if (*bf2 != '\0') {
argv[j++] = strdup(bf2);
- g_free (bf2);
+ g_free(bf2);
}
- assert (j == argc);
+ assert(j == argc);
- run_gvpr (view->g[view->activeGraph], argc, argv);
+ run_gvpr(view->g[view->activeGraph], argc, argv);
for (i = 1; i < argc; i++)
- free (argv[i]);
- free (argv);
+ free(argv[i]);
+ free(argv);
}
opens a file open dialog and load a gvpr program to gvpr script text box
if the current script is modified, user should be informed about it
*/
-void
-on_gvprbuttonload_clicked(GtkWidget * widget, gpointer user_data)
+void on_gvprbuttonload_clicked(GtkWidget * widget, gpointer user_data)
{
- FILE *input_file=NULL;
- char* str;
+ FILE *input_file = NULL;
+ char *str;
agxbuf xbuf;
- GtkTextBuffer * gtkbuf; /*GTK buffer from glade GUI*/
+ GtkTextBuffer *gtkbuf; /*GTK buffer from glade GUI */
char buf[BUFSIZ];
unsigned char xbuffer[BUFSIZ];
- agxbinit (&xbuf, SMALLBUF, xbuffer);
-
- /*file name should be returned in xbuf*/
- if (openfiledlg(0,NULL,&xbuf))
- {
- input_file = fopen(agxbuse (&xbuf), "r");
- if (input_file)
- {
- while (fgets(buf, BUFSIZ, input_file))
- agxbput (&xbuf, buf);
- gtkbuf = gtk_text_view_get_buffer((GtkTextView*) glade_xml_get_widget(xml,"gvprtextinput"));
- str=agxbuse (&xbuf);
- if(g_utf8_validate(str,-1,NULL))
- {
- gtk_text_buffer_set_text (gtkbuf, str, -1);
- }
- else
- {
- show_gui_warning ("File format is not UTF8!");
- }
- fclose (input_file);
- }
- else
- {
- show_gui_warning ("file couldn't be opened\n");
+ agxbinit(&xbuf, SMALLBUF, xbuffer);
+
+ /*file name should be returned in xbuf */
+ if (openfiledlg(0, NULL, &xbuf)) {
+ input_file = fopen(agxbuse(&xbuf), "r");
+ if (input_file) {
+ while (fgets(buf, BUFSIZ, input_file))
+ agxbput(&xbuf, buf);
+ gtkbuf =
+ gtk_text_view_get_buffer((GtkTextView *)
+ glade_xml_get_widget(xml,
+ "gvprtextinput"));
+ str = agxbuse(&xbuf);
+ if (g_utf8_validate(str, -1, NULL)) {
+ gtk_text_buffer_set_text(gtkbuf, str, -1);
+ } else {
+ show_gui_warning("File format is not UTF8!");
+ }
+ fclose(input_file);
+ } else {
+ show_gui_warning("file couldn't be opened\n");
}
}
- agxbfree (&xbuf);
+ agxbfree(&xbuf);
}
/*
*/
void on_gvprbuttonsave_clicked(GtkWidget * widget, gpointer user_data)
{
- FILE *output_file=NULL;
- agxbuf xbuf;
- GtkTextBuffer * gtkbuf; /*GTK buffer from glade GUI*/
- int charcnt;
- char* bf2;
- GtkTextIter startit;
- GtkTextIter endit;
-
-
-
- agxbinit (&xbuf, SMALLBUF, NULL);
- /*file name should be returned in xbuf*/
- if(savefiledlg(0,NULL,&xbuf))
- {
- output_file = fopen(agxbuse (&xbuf), "w");
- if (output_file)
- {
- gtkbuf=gtk_text_view_get_buffer((GtkTextView*) glade_xml_get_widget(xml,"gvprtextinput"));
- charcnt=gtk_text_buffer_get_char_count (gtkbuf);
- gtk_text_buffer_get_start_iter (gtkbuf,&startit);
- gtk_text_buffer_get_end_iter (gtkbuf,&endit);
- bf2=gtk_text_buffer_get_text(gtkbuf,&startit,&endit,0);
- fprintf(output_file,"%s",bf2);
- fclose(output_file);
-
- }
-
-
- /*Code has not been completed for this function yet*/
+ FILE *output_file = NULL;
+ agxbuf xbuf;
+ GtkTextBuffer *gtkbuf; /*GTK buffer from glade GUI */
+ int charcnt;
+ char *bf2;
+ GtkTextIter startit;
+ GtkTextIter endit;
+
+
+
+ agxbinit(&xbuf, SMALLBUF, NULL);
+ /*file name should be returned in xbuf */
+ if (savefiledlg(0, NULL, &xbuf)) {
+ output_file = fopen(agxbuse(&xbuf), "w");
+ if (output_file) {
+ gtkbuf =
+ gtk_text_view_get_buffer((GtkTextView *)
+ glade_xml_get_widget(xml,
+ "gvprtextinput"));
+ charcnt = gtk_text_buffer_get_char_count(gtkbuf);
+ gtk_text_buffer_get_start_iter(gtkbuf, &startit);
+ gtk_text_buffer_get_end_iter(gtkbuf, &endit);
+ bf2 = gtk_text_buffer_get_text(gtkbuf, &startit, &endit, 0);
+ fprintf(output_file, "%s", bf2);
+ fclose(output_file);
+
}
-}
+ /*Code has not been completed for this function yet */
+ }
+
+}
#include "gui.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
//file
-_BB void mNewSlot(GtkWidget * widget, gpointer user_data);
-_BB void mOpenSlot(GtkWidget * widget, gpointer user_data);
-_BB void mSaveSlot(GtkWidget * widget, gpointer user_data);
-_BB void mSaveAsSlot(GtkWidget * widget, gpointer user_data);
-_BB void mCloseSlot(GtkWidget * widget, gpointer user_data);
-_BB void mOptionsSlot(GtkWidget * widget, gpointer user_data);
-_BB void mQuitSlot(GtkWidget * widget, gpointer user_data);
+ _BB void mNewSlot(GtkWidget * widget, gpointer user_data);
+ _BB void mOpenSlot(GtkWidget * widget, gpointer user_data);
+ _BB void mSaveSlot(GtkWidget * widget, gpointer user_data);
+ _BB void mSaveAsSlot(GtkWidget * widget, gpointer user_data);
+ _BB void mCloseSlot(GtkWidget * widget, gpointer user_data);
+ _BB void mOptionsSlot(GtkWidget * widget, gpointer user_data);
+ _BB void mQuitSlot(GtkWidget * widget, gpointer user_data);
//edit
-_BB void mCutSlot(GtkWidget * widget, gpointer user_data);
-_BB void mCopySlot(GtkWidget * widget, gpointer user_data);
-_BB void mPasteSlot(GtkWidget * widget, gpointer user_data);
-_BB void mDeleteSlot(GtkWidget * widget, gpointer user_data);
-_BB void mTopviewSettingsSlot(GtkWidget * widget, gpointer user_data);
-_BB void mNodeFindSlot(GtkWidget * widget, gpointer user_data);
+ _BB void mCutSlot(GtkWidget * widget, gpointer user_data);
+ _BB void mCopySlot(GtkWidget * widget, gpointer user_data);
+ _BB void mPasteSlot(GtkWidget * widget, gpointer user_data);
+ _BB void mDeleteSlot(GtkWidget * widget, gpointer user_data);
+ _BB void mTopviewSettingsSlot(GtkWidget * widget, gpointer user_data);
+ _BB void mNodeFindSlot(GtkWidget * widget, gpointer user_data);
//view
-_BB void mShowToolBoxSlot(GtkWidget * widget, gpointer user_data);
-_BB void mShowHostSelectionSlot(GtkWidget * widget, gpointer user_data);
-_BB void mMenuPan(GtkWidget * widget, gpointer user_data);
-_BB void mMenuZoom(GtkWidget * widget, gpointer user_data);
-_BB void mShowConsoleSlot(GtkWidget * widget, gpointer user_data);
-_BB void mHideConsoleSlot(GtkWidget * widget, gpointer user_data);
+ _BB void mShowToolBoxSlot(GtkWidget * widget, gpointer user_data);
+ _BB void mShowHostSelectionSlot(GtkWidget * widget,
+ gpointer user_data);
+ _BB void mMenuPan(GtkWidget * widget, gpointer user_data);
+ _BB void mMenuZoom(GtkWidget * widget, gpointer user_data);
+ _BB void mShowConsoleSlot(GtkWidget * widget, gpointer user_data);
+ _BB void mHideConsoleSlot(GtkWidget * widget, gpointer user_data);
//Graph
-_BB void mNodeListSlot(GtkWidget * widget, gpointer user_data);
-_BB void mNewNodeSlot(GtkWidget * widget, gpointer user_data);
-_BB void mNewEdgeSlot(GtkWidget * widget, gpointer user_data);
-_BB void mNewClusterSlot(GtkWidget * widget, gpointer user_data);
-_BB void mGraphPropertiesSlot(GtkWidget * widget, gpointer user_data);
-_BB void mClusterPropertiesSlot(GtkWidget * widget, gpointer user_data);
-_BB void mNodePropertiesSlot(GtkWidget * widget, gpointer user_data);
-_BB void mEdgePropertiesSlot(GtkWidget * widget, gpointer user_data);
-_BB void mShowCodeSlot(GtkWidget * widget, gpointer user_data);
-_BB void mDotSlot(GtkWidget * widget, gpointer user_data);
-_BB void mNeatoSlot(GtkWidget * widget, gpointer user_data);
-_BB void mTwopiSlot(GtkWidget * widget, gpointer user_data);
-_BB void mCircoSlot(GtkWidget * widget, gpointer user_data);
-_BB void mFdpSlot(GtkWidget * widget, gpointer user_data);
-_BB void mSfdpSlot(GtkWidget * widget, gpointer user_data);
+ _BB void mNodeListSlot(GtkWidget * widget, gpointer user_data);
+ _BB void mNewNodeSlot(GtkWidget * widget, gpointer user_data);
+ _BB void mNewEdgeSlot(GtkWidget * widget, gpointer user_data);
+ _BB void mNewClusterSlot(GtkWidget * widget, gpointer user_data);
+ _BB void mGraphPropertiesSlot(GtkWidget * widget, gpointer user_data);
+ _BB void mClusterPropertiesSlot(GtkWidget * widget,
+ gpointer user_data);
+ _BB void mNodePropertiesSlot(GtkWidget * widget, gpointer user_data);
+ _BB void mEdgePropertiesSlot(GtkWidget * widget, gpointer user_data);
+ _BB void mShowCodeSlot(GtkWidget * widget, gpointer user_data);
+ _BB void mDotSlot(GtkWidget * widget, gpointer user_data);
+ _BB void mNeatoSlot(GtkWidget * widget, gpointer user_data);
+ _BB void mTwopiSlot(GtkWidget * widget, gpointer user_data);
+ _BB void mCircoSlot(GtkWidget * widget, gpointer user_data);
+ _BB void mFdpSlot(GtkWidget * widget, gpointer user_data);
+ _BB void mSfdpSlot(GtkWidget * widget, gpointer user_data);
//select
-_BB void mSelectAllSlot(GtkWidget * widget, gpointer user_data);
-_BB void mUnselectAllSlot(GtkWidget * widget, gpointer user_data);
-_BB void mSelectAllNodesSlot(GtkWidget * widget, gpointer user_data);
-_BB void mSelectAllEdgesSlot(GtkWidget * widget, gpointer user_data);
-_BB void mSelectAllClustersSlot(GtkWidget * widget, gpointer user_data);
-_BB void mUnselectAllNodesSlot(GtkWidget * widget, gpointer user_data);
-_BB void mUnselectAllEdgesSlot(GtkWidget * widget, gpointer user_data);
-_BB void mUnselectAllClustersSlot(GtkWidget * widget, gpointer user_data);
-_BB void mSingleSelectSlot(GtkWidget * widget, gpointer user_data);
-_BB void mSelectAreaSlot(GtkWidget * widget, gpointer user_data);
-_BB void mSelectAreaXSlot(GtkWidget * widget, gpointer user_data);
+ _BB void mSelectAllSlot(GtkWidget * widget, gpointer user_data);
+ _BB void mUnselectAllSlot(GtkWidget * widget, gpointer user_data);
+ _BB void mSelectAllNodesSlot(GtkWidget * widget, gpointer user_data);
+ _BB void mSelectAllEdgesSlot(GtkWidget * widget, gpointer user_data);
+ _BB void mSelectAllClustersSlot(GtkWidget * widget,
+ gpointer user_data);
+ _BB void mUnselectAllNodesSlot(GtkWidget * widget, gpointer user_data);
+ _BB void mUnselectAllEdgesSlot(GtkWidget * widget, gpointer user_data);
+ _BB void mUnselectAllClustersSlot(GtkWidget * widget,
+ gpointer user_data);
+ _BB void mSingleSelectSlot(GtkWidget * widget, gpointer user_data);
+ _BB void mSelectAreaSlot(GtkWidget * widget, gpointer user_data);
+ _BB void mSelectAreaXSlot(GtkWidget * widget, gpointer user_data);
//help
-_BB void mAbout(GtkWidget * widget, gpointer user_data);
-_BB void mHelp(GtkWidget * widget, gpointer user_data);
-_BB void mTestgvpr(GtkWidget * widget, gpointer user_data);
-void change_cursor(GdkCursorType C);
-int show_close_nosavedlg(void);
+ _BB void mAbout(GtkWidget * widget, gpointer user_data);
+ _BB void mHelp(GtkWidget * widget, gpointer user_data);
+ _BB void mTestgvpr(GtkWidget * widget, gpointer user_data);
+ void change_cursor(GdkCursorType C);
+ int show_close_nosavedlg(void);
/*others from settings dialog*/
-_BB void on_gvprbuttonload_clicked(GtkWidget * widget, gpointer user_data);
-_BB void on_gvprbuttonsave_clicked(GtkWidget * widget, gpointer user_data);
+ _BB void on_gvprbuttonload_clicked(GtkWidget * widget,
+ gpointer user_data);
+ _BB void on_gvprbuttonsave_clicked(GtkWidget * widget,
+ gpointer user_data);
+#ifdef __cplusplus
+} /* end extern "C" */
+#endif
#endif
void btnToolSingleSelect_clicked(GtkWidget * widget, gpointer user_data)
{
deselect_all(view->g[view->activeGraph]);
- //gtk_toggle_tool_button_set_active ((GtkToggleToolButton*)widget,1);
- switch_Mouse(NULL, 3);
+ //gtk_toggle_tool_button_set_active ((GtkToggleToolButton*)widget,1);
+ switch_Mouse(NULL, 3);
}
void btnToolRectSelect_clicked(GtkWidget * widget, gpointer user_data)
{
- switch_Mouse(NULL, 0);
+ switch_Mouse(NULL, 0);
}
void btnToolZoomIn_clicked(GtkWidget * widget, gpointer user_data)
{
- glmotion_zoom_inc(1);
+ glmotion_zoom_inc(1);
}
void btnToolZoomOut_clicked(GtkWidget * widget, gpointer user_data)
{
- glmotion_zoom_inc(0);
+ glmotion_zoom_inc(0);
}
void btnToolZoomFit_clicked(GtkWidget * widget, gpointer user_data)
{
- float z,GDX,SDX,GDY,SDY;
- (view->active_camera >=0)
- ? (z=view->cameras[view->active_camera]->r):(z=view->zoom*-1);
-
- GDX=(view->bdxRight/z-view->bdxLeft/z);
- SDX=(view->clipX2 -view->clipX1);
- GDY=(view->bdyTop/z-view->bdyBottom/z);
- SDY=(view->clipY2 -view->clipY1);
-
- if ((SDX / GDX) <= (SDY / GDY))
- {
- (view->active_camera >=0) ?
- (view->cameras[view->active_camera]->r=view->cameras[view->active_camera]->r/ (SDX/GDX) ):
- (view->zoom = view->zoom /(SDX/GDX));
- }
- else
- {
- (view->active_camera >=0) ?
- (view->cameras[view->active_camera]->r=view->cameras[view->active_camera]->r/ (SDY/GDY) ):
- (view->zoom = view->zoom /(SDY/GDY));
-
- }
- btnToolFit_clicked(NULL,NULL);
+ float z, GDX, SDX, GDY, SDY;
+ (view->active_camera >= 0)
+ ? (z = view->cameras[view->active_camera]->r) : (z =
+ view->zoom * -1);
+
+ GDX = (view->bdxRight / z - view->bdxLeft / z);
+ SDX = (view->clipX2 - view->clipX1);
+ GDY = (view->bdyTop / z - view->bdyBottom / z);
+ SDY = (view->clipY2 - view->clipY1);
+
+ if ((SDX / GDX) <= (SDY / GDY)) {
+ (view->active_camera >= 0) ?
+ (view->cameras[view->active_camera]->r =
+ view->cameras[view->active_camera]->r / (SDX /
+ GDX)) : (view->zoom =
+ view->zoom /
+ (SDX /
+ GDX));
+ } else {
+ (view->active_camera >= 0) ?
+ (view->cameras[view->active_camera]->r =
+ view->cameras[view->active_camera]->r / (SDY /
+ GDY)) : (view->zoom =
+ view->zoom /
+ (SDY /
+ GDY));
+
+ }
+ btnToolFit_clicked(NULL, NULL);
}
void btnToolFit_clicked(GtkWidget * widget, gpointer user_data)
{
- float scx,scy,gcx,gcy,z;
+ float scx, scy, gcx, gcy, z;
- (view->active_camera >=0)
- ? (z=view->cameras[view->active_camera]->r):(z=view->zoom*-1);
+ (view->active_camera >= 0)
+ ? (z = view->cameras[view->active_camera]->r) : (z =
+ view->zoom * -1);
- gcx=view->bdxLeft/z+(view->bdxRight/z-view->bdxLeft/z)/(float)(2.0);
- scx=view->clipX1+(view->clipX2 -view->clipX1)/(float)(2.0);
- gcy=view->bdyBottom/z+(view->bdyTop/z-view->bdyBottom/z)/(float)(2.0);
- scy=view->clipY1+(view->clipY2 -view->clipY1)/(float)(2.0);
+ gcx =
+ view->bdxLeft / z + (view->bdxRight / z -
+ view->bdxLeft / z) / (float) (2.0);
+ scx = view->clipX1 + (view->clipX2 - view->clipX1) / (float) (2.0);
+ gcy =
+ view->bdyBottom / z + (view->bdyTop / z -
+ view->bdyBottom / z) / (float) (2.0);
+ scy = view->clipY1 + (view->clipY2 - view->clipY1) / (float) (2.0);
- if (view->active_camera >=0)
- {
+ if (view->active_camera >= 0) {
- view->cameras[view->active_camera]->targetx +=(gcx-scx);
- view->cameras[view->active_camera]->targety +=(gcx-scy);
- }
- else
- {
- view->panx += (gcx-scx);
- view->pany += (gcy-scy);
- }
- view->Topview->fitin_zoom=view->zoom;
+ view->cameras[view->active_camera]->targetx += (gcx - scx);
+ view->cameras[view->active_camera]->targety += (gcx - scy);
+ } else {
+ view->panx += (gcx - scx);
+ view->pany += (gcy - scy);
+ }
+ view->Topview->fitin_zoom = view->zoom;
- glexpose();
+ glexpose();
}
+
void btnToolMove_clicked(GtkWidget * widget, gpointer user_data)
{
switch_Mouse(NULL, 10);
}
void btnToolCursor_clicked(GtkWidget * widget, gpointer user_data)
{
- switch_Mouse(NULL, -1);
+ switch_Mouse(NULL, -1);
}
-void write_to_console(char* text)
+void write_to_console(char *text)
{
- //init console text
- GtkTextIter iter;
- if(!view->consoleText)
- view->consoleText=gtk_text_buffer_new(NULL);
- gtk_text_buffer_get_end_iter(view->consoleText,&iter);
- gtk_text_buffer_insert (view->consoleText,&iter,text,-1);
- gtk_text_view_set_buffer ((GtkTextView*)glade_xml_get_widget(xml, "consoleText"),view->consoleText);
+ //init console text
+ GtkTextIter iter;
+ if (!view->consoleText)
+ view->consoleText = gtk_text_buffer_new(NULL);
+ gtk_text_buffer_get_end_iter(view->consoleText, &iter);
+ gtk_text_buffer_insert(view->consoleText, &iter, text, -1);
+ gtk_text_view_set_buffer((GtkTextView *)
+ glade_xml_get_widget(xml, "consoleText"),
+ view->consoleText);
}
void on_btnActivateGraph_clicked(GtkWidget * widget, gpointer user_data)
{
- int graphId;
- graphId=gtk_combo_box_get_active(view->graphComboBox);
- /* fprintf (stderr, "switch to graph %d\n",graphId); */
- switch_graph(graphId);
+ int graphId;
+ graphId = gtk_combo_box_get_active(view->graphComboBox);
+ /* fprintf (stderr, "switch to graph %d\n",graphId); */
+ switch_graph(graphId);
}
-
#else
#define _BB /**/
#endif
-_BB void btnToolSingleSelect_clicked(GtkWidget * widget,
- gpointer user_data);
-_BB void btnToolRectSelect_clicked(GtkWidget * widget, gpointer user_data);
-_BB void btnToolRectXSelect_clicked(GtkWidget * widget,
- gpointer user_data);
+#ifdef __cplusplus
+extern "C" {
+#endif
-_BB void btnToolAntiRectSelect_clicked(GtkWidget * widget,
+ _BB void btnToolSingleSelect_clicked(GtkWidget * widget,
+ gpointer user_data);
+ _BB void btnToolRectSelect_clicked(GtkWidget * widget,
gpointer user_data);
-_BB void btnToolAntiRectXSelect_clicked(GtkWidget * widget,
+ _BB void btnToolRectXSelect_clicked(GtkWidget * widget,
gpointer user_data);
+ _BB void btnToolAntiRectSelect_clicked(GtkWidget * widget,
+ gpointer user_data);
+ _BB void btnToolAntiRectXSelect_clicked(GtkWidget * widget,
+ gpointer user_data);
-_BB void btnToolPan_clicked(GtkWidget * widget, gpointer user_data);
-_BB void btnToolZoom_clicked(GtkWidget * widget, gpointer user_data);
-_BB void btnToolZoomIn_clicked(GtkWidget * widget, gpointer user_data);
-_BB void btnToolZoomOut_clicked(GtkWidget * widget, gpointer user_data);
-_BB void btnToolZoomFit_clicked(GtkWidget * widget, gpointer user_data);
-_BB void btnToolFit_clicked(GtkWidget * widget, gpointer user_data);
-_BB void btnToolMove_clicked(GtkWidget * widget, gpointer user_data);
-_BB void btnToolAddNode_clicked(GtkWidget * widget, gpointer user_data);
-_BB void btnToolDeleteNode_clicked(GtkWidget * widget, gpointer user_data);
-_BB void btnToolFindNode_clicked(GtkWidget * widget, gpointer user_data);
-_BB void btnToolAddEdge_clicked(GtkWidget * widget, gpointer user_data);
-_BB void btnToolDeleteEdge_clicked(GtkWidget * widget, gpointer user_data);
-_BB void btnToolFindEdge_clicked(GtkWidget * widget, gpointer user_data);
-_BB void btnToolCursor_clicked(GtkWidget * widget, gpointer user_data);
-_BB void on_btnActivateGraph_clicked(GtkWidget * widget, gpointer user_data);
-void write_to_console(char* text);
+ _BB void btnToolPan_clicked(GtkWidget * widget, gpointer user_data);
+ _BB void btnToolZoom_clicked(GtkWidget * widget, gpointer user_data);
+ _BB void btnToolZoomIn_clicked(GtkWidget * widget, gpointer user_data);
+ _BB void btnToolZoomOut_clicked(GtkWidget * widget,
+ gpointer user_data);
+ _BB void btnToolZoomFit_clicked(GtkWidget * widget,
+ gpointer user_data);
+ _BB void btnToolFit_clicked(GtkWidget * widget, gpointer user_data);
+ _BB void btnToolMove_clicked(GtkWidget * widget, gpointer user_data);
+ _BB void btnToolAddNode_clicked(GtkWidget * widget,
+ gpointer user_data);
+ _BB void btnToolDeleteNode_clicked(GtkWidget * widget,
+ gpointer user_data);
+ _BB void btnToolFindNode_clicked(GtkWidget * widget,
+ gpointer user_data);
+ _BB void btnToolAddEdge_clicked(GtkWidget * widget,
+ gpointer user_data);
+ _BB void btnToolDeleteEdge_clicked(GtkWidget * widget,
+ gpointer user_data);
+ _BB void btnToolFindEdge_clicked(GtkWidget * widget,
+ gpointer user_data);
+ _BB void btnToolCursor_clicked(GtkWidget * widget, gpointer user_data);
+ _BB void on_btnActivateGraph_clicked(GtkWidget * widget,
+ gpointer user_data);
+ void write_to_console(char *text);
+#ifdef __cplusplus
+} /* end extern "C" */
+#endif
#endif
+/* $Id$Revision: */
/* vim:set shiftwidth=4 ts=8: */
/**********************************************************
void on_settingsOKBtn_clicked(GtkWidget * widget, gpointer user_data)
{
- on_settingsApplyBtn_clicked (widget,user_data);
- gtk_widget_hide(glade_xml_get_widget(xml, "dlgSettings"));
+ on_settingsApplyBtn_clicked(widget, user_data);
+ gtk_widget_hide(glade_xml_get_widget(xml, "dlgSettings"));
}
-void on_settingsApplyBtn_clicked(GtkWidget * widget, gpointer user_data)
+void on_settingsApplyBtn_clicked(GtkWidget * widget, gpointer user_data)
{
update_graph_from_settings(view->g[view->activeGraph]);
set_viewport_settings_from_template(view, view->g[view->activeGraph]);
- update_topview(view->g[view->activeGraph],view->Topview,0);
+ update_topview(view->g[view->activeGraph], view->Topview, 0);
/* settvcolorinfo(view->g[view->activeGraph],view->Topview);
init_node_size(view->g[view->activeGraph])*/
}
buf = agget(view->g[view->activeGraph], attribute);
if ((!buf) || (strcmp(buf, "") == 0))
buf = agget(view->default_attributes, attribute);
- if (buf)
- {
- colorxlate(buf, &cl, RGBA_DOUBLE);
- color.red = (int) (cl.u.RGBA[0] * 65535.0);
- color.green = (int) (cl.u.RGBA[1] * 65535.0);
- color.blue = (int) (cl.u.RGBA[2] * 65535.0);
+ if (buf) {
+ colorxlate(buf, &cl, RGBA_DOUBLE);
+ color.red = (int) (cl.u.RGBA[0] * 65535.0);
+ color.green = (int) (cl.u.RGBA[1] * 65535.0);
+ color.blue = (int) (cl.u.RGBA[2] * 65535.0);
gtk_color_button_set_color((GtkColorButton *)
glade_xml_get_widget(xml, widget_name),
&color);
Agraph_t * g)
{
GdkColor color;
- char *buf = N_GNEW(256,char);
+ char *buf = N_GNEW(256, char);
gtk_color_button_get_color((GtkColorButton *)
glade_xml_get_widget(xml, widget_name),
&color);
free(buf);
return 1;
}
-static int get_text_widget_to_attribute(char *attribute,char *widget_name,Agraph_t * g)
+static int get_text_widget_to_attribute(char *attribute, char *widget_name,
+ Agraph_t * g)
{
char buf[512];
- if (strlen(attribute)> 512)
- return 0;
- sprintf (buf, "%s",gtk_entry_get_text ((GtkEntry *)glade_xml_get_widget(xml, widget_name)));
- agattr(g, AGRAPH, attribute, buf);
- return 1;
+ if (strlen(attribute) > 512)
+ return 0;
+ sprintf(buf, "%s",
+ gtk_entry_get_text((GtkEntry *)
+ glade_xml_get_widget(xml, widget_name)));
+ agattr(g, AGRAPH, attribute, buf);
+ return 1;
}
-static int set_text_widget(char *attribute, char *widget_name)
+static int set_text_widget(char *attribute, char *widget_name)
{
- char* buf;
+ char *buf;
buf = agget(view->g[view->activeGraph], attribute);
if ((!buf) || (strcmp(buf, "") == 0))
buf = agget(view->default_attributes, attribute);
if (buf) {
- gtk_entry_set_text((GtkEntry*)glade_xml_get_widget(xml,widget_name),buf);
-
+ gtk_entry_set_text((GtkEntry *)
+ glade_xml_get_widget(xml, widget_name), buf);
+
return 1;
}
return 0;
{
int value;
char buf[100];
- value =
- (int) gtk_toggle_button_get_active((GtkToggleButton *)
- glade_xml_get_widget(xml,
- widget_name));
- sprintf (buf, "%d", value);
+ value = (int) gtk_toggle_button_get_active((GtkToggleButton *)
+ glade_xml_get_widget(xml,
+ widget_name));
+ sprintf(buf, "%d", value);
agattr(g, AGRAPH, attribute, buf);
return 1;
}
{
float value;
char buf[25];
- value =
- (float) gtk_spin_button_get_value((GtkSpinButton *)
- glade_xml_get_widget(xml,
- widget_name));
+ value = (float) gtk_spin_button_get_value((GtkSpinButton *)
+ glade_xml_get_widget(xml,
+ widget_name));
sprintf(buf, "%f", value);
// agattr(
agattr(g, AGRAPH, attribute, buf);
return 1;
}
static int get_scalebtn_widget_to_attribute(char *attribute,
- char *widget_name, Agraph_t * g)
+ char *widget_name,
+ Agraph_t * g)
{
float value;
char buf[25];
- value =
- (float) gtk_range_get_value((GtkRange *)
- glade_xml_get_widget(xml,
- widget_name));
- sprintf(buf, "%f", value);
+ value = (float) gtk_range_get_value((GtkRange *)
+ glade_xml_get_widget(xml,
+ widget_name));
+ sprintf(buf, "%f", value);
// agattr(
agattr(g, AGRAPH, attribute, buf);
return 1;
}
-static int set_scalebtn_widget_to_attribute(char *attribute, char *widget_name)
+static int set_scalebtn_widget_to_attribute(char *attribute,
+ char *widget_name)
{
char *buf;
float value;
if (buf) {
value = (float) atof(buf);
gtk_range_set_value((GtkRange *)
- glade_xml_get_widget(xml, widget_name),
- value);
+ glade_xml_get_widget(xml, widget_name), value);
return 1;
}
return 0;
}
-static int set_combobox_widget(char *attribute,char *widget_name)
+static int set_combobox_widget(char *attribute, char *widget_name)
{
char *buf;
int value;
if ((!buf) || (strcmp(buf, "") == 0))
buf = agget(view->default_attributes, attribute);
- if (buf)
- {
- value=(int) atof(buf);
- gtk_combo_box_set_active(
- (GtkComboBox *) glade_xml_get_widget(xml,widget_name),
- (int)value);
+ if (buf) {
+ value = (int) atof(buf);
+ gtk_combo_box_set_active((GtkComboBox *)
+ glade_xml_get_widget(xml, widget_name),
+ (int) value);
- return 1;
- }
+ return 1;
+ }
return 0;
}
-static int get_combobox_widget_to_attribute(char *attribute, char *widget_name, Agraph_t * g)
+static int get_combobox_widget_to_attribute(char *attribute,
+ char *widget_name,
+ Agraph_t * g)
{
char buf[25];
float value;
- value=(float)
+ value = (float)
gtk_combo_box_get_active((GtkComboBox *)
- glade_xml_get_widget(xml,
- widget_name));
+ glade_xml_get_widget(xml, widget_name));
sprintf(buf, "%f", value);
agattr(g, AGRAPH, attribute, buf);
int load_settings_from_graph(Agraph_t * g)
{
- char *buf; /*local buffer*/
- set_color_button_widget("bgcolor", "settingsColorBtn1");
+ char *buf; /*local buffer */
+ set_color_button_widget("bgcolor", "settingsColorBtn1");
set_color_button_widget("bordercolor", "settingsColorBtn2");
set_color_button_widget("gridcolor", "settingsColorBtn3");
set_color_button_widget("highlightednodecolor", "settingsColorBtn6");
set_color_button_widget("highlightededgecolor", "settingsColorBtn7");
set_color_button_widget("selectednodecolor", "settingsColorBtn8");
set_color_button_widget("selectededgecolor", "settingsColorBtn9");
- set_color_button_widget("defaultnodecolor","DefaultNodeCbtn");
- set_color_button_widget("defaultedgecolor","DefaultEdgeCbtn");
+ set_color_button_widget("defaultnodecolor", "DefaultNodeCbtn");
+ set_color_button_widget("defaultedgecolor", "DefaultEdgeCbtn");
- set_color_button_widget("topologicaltopviewfinestcolor",
- "settingsColorBtn9");
- set_color_button_widget("topologicaltopviewcoarsestcolor","settingsColorBtn9");
+ set_color_button_widget("topologicaltopviewfinestcolor",
+ "settingsColorBtn9");
+ set_color_button_widget("topologicaltopviewcoarsestcolor",
+ "settingsColorBtn9");
set_color_button_widget("topologicalfisheyefinestcolor",
"settingsColorBtn10");
set_color_button_widget("topologicalfisheyecoarsestcolor",
"settingsColorBtn11");
- set_text_widget("topologicalfisheyelabelattribute","finenodelabelattribute");
+ set_text_widget("topologicalfisheyelabelattribute",
+ "finenodelabelattribute");
set_checkbox_widget("bordervisible", "settingsChkBox2");
set_checkbox_widget("gridvisible", "settingsChkBox3");
- set_checkbox_widget("drawnodes", "settingsChkBox5-1");
- set_checkbox_widget("drawedges", "settingsChkBox5-2");
+ set_checkbox_widget("drawnodes", "settingsChkBox5-1");
+ set_checkbox_widget("drawedges", "settingsChkBox5-2");
- /*page 2 label settings*/
- set_combobox_widget("labelglutfont","labelfont");
+ /*page 2 label settings */
+ set_combobox_widget("labelglutfont", "labelfont");
- set_color_button_widget("nodelabelcolor","nodelabelcolor");
- set_color_button_widget("edgelabelcolor","edgelabelcolor");
- set_text_widget("nodelabelattribute","labelnodeattribute");
- set_text_widget("edgecolorattribute","edgecolortxt");
+ set_color_button_widget("nodelabelcolor", "nodelabelcolor");
+ set_color_button_widget("edgelabelcolor", "edgelabelcolor");
+ set_text_widget("nodelabelattribute", "labelnodeattribute");
+ set_text_widget("edgecolorattribute", "edgecolortxt");
- set_text_widget("edgelabelattribute","labeledgeattribute");
- set_checkbox_widget("labelwithdegree", "labelwithdegree");
- set_spinbtn_widget("labelnumberofnodes","labelzoomfactor");
- set_checkbox_widget("shownodelabels", "labelshownodes");
- set_checkbox_widget("showedgelabels", "labelshowedges");
+ set_text_widget("edgelabelattribute", "labeledgeattribute");
+ set_checkbox_widget("labelwithdegree", "labelwithdegree");
+ set_spinbtn_widget("labelnumberofnodes", "labelzoomfactor");
+ set_checkbox_widget("shownodelabels", "labelshownodes");
+ set_checkbox_widget("showedgelabels", "labelshowedges");
- set_checkbox_widget("usermode", "settingsChkBox10");
+ set_checkbox_widget("usermode", "settingsChkBox10");
set_checkbox_widget("nodesizewithdegree", "settingsChkBox11");
set_checkbox_widget("antialiasing", "settingsChkBox12");
set_checkbox_widget("topologicalfisheyelabelfocus",
"settingsChkBox18");
- set_checkbox_widget("defaultnodeshapegl",
- "settingsChkBox10_1");
- set_checkbox_widget("defaultnodeshapespherical",
- "settingsChkBox10_2");
+ set_checkbox_widget("defaultnodeshapegl", "settingsChkBox10_1");
+ set_checkbox_widget("defaultnodeshapespherical", "settingsChkBox10_2");
set_checkbox_widget("defaultnodeshaperectangular",
"settingsChkBox10_3");
-
-
- set_spinbtn_widget("defaultmagnifierwidth", "settingsspinbutton1");
+
+
+ set_spinbtn_widget("defaultmagnifierwidth", "settingsspinbutton1");
set_spinbtn_widget("defaultmagnifierheight", "settingsspinbutton2");
set_spinbtn_widget("defaultmagnifierkts", "settingsspinbutton3");
set_spinbtn_widget("defaultfisheyemagnifierradius",
"settingsspinbutton7");
set_spinbtn_widget("topologicalfisheyedistortionfactor",
"settingsspinbutton8");
-
- /*alpha values,1 for nodes 1 for edges*/
+
+ /*alpha values,1 for nodes 1 for edges */
- set_scalebtn_widget_to_attribute("defaultnodealpha", "settingsscale1"); /*node alpha*/
- set_scalebtn_widget_to_attribute("defaultedgealpha", "settingsscale2"); /*edge alpha*/
- set_scalebtn_widget_to_attribute("nodesize", "nodesizescale"); /*edge alpha*/
+ set_scalebtn_widget_to_attribute("defaultnodealpha", "settingsscale1"); /*node alpha */
+ set_scalebtn_widget_to_attribute("defaultedgealpha", "settingsscale2"); /*edge alpha */
+ set_scalebtn_widget_to_attribute("nodesize", "nodesizescale"); /*edge alpha */
/*Node Shape Combo, 0:opengl dots, 1:circle ,2:box */
buf = agget(view->g[view->activeGraph], "defaultnodeshape");
if (!buf)
buf = agget(view->default_attributes, "defaultnodeshape");
- if (buf)
- {
- /*select the right item in combo box */
- gtk_combo_box_set_active((GtkComboBox *)
+ if (buf) {
+ /*select the right item in combo box */
+ gtk_combo_box_set_active((GtkComboBox *)
glade_xml_get_widget(xml,
"settingscombobox1"),
atoi(buf));
- }
- /*Color theme*/
+ }
+ /*Color theme */
buf = agget(view->g[view->activeGraph], "colortheme");
if (!buf)
buf = agget(view->default_attributes, "colortheme");
- if (buf)
- {
- /*select the right item in combo box */
- gtk_combo_box_set_active((GtkComboBox *)
+ if (buf) {
+ /*select the right item in combo box */
+ gtk_combo_box_set_active((GtkComboBox *)
glade_xml_get_widget(xml,
"colorthemecb"),
atoi(buf));
- }
+ }
/*Node Shape Combo, 0:opengl dots, 1:circle ,2:box */
-
+
return 1;
}
int value;
char buf2[10];
- buf=gtk_font_selection_get_font_name((GtkFontSelection*)glade_xml_get_widget(xml, "settingsFontSelection"));
- agset(g,"defaultfontname",buf);
+ buf =
+ gtk_font_selection_get_font_name((GtkFontSelection *)
+ glade_xml_get_widget(xml,
+ "settingsFontSelection"));
+ agset(g, "defaultfontname", buf);
#endif
get_color_button_widget_to_attribute("bgcolor", "settingsColorBtn1",
g);
"settingsColorBtn9", g);
- get_color_button_widget_to_attribute("defaultnodecolor","DefaultNodeCbtn", g);
- get_color_button_widget_to_attribute("defaultedgecolor","DefaultEdgeCbtn", g);
+ get_color_button_widget_to_attribute("defaultnodecolor",
+ "DefaultNodeCbtn", g);
+ get_color_button_widget_to_attribute("defaultedgecolor",
+ "DefaultEdgeCbtn", g);
"settingsColorBtn10", g);
get_color_button_widget_to_attribute("topologicalfisheyecoarsestcolor",
"settingsColorBtn11", g);
- get_text_widget_to_attribute("topologicalfisheyelabelattribute","finenodelabelattribute",g);
+ get_text_widget_to_attribute("topologicalfisheyelabelattribute",
+ "finenodelabelattribute", g);
get_checkbox_widget_to_attribute("bordervisible", "settingsChkBox2",
g);
get_checkbox_widget_to_attribute("gridvisible", "settingsChkBox3", g);
- get_checkbox_widget_to_attribute("drawnodes",
- "settingsChkBox5-1", g);
- get_checkbox_widget_to_attribute("drawedges",
- "settingsChkBox5-2", g);
-
- /*page 2 label settings*/
- get_combobox_widget_to_attribute("labelglutfont","labelfont", g);
+ get_checkbox_widget_to_attribute("drawnodes", "settingsChkBox5-1", g);
+ get_checkbox_widget_to_attribute("drawedges", "settingsChkBox5-2", g);
+
+ /*page 2 label settings */
+ get_combobox_widget_to_attribute("labelglutfont", "labelfont", g);
- get_color_button_widget_to_attribute("nodelabelcolor","nodelabelcolor", g);
- get_color_button_widget_to_attribute("edgelabelcolor","edgelabelcolor", g);
+ get_color_button_widget_to_attribute("nodelabelcolor",
+ "nodelabelcolor", g);
+ get_color_button_widget_to_attribute("edgelabelcolor",
+ "edgelabelcolor", g);
- get_text_widget_to_attribute("nodelabelattribute","labelnodeattribute",g);
- get_text_widget_to_attribute("edgelabelattribute","labeledgeattribute",g);
-
- get_text_widget_to_attribute("edgecolorattribute","edgecolortxt",g);
+ get_text_widget_to_attribute("nodelabelattribute",
+ "labelnodeattribute", g);
+ get_text_widget_to_attribute("edgelabelattribute",
+ "labeledgeattribute", g);
- get_checkbox_widget_to_attribute("labelwithdegree", "labelwithdegree", g);
- get_spinbtn_widget_to_attribute("labelnumberofnodes","labelzoomfactor", g);
- get_checkbox_widget_to_attribute("shownodelabels", "labelshownodes", g);
- get_checkbox_widget_to_attribute("showedgelabels", "labelshowedges", g);
+ get_text_widget_to_attribute("edgecolorattribute", "edgecolortxt", g);
+ get_checkbox_widget_to_attribute("labelwithdegree", "labelwithdegree",
+ g);
+ get_spinbtn_widget_to_attribute("labelnumberofnodes",
+ "labelzoomfactor", g);
+ get_checkbox_widget_to_attribute("shownodelabels", "labelshownodes",
+ g);
+ get_checkbox_widget_to_attribute("showedgelabels", "labelshowedges",
+ g);
- get_checkbox_widget_to_attribute("usermode", "settingsChkBox10", g);
+ get_checkbox_widget_to_attribute("usermode", "settingsChkBox10", g);
- get_checkbox_widget_to_attribute("nodesizewithdegree",
+
+ get_checkbox_widget_to_attribute("nodesizewithdegree",
"settingsChkBox11", g);
get_checkbox_widget_to_attribute("antialiasing", "settingsChkBox12",
g);
"settingsspinbutton7", g);
get_spinbtn_widget_to_attribute("topologicalfisheyedistortionfactor",
"settingsspinbutton8", g);
- /*added later*/
- get_scalebtn_widget_to_attribute("defaultnodealpha",
- "settingsscale1", g);
- get_scalebtn_widget_to_attribute("defaultedgealpha",
- "settingsscale2", g);
- get_scalebtn_widget_to_attribute("nodesize",
- "nodesizescale", g);
+ /*added later */
+ get_scalebtn_widget_to_attribute("defaultnodealpha",
+ "settingsscale1", g);
+ get_scalebtn_widget_to_attribute("defaultedgealpha",
+ "settingsscale2", g);
+ get_scalebtn_widget_to_attribute("nodesize", "nodesizescale", g);
- get_combobox_widget_to_attribute("defaultnodeshape","settingscombobox1", g) ;
- get_combobox_widget_to_attribute("colortheme","colorthemecb", g) ;
+ get_combobox_widget_to_attribute("defaultnodeshape",
+ "settingscombobox1", g);
+ get_combobox_widget_to_attribute("colortheme", "colorthemecb", g);
- return 1;
+ return 1;
}
int show_settings_form()
gtk_widget_hide(glade_xml_get_widget(xml, "dlgSettings"));
gtk_widget_show(glade_xml_get_widget(xml, "dlgSettings"));
gtk_window_set_keep_above((GtkWindow *)
- glade_xml_get_widget(xml, "dlgSettings"), 1);
- }
- else {
+ glade_xml_get_widget(xml, "dlgSettings"),
+ 1);
+ } else {
GtkMessageDialog *dlg;
- dlg = (GtkMessageDialog *) gtk_message_dialog_new(NULL,
- GTK_DIALOG_MODAL,
- GTK_MESSAGE_QUESTION,
- GTK_BUTTONS_OK,
- "No active graph");
- gtk_dialog_run((GtkDialog *) dlg);
- gtk_widget_hide((GtkWidget *) dlg);
+ dlg = (GtkMessageDialog *) gtk_message_dialog_new(NULL,
+ GTK_DIALOG_MODAL,
+ GTK_MESSAGE_QUESTION,
+ GTK_BUTTONS_OK,
+ "No active graph");
+ gtk_dialog_run((GtkDialog *) dlg);
+ gtk_widget_hide((GtkWidget *) dlg);
}
return 1;
}
#include "smyrnadefs.h"
-_BB void on_settingsOKBtn_clicked(GtkWidget * widget, gpointer user_data);
-_BB void on_settingsCancelBtn_clicked(GtkWidget * widget,gpointer user_data);
-_BB void on_settingsApplyBtn_clicked(GtkWidget * widget, gpointer user_data);
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ _BB void on_settingsOKBtn_clicked(GtkWidget * widget,
+ gpointer user_data);
+ _BB void on_settingsCancelBtn_clicked(GtkWidget * widget,
+ gpointer user_data);
+ _BB void on_settingsApplyBtn_clicked(GtkWidget * widget,
+ gpointer user_data);
-extern int load_settings_from_graph(Agraph_t * g);
-extern int update_graph_from_settings(Agraph_t * g);
-extern int show_settings_form();
+ extern int load_settings_from_graph(Agraph_t * g);
+ extern int update_graph_from_settings(Agraph_t * g);
+ extern int show_settings_form();
+#ifdef __cplusplus
+} /* end extern "C" */
+#endif
#endif
#include "gvprpipe.h"
#include "const.h"
-#include <stdio.h>
+#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <glade/glade.h>
#include "draw.h"
#include "gui.h"
-#include <viewport.h>
+#include <viewport.h>
//#include <gltemplate.h>
#include <gvpr.h>
-extern GladeXML *xml; //global libglade vars
-static ssize_t outfn (void* sp, const char *buf, size_t nbyte, void* dp)
+extern GladeXML *xml; //global libglade vars
+static ssize_t outfn(void *sp, const char *buf, size_t nbyte, void *dp)
{
- append_textview((GtkTextView*) glade_xml_get_widget(xml,"gvprtextoutput"),buf,nbyte);
- append_textview((GtkTextView*) glade_xml_get_widget(xml,"mainconsole"),buf,nbyte);
- return nbyte;
+ append_textview((GtkTextView *)
+ glade_xml_get_widget(xml, "gvprtextoutput"), buf,
+ nbyte);
+ append_textview((GtkTextView *)
+ glade_xml_get_widget(xml, "mainconsole"), buf, nbyte);
+ return nbyte;
}
#ifdef UNUSED
-static ssize_t errfn (void* sp, const char *buf, size_t nbyte, void* dp)
+static ssize_t errfn(void *sp, const char *buf, size_t nbyte, void *dp)
{
- return 0;
+ return 0;
}
#endif
-int run_gvpr (Agraph_t* srcGraph, int argc, char* argv[])
+int run_gvpr(Agraph_t * srcGraph, int argc, char *argv[])
{
int i, rv = 1;
gvpropts opts;
- Agraph_t* gs[2];
+ Agraph_t *gs[2];
static int count;
char buf[SMALLBUF];
opts.out = outfn;
opts.err = outfn;
opts.flags = GV_USE_OUTGRAPH;
-
- rv = gvpr (argc, argv, &opts);
- if (rv) { /* error */
- fprintf (stderr, "Error in gvpr\n");
- }
- else if (opts.n_outgraphs) {
- refreshViewport (0);
- sprintf (buf, "<%d>", ++count);
+ rv = gvpr(argc, argv, &opts);
+
+ if (rv) { /* error */
+ fprintf(stderr, "Error in gvpr\n");
+ } else if (opts.n_outgraphs) {
+ refreshViewport(0);
+ sprintf(buf, "<%d>", ++count);
if (opts.outgraphs[0] != view->g[view->activeGraph])
add_graph_to_viewport(opts.outgraphs[0], buf);
if (opts.n_outgraphs > 1)
- fprintf (stderr, "Warning: multiple output graphs-discarded\n");
+ fprintf(stderr, "Warning: multiple output graphs-discarded\n");
for (i = 1; i < opts.n_outgraphs; i++) {
- agclose (opts.outgraphs[i]);
+ agclose(opts.outgraphs[i]);
}
- }
- else {
- refreshViewport (0);
+ } else {
+ refreshViewport(0);
}
return rv;
}
#include "cgraph.h"
-extern int run_gvpr(Agraph_t* srcGraph, int, char**);
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ extern int run_gvpr(Agraph_t * srcGraph, int, char **);
+#ifdef __cplusplus
+} /* end extern "C" */
+#endif
#endif
+/* $Id$Revision: */
/* vim:set shiftwidth=4 ts=8: */
/**********************************************************
}
}
-void positionAllItems(Hierarchy * hp, focus_t * fs, reposition_t* parms)
+void positionAllItems(Hierarchy * hp, focus_t * fs, reposition_t * parms)
{
int i;
int interval = 20;
- int counter = 0; /* no. of active nodes */
+ int counter = 0; /* no. of active nodes */
double *x_coords = N_NEW(hp->nvtxs[0], double);
double *y_coords = N_NEW(hp->nvtxs[0], double);
int max_level = hp->nlevels - 1; // coarsest level
height *= parms->graphSize / 100.0;
if (fs->num_foci == 0) {
if (parms->rescale == Scale)
- scale_coords(x_coords, y_coords, counter, width, height, margin);
+ scale_coords(x_coords, y_coords, counter, width, height,
+ margin);
} else
switch (parms->rescale) {
case Polar:
rescale_layout_polar(x_coords, y_coords, fs->x_foci,
fs->y_foci, fs->num_foci, counter,
- interval, width, height, margin, distortion);
+ interval, width, height, margin,
+ distortion);
break;
case Rectilinear:
rescale_layout(x_coords, y_coords, counter, interval,
width, height, margin, distortion);
break;
case Scale:
- scale_coords(x_coords, y_coords, counter, width, height, margin);
+ scale_coords(x_coords, y_coords, counter, width, height,
+ margin);
break;
case NoRescale:
break;
}
#ifdef DEBUG
-static void
-dumpG (int nn, v_data * graph)
+static void dumpG(int nn, v_data * graph)
{
int i, j;
- for (i=0; i < nn; i++) {
- fprintf (stderr, "[%d]", i);
- for (j=1; j < graph->nedges; j++)
- fprintf (stderr, " %d", graph->edges[j]);
- fprintf (stderr, "\n");
+ for (i = 0; i < nn; i++) {
+ fprintf(stderr, "[%d]", i);
+ for (j = 1; j < graph->nedges; j++)
+ fprintf(stderr, " %d", graph->edges[j]);
+ fprintf(stderr, "\n");
graph++;
}
}
-static void
-dumpEG (int nn, ex_vtx_data * graph)
+static void dumpEG(int nn, ex_vtx_data * graph)
{
int i, j;
- for (i=0; i < nn; i++) {
- fprintf (stderr, "[%d](%d,%d,%d)(%f,%f)", i, graph->size, graph->active_level,
- graph->globalIndex, graph->x_coord, graph->y_coord);
- for (j=1; j < graph->nedges; j++)
- fprintf (stderr, " %d", graph->edges[j]);
- fprintf (stderr, "\n");
- graph++;
+ for (i = 0; i < nn; i++) {
+ fprintf(stderr, "[%d](%d,%d,%d)(%f,%f)", i, graph->size,
+ graph->active_level, graph->globalIndex, graph->x_coord,
+ graph->y_coord);
+ for (j = 1; j < graph->nedges; j++)
+ fprintf(stderr, " %d", graph->edges[j]);
+ fprintf(stderr, "\n");
+ graph++;
}
}
-static void
-dumpHier (Hierarchy* hier)
+static void dumpHier(Hierarchy * hier)
{
int i;
for (i = 0; i < hier->nlevels; i++) {
- fprintf (stderr, "level [%d] %d %d \n", i, hier->nvtxs[i], hier->nedges[i]);
- fprintf (stderr, "graph\n");
- dumpG (hier->nvtxs[i], hier->graphs[0]);
- fprintf (stderr, "geom_graph\n");
- dumpEG (hier->nvtxs[i], hier->geom_graphs[0]);
+ fprintf(stderr, "level [%d] %d %d \n", i, hier->nvtxs[i],
+ hier->nedges[i]);
+ fprintf(stderr, "graph\n");
+ dumpG(hier->nvtxs[i], hier->graphs[0]);
+ fprintf(stderr, "geom_graph\n");
+ dumpEG(hier->nvtxs[i], hier->geom_graphs[0]);
}
}
#endif
Hierarchy *makeHier(int nn, int ne, v_data * graph, double *x_coords,
- double *y_coords, hierparms_t* parms)
+ double *y_coords, hierparms_t * parms)
{
v_data *delaunay;
ex_vtx_data *geom_graph;
return fs;
}
-void freeFocus(focus_t* fs)
+void freeFocus(focus_t * fs)
{
- free (fs->foci_nodes);
- free (fs->x_foci);
- free (fs->y_foci);
- free (fs);
+ free(fs->foci_nodes);
+ free(fs->x_foci);
+ free(fs->y_foci);
+ free(fs);
}
#include "hierarchy.h"
-typedef struct {
- int num_foci;
- int *foci_nodes; /* Nodes in real graph */
- double *x_foci; /* Universal coordinates */
- double *y_foci;
-} focus_t;
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ typedef struct {
+ int num_foci;
+ int *foci_nodes; /* Nodes in real graph */
+ double *x_foci; /* Universal coordinates */
+ double *y_foci;
+ } focus_t;
/* Conversion from logical to physical coordinates:
* NoRescale - simple copy
* For Scale, this is all that is done.
* For Polar and Rectilinear, more space is provided around the foci.
*/
-typedef enum {NoRescale, Scale, Polar, Rectilinear} RescaleType;
+ typedef enum { NoRescale, Scale, Polar, Rectilinear } RescaleType;
-typedef struct {
+ typedef struct {
/* First 5 must be set i rescale = Polar or Rectilinear */
- int width; /* viewport width */
- int height; /* viewport height */
- int margin; /* viewport margin */
- int graphSize; /* 0 -- 100: percent to shrink w x h */
- double distortion; /* default of 1.0 */
- RescaleType rescale;
-} reposition_t;
+ int width; /* viewport width */
+ int height; /* viewport height */
+ int margin; /* viewport margin */
+ int graphSize; /* 0 -- 100: percent to shrink w x h */
+ double distortion; /* default of 1.0 */
+ RescaleType rescale;
+ } reposition_t;
-void positionAllItems(Hierarchy * hp, focus_t * fs, reposition_t* parms);
-Hierarchy *makeHier(int nnodes, int nedges, v_data *, double *,
- double*, hierparms_t *);
+ void positionAllItems(Hierarchy * hp, focus_t * fs,
+ reposition_t * parms);
+ Hierarchy *makeHier(int nnodes, int nedges, v_data *, double *,
+ double *, hierparms_t *);
-focus_t *initFocus(int ncnt);
-void freeFocus(focus_t* fs);
+ focus_t *initFocus(int ncnt);
+ void freeFocus(focus_t * fs);
+#ifdef __cplusplus
+} /* end extern "C" */
+#endif
#endif
-/* $Id$ $Revision$ */
+/* $Id$Revision: */
/* vim:set shiftwidth=4 ts=8: */
/**********************************************************
gchar *package_data_dir;
#endif
gchar *package_locale_dir;
-static char* smyrnaDir; /* path to directory containin smyrna data files */
-char* smyrnaGlade;
+static char *smyrnaDir; /* path to directory containin smyrna data files */
+char *smyrnaGlade;
unsigned char SmyrnaVerbose;
* it later.
* Returns NULL on error.
*/
-char*
-smyrnaPath (char* suffix)
+char *smyrnaPath(char *suffix)
{
static int buflen;
- static char* buf;
+ static char *buf;
static int baselen;
int slen;
#ifdef WIN32
- char* pathSep = "\\";
+ char *pathSep = "\\";
#else
- char* pathSep = "/";
+ char *pathSep = "/";
#endif
- assert (smyrnaDir);
+ assert(smyrnaDir);
if (!buf) {
- baselen = strlen (smyrnaDir) + 2;
+ baselen = strlen(smyrnaDir) + 2;
buflen = baselen + 100;
- buf = N_NEW(buflen,char);
+ buf = N_NEW(buflen, char);
}
- slen = strlen (suffix);
+ slen = strlen(suffix);
if (baselen + slen > buflen) {
buflen = baselen + slen;
- buf = realloc (buf, buflen);
+ buf = realloc(buf, buflen);
}
- sprintf (buf, "%s%s%s", smyrnaDir, pathSep, suffix);
+ sprintf(buf, "%s%s%s", smyrnaDir, pathSep, suffix);
return buf;
}
}
-static char*
-parseArgs (int argc, char *argv[], ViewInfo* view)
+static char *parseArgs(int argc, char *argv[], ViewInfo * view)
{
unsigned int c;
SmyrnaVerbose = 1;
break;
case 't':
- view->dfltViewType = VT_TOPVIEW;
+ view->dfltViewType = VT_TOPVIEW;
break;
case 'x':
- view->dfltViewType = VT_XDOT;
+ view->dfltViewType = VT_XDOT;
break;
case 'K':
- view->dfltEngine = s2layout (optarg);
+ view->dfltEngine = s2layout(optarg);
break;
case '?':
if (optopt == '?')
usage(0);
else
- fprintf(stderr, "smyrna: option -%c unrecognized - ignored\n",
+ fprintf(stderr,
+ "smyrna: option -%c unrecognized - ignored\n",
optopt);
break;
}
}
if (optind < argc)
- return argv[optind];
+ return argv[optind];
else
return NULL;
}
#ifdef UNUSED
-static void close_cgraph(Agraph_t* g)
+static void close_cgraph(Agraph_t * g)
{
- Agnode_t *v;
- for (v = agfstnode(g); v; v = agnxtnode(g, v))
- {
- agdelrec(v, "temp_node_record");
- }
- agclose(g);
+ Agnode_t *v;
+ for (v = agfstnode(g); v; v = agnxtnode(g, v)) {
+ agdelrec(v, "temp_node_record");
+ }
+ agclose(g);
}
#endif
int main(int argc, char *argv[])
{
GdkGLConfig *glconfig;
- char* initFileName;
- /*combo box to show loaded graphs*/
- GtkComboBox * graphComboBox;
+ char *initFileName;
+ /*combo box to show loaded graphs */
+ GtkComboBox *graphComboBox;
- smyrnaDir = getenv ("SMYRNA_PATH");
+ smyrnaDir = getenv("SMYRNA_PATH");
if (!smyrnaDir) {
#ifdef _WIN32
- int sz = GetCurrentDirectory(0, NULL)+strlen("\\share\\graphviz\\smyrna") + 1;
+ int sz =
+ GetCurrentDirectory(0,
+ NULL) +
+ strlen("\\share\\graphviz\\smyrna") + 1;
smyrnaDir = N_NEW(sz, char);
- GetCurrentDirectory (sz, smyrnaDir);
- smyrnaDir[strlen(smyrnaDir)-4]=(char)0;
- strcat(smyrnaDir,"\\share\\graphviz\\smyrna");
+ GetCurrentDirectory(sz, smyrnaDir);
+ smyrnaDir[strlen(smyrnaDir) - 4] = (char) 0;
+ strcat(smyrnaDir, "\\share\\graphviz\\smyrna");
#else
smyrnaDir = SMYRNA_PATH;
#endif
load_attributes();
#ifdef G_OS_WIN32
- package_prefix =g_win32_get_package_installation_directory(NULL, NULL);
+ package_prefix =
+ g_win32_get_package_installation_directory(NULL, NULL);
package_data_dir = g_build_filename(package_prefix, "share", NULL);
package_locale_dir =
g_build_filename(package_prefix, "share", "locale", NULL);
#else
package_locale_dir = g_build_filename(smyrnaDir, "locale", NULL);
-#endif /* # */
+#endif /* # */
#ifdef ENABLE_NLS
bindtextdomain(GETTEXT_PACKAGE, package_locale_dir);
bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
init_viewport(view);
gtk_set_locale();
gtk_init(&argc, &argv);
- initFileName = parseArgs (argc, argv, view);
- if (!(smyrnaGlade))
- smyrnaGlade = smyrnaPath ("smyrna.glade");
+ initFileName = parseArgs(argc, argv, view);
+ if (!(smyrnaGlade))
+ smyrnaGlade = smyrnaPath("smyrna.glade");
xml = glade_xml_new(smyrnaGlade, NULL, NULL);
gladewidget = glade_xml_get_widget(xml, "frmMain");
gtk_widget_show(gladewidget);
g_signal_connect((gpointer) gladewidget, "destroy",
G_CALLBACK(mQuitSlot), NULL);
glade_xml_signal_autoconnect(xml);
- if (initFileName)
- {
- view->initFile=1;
- view->initFileName=strdup(initFileName);
- }
- gtk_gl_init(0, 0);
+ if (initFileName) {
+ view->initFile = 1;
+ view->initFileName = strdup(initFileName);
+ }
+ gtk_gl_init(0, 0);
/* Configure OpenGL framebuffer. */
glconfig = configure_gl();
-// gladewidget = glade_xml_get_widget(xml, "vbox2");
- gladewidget = glade_xml_get_widget(xml, "hbox11");
+// gladewidget = glade_xml_get_widget(xml, "vbox2");
+ gladewidget = glade_xml_get_widget(xml, "hbox11");
create_window(glconfig, gladewidget);
- change_cursor(GDK_TOP_LEFT_ARROW);
+ change_cursor(GDK_TOP_LEFT_ARROW);
-#ifndef WIN32
- glutInit(&argc,argv);
+#ifndef WIN32
+ glutInit(&argc, argv);
#endif
- gladewidget = glade_xml_get_widget(xml, "hbox10");
- graphComboBox=(GtkComboBox*)gtk_combo_box_new_text();
- gtk_box_pack_end(gladewidget,graphComboBox,1,1,10);
+ gladewidget = glade_xml_get_widget(xml, "hbox10");
+ graphComboBox = (GtkComboBox *) gtk_combo_box_new_text();
+ gtk_box_pack_end(gladewidget, graphComboBox, 1, 1, 10);
gtk_widget_show(graphComboBox);
- view->graphComboBox=graphComboBox;
- gtk_main();
+ view->graphComboBox = graphComboBox;
+ gtk_main();
#ifndef MATERIALS_H
#define MATERIALS_H
-typedef struct _MaterialProp {
- GLfloat ambient[4];
- GLfloat diffuse[4];
- GLfloat specular[4];
- GLfloat shininess;
-} MaterialProp;
-
-static MaterialProp mat_emerald = {
- {0.0215, 0.1745, 0.0215, 1.0},
- {0.07568, 0.61424, 0.07568, 1.0},
- {0.633, 0.727811, 0.633, 1.0},
- 0.6
-};
-
-static MaterialProp mat_jade = {
- {0.135, 0.2225, 0.1575, 1.0},
- {0.54, 0.89, 0.63, 1.0},
- {0.316228, 0.316228, 0.316228, 1.0},
- 0.1
-};
-
-static MaterialProp mat_obsidian = {
- {0.05375, 0.05, 0.06625, 1.0},
- {0.18275, 0.17, 0.22525, 1.0},
- {0.332741, 0.328634, 0.346435, 1.0},
- 0.3
-};
-
-static MaterialProp mat_pearl = {
- {0.25, 0.20725, 0.20725, 1.0},
- {1.0, 0.829, 0.829, 1.0},
- {0.296648, 0.296648, 0.296648, 1.0},
- 0.088
-};
-
-static MaterialProp mat_ruby = {
- {0.1745, 0.01175, 0.01175, 1.0},
- {0.61424, 0.04136, 0.04136, 1.0},
- {0.727811, 0.626959, 0.626959, 1.0},
- 0.6
-};
-
-static MaterialProp mat_turquoise = {
- {0.1, 0.18725, 0.1745, 1.0},
- {0.396, 0.74151, 0.69102, 1.0},
- {0.297254, 0.30829, 0.306678, 1.0},
- 0.1
-};
-
-static MaterialProp mat_brass = {
- {0.329412, 0.223529, 0.027451, 1.0},
- {0.780392, 0.568627, 0.113725, 1.0},
- {0.992157, 0.941176, 0.807843, 1.0},
- 0.21794872
-};
-
-static MaterialProp mat_bronze = {
- {0.2125, 0.1275, 0.054, 1.0},
- {0.714, 0.4284, 0.18144, 1.0},
- {0.393548, 0.271906, 0.166721, 1.0},
- 0.2
-};
-
-static MaterialProp mat_chrome = {
- {0.25, 0.25, 0.25, 1.0},
- {0.4, 0.4, 0.4, 1.0},
- {0.774597, 0.774597, 0.774597, 1.0},
- 0.6
-};
-
-static MaterialProp mat_copper = {
- {0.19125, 0.0735, 0.0225, 1.0},
- {0.7038, 0.27048, 0.0828, 1.0},
- {0.256777, 0.137622, 0.086014, 1.0},
- 0.1
-};
-
-static MaterialProp mat_gold = {
- {0.24725, 0.1995, 0.0745, 1.0},
- {0.75164, 0.60648, 0.22648, 1.0},
- {0.628281, 0.555802, 0.366065, 1.0},
- 0.4
-};
-
-static MaterialProp mat_silver = {
- {0.19225, 0.19225, 0.19225, 1.0},
- {0.50754, 0.50754, 0.50754, 1.0},
- {0.508273, 0.508273, 0.508273, 1.0},
- 0.4
-};
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ typedef struct _MaterialProp {
+ GLfloat ambient[4];
+ GLfloat diffuse[4];
+ GLfloat specular[4];
+ GLfloat shininess;
+ } MaterialProp;
+
+ static MaterialProp mat_emerald = {
+ {0.0215, 0.1745, 0.0215, 1.0},
+ {0.07568, 0.61424, 0.07568, 1.0},
+ {0.633, 0.727811, 0.633, 1.0},
+ 0.6
+ };
+
+ static MaterialProp mat_jade = {
+ {0.135, 0.2225, 0.1575, 1.0},
+ {0.54, 0.89, 0.63, 1.0},
+ {0.316228, 0.316228, 0.316228, 1.0},
+ 0.1
+ };
+
+ static MaterialProp mat_obsidian = {
+ {0.05375, 0.05, 0.06625, 1.0},
+ {0.18275, 0.17, 0.22525, 1.0},
+ {0.332741, 0.328634, 0.346435, 1.0},
+ 0.3
+ };
+
+ static MaterialProp mat_pearl = {
+ {0.25, 0.20725, 0.20725, 1.0},
+ {1.0, 0.829, 0.829, 1.0},
+ {0.296648, 0.296648, 0.296648, 1.0},
+ 0.088
+ };
+
+ static MaterialProp mat_ruby = {
+ {0.1745, 0.01175, 0.01175, 1.0},
+ {0.61424, 0.04136, 0.04136, 1.0},
+ {0.727811, 0.626959, 0.626959, 1.0},
+ 0.6
+ };
+
+ static MaterialProp mat_turquoise = {
+ {0.1, 0.18725, 0.1745, 1.0},
+ {0.396, 0.74151, 0.69102, 1.0},
+ {0.297254, 0.30829, 0.306678, 1.0},
+ 0.1
+ };
+
+ static MaterialProp mat_brass = {
+ {0.329412, 0.223529, 0.027451, 1.0},
+ {0.780392, 0.568627, 0.113725, 1.0},
+ {0.992157, 0.941176, 0.807843, 1.0},
+ 0.21794872
+ };
+
+ static MaterialProp mat_bronze = {
+ {0.2125, 0.1275, 0.054, 1.0},
+ {0.714, 0.4284, 0.18144, 1.0},
+ {0.393548, 0.271906, 0.166721, 1.0},
+ 0.2
+ };
+
+ static MaterialProp mat_chrome = {
+ {0.25, 0.25, 0.25, 1.0},
+ {0.4, 0.4, 0.4, 1.0},
+ {0.774597, 0.774597, 0.774597, 1.0},
+ 0.6
+ };
+
+ static MaterialProp mat_copper = {
+ {0.19125, 0.0735, 0.0225, 1.0},
+ {0.7038, 0.27048, 0.0828, 1.0},
+ {0.256777, 0.137622, 0.086014, 1.0},
+ 0.1
+ };
+
+ static MaterialProp mat_gold = {
+ {0.24725, 0.1995, 0.0745, 1.0},
+ {0.75164, 0.60648, 0.22648, 1.0},
+ {0.628281, 0.555802, 0.366065, 1.0},
+ 0.4
+ };
+
+ static MaterialProp mat_silver = {
+ {0.19225, 0.19225, 0.19225, 1.0},
+ {0.50754, 0.50754, 0.50754, 1.0},
+ {0.508273, 0.508273, 0.508273, 1.0},
+ 0.4
+ };
+
+#ifdef __cplusplus
+} /* end extern "C" */
+#endif
+
#endif
#include "md5.h"
#include <string.h>
-#undef BYTE_ORDER /* 1 = big-endian, -1 = little-endian, 0 = unknown */
+#undef BYTE_ORDER /* 1 = big-endian, -1 = little-endian, 0 = unknown */
#ifdef ARCH_IS_BIG_ENDIAN
# define BYTE_ORDER (ARCH_IS_BIG_ENDIAN ? 1 : -1)
#else
static void
-md5_process(md5_state_t *pms, const md5_byte_t *data /*[64]*/)
+md5_process(md5_state_t * pms, const md5_byte_t * data /*[64] */ )
{
md5_word_t
a = pms->abcd[0], b = pms->abcd[1],
*/
static const int w = 1;
- if (*((const md5_byte_t *)&w)) /* dynamic little-endian */
+ if (*((const md5_byte_t *) &w)) /* dynamic little-endian */
#endif
#if BYTE_ORDER <= 0 /* little-endian */
{
* On little-endian machines, we can process properly aligned
* data without copying it.
*/
- if (!((data - (const md5_byte_t *)0) & 3)) {
+ if (!((data - (const md5_byte_t *) 0) & 3)) {
/* data are properly aligned */
- X = (const md5_word_t *)data;
+ X = (const md5_word_t *) data;
} else {
/* not aligned */
memcpy(xbuf, data, 64);
# define xbuf X /* (static only) */
# endif
for (i = 0; i < 16; ++i, xp += 4)
- xbuf[i] = xp[0] + (xp[1] << 8) + (xp[2] << 16) + (xp[3] << 24);
+ xbuf[i] =
+ xp[0] + (xp[1] << 8) + (xp[2] << 16) + (xp[3] << 24);
}
#endif
}
t = a + F(b,c,d) + X[k] + Ti;\
a = ROTATE_LEFT(t, s) + b
/* Do the following 16 operations. */
- SET(a, b, c, d, 0, 7, T1);
- SET(d, a, b, c, 1, 12, T2);
- SET(c, d, a, b, 2, 17, T3);
- SET(b, c, d, a, 3, 22, T4);
- SET(a, b, c, d, 4, 7, T5);
- SET(d, a, b, c, 5, 12, T6);
- SET(c, d, a, b, 6, 17, T7);
- SET(b, c, d, a, 7, 22, T8);
- SET(a, b, c, d, 8, 7, T9);
- SET(d, a, b, c, 9, 12, T10);
+ SET(a, b, c, d, 0, 7, T1);
+ SET(d, a, b, c, 1, 12, T2);
+ SET(c, d, a, b, 2, 17, T3);
+ SET(b, c, d, a, 3, 22, T4);
+ SET(a, b, c, d, 4, 7, T5);
+ SET(d, a, b, c, 5, 12, T6);
+ SET(c, d, a, b, 6, 17, T7);
+ SET(b, c, d, a, 7, 22, T8);
+ SET(a, b, c, d, 8, 7, T9);
+ SET(d, a, b, c, 9, 12, T10);
SET(c, d, a, b, 10, 17, T11);
SET(b, c, d, a, 11, 22, T12);
- SET(a, b, c, d, 12, 7, T13);
+ SET(a, b, c, d, 12, 7, T13);
SET(d, a, b, c, 13, 12, T14);
SET(c, d, a, b, 14, 17, T15);
SET(b, c, d, a, 15, 22, T16);
#undef SET
- /* Round 2. */
- /* Let [abcd k s i] denote the operation
- a = b + ((a + G(b,c,d) + X[k] + T[i]) <<< s). */
+ /* Round 2. */
+ /* Let [abcd k s i] denote the operation
+ a = b + ((a + G(b,c,d) + X[k] + T[i]) <<< s). */
#define G(x, y, z) (((x) & (z)) | ((y) & ~(z)))
#define SET(a, b, c, d, k, s, Ti)\
t = a + G(b,c,d) + X[k] + Ti;\
a = ROTATE_LEFT(t, s) + b
- /* Do the following 16 operations. */
- SET(a, b, c, d, 1, 5, T17);
- SET(d, a, b, c, 6, 9, T18);
+ /* Do the following 16 operations. */
+ SET(a, b, c, d, 1, 5, T17);
+ SET(d, a, b, c, 6, 9, T18);
SET(c, d, a, b, 11, 14, T19);
- SET(b, c, d, a, 0, 20, T20);
- SET(a, b, c, d, 5, 5, T21);
- SET(d, a, b, c, 10, 9, T22);
+ SET(b, c, d, a, 0, 20, T20);
+ SET(a, b, c, d, 5, 5, T21);
+ SET(d, a, b, c, 10, 9, T22);
SET(c, d, a, b, 15, 14, T23);
- SET(b, c, d, a, 4, 20, T24);
- SET(a, b, c, d, 9, 5, T25);
- SET(d, a, b, c, 14, 9, T26);
- SET(c, d, a, b, 3, 14, T27);
- SET(b, c, d, a, 8, 20, T28);
- SET(a, b, c, d, 13, 5, T29);
- SET(d, a, b, c, 2, 9, T30);
- SET(c, d, a, b, 7, 14, T31);
+ SET(b, c, d, a, 4, 20, T24);
+ SET(a, b, c, d, 9, 5, T25);
+ SET(d, a, b, c, 14, 9, T26);
+ SET(c, d, a, b, 3, 14, T27);
+ SET(b, c, d, a, 8, 20, T28);
+ SET(a, b, c, d, 13, 5, T29);
+ SET(d, a, b, c, 2, 9, T30);
+ SET(c, d, a, b, 7, 14, T31);
SET(b, c, d, a, 12, 20, T32);
#undef SET
- /* Round 3. */
- /* Let [abcd k s t] denote the operation
- a = b + ((a + H(b,c,d) + X[k] + T[i]) <<< s). */
+ /* Round 3. */
+ /* Let [abcd k s t] denote the operation
+ a = b + ((a + H(b,c,d) + X[k] + T[i]) <<< s). */
#define H(x, y, z) ((x) ^ (y) ^ (z))
#define SET(a, b, c, d, k, s, Ti)\
t = a + H(b,c,d) + X[k] + Ti;\
a = ROTATE_LEFT(t, s) + b
- /* Do the following 16 operations. */
- SET(a, b, c, d, 5, 4, T33);
- SET(d, a, b, c, 8, 11, T34);
+ /* Do the following 16 operations. */
+ SET(a, b, c, d, 5, 4, T33);
+ SET(d, a, b, c, 8, 11, T34);
SET(c, d, a, b, 11, 16, T35);
SET(b, c, d, a, 14, 23, T36);
- SET(a, b, c, d, 1, 4, T37);
- SET(d, a, b, c, 4, 11, T38);
- SET(c, d, a, b, 7, 16, T39);
+ SET(a, b, c, d, 1, 4, T37);
+ SET(d, a, b, c, 4, 11, T38);
+ SET(c, d, a, b, 7, 16, T39);
SET(b, c, d, a, 10, 23, T40);
- SET(a, b, c, d, 13, 4, T41);
- SET(d, a, b, c, 0, 11, T42);
- SET(c, d, a, b, 3, 16, T43);
- SET(b, c, d, a, 6, 23, T44);
- SET(a, b, c, d, 9, 4, T45);
+ SET(a, b, c, d, 13, 4, T41);
+ SET(d, a, b, c, 0, 11, T42);
+ SET(c, d, a, b, 3, 16, T43);
+ SET(b, c, d, a, 6, 23, T44);
+ SET(a, b, c, d, 9, 4, T45);
SET(d, a, b, c, 12, 11, T46);
SET(c, d, a, b, 15, 16, T47);
- SET(b, c, d, a, 2, 23, T48);
+ SET(b, c, d, a, 2, 23, T48);
#undef SET
- /* Round 4. */
- /* Let [abcd k s t] denote the operation
- a = b + ((a + I(b,c,d) + X[k] + T[i]) <<< s). */
+ /* Round 4. */
+ /* Let [abcd k s t] denote the operation
+ a = b + ((a + I(b,c,d) + X[k] + T[i]) <<< s). */
#define I(x, y, z) ((y) ^ ((x) | ~(z)))
#define SET(a, b, c, d, k, s, Ti)\
t = a + I(b,c,d) + X[k] + Ti;\
a = ROTATE_LEFT(t, s) + b
- /* Do the following 16 operations. */
- SET(a, b, c, d, 0, 6, T49);
- SET(d, a, b, c, 7, 10, T50);
+ /* Do the following 16 operations. */
+ SET(a, b, c, d, 0, 6, T49);
+ SET(d, a, b, c, 7, 10, T50);
SET(c, d, a, b, 14, 15, T51);
- SET(b, c, d, a, 5, 21, T52);
- SET(a, b, c, d, 12, 6, T53);
- SET(d, a, b, c, 3, 10, T54);
+ SET(b, c, d, a, 5, 21, T52);
+ SET(a, b, c, d, 12, 6, T53);
+ SET(d, a, b, c, 3, 10, T54);
SET(c, d, a, b, 10, 15, T55);
- SET(b, c, d, a, 1, 21, T56);
- SET(a, b, c, d, 8, 6, T57);
+ SET(b, c, d, a, 1, 21, T56);
+ SET(a, b, c, d, 8, 6, T57);
SET(d, a, b, c, 15, 10, T58);
- SET(c, d, a, b, 6, 15, T59);
+ SET(c, d, a, b, 6, 15, T59);
SET(b, c, d, a, 13, 21, T60);
- SET(a, b, c, d, 4, 6, T61);
+ SET(a, b, c, d, 4, 6, T61);
SET(d, a, b, c, 11, 10, T62);
- SET(c, d, a, b, 2, 15, T63);
- SET(b, c, d, a, 9, 21, T64);
+ SET(c, d, a, b, 2, 15, T63);
+ SET(b, c, d, a, 9, 21, T64);
#undef SET
- /* Then perform the following additions. (That is increment each
- of the four registers by the value it had before this block
- was started.) */
+ /* Then perform the following additions. (That is increment each
+ of the four registers by the value it had before this block
+ was started.) */
pms->abcd[0] += a;
pms->abcd[1] += b;
pms->abcd[2] += c;
pms->abcd[3] += d;
}
-void
-md5_init(md5_state_t *pms)
+void md5_init(md5_state_t * pms)
{
pms->count[0] = pms->count[1] = 0;
pms->abcd[0] = 0x67452301;
- pms->abcd[1] = /*0xefcdab89*/ T_MASK ^ 0x10325476;
- pms->abcd[2] = /*0x98badcfe*/ T_MASK ^ 0x67452301;
+ pms->abcd[1] = /*0xefcdab89 */ T_MASK ^ 0x10325476;
+ pms->abcd[2] = /*0x98badcfe */ T_MASK ^ 0x67452301;
pms->abcd[3] = 0x10325476;
}
-void
-md5_append(md5_state_t *pms, const md5_byte_t *data, int nbytes)
+void md5_append(md5_state_t * pms, const md5_byte_t * data, int nbytes)
{
const md5_byte_t *p = data;
size_t left = nbytes;
int offset = (pms->count[0] >> 3) & 63;
- md5_word_t nbits = (md5_word_t)(nbytes << 3);
+ md5_word_t nbits = (md5_word_t) (nbytes << 3);
if (nbytes <= 0)
return;
memcpy(pms->buf, p, left);
}
-void
-md5_finish(md5_state_t *pms, md5_byte_t digest[16])
+void md5_finish(md5_state_t * pms, md5_byte_t digest[16])
{
static const md5_byte_t pad[64] = {
0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/* Save the length before padding. */
for (i = 0; i < 8; ++i)
- data[i] = (md5_byte_t)(pms->count[i >> 2] >> ((i & 3) << 3));
+ data[i] = (md5_byte_t) (pms->count[i >> 2] >> ((i & 3) << 3));
/* Pad to 56 bytes mod 64. */
md5_append(pms, pad, ((55 - (pms->count[0] >> 3)) & 63) + 1);
/* Append the length. */
md5_append(pms, data, 8);
for (i = 0; i < 16; ++i)
- digest[i] = (md5_byte_t)(pms->abcd[i >> 2] >> ((i & 3) << 3));
+ digest[i] = (md5_byte_t) (pms->abcd[i >> 2] >> ((i & 3) << 3));
}
* efficiently on either one than if ARCH_IS_BIG_ENDIAN is defined.
*/
-typedef unsigned char md5_byte_t; /* 8-bit byte */
-typedef unsigned int md5_word_t; /* 32-bit word */
+typedef unsigned char md5_byte_t; /* 8-bit byte */
+typedef unsigned int md5_word_t; /* 32-bit word */
/* Define the state of the MD5 Algorithm. */
typedef struct md5_state_s {
} md5_state_t;
#ifdef __cplusplus
-extern "C"
-{
+extern "C" {
#endif
/* Initialize the algorithm. */
-void md5_init(md5_state_t *pms);
+ void md5_init(md5_state_t * pms);
/* Append a string to the message. */
-void md5_append(md5_state_t *pms, const md5_byte_t *data, int nbytes);
+ void md5_append(md5_state_t * pms, const md5_byte_t * data,
+ int nbytes);
/* Finish the message and return the digest. */
-void md5_finish(md5_state_t *pms, md5_byte_t digest[16]);
+ void md5_finish(md5_state_t * pms, md5_byte_t digest[16]);
#ifdef __cplusplus
-} /* end extern "C" */
+} /* end extern "C" */
#endif
-
-#endif /* md5_INCLUDED */
+#endif /* md5_INCLUDED */
//select functions
-static Agsym_t*
-getNodeSelectedAttr (Agraph_t* g)
+static Agsym_t *getNodeSelectedAttr(Agraph_t * g)
{
- static Agraph_t* saveg;
- static Agsym_t* saveattr;
+ static Agraph_t *saveg;
+ static Agsym_t *saveattr;
if (saveg != g) {
saveg = g;
- if (!(saveattr = agattr(saveg,AGNODE,"selected",0))) {
- saveattr = agattr(saveg,AGNODE,"selected","0");
+ if (!(saveattr = agattr(saveg, AGNODE, "selected", 0))) {
+ saveattr = agattr(saveg, AGNODE, "selected", "0");
}
}
return saveattr;
}
-static Agsym_t*
-getEdgeSelectedAttr (Agraph_t* g)
+static Agsym_t *getEdgeSelectedAttr(Agraph_t * g)
{
- static Agraph_t* saveg;
- static Agsym_t* saveattr;
+ static Agraph_t *saveg;
+ static Agsym_t *saveattr;
if (saveg != g) {
saveg = g;
- if (!(saveattr = agattr(saveg,AGEDGE,"selected",0))) {
- saveattr = agattr(saveg,AGEDGE,"selected","0");
+ if (!(saveattr = agattr(saveg, AGEDGE, "selected", 0))) {
+ saveattr = agattr(saveg, AGEDGE, "selected", "0");
}
}
return saveattr;
}
-int select_node(topview_node* N)
+int select_node(topview_node * N)
{
- Agsym_t* a = getNodeSelectedAttr(N->Node->root);
+ Agsym_t *a = getNodeSelectedAttr(N->Node->root);
- N->data.Selected=1;
- return agxset (N->Node, a, "1");
+ N->data.Selected = 1;
+ return agxset(N->Node, a, "1");
}
-int select_edge(topview_edge* E)
+int select_edge(topview_edge * E)
{
- Agsym_t* a = getEdgeSelectedAttr(aghead(E->Edge)->root);
+ Agsym_t *a = getEdgeSelectedAttr(aghead(E->Edge)->root);
- E->data.Selected=1;
- return agxset (E->Edge, a, "1");
+ E->data.Selected = 1;
+ return agxset(E->Edge, a, "1");
}
-int deselect_node(topview_node* N)
+int deselect_node(topview_node * N)
{
- Agsym_t* a = getNodeSelectedAttr(N->Node->root);
-
- N->data.Selected=0;
+ Agsym_t *a = getNodeSelectedAttr(N->Node->root);
+
+ N->data.Selected = 0;
return agxset(N->Node, a, "0");
}
-int deselect_edge(topview_edge* E)
+int deselect_edge(topview_edge * E)
{
- Agsym_t* a = getEdgeSelectedAttr(aghead(E->Edge)->root);
+ Agsym_t *a = getEdgeSelectedAttr(aghead(E->Edge)->root);
- E->data.Selected=0;
+ E->data.Selected = 0;
return agxset(E->Edge, a, "0");
}
#if UNUSED
-static void update_cgraph_pos(topview_node* N)
+static void update_cgraph_pos(topview_node * N)
{
char buf[512];
- Agsym_t* pos;
- Agnode_t* obj=N->Node;
+ Agsym_t *pos;
+ Agnode_t *obj = N->Node;
- if ((pos = agattrsym (obj, "pos"))) {
- sprintf (buf, "%lf,%lf",N->distorted_x,N->distorted_y);
+ if ((pos = agattrsym(obj, "pos"))) {
+ sprintf(buf, "%lf,%lf", N->distorted_x, N->distorted_y);
agxset(obj, pos, buf);
}
}
{
int ind = 0;
//check if in the list
- for (ind = 0; ind < view->Topview->Nodecount;ind ++)
- {
- select_node(&view->Topview->Nodes[ind]);
+ for (ind = 0; ind < view->Topview->Nodecount; ind++) {
+ select_node(&view->Topview->Nodes[ind]);
}
return 1;
}
{
int ind = 0;
//check if in the list
- for (ind = 0; ind < view->Topview->Edgecount;ind ++)
- {
- select_edge(&view->Topview->Edges[ind]);
+ for (ind = 0; ind < view->Topview->Edgecount; ind++) {
+ select_edge(&view->Topview->Edges[ind]);
}
return 1;
{
int ind = 0;
//check if in the list
- for (ind = 0; ind < view->Topview->Nodecount;ind ++)
- {
- deselect_node(&view->Topview->Nodes[ind]);
+ for (ind = 0; ind < view->Topview->Nodecount; ind++) {
+ deselect_node(&view->Topview->Nodes[ind]);
}
return 1;
{
int ind = 0;
//check if in the list
- for (ind = 0; ind < view->Topview->Edgecount;ind ++)
- {
- deselect_edge(&view->Topview->Edges[ind]);
+ for (ind = 0; ind < view->Topview->Edgecount; ind++) {
+ deselect_edge(&view->Topview->Edges[ind]);
}
return 1;
}
+
int select_all(Agraph_t * g)
{
select_all_nodes(g);
return 1;
}
-int deselect_all(Agraph_t* g)
+
+int deselect_all(Agraph_t * g)
{
deselect_all_nodes(g);
deselect_all_edges(g);
float x, y, m, iter;
float RX, RY, RW, RH;
int intersects, in;
- if (view->mouse.mouse_mode == MM_SINGLE_SELECT)
- {
- RW = 10;
- RH = 10;
- }
+ if (view->mouse.mouse_mode == MM_SINGLE_SELECT) {
+ RW = 10;
+ RH = 10;
+ }
RX = view->Selection.X;
RY = view->Selection.Y;
return (a <= 1);
}
int point_within_sphere_with_coords(float x0, float y0, float z0, float r,
- float x, float y,float z)
+ float x, float y, float z)
{
- float rr=(x-x0)*(x-x0)+(y-y0)*(y-y0)+(z-z0)*(z-z0);
- rr=(float)pow(rr,0.5);
- if (rr <= r)
- return 1;
- return 0;
+ float rr =
+ (x - x0) * (x - x0) + (y - y0) * (y - y0) + (z - z0) * (z - z0);
+ rr = (float) pow(rr, 0.5);
+ if (rr <= r)
+ return 1;
+ return 0;
}
-float distance_to_line(float ax,float ay,float bx,float by,float cx,float cy)
+float distance_to_line(float ax, float ay, float bx, float by, float cx,
+ float cy)
{
- //this function returns the distance between a line(a-b) segment and a point(c) in 2D plane
- return (float)sqrt(
- pow(((by-ay)*(cx-ax)+(bx-ax)*(cy-ay)),2)
- /
- ( pow((bx-ax),2) + pow((by-ay),2))
- );
+ //this function returns the distance between a line(a-b) segment and a point(c) in 2D plane
+ return (float)
+ sqrt(pow(((by - ay) * (cx - ax) + (bx - ax) * (cy - ay)), 2)
+ / (pow((bx - ax), 2) + pow((by - ay), 2))
+ );
}
#include "draw.h"
#include <GL/gl.h>
+#ifdef __cplusplus
+extern "C" {
+#endif
+
#define SELECTION_SEGMENT_DIVIDER 5.0 //control points count to check if a line segment is withing clipping rect
#define SINGLE_SELECTION_WIDTH 10 //width of the rect clip for single selections , higher values more catches less sensitivity
-extern int lineintersects(float X1, float X2, float Y1, float Y2);
-extern int point_within_ellips_with_coords(float ex, float ey, float ea,
- float eb, float px, float py);
-extern int is_point_in_rectangle(float X, float Y, float RX, float RY,
- float RW, float RH);
+ extern int lineintersects(float X1, float X2, float Y1, float Y2);
+ extern int point_within_ellips_with_coords(float ex, float ey,
+ float ea, float eb,
+ float px, float py);
+ extern int is_point_in_rectangle(float X, float Y, float RX, float RY,
+ float RW, float RH);
-extern int SelectBeziers(sdot_op * op);
-extern int SelectEllipse(sdot_op * op);
-extern int SelectPolygon(sdot_op * op);
-extern int SelectPolyline(sdot_op * op);
+ extern int SelectBeziers(sdot_op * op);
+ extern int SelectEllipse(sdot_op * op);
+ extern int SelectPolygon(sdot_op * op);
+ extern int SelectPolyline(sdot_op * op);
-extern int SelectText(sdot_op * op);
-extern int SelectImage(sdot_op * op);
+ extern int SelectText(sdot_op * op);
+ extern int SelectImage(sdot_op * op);
-extern int select_node(topview_node*);
-extern int select_edge(topview_edge*);
+ extern int select_node(topview_node *);
+ extern int select_edge(topview_edge *);
-extern int deselect_node(topview_node*);
-extern int deselect_edge(topview_edge* );
+ extern int deselect_node(topview_node *);
+ extern int deselect_edge(topview_edge *);
-extern int select_all_nodes(Agraph_t*);
-extern int select_all_edges(Agraph_t*);
-extern int select_all(Agraph_t*);
+ extern int select_all_nodes(Agraph_t *);
+ extern int select_all_edges(Agraph_t *);
+ extern int select_all(Agraph_t *);
-extern int deselect_all_nodes(Agraph_t*);
-extern int deselect_all_edges(Agraph_t*);
-extern int deselect_all(Agraph_t*);
-int point_within_sphere_with_coords(float x0, float y0, float z0, float r,float x, float y,float z);
-float distance_to_line(float ax,float ay,float bx,float by,float cx,float cy);
+ extern int deselect_all_nodes(Agraph_t *);
+ extern int deselect_all_edges(Agraph_t *);
+ extern int deselect_all(Agraph_t *);
+ int point_within_sphere_with_coords(float x0, float y0, float z0,
+ float r, float x, float y,
+ float z);
+ float distance_to_line(float ax, float ay, float bx, float by,
+ float cx, float cy);
+#ifdef __cplusplus
+} /* end extern "C" */
+#endif
#endif
#include "hier.h"
#include "md5.h"
#include "glutils.h"
-#include "arcball.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ typedef struct _ArcBall_t ArcBall_t;
#define IS_TEST_MODE_ON 0
#define DEFAULT_MAGNIFIER_WIDTH 300
#define SPHERE_SLICE_COUNT 6
#define DOT_SIZE_CORRECTION_FAC 0.3
-typedef enum { nodshapedot,nodeshapecircle} node_shape;
-typedef enum { leftmousebutton,rightmousebutton,thirdmousebutton} clicked_mouse_button;
-typedef enum { MOUSE_ROTATE_X,MOUSE_ROTATE_Y,MOUSE_ROTATE_XY,MOUSE_ROTATE_Z} mouse_rotate_axis;
+ typedef enum { nodshapedot, nodeshapecircle } node_shape;
+ typedef enum { leftmousebutton, rightmousebutton,
+ thirdmousebutton } clicked_mouse_button;
+ typedef enum { MOUSE_ROTATE_X, MOUSE_ROTATE_Y, MOUSE_ROTATE_XY,
+ MOUSE_ROTATE_Z } mouse_rotate_axis;
-typedef struct {
- float R;
- float G;
- float B;
- float A; //Alpha
- int tag; /*custom data field*/
-} RGBColor;
+ typedef struct {
+ float R;
+ float G;
+ float B;
+ float A; //Alpha
+ int tag; /*custom data field */
+ } RGBColor;
#define MAX_BTN_CNT 50
-typedef struct{
+ typedef struct {
float perc;
RGBColor c;
int smooth;
-}colorschema;
+ } colorschema;
-typedef struct{
- char* script;
- char* args;
- char* attr_name; /*attribute name to identify script in the graph*/
-}gvprscript;
+ typedef struct {
+ char *script;
+ char *args;
+ char *attr_name; /*attribute name to identify script in the graph */
+ } gvprscript;
-typedef struct{
+ typedef struct {
int schemacount;
- colorschema* s;
-}colorschemaset;
-
-
-
-typedef enum {
- VT_NONE,
- VT_XDOT,
- VT_TOPVIEW,
- VT_TOPFISH,
-} viewtype_t;
-
-
-typedef enum {
- GVE_NONE = -1,
- GVE_GRAPH,
- GVE_CLUSTER,
- GVE_NODE,
- GVE_EDGE /* keep last */
-} gve_element;
-
-typedef enum {
- GVK_NONE = -1,
- GVK_DOT,
- GVK_NEATO,
- GVK_TWOPI,
- GVK_CIRCO,
- GVK_FDP,
- GVK_SFDP/* keep last */
-} gvk_layout;
-
-typedef struct {
+ colorschema *s;
+ } colorschemaset;
+
+
+
+ typedef enum {
+ VT_NONE,
+ VT_XDOT,
+ VT_TOPVIEW,
+ VT_TOPFISH,
+ } viewtype_t;
+
+
+ typedef enum {
+ GVE_NONE = -1,
+ GVE_GRAPH,
+ GVE_CLUSTER,
+ GVE_NODE,
+ GVE_EDGE /* keep last */
+ } gve_element;
+
+ typedef enum {
+ GVK_NONE = -1,
+ GVK_DOT,
+ GVK_NEATO,
+ GVK_TWOPI,
+ GVK_CIRCO,
+ GVK_FDP,
+ GVK_SFDP /* keep last */
+ } gvk_layout;
+
+ typedef struct {
int anglex;
int angley;
int anglez;
-} rotation;
+ } rotation;
-typedef struct {
+ typedef struct {
int anglex;
int angley;
int anglez;
-} gl3DNav;
+ } gl3DNav;
-typedef struct {
- GtkButton **gtkhostbtn;
- int gtkhostbtncount;
- GtkColorButton **gtkhostcolor;
- int hostactive[MAX_BTN_CNT]; //temporary static, convert to dynamic,realloc
- char **hostregex;
-} topviewdata;
+ typedef struct {
+ GtkButton **gtkhostbtn;
+ int gtkhostbtncount;
+ GtkColorButton **gtkhostcolor;
+ int hostactive[MAX_BTN_CNT]; //temporary static, convert to dynamic,realloc
+ char **hostregex;
+ } topviewdata;
-typedef struct xdot_set xdot_set;
+ typedef struct xdot_set xdot_set;
//bind this to cgraph g
/*
*/
-typedef enum { GEpixels, GEinches, GEmm } GEunit;
-
-typedef struct _object_data //has to be attached to every Node, Edge, Graph and cluster
-{
- Agrec_t h;
- int ID;
- char *ObjName;
- int ObjType;
- int Layer;
- int Visible;
- int Locked;
- int Highlighted;
- int Selected;
- int Preselected;
- int NumDataCount;
- float *NumData;
- int StrDataCount;
- char **StrData;
- int selectionflag;
- int param; //generic purpose param
- int TVRef; //Topview reference
- int edgeid; /*for only edges, > 0 multiedges*/
-
-} element_data;
-typedef struct _temp_node_record //helper record to identofy head and tail of edges
-{
- Agrec_t h;
- int ID;
- int TVref; //topview data structure reference
-}temp_node_record;
+ typedef enum { GEpixels, GEinches, GEmm } GEunit;
+
+ typedef struct _object_data //has to be attached to every Node, Edge, Graph and cluster
+ {
+ Agrec_t h;
+ int ID;
+ char *ObjName;
+ int ObjType;
+ int Layer;
+ int Visible;
+ int Locked;
+ int Highlighted;
+ int Selected;
+ int Preselected;
+ int NumDataCount;
+ float *NumData;
+ int StrDataCount;
+ char **StrData;
+ int selectionflag;
+ int param; //generic purpose param
+ int TVRef; //Topview reference
+ int edgeid; /*for only edges, > 0 multiedges */
+
+ } element_data;
+ typedef struct _temp_node_record //helper record to identofy head and tail of edges
+ {
+ Agrec_t h;
+ int ID;
+ int TVref; //topview data structure reference
+ } temp_node_record;
/*#define OD_ID(p) (((custom_object_data*)AGDATA(p))->ID)
#define OD_ObjName(p) (((custom_object_data*)AGDATA(p))->ObjName)
-typedef enum { CAM_PERSPECTIVE,CAM_ORTHO} cam_t;
+ typedef enum { CAM_PERSPECTIVE, CAM_ORTHO } cam_t;
-typedef struct _viewport_camera{
+ typedef struct _viewport_camera {
float x;
float y;
float z;
float r;
- cam_t type; //
-} viewport_camera;
-
-
-
-typedef struct {
- Agnode_t *Node;
- /*original coordinates */
- float x;
- float y;
- float z;
- /*coordinates to draw */
- float distorted_x;
- float distorted_y;
- float distorted_z;
- float zoom_factor;
- int in_fish_eye; //boolean value if to apply fisheye
- RGBColor Color;
- RGBColor GroupColor;
- int GroupIndex; //default -1;
- int update_required;
- char *Label;
- char *Label2;
- int degree;
- float node_alpha;
- int valid;
+ cam_t type; //
+ } viewport_camera;
+
+
+
+ typedef struct {
+ Agnode_t *Node;
+ /*original coordinates */
+ float x;
+ float y;
+ float z;
+ /*coordinates to draw */
+ float distorted_x;
+ float distorted_y;
+ float distorted_z;
+ float zoom_factor;
+ int in_fish_eye; //boolean value if to apply fisheye
+ RGBColor Color;
+ RGBColor GroupColor;
+ int GroupIndex; //default -1;
+ int update_required;
+ char *Label;
+ char *Label2;
+ int degree;
+ float node_alpha;
+ int valid;
element_data data;
float size;
-} topview_node;
-
-typedef struct {
-// topview_node *Tnode; //Tail node
-// topview_node *Hnode; //Tail node
- Agedge_t *Edge; //edge itself
- float x1;
- float y1;
- float z1;
- float x2;
- float y2;
- float z2;
+ } topview_node;
+
+ typedef struct {
+// topview_node *Tnode; //Tail node
+// topview_node *Hnode; //Tail node
+ Agedge_t *Edge; //edge itself
+ float x1;
+ float y1;
+ float z1;
+ float x2;
+ float y2;
+ float z2;
float length;
- topview_node *Node1; //Tail
- topview_node *Node2; //Head
- RGBColor Color;
- int update_required;
+ topview_node *Node1; //Tail
+ topview_node *Node2; //Head
+ RGBColor Color;
+ int update_required;
element_data data;
-} topview_edge;
-typedef struct _graph_data {
- Agrec_t h;
- char *GraphFileName;
- //graph's location, change these to move the whole graph
- int Modified; //if graph has been modified after loading
- float offsetx;
- float offsety;
- float offsetz;
-} graph_data;
-
-typedef struct {
- topview_node *Nodes;
- topview_edge *Edges;
- int Nodecount;
- int Edgecount;
- int limits[4];
- topviewdata *TopviewData;
- void *customptr;
- Hierarchy *h;
+ } topview_edge;
+ typedef struct _graph_data {
+ Agrec_t h;
+ char *GraphFileName;
+ //graph's location, change these to move the whole graph
+ int Modified; //if graph has been modified after loading
+ float offsetx;
+ float offsety;
+ float offsetz;
+ } graph_data;
+
+ typedef struct {
+ topview_node *Nodes;
+ topview_edge *Edges;
+ int Nodecount;
+ int Edgecount;
+ int limits[4];
+ topviewdata *TopviewData;
+ void *customptr;
+ Hierarchy *h;
glCompColor srcColor; //fine node colors of topfisheye
- glCompColor tarColor; //supernode colors of fisheye
- int is_top_fisheye; //1 draw hierarchy 0 draw regular topview
- focus_t* fs;
- struct {
- reposition_t repos;
- levelparms_t level;
- hierparms_t hier;
- } parms;
+ glCompColor tarColor; //supernode colors of fisheye
+ int is_top_fisheye; //1 draw hierarchy 0 draw regular topview
+ focus_t *fs;
+ struct {
+ reposition_t repos;
+ levelparms_t level;
+ hierparms_t hier;
+ } parms;
int animate;
- topview_node** picked_nodes;
+ topview_node **picked_nodes;
int picked_node_count;
- topview_edge** picked_edges;
+ topview_edge **picked_edges;
int picked_edge_count;
graph_data Graphdata;
float init_node_size; //raster size of node
float init_zoom;
float fitin_zoom;
- xdot_set* xdot_list; /*xdot attached to whole graph*/
+ xdot_set *xdot_list; /*xdot attached to whole graph */
-} topview;
+ } topview;
-enum {
- COL_NAME = 0,
- COL_FILENAME,
- NUM_COLS
-};
+ enum {
+ COL_NAME = 0,
+ COL_FILENAME,
+ NUM_COLS
+ };
-typedef struct _mouse_attr {
- int mouse_down;
- int mouse_mode;
+ typedef struct _mouse_attr {
+ int mouse_down;
+ int mouse_mode;
int pick;
- float mouse_X;
- float mouse_Y;
+ float mouse_X;
+ float mouse_Y;
float begin_x;
float begin_y;
float dx;
- float dy;
- float GLX;/*opengl coordiantes for right click*/
+ float dy;
+ float GLX; /*opengl coordiantes for right click */
float GLY;
float GLZ;
- mouse_rotate_axis rotate_axis;
+ mouse_rotate_axis rotate_axis;
clicked_mouse_button button;
-} mouse_attr;
+ } mouse_attr;
-typedef struct _attribute {
- char Type;
- char *Name;
- char *Default;
- char ApplyTo[GVE_EDGE+1];
- char Engine[GVK_FDP+1];
- char **ComboValues;
- int ComboValuesCount;
- GtkWidget *attrWidget;
+ typedef struct _attribute {
+ char Type;
+ char *Name;
+ char *Default;
+ char ApplyTo[GVE_EDGE + 1];
+ char Engine[GVK_FDP + 1];
+ char **ComboValues;
+ int ComboValuesCount;
+ GtkWidget *attrWidget;
-} attribute;
+ } attribute;
-typedef struct _selection {
- int Active; //0 there is no selection need to be applied
- char Type; //0 single selection , 1 rectangle , 2 rectangleX
+ typedef struct _selection {
+ int Active; //0 there is no selection need to be applied
+ char Type; //0 single selection , 1 rectangle , 2 rectangleX
int PickingType; //0 normal, union,2 subtract 3 intersection
- float X, Y, W, H; //selection boundries
- int Anti; //subtract selections if 1
- int AlreadySelected; //for single selections to avoid selecting more than one object
- RGBColor SelectionColor;
- float node_distance; //to get the closest node , this value is updated for each node, distance between selection coords and node coords, smallest gets to be selected
- topview_node* single_selected_node; //pointer to selected node in a single node/edge selection cycle,after each node loop this value is checked and if it is in the limits that node is selected or deselected
- //before the node/edge loop this value is nulled
- topview_edge* single_selected_edge;//pointer to selected/picked edge
-
-} selection;
-typedef struct _magnifier {
- float x, y;
- float kts; //zoom X
- float GLwidth, GLheight;
- int width, height; //how big is the magnifier referenced from windows
- int active;
-} magnifier;
-
-typedef struct _fisheye_magnifier {
- float x, y; //center coords of active circle
- float distortion_factor; //distortion factor ,default 1
- int R; //radius of the magnifier
- int constantR; //radius of the magnifier referenced from windows
- int active;
- int fisheye_distortion_fac;
-} fisheye_magnifier;
-
-
-
-typedef struct _ViewInfo
-{
- /*view variables*/
+ float X, Y, W, H; //selection boundries
+ int Anti; //subtract selections if 1
+ int AlreadySelected; //for single selections to avoid selecting more than one object
+ RGBColor SelectionColor;
+ float node_distance; //to get the closest node , this value is updated for each node, distance between selection coords and node coords, smallest gets to be selected
+ topview_node *single_selected_node; //pointer to selected node in a single node/edge selection cycle,after each node loop this value is checked and if it is in the limits that node is selected or deselected
+ //before the node/edge loop this value is nulled
+ topview_edge *single_selected_edge; //pointer to selected/picked edge
+
+ } selection;
+ typedef struct _magnifier {
+ float x, y;
+ float kts; //zoom X
+ float GLwidth, GLheight;
+ int width, height; //how big is the magnifier referenced from windows
+ int active;
+ } magnifier;
+
+ typedef struct _fisheye_magnifier {
+ float x, y; //center coords of active circle
+ float distortion_factor; //distortion factor ,default 1
+ int R; //radius of the magnifier
+ int constantR; //radius of the magnifier referenced from windows
+ int active;
+ int fisheye_distortion_fac;
+ } fisheye_magnifier;
+
+
+
+ typedef struct _ViewInfo {
+ /*view variables */
float panx;
float pany;
float panz;
float prevpanz;
float zoom;
- /*clipping coordinates, to avoid unnecesarry rendering*/
- float clipX1,clipX2,clipY1,clipY2,clipZ1,clipZ2;
+ /*clipping coordinates, to avoid unnecesarry rendering */
+ float clipX1, clipX2, clipY1, clipY2, clipZ1, clipZ2;
- /*background color*/
+ /*background color */
RGBColor bgColor;
- /*default pen color*/
+ /*default pen color */
RGBColor penColor;
- /*default fill color*/
+ /*default fill color */
RGBColor fillColor;
- /*highlighted Node Color*/
+ /*highlighted Node Color */
RGBColor highlightedNodeColor;
- /*highlighted Edge Color*/
+ /*highlighted Edge Color */
RGBColor highlightedEdgeColor;
- /*grid color*/
+ /*grid color */
RGBColor gridColor; //grid color
- /*border color*/
+ /*border color */
RGBColor borderColor;
- /*selected node color*/
+ /*selected node color */
RGBColor selectedNodeColor;
- /*selected edge color*/
+ /*selected edge color */
RGBColor selectedEdgeColor;
- /*default node alpha*/
+ /*default node alpha */
float defaultnodealpha;
- /*default edge alpha*/
+ /*default edge alpha */
float defaultedgealpha;
- /*default node shape*/
+ /*default node shape */
int defaultnodeshape;
- /*default line width*/
+ /*default line width */
float LineWidth;
-
- /*grid is drawn if this variable is 1*/
- int gridVisible;
- /*grid cell size in gl coords system*/
- float gridSize; //grid cell size
- /*draws a border in border colors if it is 1*/
- int bdVisible; //if borders are visible (boundries of the drawing,
- /*border coordinates, needs to be calculated for each graph*/
+ /*grid is drawn if this variable is 1 */
+ int gridVisible;
+ /*grid cell size in gl coords system */
+ float gridSize; //grid cell size
- /*randomize node colors or use default node color*/
+ /*draws a border in border colors if it is 1 */
+ int bdVisible; //if borders are visible (boundries of the drawing,
+ /*border coordinates, needs to be calculated for each graph */
+
+ /*randomize node colors or use default node color */
int rndNodeColor;
- /*randomize edge colors or use default edge color*/
+ /*randomize edge colors or use default edge color */
int rndEdgeColor;
- /*Font Size*/
+ /*Font Size */
float FontSize;
- float bdxLeft,bdyTop,bdzTop;
- float bdxRight,bdyBottom,bdzBottom;
+ float bdxLeft, bdyTop, bdzTop;
+ float bdxRight, bdyBottom, bdzBottom;
- /*reserved , not being used yet*/
- GEunit unit; //default pixels :0
+ /*reserved , not being used yet */
+ GEunit unit; //default pixels :0
- /*variable to hold mouse coordinates temporarily*/
- float GLx,GLy,GLz;
- /*this is second set of mouse coordinates holder for, it is needed to draw a rectangle with mouse*/
- float GLx2,GLy2,GLz2;
+ /*variable to hold mouse coordinates temporarily */
+ float GLx, GLy, GLz;
+ /*this is second set of mouse coordinates holder for, it is needed to draw a rectangle with mouse */
+ float GLx2, GLy2, GLz2;
- /*screen window size in 2d*/
- int w,h;
- /*graph pointer to hold loaded graphs*/
- Agraph_t** g;
- /*number of graphs loaded*/
- int graphCount;
- /*active graph*/
- int activeGraph;
+ /*screen window size in 2d */
+ int w, h;
+ /*graph pointer to hold loaded graphs */
+ Agraph_t **g;
+ /*number of graphs loaded */
+ int graphCount;
+ /*active graph */
+ int activeGraph;
- /*texture data*/
- int texture; /*1 texturing enabled, 0 disabled*/
- /*opengl depth value to convert mouse to GL coords*/
- float GLDepth;
+ /*texture data */
+ int texture; /*1 texturing enabled, 0 disabled */
+ /*opengl depth value to convert mouse to GL coords */
+ float GLDepth;
- /*stores the info about status of mouse,pressed? what button ? where?*/
+ /*stores the info about status of mouse,pressed? what button ? where? */
mouse_attr mouse;
- /*selection object,refer to smyrnadefs.h for more info*/
+ /*selection object,refer to smyrnadefs.h for more info */
selection Selection;
- /*rectangular magnifier object*/
+ /*rectangular magnifier object */
magnifier mg;
- /*fisheye magnifier object*/
+ /*fisheye magnifier object */
fisheye_magnifier fmg;
- viewport_camera** cameras;
- int camera_count; //number of cameras
+ viewport_camera **cameras;
+ int camera_count; //number of cameras
int active_camera;
- viewport_camera* selected_camera; //selected camera does not have to nec. be active one
+ viewport_camera *selected_camera; //selected camera does not have to nec. be active one
- /*data attributes are read from graph's attributes DataAttribute1 and DataAttribute2*/
- char* node_data_attribute1; /*for topview graphs this is the node data attribute to put as label*/
- char* node_data_attribute2; /*for topview graphs this is the node data attribute to be stored and used for something else*/
+ /*data attributes are read from graph's attributes DataAttribute1 and DataAttribute2 */
+ char *node_data_attribute1; /*for topview graphs this is the node data attribute to put as label */
+ char *node_data_attribute2; /*for topview graphs this is the node data attribute to be stored and used for something else */
- /*0 advanced users with editing options 1 nonice users just navigate (glmenu system)*/
- int topviewusermode;
- /*this should not be confused with graphviz node shapes, it can be dot or circles (dots are rendered mych faster, circle looks handsome, if graph is ulta large go with dot*/
-// node_shape nodeshape;
- /*if true and nodeshape is nodeshapecircle , radius of nodes changes with degree*/
+ /*0 advanced users with editing options 1 nonice users just navigate (glmenu system) */
+ int topviewusermode;
+ /*this should not be confused with graphviz node shapes, it can be dot or circles (dots are rendered mych faster, circle looks handsome, if graph is ulta large go with dot */
+// node_shape nodeshape;
+ /*if true and nodeshape is nodeshapecircle , radius of nodes changes with degree */
int nodesizewithdegree;
- /*open gl canvas, used to be a globa variable before looks better wrapped in viewinfo*/
- GtkWidget *drawing_area;
+ /*open gl canvas, used to be a globa variable before looks better wrapped in viewinfo */
+ GtkWidget *drawing_area;
- /*some boolean variable for variety hacks used in the software*/
+ /*some boolean variable for variety hacks used in the software */
int SignalBlock;
- /*Topview data structure, refer topview.h for more info*/
- topview* Topview;
- Agraph_t* default_attributes;
- /*timer for animations*/
- GTimer* timer;
- /*this timer is session timer and always active*/
- GTimer* timer2;
+ /*Topview data structure, refer topview.h for more info */
+ topview *Topview;
+ Agraph_t *default_attributes;
+ /*timer for animations */
+ GTimer *timer;
+ /*this timer is session timer and always active */
+ GTimer *timer2;
int active_frame;
int total_frames;
int frame_length;
- /*lately added*/
+ /*lately added */
int drawnodes;
int drawedges;
int drawlabels;
int drawnodelabels;
int drawedgelabels;
- /*labelling properties*/
- void* glutfont;
+ /*labelling properties */
+ void *glutfont;
glCompColor nodelabelcolor;
glCompColor edgelabelcolor;
int labelwithdegree;
viewtype_t dfltViewType;
gvk_layout dfltEngine;
- GtkTextBuffer* consoleText;
+ GtkTextBuffer *consoleText;
float FontSizeConst;
- glCompSet *widgets; //for novice user open gl menu
- int visiblenodecount; /*helper variable to know the number of the nodes being rendered, good data to optimize speed*/
- md5_byte_t orig_key[16] ; /*md5 result for original graph*/
- md5_byte_t final_key[16] ; /*md5 result right before graph is saved*/
- char* initFileName; //file name from command line
+ glCompSet *widgets; //for novice user open gl menu
+ int visiblenodecount; /*helper variable to know the number of the nodes being rendered, good data to optimize speed */
+ md5_byte_t orig_key[16]; /*md5 result for original graph */
+ md5_byte_t final_key[16]; /*md5 result right before graph is saved */
+ char *initFileName; //file name from command line
int initFile;
- colorschemaset* colschms;
- char* template_file;
- char* glade_file;
- char* attr_file;
+ colorschemaset *colschms;
+ char *template_file;
+ char *glade_file;
+ char *attr_file;
int flush;
line interpol;
- gvprscript* scripts;
- int script_count; /*# of scripts*/
- GtkComboBox* graphComboBox;/*pointer to graph combo box at top right*/
- ArcBall_t* arcball;
+ gvprscript *scripts;
+ int script_count; /*# of scripts */
+ GtkComboBox *graphComboBox; /*pointer to graph combo box at top right */
+ ArcBall_t *arcball;
-} ViewInfo;
+ } ViewInfo;
/*rotation steps*/
+ extern ViewInfo *view;
+ extern GtkMessageDialog *Dlg;
+ extern int respond;
+ extern char *smyrnaPath(char *suffix);
+ extern char *smyrnaGlade;
+ extern void glexpose(void);
+ extern char *layout2s(gvk_layout gvkl);
+ extern gvk_layout s2layout(char *s);
+ extern char *element2s(gve_element);
+ extern unsigned char SmrynaVerbose;
-extern ViewInfo *view;
-extern GtkMessageDialog *Dlg;
-extern int respond;
-extern char* smyrnaPath (char* suffix);
-extern char* smyrnaGlade;
-
-extern void glexpose(void);
-
-extern char* layout2s (gvk_layout gvkl);
-extern gvk_layout s2layout (char* s);
-extern char* element2s (gve_element);
-extern unsigned char SmrynaVerbose;
-
+#ifdef __cplusplus
+} /* end extern "C" */
+#endif
#endif
#include "support.h"
-GtkWidget*
-lookup_widget (GtkWidget *widget,
- const gchar *widget_name)
+GtkWidget *lookup_widget(GtkWidget * widget, const gchar * widget_name)
{
- GtkWidget *parent, *found_widget;
-
- for (;;)
- {
- if (GTK_IS_MENU (widget))
- parent = gtk_menu_get_attach_widget (GTK_MENU (widget));
- else
- parent = widget->parent;
- if (!parent)
- parent = (GtkWidget*) g_object_get_data (G_OBJECT (widget), "GladeParentKey");
- if (parent == NULL)
- break;
- widget = parent;
+ GtkWidget *parent, *found_widget;
+
+ for (;;) {
+ if (GTK_IS_MENU(widget))
+ parent = gtk_menu_get_attach_widget(GTK_MENU(widget));
+ else
+ parent = widget->parent;
+ if (!parent)
+ parent =
+ (GtkWidget *) g_object_get_data(G_OBJECT(widget),
+ "GladeParentKey");
+ if (parent == NULL)
+ break;
+ widget = parent;
}
- found_widget = (GtkWidget*) g_object_get_data (G_OBJECT (widget),
- widget_name);
- if (!found_widget)
- g_warning ("Widget not found: %s", widget_name);
- return found_widget;
+ found_widget = (GtkWidget *) g_object_get_data(G_OBJECT(widget),
+ widget_name);
+ if (!found_widget)
+ g_warning("Widget not found: %s", widget_name);
+ return found_widget;
}
static GList *pixmaps_directories = NULL;
/* Use this function to set the directory containing installed pixmaps. */
-void
-add_pixmap_directory (const gchar *directory)
+void add_pixmap_directory(const gchar * directory)
{
- pixmaps_directories = g_list_prepend (pixmaps_directories,
- g_strdup (directory));
+ pixmaps_directories = g_list_prepend(pixmaps_directories,
+ g_strdup(directory));
}
/* This is an internally used function to find pixmap files. */
-static gchar*
-find_pixmap_file (const gchar *filename)
+static gchar *find_pixmap_file(const gchar * filename)
{
- GList *elem;
-
- /* We step through each of the pixmaps directory to find it. */
- elem = pixmaps_directories;
- while (elem)
- {
- gchar *pathname = g_strdup_printf ("%s%s%s", (gchar*)elem->data,
- G_DIR_SEPARATOR_S, filename);
- if (g_file_test (pathname, G_FILE_TEST_EXISTS))
- return pathname;
- g_free (pathname);
- elem = elem->next;
+ GList *elem;
+
+ /* We step through each of the pixmaps directory to find it. */
+ elem = pixmaps_directories;
+ while (elem) {
+ gchar *pathname = g_strdup_printf("%s%s%s", (gchar *) elem->data,
+ G_DIR_SEPARATOR_S, filename);
+ if (g_file_test(pathname, G_FILE_TEST_EXISTS))
+ return pathname;
+ g_free(pathname);
+ elem = elem->next;
}
- return NULL;
+ return NULL;
}
/* This is an internally used function to create pixmaps. */
-GtkWidget*
-create_pixmap (GtkWidget *widget,
- const gchar *filename)
+GtkWidget *create_pixmap(GtkWidget * widget, const gchar * filename)
{
- gchar *pathname = NULL;
- GtkWidget *pixmap;
+ gchar *pathname = NULL;
+ GtkWidget *pixmap;
- if (!filename || !filename[0])
- return gtk_image_new ();
+ if (!filename || !filename[0])
+ return gtk_image_new();
- pathname = find_pixmap_file (filename);
+ pathname = find_pixmap_file(filename);
- if (!pathname)
- {
- g_warning (_("Couldn't find pixmap file: %s"), filename);
- return gtk_image_new ();
+ if (!pathname) {
+ g_warning(_("Couldn't find pixmap file: %s"), filename);
+ return gtk_image_new();
}
- pixmap = gtk_image_new_from_file (pathname);
- g_free (pathname);
- return pixmap;
+ pixmap = gtk_image_new_from_file(pathname);
+ g_free(pathname);
+ return pixmap;
}
/* This is an internally used function to create pixmaps. */
-GdkPixbuf*
-create_pixbuf (const gchar *filename)
+GdkPixbuf *create_pixbuf(const gchar * filename)
{
- gchar *pathname = NULL;
- GdkPixbuf *pixbuf;
- GError *error = NULL;
+ gchar *pathname = NULL;
+ GdkPixbuf *pixbuf;
+ GError *error = NULL;
- if (!filename || !filename[0])
- return NULL;
+ if (!filename || !filename[0])
+ return NULL;
- pathname = find_pixmap_file (filename);
+ pathname = find_pixmap_file(filename);
- if (!pathname)
- {
- g_warning (_("Couldn't find pixmap file: %s"), filename);
- return NULL;
+ if (!pathname) {
+ g_warning(_("Couldn't find pixmap file: %s"), filename);
+ return NULL;
}
- pixbuf = gdk_pixbuf_new_from_file (pathname, &error);
- if (!pixbuf)
- {
- fprintf (stderr, "Failed to load pixbuf file: %s: %s\n",
- pathname, error->message);
- g_error_free (error);
+ pixbuf = gdk_pixbuf_new_from_file(pathname, &error);
+ if (!pixbuf) {
+ fprintf(stderr, "Failed to load pixbuf file: %s: %s\n",
+ pathname, error->message);
+ g_error_free(error);
}
- g_free (pathname);
- return pixbuf;
+ g_free(pathname);
+ return pixbuf;
}
/* This is used to set ATK action descriptions. */
void
-glade_set_atk_action_description (AtkAction *action,
- const gchar *action_name,
- const gchar *description)
+glade_set_atk_action_description(AtkAction * action,
+ const gchar * action_name,
+ const gchar * description)
{
- gint n_actions, i;
+ gint n_actions, i;
+
+ n_actions = atk_action_get_n_actions(action);
- n_actions = atk_action_get_n_actions (action);
-
- for (i = 0; i < n_actions; i++)
- {
- if (!strcmp (atk_action_get_name (action, i), action_name))
- atk_action_set_description (action, i, description);
+ for (i = 0; i < n_actions; i++) {
+ if (!strcmp(atk_action_get_name(action, i), action_name))
+ atk_action_set_description(action, i, description);
}
}
-
* or alternatively any widget in the component, and the name of the widget
* you want returned.
*/
-GtkWidget* lookup_widget (GtkWidget *widget,
- const gchar *widget_name);
+GtkWidget *lookup_widget(GtkWidget * widget, const gchar * widget_name);
/* Use this function to set the directory containing installed pixmaps. */
-void add_pixmap_directory (const gchar *directory);
+void add_pixmap_directory(const gchar * directory);
/*
*/
/* This is used to create the pixmaps used in the interface. */
-GtkWidget* create_pixmap (GtkWidget *widget,
- const gchar *filename);
+GtkWidget *create_pixmap(GtkWidget * widget, const gchar * filename);
/* This is used to create the pixbufs used in the interface. */
-GdkPixbuf* create_pixbuf (const gchar *filename);
+GdkPixbuf *create_pixbuf(const gchar * filename);
/* This is used to set ATK action descriptions. */
-void glade_set_atk_action_description (AtkAction *action,
- const gchar *action_name,
- const gchar *description);
+void glade_set_atk_action_description(AtkAction * action,
+ const gchar * action_name,
+ const gchar * description);
/* These variables define various paths detected at runtime. */
extern gchar *package_prefix;
extern gchar *package_data_dir;
extern gchar *package_locale_dir;
-
+/* $Id$Revision: */
/* vim:set shiftwidth=4 ts=8: */
/**********************************************************
+/* $Id$Revision: */
/* vim:set shiftwidth=4 ts=8: */
/**********************************************************
#include <wincrypt.h>
#endif
-static int get_temp_coords(topview* t,int level,int v,double* coord_x,double* coord_y);
+static int get_temp_coords(topview * t, int level, int v, double *coord_x,
+ double *coord_y);
#ifdef UNUSED
-static int get_temp_coords2(topview* t,int level,int v,double* coord_x,double* coord_y,float *R,float *G,float *B);
+static int get_temp_coords2(topview * t, int level, int v, double *coord_x,
+ double *coord_y, float *R, float *G, float *B);
#endif
-static void color_interpolation(glCompColor srcColor,glCompColor tarColor,glCompColor* color,int levelcount,int level)
+static void color_interpolation(glCompColor srcColor, glCompColor tarColor,
+ glCompColor * color, int levelcount,
+ int level)
{
- if (levelcount <=0)
- return;
-
-
- color->R=((float)level*tarColor.R-(float)level*srcColor.R+(float)levelcount*srcColor.R) /
- (float)levelcount;
- color->G=((float)level*tarColor.G-(float)level*srcColor.G+(float)levelcount*srcColor.G) /
- (float)levelcount;
- color->B=((float)level*tarColor.B-(float)level*srcColor.B+(float)levelcount*srcColor.B) /
- (float)levelcount;
+ if (levelcount <= 0)
+ return;
+
+
+ color->R =
+ ((float) level * tarColor.R - (float) level * srcColor.R +
+ (float) levelcount * srcColor.R) / (float) levelcount;
+ color->G =
+ ((float) level * tarColor.G - (float) level * srcColor.G +
+ (float) levelcount * srcColor.G) / (float) levelcount;
+ color->B =
+ ((float) level * tarColor.B - (float) level * srcColor.B +
+ (float) levelcount * srcColor.B) / (float) levelcount;
}
static double dist(double x1, double y1, double x2, double y2)
return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2) +
(z1 - z2) * (z1 - z2));
}
+
#ifdef UNUSED
static void drawtopologicalfisheyestatic(topview * t);
#endif
double distance, distorted_distance, ratio, range;
range = 0;
- for (i = 1; i < t->Nodecount; i++)
- {
- if (point_within_ellips_with_coords
- ((float) x_focus, (float) y_focus, (float) view->fmg.R,
- (float) view->fmg.R, t->Nodes[i].x, t->Nodes[i].y))
- {
- range = MAX(range,
- dist(t->Nodes[i].x, t->Nodes[i].y, x_focus, y_focus));
- }
+ for (i = 1; i < t->Nodecount; i++) {
+ if (point_within_ellips_with_coords
+ ((float) x_focus, (float) y_focus, (float) view->fmg.R,
+ (float) view->fmg.R, t->Nodes[i].x, t->Nodes[i].y)) {
+ range = MAX(range,
+ dist(t->Nodes[i].x, t->Nodes[i].y, x_focus,
+ y_focus));
+ }
}
- for (i = 1; i < t->Nodecount; i++)
- {
+ for (i = 1; i < t->Nodecount; i++) {
- if (point_within_ellips_with_coords
- ((float) x_focus, (float) y_focus, (float) view->fmg.R,
- (float) view->fmg.R, t->Nodes[i].x, t->Nodes[i].y))
- {
- distance =
- dist(t->Nodes[i].x, t->Nodes[i].y, x_focus, y_focus);
- distorted_distance = G(distance / range) * range;
- if (distance != 0)
- {
- ratio = distorted_distance / distance;
- }
- else
- {
- ratio = 0;
- }
- t->Nodes[i].distorted_x =
- (float) x_focus + (t->Nodes[i].x - (float) x_focus) * (float) ratio;
- t->Nodes[i].distorted_y =
- (float) y_focus + (t->Nodes[i].y - (float) y_focus) * (float) ratio;
- t->Nodes[i].zoom_factor =(float) 1 *(float) distorted_distance / (float) distance;
- }
- else
- {
- t->Nodes[i].distorted_x = t->Nodes[i].x;
- t->Nodes[i].distorted_y = t->Nodes[i].y;
- t->Nodes[i].zoom_factor = 1;
- }
+ if (point_within_ellips_with_coords
+ ((float) x_focus, (float) y_focus, (float) view->fmg.R,
+ (float) view->fmg.R, t->Nodes[i].x, t->Nodes[i].y)) {
+ distance =
+ dist(t->Nodes[i].x, t->Nodes[i].y, x_focus, y_focus);
+ distorted_distance = G(distance / range) * range;
+ if (distance != 0) {
+ ratio = distorted_distance / distance;
+ } else {
+ ratio = 0;
+ }
+ t->Nodes[i].distorted_x =
+ (float) x_focus + (t->Nodes[i].x -
+ (float) x_focus) * (float) ratio;
+ t->Nodes[i].distorted_y =
+ (float) y_focus + (t->Nodes[i].y -
+ (float) y_focus) * (float) ratio;
+ t->Nodes[i].zoom_factor =
+ (float) 1 *(float) distorted_distance / (float) distance;
+ } else {
+ t->Nodes[i].distorted_x = t->Nodes[i].x;
+ t->Nodes[i].distorted_y = t->Nodes[i].y;
+ t->Nodes[i].zoom_factor = 1;
}
+ }
}
void fisheye_spherical(double x_focus, double y_focus, double z_focus,
topview * t)
int ne = tv->Edgecount; /* upper bound */
int nv = tv->Nodecount;
v_data *graph = N_NEW(nv, v_data);
- int *edges = N_NEW(2 * ne + nv, int); /* reserve space for self loops */
+ int *edges = N_NEW(2 * ne + nv, int); /* reserve space for self loops */
float *ewgts = N_NEW(2 * ne + nv, float);
Agnode_t *np;
Agedge_t *ep;
int i_nedges;
ne = 0;
- for (i = 0; i < nv; i++)
- {
- graph[i].edges = edges++; /* reserve space for the self loop */
- graph[i].ewgts = ewgts++;
- #ifdef STYLES
- graph[i].styles = NULL;
- #endif
- i_nedges = 1; /* one for the self */
-
- np = tv->Nodes[i].Node;
- if (!g)
- g = agraphof(np);
- for (ep = agfstedge(g, np); ep; ep = agnxtedge(g, ep, np))
- {
- Agnode_t *vp;
- Agnode_t *tp = agtail(ep);
- Agnode_t *hp = aghead(ep);
- assert(hp != tp);
- /* FIX: handle multiedges */
- vp = (tp == np ? hp : tp);
- ne++;
- i_nedges++;
- *edges++ =((temp_node_record*)AGDATA(vp))->TVref;
- *ewgts++ = 1;
- }
+ for (i = 0; i < nv; i++) {
+ graph[i].edges = edges++; /* reserve space for the self loop */
+ graph[i].ewgts = ewgts++;
+#ifdef STYLES
+ graph[i].styles = NULL;
+#endif
+ i_nedges = 1; /* one for the self */
+
+ np = tv->Nodes[i].Node;
+ if (!g)
+ g = agraphof(np);
+ for (ep = agfstedge(g, np); ep; ep = agnxtedge(g, ep, np)) {
+ Agnode_t *vp;
+ Agnode_t *tp = agtail(ep);
+ Agnode_t *hp = aghead(ep);
+ assert(hp != tp);
+ /* FIX: handle multiedges */
+ vp = (tp == np ? hp : tp);
+ ne++;
+ i_nedges++;
+ *edges++ = ((temp_node_record *) AGDATA(vp))->TVref;
+ *ewgts++ = 1;
+ }
- graph[i].nedges = i_nedges;
- graph[i].edges[0] = i;
- graph[i].ewgts[0] = 1 - i_nedges;
+ graph[i].nedges = i_nedges;
+ graph[i].edges[0] = i;
+ graph[i].ewgts[0] = 1 - i_nedges;
}
ne /= 2; /* each edge counted twice */
*nedges = ne;
* freeGraph (graph);
* fs = initFocus (topview->Nodecount); // create focus set
*/
-void prepare_topological_fisheye(topview* t)
+void prepare_topological_fisheye(topview * t)
{
double *x_coords = N_NEW(t->Nodecount, double); // initial x coordinates
double *y_coords = N_NEW(t->Nodecount, double); // initial y coordinates
Hierarchy *hp;
ex_vtx_data *gg;
topview_node *np;
- gvcolor_t cl;
+ gvcolor_t cl;
v_data *graph = makeGraph(t, &ne);
-// t->animate=1; //turn the animation on
- for (i = 0, np = t->Nodes; i < t->Nodecount; i++, np++)
- {
- x_coords[i] = np->x;
- y_coords[i] = np->y;
+// t->animate=1; //turn the animation on
+ for (i = 0, np = t->Nodes; i < t->Nodecount; i++, np++) {
+ x_coords[i] = np->x;
+ y_coords[i] = np->y;
}
- hp = t->h =
- makeHier(t->Nodecount, ne, graph, x_coords, y_coords, &(t->parms.hier));
+ hp = t->h =
+ makeHier(t->Nodecount, ne, graph, x_coords, y_coords,
+ &(t->parms.hier));
freeGraph(graph);
free(x_coords);
free(y_coords);
- fs = t->fs = initFocus(t->Nodecount); // create focus set
+ fs = t->fs = initFocus(t->Nodecount); // create focus set
gg = hp->geom_graphs[0];
- closest_fine_node = 0; /* first node */
+ closest_fine_node = 0; /* first node */
fs->num_foci = 1;
fs->foci_nodes[0] = closest_fine_node;
fs->x_foci[0] = hp->geom_graphs[cur_level][closest_fine_node].x_coord;
fs->y_foci[0] = hp->geom_graphs[cur_level][closest_fine_node].y_coord;
- view->Topview->parms.repos.width =(int) (view->bdxRight-view->bdxLeft);
- view->Topview->parms.repos.height =(int) (view->bdyTop-view->bdyBottom);
- view->Topview->parms.repos.rescale=Polar;
+ view->Topview->parms.repos.width =
+ (int) (view->bdxRight - view->bdxLeft);
+ view->Topview->parms.repos.height =
+ (int) (view->bdyTop - view->bdyBottom);
+ view->Topview->parms.repos.rescale = Polar;
- //topological fisheye
+ //topological fisheye
- colorxlate(get_attribute_value("topologicalfisheyefinestcolor", view, view->g[view->activeGraph]), &cl,
- RGBA_DOUBLE);
- view->Topview->srcColor.R = (float) cl.u.RGBA[0];
+ colorxlate(get_attribute_value
+ ("topologicalfisheyefinestcolor", view,
+ view->g[view->activeGraph]), &cl, RGBA_DOUBLE);
+ view->Topview->srcColor.R = (float) cl.u.RGBA[0];
view->Topview->srcColor.G = (float) cl.u.RGBA[1];
view->Topview->srcColor.B = (float) cl.u.RGBA[2];
- colorxlate(get_attribute_value("topologicalfisheyecoarsestcolor", view, view->g[view->activeGraph]), &cl,
- RGBA_DOUBLE);
- view->Topview->tarColor.R = (float) cl.u.RGBA[0];
+ colorxlate(get_attribute_value
+ ("topologicalfisheyecoarsestcolor", view,
+ view->g[view->activeGraph]), &cl, RGBA_DOUBLE);
+ view->Topview->tarColor.R = (float) cl.u.RGBA[0];
view->Topview->tarColor.G = (float) cl.u.RGBA[1];
view->Topview->tarColor.B = (float) cl.u.RGBA[2];
- sscanf(agget(view->g[view->activeGraph],"topologicalfisheyedistortionfactor"),"%lf",&view->Topview->parms.repos.distortion);
- sscanf(agget(view->g[view->activeGraph],"topologicalfisheyefinenodes"),"%d",&view->Topview->parms.level.num_fine_nodes);
- sscanf(agget(view->g[view->activeGraph],"topologicalfisheyecoarseningfactor"),"%lf",&view->Topview->parms.level.coarsening_rate);
- sscanf(agget(view->g[view->activeGraph],"topologicalfisheyedist2limit"),"%d",&view->Topview->parms.hier.dist2_limit);
- sscanf(agget(view->g[view->activeGraph],"topologicalfisheyeanimate"),"%d",&view->Topview->animate);
-
- set_active_levels(hp, fs->foci_nodes, fs->num_foci, &(t->parms.level));
- positionAllItems(hp, fs, &(t->parms.repos));
- refresh_old_values(t);
+ sscanf(agget
+ (view->g[view->activeGraph],
+ "topologicalfisheyedistortionfactor"), "%lf",
+ &view->Topview->parms.repos.distortion);
+ sscanf(agget
+ (view->g[view->activeGraph], "topologicalfisheyefinenodes"),
+ "%d", &view->Topview->parms.level.num_fine_nodes);
+ sscanf(agget
+ (view->g[view->activeGraph],
+ "topologicalfisheyecoarseningfactor"), "%lf",
+ &view->Topview->parms.level.coarsening_rate);
+ sscanf(agget
+ (view->g[view->activeGraph], "topologicalfisheyedist2limit"),
+ "%d", &view->Topview->parms.hier.dist2_limit);
+ sscanf(agget(view->g[view->activeGraph], "topologicalfisheyeanimate"),
+ "%d", &view->Topview->animate);
+
+ set_active_levels(hp, fs->foci_nodes, fs->num_foci, &(t->parms.level));
+ positionAllItems(hp, fs, &(t->parms.repos));
+ refresh_old_values(t);
/* fprintf (stderr, "No. of active nodes = %d\n", count_active_nodes(hp)); */
/*
draws all level 0 nodes and edges, during animation
*/
-void printalllevels(topview* t)
+void printalllevels(topview * t)
{
int level, v;
Hierarchy *hp = t->h;
glPointSize(5);
glBegin(GL_POINTS);
- for (level = 0; level < hp->nlevels; level++)
- {
- for (v = 0; v < hp->nvtxs[level]; v++)
- {
- ex_vtx_data *gg = hp->geom_graphs[level];
- if (gg[v].active_level == level)
- {
- double x0,y0;
- get_temp_coords(t,level,v,&x0,&y0);
- glColor3f((GLfloat) (hp->nlevels - level) / (GLfloat) hp->nlevels,
- (GLfloat) level / (GLfloat) hp->nlevels, 0);
- glVertex3f((GLfloat) x0, (GLfloat) y0, (GLfloat) 0);
- }
- }
+ for (level = 0; level < hp->nlevels; level++) {
+ for (v = 0; v < hp->nvtxs[level]; v++) {
+ ex_vtx_data *gg = hp->geom_graphs[level];
+ if (gg[v].active_level == level) {
+ double x0, y0;
+ get_temp_coords(t, level, v, &x0, &y0);
+ glColor3f((GLfloat) (hp->nlevels - level) /
+ (GLfloat) hp->nlevels,
+ (GLfloat) level / (GLfloat) hp->nlevels, 0);
+ glVertex3f((GLfloat) x0, (GLfloat) y0, (GLfloat) 0);
+ }
+ }
}
glEnd();
}
void drawtopfishnodes(topview * t)
{
- glCompColor srcColor;
- glCompColor tarColor;
- glCompColor color;
- int level, v;
+ glCompColor srcColor;
+ glCompColor tarColor;
+ glCompColor color;
+ int level, v;
Hierarchy *hp = t->h;
- static int max_visible_level=0;
- srcColor.R=view->Topview->srcColor.R;
- srcColor.G=view->Topview->srcColor.G;
- srcColor.B=view->Topview->srcColor.B;
- tarColor.R=view->Topview->tarColor.R;
- tarColor.G=view->Topview->tarColor.G;
- tarColor.B=view->Topview->tarColor.B;
-
-
- glEnable(GL_POINT_SMOOTH); /*turn this off to make points look square*/
- //draw focused node little bigger than others
+ static int max_visible_level = 0;
+ srcColor.R = view->Topview->srcColor.R;
+ srcColor.G = view->Topview->srcColor.G;
+ srcColor.B = view->Topview->srcColor.B;
+ tarColor.R = view->Topview->tarColor.R;
+ tarColor.G = view->Topview->tarColor.G;
+ tarColor.B = view->Topview->tarColor.B;
+
+
+ glEnable(GL_POINT_SMOOTH); /*turn this off to make points look square */
+ //draw focused node little bigger than others
/* ex_vtx_data *gg = hp->geom_graphs[0];
if ((gg[v].active_level == 0) &&(v==t->fs->foci_nodes[0]))*/
- //drawing nodes
- glPointSize(7);
- level=0;
+ //drawing nodes
+ glPointSize(7);
+ level = 0;
glBegin(GL_POINTS);
- for (level = 0; level < hp->nlevels; level++)
- {
- for (v = 0; v < hp->nvtxs[level]; v++)
- {
- double x0,y0;
- if (get_temp_coords(t,level,v,&x0,&y0))
- {
-
- if (!(((-x0 / view->zoom > view->clipX1)
- && (-x0 / view->zoom < view->clipX2)
- && (-y0 / view->zoom > view->clipY1)
- && (-y0 / view->zoom < view->clipY2))))
- continue;
-
-// if (level !=0)
-// glColor4f((GLfloat) (hp->nlevels - level)*(GLfloat)0.5 / (GLfloat) hp->nlevels,
-// (GLfloat) level / (GLfloat) hp->nlevels, (GLfloat)0,(GLfloat)view->defaultnodealpha);
- // else
-// glColor4f((GLfloat) 1,
-// (GLfloat) level / (GLfloat) hp->nlevels*2, 0,view->defaultnodealpha);
-
- if (max_visible_level < level)
- max_visible_level=level;
- color_interpolation(srcColor,tarColor,&color,max_visible_level,level);
- glColor4f(color.R,color.G,color.B,(GLfloat)view->defaultnodealpha);
+ for (level = 0; level < hp->nlevels; level++) {
+ for (v = 0; v < hp->nvtxs[level]; v++) {
+ double x0, y0;
+ if (get_temp_coords(t, level, v, &x0, &y0)) {
+
+ if (!(((-x0 / view->zoom > view->clipX1)
+ && (-x0 / view->zoom < view->clipX2)
+ && (-y0 / view->zoom > view->clipY1)
+ && (-y0 / view->zoom < view->clipY2))))
+ continue;
+
+// if (level !=0)
+// glColor4f((GLfloat) (hp->nlevels - level)*(GLfloat)0.5 / (GLfloat) hp->nlevels,
+// (GLfloat) level / (GLfloat) hp->nlevels, (GLfloat)0,(GLfloat)view->defaultnodealpha);
+ // else
+// glColor4f((GLfloat) 1,
+// (GLfloat) level / (GLfloat) hp->nlevels*2, 0,view->defaultnodealpha);
+
+ if (max_visible_level < level)
+ max_visible_level = level;
+ color_interpolation(srcColor, tarColor, &color,
+ max_visible_level, level);
+ glColor4f(color.R, color.G, color.B,
+ (GLfloat) view->defaultnodealpha);
/* glColor3f((GLfloat) (hp->nlevels - level)*0.5 / (GLfloat) hp->nlevels,
(GLfloat) level / (GLfloat) hp->nlevels, 0);*/
- glVertex3f((GLfloat) x0, (GLfloat) y0, (GLfloat) 0);
- }
- }
+ glVertex3f((GLfloat) x0, (GLfloat) y0, (GLfloat) 0);
+ }
+ }
}
- glEnd();
+ glEnd();
}
-void drawtopfishnodelabels(topview* t)
-{
- int v, finenodes,focusnodes;
- char buf[512];
- char* str;
- Hierarchy *hp = t->h;
- finenodes=focusnodes=0;
- str = agget(view->g[view->activeGraph], "topologicalfisheyelabelfinenodes");
- if(strcmp(str,"1")==0){finenodes=1;}
- str = agget(view->g[view->activeGraph], "topologicalfisheyelabelfocus");
- if(strcmp(str,"1")==0){focusnodes=1;}
- if((finenodes)||(focusnodes))
- {
- for (v = 0; v < hp->nvtxs[0]; v++)
- {
- ex_vtx_data *gg = hp->geom_graphs[0];
- if (gg[v].active_level==0)
- {
- if(view->Topview->Nodes[v].Label)
- strcpy(buf,view->Topview->Nodes[v].Label);
- else
- sprintf(buf,"%d",v);
-
- if((v==t->fs->foci_nodes[0]) &&(focusnodes))
- {
- glColor4f((float)0, (float)0, (float)1, (float)1);
- glprintfglut(GLUT_BITMAP_HELVETICA_18,gg[v].physical_x_coord,gg[v].physical_y_coord,0,buf);
- }
- else if (finenodes)
- {
- glColor4f(0, 0, 0, 1);
- glprintfglut(GLUT_BITMAP_HELVETICA_10,gg[v].physical_x_coord,gg[v].physical_y_coord,0,buf);
- }
- }
+void drawtopfishnodelabels(topview * t)
+{
+ int v, finenodes, focusnodes;
+ char buf[512];
+ char *str;
+ Hierarchy *hp = t->h;
+ finenodes = focusnodes = 0;
+ str =
+ agget(view->g[view->activeGraph],
+ "topologicalfisheyelabelfinenodes");
+ if (strcmp(str, "1") == 0) {
+ finenodes = 1;
+ }
+ str =
+ agget(view->g[view->activeGraph], "topologicalfisheyelabelfocus");
+ if (strcmp(str, "1") == 0) {
+ focusnodes = 1;
+ }
+ if ((finenodes) || (focusnodes)) {
+ for (v = 0; v < hp->nvtxs[0]; v++) {
+ ex_vtx_data *gg = hp->geom_graphs[0];
+ if (gg[v].active_level == 0) {
+ if (view->Topview->Nodes[v].Label)
+ strcpy(buf, view->Topview->Nodes[v].Label);
+ else
+ sprintf(buf, "%d", v);
+
+ if ((v == t->fs->foci_nodes[0]) && (focusnodes)) {
+ glColor4f((float) 0, (float) 0, (float) 1, (float) 1);
+ glprintfglut(GLUT_BITMAP_HELVETICA_18,
+ gg[v].physical_x_coord,
+ gg[v].physical_y_coord, 0, buf);
+ } else if (finenodes) {
+ glColor4f(0, 0, 0, 1);
+ glprintfglut(GLUT_BITMAP_HELVETICA_10,
+ gg[v].physical_x_coord,
+ gg[v].physical_y_coord, 0, buf);
}
+ }
+
}
+ }
}
void drawtopfishedges(topview * t)
{
- glCompColor srcColor;
- glCompColor tarColor;
- glCompColor color;
+ glCompColor srcColor;
+ glCompColor tarColor;
+ glCompColor color;
- int level, v, i, n;
+ int level, v, i, n;
Hierarchy *hp = t->h;
- static int max_visible_level=0;
- srcColor.R=view->Topview->srcColor.R;
- srcColor.G=view->Topview->srcColor.G;
- srcColor.B=view->Topview->srcColor.B;
- tarColor.R=view->Topview->tarColor.R;
- tarColor.G=view->Topview->tarColor.G;
- tarColor.B=view->Topview->tarColor.B;
-
- //and edges
- glBegin(GL_LINES);
- for (level = 0; level < hp->nlevels; level++)
- {
- for (v = 0; v < hp->nvtxs[level]; v++)
- {
- v_data *g = hp->graphs[level];
- double x0,y0;
- if (get_temp_coords(t,level,v,&x0,&y0))
- {
- for (i = 1; i < g[v].nedges; i++)
- {
- double x, y;
- n = g[v].edges[i];
-
-
- if (max_visible_level < level)
- max_visible_level=level;
- color_interpolation(srcColor,tarColor,&color,max_visible_level,level);
- glColor4f(color.R,color.G,color.B,(GLfloat)view->defaultnodealpha);
-
-
- if (get_temp_coords(t,level,n,&x,&y))
- {
- glVertex3f((GLfloat) x0, (GLfloat) y0,(GLfloat) 0);
- glVertex3f((GLfloat) x, (GLfloat) y,(GLfloat) 0);
- }
- else// if (gg[n].active_level > level)
- {
- int levell,nodee;
- find_active_ancestor_info(hp, level, n, &levell,&nodee);
-// find_physical_coords(hp, level, n, &x, &y);
- if (get_temp_coords(t,levell,nodee,&x,&y))
- {
-
- if( (!(((-x0 / view->zoom > view->clipX1)
- && (-x0 / view->zoom < view->clipX2)
- && (-y0 / view->zoom > view->clipY1)
- && (-y0 / view->zoom < view->clipY2))))
- &&
- (!(((-x / view->zoom > view->clipX1)
- && (-x / view->zoom < view->clipX2)
- && (-y / view->zoom > view->clipY1)
- && (-y / view->zoom < view->clipY2)))))
-
- continue;
-
-
- glVertex3f((GLfloat) x0, (GLfloat) y0,(GLfloat) 0);
- glVertex3f((GLfloat) x, (GLfloat) y, (GLfloat) 0);
- }
- }
- }
+ static int max_visible_level = 0;
+ srcColor.R = view->Topview->srcColor.R;
+ srcColor.G = view->Topview->srcColor.G;
+ srcColor.B = view->Topview->srcColor.B;
+ tarColor.R = view->Topview->tarColor.R;
+ tarColor.G = view->Topview->tarColor.G;
+ tarColor.B = view->Topview->tarColor.B;
+
+ //and edges
+ glBegin(GL_LINES);
+ for (level = 0; level < hp->nlevels; level++) {
+ for (v = 0; v < hp->nvtxs[level]; v++) {
+ v_data *g = hp->graphs[level];
+ double x0, y0;
+ if (get_temp_coords(t, level, v, &x0, &y0)) {
+ for (i = 1; i < g[v].nedges; i++) {
+ double x, y;
+ n = g[v].edges[i];
+
+
+ if (max_visible_level < level)
+ max_visible_level = level;
+ color_interpolation(srcColor, tarColor, &color,
+ max_visible_level, level);
+ glColor4f(color.R, color.G, color.B,
+ (GLfloat) view->defaultnodealpha);
+
+
+ if (get_temp_coords(t, level, n, &x, &y)) {
+ glVertex3f((GLfloat) x0, (GLfloat) y0,
+ (GLfloat) 0);
+ glVertex3f((GLfloat) x, (GLfloat) y, (GLfloat) 0);
+ } else // if (gg[n].active_level > level)
+ {
+ int levell, nodee;
+ find_active_ancestor_info(hp, level, n, &levell,
+ &nodee);
+// find_physical_coords(hp, level, n, &x, &y);
+ if (get_temp_coords(t, levell, nodee, &x, &y)) {
+
+ if ((!(((-x0 / view->zoom > view->clipX1)
+ && (-x0 / view->zoom < view->clipX2)
+ && (-y0 / view->zoom > view->clipY1)
+ && (-y0 / view->zoom < view->clipY2))))
+ && (!(((-x / view->zoom > view->clipX1)
+ && (-x / view->zoom < view->clipX2)
+ && (-y / view->zoom > view->clipY1)
+ && (-y / view->zoom <
+ view->clipY2)))))
+
+ continue;
+
+
+ glVertex3f((GLfloat) x0, (GLfloat) y0,
+ (GLfloat) 0);
+ glVertex3f((GLfloat) x, (GLfloat) y,
+ (GLfloat) 0);
}
+ }
}
+ }
}
+ }
glEnd();
- glDisable(GL_POINT_SMOOTH);
+ glDisable(GL_POINT_SMOOTH);
}
void drawtopologicalfisheye(topview * t)
{
- get_active_frame(t);
- drawtopfishnodes(t);
- drawtopfishedges(t);
- if(!t->animate)
- drawtopfishnodelabels(t);
+ get_active_frame(t);
+ drawtopfishnodes(t);
+ drawtopfishedges(t);
+ if (!t->animate)
+ drawtopfishnodelabels(t);
}
-int get_temp_coords(topview* t,int level,int v,double* coord_x,double* coord_y)
+int get_temp_coords(topview * t, int level, int v, double *coord_x,
+ double *coord_y)
{
Hierarchy *hp = t->h;
- ex_vtx_data *gg = hp->geom_graphs[level];
- /* v_data *g = hp->graphs[level]; */
+ ex_vtx_data *gg = hp->geom_graphs[level];
+ /* v_data *g = hp->graphs[level]; */
- if (!t->animate)
- {
- if (gg[v].active_level != level)
- return 0;
+ if (!t->animate) {
+ if (gg[v].active_level != level)
+ return 0;
- *coord_x=(double)gg[v].physical_x_coord;
- *coord_y=(double)gg[v].physical_y_coord;
- }
- else
+ *coord_x = (double) gg[v].physical_x_coord;
+ *coord_y = (double) gg[v].physical_y_coord;
+ } else {
+
+
+ double x0, y0, x1, y1;
+ int OAL, AL;
+
+ x0 = 0;
+ y0 = 0;
+ x1 = 0;
+ y1 = 0;
+ AL = gg[v].active_level;
+ OAL = gg[v].old_active_level;
+
+ if ((OAL < level) || (AL < level)) //no draw
+ return 0;
+ if ((OAL >= level) || (AL >= level)) //draw the node
{
+ if ((OAL == level) && (AL == level)) //draw as is from old coords to new)
+ {
+ x0 = (double) gg[v].old_physical_x_coord;
+ y0 = (double) gg[v].old_physical_y_coord;
+ x1 = (double) gg[v].physical_x_coord;
+ y1 = (double) gg[v].physical_y_coord;
+ }
+ if ((OAL > level) && (AL == level)) //draw as from ancs to new)
+ {
+ find_old_physical_coords(t->h, level, v, &x0, &y0);
+ x1 = (double) gg[v].physical_x_coord;
+ y1 = (double) gg[v].physical_y_coord;
+ }
+ if ((OAL == level) && (AL > level)) //draw as from ancs to new)
+ {
+ find_physical_coords(t->h, level, v, &x1, &y1);
+ x0 = (double) gg[v].old_physical_x_coord;
+ y0 = (double) gg[v].old_physical_y_coord;
+ }
+ get_interpolated_coords(x0, y0, x1, y1, view->active_frame,
+ view->total_frames, coord_x, coord_y);
+ if ((x0 == 0) || (x1 == 0))
+ return 0;
-
- double x0,y0,x1,y1;
- int OAL,AL;
-
- x0=0;
- y0=0;
- x1=0;
- y1=0;
- AL=gg[v].active_level;
- OAL=gg[v].old_active_level;
-
- if ((OAL < level) || (AL < level)) //no draw
- return 0;
- if ((OAL >= level) || (AL >= level)) //draw the node
- {
- if((OAL == level) && (AL == level)) //draw as is from old coords to new)
- {
- x0=(double)gg[v].old_physical_x_coord;
- y0=(double)gg[v].old_physical_y_coord;
- x1=(double)gg[v].physical_x_coord;
- y1=(double)gg[v].physical_y_coord;
- }
- if((OAL > level) && (AL == level)) //draw as from ancs to new)
- {
- find_old_physical_coords(t->h,level,v,&x0,&y0);
- x1=(double)gg[v].physical_x_coord;
- y1=(double)gg[v].physical_y_coord;
- }
- if((OAL == level) && (AL > level)) //draw as from ancs to new)
- {
- find_physical_coords(t->h,level,v,&x1,&y1);
- x0=(double)gg[v].old_physical_x_coord;
- y0=(double)gg[v].old_physical_y_coord;
- }
- get_interpolated_coords(x0,y0,x1,y1,view->active_frame,view->total_frames,coord_x,coord_y);
- if ((x0 == 0) || (x1==0))
- return 0;
-
- }
}
- return 1;
+ }
+ return 1;
}
void infotopfisheye(topview * t, float *x, float *y, float *z)
{
- Hierarchy *hp = t->h;
- int closest_fine_node;
- find_closest_active_node(hp, *x, *y, &closest_fine_node);
-
+ Hierarchy *hp = t->h;
+ int closest_fine_node;
+ find_closest_active_node(hp, *x, *y, &closest_fine_node);
+
+
-
/* hp->geom_graphs[0][closest_fine_node].x_coord;
hp->geom_graphs[0][closest_fine_node].y_coord;*/
}
void changetopfishfocus(topview * t, float *x, float *y,
- float *z, int num_foci)
+ float *z, int num_foci)
{
- gvcolor_t cl;
- focus_t *fs = t->fs;
+ gvcolor_t cl;
+ focus_t *fs = t->fs;
int i;
int closest_fine_node;
int cur_level = 0;
- Hierarchy *hp = t->h;
- refresh_old_values(t);
- fs->num_foci = num_foci;
+ Hierarchy *hp = t->h;
+ refresh_old_values(t);
+ fs->num_foci = num_foci;
for (i = 0; i < num_foci; i++) {
find_closest_active_node(hp, x[i], y[i], &closest_fine_node);
fs->foci_nodes[i] = closest_fine_node;
fs->x_foci[i] =
- hp->geom_graphs[cur_level][closest_fine_node].x_coord;
+ hp->geom_graphs[cur_level][closest_fine_node].x_coord;
fs->y_foci[i] =
- hp->geom_graphs[cur_level][closest_fine_node].y_coord;
+ hp->geom_graphs[cur_level][closest_fine_node].y_coord;
}
- view->Topview->parms.repos.width =(int) (view->bdxRight-view->bdxLeft);
- view->Topview->parms.repos.height =(int) (view->bdyTop-view->bdyBottom);
+ view->Topview->parms.repos.width =
+ (int) (view->bdxRight - view->bdxLeft);
+ view->Topview->parms.repos.height =
+ (int) (view->bdyTop - view->bdyBottom);
- colorxlate(get_attribute_value("topologicalfisheyefinestcolor", view, view->g[view->activeGraph]), &cl,
- RGBA_DOUBLE);
- view->Topview->srcColor.R = (float) cl.u.RGBA[0];
+ colorxlate(get_attribute_value
+ ("topologicalfisheyefinestcolor", view,
+ view->g[view->activeGraph]), &cl, RGBA_DOUBLE);
+ view->Topview->srcColor.R = (float) cl.u.RGBA[0];
view->Topview->srcColor.G = (float) cl.u.RGBA[1];
view->Topview->srcColor.B = (float) cl.u.RGBA[2];
- colorxlate(get_attribute_value("topologicalfisheyecoarsestcolor", view, view->g[view->activeGraph]), &cl,
- RGBA_DOUBLE);
- view->Topview->tarColor.R = (float) cl.u.RGBA[0];
+ colorxlate(get_attribute_value
+ ("topologicalfisheyecoarsestcolor", view,
+ view->g[view->activeGraph]), &cl, RGBA_DOUBLE);
+ view->Topview->tarColor.R = (float) cl.u.RGBA[0];
view->Topview->tarColor.G = (float) cl.u.RGBA[1];
view->Topview->tarColor.B = (float) cl.u.RGBA[2];
- sscanf(agget(view->g[view->activeGraph],"topologicalfisheyedistortionfactor"),"%lf",&view->Topview->parms.repos.distortion);
- sscanf(agget(view->g[view->activeGraph],"topologicalfisheyefinenodes"),"%d",&view->Topview->parms.level.num_fine_nodes);
- sscanf(agget(view->g[view->activeGraph],"topologicalfisheyecoarseningfactor"),"%lf",&view->Topview->parms.level.coarsening_rate);
- sscanf(agget(view->g[view->activeGraph],"topologicalfisheyedist2limit"),"%d",&view->Topview->parms.hier.dist2_limit);
- sscanf(agget(view->g[view->activeGraph],"topologicalfisheyeanimate"),"%d",&view->Topview->animate);
+ sscanf(agget
+ (view->g[view->activeGraph],
+ "topologicalfisheyedistortionfactor"), "%lf",
+ &view->Topview->parms.repos.distortion);
+ sscanf(agget
+ (view->g[view->activeGraph], "topologicalfisheyefinenodes"),
+ "%d", &view->Topview->parms.level.num_fine_nodes);
+ sscanf(agget
+ (view->g[view->activeGraph],
+ "topologicalfisheyecoarseningfactor"), "%lf",
+ &view->Topview->parms.level.coarsening_rate);
+ sscanf(agget
+ (view->g[view->activeGraph], "topologicalfisheyedist2limit"),
+ "%d", &view->Topview->parms.hier.dist2_limit);
+ sscanf(agget(view->g[view->activeGraph], "topologicalfisheyeanimate"),
+ "%d", &view->Topview->animate);
set_active_levels(hp, fs->foci_nodes, fs->num_foci, &(t->parms.level));
- positionAllItems(hp, fs, &(t->parms.repos));
+ positionAllItems(hp, fs, &(t->parms.repos));
- view->Topview->animate=1;
+ view->Topview->animate = 1;
- if(t->animate)
- {
- view->active_frame=0;
- g_timer_start(view->timer);
- }
+ if (t->animate) {
+ view->active_frame = 0;
+ g_timer_start(view->timer);
+ }
}
-void refresh_old_values(topview* t)
+void refresh_old_values(topview * t)
{
int level, v;
Hierarchy *hp = t->h;
- for (level = 0; level < hp->nlevels; level++)
- {
- for (v = 0; v < hp->nvtxs[level]; v++)
- {
- ex_vtx_data *gg = hp->geom_graphs[level];
- /* v_data *g = hp->graphs[level]; */
- /* double x0,y0; */
- gg[v].old_physical_x_coord=gg[v].physical_x_coord;
- gg[v].old_physical_y_coord=gg[v].physical_y_coord;
- gg[v].old_active_level=gg[v].active_level;
- }
+ for (level = 0; level < hp->nlevels; level++) {
+ for (v = 0; v < hp->nvtxs[level]; v++) {
+ ex_vtx_data *gg = hp->geom_graphs[level];
+ /* v_data *g = hp->graphs[level]; */
+ /* double x0,y0; */
+ gg[v].old_physical_x_coord = gg[v].physical_x_coord;
+ gg[v].old_physical_y_coord = gg[v].physical_y_coord;
+ gg[v].old_active_level = gg[v].active_level;
}
+ }
}
-void get_interpolated_coords(double x0,double y0,double x1,double y1,int fr,int total_fr, double* x,double* y)
+void get_interpolated_coords(double x0, double y0, double x1, double y1,
+ int fr, int total_fr, double *x, double *y)
{
- *x=x0+(x1-x0)/(double)total_fr*(double)(fr+1);
- *y= y0+(y1-y0)/(double)total_fr*(double)(fr+1);
+ *x = x0 + (x1 - x0) / (double) total_fr *(double) (fr + 1);
+ *y = y0 + (y1 - y0) / (double) total_fr *(double) (fr + 1);
}
-int get_active_frame(topview* t)
-{
- gulong microseconds;
- gdouble seconds;
- int fr;
- seconds=g_timer_elapsed(view->timer,µseconds);
- fr=(int)(seconds/((double)view->frame_length/(double)1000));
- if (fr<view->total_frames)
- {
- if (fr==view->active_frame)
- return 0;
- else
- {
- view->active_frame=fr;
- return 1;
- }
- }
- else
- {
- g_timer_stop(view->timer);
- view->Topview->animate=0;
- return 0;
+int get_active_frame(topview * t)
+{
+ gulong microseconds;
+ gdouble seconds;
+ int fr;
+ seconds = g_timer_elapsed(view->timer, µseconds);
+ fr = (int) (seconds / ((double) view->frame_length / (double) 1000));
+ if (fr < view->total_frames) {
+
+ if (fr == view->active_frame)
+ return 0;
+ else {
+ view->active_frame = fr;
+ return 1;
}
+ } else {
+ g_timer_stop(view->timer);
+ view->Topview->animate = 0;
+ return 0;
+ }
}
void drawtopologicalfisheyestatic(topview * t)
{
int level, v;
- Hierarchy* hp = t->h;
+ Hierarchy *hp = t->h;
- glPointSize(15);
- glBegin(GL_POINTS);
- for (level=0;level < hp->nlevels;level++) {
- for (v=0;v < hp->nvtxs[level]; v++) {
- ex_vtx_data* gg = hp->geom_graphs[level];
- if(gg[v].active_level==level) {
+ glPointSize(15);
+ glBegin(GL_POINTS);
+ for (level = 0; level < hp->nlevels; level++) {
+ for (v = 0; v < hp->nvtxs[level]; v++) {
+ ex_vtx_data *gg = hp->geom_graphs[level];
+ if (gg[v].active_level == level) {
double x0 = gg[v].physical_x_coord;
double y0 = gg[v].physical_y_coord;
-// glColor3f((GLfloat)(hp->nlevels-level)/(GLfloat)hp->nlevels,(GLfloat)level/(GLfloat)hp->nlevels,0);
- glColor4f((GLfloat)0,(GLfloat)1,(GLfloat)0,(GLfloat)0.2);
- glVertex3f((GLfloat)x0,(GLfloat)y0,(GLfloat)0);
+// glColor3f((GLfloat)(hp->nlevels-level)/(GLfloat)hp->nlevels,(GLfloat)level/(GLfloat)hp->nlevels,0);
+ glColor4f((GLfloat) 0, (GLfloat) 1, (GLfloat) 0,
+ (GLfloat) 0.2);
+ glVertex3f((GLfloat) x0, (GLfloat) y0, (GLfloat) 0);
}
}
}
glEnd();
-
-
-
+
+
+
/* glBegin(GL_LINES);
for (level=0;level < hp->nlevels;level++) {
for (v=0;v < hp->nvtxs[level]; v++) {
glEnd();*/
}
#endif
-
+/* $Id$Revision: */
/* vim:set shiftwidth=4 ts=8: */
/**********************************************************
#include "smyrnadefs.h"
#include "hier.h"
-void fisheye_polar(double x_focus, double y_focus, topview * t);
-void fisheye_spherical(double x_focus, double y_focus, double z_focus,
- topview * t);
-void prepare_topological_fisheye(topview*);
-void drawtopologicalfisheye(topview * t);
-void drawtopologicalfisheye2(topview * t);
-void changetopfishfocus(topview * t, float *x, float *y,
- float *z, int num_foci);
-void refresh_old_values(topview* t);
-void get_interpolated_coords(double x0,double y0,double x1,double y1,int fr,int total_fr, double* x,double* y);
-int get_active_frame(topview* t);
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ void fisheye_polar(double x_focus, double y_focus, topview * t);
+ void fisheye_spherical(double x_focus, double y_focus, double z_focus,
+ topview * t);
+ void prepare_topological_fisheye(topview *);
+ void drawtopologicalfisheye(topview * t);
+ void drawtopologicalfisheye2(topview * t);
+ void changetopfishfocus(topview * t, float *x, float *y,
+ float *z, int num_foci);
+ void refresh_old_values(topview * t);
+ void get_interpolated_coords(double x0, double y0, double x1,
+ double y1, int fr, int total_fr,
+ double *x, double *y);
+ int get_active_frame(topview * t);
+
+#ifdef __cplusplus
+} /* end extern "C" */
+#endif
#endif
static void set_topview_options(void);
static int draw_topview_label(topview_node * v, float zdepth);
static int draw_topview_edge_label(topview_edge * e, float zdepth);
-static int node_visible(topview_node* n);
+static int node_visible(topview_node * n);
static int select_topview_node(topview_node * n);
static int get_color_from_edge(topview_edge * e);
-static void draw_xdot_set(xdot_set* s);
-static xdot_set* init_xdot_set();
-static void free_xdotset(xdot_set* s);
-static void add_to_xdot_set(xdot_set* s, xdot *x);
+static void draw_xdot_set(xdot_set * s);
+static xdot_set *init_xdot_set();
+static void free_xdotset(xdot_set * s);
+static void add_to_xdot_set(xdot_set * s, xdot * x);
void cleartopview(topview * t)
{
- free (t->Nodes);
- free (t->Edges);
- free_xdotset(t->xdot_list);
+ free(t->Nodes);
+ free(t->Edges);
+ free_xdotset(t->xdot_list);
}
-static void init_element_data(element_data* d)
+static void init_element_data(element_data * d)
{
-
- d->Highlighted=0;
- d->Layer=0;
- d->Visible=1;
- d->Highlighted=0;
- d->Selected=0;
- d->Preselected=0;
- d->NumDataCount=0;
- d->NumData=(float*)0;
- d->StrDataCount=0;
- d->StrData=(char**)0;
- d->selectionflag=0;
- d->param=0;
- d->TVRef=-1;
-}
-
-static void
-setpositioninfo(float* x,float* y,float* z,char* buf)
+
+ d->Highlighted = 0;
+ d->Layer = 0;
+ d->Visible = 1;
+ d->Highlighted = 0;
+ d->Selected = 0;
+ d->Preselected = 0;
+ d->NumDataCount = 0;
+ d->NumData = (float *) 0;
+ d->StrDataCount = 0;
+ d->StrData = (char **) 0;
+ d->selectionflag = 0;
+ d->param = 0;
+ d->TVRef = -1;
+}
+
+static void setpositioninfo(float *x, float *y, float *z, char *buf)
{
- /*zero all values*/
- *x=0;
- *y=0;
- *z=0;
- sscanf(buf,"%f,%f,%f",x,y,z);
+ /*zero all values */
+ *x = 0;
+ *y = 0;
+ *z = 0;
+ sscanf(buf, "%f,%f,%f", x, y, z);
}
-static void setRGBcolor(RGBColor* c,char* colorstr)
+static void setRGBcolor(RGBColor * c, char *colorstr)
{
gvcolor_t cl;
- /*if node has color attribute*/
- if ((colorstr != '\0') && (strlen(colorstr) > 0))
- {
- colorxlate(colorstr, &cl, RGBA_DOUBLE);
- c->tag=1; /*tag is used to identofy colros set by the graph , not smyrna*/
- }
- else
- {
- colorxlate(agget(view->g[view->activeGraph],"defaultnodecolor"), &cl, RGBA_DOUBLE);
- c->tag=0;
- }
- c->R = (float) cl.u.RGBA[0];
- c->G = (float) cl.u.RGBA[1];
- c->B = (float) cl.u.RGBA[2];
- c->A = (float) cl.u.RGBA[3];
+ /*if node has color attribute */
+ if ((colorstr != '\0') && (strlen(colorstr) > 0)) {
+ colorxlate(colorstr, &cl, RGBA_DOUBLE);
+ c->tag = 1; /*tag is used to identofy colros set by the graph , not smyrna */
+ } else {
+ colorxlate(agget(view->g[view->activeGraph], "defaultnodecolor"),
+ &cl, RGBA_DOUBLE);
+ c->tag = 0;
+ }
+ c->R = (float) cl.u.RGBA[0];
+ c->G = (float) cl.u.RGBA[1];
+ c->B = (float) cl.u.RGBA[2];
+ c->A = (float) cl.u.RGBA[3];
}
/*update position info from cgraph*/
-void settvposinfo(Agraph_t* g,topview* t)
+void settvposinfo(Agraph_t * g, topview * t)
{
int ind;
- float maxedgelen,len,minedgelen,totallen;
+ float maxedgelen, len, minedgelen, totallen;
float xmin, xmax, ymin, ymax;
- topview_node* np;
- topview_edge* ep;
- Agsym_t* poss = agattr (g, AGNODE, "pos", 0);
- assert (poss);
+ topview_node *np;
+ topview_edge *ep;
+ Agsym_t *poss = agattr(g, AGNODE, "pos", 0);
+ assert(poss);
- maxedgelen=0;
+ maxedgelen = 0;
xmax = ymax = -MAXFLOAT;
xmin = ymin = minedgelen = MAXFLOAT;
- totallen=0;
+ totallen = 0;
- /*loop nodes*/
- for (ind=0;ind < t->Nodecount ; ind ++)
- {
- np = t->Nodes + ind;
- setpositioninfo(&np->x,&np->y,&np->z,agxget(np->Node, poss));
-
- /*distorted coordiates, same with original ones at the beginning*/
- np->distorted_x = t->Nodes[ind].x;
- np->distorted_y = t->Nodes[ind].y;
- np->distorted_z = t->Nodes[ind].z;
- xmax = MAX(xmax, np->x);
- xmin = MIN(xmin, np->x);
- ymax = MAX(ymax, np->y);
- ymin = MIN(ymin, np->y);
- }
-
- /*loop edges*/
- for (ind=0;ind < t->Edgecount ; ind ++)
- {
- ep = t->Edges + ind;
- ep->x1 = ep->Node1->x;
- ep->y1 = ep->Node1->y;
- ep->z1 = ep->Node1->z;
- ep->x2 = ep->Node2->x;
- ep->y2 = ep->Node2->y;
- ep->z2 = ep->Node2->z;
- len=(float)DIST(ep->x2 - ep->x1, ep->y2 - ep->y1);
- totallen = totallen + len;
- if (len > maxedgelen)
- maxedgelen=len;
- if(len < minedgelen)
- minedgelen=len;
- ep->length=len;
+ /*loop nodes */
+ for (ind = 0; ind < t->Nodecount; ind++) {
+ np = t->Nodes + ind;
+ setpositioninfo(&np->x, &np->y, &np->z, agxget(np->Node, poss));
+
+ /*distorted coordiates, same with original ones at the beginning */
+ np->distorted_x = t->Nodes[ind].x;
+ np->distorted_y = t->Nodes[ind].y;
+ np->distorted_z = t->Nodes[ind].z;
+ xmax = MAX(xmax, np->x);
+ xmin = MIN(xmin, np->x);
+ ymax = MAX(ymax, np->y);
+ ymin = MIN(ymin, np->y);
}
- t->maxedgelen=maxedgelen;
- t->minedgelen=minedgelen;
- t->avgedgelength=totallen / (float) t->Edgecount;
+ /*loop edges */
+ for (ind = 0; ind < t->Edgecount; ind++) {
+ ep = t->Edges + ind;
+ ep->x1 = ep->Node1->x;
+ ep->y1 = ep->Node1->y;
+ ep->z1 = ep->Node1->z;
+ ep->x2 = ep->Node2->x;
+ ep->y2 = ep->Node2->y;
+ ep->z2 = ep->Node2->z;
+ len = (float) DIST(ep->x2 - ep->x1, ep->y2 - ep->y1);
+ totallen = totallen + len;
+ if (len > maxedgelen)
+ maxedgelen = len;
+ if (len < minedgelen)
+ minedgelen = len;
+ ep->length = len;
+ }
+
+ t->maxedgelen = maxedgelen;
+ t->minedgelen = minedgelen;
+ t->avgedgelength = totallen / (float) t->Edgecount;
}
static int mapbool(char *p, int defv)
{
if (p == NULL || (*p == '\0'))
- return defv;
+ return defv;
if (!strcasecmp(p, "false"))
- return 0;
+ return 0;
if (!strcasecmp(p, "true"))
- return 1;
+ return 1;
return atoi(p);
}
/*for atttribute values which has no meaning for a 0 or 1 value 0 iz returned,
function is error safe
*/
-static int boolAttr(void* obj, Agsym_t* attr, int defv)
+static int boolAttr(void *obj, Agsym_t * attr, int defv)
{
- if (attr == NULL) return defv;
- else return mapbool(agxget (obj,attr), defv);
+ if (attr == NULL)
+ return defv;
+ else
+ return mapbool(agxget(obj, attr), defv);
}
-static int visible (void* obj, Agsym_t* vattr, Agsym_t* sattr)
+static int visible(void *obj, Agsym_t * vattr, Agsym_t * sattr)
{
if (vattr)
- return boolAttr (obj, vattr, 1);
+ return boolAttr(obj, vattr, 1);
else if (sattr) {
- if (strcmp (agxget (obj, sattr), "invis")) return 1;
- else return 0;
- }
- else
+ if (strcmp(agxget(obj, sattr), "invis"))
+ return 1;
+ else
+ return 0;
+ } else
return 1;
}
-void settvcolorinfo(Agraph_t* g,topview* t)
+void settvcolorinfo(Agraph_t * g, topview * t)
{
int ind;
RGBColor color;
- topview_node* np;
- topview_edge* ep;
- Agsym_t* sel = agattr (g, AGNODE, "selected", 0);
- Agsym_t* hilite = agattr (g, AGNODE, "highlighted", 0);
- Agsym_t* vis = agattr (g, AGNODE, "visible", 0);
- Agsym_t* sty = agattr (g, AGNODE, "style", 0);
- Agsym_t* ecolor = agattr (g, AGEDGE, "color", 0);
- Agsym_t* edgeid=agattr (g, AGEDGE, "edgeid", 0);
- char* color_string;
-
- /*loop nodes*/
- for (ind=0;ind < t->Nodecount ; ind ++)
- {
- np = t->Nodes + ind;
- setRGBcolor(&color,agget(np->Node, "color"));
- np->Color = color;
-
- /*while in the loop why dont we set some smyrna settings from graph? selected , highlighted , visible */
- np->data.Selected = boolAttr(np->Node,sel,0);
- np->data.Highlighted = boolAttr(np->Node,hilite,0);
- np->data.Visible = visible(np->Node,vis,sty);
+ topview_node *np;
+ topview_edge *ep;
+ Agsym_t *sel = agattr(g, AGNODE, "selected", 0);
+ Agsym_t *hilite = agattr(g, AGNODE, "highlighted", 0);
+ Agsym_t *vis = agattr(g, AGNODE, "visible", 0);
+ Agsym_t *sty = agattr(g, AGNODE, "style", 0);
+ Agsym_t *ecolor = agattr(g, AGEDGE, "color", 0);
+ Agsym_t *edgeid = agattr(g, AGEDGE, "edgeid", 0);
+ char *color_string;
+
+ /*loop nodes */
+ for (ind = 0; ind < t->Nodecount; ind++) {
+ np = t->Nodes + ind;
+ setRGBcolor(&color, agget(np->Node, "color"));
+ np->Color = color;
+
+ /*while in the loop why dont we set some smyrna settings from graph? selected , highlighted , visible */
+ np->data.Selected = boolAttr(np->Node, sel, 0);
+ np->data.Highlighted = boolAttr(np->Node, hilite, 0);
+ np->data.Visible = visible(np->Node, vis, sty);
}
- /*loop edges*/
- sel = agattr (g, AGEDGE, "selected", 0);
- hilite = agattr (g, AGEDGE, "highlighted", 0);
- vis = agattr (g, AGEDGE, "visible", 0);
- sty = agattr (g, AGEDGE, "style", 0);
- setMultiedges(g,"edgeid");
- edgeid=agattr (g, AGEDGE, "edgeid", 0);
- /*set multi edges*/
- for (ind = 0;ind < t->Edgecount ; ind ++)
- {
- ep = t->Edges + ind;
- if (ecolor && (color_string = agxget(ep->Edge, ecolor)) && (*color_string != '\0'))
- setRGBcolor(&color,color_string);
- else{ /*use color theme*/
- getcolorfromschema(view->colschms,ep->length,t->maxedgelen,&color);
- color.tag = 0;
- }
- ep->data.edgeid=boolAttr(ep->Edge,edgeid,0);
- ep->Color = color;
- ep->data.Selected = boolAttr(ep->Edge,sel,0);
- ep->data.Highlighted = boolAttr(ep->Edge,hilite,0);
- ep->data.Visible = visible(ep->Edge,vis,sty);
+ /*loop edges */
+ sel = agattr(g, AGEDGE, "selected", 0);
+ hilite = agattr(g, AGEDGE, "highlighted", 0);
+ vis = agattr(g, AGEDGE, "visible", 0);
+ sty = agattr(g, AGEDGE, "style", 0);
+ setMultiedges(g, "edgeid");
+ edgeid = agattr(g, AGEDGE, "edgeid", 0);
+ /*set multi edges */
+ for (ind = 0; ind < t->Edgecount; ind++) {
+ ep = t->Edges + ind;
+ if (ecolor && (color_string = agxget(ep->Edge, ecolor))
+ && (*color_string != '\0'))
+ setRGBcolor(&color, color_string);
+ else { /*use color theme */
+ getcolorfromschema(view->colschms, ep->length, t->maxedgelen,
+ &color);
+ color.tag = 0;
+ }
+ ep->data.edgeid = boolAttr(ep->Edge, edgeid, 0);
+ ep->Color = color;
+ ep->data.Selected = boolAttr(ep->Edge, sel, 0);
+ ep->data.Highlighted = boolAttr(ep->Edge, hilite, 0);
+ ep->data.Visible = visible(ep->Edge, vis, sty);
}
}
-static xdot* parseXdotwithattr(void *p, char *attr)
+static xdot *parseXdotwithattr(void *p, char *attr)
{
xdot *xDot;
if ((xDot = parseXDotF(agget(p, attr), OpFns, sizeof(xdot_op))))
- return xDot;
- else
- return NULL;
+ return xDot;
+ else
+ return NULL;
}
-static void parseXdotwithattrs(void *e, xdot_set* s)
+static void parseXdotwithattrs(void *e, xdot_set * s)
{
- add_to_xdot_set(s,parseXdotwithattr(e, "_draw_"));
- add_to_xdot_set(s,parseXdotwithattr(e, "_ldraw_"));
- add_to_xdot_set(s,parseXdotwithattr(e, "_hdraw_"));
- add_to_xdot_set(s,parseXdotwithattr(e, "_tdraw_"));
- add_to_xdot_set(s,parseXdotwithattr(e, "_hldraw_"));
- add_to_xdot_set(s,parseXdotwithattr(e, "_tldraw_"));
+ add_to_xdot_set(s, parseXdotwithattr(e, "_draw_"));
+ add_to_xdot_set(s, parseXdotwithattr(e, "_ldraw_"));
+ add_to_xdot_set(s, parseXdotwithattr(e, "_hdraw_"));
+ add_to_xdot_set(s, parseXdotwithattr(e, "_tdraw_"));
+ add_to_xdot_set(s, parseXdotwithattr(e, "_hldraw_"));
+ add_to_xdot_set(s, parseXdotwithattr(e, "_tldraw_"));
}
-void settvxdot(Agraph_t* g,topview* t)
+
+void settvxdot(Agraph_t * g, topview * t)
{
- /*look for xdot attributes and parse them if there is any*/
-
- topview_node* np;
- topview_edge* ep;
- int ind;
- for (ind=0;ind < t->Nodecount ; ind ++)
- {
- np=&t->Nodes[ind];
- parseXdotwithattrs(np->Node, t->xdot_list);
+ /*look for xdot attributes and parse them if there is any */
+
+ topview_node *np;
+ topview_edge *ep;
+ int ind;
+ for (ind = 0; ind < t->Nodecount; ind++) {
+ np = &t->Nodes[ind];
+ parseXdotwithattrs(np->Node, t->xdot_list);
}
- for (ind=0;ind < t->Edgecount ; ind ++)
- {
- ep=&t->Edges[ind];
- parseXdotwithattrs(ep->Edge, t->xdot_list);
+ for (ind = 0; ind < t->Edgecount; ind++) {
+ ep = &t->Edges[ind];
+ parseXdotwithattrs(ep->Edge, t->xdot_list);
}
}
-void init_node_size(Agraph_t * g,topview * t)
+void init_node_size(Agraph_t * g, topview * t)
{
- float vsize;
- int percent;
- percent = atoi(agget(g,"nodesize"));
- if (percent == 0)
- percent=0.000001;
- vsize = 0.05*sqrt((view->bdxRight - view->bdxLeft)*(view->bdyTop - view->bdyBottom));
- t->init_node_size = vsize*2/GetOGLDistance(2)*percent/100.0/sqrt(t->Nodecount);
- t->init_zoom = view->zoom;
+ float vsize;
+ int percent;
+ percent = atoi(agget(g, "nodesize"));
+ if (percent == 0)
+ percent = 0.000001;
+ vsize =
+ 0.05 * sqrt((view->bdxRight - view->bdxLeft) *
+ (view->bdyTop - view->bdyBottom));
+ t->init_node_size =
+ vsize * 2 / GetOGLDistance(2) * percent / 100.0 /
+ sqrt(t->Nodecount);
+ t->init_zoom = view->zoom;
}
-void update_topview(Agraph_t * g, topview * t,int init)
+void update_topview(Agraph_t * g, topview * t, int init)
{
- char* info_file;
- char* str;
- char buf[512];
- int BUFSIZE=512;
- unsigned char xbuffer[BUFSIZ];
- FILE* f;
-
- if (init)
- preparetopview(g,t);
- free_xdotset(view->Topview->xdot_list);
- t->xdot_list=init_xdot_set();
- settvposinfo(g,t);
- settvcolorinfo(g,t);
+ char *info_file;
+ char *str;
+ char buf[512];
+ /* int BUFSIZE = 512; */
+ unsigned char xbuffer[BUFSIZ];
+ FILE *f;
+
+ if (init)
+ preparetopview(g, t);
+ free_xdotset(view->Topview->xdot_list);
+ t->xdot_list = init_xdot_set();
+ settvposinfo(g, t);
+ settvcolorinfo(g, t);
set_boundaries(t);
set_update_required(t);
- settvxdot(view->g[view->activeGraph],view->Topview);
- init_node_size(g,t);
- /*This is a temp code , need to be removed after Xue's demo*/
- info_file=agget(g,"demo_file");
- if ((info_file != NULL) && (strlen(info_file)!=0))
- {
- agxbuf xbuf;
- agxbinit (&xbuf,512, xbuffer);
-
- f=fopen(info_file,"r");
- if (info_file)
- {
- while (fgets(buf, BUFSIZ, f))
- agxbput (&xbuf, buf);
- agxbput (&xbuf, "");
- str=agxbuse (&xbuf);
- append_textview((GtkTextView*) glade_xml_get_widget(xml,"mainconsole"),str,strlen(str));
- }
+ settvxdot(view->g[view->activeGraph], view->Topview);
+ init_node_size(g, t);
+ /*This is a temp code , need to be removed after Xue's demo */
+ info_file = agget(g, "demo_file");
+ if ((info_file != NULL) && (strlen(info_file) != 0)) {
+ agxbuf xbuf;
+ agxbinit(&xbuf, 512, xbuffer);
+
+ f = fopen(info_file, "r");
+ if (info_file) {
+ while (fgets(buf, BUFSIZ, f))
+ agxbput(&xbuf, buf);
+ agxbput(&xbuf, "");
+ str = agxbuse(&xbuf);
+ append_textview((GtkTextView *)
+ glade_xml_get_widget(xml, "mainconsole"), str,
+ strlen(str));
}
-
+ }
+
- /*end of temp code*/
+ /*end of temp code */
- if (view->SignalBlock)
- btnToolZoomFit_clicked(NULL,NULL);
+ if (view->SignalBlock)
+ btnToolZoomFit_clicked(NULL, NULL);
}
Agedge_t *e;
Agsym_t *sym;
int ind, ind2, data_type_count; //number of columns for custom view->Topview data ,IP ,HOST, etc
- float maxedgelen,minedgelen,edgelength;
+ float maxedgelen, minedgelen, edgelength;
- maxedgelen=0;
- minedgelen=MAXFLOAT;
- edgelength=0;
+ maxedgelen = 0;
+ minedgelen = MAXFLOAT;
+ edgelength = 0;
ind = 0;
ind2 = 0;
data_type_count = 0;
- d_attr1=NULL;
+ d_attr1 = NULL;
d_attr1 = agget(g, "nodelabelattribute");
if (d_attr1) {
if (!strcmp(d_attr1, "\\N"))
d_attr2 = agget(g, "DataAttribute2");
- /*initialize node and edge array */
- t->Edges = N_GNEW(agnedges(g), topview_edge);
+ /*initialize node and edge array */
+ t->Edges = N_GNEW(agnedges(g), topview_edge);
t->Nodes = N_GNEW(agnnodes(g), topview_node);
- t->maxnodedegree=1;
-
- for (v = agfstnode(g); v; v = agnxtnode(g, v))
- {
- //bind temp record;
- agbindrec(v, "temp_node_record", sizeof(temp_node_record), TRUE);//graph custom data
- /*initialize group index, -1 means no group */
- t->Nodes[ind].GroupIndex = -1;
- t->Nodes[ind].Node = v;
- t->Nodes[ind].data.TVRef=ind;
- ((temp_node_record*)AGDATA(v))->TVref=ind;
- init_element_data(&t->Nodes[ind].data);
- t->Nodes[ind].zoom_factor = 1;
- t->Nodes[ind].degree = agdegree(g, v, 1, 1);
- if (agget(t->Nodes[ind].Node,"size")) /*set node size*/
- t->Nodes[ind].size=atof(agget(t->Nodes[ind].Node,"size"));
- else
- t->Nodes[ind].size=0;
- if (t->Nodes[ind].degree > t->maxnodedegree)
- t->maxnodedegree=t->Nodes[ind].degree;
- view->Topview->Nodes[ind].Label=NULL;
-
- t->Nodes[ind].node_alpha = 1;
- for (e = agfstout(g, v); e; e = agnxtout(g, e))
- {
- init_element_data(&t->Edges[ind2].data);/*init edge data*/
- t->Edges[ind2].Edge = e;
- ind2++;
- }
- ind++;
+ t->maxnodedegree = 1;
+
+ for (v = agfstnode(g); v; v = agnxtnode(g, v)) {
+ //bind temp record;
+ agbindrec(v, "temp_node_record", sizeof(temp_node_record), TRUE); //graph custom data
+ /*initialize group index, -1 means no group */
+ t->Nodes[ind].GroupIndex = -1;
+ t->Nodes[ind].Node = v;
+ t->Nodes[ind].data.TVRef = ind;
+ ((temp_node_record *) AGDATA(v))->TVref = ind;
+ init_element_data(&t->Nodes[ind].data);
+ t->Nodes[ind].zoom_factor = 1;
+ t->Nodes[ind].degree = agdegree(g, v, 1, 1);
+ if (agget(t->Nodes[ind].Node, "size")) /*set node size */
+ t->Nodes[ind].size = atof(agget(t->Nodes[ind].Node, "size"));
+ else
+ t->Nodes[ind].size = 0;
+ if (t->Nodes[ind].degree > t->maxnodedegree)
+ t->maxnodedegree = t->Nodes[ind].degree;
+ view->Topview->Nodes[ind].Label = NULL;
+
+ t->Nodes[ind].node_alpha = 1;
+ for (e = agfstout(g, v); e; e = agnxtout(g, e)) {
+ init_element_data(&t->Edges[ind2].data); /*init edge data */
+ t->Edges[ind2].Edge = e;
+ ind2++;
}
+ ind++;
+ }
- /*attach edge node references , loop one more time,set colors*/
+ /*attach edge node references , loop one more time,set colors */
ind = 0;
ind2 = 0;
- for (v = agfstnode(g); v; v = agnxtnode(g, v))
- {
- for (e=agfstout(g, v); e; e = agnxtout(g, e))
- {
- t->Edges[ind2].Node1 =&t->Nodes[((temp_node_record*)AGDATA(agtail(e)))->TVref];
- t->Edges[ind2].Node2 =&t->Nodes[((temp_node_record*)AGDATA(aghead(e)))->TVref];
- ind2++;
- }
- ind++;
+ for (v = agfstnode(g); v; v = agnxtnode(g, v)) {
+ for (e = agfstout(g, v); e; e = agnxtout(g, e)) {
+ t->Edges[ind2].Node1 =
+ &t->Nodes[((temp_node_record *) AGDATA(agtail(e)))->TVref];
+ t->Edges[ind2].Node2 =
+ &t->Nodes[((temp_node_record *) AGDATA(aghead(e)))->TVref];
+ ind2++;
+ }
+ ind++;
}
- /*set some stats for topview*/
- t->Nodecount = ind;
+ /*set some stats for topview */
+ t->Nodecount = ind;
t->Edgecount = ind2;
- /*create glcomp menu system*/
- view->widgets =glcreate_gl_topview_menu();
- /*for grouped data , group data viewing buttons extension*/
-// load_host_buttons(t, g, view->widgets);
- /*set topologilca fisheye to NULL*/
- t->h = '\0';
+ /*create glcomp menu system */
+ view->widgets = glcreate_gl_topview_menu();
+ /*for grouped data , group data viewing buttons extension */
+// load_host_buttons(t, g, view->widgets);
+ /*set topologilca fisheye to NULL */
+ t->h = '\0';
if (view->dfltViewType == VT_TOPFISH)
- t->is_top_fisheye = 1;
+ t->is_top_fisheye = 1;
else
- t->is_top_fisheye = 0;
+ t->is_top_fisheye = 0;
- /*reset picked nodes*/
- t->picked_node_count = 0;
+ /*reset picked nodes */
+ t->picked_node_count = 0;
t->picked_nodes = '\0';
- t->picked_edge_count = 0;
+ t->picked_edge_count = 0;
t->picked_edges = '\0';
- /*hide stupid console window*/
- gtk_widget_hide(glade_xml_get_widget(xml, "vbox13"));
- gtk_widget_hide(glade_xml_get_widget(xml, "hbox7"));
+ /*hide stupid console window */
+ gtk_widget_hide(glade_xml_get_widget(xml, "vbox13"));
+ gtk_widget_hide(glade_xml_get_widget(xml, "hbox7"));
}
static float set_gl_dot_size(topview * t)
{
- float sizevc;
- if (view->active_camera==-1)
- sizevc = t->init_node_size /view->zoom*t->init_zoom;
- else
- sizevc=t->init_node_size /view->cameras[view->active_camera]->r*t->init_zoom;
+ float sizevc;
+ if (view->active_camera == -1)
+ sizevc = t->init_node_size / view->zoom * t->init_zoom;
+ else
+ sizevc =
+ t->init_node_size / view->cameras[view->active_camera]->r *
+ t->init_zoom;
- if (sizevc < 1)
- sizevc=1;
- return sizevc;
+ if (sizevc < 1)
+ sizevc = 1;
+ return sizevc;
}
+
/*
draws multi edges , single edges
this function assumes glBegin(GL_LINES) has been called
*/
-static void draw_edge(double x1,double y1,double z1,double x2,double y2,double z2,int deg,topview_edge* e)
+static void draw_edge(double x1, double y1, double z1, double x2,
+ double y2, double z2, int deg, topview_edge * e)
{
- double alpha,R,ITERANGLE;
- double X1,Y1,X2,Y2;
-
- if (deg)
- {
- R=e->length / 20.0;
- if ((deg / 2) * 2 != deg) /*odd*/
- ITERANGLE=(deg)*15.00*-1;
- else
- ITERANGLE=(deg)*15.00;
- ITERANGLE=DEG2RAD*ITERANGLE;
-
- alpha = atan((y2-y1)/(x2-x1));
- if (x1 > x2)
- ITERANGLE=180*DEG2RAD-ITERANGLE;
- X1=R * cos(alpha-ITERANGLE)+x1;
- Y1=R * sin(alpha-ITERANGLE)+y1;
- X2=R * cos(alpha-(180*DEG2RAD-ITERANGLE))+x2;
- Y2=R * sin(alpha-(180*DEG2RAD-ITERANGLE))+y2;
- glVertex3f(x1,y1,z1);
- glVertex3f(X1,Y1,z1);
- glVertex3f(X1,Y1,z1);
- glVertex3f(X2,Y2,z2);
- glVertex3f(X2,Y2,z2);
- glVertex3f(x2,y2,z2);
- }
+ double alpha, R, ITERANGLE;
+ double X1, Y1, X2, Y2;
+
+ if (deg) {
+ R = e->length / 20.0;
+ if ((deg / 2) * 2 != deg) /*odd */
+ ITERANGLE = (deg) * 15.00 * -1;
else
- {
- glVertex3f(x1,y1,z1);
- glVertex3f(x2,y2,z2);
+ ITERANGLE = (deg) * 15.00;
+ ITERANGLE = DEG2RAD * ITERANGLE;
+
+ alpha = atan((y2 - y1) / (x2 - x1));
+ if (x1 > x2)
+ ITERANGLE = 180 * DEG2RAD - ITERANGLE;
+ X1 = R * cos(alpha - ITERANGLE) + x1;
+ Y1 = R * sin(alpha - ITERANGLE) + y1;
+ X2 = R * cos(alpha - (180 * DEG2RAD - ITERANGLE)) + x2;
+ Y2 = R * sin(alpha - (180 * DEG2RAD - ITERANGLE)) + y2;
+ glVertex3f(x1, y1, z1);
+ glVertex3f(X1, Y1, z1);
+ glVertex3f(X1, Y1, z1);
+ glVertex3f(X2, Y2, z2);
+ glVertex3f(X2, Y2, z2);
+ glVertex3f(x2, y2, z2);
+ } else {
+ glVertex3f(x1, y1, z1);
+ glVertex3f(x2, y2, z2);
- }
+ }
}
-static int begintopviewnodes(Agraph_t* g, float dotsz)
+static int begintopviewnodes(Agraph_t * g, float dotsz)
{
- switch (view->defaultnodeshape)
- {
- case 0:
- glPointSize((GLfloat)dotsz);
- glEnable(GL_POINT_SMOOTH);
- glBegin(GL_POINTS);
- break;
- case 1:
- /* set_gl_dot_size(view->Topview); FIX - command with no effect */
- break;
- default:
- /* set_gl_dot_size(view->Topview); FIX - command with no effect */
- glBegin(GL_POINTS);
-
- };
- //reset single selection mechanism
- view->Selection.single_selected_node=(topview_node*)0;
- view->Selection.single_selected_edge=(topview_edge*)0;
- view->Selection.node_distance=-1;
- return 1;
+ switch (view->defaultnodeshape) {
+ case 0:
+ glPointSize((GLfloat) dotsz);
+ glEnable(GL_POINT_SMOOTH);
+ glBegin(GL_POINTS);
+ break;
+ case 1:
+ /* set_gl_dot_size(view->Topview); FIX - command with no effect */
+ break;
+ default:
+ /* set_gl_dot_size(view->Topview); FIX - command with no effect */
+ glBegin(GL_POINTS);
+
+ };
+ //reset single selection mechanism
+ view->Selection.single_selected_node = (topview_node *) 0;
+ view->Selection.single_selected_edge = (topview_edge *) 0;
+ view->Selection.node_distance = -1;
+ return 1;
}
-static void enddrawcycle(Agraph_t* g)
+static void enddrawcycle(Agraph_t * g)
{
- if (view->Selection.single_selected_edge) {
- if (!(view->mouse.button== rightmousebutton)) //right click pick mode
- { //left click single select mode
- if (view->Selection.single_selected_edge->data.Selected == 0)
- {
- view->Selection.single_selected_edge->data.Selected = 1;
- select_edge(view->Selection.single_selected_edge);
- }
- else
- {
- view->Selection.single_selected_edge->data.Selected = 1;
- deselect_edge(view->Selection.single_selected_edge);
+ if (view->Selection.single_selected_edge) {
+ if (!(view->mouse.button == rightmousebutton)) //right click pick mode
+ { //left click single select mode
+ if (view->Selection.single_selected_edge->data.Selected == 0) {
+ view->Selection.single_selected_edge->data.Selected = 1;
+ select_edge(view->Selection.single_selected_edge);
+ } else {
+ view->Selection.single_selected_edge->data.Selected = 1;
+ deselect_edge(view->Selection.single_selected_edge);
}
}
/* return 1; */
}
- if (view->Selection.single_selected_node)
- {
- if (view->mouse.button== rightmousebutton)
- //right click pick mode
- ;
- /* pick_node(view->Selection.single_selected_node);*/
- else
- { //left click single select mode
- if (view->Selection.single_selected_node->data.Selected == 0)
- {
- view->Selection.single_selected_node->data.Selected = 1;
- select_node(view->Selection.single_selected_node);
- }
- else
- {
- view->Selection.single_selected_node->data.Selected = 1;
- deselect_node(view->Selection.single_selected_node);
+ if (view->Selection.single_selected_node) {
+ if (view->mouse.button == rightmousebutton)
+ //right click pick mode
+ ;
+ /* pick_node(view->Selection.single_selected_node); */
+ else { //left click single select mode
+ if (view->Selection.single_selected_node->data.Selected == 0) {
+ view->Selection.single_selected_node->data.Selected = 1;
+ select_node(view->Selection.single_selected_node);
+ } else {
+ view->Selection.single_selected_node->data.Selected = 1;
+ deselect_node(view->Selection.single_selected_node);
}
}
- }
+ }
}
-static int endtopviewnodes(Agraph_t* g)
+static int endtopviewnodes(Agraph_t * g)
{
- switch (view->defaultnodeshape)
- {
- case 0:
- glEnd();
- glDisable(GL_POINT_SMOOTH);
- break;
- case 1:
- break;
- default:
- glEnd();
- break;
+ switch (view->defaultnodeshape) {
+ case 0:
+ glEnd();
+ glDisable(GL_POINT_SMOOTH);
+ break;
+ case 1:
+ break;
+ default:
+ glEnd();
+ break;
- };
-
- return 1;
+ };
+
+ return 1;
}
topview_node *v;
float ddx, ddy, ddz;
int ind = 0;
- float dotsize = set_gl_dot_size(view->Topview); //sets the size of the gl points
- set_topview_options();
+ float dotsize = set_gl_dot_size(view->Topview); //sets the size of the gl points
+ set_topview_options();
begintopviewnodes(g, dotsize);
- view->visiblenodecount=0;
- for (ind = 0; ind < view->Topview->Nodecount; ind++)
- {
- v = view->Topview->Nodes+ind;
- if (((-v->distorted_x / view->zoom >= view->clipX1)
- && (-v->distorted_x / view->zoom <= view->clipX2)
- && (-v->distorted_y / view->zoom >= view->clipY1)
- && (-v->distorted_y / view->zoom <= view->clipY2))
- || (view->active_camera >= 0) )
- {
- float zdepth;
- view->visiblenodecount = view->visiblenodecount + 1;
- if(!view->drawnodes || !node_visible(v))
- continue;
-
- /*check for each node if it needs to be selected or picked*/
- select_topview_node(v);
- //UPDATE view->Topview data from cgraph
- /* if (v->update_required) */
- /* update_topview_node_from_cgraph(v); */
- if (v->data.Selected == 1)
- {
- glColor4f(view->selectedNodeColor.R, view->selectedNodeColor.G, view->selectedNodeColor.B, view->selectedNodeColor.A);
- ddx = dx;
- ddy = dy;
- ddz = dz;
- }
- else
- { //get the color from node
- glColor4f(v->Color.R, v->Color.G, v->Color.B,v->node_alpha*view->defaultnodealpha);
- ddx = 0;
- ddy = 0;
- ddz = 0;
- }
- if (v->distorted_x != v->x)
- zdepth = (float) Z_FORWARD_PLANE;
- else
- zdepth = (float) Z_BACK_PLANE;
-
- if ((view->defaultnodeshape==0))
- {
- glVertex3f(v->distorted_x - ddx,
- v->distorted_y - ddy, v->distorted_z - ddz);
- }
- else if (view->defaultnodeshape==1)
- {
- if(v->size > 0)
- drawCircle(v->distorted_x - ddx,v->distorted_y - ddy,v->size*view->Topview->init_node_size,v->distorted_z - ddz);
- else
- drawCircle(v->distorted_x - ddx,v->distorted_y - ddy,view->Topview->init_node_size,v->distorted_z - ddz);
- }
- }
- else
- {
- /* int a=1; */
- }
+ view->visiblenodecount = 0;
+ for (ind = 0; ind < view->Topview->Nodecount; ind++) {
+ v = view->Topview->Nodes + ind;
+ if (((-v->distorted_x / view->zoom >= view->clipX1)
+ && (-v->distorted_x / view->zoom <= view->clipX2)
+ && (-v->distorted_y / view->zoom >= view->clipY1)
+ && (-v->distorted_y / view->zoom <= view->clipY2))
+ || (view->active_camera >= 0)) {
+ float zdepth;
+ view->visiblenodecount = view->visiblenodecount + 1;
+ if (!view->drawnodes || !node_visible(v))
+ continue;
+
+ /*check for each node if it needs to be selected or picked */
+ select_topview_node(v);
+ //UPDATE view->Topview data from cgraph
+ /* if (v->update_required) */
+ /* update_topview_node_from_cgraph(v); */
+ if (v->data.Selected == 1) {
+ glColor4f(view->selectedNodeColor.R,
+ view->selectedNodeColor.G,
+ view->selectedNodeColor.B,
+ view->selectedNodeColor.A);
+ ddx = dx;
+ ddy = dy;
+ ddz = dz;
+ } else { //get the color from node
+ glColor4f(v->Color.R, v->Color.G, v->Color.B,
+ v->node_alpha * view->defaultnodealpha);
+ ddx = 0;
+ ddy = 0;
+ ddz = 0;
+ }
+ if (v->distorted_x != v->x)
+ zdepth = (float) Z_FORWARD_PLANE;
+ else
+ zdepth = (float) Z_BACK_PLANE;
+
+ if ((view->defaultnodeshape == 0)) {
+ glVertex3f(v->distorted_x - ddx,
+ v->distorted_y - ddy, v->distorted_z - ddz);
+ } else if (view->defaultnodeshape == 1) {
+ if (v->size > 0)
+ drawCircle(v->distorted_x - ddx, v->distorted_y - ddy,
+ v->size * view->Topview->init_node_size,
+ v->distorted_z - ddz);
+ else
+ drawCircle(v->distorted_x - ddx, v->distorted_y - ddy,
+ view->Topview->init_node_size,
+ v->distorted_z - ddz);
+ }
+ } else {
+ /* int a=1; */
+ }
}
endtopviewnodes(g);
return 1;
float dddx, dddy, dddz;
int ind = 0;
if (!view->drawedges)
- return;
+ return;
glBegin(GL_LINES);
set_topview_options();
for (ind = 0; ind < view->Topview->Edgecount; ind++) {
e = view->Topview->Edges + ind;
if (((e->x1 / view->zoom * -1 > view->clipX1)
- && (e->x1 / view->zoom * -1 < view->clipX2)
- && (e->y1 / view->zoom * -1 > view->clipY1)
- && (e->y1 / view->zoom * -1 < view->clipY2))
- ||
- ((e->x2 / view->zoom * -1 > view->clipX1)
- && (e->x2 / view->zoom * -1 < view->clipX2)
- && (e->y2 / view->zoom * -1 > view->clipY1)
- && (e->y2 / view->zoom * -1 < view->clipY2))
- || (view->active_camera >= 0)) {
-
- if (!get_color_from_edge(e))
+ && (e->x1 / view->zoom * -1 < view->clipX2)
+ && (e->y1 / view->zoom * -1 > view->clipY1)
+ && (e->y1 / view->zoom * -1 < view->clipY2))
+ || ((e->x2 / view->zoom * -1 > view->clipX1)
+ && (e->x2 / view->zoom * -1 < view->clipX2)
+ && (e->y2 / view->zoom * -1 > view->clipY1)
+ && (e->y2 / view->zoom * -1 < view->clipY2))
+ || (view->active_camera >= 0)) {
+
+ if (!get_color_from_edge(e))
continue;
//select_topview_edge(e);
ddx = dx;
ddy = dy;
ddz = 0;
- }
- else {
+ } else {
ddx = 0;
ddy = 0;
ddz = 0;
dddx = dx;
dddy = dy;
dddz = 0;
- }
- else {
+ } else {
dddx = 0;
dddy = 0;
dddz = 0;
}
/*glVertex3f(e->Node1->distorted_x - ddx,
- e->Node1->distorted_y - ddy,
- e->Node1->distorted_z - ddz);
- e->Node2->distorted_x - dddx,
- e->Node2->distorted_y - dddy,
- e->Node2->distorted_z - ddz*/
- draw_edge(e->Node1->distorted_x - ddx,e->Node1->distorted_y - ddy,e->Node1->distorted_z - ddz
- , e->Node2->distorted_x - dddx,e->Node2->distorted_y - dddy,e->Node2->distorted_z - ddz,e->data.edgeid,e);
+ e->Node1->distorted_y - ddy,
+ e->Node1->distorted_z - ddz);
+ e->Node2->distorted_x - dddx,
+ e->Node2->distorted_y - dddy,
+ e->Node2->distorted_z - ddz */
+ draw_edge(e->Node1->distorted_x - ddx,
+ e->Node1->distorted_y - ddy,
+ e->Node1->distorted_z - ddz,
+ e->Node2->distorted_x - dddx,
+ e->Node2->distorted_y - dddy,
+ e->Node2->distorted_z - ddz, e->data.edgeid, e);
+
-
}
}
glEnd();
static int drawtopviewlabels(Agraph_t * g)
{
//drawing labels
- int ind = 0;
- topview_node *v;
- float f;
-
- if (
- ((view->visiblenodecount >view->labelnumberofnodes) && (view->active_camera == -1))
- || (!view->labelshownodes) ||(!view->drawnodes))
- return 0;
- if (view->Topview->maxnodedegree > 15)
- f=15;
- else
- f=view->Topview->maxnodedegree;
- for (ind = 0; ind < view->Topview->Nodecount; ind++)
- {
-
- v = &view->Topview->Nodes[ind];
+ int ind = 0;
+ topview_node *v;
+ float f;
+
+ if (((view->visiblenodecount > view->labelnumberofnodes)
+ && (view->active_camera == -1))
+ || (!view->labelshownodes) || (!view->drawnodes))
+ return 0;
+ if (view->Topview->maxnodedegree > 15)
+ f = 15;
+ else
+ f = view->Topview->maxnodedegree;
+ for (ind = 0; ind < view->Topview->Nodecount; ind++) {
- if (view->active_camera == -1)
- {
- if( ((float)view->visiblenodecount > view->labelnumberofnodes * v->degree / f) && view->labelwithdegree)
- continue;
- }
- if (!node_visible(v))
- continue;
- draw_topview_label(v, 1);
+ v = &view->Topview->Nodes[ind];
+
+ if (view->active_camera == -1) {
+ if (((float) view->visiblenodecount >
+ view->labelnumberofnodes * v->degree / f)
+ && view->labelwithdegree)
+ continue;
}
- return 1;
+ if (!node_visible(v))
+ continue;
+ draw_topview_label(v, 1);
+ }
+ return 1;
}
static int drawtopviewedgelabels(Agraph_t * g)
{
//drawing labels
- int ind = 0;
- topview_edge *e;
- float f;
-
- if ((view->visiblenodecount >view->labelnumberofnodes) || (!view->labelshowedges))
- return 0;
- if (view->Topview->maxnodedegree > 15)
- f=15;
- else
- f=view->Topview->maxnodedegree;
- for (ind = 0; ind < view->Topview->Edgecount; ind++)
- {
-
- e = &view->Topview->Edges[ind];
-
- if(
- (((float)view->visiblenodecount > view->labelnumberofnodes * e->Node1->degree / f) && view->labelwithdegree)
- &&
- (((float)view->visiblenodecount > view->labelnumberofnodes * e->Node2->degree / f) && view->labelwithdegree)
- )
- continue;
- if( (!node_visible(e->Node1)) && (!node_visible(e->Node2)) )
- continue;
- draw_topview_edge_label(e, 0.001);
- }
- return 1;
+ int ind = 0;
+ topview_edge *e;
+ float f;
+
+ if ((view->visiblenodecount > view->labelnumberofnodes)
+ || (!view->labelshowedges))
+ return 0;
+ if (view->Topview->maxnodedegree > 15)
+ f = 15;
+ else
+ f = view->Topview->maxnodedegree;
+ for (ind = 0; ind < view->Topview->Edgecount; ind++) {
+
+ e = &view->Topview->Edges[ind];
+
+ if ((((float) view->visiblenodecount >
+ view->labelnumberofnodes * e->Node1->degree / f)
+ && view->labelwithdegree)
+ &&
+ (((float) view->visiblenodecount >
+ view->labelnumberofnodes * e->Node2->degree / f)
+ && view->labelwithdegree)
+ )
+ continue;
+ if ((!node_visible(e->Node1)) && (!node_visible(e->Node2)))
+ continue;
+ draw_topview_edge_label(e, 0.001);
+ }
+ return 1;
}
void drawTopViewGraph(Agraph_t * g)
{
drawtopviewnodes(g);
- drawtopviewlabels(g);
+ drawtopviewlabels(g);
drawtopviewedges(g);
- drawtopviewedgelabels(g);
- enddrawcycle(g);
- draw_xdot_set(view->Topview->xdot_list);
- draw_node_hint_boxes();
+ drawtopviewedgelabels(g);
+ enddrawcycle(g);
+ draw_xdot_set(view->Topview->xdot_list);
+ draw_node_hint_boxes();
if ((view->Selection.Active > 0) && (!view->SignalBlock)) {
view->Selection.Active = 0;
drawTopViewGraph(g);
}
return 0;*/
}
- if (
- (( view->Selection.Type == 0) && (view->Selection.Active))
- ||
- (view->mouse.button== rightmousebutton)) //single selection or right click (picking)
- {
- float dist=(float)DIST2(view->Selection.X-n->distorted_x, view->Selection.Y-n->distorted_y);
+ if (((view->Selection.Type == 0) && (view->Selection.Active))
+ || (view->mouse.button == rightmousebutton)) //single selection or right click (picking)
+ {
+ float dist =
+ (float) DIST2(view->Selection.X - n->distorted_x,
+ view->Selection.Y - n->distorted_y);
+
+ if ((view->Selection.node_distance == -1)
+ || (dist < view->Selection.node_distance)) {
+ view->Selection.node_distance = dist;
+ view->Selection.single_selected_node = n;
+ }
- if ((view->Selection.node_distance==-1) ||(dist < view->Selection.node_distance))
- {
- view->Selection.node_distance=dist;
- view->Selection.single_selected_node=n;
- }
+ return 0;
- return 0;
-
/* if (OD_Selected(n->Node) == 0)
{
OD_Selected(n->Node) = 1;
}
break;*/
- }
- if(view->Selection.Active==0)
- return 0;
- if (is_point_in_rectangle
+ }
+ if (view->Selection.Active == 0)
+ return 0;
+ if (is_point_in_rectangle
(n->x, n->y, view->Selection.X, view->Selection.Y,
view->Selection.W, view->Selection.H)) {
view->Selection.AlreadySelected = 1;
} else {
- deselect_node (n);
+ deselect_node(n);
view->Selection.AlreadySelected = 1;
}
break;
#ifdef UNUSED
static int select_topview_edge(topview_edge * e)
{
-
- int r = 0;
- if (
- (( view->Selection.Type == 0) && (view->Selection.Active))
- ||
- (view->mouse.button== rightmousebutton)) //single selection or right click (picking)
- {
- float dist=distance_to_line(e->x1,e->y1,e->x2,e->y2,view->Selection.X,view->Selection.Y);
- if ((view->Selection.node_distance==-1) ||(dist < view->Selection.node_distance))
- {
- view->Selection.node_distance=dist;
- view->Selection.single_selected_edge=e;
- }
+ int r = 0;
+ if (((view->Selection.Type == 0) && (view->Selection.Active))
+ || (view->mouse.button == rightmousebutton)) //single selection or right click (picking)
+ {
- return 0;
+ float dist =
+ distance_to_line(e->x1, e->y1, e->x2, e->y2, view->Selection.X,
+ view->Selection.Y);
+ if ((view->Selection.node_distance == -1)
+ || (dist < view->Selection.node_distance)) {
+ view->Selection.node_distance = dist;
+ view->Selection.single_selected_edge = e;
}
+
+ return 0;
+ }
if (!view->Selection.Active)
- return 0;
+ return 0;
r = (lineintersects(e->x1, e->y1, e->x2, e->y2));
- if (r >= 0)
- {
- switch (view->Selection.Type)
- {
- case 0:
- if (OD_Selected(e->Edge) == 0)
- {
- OD_Selected(e->Edge) = 1;
- select_object(view->g[view->activeGraph], e->Edge);
- }
- else
- {
- OD_Selected(e->Edge) = 1;
- deselect_object(view->g[view->activeGraph], e->Edge);
- }
- break;
+ if (r >= 0) {
+ switch (view->Selection.Type) {
+ case 0:
+ if (OD_Selected(e->Edge) == 0) {
+ OD_Selected(e->Edge) = 1;
+ select_object(view->g[view->activeGraph], e->Edge);
+ } else {
+ OD_Selected(e->Edge) = 1;
+ deselect_object(view->g[view->activeGraph], e->Edge);
+ }
+ break;
- }
+ }
}
return 1;
float calculate_font_size(topview_node * v)
{
- float n;
- n=(float)v->degree+(float)1.00;
- return n;
+ float n;
+ n = (float) v->degree + (float) 1.00;
+ return n;
}
float ddx = 0;
float ddy = 0;
- char* buf;
- if (((v->distorted_x / view->zoom * -1 > view->clipX1)
- && (v->distorted_x / view->zoom * -1 < view->clipX2)
- && (v->distorted_y / view->zoom * -1 > view->clipY1)
- && (v->distorted_y / view->zoom * -1 < view->clipY2)) || (view->active_camera >=0))
- {
- if (v->data.Selected == 1)
- {
- ddx = dx;
- ddy = dy;
- }
- glColor4f(view->nodelabelcolor.R,view->nodelabelcolor.G,view->nodelabelcolor.B,view->nodelabelcolor.A);
- buf=agget(agraphof(v->Node),"nodelabelattribute");
- if (buf)
- glprintfglut(view->glutfont,(v->distorted_x - ddx),(v->distorted_y - ddy),v->distorted_z,
- agget(v->Node,buf));
- return 1;
+ char *buf;
+ if (((v->distorted_x / view->zoom * -1 > view->clipX1)
+ && (v->distorted_x / view->zoom * -1 < view->clipX2)
+ && (v->distorted_y / view->zoom * -1 > view->clipY1)
+ && (v->distorted_y / view->zoom * -1 < view->clipY2))
+ || (view->active_camera >= 0)) {
+ if (v->data.Selected == 1) {
+ ddx = dx;
+ ddy = dy;
+ }
+ glColor4f(view->nodelabelcolor.R, view->nodelabelcolor.G,
+ view->nodelabelcolor.B, view->nodelabelcolor.A);
+ buf = agget(agraphof(v->Node), "nodelabelattribute");
+ if (buf)
+ glprintfglut(view->glutfont, (v->distorted_x - ddx),
+ (v->distorted_y - ddy), v->distorted_z,
+ agget(v->Node, buf));
+ return 1;
} else
- return 0;
+ return 0;
}
static int draw_topview_edge_label(topview_edge * e, float zdepth)
{
float ddx = 0;
float ddy = 0;
- char* buf;
- float x1,y1,z1,x2,y2,z2,x,y,z;
- x1=e->Node1->distorted_x;
- y1=e->Node1->distorted_y;
- x2=e->Node2->distorted_x;
- y2=e->Node2->distorted_y;
- z1=e->Node1->distorted_z;
- z2=e->Node2->distorted_z;
+ char *buf;
+ float x1, y1, z1, x2, y2, z2, x, y, z;
+ x1 = e->Node1->distorted_x;
+ y1 = e->Node1->distorted_y;
+ x2 = e->Node2->distorted_x;
+ y2 = e->Node2->distorted_y;
+ z1 = e->Node1->distorted_z;
+ z2 = e->Node2->distorted_z;
- if ((x1 / view->zoom * -1 > view->clipX1)
+ if ((x1 / view->zoom * -1 > view->clipX1)
&& (x1 / view->zoom * -1 < view->clipX2)
&& (y1 / view->zoom * -1 > view->clipY1)
- && (y1 / view->zoom * -1 < view->clipY2))
- {
-
- x=(x2-x1)/2.00 + x1;
- y=(y2-y1)/2.00 + y1;
- z=(z2-z1)/2.00 + z1;
- if (e->data.Selected==1)
- {
- ddx = dx;
- ddy = dy;
- }
- glColor4f(view->edgelabelcolor.R,view->edgelabelcolor.G,view->edgelabelcolor.B,view->edgelabelcolor.A);
- buf=agget(agraphof(e->Edge),"edgelabelattribute");
- if (buf)
- glprintfglut(view->glutfont,x - ddx,y - ddy,z,agget(e->Edge,buf));
- return 1;
+ && (y1 / view->zoom * -1 < view->clipY2)) {
+
+ x = (x2 - x1) / 2.00 + x1;
+ y = (y2 - y1) / 2.00 + y1;
+ z = (z2 - z1) / 2.00 + z1;
+ if (e->data.Selected == 1) {
+ ddx = dx;
+ ddy = dy;
+ }
+ glColor4f(view->edgelabelcolor.R, view->edgelabelcolor.G,
+ view->edgelabelcolor.B, view->edgelabelcolor.A);
+ buf = agget(agraphof(e->Edge), "edgelabelattribute");
+ if (buf)
+ glprintfglut(view->glutfont, x - ddx, y - ddy, z,
+ agget(e->Edge, buf));
+ return 1;
} else
- return 0;
+ return 0;
}
/*if both head and tail nodes are selected use selection color for edges */
- if ((e->Node1->data.Selected) || (e->Node2->data.Selected)) {
+ if ((e->Node1->data.Selected) || (e->Node2->data.Selected)) {
glColor4f(view->selectedEdgeColor.R, view->selectedEdgeColor.G,
view->selectedEdgeColor.B, view->selectedEdgeColor.A);
return return_value;
}
/*if both head and tail nodes are highlighted use edge highlight color */
- if ((e->Node1->data.Highlighted)
+ if ((e->Node1->data.Highlighted)
&& (e->Node2->data.Highlighted)) {
glColor4f(view->highlightedEdgeColor.R,
view->highlightedEdgeColor.G,
}
/*get edge's color attribute */
- if (e->Color.tag==0)
- glColor4f(e->Color.R,e->Color.G,e->Color.B,Alpha*e->Color.A);
- else
- glColor4f(e->Color.R,e->Color.G,e->Color.B,e->Color.A);
+ if (e->Color.tag == 0)
+ glColor4f(e->Color.R, e->Color.G, e->Color.B, Alpha * e->Color.A);
+ else
+ glColor4f(e->Color.R, e->Color.G, e->Color.B, e->Color.A);
return return_value;
}
static int node_visible(topview_node * n)
{
- return n->data.Visible;
+ return n->data.Visible;
}
#define strcaseeq(a,b) (*(a)==*(b)&&!strcasecmp(a,b))
-gvk_layout
-s2layout (char* s)
+gvk_layout s2layout(char *s)
{
- if (!s) return GVK_NONE;
+ if (!s)
+ return GVK_NONE;
if (strcaseeq(s, "dot"))
return GVK_DOT;
}
-char*
-layout2s (gvk_layout gvkl)
+char *layout2s(gvk_layout gvkl)
{
- char* s;
+ char *s;
switch (gvkl) {
- case GVK_NONE :
+ case GVK_NONE:
s = "";
break;
- case GVK_DOT :
+ case GVK_DOT:
s = "dot";
break;
- case GVK_NEATO :
+ case GVK_NEATO:
s = "neato";
break;
- case GVK_TWOPI :
+ case GVK_TWOPI:
s = "twopi";
break;
- case GVK_CIRCO :
+ case GVK_CIRCO:
s = "circo";
break;
- case GVK_FDP :
+ case GVK_FDP:
s = "fdp";
break;
- case GVK_SFDP :
+ case GVK_SFDP:
s = "sfdp";
break;
- default :
+ default:
s = "";
break;
}
return s;
}
-char*
-element2s (gve_element el)
+char *element2s(gve_element el)
{
- char* s;
+ char *s;
switch (el) {
- case GVE_NONE :
+ case GVE_NONE:
s = "";
break;
- case GVE_GRAPH :
+ case GVE_GRAPH:
s = "graph";
break;
- case GVE_CLUSTER :
+ case GVE_CLUSTER:
s = "cluster";
break;
- case GVE_NODE :
+ case GVE_NODE:
s = "node";
break;
- case GVE_EDGE :
+ case GVE_EDGE:
s = "edge";
break;
- default :
+ default:
s = "";
break;
}
return s;
}
-static int node_regex(topview_node * n,char* exp)
+static int node_regex(topview_node * n, char *exp)
{
regex_t preg;
- char *data =n->Label;
- int return_value=0;
- if (data)
- {
- regcomp(&preg, exp, REG_NOSUB);
- if (regexec(&preg, data, 0, 0, 0) == 0)
- return_value=1;
- else
- return_value=0;
- regfree(&preg);
- }
- return return_value;
+ char *data = n->Label;
+ int return_value = 0;
+ if (data) {
+ regcomp(&preg, exp, REG_NOSUB);
+ if (regexec(&preg, data, 0, 0, 0) == 0)
+ return_value = 1;
+ else
+ return_value = 0;
+ regfree(&preg);
+ }
+ return return_value;
}
-void select_with_regex(char* exp)
+void select_with_regex(char *exp)
{
- topview_node *v;
- int ind=0;
- for (ind = 0; ind < view->Topview->Nodecount; ind++)
- {
- v = &view->Topview->Nodes[ind];
- if (node_visible(v))
- {
- if(node_regex(v,exp))
- {
- v->data.Selected = 1;
- select_node(v);
- }
- }
+ topview_node *v;
+ int ind = 0;
+ for (ind = 0; ind < view->Topview->Nodecount; ind++) {
+ v = &view->Topview->Nodes[ind];
+ if (node_visible(v)) {
+ if (node_regex(v, exp)) {
+ v->data.Selected = 1;
+ select_node(v);
+ }
}
+ }
}
struct xdot_set {
- Dt_t* objs; /* original graph object (node edge graph) */
- Dt_t* xdots; /* xdot collection */
+ Dt_t *objs; /* original graph object (node edge graph) */
+ Dt_t *xdots; /* xdot collection */
};
static Dtdisc_t qDisc = {
- offsetof(xdot,ops),
- sizeof(xdot_op*),
+ offsetof(xdot, ops),
+ sizeof(xdot_op *),
-1,
NIL(Dtmake_f),
NIL(Dtfree_f),
NIL(Dtevent_f)
};
-static xdot_set* init_xdot_set()
+static xdot_set *init_xdot_set()
{
- xdot_set* rv;
+ xdot_set *rv;
rv = NEW(xdot_set);
rv->objs = NULL;
- rv->xdots = dtopen (&qDisc, Dtqueue);
+ rv->xdots = dtopen(&qDisc, Dtqueue);
return rv;
}
-static void add_to_xdot_set(xdot_set* s, xdot *x)
+static void add_to_xdot_set(xdot_set * s, xdot * x)
{
- dtinsert (s->xdots, x);
+ dtinsert(s->xdots, x);
}
#ifdef UNUSED
-static xdot* remove_from_xdot_set (xdot_set* s)
+static xdot *remove_from_xdot_set(xdot_set * s)
{
- return (xdot*)dtdelete (s->xdots, NULL);
+ return (xdot *) dtdelete(s->xdots, NULL);
}
#endif
-static void free_xdotset(xdot_set* s)
+static void free_xdotset(xdot_set * s)
{
- if (!s) return;
- if (s->objs) dtclose (s->objs);
- if (s->xdots) dtclose (s->xdots);
- free (s);
+ if (!s)
+ return;
+ if (s->objs)
+ dtclose(s->objs);
+ if (s->xdots)
+ dtclose(s->xdots);
+ free(s);
}
-static void draw_xdot_set(xdot_set* s)
+static void draw_xdot_set(xdot_set * s)
{
int j;
- xdot* x;
-
- for (x = (xdot*)dtfirst (s->xdots); x; x = (xdot*)dtnext(s->xdots, x)) {
- xdot_op* op = x->ops;
- for (j = 0; j < x->cnt; j++, op++) {
- if (op->drawfunc)
- op->drawfunc(op,0);
- }
+ xdot *x;
+
+ for (x = (xdot *) dtfirst(s->xdots); x;
+ x = (xdot *) dtnext(s->xdots, x)) {
+ xdot_op *op = x->ops;
+ for (j = 0; j < x->cnt; j++, op++) {
+ if (op->drawfunc)
+ op->drawfunc(op, 0);
+ }
}
}
-void setMultiedges (Agraph_t* g, char* attrname)
+void setMultiedges(Agraph_t * g, char *attrname)
{
- Agsym_t* attr = agattr (g, AGEDGE, attrname, 0);
- Agnode_t* n;
- Agedge_t* e;
- PointMap* map = newPM();
+ Agsym_t *attr = agattr(g, AGEDGE, attrname, 0);
+ Agnode_t *n;
+ Agedge_t *e;
+ PointMap *map = newPM();
int tid, hid, u, v, idx;
char buf[128];
if (!attr)
- attr = agattr (g, AGEDGE, attrname, "0");
+ attr = agattr(g, AGEDGE, attrname, "0");
- for (n = agfstnode (g); n; n = agnxtnode (g, n)) {
+ for (n = agfstnode(g); n; n = agnxtnode(g, n)) {
tid = AGID(n);
- for (e = agfstout (g, n); e; e = agnxtout (g, e)) {
+ for (e = agfstout(g, n); e; e = agnxtout(g, e)) {
hid = AGID(AGHEAD(e));
if (tid < hid) {
u = tid;
v = hid;
- }
- else {
+ } else {
u = hid;
v = tid;
}
- idx = insertPM (map, u, v, 0);
- sprintf (buf, "%d", idx);
- agxset (e, attr, buf);
- updatePM (map, u, v, idx+1);
+ idx = insertPM(map, u, v, 0);
+ sprintf(buf, "%d", idx);
+ agxset(e, attr, buf);
+ updatePM(map, u, v, idx + 1);
}
}
freePM(map);
}
-
-
-
#define _BB
#endif
-void cleartopview(topview * t);
-void preparetopview(Agraph_t * g, topview * t);
-void update_topview(Agraph_t * g, topview * t,int init);
-void drawTopViewGraph(Agraph_t * g);
-int set_update_required(topview * t);
-int move_TVnodes(void);
-void local_zoom(topview * t);
-void originate_distorded_coordinates(topview * t);
-float calcfontsize(float totaledgelength,int totallabelsize,int edgecount,int totalnodecount);
-void select_with_regex(char* exp);
-void settvcolorinfo(Agraph_t* g,topview* t);
-void setMultiedges (Agraph_t* g, char* attrname);
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ void cleartopview(topview * t);
+ void preparetopview(Agraph_t * g, topview * t);
+ void update_topview(Agraph_t * g, topview * t, int init);
+ void drawTopViewGraph(Agraph_t * g);
+ int set_update_required(topview * t);
+ int move_TVnodes(void);
+ void local_zoom(topview * t);
+ void originate_distorded_coordinates(topview * t);
+ float calcfontsize(float totaledgelength, int totallabelsize,
+ int edgecount, int totalnodecount);
+ void select_with_regex(char *exp);
+ void settvcolorinfo(Agraph_t * g, topview * t);
+ void setMultiedges(Agraph_t * g, char *attrname);
+#ifdef __cplusplus
+} /* end extern "C" */
+#endif
#endif
+/* $Id$Revision: */
/* vim:set shiftwidth=4 ts=8: */
/**********************************************************
#include "smyrnadefs.h"
#include "tvnodes.h"
-int prepare_nodes_for_groups(topview * t, topviewdata * td,
- int groupindex);
-int load_host_buttons(topview * t, Agraph_t * g, glCompSet * s);
-int click_group_button(int groupindex);
-void glhost_button_clicked_Slot(void *p);
-_BB void host_button_clicked_Slot(GtkWidget * widget, gpointer user_data);
+#ifdef __cplusplus
+extern "C" {
+#endif
+ int prepare_nodes_for_groups(topview * t, topviewdata * td,
+ int groupindex);
+ int load_host_buttons(topview * t, Agraph_t * g, glCompSet * s);
+ int click_group_button(int groupindex);
+ void glhost_button_clicked_Slot(void *p);
+ _BB void host_button_clicked_Slot(GtkWidget * widget,
+ gpointer user_data);
+#ifdef __cplusplus
+} /* end extern "C" */
+#endif
#endif
* Local function prototypes (not defined in trackball.h)
*/
static float tb_project_to_sphere(float, float, float);
-static void normalize_quat(float [4]);
+static void normalize_quat(float[4]);
-void
-vzero(float *v)
+void vzero(float *v)
{
v[0] = 0.0;
v[1] = 0.0;
v[2] = 0.0;
}
-void
-vset(float *v, float x, float y, float z)
+void vset(float *v, float x, float y, float z)
{
v[0] = x;
v[1] = y;
v[2] = z;
}
-void
-vsub(const float *src1, const float *src2, float *dst)
+void vsub(const float *src1, const float *src2, float *dst)
{
dst[0] = src1[0] - src2[0];
dst[1] = src1[1] - src2[1];
dst[2] = src1[2] - src2[2];
}
-void
-vcopy(const float *v1, float *v2)
+void vcopy(const float *v1, float *v2)
{
register int i;
- for (i = 0 ; i < 3 ; i++)
- v2[i] = v1[i];
+ for (i = 0; i < 3; i++)
+ v2[i] = v1[i];
}
-void
-vcross(const float *v1, const float *v2, float *cross)
+void vcross(const float *v1, const float *v2, float *cross)
{
float temp[3];
vcopy(temp, cross);
}
-float
-vlength(const float *v)
+float vlength(const float *v)
{
return sqrt(v[0] * v[0] + v[1] * v[1] + v[2] * v[2]);
}
-void
-vscale(float *v, float div)
+void vscale(float *v, float div)
{
v[0] *= div;
v[1] *= div;
v[2] *= div;
}
-void
-vnormal(float *v)
+void vnormal(float *v)
{
- vscale(v,1.0/vlength(v));
+ vscale(v, 1.0 / vlength(v));
}
-float
-vdot(const float *v1, const float *v2)
+float vdot(const float *v1, const float *v2)
{
- return v1[0]*v2[0] + v1[1]*v2[1] + v1[2]*v2[2];
+ return v1[0] * v2[0] + v1[1] * v2[1] + v1[2] * v2[2];
}
-void
-vadd(const float *src1, const float *src2, float *dst)
+void vadd(const float *src1, const float *src2, float *dst)
{
dst[0] = src1[0] + src2[0];
dst[1] = src1[1] + src2[1];
* It is assumed that the arguments to this routine are in the range
* (-1.0 ... 1.0)
*/
-void
-trackball(float q[4], float p1x, float p1y, float p2x, float p2y)
+void trackball(float q[4], float p1x, float p1y, float p2x, float p2y)
{
- float a[3]; /* Axis of rotation */
- float phi; /* how much to rotate about axis */
+ float a[3]; /* Axis of rotation */
+ float phi; /* how much to rotate about axis */
float p1[3], p2[3], d[3];
float t;
if (p1x == p2x && p1y == p2y) {
- /* Zero rotation */
- vzero(q);
- q[3] = 1.0;
- return;
+ /* Zero rotation */
+ vzero(q);
+ q[3] = 1.0;
+ return;
}
/*
* First, figure out z-coordinates for projection of P1 and P2 to
* deformed sphere
*/
- vset(p1,p1x,p1y,tb_project_to_sphere(TRACKBALLSIZE,p1x,p1y));
- vset(p2,p2x,p2y,tb_project_to_sphere(TRACKBALLSIZE,p2x,p2y));
+ vset(p1, p1x, p1y, tb_project_to_sphere(TRACKBALLSIZE, p1x, p1y));
+ vset(p2, p2x, p2y, tb_project_to_sphere(TRACKBALLSIZE, p2x, p2y));
/*
* Now, we want the cross product of P1 and P2
*/
- vcross(p2,p1,a);
+ vcross(p2, p1, a);
/*
* Figure out how much to rotate around that axis.
*/
- vsub(p1,p2,d);
- t = vlength(d) / (2.0*TRACKBALLSIZE);
+ vsub(p1, p2, d);
+ t = vlength(d) / (2.0 * TRACKBALLSIZE);
/*
* Avoid problems with out-of-control values...
*/
- if (t > 1.0) t = 1.0;
- if (t < -1.0) t = -1.0;
+ if (t > 1.0)
+ t = 1.0;
+ if (t < -1.0)
+ t = -1.0;
phi = 2.0 * asin(t);
- axis_to_quat(a,phi,q);
+ axis_to_quat(a, phi, q);
}
/*
* Given an axis and angle, compute quaternion.
*/
-void
-axis_to_quat(float a[3], float phi, float q[4])
+void axis_to_quat(float a[3], float phi, float q[4])
{
vnormal(a);
- vcopy(a,q);
- vscale(q,sin(phi/2.0));
- q[3] = cos(phi/2.0);
+ vcopy(a, q);
+ vscale(q, sin(phi / 2.0));
+ q[3] = cos(phi / 2.0);
}
/*
* Project an x,y pair onto a sphere of radius r OR a hyperbolic sheet
* if we are away from the center of the sphere.
*/
-static float
-tb_project_to_sphere(float r, float x, float y)
+static float tb_project_to_sphere(float r, float x, float y)
{
float d, t, z;
- d = sqrt(x*x + y*y);
- if (d < r * 0.70710678118654752440) { /* Inside sphere */
- z = sqrt(r*r - d*d);
- } else { /* On hyperbola */
- t = r / 1.41421356237309504880;
- z = t*t / d;
+ d = sqrt(x * x + y * y);
+ if (d < r * 0.70710678118654752440) { /* Inside sphere */
+ z = sqrt(r * r - d * d);
+ } else { /* On hyperbola */
+ t = r / 1.41421356237309504880;
+ z = t * t / d;
}
return z;
}
#define RENORMCOUNT 97
-void
-add_quats(float q1[4], float q2[4], float dest[4])
+void add_quats(float q1[4], float q2[4], float dest[4])
{
- static int count=0;
+ static int count = 0;
float t1[4], t2[4], t3[4];
float tf[4];
- vcopy(q1,t1);
- vscale(t1,q2[3]);
+ vcopy(q1, t1);
+ vscale(t1, q2[3]);
- vcopy(q2,t2);
- vscale(t2,q1[3]);
+ vcopy(q2, t2);
+ vscale(t2, q1[3]);
- vcross(q2,q1,t3);
- vadd(t1,t2,tf);
- vadd(t3,tf,tf);
- tf[3] = q1[3] * q2[3] - vdot(q1,q2);
+ vcross(q2, q1, t3);
+ vadd(t1, t2, tf);
+ vadd(t3, tf, tf);
+ tf[3] = q1[3] * q2[3] - vdot(q1, q2);
dest[0] = tf[0];
dest[1] = tf[1];
dest[3] = tf[3];
if (++count > RENORMCOUNT) {
- count = 0;
- normalize_quat(dest);
+ count = 0;
+ normalize_quat(dest);
}
}
* - Pletinckx, D., Quaternion calculus as a basic tool in computer
* graphics, The Visual Computer 5, 2-13, 1989.
*/
-static void
-normalize_quat(float q[4])
+static void normalize_quat(float q[4])
{
int i;
float mag;
- mag = (q[0]*q[0] + q[1]*q[1] + q[2]*q[2] + q[3]*q[3]);
- for (i = 0; i < 4; i++) q[i] /= mag;
+ mag = (q[0] * q[0] + q[1] * q[1] + q[2] * q[2] + q[3] * q[3]);
+ for (i = 0; i < 4; i++)
+ q[i] /= mag;
}
/*
* Build a rotation matrix, given a quaternion rotation.
*
*/
-void
-build_rotmatrix(float m[4][4], float q[4])
+void build_rotmatrix(float m[4][4], float q[4])
{
m[0][0] = 1.0 - 2.0 * (q[1] * q[1] + q[2] * q[2]);
m[0][1] = 2.0 * (q[0] * q[1] - q[2] * q[3]);
m[0][3] = 0.0;
m[1][0] = 2.0 * (q[0] * q[1] + q[2] * q[3]);
- m[1][1]= 1.0 - 2.0 * (q[2] * q[2] + q[0] * q[0]);
+ m[1][1] = 1.0 - 2.0 * (q[2] * q[2] + q[0] * q[0]);
m[1][2] = 2.0 * (q[1] * q[2] - q[0] * q[3]);
m[1][3] = 0.0;
m[3][2] = 0.0;
m[3][3] = 1.0;
}
-
* The resulting rotation is returned as a quaternion rotation in the
* first paramater.
*/
-void
-trackball(float q[4], float p1x, float p1y, float p2x, float p2y);
+void trackball(float q[4], float p1x, float p1y, float p2x, float p2y);
/*
* Given two quaternions, add them together to get a third quaternion.
* rotation, the second and third the total rotation (which will be
* over-written with the resulting new total rotation).
*/
-void
-add_quats(float *q1, float *q2, float *dest);
+void add_quats(float *q1, float *q2, float *dest);
/*
* A useful function, builds a rotation matrix in Matrix based on
* given quaternion.
*/
-void
-build_rotmatrix(float m[4][4], float q[4]);
+void build_rotmatrix(float m[4][4], float q[4]);
/*
* This function computes a quaternion based on an axis (defined by
* the given vector) and an angle about which to rotate. The angle is
* expressed in radians. The result is put into the third argument.
*/
-void
-axis_to_quat(float a[3], float phi, float q[4]);
-
+void axis_to_quat(float a[3], float phi, float q[4]);
data_attr2 = agget(view->g[view->activeGraph], "DataAttribute2");
- if (TV_Nodes.filtered)
- {
- int valid = 1;
- if ((MP_Flag == 1) || (!n))
- {
- n = tree_from_filter_string(TV_Nodes.filter.filter_string);
- MP_Flag = 0;
- buf =agget(view->Topview->Nodes[TV_Node->index].Node,data_attr1);
- if (buf)
- {
- if (strcmp(TV_Nodes.filter.min_data1, buf))
- valid = 0;
- }
- }
- if (data_attr1 && strlen(TV_Nodes.filter.max_data1) && agget(view->Topview->Nodes[TV_Node->index].Node,data_attr1))
- {
- if (strcmp(agget(view->Topview->Nodes[TV_Node->index].Node, data_attr1), TV_Nodes.filter.min_data1))
- valid = 0;
- }
- //string data checks attr2
- if (data_attr2 && strlen(TV_Nodes.filter.min_data2) && agget(view->Topview->Nodes[TV_Node->index].Node,data_attr2))
- {
- if (strcmp(TV_Nodes.filter.min_data2,agget(view->Topview->Nodes[TV_Node->index].Node,data_attr2)))
- valid = 0;
- }
- if (data_attr2 && strlen(TV_Nodes.filter.max_data2)
- && agget(view->Topview->Nodes[TV_Node->index].Node,
- data_attr2))
- {
-
- if (strcmp(agget(view->Topview->Nodes[TV_Node->index].Node, data_attr2),TV_Nodes.filter.min_data2))
- valid = 0;
-
- }
- if (strlen(TV_Nodes.filter.filter_string) > 0)
- valid = evaluate_expresions(TV_Node, n);
- //if show only highlighted
- if (TV_Nodes.filter.highlighted >= 0)
- {
- if (view->Topview->Nodes[TV_Node->index].data.Highlighted!= TV_Nodes.filter.highlighted)
- valid = 0;
- }
- //if show only visibles
- if (TV_Nodes.filter.visible >= 0)
- {
- if (view->Topview->Nodes[TV_Node->index].data.Visible!= TV_Nodes.filter.visible)
- valid = 0;
- }
- //if show only selected
- if (TV_Nodes.filter.selected >= 0)
- {
- if (view->Topview->Nodes[TV_Node->index].data.Selected!= TV_Nodes.filter.selected)
- valid = 0;
- }
- return valid;
- }
- else
- return 1;
+ if (TV_Nodes.filtered) {
+ int valid = 1;
+ if ((MP_Flag == 1) || (!n)) {
+ n = tree_from_filter_string(TV_Nodes.filter.filter_string);
+ MP_Flag = 0;
+ buf =
+ agget(view->Topview->Nodes[TV_Node->index].Node,
+ data_attr1);
+ if (buf) {
+ if (strcmp(TV_Nodes.filter.min_data1, buf))
+ valid = 0;
+ }
+ }
+ if (data_attr1 && strlen(TV_Nodes.filter.max_data1)
+ && agget(view->Topview->Nodes[TV_Node->index].Node,
+ data_attr1)) {
+ if (strcmp
+ (agget
+ (view->Topview->Nodes[TV_Node->index].Node, data_attr1),
+ TV_Nodes.filter.min_data1))
+ valid = 0;
+ }
+ //string data checks attr2
+ if (data_attr2 && strlen(TV_Nodes.filter.min_data2)
+ && agget(view->Topview->Nodes[TV_Node->index].Node,
+ data_attr2)) {
+ if (strcmp
+ (TV_Nodes.filter.min_data2,
+ agget(view->Topview->Nodes[TV_Node->index].Node,
+ data_attr2)))
+ valid = 0;
+ }
+ if (data_attr2 && strlen(TV_Nodes.filter.max_data2)
+ && agget(view->Topview->Nodes[TV_Node->index].Node,
+ data_attr2)) {
+
+ if (strcmp
+ (agget
+ (view->Topview->Nodes[TV_Node->index].Node, data_attr2),
+ TV_Nodes.filter.min_data2))
+ valid = 0;
+
+ }
+ if (strlen(TV_Nodes.filter.filter_string) > 0)
+ valid = evaluate_expresions(TV_Node, n);
+ //if show only highlighted
+ if (TV_Nodes.filter.highlighted >= 0) {
+ if (view->Topview->Nodes[TV_Node->index].data.Highlighted !=
+ TV_Nodes.filter.highlighted)
+ valid = 0;
+ }
+ //if show only visibles
+ if (TV_Nodes.filter.visible >= 0) {
+ if (view->Topview->Nodes[TV_Node->index].data.Visible !=
+ TV_Nodes.filter.visible)
+ valid = 0;
+ }
+ //if show only selected
+ if (TV_Nodes.filter.selected >= 0) {
+ if (view->Topview->Nodes[TV_Node->index].data.Selected !=
+ TV_Nodes.filter.selected)
+ valid = 0;
+ }
+ return valid;
+ } else
+ return 1;
}
static int update_node_gui_objects(tv_node * TV_Node)
}
gtk_widget_show((GtkWidget *) TV_Node->chkSelected);
gtk_toggle_button_set_active((GtkToggleButton *) TV_Node->chkSelected,
- view->Topview-> Nodes[TV_Node->index].data.Selected);
+ view->Topview->Nodes[TV_Node->index].data.
+ Selected);
//Id Label
if (!TV_Node->IDLabel) {
gtk_widget_show((GtkWidget *) TV_Node->chkVisible);
gtk_toggle_button_set_active((GtkToggleButton *) TV_Node->chkVisible,
- view->Topview->Nodes[TV_Node->index].data.Visible);
+ view->Topview->Nodes[TV_Node->index].data.
+ Visible);
//highlighted
if (!TV_Node->chkHighlighted) {
TV_Node->chkHighlighted =
LOCATION_X_CHKHIGHLIGHTED, TV_Nodes.Y);
}
gtk_widget_show((GtkWidget *) TV_Node->chkHighlighted);
- gtk_toggle_button_set_active((GtkToggleButton*)TV_Node-> chkHighlighted,
- view->Topview->Nodes[TV_Node->index].data.Highlighted);
+ gtk_toggle_button_set_active((GtkToggleButton *) TV_Node->
+ chkHighlighted,
+ view->Topview->Nodes[TV_Node->index].data.
+ Highlighted);
//NAME
gtk_widget_set_size_request((GtkWidget *) TV_Node->Name, 75, 23);
}
- gtk_entry_set_text(TV_Node->Name,
- agnameof(view->Topview->Nodes[TV_Node->index].Node));
+ gtk_entry_set_text(TV_Node->Name,
+ agnameof(view->Topview->Nodes[TV_Node->index].
+ Node));
gtk_widget_show((GtkWidget *) TV_Node->Name);
- //DATA 1
+ //DATA 1
if (!TV_Node->Data1) {
TV_Node->Data1 = (GtkEntry *) gtk_entry_new();
gtk_layout_put(layout, (GtkWidget *) TV_Node->Data1,
tv_node *tvn;
GtkLabel *lblTVPage;
- if ((page >= 0) && page <= TV_Nodes.pagecount)
- {
- if (TV_Nodes.general_purpose_flag == 1)
- {
- update_TV_data_from_gui();
- TV_Nodes.general_purpose_flag = 0;
- }
- TV_Nodes.activepage = page;
- TV_Nodes.page_data_node_index =TV_Nodes.page_history[TV_Nodes.activepage];
- TV_Nodes.page_data_index = 0;
- TV_Nodes.firstnodeid = TV_Nodes.page_data_node_index;
- TV_Nodes.Y = TV_Nodes.initial_Y;
- hide_data_widgets();
- }
- else
- return 0;
- while ((TV_Nodes.page_data_index < TV_Nodes.recordperpage)&& (TV_Nodes.page_data_node_index < view->Topview->Nodecount))
- {
- tvn = &TV_Nodes.TV_Node[TV_Nodes.page_data_index];
- tvn->index = TV_Nodes.page_data_node_index;
- if (view->Topview->Nodes[TV_Nodes.page_data_node_index].valid == 1)
- {
- TV_Nodes.page_data_index++;
- update_node_gui_objects(tvn);
- TV_Nodes.Y = TV_Nodes.Y + TV_Nodes.Y_Gap;
- }
- TV_Nodes.page_data_node_index++;
+ if ((page >= 0) && page <= TV_Nodes.pagecount) {
+ if (TV_Nodes.general_purpose_flag == 1) {
+ update_TV_data_from_gui();
+ TV_Nodes.general_purpose_flag = 0;
+ }
+ TV_Nodes.activepage = page;
+ TV_Nodes.page_data_node_index =
+ TV_Nodes.page_history[TV_Nodes.activepage];
+ TV_Nodes.page_data_index = 0;
+ TV_Nodes.firstnodeid = TV_Nodes.page_data_node_index;
+ TV_Nodes.Y = TV_Nodes.initial_Y;
+ hide_data_widgets();
+ } else
+ return 0;
+ while ((TV_Nodes.page_data_index < TV_Nodes.recordperpage)
+ && (TV_Nodes.page_data_node_index < view->Topview->Nodecount)) {
+ tvn = &TV_Nodes.TV_Node[TV_Nodes.page_data_index];
+ tvn->index = TV_Nodes.page_data_node_index;
+ if (view->Topview->Nodes[TV_Nodes.page_data_node_index].valid == 1) {
+ TV_Nodes.page_data_index++;
+ update_node_gui_objects(tvn);
+ TV_Nodes.Y = TV_Nodes.Y + TV_Nodes.Y_Gap;
}
+ TV_Nodes.page_data_node_index++;
+ }
lblTVPage = (GtkLabel *) glade_xml_get_widget(xml, "lblTVPage");
sprintf(buf, "(%i / %i)", TV_Nodes.activepage + 1,
TV_Nodes.pagecount + 1);
TV_Nodes.page_history[TV_Nodes.page_history_count - 1];
TV_Nodes.page_history_count--;
TV_Nodes.page_history =
- RALLOC(TV_Nodes.page_history_count, TV_Nodes.page_history, int);
+ RALLOC(TV_Nodes.page_history_count, TV_Nodes.page_history,
+ int);
return return_value;
}
return 0;
TV_Nodes.activepage = -1;
reset_page_History();
push_to_page_history(0);
- for (i = 0; i < view->Topview->Nodecount; i++)
- {
- tvn.index = i;
- if (validate_node(&tvn))
- {
- count++;
- view->Topview->Nodes[i].valid = 1;
- }
- else
- view->Topview->Nodes[i].valid = 0;
- if (count == TV_Nodes.recordperpage)
- {
- push_to_page_history(i + 1);
- TV_Nodes.pagecount++;
- count = 0;
- }
+ for (i = 0; i < view->Topview->Nodecount; i++) {
+ tvn.index = i;
+ if (validate_node(&tvn)) {
+ count++;
+ view->Topview->Nodes[i].valid = 1;
+ } else
+ view->Topview->Nodes[i].valid = 0;
+ if (count == TV_Nodes.recordperpage) {
+ push_to_page_history(i + 1);
+ TV_Nodes.pagecount++;
+ count = 0;
+ }
}
spn = (GtkSpinButton *) glade_xml_get_widget(xml, "spnTVGotopage");
gtk_spin_button_set_value(spn, 0);
return 1;
}
+
/*
call this function to create a subgraph from filtered nodes and maybe edges
*/
-int create_save_subgraph_from_filter(char* filename)
+int create_save_subgraph_from_filter(char *filename)
{
- int i=0;
- Agraph_t* subg = agsubg (view->g[view->activeGraph], "temp", 1);
- FILE* outputfile;
- for (i = 0; i < view->Topview->Nodecount; i++)
- {
- if (view->Topview->Nodes[i].valid==1)
- {
- agsubnode (subg, view->Topview->Nodes[i].Node, 1);
- }
+ int i = 0;
+ Agraph_t *subg = agsubg(view->g[view->activeGraph], "temp", 1);
+ FILE *outputfile;
+ for (i = 0; i < view->Topview->Nodecount; i++) {
+ if (view->Topview->Nodes[i].valid == 1) {
+ agsubnode(subg, view->Topview->Nodes[i].Node, 1);
}
+ }
- if ((outputfile = fopen(filename, "w")))
- {
- if(agwrite (subg, outputfile))
- {
- agdelsubg (view->g[view->activeGraph], subg);
- return 1;
- }
- else
- {
- agdelsubg (view->g[view->activeGraph], subg);
- return 0;
- }
- }
- else
- {
- agdelsubg (view->g[view->activeGraph], subg);
- return 0;
+ if ((outputfile = fopen(filename, "w"))) {
+ if (agwrite(subg, outputfile)) {
+ agdelsubg(view->g[view->activeGraph], subg);
+ return 1;
+ } else {
+ agdelsubg(view->g[view->activeGraph], subg);
+ return 0;
}
+ } else {
+ agdelsubg(view->g[view->activeGraph], subg);
+ return 0;
+ }
}
data_attr1 = agget(view->g[view->activeGraph], "DataAttribute1");
data_attr2 = agget(view->g[view->activeGraph], "DataAttribute2");
- for (i = 0; i < TV_Nodes.recordperpage; i++)
- {
- index = TV_Nodes.TV_Node[i].index;
- if (index < view->Topview->Nodecount)
- {
- // apply if selected
- if (gtk_toggle_button_get_active((GtkToggleButton *) TV_Nodes.TV_Node[i].chkSelected))
- {
- if (!view->Topview->Nodes[index].data.Selected)
- select_node(&view->Topview->Nodes[index]);
- }
- else
- {
- if (view->Topview->Nodes[index].data.Selected)
- deselect_node(&view->Topview->Nodes[index]);
- }
- // apply if Visible
- if (gtk_toggle_button_get_active((GtkToggleButton *) TV_Nodes.TV_Node[i].chkVisible))
- {
- if (!view->Topview->Nodes[index].data.Visible)
- view->Topview->Nodes[index].data.Visible = 1;
- }
- else
- {
- if (view->Topview->Nodes[index].data.Visible)
- view->Topview->Nodes[index].data.Visible = 0;
- }
- // apply if Highlighted
- if (gtk_toggle_button_get_active((GtkToggleButton *) TV_Nodes.TV_Node[i].chkHighlighted))
- {
- if (!view->Topview->Nodes[index].data.Highlighted)
- view->Topview->Nodes[index].data.Highlighted = 1;
- }
- else
- {
- if (view->Topview->Nodes[index].data.Highlighted)
- view->Topview->Nodes[index].data.Highlighted = 0;
- }
- agset((void *) view->Topview->Nodes[index].Node, data_attr1,(char *) gtk_entry_get_text(TV_Nodes.TV_Node[i].Data1));
- agset(view->Topview->Nodes[index].Node, data_attr2,(char *) gtk_entry_get_text(TV_Nodes.TV_Node[i].Data2));
-
- }
+ for (i = 0; i < TV_Nodes.recordperpage; i++) {
+ index = TV_Nodes.TV_Node[i].index;
+ if (index < view->Topview->Nodecount) {
+ // apply if selected
+ if (gtk_toggle_button_get_active
+ ((GtkToggleButton *) TV_Nodes.TV_Node[i].chkSelected)) {
+ if (!view->Topview->Nodes[index].data.Selected)
+ select_node(&view->Topview->Nodes[index]);
+ } else {
+ if (view->Topview->Nodes[index].data.Selected)
+ deselect_node(&view->Topview->Nodes[index]);
+ }
+ // apply if Visible
+ if (gtk_toggle_button_get_active
+ ((GtkToggleButton *) TV_Nodes.TV_Node[i].chkVisible)) {
+ if (!view->Topview->Nodes[index].data.Visible)
+ view->Topview->Nodes[index].data.Visible = 1;
+ } else {
+ if (view->Topview->Nodes[index].data.Visible)
+ view->Topview->Nodes[index].data.Visible = 0;
+ }
+ // apply if Highlighted
+ if (gtk_toggle_button_get_active
+ ((GtkToggleButton *) TV_Nodes.TV_Node[i].chkHighlighted)) {
+ if (!view->Topview->Nodes[index].data.Highlighted)
+ view->Topview->Nodes[index].data.Highlighted = 1;
+ } else {
+ if (view->Topview->Nodes[index].data.Highlighted)
+ view->Topview->Nodes[index].data.Highlighted = 0;
+ }
+ agset((void *) view->Topview->Nodes[index].Node, data_attr1,
+ (char *) gtk_entry_get_text(TV_Nodes.TV_Node[i].Data1));
+ agset(view->Topview->Nodes[index].Node, data_attr2,
+ (char *) gtk_entry_get_text(TV_Nodes.TV_Node[i].Data2));
+
+ }
}
return 1;
((GtkToggleButton *) glade_xml_get_widget(xml, "rbTVFilterSel3")))
selected = 0;
- if (gtk_toggle_button_get_active
- ((GtkToggleButton *)
- glade_xml_get_widget(xml, "rbTVFilterVisible1")))
+ if (gtk_toggle_button_get_active((GtkToggleButton *)
+ glade_xml_get_widget(xml,
+ "rbTVFilterVisible1")))
visible = -1;
- if (gtk_toggle_button_get_active
- ((GtkToggleButton *)
- glade_xml_get_widget(xml, "rbTVFilterVisible2")))
+ if (gtk_toggle_button_get_active((GtkToggleButton *)
+ glade_xml_get_widget(xml,
+ "rbTVFilterVisible2")))
visible = 1;
- if (gtk_toggle_button_get_active
- ((GtkToggleButton *)
- glade_xml_get_widget(xml, "rbTVFilterVisible3")))
+ if (gtk_toggle_button_get_active((GtkToggleButton *)
+ glade_xml_get_widget(xml,
+ "rbTVFilterVisible3")))
visible = 0;
if (gtk_toggle_button_get_active
if (gtk_toggle_button_get_active
((GtkToggleButton *) glade_xml_get_widget(xml, "rbTVFilterHigh3")))
highlighted = 0;
- set_filter(&TV_Nodes.filter,
- (char *) gtk_entry_get_text((GtkEntry *)
- glade_xml_get_widget(xml,
- "edtTVFilterMinData1")),
+ set_filter(&TV_Nodes.filter, (char *) gtk_entry_get_text((GtkEntry *)
+ glade_xml_get_widget
+ (xml,
+ "edtTVFilterMinData1")),
(char *) gtk_entry_get_text((GtkEntry *)
glade_xml_get_widget(xml,
"edtTVFilterMaxData1")),
}
-static int cache_validate_node(tv_node* tvn)
+static int cache_validate_node(tv_node * tvn)
{
- return view->Topview->Nodes[tvn->index].valid;
+ return view->Topview->Nodes[tvn->index].valid;
}
int tv_select_all(void)
{
tv_node tvn;
int i;
- for (i = 0; i < view->Topview->Nodecount; i++)
- {
- tvn.index = i;
- if (cache_validate_node(&tvn))
- {
- view->Topview->Nodes[i].data.Highlighted = 1;
- }
+ for (i = 0; i < view->Topview->Nodecount; i++) {
+ tvn.index = i;
+ if (cache_validate_node(&tvn)) {
+ view->Topview->Nodes[i].data.Highlighted = 1;
+ }
}
apply_filter_from_gui();
return 1;
for (i = 0; i < view->Topview->Nodecount; i++) {
tvn.index = i;
if (cache_validate_node(&tvn)) {
- view->Topview->Nodes[i].data.Highlighted = 0;
+ view->Topview->Nodes[i].data.Highlighted = 0;
}
}
apply_filter_from_gui();
for (i = 0; i < view->Topview->Nodecount; i++) {
tvn.index = i;
if (cache_validate_node(&tvn)) {
- view->Topview->Nodes[i].data.Visible = 1;
+ view->Topview->Nodes[i].data.Visible = 1;
}
}
apply_filter_from_gui();
for (i = 0; i < view->Topview->Nodecount; i++) {
tvn.index = i;
if (cache_validate_node(&tvn)) {
- view->Topview->Nodes[i].data.Visible = 0;
+ view->Topview->Nodes[i].data.Visible = 0;
}
}
apply_filter_from_gui();
}
int tv_save_as(void)
{
- GtkWidget *dialog;
- dialog = gtk_file_chooser_dialog_new("Save File",
- NULL,
- GTK_FILE_CHOOSER_ACTION_SAVE,
- GTK_STOCK_CANCEL,
- GTK_RESPONSE_CANCEL,
- GTK_STOCK_SAVE,
- GTK_RESPONSE_ACCEPT, NULL);
- gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER
- (dialog), TRUE);
- if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) {
- char *filename;
- filename =
- gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
-
- create_save_subgraph_from_filter(filename);
- g_free(filename);
- gtk_widget_destroy(dialog);
-
- return 1;
- } else {
- gtk_widget_destroy(dialog);
- return 0;
- }
+ GtkWidget *dialog;
+ dialog = gtk_file_chooser_dialog_new("Save File",
+ NULL,
+ GTK_FILE_CHOOSER_ACTION_SAVE,
+ GTK_STOCK_CANCEL,
+ GTK_RESPONSE_CANCEL,
+ GTK_STOCK_SAVE,
+ GTK_RESPONSE_ACCEPT, NULL);
+ gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER
+ (dialog), TRUE);
+ if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) {
+ char *filename;
+ filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
+
+ create_save_subgraph_from_filter(filename);
+ g_free(filename);
+ gtk_widget_destroy(dialog);
+
+ return 1;
+ } else {
+ gtk_widget_destroy(dialog);
return 0;
+ }
+ return 0;
}
#define LOCATION_X_DATA1 356
#define LOCATION_X_DATA2 561
-typedef struct token_info {
- int op_index; // has to
- int op1_length;
- int op2_length;
-
-} token_info;
-
-typedef struct btree_node {
- int child_count;
- struct btree_node **childs;
- struct btree_node *parent;
- int rank; //0 root
- char op; // & | + - whatever
- int node_type; //0 and 1 or 2 atom
- char *attr_name;
- char *regex;
- float min;
- float max;
- int value; //filter result true false, 0 , 1
- int active;
-} btree_node;
-
-typedef struct _tv_filter {
- btree_node *root;
- char *min_data1;
- char *min_data2;
- char *max_data1;
- char *max_data2;
- char *filter_string;
- int active;
- int visible; //-1 all 0 not not visible 1 only visibles
- int highlighted; //same above
- int selected; //same above
-} tv_filter;
-
-typedef struct _tv_node {
- int index;
- GtkCheckButton *chkSelected;
- GtkCheckButton *chkVisible;
- GtkCheckButton *chkHighlighted;
- GtkLabel *IDLabel;
- GtkEntry *Name;
- GtkEntry *Data1;
- GtkEntry *Data2;
- int valid;
-} tv_node;
-
-
-typedef struct _tv_nodes {
- int pagecount;
- int activepage;
- int firstnodeid;
- int *page_history;
- int page_history_count;
- int recordperpage; //dynamic so that can be changed by plugins etc
- int filtered;
- int page_data_index;
- int page_data_node_index;
- tv_node TV_Node[MAX_NODE_PER_PAGE];
- tv_filter filter;
- int Y;
- int Y_Gap;
- int initial_Y;
- int chkSelected_X;
- int IDLabel_X;
- int chkVisible_X;
- int chkHighlighted_X;
- int Data1_X;
- int Data2_X;
- int initialized;
- int general_purpose_flag; //dont forget to to set it back
-} tv_nodes;
-extern tv_nodes TV_Nodes;
-
-
-
-void execute_tv_nodes(void);
-int set_filter(tv_filter * TV_Filter, char *MinData1,
- char *MaxData1, char *MinData2, char *MaxData2,
- char *Filter_String, int selected, int visible,
- int highlighted);
-int tv_nodes_goto_page(int page);
-int tv_nodes_next_page(void);
-int tv_nodes_prior_page(void);
-int tv_nodes_last_page(void);
-int tv_nodes_first_page(void);
-
-int reset_page_History(void);
-int prepare_page_history(void);
-int create_save_subgraph_from_filter(char* filename);
-int update_TV_data_from_gui(void);
-int apply_filter_from_gui(void);
-int tv_select_all(void);
-int tv_unselect_all(void);
-int tv_highligh_all(void);
-int tv_unhighligh_all(void);
-int tv_show_all(void);
-int tv_hide_all(void);
-int tv_save_as(void);
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ typedef struct token_info {
+ int op_index; // has to
+ int op1_length;
+ int op2_length;
+
+ } token_info;
+
+ typedef struct btree_node {
+ int child_count;
+ struct btree_node **childs;
+ struct btree_node *parent;
+ int rank; //0 root
+ char op; // & | + - whatever
+ int node_type; //0 and 1 or 2 atom
+ char *attr_name;
+ char *regex;
+ float min;
+ float max;
+ int value; //filter result true false, 0 , 1
+ int active;
+ } btree_node;
+
+ typedef struct _tv_filter {
+ btree_node *root;
+ char *min_data1;
+ char *min_data2;
+ char *max_data1;
+ char *max_data2;
+ char *filter_string;
+ int active;
+ int visible; //-1 all 0 not not visible 1 only visibles
+ int highlighted; //same above
+ int selected; //same above
+ } tv_filter;
+
+ typedef struct _tv_node {
+ int index;
+ GtkCheckButton *chkSelected;
+ GtkCheckButton *chkVisible;
+ GtkCheckButton *chkHighlighted;
+ GtkLabel *IDLabel;
+ GtkEntry *Name;
+ GtkEntry *Data1;
+ GtkEntry *Data2;
+ int valid;
+ } tv_node;
+
+
+ typedef struct _tv_nodes {
+ int pagecount;
+ int activepage;
+ int firstnodeid;
+ int *page_history;
+ int page_history_count;
+ int recordperpage; //dynamic so that can be changed by plugins etc
+ int filtered;
+ int page_data_index;
+ int page_data_node_index;
+ tv_node TV_Node[MAX_NODE_PER_PAGE];
+ tv_filter filter;
+ int Y;
+ int Y_Gap;
+ int initial_Y;
+ int chkSelected_X;
+ int IDLabel_X;
+ int chkVisible_X;
+ int chkHighlighted_X;
+ int Data1_X;
+ int Data2_X;
+ int initialized;
+ int general_purpose_flag; //dont forget to to set it back
+ } tv_nodes;
+ extern tv_nodes TV_Nodes;
+
+
+
+ void execute_tv_nodes(void);
+ int set_filter(tv_filter * TV_Filter, char *MinData1,
+ char *MaxData1, char *MinData2, char *MaxData2,
+ char *Filter_String, int selected, int visible,
+ int highlighted);
+ int tv_nodes_goto_page(int page);
+ int tv_nodes_next_page(void);
+ int tv_nodes_prior_page(void);
+ int tv_nodes_last_page(void);
+ int tv_nodes_first_page(void);
+
+ int reset_page_History(void);
+ int prepare_page_history(void);
+ int create_save_subgraph_from_filter(char *filename);
+ int update_TV_data_from_gui(void);
+ int apply_filter_from_gui(void);
+ int tv_select_all(void);
+ int tv_unselect_all(void);
+ int tv_highligh_all(void);
+ int tv_unhighligh_all(void);
+ int tv_show_all(void);
+ int tv_hide_all(void);
+ int tv_save_as(void);
+
+#ifdef __cplusplus
+} /* end extern "C" */
+#endif
#endif
#include "memory.h"
#include "topviewsettings.h"
#include "md5.h"
+#include "arcball.h"
/* Forward declarations */
#ifdef UNUSED
static int init_object_custom_data(Agraph_t * graph, void *obj);
-static void refresh_borders(Agraph_t* g);
+static void refresh_borders(Agraph_t * g);
#endif
#define countof( array ) ( sizeof( array )/sizeof( array[0] ) )
return atoi(p);
}
static Dtdisc_t qDisc = {
- offsetof(xdot,ops),
- sizeof(xdot_op*),
+ offsetof(xdot, ops),
+ sizeof(xdot_op *),
-1,
NIL(Dtmake_f),
NIL(Dtfree_f),
void clear_viewport(ViewInfo * view)
{
/*free topview if there is one */
- if (view->activeGraph >= 0)
- cleartopview(view->Topview);
- if (view->graphCount)
- agclose(view->g[view->activeGraph]);
-// init_viewport(view);
+ if (view->activeGraph >= 0)
+ cleartopview(view->Topview);
+ if (view->graphCount)
+ agclose(view->g[view->activeGraph]);
+// init_viewport(view);
}
-static void* get_glut_font(int ind)
+static void *get_glut_font(int ind)
{
- switch (ind)
- {
- case 0:
- return GLUT_BITMAP_9_BY_15;
- break;
- case 1:
- return GLUT_BITMAP_8_BY_13;
- break;
- case 2:
- return GLUT_BITMAP_TIMES_ROMAN_10;
- break;
- case 3:
- return GLUT_BITMAP_HELVETICA_10;
- break;
- case 4:
- return GLUT_BITMAP_HELVETICA_12;
- break;
- case 5:
- return GLUT_BITMAP_HELVETICA_18;
- break;
- default:
- return GLUT_BITMAP_TIMES_ROMAN_10;
- }
+ switch (ind) {
+ case 0:
+ return GLUT_BITMAP_9_BY_15;
+ break;
+ case 1:
+ return GLUT_BITMAP_8_BY_13;
+ break;
+ case 2:
+ return GLUT_BITMAP_TIMES_ROMAN_10;
+ break;
+ case 3:
+ return GLUT_BITMAP_HELVETICA_10;
+ break;
+ case 4:
+ return GLUT_BITMAP_HELVETICA_12;
+ break;
+ case 5:
+ return GLUT_BITMAP_HELVETICA_18;
+ break;
+ default:
+ return GLUT_BITMAP_TIMES_ROMAN_10;
+ }
}
-void fill_key(md5_byte_t* b,md5_byte_t* data)
+void fill_key(md5_byte_t * b, md5_byte_t * data)
{
- int ind=0;
- for (ind=0;ind < 16;ind ++)
- {
- b[ind]=data[ind];
- }
+ int ind = 0;
+ for (ind = 0; ind < 16; ind++) {
+ b[ind] = data[ind];
+ }
}
-static int compare_keys(md5_byte_t* b1,md5_byte_t* b2)
+static int compare_keys(md5_byte_t * b1, md5_byte_t * b2)
{
- /*1 keys are equal*/
- /*0 not equal*/
-
- int ind=0;
- int eq=1;
- for (ind=0;ind < 16;ind ++)
- {
- if (b1[ind] != b2[ind])
- {
- eq=0;
- }
+ /*1 keys are equal */
+ /*0 not equal */
+
+ int ind = 0;
+ int eq = 1;
+ for (ind = 0; ind < 16; ind++) {
+ if (b1[ind] != b2[ind]) {
+ eq = 0;
}
- return eq;
+ }
+ return eq;
}
-int close_graph(ViewInfo * view,int graphid)
+int close_graph(ViewInfo * view, int graphid)
{
- if (view->activeGraph < 0)
- return 1;
- fill_key(view->final_key,get_md5_key(view->g[graphid]));
- if (!compare_keys(view->final_key,view->orig_key))
- view->Topview->Graphdata.Modified=1;
- if (view->Topview->Graphdata.Modified)
- {
- switch (show_close_nosavedlg())
- {
- case 0: /*save and close*/
- save_graph();
- clear_viewport(view);
- return 1;
- break;
- case 1:/*dont save but close*/
- clear_viewport(view);
- return 1;
- break;
- case 2:/*cancel do nothing*/
- return 0;
- break;
- default:
- break;
- }
- }
- clear_viewport(view);
+ if (view->activeGraph < 0)
return 1;
+ fill_key(view->final_key, get_md5_key(view->g[graphid]));
+ if (!compare_keys(view->final_key, view->orig_key))
+ view->Topview->Graphdata.Modified = 1;
+ if (view->Topview->Graphdata.Modified) {
+ switch (show_close_nosavedlg()) {
+ case 0: /*save and close */
+ save_graph();
+ clear_viewport(view);
+ return 1;
+ break;
+ case 1: /*dont save but close */
+ clear_viewport(view);
+ return 1;
+ break;
+ case 2: /*cancel do nothing */
+ return 0;
+ break;
+ default:
+ break;
+ }
+ }
+ clear_viewport(view);
+ return 1;
}
return buf;
}
-void
-set_viewport_settings_from_template(ViewInfo * view, Agraph_t * g)
+void set_viewport_settings_from_template(ViewInfo * view, Agraph_t * g)
{
gvcolor_t cl;
char *buf;
- colorxlate(get_attribute_value("bordercolor", view, g), &cl,
- RGBA_DOUBLE);
+ colorxlate(get_attribute_value("bordercolor", view, g), &cl,
+ RGBA_DOUBLE);
view->borderColor.R = (float) cl.u.RGBA[0];
view->borderColor.G = (float) cl.u.RGBA[1];
view->borderColor.B = (float) cl.u.RGBA[2];
view->borderColor.A =
(float) atof(get_attribute_value("bordercoloralpha", view, g));
- view->bdVisible =
- atoi(get_attribute_value("bordervisible", view, g));
+ view->bdVisible = atoi(get_attribute_value("bordervisible", view, g));
buf = get_attribute_value("gridcolor", view, g);
colorxlate(buf, &cl, RGBA_DOUBLE);
get_attribute_value("gridsize", view,
g));
- view->defaultnodeshape=atoi(buf=get_attribute_value("defaultnodeshape", view,g));
- /* view->Selection.PickingType=atoi(buf=get_attribute_value("defaultselectionmethod", view,g)); */
+ view->defaultnodeshape = atoi(buf =
+ get_attribute_value("defaultnodeshape",
+ view, g));
+ /* view->Selection.PickingType=atoi(buf=get_attribute_value("defaultselectionmethod", view,g)); */
-
- view->gridVisible = atoi(get_attribute_value("gridvisible", view, g));
+
+ view->gridVisible = atoi(get_attribute_value("gridvisible", view, g));
//mouse mode=pan
view->bgColor.R = (float) cl.u.RGBA[0];
view->bgColor.G = (float) cl.u.RGBA[1];
view->bgColor.B = (float) cl.u.RGBA[2];
- view->bgColor.A = (float)1;
+ view->bgColor.A = (float) 1;
//selected nodes are drawn with this color
colorxlate(get_attribute_value("selectednodecolor", view, g), &cl,
view->selectedNodeColor.R = (float) cl.u.RGBA[0];
view->selectedNodeColor.G = (float) cl.u.RGBA[1];
view->selectedNodeColor.B = (float) cl.u.RGBA[2];
- view->selectedNodeColor.A =
- (float)
+ view->selectedNodeColor.A = (float)
atof(get_attribute_value("selectednodecoloralpha", view, g));
//selected edge are drawn with this color
colorxlate(get_attribute_value("selectededgecolor", view, g), &cl,
view->selectedEdgeColor.R = (float) cl.u.RGBA[0];
view->selectedEdgeColor.G = (float) cl.u.RGBA[1];
view->selectedEdgeColor.B = (float) cl.u.RGBA[2];
- view->selectedEdgeColor.A =
- (float)
+ view->selectedEdgeColor.A = (float)
atof(get_attribute_value("selectededgecoloralpha", view, g));
colorxlate(get_attribute_value("highlightednodecolor", view, g), &cl,
view->highlightedNodeColor.R = (float) cl.u.RGBA[0];
view->highlightedNodeColor.G = (float) cl.u.RGBA[1];
view->highlightedNodeColor.B = (float) cl.u.RGBA[2];
- view->highlightedNodeColor.A =
- (float)
+ view->highlightedNodeColor.A = (float)
atof(get_attribute_value("highlightednodecoloralpha", view, g));
buf = agget(g, "highlightededgecolor");
view->highlightedEdgeColor.R = (float) cl.u.RGBA[0];
view->highlightedEdgeColor.G = (float) cl.u.RGBA[1];
view->highlightedEdgeColor.B = (float) cl.u.RGBA[2];
- view->highlightedEdgeColor.A =
- (float)
+ view->highlightedEdgeColor.A = (float)
atof(get_attribute_value("highlightededgecoloralpha", view, g));
- view->defaultnodealpha =
- (float)
+ view->defaultnodealpha = (float)
atof(get_attribute_value("defaultnodealpha", view, g));
- view->defaultedgealpha =
- (float)
+ view->defaultedgealpha = (float)
atof(get_attribute_value("defaultedgealpha", view, g));
/*default line width */
view->LineWidth =
(float) atof(get_attribute_value("defaultlinewidth", view, g));
- view->FontSize = (float)atof(get_attribute_value("defaultfontsize", view, g));
+ view->FontSize =
+ (float) atof(get_attribute_value("defaultfontsize", view, g));
view->topviewusermode = atoi(get_attribute_value("usermode", view, g));
get_attribute_value("defaultmagnifierwidth", view, g);
view->fmg.fisheye_distortion_fac =
atoi(get_attribute_value
("defaultfisheyemagnifierdistort", view, g));
- view->drawnodes=
- atoi(get_attribute_value ("drawnodes", view, g));
- view->drawedges=
- atoi(get_attribute_value ("drawedges", view, g));
- view->drawlabels=atoi(get_attribute_value ("drawlabels", view, g));
- view->FontSizeConst=0; //this will be calculated later in topview.c while calculating optimum font size
-
- view->glutfont=get_glut_font(atoi(get_attribute_value ("labelglutfont", view, g)));
- colorxlate(get_attribute_value("nodelabelcolor", view, g), &cl,RGBA_DOUBLE);
- view->nodelabelcolor.R=(float)cl.u.RGBA[0];
- view->nodelabelcolor.G=(float) cl.u.RGBA[1];
- view->nodelabelcolor.B=(float) cl.u.RGBA[2];
- view->nodelabelcolor.A= (float)atof(get_attribute_value("defaultnodealpha", view, g));
- colorxlate(get_attribute_value("edgelabelcolor", view, g), &cl,RGBA_DOUBLE);
- view->edgelabelcolor.R=(float) cl.u.RGBA[0];
- view->edgelabelcolor.G=(float) cl.u.RGBA[1];
- view->edgelabelcolor.B=(float) cl.u.RGBA[2];
- view->edgelabelcolor.A= (float)atof(get_attribute_value("defaultedgealpha", view, g));
- view->labelwithdegree=atoi(get_attribute_value ("labelwithdegree", view, g));
- view->labelnumberofnodes=atof(get_attribute_value ("labelnumberofnodes", view, g));
- view->labelshownodes=atoi(get_attribute_value ("shownodelabels", view, g));
- view->labelshowedges=atoi(get_attribute_value ("showedgelabels", view, g));
- view->colschms=create_color_theme(atoi(get_attribute_value ("colortheme", view, g)));
-
-
- if (view->graphCount > 0)
- glClearColor(view->bgColor.R, view->bgColor.G, view->bgColor.B, view->bgColor.A); //background color
+ view->drawnodes = atoi(get_attribute_value("drawnodes", view, g));
+ view->drawedges = atoi(get_attribute_value("drawedges", view, g));
+ view->drawlabels = atoi(get_attribute_value("drawlabels", view, g));
+ view->FontSizeConst = 0; //this will be calculated later in topview.c while calculating optimum font size
+
+ view->glutfont =
+ get_glut_font(atoi(get_attribute_value("labelglutfont", view, g)));
+ colorxlate(get_attribute_value("nodelabelcolor", view, g), &cl,
+ RGBA_DOUBLE);
+ view->nodelabelcolor.R = (float) cl.u.RGBA[0];
+ view->nodelabelcolor.G = (float) cl.u.RGBA[1];
+ view->nodelabelcolor.B = (float) cl.u.RGBA[2];
+ view->nodelabelcolor.A =
+ (float) atof(get_attribute_value("defaultnodealpha", view, g));
+ colorxlate(get_attribute_value("edgelabelcolor", view, g), &cl,
+ RGBA_DOUBLE);
+ view->edgelabelcolor.R = (float) cl.u.RGBA[0];
+ view->edgelabelcolor.G = (float) cl.u.RGBA[1];
+ view->edgelabelcolor.B = (float) cl.u.RGBA[2];
+ view->edgelabelcolor.A =
+ (float) atof(get_attribute_value("defaultedgealpha", view, g));
+ view->labelwithdegree =
+ atoi(get_attribute_value("labelwithdegree", view, g));
+ view->labelnumberofnodes =
+ atof(get_attribute_value("labelnumberofnodes", view, g));
+ view->labelshownodes =
+ atoi(get_attribute_value("shownodelabels", view, g));
+ view->labelshowedges =
+ atoi(get_attribute_value("showedgelabels", view, g));
+ view->colschms =
+ create_color_theme(atoi
+ (get_attribute_value("colortheme", view, g)));
+
+
+ if (view->graphCount > 0)
+ glClearColor(view->bgColor.R, view->bgColor.G, view->bgColor.B, view->bgColor.A); //background color
}
-static gboolean gl_main_expose(gpointer data) {
- if (view->activeGraph >= 0)
- {
- if(view->Topview->animate==1)
- expose_event(view->drawing_area, NULL, NULL);
- return 1;
- }
+static gboolean gl_main_expose(gpointer data)
+{
+ if (view->activeGraph >= 0) {
+ if (view->Topview->animate == 1)
+ expose_event(view->drawing_area, NULL, NULL);
return 1;
+ }
+ return 1;
}
-static void
-get_data_dir()
+static void get_data_dir()
{
if (view->template_file) {
free(view->template_file);
free(view->attr_file);
}
- view->template_file = strdup(smyrnaPath ("template.dot"));
- view->glade_file = strdup(smyrnaPath ("smyrna.glade"));
- view->attr_file = strdup(smyrnaPath ("attrs.txt"));
+ view->template_file = strdup(smyrnaPath("template.dot"));
+ view->glade_file = strdup(smyrnaPath("smyrna.glade"));
+ view->attr_file = strdup(smyrnaPath("attrs.txt"));
}
void init_viewport(ViewInfo * view)
{
- FILE *input_file=NULL;
+ FILE *input_file = NULL;
get_data_dir();
input_file = fopen(view->template_file, "rb");
- if (!input_file) {
- fprintf (stderr, "default attributes template graph file \"%s\" not found\n", view->template_file);
- exit(-1);
- } else if (!(view->default_attributes = agread(input_file, 0)))
- {
- fprintf (stderr, "could not load default attributes template graph file \"%s\"\n", view->template_file);
- exit(-1);
+ if (!input_file) {
+ fprintf(stderr,
+ "default attributes template graph file \"%s\" not found\n",
+ view->template_file);
+ exit(-1);
+ } else if (!(view->default_attributes = agread(input_file, 0))) {
+ fprintf(stderr,
+ "could not load default attributes template graph file \"%s\"\n",
+ view->template_file);
+ exit(-1);
}
-
- //init graphs
+ //init graphs
view->g = NULL; //no graph, gl screen should check it
view->graphCount = 0; //and disable interactivity if count is zero
- view->bdxLeft = 0;
+ view->bdxLeft = 0;
view->bdxRight = 500;
view->bdyBottom = 0;
view->bdyTop = 500;
view->fmg.constantR = DEFAULT_FISHEYE_MAGNIFIER_RADIUS;
view->fmg.active = 0;
view->mouse.mouse_down = 0;
- view->mouse.pick=0;
+ view->mouse.pick = 0;
view->activeGraph = -1;
view->SignalBlock = 0;
view->Selection.Active = 0;
view->Selection.Anti = 0;
view->Topview = GNEW(topview);
view->Topview->fs = 0;
- view->Topview->xdot_list=NULL;
+ view->Topview->xdot_list = NULL;
/* init topfish parameters */
view->Topview->parms.level.num_fine_nodes = 10;
view->Topview->parms.hier.dist2_limit = 1;
view->Topview->parms.hier.min_nvtxs = 20;
view->Topview->parms.repos.rescale = Polar;
- view->Topview->parms.repos.width =(int) (view->bdxRight-view->bdxLeft);
- view->Topview->parms.repos.height =(int) (view->bdyTop-view->bdyBottom);
+ view->Topview->parms.repos.width =
+ (int) (view->bdxRight - view->bdxLeft);
+ view->Topview->parms.repos.height =
+ (int) (view->bdyTop - view->bdyBottom);
view->Topview->parms.repos.margin = 0;
view->Topview->parms.repos.graphSize = 100;
view->Topview->parms.repos.distortion = 1.0;
- /*create timer*/
- view->timer=g_timer_new();
- view->timer2=g_timer_new();
-
- g_timer_stop(view->timer);
- view->active_frame=0;
- view->total_frames=1500;
- view->frame_length=1;
- /*add a call back to the main()*/
- g_timeout_add_full((gint)G_PRIORITY_DEFAULT,(guint)100,gl_main_expose,NULL,NULL);
- view->cameras='\0';;
- view->camera_count=0;
- view->active_camera=-1;
+ /*create timer */
+ view->timer = g_timer_new();
+ view->timer2 = g_timer_new();
+
+ g_timer_stop(view->timer);
+ view->active_frame = 0;
+ view->total_frames = 1500;
+ view->frame_length = 1;
+ /*add a call back to the main() */
+ g_timeout_add_full((gint) G_PRIORITY_DEFAULT, (guint) 100,
+ gl_main_expose, NULL, NULL);
+ view->cameras = '\0';;
+ view->camera_count = 0;
+ view->active_camera = -1;
set_viewport_settings_from_template(view, view->default_attributes);
view->dfltViewType = VT_NONE;
view->dfltEngine = GVK_NONE;
- view->Topview->Graphdata.GraphFileName = (char*)0;
- view->Topview->Graphdata.Modified=0;
- view->colschms=NULL;
- view->flush=1;
- view->arcball=NEW(ArcBall_t);
- /*add default camera*/
- //create fontset
+ view->Topview->Graphdata.GraphFileName = (char *) 0;
+ view->Topview->Graphdata.Modified = 0;
+ view->colschms = NULL;
+ view->flush = 1;
+ view->arcball = NEW(ArcBall_t);
+ /*add default camera */
+ //create fontset
}
*/
static void update_graph_params(Agraph_t * graph)
{
- agattr(graph, AGRAPH, "GraphFileName",view->Topview->Graphdata.GraphFileName);
+ agattr(graph, AGRAPH, "GraphFileName",
+ view->Topview->Graphdata.GraphFileName);
}
#ifdef UNUSED
/* clear_object_xdot:
* clear single object's xdot info
- */
+ */
static int clear_object_xdot(void *obj)
{
if (obj) {
{
Agraph_t *g;
FILE *input_file;
- /* char* bf; */
- /* char buf[512]; */
- if (!(input_file = fopen(filename, "r")))
- {
- g_print("Cannot open %s\n", filename);
- return 0;
+ /* char* bf; */
+ /* char buf[512]; */
+ if (!(input_file = fopen(filename, "r"))) {
+ g_print("Cannot open %s\n", filename);
+ return 0;
}
- if (!(g = agread(input_file, NIL(Agdisc_t *))))
- {
- g_print("Cannot read graph in %s\n", filename);
- fclose (input_file);
- return 0;
+ if (!(g = agread(input_file, NIL(Agdisc_t *)))) {
+ g_print("Cannot read graph in %s\n", filename);
+ fclose(input_file);
+ return 0;
}
- /* If no position info, run layout with -Txdot
- */
- if (!agattr(g, AGNODE, "pos", NULL))
- {
- g_print("There is no position info in %s\n", filename);
- fclose (input_file);
- return 0;
+ /* If no position info, run layout with -Txdot
+ */
+ if (!agattr(g, AGNODE, "pos", NULL)) {
+ g_print("There is no position info in %s\n", filename);
+ fclose(input_file);
+ return 0;
}
- free (view->Topview->Graphdata.GraphFileName);
- view->Topview->Graphdata.GraphFileName = strdup (filename);
+ free(view->Topview->Graphdata.GraphFileName);
+ view->Topview->Graphdata.GraphFileName = strdup(filename);
return g;
}
+
#ifdef UNUSED
-static void refresh_borders(Agraph_t* g)
+static void refresh_borders(Agraph_t * g)
{
- sscanf(agget(g,"bb"),"%f,%f,%f,%f",&(view->bdxLeft),&(view->bdyBottom),&(view->bdxRight),&(view->bdyTop));
+ sscanf(agget(g, "bb"), "%f,%f,%f,%f", &(view->bdxLeft),
+ &(view->bdyBottom), &(view->bdxRight), &(view->bdyTop));
}
#endif
{
Agraph_t *graph = loadGraph(fileName);
- return add_graph_to_viewport (graph, fileName);
+ return add_graph_to_viewport(graph, fileName);
}
-void
-refreshViewport (int doClear)
+void refreshViewport(int doClear)
{
- Agraph_t* graph = view->g[view->activeGraph];
+ Agraph_t *graph = view->g[view->activeGraph];
load_settings_from_graph(graph);
update_graph_from_settings(graph);
set_viewport_settings_from_template(view, graph);
if (doClear)
cleartopview(view->Topview);
-
- update_topview(graph, view->Topview,1);
- fill_key(view->orig_key,get_md5_key(graph));
+
+ update_topview(graph, view->Topview, 1);
+ fill_key(view->orig_key, get_md5_key(graph));
expose_event(view->drawing_area, NULL, NULL);
}
-static void
-activate (int id, int doClear)
+static void activate(int id, int doClear)
{
view->activeGraph = id;
- refreshViewport (doClear);
+ refreshViewport(doClear);
}
-int add_graph_to_viewport(Agraph_t* graph, char* id)
+int add_graph_to_viewport(Agraph_t * graph, char *id)
{
if (graph) {
view->graphCount = view->graphCount + 1;
- view->g =(Agraph_t **) realloc(view->g,sizeof(Agraph_t *) * view->graphCount);
+ view->g =
+ (Agraph_t **) realloc(view->g,
+ sizeof(Agraph_t *) * view->graphCount);
view->g[view->graphCount - 1] = graph;
- gtk_combo_box_append_text(view->graphComboBox,id);
+ gtk_combo_box_append_text(view->graphComboBox, id);
- activate (view->graphCount - 1,0);
+ activate(view->graphCount - 1, 0);
return 1;
- }
- else {
+ } else {
return 0;
}
void switch_graph(int graphId)
{
if (graphId >= view->graphCount)
- return;/*wrong entry*/
+ return; /*wrong entry */
else
- activate (graphId, 0);
+ activate(graphId, 0);
}
#ifdef UNUSED
int append_to_md5(void *chan, const char *str)
{
- md5_append(&pms,(unsigned char*)str,(int)strlen(str));
- return 1;
+ md5_append(&pms, (unsigned char *) str, (int) strlen(str));
+ return 1;
}
-int flush_md5 (void *chan)
+int flush_md5(void *chan)
{
- md5_finish(&pms,md5_digest);
- return 1;
+ md5_finish(&pms, md5_digest);
+ return 1;
}
-md5_byte_t* get_md5_key(Agraph_t* graph)
+md5_byte_t *get_md5_key(Agraph_t * graph)
{
- Agiodisc_t* xio;
- Agiodisc_t a;
- xio=graph->clos->disc.io;
- a.afread=graph->clos->disc.io->afread;
- a.putstr=append_to_md5;
- a.flush=flush_md5;
- graph->clos->disc.io=&a;
- md5_init(&pms);
- agwrite(graph,NULL);
- graph->clos->disc.io=xio;
- return md5_digest;
+ Agiodisc_t *xio;
+ Agiodisc_t a;
+ xio = graph->clos->disc.io;
+ a.afread = graph->clos->disc.io->afread;
+ a.putstr = append_to_md5;
+ a.flush = flush_md5;
+ graph->clos->disc.io = &a;
+ md5_init(&pms);
+ agwrite(graph, NULL);
+ graph->clos->disc.io = xio;
+ return md5_digest;
}
/* save_graph_with_file_name:
*/
int save_graph_with_file_name(Agraph_t * graph, char *fileName)
{
-
- FILE *output_file;
+
+ FILE *output_file;
update_graph_params(graph);
if (fileName)
output_file = fopen(fileName, "w");
if (output_file == NULL) {
g_print("Cannot create file \n");
return 0;
- }
+ }
if (agwrite(graph, (void *) output_file)) {
g_print("%s successfully saved \n", fileName);
if (view->activeGraph > -1) {
//check if active graph has a file name
if (view->Topview->Graphdata.GraphFileName) {
- return save_graph_with_file_name(
- view->g[view->activeGraph],
- view->Topview->Graphdata.GraphFileName);
+ return save_graph_with_file_name(view->g[view->activeGraph],
+ view->Topview->Graphdata.
+ GraphFileName);
} else
return save_as_graph();
}
- fill_key(view->orig_key,get_md5_key(view->g[view->activeGraph]));
+ fill_key(view->orig_key, get_md5_key(view->g[view->activeGraph]));
return 1;
}
*/
/* move_node:
- */
+ */
void movenode(void *obj, float dx, float dy)
{
char buf[512];
double x, y;
- Agsym_t* pos;
+ Agsym_t *pos;
- if ((AGTYPE(obj) == AGNODE) && (pos = agattrsym (obj, "pos"))) {
- sscanf (agxget (obj, pos), "%lf,%lf", &x, &y);
- sprintf (buf, "%lf,%lf", x - dx, y - dy);
+ if ((AGTYPE(obj) == AGNODE) && (pos = agattrsym(obj, "pos"))) {
+ sscanf(agxget(obj, pos), "%lf,%lf", &x, &y);
+ sprintf(buf, "%lf,%lf", x - dx, y - dy);
agxset(obj, pos, buf);
- }
+ }
}
#ifdef UNUSED
}
}
#endif
-int setGdkColor(GdkColor * c, char *color) {
+int setGdkColor(GdkColor * c, char *color)
+{
gvcolor_t cl;
if (color != '\0') {
colorxlate(color, &cl, RGBA_DOUBLE);
}
-void glexpose(void) {
+void glexpose(void)
+{
expose_event(view->drawing_area, NULL, NULL);
}
gtk_widget_hide(glade_xml_get_widget(xml, "frmWait"));
gtk_widget_show(glade_xml_get_widget(xml, "frmWait"));
gtk_window_set_keep_above((GtkWindow *)
- glade_xml_get_widget(xml,
- "frmWait"), 1);
+ glade_xml_get_widget(xml, "frmWait"), 1);
}
void please_dont_wait(void)
gtk_widget_hide(glade_xml_get_widget(xml, "frmWait"));
}
-float interpol(float minv,float maxv,float minc,float maxc,float x)
+float interpol(float minv, float maxv, float minc, float maxc, float x)
{
- return ((x-minv)*(maxc-minc)/(maxv-minv)+minc);
+ return ((x - minv) * (maxc - minc) / (maxv - minv) + minc);
}
-void getcolorfromschema(colorschemaset* sc,float l,float maxl,RGBColor* c)
+void getcolorfromschema(colorschemaset * sc, float l, float maxl,
+ RGBColor * c)
{
- int ind;
- /* float cuml=0.00; */
- float percl=l/maxl*100.00;
- for (ind=0;ind < sc->schemacount;ind ++)
- {
- if (percl < sc->s[ind].perc)
- break;
- }
+ int ind;
+ /* float cuml=0.00; */
+ float percl = l / maxl * 100.00;
+ for (ind = 0; ind < sc->schemacount; ind++) {
+ if (percl < sc->s[ind].perc)
+ break;
+ }
- if (sc->s[ind].smooth)
- {
- c->R=interpol(sc->s[ind-1].perc,sc->s[ind].perc,sc->s[ind-1].c.R,sc->s[ind].c.R,percl);
- c->G=interpol(sc->s[ind-1].perc,sc->s[ind].perc,sc->s[ind-1].c.G,sc->s[ind].c.G,percl);
- c->B=interpol(sc->s[ind-1].perc,sc->s[ind].perc,sc->s[ind-1].c.B,sc->s[ind].c.B,percl);
- c->A=1;
- }
- else
- {
- c->R=sc->s[ind].c.R;
- c->G=sc->s[ind].c.G;
- c->B=sc->s[ind].c.B;
- c->A=1;
- }
+ if (sc->s[ind].smooth) {
+ c->R =
+ interpol(sc->s[ind - 1].perc, sc->s[ind].perc,
+ sc->s[ind - 1].c.R, sc->s[ind].c.R, percl);
+ c->G =
+ interpol(sc->s[ind - 1].perc, sc->s[ind].perc,
+ sc->s[ind - 1].c.G, sc->s[ind].c.G, percl);
+ c->B =
+ interpol(sc->s[ind - 1].perc, sc->s[ind].perc,
+ sc->s[ind - 1].c.B, sc->s[ind].c.B, percl);
+ c->A = 1;
+ } else {
+ c->R = sc->s[ind].c.R;
+ c->G = sc->s[ind].c.G;
+ c->B = sc->s[ind].c.B;
+ c->A = 1;
+ }
}
-static void set_color_theme_color(colorschemaset* sc,char** colorstr,int colorcnt,int smooth)
+static void set_color_theme_color(colorschemaset * sc, char **colorstr,
+ int colorcnt, int smooth)
{
- int ind=0;
+ int ind = 0;
gvcolor_t cl;
- float av_perc;
- av_perc=100.00/(float)(colorcnt-1);
- for (; ind < colorcnt; ind ++)
- {
- colorxlate(colorstr[ind], &cl,RGBA_DOUBLE);
- sc->s[ind].c.R=cl.u.RGBA[0];
- sc->s[ind].c.G=cl.u.RGBA[1];
- sc->s[ind].c.B=cl.u.RGBA[2];
- sc->s[ind].c.A=cl.u.RGBA[3];
- sc->s[ind].perc=ind*av_perc;
- sc->s[ind].smooth=smooth;
- }
+ float av_perc;
+ av_perc = 100.00 / (float) (colorcnt - 1);
+ for (; ind < colorcnt; ind++) {
+ colorxlate(colorstr[ind], &cl, RGBA_DOUBLE);
+ sc->s[ind].c.R = cl.u.RGBA[0];
+ sc->s[ind].c.G = cl.u.RGBA[1];
+ sc->s[ind].c.B = cl.u.RGBA[2];
+ sc->s[ind].c.A = cl.u.RGBA[3];
+ sc->s[ind].perc = ind * av_perc;
+ sc->s[ind].smooth = smooth;
+ }
colorschema* s;
}colorschemaset; */
-void clear_color_theme (colorschemaset* cs)
+void clear_color_theme(colorschemaset * cs)
{
- free(cs->s);
- free(cs);
+ free(cs->s);
+ free(cs);
}
-colorschemaset* create_color_theme(int themeid)
+colorschemaset *create_color_theme(int themeid)
{
- char **colors;
- colorschemaset* s=malloc(sizeof(colorschemaset));
-
- if (view->colschms)
- clear_color_theme (view->colschms);
- s->schemacount=4;
- s->s=malloc(sizeof(colorschema)*4);
-
-
- colors=malloc(sizeof(char*)*4);
-
-
- switch (themeid)
- {
- case 0: //deep blue
-
- colors[0]=strdup("#C8CBED");
- colors[1]=strdup("#9297D3");
- colors[2]=strdup("#blue");
- colors[3]=strdup("#2C2E41");
- set_color_theme_color(s,colors,s->schemacount,1);
- break;
- case 1: //all pastel
- colors[0]=strdup("#EBBE29");
- colors[1]=strdup("#D58C4A");
- colors[2]=strdup("#74AE09");
- colors[3]=strdup("#893C49");
- set_color_theme_color(s,colors,s->schemacount,1);
- break;
- case 2: //magma
- colors[0]=strdup("#E0061E");
- colors[1]=strdup("#F0F143");
- colors[2]=strdup("#95192B");
- colors[3]=strdup("#EB712F");
- set_color_theme_color(s,colors,s->schemacount,1);
- break;
- case 3: //rain forest
- colors[0]=strdup("#1E6A10");
- colors[1]=strdup("#2ABE0E");
- colors[2]=strdup("#AEDD39");
- colors[3]=strdup("#5EE88B");
- set_color_theme_color(s,colors,s->schemacount,1);
- break;
- }
- free (colors[0]);
- free (colors[1]);
- free (colors[2]);
- free (colors[3]);
- free (colors);
- return s;
+ char **colors;
+ colorschemaset *s = malloc(sizeof(colorschemaset));
+
+ if (view->colschms)
+ clear_color_theme(view->colschms);
+ s->schemacount = 4;
+ s->s = malloc(sizeof(colorschema) * 4);
+
+
+ colors = malloc(sizeof(char *) * 4);
+
+
+ switch (themeid) {
+ case 0: //deep blue
+
+ colors[0] = strdup("#C8CBED");
+ colors[1] = strdup("#9297D3");
+ colors[2] = strdup("#blue");
+ colors[3] = strdup("#2C2E41");
+ set_color_theme_color(s, colors, s->schemacount, 1);
+ break;
+ case 1: //all pastel
+ colors[0] = strdup("#EBBE29");
+ colors[1] = strdup("#D58C4A");
+ colors[2] = strdup("#74AE09");
+ colors[3] = strdup("#893C49");
+ set_color_theme_color(s, colors, s->schemacount, 1);
+ break;
+ case 2: //magma
+ colors[0] = strdup("#E0061E");
+ colors[1] = strdup("#F0F143");
+ colors[2] = strdup("#95192B");
+ colors[3] = strdup("#EB712F");
+ set_color_theme_color(s, colors, s->schemacount, 1);
+ break;
+ case 3: //rain forest
+ colors[0] = strdup("#1E6A10");
+ colors[1] = strdup("#2ABE0E");
+ colors[2] = strdup("#AEDD39");
+ colors[3] = strdup("#5EE88B");
+ set_color_theme_color(s, colors, s->schemacount, 1);
+ break;
+ }
+ free(colors[0]);
+ free(colors[1]);
+ free(colors[2]);
+ free(colors[3]);
+ free(colors);
+ return s;
}
void test_color_pallete()
{
- int ind=0;
- float xGAP=5;
- float yGAP=80;
- float x=50;
- float y=50;
- RGBColor c;
- for (ind=0;ind < 350;ind ++)
- {
- getcolorfromschema(view->colschms,ind,350,&c);
- x=ind*xGAP;
- glBegin(GL_POLYGON);
- glColor3f(c.R,c.G,c.B);
- glVertex3f(x,y,0.0);
- glVertex3f(x+xGAP,y,0.0);
- glVertex3f(x+xGAP,y+yGAP,0.0);
- glVertex3f(x,y+yGAP,0.0);
- glEnd();
- }
+ int ind = 0;
+ float xGAP = 5;
+ float yGAP = 80;
+ float x = 50;
+ float y = 50;
+ RGBColor c;
+ for (ind = 0; ind < 350; ind++) {
+ getcolorfromschema(view->colschms, ind, 350, &c);
+ x = ind * xGAP;
+ glBegin(GL_POLYGON);
+ glColor3f(c.R, c.G, c.B);
+ glVertex3f(x, y, 0.0);
+ glVertex3f(x + xGAP, y, 0.0);
+ glVertex3f(x + xGAP, y + yGAP, 0.0);
+ glVertex3f(x, y + yGAP, 0.0);
+ glEnd();
+ }
}
#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 *);
-void clear_viewport(ViewInfo * view);
-void switch_graph(int);
-void refreshViewport (int doClear);
-int add_graph_to_viewport_from_file(char *fileName);
-int add_graph_to_viewport(Agraph_t* graph, char*);
-int close_graph(ViewInfo * view,int graphid);
-int save_graph(void);
-int save_graph_with_file_name(Agraph_t * graph, char *fileName);
-int save_as_graph(void);
-
-int do_graph_layout(Agraph_t * graph, int Engine, int keeppos);
-
-void movenode(void *n, float dx, float dy);
-void glexpose(void);
-void move_nodes(Agraph_t * g);
-void please_wait(void);
-void please_dont_wait(void);
-extern md5_byte_t* get_md5_key(Agraph_t* graph);
-void fill_key(md5_byte_t* b,md5_byte_t* data);
-colorschemaset* create_color_theme(int themeid);
-extern void getcolorfromschema(colorschemaset* sc,float l,float maxl,RGBColor* c);
-
-
- /* helper functions */
-extern int setGdkColor(GdkColor * c, char *color);
-extern char *get_attribute_value(char *attr, ViewInfo * view, Agraph_t * g);
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ void init_viewport(ViewInfo * view);
+ void set_viewport_settings_from_template(ViewInfo * view, Agraph_t *);
+ void clear_viewport(ViewInfo * view);
+ void switch_graph(int);
+ void refreshViewport(int doClear);
+ int add_graph_to_viewport_from_file(char *fileName);
+ int add_graph_to_viewport(Agraph_t * graph, char *);
+ int close_graph(ViewInfo * view, int graphid);
+ int save_graph(void);
+ int save_graph_with_file_name(Agraph_t * graph, char *fileName);
+ int save_as_graph(void);
+
+ int do_graph_layout(Agraph_t * graph, int Engine, int keeppos);
+
+ void movenode(void *n, float dx, float dy);
+ void glexpose(void);
+ void move_nodes(Agraph_t * g);
+ void please_wait(void);
+ void please_dont_wait(void);
+ extern md5_byte_t *get_md5_key(Agraph_t * graph);
+ void fill_key(md5_byte_t * b, md5_byte_t * data);
+ colorschemaset *create_color_theme(int themeid);
+ extern void getcolorfromschema(colorschemaset * sc, float l,
+ float maxl, RGBColor * c);
+
+
+ /* helper functions */
+ extern int setGdkColor(GdkColor * c, char *color);
+ extern char *get_attribute_value(char *attr, ViewInfo * view,
+ Agraph_t * g);
+
+#ifdef __cplusplus
+} /* end extern "C" */
+#endif
#endif
+/* $Id$Revision: */
/* vim:set shiftwidth=4 ts=8: */
/**********************************************************
{
int ind;
int found = 0;
- for (ind = 0; ind < view->camera_count; ind++)
- {
- if ((view->cameras[ind] == c) && found == 0)
- found = 1;
- if ((found == 1) && (ind < (view->camera_count - 1)))
- view->cameras[ind] = view->cameras[ind + 1];
+ for (ind = 0; ind < view->camera_count; ind++) {
+ if ((view->cameras[ind] == c) && found == 0)
+ found = 1;
+ if ((found == 1) && (ind < (view->camera_count - 1)))
+ view->cameras[ind] = view->cameras[ind + 1];
}
- if (found)
- {
- free(c);
- view->camera_count--;
- view->cameras =RALLOC(view->camera_count, view->cameras, viewport_camera *);
- viewport_update_camera_indexes(view);
- view->active_camera--;
- return 1;
+ if (found) {
+ free(c);
+ view->camera_count--;
+ view->cameras =
+ RALLOC(view->camera_count, view->cameras, viewport_camera *);
+ viewport_update_camera_indexes(view);
+ view->active_camera--;
+ return 1;
}
return 0;
}
int ind, ind2;
- GLfloat x, y;
+ GLfloat x, y;
char buf[256];
glCompPanel *p;
glCompButton *b;
- glCompSet *s = view->widgets;
+ glCompSet *s = view->widgets;
int p_height;
/*first we need to get rid of the old menu */
- for (ind = 0; ind < s->panelcount; ind++)
- {
- if (s->panels[ind]->data == 3)
- {
- /*remove buttons in the panel */
- for (ind2 = 0; ind2 < s->buttoncount; ind2++)
- {
- if (s->buttons[ind2]->panel == s->panels[ind])
- {
- glCompSetRemoveButton(s, s->buttons[ind2]);
- ind2--;
- }
- }
- /*remove panel itself */
- glCompSetRemovePanel(s, s->panels[ind]);
- break;
+ for (ind = 0; ind < s->panelcount; ind++) {
+ if (s->panels[ind]->data == 3) {
+ /*remove buttons in the panel */
+ for (ind2 = 0; ind2 < s->buttoncount; ind2++) {
+ if (s->buttons[ind2]->panel == s->panels[ind]) {
+ glCompSetRemoveButton(s, s->buttons[ind2]);
+ ind2--;
}
+ }
+ /*remove panel itself */
+ glCompSetRemovePanel(s, s->panels[ind]);
+ break;
+ }
}
/*container for camera buttons */
p = glCompPanelNew((GLfloat) 25, (GLfloat) 75,
(GLfloat) 4 * PANEL_PADDING +
- 3 * CAMERA_BUTTON_WIDTH, (GLfloat) p_height,scientific_y);
+ 3 * CAMERA_BUTTON_WIDTH, (GLfloat) p_height,
+ scientific_y);
p->data = 3;
glCompSetAddPanel(s, p);
b = glCompButtonNew((GLfloat) PANEL_PADDING, (GLfloat) PANEL_PADDING,
(GLfloat) CAMERA_BUTTON_WIDTH,
- (GLfloat) CAMERA_BUTTON_HEIGHT, "ADD", '\0', 0, 0,scientific_y);
+ (GLfloat) CAMERA_BUTTON_HEIGHT, "ADD", '\0', 0, 0,
+ scientific_y);
b->panel = p;
b->groupid = 0;
b->customptr = view;
(GLfloat) CAMERA_BUTTON_WIDTH,
(GLfloat) PANEL_PADDING,
(GLfloat) CAMERA_BUTTON_WIDTH,
- (GLfloat) CAMERA_BUTTON_HEIGHT, "2D", '\0', 0, 0,scientific_y);
+ (GLfloat) CAMERA_BUTTON_HEIGHT, "2D", '\0', 0, 0,
+ scientific_y);
b->panel = p;
b->groupid = 4; //4 is assigned to all camera buttons
b->customptr = view;
glCompSetAddButton(s, b);
b->callbackfunc = menu_click_2d;
- for (ind = 0; ind < view->camera_count; ind++)
- {
- y = p->height - ((GLfloat) PANEL_PADDING +
- (GLfloat)ind * ((GLfloat) CAMERA_BUTTON_HEIGHT +
- (GLfloat) PANEL_PADDING)) -
- (GLfloat)CAMERA_BUTTON_HEIGHT;
- x = PANEL_PADDING;
- sprintf(buf, "CAM%i", ind + 1);
- b = glCompButtonNew((GLfloat)x, (GLfloat)y, (GLfloat) CAMERA_BUTTON_WIDTH,
- (GLfloat) CAMERA_BUTTON_HEIGHT, buf, '\0', 0,
- 0,scientific_y);
- b->panel = p;
- b->groupid = 4; //4 is assigned to all camera buttons
- b->data = ind; //assign camera id to custom data to use single call back
- b->customptr = view;
- glCompSetAddButton(s, b);
- b->callbackfunc = menu_click_camera_select;
-
- x = PANEL_PADDING * 2 + CAMERA_BUTTON_WIDTH;
- b = glCompButtonNew((GLfloat)x,(GLfloat) y, (GLfloat) CAMERA_BUTTON_WIDTH,
+ for (ind = 0; ind < view->camera_count; ind++) {
+ y = p->height - ((GLfloat) PANEL_PADDING +
+ (GLfloat) ind * ((GLfloat) CAMERA_BUTTON_HEIGHT +
+ (GLfloat) PANEL_PADDING)) -
+ (GLfloat) CAMERA_BUTTON_HEIGHT;
+ x = PANEL_PADDING;
+ sprintf(buf, "CAM%i", ind + 1);
+ b = glCompButtonNew((GLfloat) x, (GLfloat) y,
+ (GLfloat) CAMERA_BUTTON_WIDTH,
+ (GLfloat) CAMERA_BUTTON_HEIGHT, buf, '\0', 0,
+ 0, scientific_y);
+ b->panel = p;
+ b->groupid = 4; //4 is assigned to all camera buttons
+ b->data = ind; //assign camera id to custom data to use single call back
+ b->customptr = view;
+ glCompSetAddButton(s, b);
+ b->callbackfunc = menu_click_camera_select;
+
+ x = PANEL_PADDING * 2 + CAMERA_BUTTON_WIDTH;
+ b = glCompButtonNew((GLfloat) x, (GLfloat) y,
+ (GLfloat) CAMERA_BUTTON_WIDTH,
(GLfloat) CAMERA_BUTTON_HEIGHT, "Remove", '\0',
- 0, 0,scientific_y);
- b->panel = p;
- b->groupid = 0;
- b->data = ind; //assign camera id to custom data to use single call back
- b->customptr = view;
- glCompSetAddButton(s, b);
- b->callbackfunc = menu_click_camera_remove;
-
- x = PANEL_PADDING * 3 + CAMERA_BUTTON_WIDTH * 2;
- b = glCompButtonNew((GLfloat) x, (GLfloat) y,
+ 0, 0, scientific_y);
+ b->panel = p;
+ b->groupid = 0;
+ b->data = ind; //assign camera id to custom data to use single call back
+ b->customptr = view;
+ glCompSetAddButton(s, b);
+ b->callbackfunc = menu_click_camera_remove;
+
+ x = PANEL_PADDING * 3 + CAMERA_BUTTON_WIDTH * 2;
+ b = glCompButtonNew((GLfloat) x, (GLfloat) y,
(GLfloat) CAMERA_BUTTON_WIDTH,
(GLfloat) CAMERA_BUTTON_HEIGHT, "Edit", '\0',
- 0, 0,scientific_y);
- b->panel = p;
- b->groupid = 0;
- b->data = ind; //assign camera id to custom data to use single call back
- b->customptr = view;
- glCompSetAddButton(s, b);
- b->callbackfunc = menu_click_camera_edit;
+ 0, 0, scientific_y);
+ b->panel = p;
+ b->groupid = 0;
+ b->data = ind; //assign camera id to custom data to use single call back
+ b->customptr = view;
+ glCompSetAddButton(s, b);
+ b->callbackfunc = menu_click_camera_edit;
}
}
#endif
}
-void dlgcameraokbutton_clicked_cb(GtkWidget * widget, gpointer user_data) {
+void dlgcameraokbutton_clicked_cb(GtkWidget * widget, gpointer user_data)
+{
gtk_widget_hide(glade_xml_get_widget(xml, "dlgCamera"));
save_camera_settings(view->selected_camera);
}
#include "smyrnadefs.h"
#include "glcompset.h"
-viewport_camera* add_camera_to_viewport(ViewInfo * view);
-void set_camera_x_y(viewport_camera* c);
-int delete_camera_from_viewport(ViewInfo * view,viewport_camera* c);
-int activate_viewport_camera (ViewInfo * view,int cam_index);
-int refresh_viewport_camera (ViewInfo * view);
-void attach_camera_widget(ViewInfo * view);
-int show_camera_settings(viewport_camera* c);
-int save_camera_settings(viewport_camera* c);
-_BB void dlgcameraokbutton_clicked_cb(GtkWidget * widget, gpointer user_data);
-_BB void dlgcameracancelbutton_clicked_cb(GtkWidget * widget, gpointer user_data);
-extern void menu_click_add_camera(void *p);
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ viewport_camera *add_camera_to_viewport(ViewInfo * view);
+ void set_camera_x_y(viewport_camera * c);
+ int delete_camera_from_viewport(ViewInfo * view, viewport_camera * c);
+ int activate_viewport_camera(ViewInfo * view, int cam_index);
+ int refresh_viewport_camera(ViewInfo * view);
+ void attach_camera_widget(ViewInfo * view);
+ int show_camera_settings(viewport_camera * c);
+ int save_camera_settings(viewport_camera * c);
+ _BB void dlgcameraokbutton_clicked_cb(GtkWidget * widget,
+ gpointer user_data);
+ _BB void dlgcameracancelbutton_clicked_cb(GtkWidget * widget,
+ gpointer user_data);
+ extern void menu_click_add_camera(void *p);
+#ifdef __cplusplus
+} /* end extern "C" */
+#endif
#endif