]> granicus.if.org Git - graphviz/commitdiff
smyrna xdot implementation with pango support finished
authorarif <devnull@localhost>
Thu, 15 Oct 2009 17:21:19 +0000 (17:21 +0000)
committerarif <devnull@localhost>
Thu, 15 Oct 2009 17:21:19 +0000 (17:21 +0000)
cmd/smyrna/draw.c
cmd/smyrna/draw.h
cmd/smyrna/gui/callbacks.c
cmd/smyrna/smyrnadefs.h
cmd/smyrna/topview.c
cmd/smyrna/topview.h
cmd/smyrna/viewport.c
cmd/smyrna/viewport.h
lib/glcomp/glcompdefs.h
lib/glcomp/glcompfont.c
lib/glcomp/glcompfont.h

index 461d7f0e5464a7e4c72f742a175903f131b84d1f..1ff8f79deb31dcb1989b24f8cda908d1440b65db 100755 (executable)
@@ -32,7 +32,7 @@ XDOT DRAWING FUNCTIONS, maybe need to move them somewhere else
 //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,
@@ -99,7 +99,7 @@ void DrawBezier(GLfloat * xp, GLfloat * yp, GLfloat * zp, int filled,
        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;
@@ -199,16 +199,20 @@ static void relocate_spline(sdot_op * sop, int param)
        }*/
 }
 
-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)
@@ -237,64 +241,18 @@ static void DrawBeziers(xdot_op * op, int param)
     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;
@@ -331,17 +289,21 @@ void DrawEllipse(xdot_op * op, int param)
        //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) {
@@ -373,15 +335,19 @@ static void DrawPolygon(xdot_op * op, int param)
     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);
@@ -395,106 +361,85 @@ void DrawPolyline(xdot_op * op, int param)
     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)
@@ -511,15 +456,15 @@ 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);
@@ -587,7 +532,7 @@ void draw_circle(float originX, float originY, float radius)
         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;
     }
@@ -659,13 +604,13 @@ void drawBorders(ViewInfo * view)
     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);
@@ -760,9 +705,9 @@ static void scanXdot(xdot * xDot, void *p)
     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
-       }
+       }*/
     }
 
 }
@@ -807,7 +752,7 @@ void scanGraph(Agraph_t * g)
     }
 
 }
-int randomize_color(RGBColor * c, int brightness)
+int randomize_color(glCompColor * c, int brightness)
 {
     float R, B, G;
     float add;
@@ -835,7 +780,7 @@ void drawCircle(float x, float y, float radius, float zdepth)
        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();
@@ -854,10 +799,10 @@ drawfunc_t OpFns[] = {
     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];
@@ -881,7 +826,7 @@ void drawEllipse(float xradius, float yradius, int angle1, int angle2)
        //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();
index 994f880218ad7910da6c712c343bcbac88ae9400..b227e4aa1c481e74dbb33ecb7c935a5e1bc8a7b3 100755 (executable)
 #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
@@ -44,18 +37,46 @@ extern "C" {
     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" */
index 6edbd4068a0d554f6f8d4820f5637624209ff07d..6ddd4e2332f038f518c0842b9d6694d048ff4865 100755 (executable)
@@ -208,9 +208,6 @@ void frmObject_set_scroll(GtkWidget * widget, gpointer user_data)
 
 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"));
 }
index 9b4e77db421f739c4899e8a423fc3d6b09a33a30..4631ce2cb7835a505e21994b9d92c2e5387fcfcd 100644 (file)
@@ -93,18 +93,23 @@ extern "C" {
     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;
@@ -273,49 +278,49 @@ extern "C" {
 
 
 
-    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;
@@ -358,7 +363,8 @@ extern "C" {
        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;
 
@@ -409,7 +415,7 @@ extern "C" {
        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
@@ -449,23 +455,23 @@ extern "C" {
        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 */
index 9594c22e8dcab078409e9c66da6229d79dc68e32..735ab8f3221a4e949bcc8f93004544ab2a2c0832 100755 (executable)
@@ -50,17 +50,15 @@ static int draw_topview_edge_label(topview_edge * e, float zdepth);
 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)
@@ -90,7 +88,7 @@ static void setpositioninfo(float *x, float *y, float *z, char *buf)
     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 */
@@ -214,7 +212,7 @@ static int visible(void *obj, Agsym_t * vattr, Agsym_t * sattr)
 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);
@@ -228,7 +226,7 @@ void settvcolorinfo(Agraph_t * g, topview * t)
     /*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 */
@@ -249,7 +247,7 @@ void settvcolorinfo(Agraph_t * g, topview * t)
        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);
@@ -267,21 +265,35 @@ void settvcolorinfo(Agraph_t * g, topview * t)
 
 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)
@@ -291,13 +303,16 @@ 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)
@@ -329,12 +344,9 @@ void update_topview(Agraph_t * g, topview * t, int init)
 
     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 */
@@ -810,7 +822,7 @@ void drawTopViewGraph(Agraph_t * g)
     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;
@@ -898,7 +910,7 @@ static int select_topview_node(topview_node * n)
     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;
 */
 
 
@@ -963,22 +975,6 @@ static int select_topview_edge(topview_edge * e)
 #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)
 {
@@ -1362,70 +1358,37 @@ void select_with_regex(char *exp)
 }
 
 
-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)
index c30320c8b4fd8387235b47723fa5bb674b71d1d5..fce32371a165ce4f1ea506edd8bc75045e4f979b 100755 (executable)
@@ -32,7 +32,6 @@ extern "C" {
     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);
