//delta values
static float dx = 0.0;
static float dy = 0.0;
-static float globalz = 0.0;
+#define LAYER_DIFF 0.001
GLubyte rasters[24] = {
0xc0, 0x00, 0xc0, 0x00, 0xc0, 0x00, 0xc0, 0x00, 0xc0, 0x00, 0xff, 0x00,
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 + view->Topview->global_z);
// Change the variable
a -= 0.05;
b = 1.0 - a;
}*/
}
-static void DrawBeziers(xdot_op * op, int param)
+static void DrawBeziers(sdot_op* o, int param)
{
//SEND ALL CONTROL POINTS IN 3D ARRAYS
- GLfloat tempX[4];
+ GLfloat tempX[4];
GLfloat tempY[4];
GLfloat tempZ[4];
int temp = 0;
int filled;
int i = 0;
+ static xdot_op * op;
+ op=&o->op;
+ view->Topview->global_z=view->Topview->global_z+o->layer*LAYER_DIFF;
+
// SelectBeziers((sdot_op *) op);
relocate_spline((sdot_op *) op, param);
if (op->kind == xd_filled_bezier)
DrawBezier(tempX, tempY, tempZ, filled, param);
}
-/*function to load .raw files*/
-#ifdef UNUSED
-static void
-load_raw_texture(char *file_name, int width, int height, int depth,
- GLenum colour_type, GLenum filter_type)
-{
- //Line 3 creates a pointer to an (as yet unallocated) array of gl unsigned bytes -
- //this will store our image until we've passed it to opengl. Line 4 stores the file pointer, don't worry about that.
- GLubyte *raw_bitmap;
- FILE *file;
-
- //The if statement from line 6-10 opens the file and reports an error if it doesn't exist.
-
- if ((file = fopen(file_name, "rb")) == NULL) {
- printf("File Not Found : %s\n", file_name);
- exit(1);
- }
- //Line 11 allocates the correct number of bytes for the size and depth of the image. Remember, our image depth will usually be 3 -- one 'channel' each for red, green and blue values.
- //Lines 13-18 check if the memory was allocated correctly and quit the program if there was a problem.
-
- raw_bitmap = N_GNEW(width * height * depth, GLubyte);
-
- if (raw_bitmap == NULL) {
- printf("Cannot allocate memory for texture\n");
- fclose(file);
- exit(1);
- }
- //Line 19 reads the required number of bytes from the file and places them into our glubyte array. Line 20 closes the close as it isn't required anymore.
- fread(raw_bitmap, width * height * depth, 1, file);
- fclose(file);
-
- //Lines 22-25 set the texture's mapping type and environment settings. GL_TEXTURE_MAG_FILTER and GL_TEXTURE_MIN_FILTER are enumerands that let us change the way in which opengl magnifies and minifies the texture. If we passed GL_LINEAR to the function, our texture would be interpolated using bilinear filtering (in other words, it'd appear smoothed). If we passed GL_NEAREST then no smoothing would occur. By passing GL_MODULATE to the texture environment function, we tell opengl to blend the texture with the base colour of the object. Had we specified GL_DECAL or GL_REPLACE then the base colour (and therefore our lighting effect) would be replaced purely with the colours of the texture.
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filter_type);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filter_type);
-
- glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
-
- //Line 27 passes the image to opengl using the function gluBuild2DMipmaps.
- //Read a graphics book for a description of mipmaps.
- //This function will also resize the texture map if it doesn't conform
- //to the opengl restriction of height and width values being a power of 2.
- gluBuild2DMipmaps(GL_TEXTURE_2D, colour_type, width, height,
- colour_type, GL_UNSIGNED_BYTE, raw_bitmap);
-
- //We don't need our texture in the temporary array anymore as it has been passed to opengl.
- //We use the standard C library call 'free' to return the allocated memory.
- free(raw_bitmap);
-}
-#endif
//Draws a ellpise made out of points.
//void DrawEllipse(xdot_point* xpoint,GLfloat xradius, GLfloat yradius,int filled)
-void DrawEllipse(xdot_op * op, int param)
+void DrawEllipse(sdot_op* o, int param)
{
//to draw a circle set xradius and yradius same values
GLfloat x, y, xradius, yradius;
int i = 0;
int filled;
+ static xdot_op * op;
+ op=&o->op;
+ view->Topview->global_z=view->Topview->global_z+o->layer*LAYER_DIFF;
set_options((sdot_op *) op, param);
x = op->u.ellipse.x - dx;
y = op->u.ellipse.y - dy;
//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), view->Topview->global_z);
}
glEnd();
}
-static void DrawPolygon(xdot_op * op, int param)
+extern void DrawPolygon(sdot_op * o, int param)
//void DrawPolygon(xdot_point* xpoint,int count, int filled)
{
int i = 0;
int filled;
- //SelectPolygon((sdot_op *) op);
+ static xdot_op * op;
+ op=&o->op;
+ view->Topview->global_z=view->Topview->global_z+o->layer*LAYER_DIFF;
+
+ //SelectPolygon((sdot_op *) op);
set_options((sdot_op *) op, param);
if (op->kind == xd_filled_polygon) {
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 + view->Topview->global_z);
}
- 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 + view->Topview->global_z); //close the polygon
glEnd();
}
-void DrawPolyline(xdot_op * op, int param)
+void DrawPolyline(sdot_op* o, int param)
{
int i = 0;
+ static xdot_op * op;
+ op=&o->op;
+ view->Topview->global_z=view->Topview->global_z+o->layer*LAYER_DIFF;
+
if (param == 0)
glColor4f(view->penColor.R, view->penColor.G, view->penColor.B,
view->penColor.A);
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 + view->Topview->global_z);
}
glEnd();
}
-#ifdef UNUSED
-static void
-DrawBitmap(GLfloat bmpX, GLfloat bmpY, GLfloat bmpW, GLfloat bmpH)
-{
- if (view->texture)
- glEnable(GL_TEXTURE_2D);
- else
- glDisable(GL_TEXTURE_2D);
-/* glRasterPos2d(bmpX,bmpY);
- glBitmap( bmpW,bmpH,0.0,0.0,0.0,0.0, 1); */
- glBegin(GL_QUADS);
- glTexCoord2d(bmpX, bmpY);
- glVertex2d(bmpX, bmpY);
- glTexCoord2d(bmpX + bmpW, bmpY);
- glVertex2d(bmpX + bmpW, bmpY);
- glTexCoord2d(bmpX + bmpW, bmpY + bmpH);
- glVertex2d(bmpX + bmpW, bmpY + bmpH);
- glTexCoord2d(bmpX, bmpY + bmpH);
- glVertex2d(bmpX, bmpY + bmpH);
- glEnd();
- glDisable(GL_TEXTURE_2D);
-}
-#endif
-
-void SetFillColor(xdot_op * op, int param)
+void SetFillColor(sdot_op* o, int param)
{
- RGBColor c;
- c = GetRGBColor(op->u.color);
+ glCompColor c;
+ static xdot_op * op;
+ op=&o->op;
+ c = GetglCompColor(op->u.color);
view->fillColor.R = c.R;
view->fillColor.G = c.G;
view->fillColor.B = c.B;
view->fillColor.A = c.A;
}
-void SetPenColor(xdot_op * op, int param)
+void SetPenColor(sdot_op* o, int param)
{
- RGBColor c;
- c = GetRGBColor(op->u.color);
+ glCompColor c;
+ static xdot_op * op;
+ op=&o->op;
+ c = GetglCompColor(op->u.color);
view->penColor.R = c.R;
view->penColor.G = c.G;
view->penColor.B = c.B;
view->penColor.A = c.A;
}
-void SetStyle(xdot_op * op, int param)
+void SetStyle(sdot_op* o, int param)
{
+ static xdot_op * op;
+ op=&o->op;
}
-static void SetFont(xdot_op * op, int param)
+static sdot_op * font_op;
+
+void SetFont(sdot_op * o, int param)
{
- //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;*/
+ font_op=o;
}
-void InsertImage(xdot_op * op, int param)
+void InsertImage(sdot_op * o, int param)
{
- // SelectImage((sdot_op *) op);
-
}
-void EmbedText(xdot_op * op, int param)
+void EmbedText(sdot_op* o, int param)
{
- /*use gl pango fonts */
-
-
+ GLfloat x,y;
+ glColor4f(view->penColor.R,view->penColor.G,view->penColor.B,view->penColor.A);
+ view->Topview->global_z=view->Topview->global_z+o->layer*LAYER_DIFF+0.05;
+ switch (o->op.u.text.align)
+ {
+ case xd_left:
+ x=o->op.u.text.x ;
+ break;
+ case xd_center:
+ x=o->op.u.text.x - o->op.u.text.width / 2.0;
+ break;
+ case xd_right:
+ x=o->op.u.text.x - o->op.u.text.width;
+ break;
+ }
+ y=o->op.u.text.y;
+ if (o->font)
+ glCompDrawText3D(o->font,x,y,view->Topview->global_z,o->op.u.text.width,font_op->op.u.font.size);
+ else
+ {
+ o->font=new_font(
+ view->widgets,
+ o->op.u.text.text,
+ &view->penColor,
+ pangotext,
+ font_op->op.u.font.name,font_op->op.u.font.size,0);
+ //new_font(glCompSet * s, char *text, glCompColor * c, glCompFontType type, char *fontdesc, int fs)*/
-#ifdef UNUSED
- GLfloat x;
-// SelectText((sdot_op *) op);
- set_options((sdot_op *) op, param);
- if (op->u.text.align == 1)
- x = (GLfloat) op->u.text.x - (GLfloat) (op->u.text.width / 2.0);
- if (op->u.text.align == 0)
- 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;
- if (param == 0)
- 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);
-#endif
+ }
}
void draw_selection_box(ViewInfo * view)
}
glBegin(GL_LINE_STRIP);
glVertex3f((GLfloat) view->GLx, (GLfloat) view->GLy,
- (GLfloat) 0.001 + globalz);
+ (GLfloat) 0.001 + view->Topview->global_z);
glVertex3f((GLfloat) view->GLx, (GLfloat) view->GLy2,
- (GLfloat) 0.001 + globalz);
+ (GLfloat) 0.001 + view->Topview->global_z);
glVertex3f((GLfloat) view->GLx2, (GLfloat) view->GLy2,
- (GLfloat) 0.001 + globalz);
+ (GLfloat) 0.001 + view->Topview->global_z);
glVertex3f((GLfloat) view->GLx2, (GLfloat) view->GLy,
- (GLfloat) 0.001 + globalz);
+ (GLfloat) 0.001 + view->Topview->global_z);
glVertex3f((GLfloat) view->GLx, (GLfloat) view->GLy,
- (GLfloat) 0.001 + globalz);
+ (GLfloat) 0.001 + view->Topview->global_z);
glEnd();
if (view->mouse.mouse_mode == 5)
glDisable(GL_LINE_STIPPLE);
angle += (float) 0.1) {
vectorX = originX + radius * (float) sin(angle);
vectorY = originY + radius * (float) cos(angle);
- glVertex3d(vectorX1, vectorY1, globalz);
+ glVertex3d(vectorX1, vectorY1, view->Topview->global_z);
vectorY1 = vectorY;
vectorX1 = vectorX;
}
sdot_op *op;
//to avoid the overlapping , z is slightly increased for each xdot of a particular object
if (AGTYPE(p)==AGEDGE)
- globalz=1;
+ view->Topview->global_z=1;
else
- globalz=0;
+ view->Topview->global_z=0;
for (id = 0; id < xDot->cnt; id++)
{
- globalz += (float)GLOBAL_Z_OFFSET;
+ view->Topview->global_z += (float)GLOBAL_Z_OFFSET;
op = ops + id;
op->obj = p;
op->op.drawfunc(&(op->op), param);
for (id = 0; id < xDot->cnt; id++) {
op = ops + id;
op->obj = p;
- if (op->op.kind == xd_font) {
+/* 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
- }
+ }*/
}
}
}
}
-int randomize_color(RGBColor * c, int brightness)
+int randomize_color(glCompColor * c, int brightness)
{
float R, B, G;
float add;
float degInRad = (float) (i * DEG2RAD);
glVertex3f((GLfloat) (x + cos(degInRad) * radius),
(GLfloat) (y + sin(degInRad) * radius),
- (GLfloat) zdepth + globalz);
+ (GLfloat) zdepth + view->Topview->global_z);
}
glEnd();
InsertImage,
};
-RGBColor GetRGBColor(char *color)
+glCompColor GetglCompColor(char *color)
{
gvcolor_t cl;
- RGBColor c;
+ glCompColor c;
if (color != '\0') {
colorxlate(color, &cl, RGBA_DOUBLE);
c.R = (float) cl.u.RGBA[0];
//convert degrees into radians
float degInRad = (float) i * (float) DEG2RAD;
glVertex3f((GLfloat) (cos(degInRad) * xradius),
- (GLfloat) (sin(degInRad) * yradius), globalz);
+ (GLfloat) (sin(degInRad) * yradius), view->Topview->global_z);
}
glEnd();
#include <stdlib.h>
#include <string.h>
#include <math.h>
+#include "glcompfont.h"
#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
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 int randomize_color(glCompColor * c, int brightness);
extern void drawCircle(float x, float y, float radius, float zdepth);
- extern RGBColor GetRGBColor(char *color);
+ extern glCompColor GetglCompColor(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);
+
+ /*xdot drawing functions*/
+ extern void DrawBeziers(sdot_op* o, int param);
+ extern void DrawEllipse(sdot_op * op, int param);
+ extern void DrawPolygon(sdot_op * op, int param);
+ extern void DrawPolyline(sdot_op * op, int param);
+ extern void SetFillColor(sdot_op* o, int param);
+ extern void SetPenColor(sdot_op* o, int param);
+ extern void SetStyle(sdot_op* o, int param);
+ extern void SetFont(sdot_op * o, int param);
+ extern void InsertImage(sdot_op * o, int param);
+ extern void EmbedText(sdot_op * o, int param);
+
+ typedef struct
+ {
+ glCompColor color;
+ float width;
+ }xdotstyle;
+
+
+
+ typedef struct
+ {
+ glCompColor penColor;
+ glCompColor fillColor;
+ xdotstyle style;
+ } xdotstate;
+
- void draw_sphere(float x, float y, float z, float r);
#ifdef __cplusplus
} /* end extern "C" */
void frmObjectBtnOK_clicked(GtkWidget * widget, gpointer user_data)
{
- //call function to update object values
-// update_object_properties(frmObjectTypeIndex, frmObjectg);
- set_update_required(view->Topview);
deselect_all(view->g[view->activeGraph]);
gtk_widget_hide(glade_xml_get_widget(xml, "frmObject"));
}
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
+ {
+ xdot_op op;
+ void *obj;
+ glCompFont* font;
+ int size;
+ int layer;
+
+ } sdot_op;
+
+
#define MAX_BTN_CNT 50
typedef struct {
float perc;
- RGBColor c;
+ glCompColor c;
int smooth;
} colorschema;
- 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;
+ 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
+ glCompColor Color;
+ glCompColor GroupColor;
+ int GroupIndex; //default -1;
+ char *Label;
+ char *Label2;
+ int degree;
+ float node_alpha;
+ int valid;
+ element_data data;
+ float size;
+ xdot* xDot;
} 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;
- element_data data;
-
+ typedef struct
+ {
+ 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
+ glCompColor Color;
+ element_data data;
+ xdot* xDot;
} topview_edge;
+
typedef struct _graph_data {
Agrec_t h;
char *GraphFileName;
float init_node_size; //raster size of node
float init_zoom;
float fitin_zoom;
- xdot_set *xdot_list; /*xdot attached to whole graph */
+ xdot* xDot;
+ float global_z;
} topview;
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;
+ glCompColor 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
float clipX1, clipX2, clipY1, clipY2, clipZ1, clipZ2;
/*background color */
- RGBColor bgColor;
+ glCompColor bgColor;
/*default pen color */
- RGBColor penColor;
+ glCompColor penColor;
/*default fill color */
- RGBColor fillColor;
+ glCompColor fillColor;
/*highlighted Node Color */
- RGBColor highlightedNodeColor;
+ glCompColor highlightedNodeColor;
/*highlighted Edge Color */
- RGBColor highlightedEdgeColor;
+ glCompColor highlightedEdgeColor;
/*grid color */
- RGBColor gridColor; //grid color
+ glCompColor gridColor; //grid color
/*border color */
- RGBColor borderColor;
+ glCompColor borderColor;
/*selected node color */
- RGBColor selectedNodeColor;
+ glCompColor selectedNodeColor;
/*selected edge color */
- RGBColor selectedEdgeColor;
+ glCompColor selectedEdgeColor;
/*default node alpha */
float defaultnodealpha;
/*default edge alpha */
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_tv_xdot(topview* t);
+static void draw_xdot(xdot* x,float base_z);
+
void cleartopview(topview * t)
{
free(t->Nodes);
free(t->Edges);
- free_xdotset(t->xdot_list);
}
static void init_element_data(element_data * d)
sscanf(buf, "%f,%f,%f", x, y, z);
}
-static void setRGBcolor(RGBColor * c, char *colorstr)
+static void setglCompColor(glCompColor * c, char *colorstr)
{
gvcolor_t cl;
/*if node has color attribute */
void settvcolorinfo(Agraph_t * g, topview * t)
{
int ind;
- RGBColor color;
+ glCompColor color;
topview_node *np;
topview_edge *ep;
Agsym_t *sel = agattr(g, AGNODE, "selected", 0);
/*loop nodes */
for (ind = 0; ind < t->Nodecount; ind++) {
np = t->Nodes + ind;
- setRGBcolor(&color, agget(np->Node, "color"));
+ setglCompColor(&color, agget(np->Node, "color"));
np->Color = color;
/*while in the loop why dont we set some smyrna settings from graph? selected , highlighted , visible */
ep = t->Edges + ind;
if (ecolor && (color_string = agxget(ep->Edge, ecolor))
&& (*color_string != '\0'))
- setRGBcolor(&color, color_string);
+ setglCompColor(&color, color_string);
else { /*use color theme */
getcolorfromschema(view->colschms, ep->length, t->maxedgelen,
&color);
static xdot *parseXdotwithattr(void *p, char *attr)
{
- xdot *xDot;
- if ((xDot = parseXDotF(agget(p, attr), OpFns, sizeof(xdot_op))))
+ int ind=0;
+ xdot *xDot;
+ xdot_op* x_op;
+ sdot_op* s_op;
+ xDot = parseXDotF(agget(p, attr), OpFns, sizeof(sdot_op));
+ if (!xDot)
+ return NULL;
+ for (ind ; ind < xDot->cnt; ind ++)
+ {
+ x_op=&(xDot->ops[ind]);
+ s_op=(sdot_op*)x_op;
+ s_op->font=NULL;
+ s_op->layer=ind;
+ }
return xDot;
- else
- return NULL;
}
-static void parseXdotwithattrs(void *e, xdot_set * s)
+static xdot* parseXdotwithattrs(void *e)
{
- 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_"));
+
+ xdot* xDot=NULL;
+ xDot=parseXDotFOn (agget(e,"_draw_" ), OpFns,sizeof(sdot_op), xDot);
+ xDot=parseXDotFOn (agget(e,"_ldraw_" ), OpFns,sizeof(sdot_op), xDot);
+ xDot=parseXDotFOn (agget(e,"_hdraw_" ), OpFns,sizeof(sdot_op), xDot);
+ xDot=parseXDotFOn (agget(e,"_tdraw_" ), OpFns,sizeof(sdot_op), xDot);
+ xDot=parseXDotFOn (agget(e,"_hldraw_" ), OpFns,sizeof(sdot_op), xDot);
+ xDot=parseXDotFOn (agget(e,"_tldraw_" ), OpFns,sizeof(sdot_op), xDot);
+ return xDot;
+
}
void settvxdot(Agraph_t * g, topview * t)
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);
+ t->xDot=parseXdotwithattrs(view->g[view->activeGraph]);
+ for (ind = 0; ind < t->Nodecount; ind++)
+ {
+ np = &t->Nodes[ind];
+ np->xDot=parseXdotwithattrs(np->Node);
}
- 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];
+ ep->xDot=parseXdotwithattrs(ep->Edge);
}
}
void init_node_size(Agraph_t * g, topview * t)
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 */
drawtopviewedges(g);
drawtopviewedgelabels(g);
enddrawcycle(g);
- draw_xdot_set(view->Topview->xdot_list);
+ draw_tv_xdot(view->Topview);
draw_node_hint_boxes();
if ((view->Selection.Active > 0) && (!view->SignalBlock)) {
view->Selection.Active = 0;
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;
+ glCompColor SelectionColor;
*/
#endif
-int set_update_required(topview * t)
-{
- int i = 0;
- int ilimit;
- ilimit = (t->Nodecount > t->Edgecount) ? t->Nodecount : t->Edgecount;
-
- for (i = 0; i < ilimit; i++) {
- if (t->Nodecount > i)
-
- t->Nodes[i].update_required = 1;
- if (t->Edgecount > i)
- t->Edges[i].update_required = 1;
- }
- return 1;
-
-}
float calculate_font_size(topview_node * v)
{
}
-struct xdot_set {
- Dt_t *objs; /* original graph object (node edge graph) */
- Dt_t *xdots; /* xdot collection */
-};
-
-
-static Dtdisc_t qDisc = {
- offsetof(xdot, ops),
- sizeof(xdot_op *),
- -1,
- NIL(Dtmake_f),
- NIL(Dtfree_f),
- NIL(Dtcompar_f),
- NIL(Dthash_f),
- NIL(Dtmemory_f),
- NIL(Dtevent_f)
-};
-
-static xdot_set *init_xdot_set()
+static void draw_xdot(xdot* x,float base_z)
{
- xdot_set *rv;
- rv = NEW(xdot_set);
- rv->objs = NULL;
- rv->xdots = dtopen(&qDisc, Dtqueue);
+ int i;
+ sdot_op *op;
+ if (!x)
+ return;
- return rv;
-}
+ view->Topview->global_z=base_z;
-static void add_to_xdot_set(xdot_set * s, xdot * x)
-{
- dtinsert(s->xdots, x);
-}
+ op=(sdot_op*)x->ops;
+ for (i=0; i < x->cnt; i++,op++)
+ {
+ if(op->op.drawfunc)
+ op->op.drawfunc(&op->op,0);
+ }
-#ifdef UNUSED
-static xdot *remove_from_xdot_set(xdot_set * s)
-{
- return (xdot *) dtdelete(s->xdots, NULL);
-}
-#endif
-static void free_xdotset(xdot_set * 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_tv_xdot(topview* t)
{
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);
- }
- }
+ float basez=0;
+ draw_xdot(t->xDot,basez);
+ basez= basez+0.01;
+ for (j=0; j < t->Nodecount; j++)
+ draw_xdot(t->Nodes[j].xDot,basez);
+ basez = basez+0.001;
+ for (j=0; j < t->Edgecount; j++)
+ draw_xdot(t->Edges[j].xDot,basez);
}
void setMultiedges(Agraph_t * g, char *attrname)
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);
view->Selection.Anti = 0;
view->Topview = GNEW(topview);
view->Topview->fs = 0;
- view->Topview->xdot_list = NULL;
+ view->Topview->xDot=NULL;
/* init topfish parameters */
view->Topview->parms.level.num_fine_nodes = 10;
return ((x - minv) * (maxc - minc) / (maxv - minv) + minc);
}
void getcolorfromschema(colorschemaset * sc, float l, float maxl,
- RGBColor * c)
+ glCompColor * c)
{
int ind;
/* float cuml=0.00; */
/*typedef struct{
float perc;
- RGBColor c;
+ glCompColor c;
int smooth;
}colorschema;
float yGAP = 80;
float x = 50;
float y = 50;
- RGBColor c;
+ glCompColor c;
for (ind = 0; ind < 350; ind++) {
getcolorfromschema(view->colschms, ind, 350, &c);
x = ind * xGAP;
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);
+ float maxl, glCompColor * c);
/* helper functions */
GLfloat G;
GLfloat B;
GLfloat A; //Alpha
+ int tag;
} glCompColor;
int size;
int reference; /*if font has references to parent */
glCompJustify justify;
+ int is2D;
int optimize;
} glCompFont;
}
-glCompFont *new_font(glCompSet * s, char *text, glCompColor * c,
- glCompFontType type, char *fontdesc, int fs)
+glCompFont *new_font(glCompSet * s, char *text, glCompColor * c,glCompFontType type, char *fontdesc, int fs,int is2D)
{
glCompFont *font = NEW(glCompFont);
font->reference = 0;
if (text)
font->tex =
glCompSetAddNewTexLabel(s, font->fontdesc, font->size, text,
- 1);
+ is2D);
return font;
}
font->justify.VJustify = parent->font->justify.VJustify;
font->justify.HJustify = parent->font->justify.HJustify;
font->optimize = parent->font->optimize;
+ font->is2D=parent->font->is2D;
if (text) {
if (strlen(text))
font->tex =
glCompSetAddNewTexLabel(parent->compset,
font->fontdesc, font->size,
- text, 1);
+ text, parent->font->is2D);
}
} else { /*no parent */
c.A = GLCOMPSET_FONT_COLOR_ALPHA;
font =
new_font(o->common.compset, text, &c, pangotext,
- GLCOMPSET_FONT_DESC, GLCOMPSET_FONT_SIZE);
+ GLCOMPSET_FONT_DESC, GLCOMPSET_FONT_SIZE,1);
}
return font;
}
font->color.A = a;
}
+
+/*texture base 3d text rendering*/
+void glCompDrawText3D(glCompFont * f,GLfloat x,GLfloat y,GLfloat z,GLfloat w,GLfloat h)
+{
+ glEnable(GL_BLEND); // Turn Blending On
+ glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
+ glEnable(GL_TEXTURE_2D);
+ glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
+ glBindTexture(GL_TEXTURE_2D,f->tex->id);
+ glBegin(GL_QUADS);
+ glTexCoord2d(0.0f, 1.0f);glVertex3d(x,y,z);
+ glTexCoord2d(1.0f, 1.0f);glVertex3d(x+w,y,z);
+ glTexCoord2d(1.0f, 0.0f);glVertex3d(x+w,y+h,z);
+ glTexCoord2d(0.0f, 0.0f);glVertex3d(x,y+h,z);
+ glEnd();
+
+ glDisable(GL_TEXTURE_2D);
+ glEnable(GL_BLEND);
+
+}
+/*bitmap base 2D text rendering */
+void glCompDrawText(glCompFont * f,GLfloat x,GLfloat y)
+{
+ glRasterPos2f(x, y);
+ glDrawPixels(f->tex->width, f->tex->height, GL_RGBA, GL_UNSIGNED_BYTE,
+ f->tex->data);
+}
+
+/*text rendering functions, depends on a globject to retrieve stats*/
void glCompRenderText(glCompFont * f, glCompObj * parentObj)
{
static glCompCommon ref;
y = ref.refPos.y + (ref.height - f->tex->height) / (GLfloat) 2.0;
break;
}
+ z=ref.refPos.z;
glCompSetColor(&f->color);
- glRasterPos2f(x, y);
- glDrawPixels(f->tex->width, f->tex->height, GL_RGBA, GL_UNSIGNED_BYTE,
- f->tex->data);
-
-/* glEnable(GL_BLEND); // Turn Blending On
- glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
- glEnable(GL_TEXTURE_2D);
- glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
- glBindTexture(GL_TEXTURE_2D,f->tex->id);
- glBegin(GL_QUADS);
- glTexCoord2d(0.0f, 1.0f);glVertex3d(x,y,z);
- glTexCoord2d(1.0f, 1.0f);glVertex3d(x+w,y,z);
- glTexCoord2d(1.0f, 0.0f);glVertex3d(x+w,y+h,z);
- glTexCoord2d(0.0f, 0.0f);glVertex3d(x,y+h,z);
- glEnd();
-
- glDisable(GL_TEXTURE_2D);
- glEnable(GL_BLEND);*/
-
-/*
- glEnable(GL_BLEND); // Turn Blending On
- glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
- glEnable(GL_TEXTURE_2D);
- glColor4f( p->fontColor.R, p->fontColor.G, p->fontColor.B, p->fontColor.A);
- glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
- glBindTexture(GL_TEXTURE_2D,((glCompSet*) (p->parentset))->texLabels[p->OGLtexture]->id);
- glBegin(GL_QUADS);
- glTexCoord2d(0.0f, 1.0f);glVertex3d(p->pos.x,p->pos.y,GLCOMPSET_BEVEL_DIFF);
- glTexCoord2d(1.0f, 1.0f);glVertex3d(p->pos.x+w,p->pos.y,GLCOMPSET_BEVEL_DIFF);
- glTexCoord2d(1.0f, 0.0f);glVertex3d(p->pos.x+w,p->pos.y+h,GLCOMPSET_BEVEL_DIFF);
- glTexCoord2d(0.0f, 0.0f);glVertex3d(p->pos.x,p->pos.y+h,GLCOMPSET_BEVEL_DIFF);
- glEnd();
-*/
-
+ glCompDrawText(f,x,y);
}
extern void fontColor(glCompFont * font, float r, float g, float b,
float a);
extern int glCompLoadFontPNG(char *name, int id);
- extern glCompFont *new_font(glCompSet * s, char *text, glCompColor * c,
- glCompFontType type, char *fontdesc,
- int fs);
+ extern glCompFont *new_font(glCompSet * s, char *text, glCompColor * c,glCompFontType type, char *fontdesc, int fs,int is2D);
extern glCompFont *new_font_from_parent(glCompObj * o, char *text);
extern void delete_font(glCompFont * f);
- extern void glCompRenderText(glCompFont * f, glCompObj * parentObj);
-
+ extern void glCompDrawText(glCompFont * f,GLfloat x,GLfloat y);
+ extern void glCompRenderText(glCompFont * f, glCompObj * parentObj);
+ extern void glCompDrawText3D(glCompFont * f,GLfloat x,GLfloat y,GLfloat z,GLfloat w,GLfloat h);
#ifdef __cplusplus
}