index 58be5ca056d3b89aaa41b89a8367422b09fab67e..e1c505d8968ccd1d3d43d60f4fce21976fe7c54e 100755 (executable)
@@ -446,7 +446,7 @@ void init_viewport(ViewInfo * view)
     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;
@@ -995,7 +995,7 @@ float interpol(float minv, float maxv, float minc, float maxc, float x)
     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; */
@@ -1048,7 +1048,7 @@ static void set_color_theme_color(colorschemaset * sc, char **colorstr,
 
 /*typedef struct{
        float perc;
-       RGBColor c;
+       glCompColor c;
        int smooth;
 
 }colorschema;
@@ -1127,7 +1127,7 @@ void test_color_pallete()
     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;
index 88664059988a1d4ca73d2fbbd3215de961f0c7c4..4984992d664d8fd9a18be09befcca10556cde438 100755 (executable)
@@ -50,7 +50,7 @@ extern "C" {
     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 */
index aa82b6e1fc062d9e8401521f5d4b2f73324c46bf..25205537d455560b9f7edbb7796b4eb1c8316c1d 100644 (file)
@@ -185,6 +185,7 @@ extern "C" {
        GLfloat G;
        GLfloat B;
        GLfloat A;              //Alpha
+       int tag;
     } glCompColor;
 
 
@@ -218,6 +219,7 @@ extern "C" {
        int size;
        int reference;          /*if font has references to parent */
        glCompJustify justify;
+       int is2D;
        int optimize;
     } glCompFont;
 
index 6fb1ce9e9d9cbcb31526ac59104e35ad33737f3c..573515378877b45ef248269438c4a8536fb1c19d 100644 (file)
@@ -195,8 +195,7 @@ void delete_font(glCompFont * f)
 
 }
 
-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;
@@ -219,7 +218,7 @@ glCompFont *new_font(glCompSet * s, char *text, glCompColor * c,
     if (text)
        font->tex =
            glCompSetAddNewTexLabel(s, font->fontdesc, font->size, text,
-                                   1);
+                                   is2D);
     return font;
 
 }
@@ -247,12 +246,13 @@ glCompFont *new_font_from_parent(glCompObj * o, char *text)
        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 */
 
@@ -263,7 +263,7 @@ glCompFont *new_font_from_parent(glCompObj * o, char *text)
        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;
 }
@@ -376,6 +376,35 @@ void fontColor(glCompFont * font, float r, float g, float b, float a)
     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;
@@ -412,41 +441,9 @@ void glCompRenderText(glCompFont * f, glCompObj * parentObj)
        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);
 
 }
index 365261f80dcb44d5aa374d63f7c45f6bf3c95ab8..99f58826606012fa176e9f6e6e3a3ff5c5693985 100644 (file)
@@ -46,13 +46,12 @@ extern "C" {
     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
 }