*** empty log message ***
authorarif <devnull@localhost>
Tue, 26 Feb 2008 16:43:51 +0000 (16:43 +0000)
committerarif <devnull@localhost>
Tue, 26 Feb 2008 16:43:51 +0000 (16:43 +0000)
17 files changed:
cmd/smyrna/.cvsignore
cmd/smyrna/Makefile.am
cmd/smyrna/draw.c
cmd/smyrna/draw.h
cmd/smyrna/glTemplate.c
cmd/smyrna/glTemplate.h
cmd/smyrna/main.c
cmd/smyrna/materials.h
cmd/smyrna/template.c
cmd/smyrna/topview.c
cmd/smyrna/topview.h
cmd/smyrna/tvnodes.c
cmd/smyrna/tvnodes.h
cmd/smyrna/viewport.c
cmd/smyrna/viewport.h
lib/filter/Makefile.am
lib/filter/btree.c

index 30020f6b0f394b2b2c6fd9b7de620724993fa14d..58a1df0135f94b156e7fd3055dcb1a73f213b324 100644 (file)
@@ -5,4 +5,4 @@
 .libs
 Makefile
 Makefile.in
-smyrna
+gtktopview
index e19cb1a0c835fa8101364b5e4eeb6615569dca7c..1b2bb6be32231ce5dbc137d229837d364fba58cc 100644 (file)
@@ -1,34 +1,31 @@
-guidir = $(pkgdatadir)/gui
-icondir = $(pkgdatadir)/icons
+gladedir = $(datadir)/gtktopview/glade
+fontsdir = $(datadir)/gtktopview/fonts
+icondir = $(datadir)/gtktopview/icons
 
 AM_CPPFLAGS = \
-       -DSMYRNA_GLADE=\""$(guidir)/smyrna.glade"\" \
-       -DSMYRNA_FONT=\""$(guidir)/arial.tga"\" \
-       -DSMYRNA_ICONSDIR=\""$(iconsdir)"\" \
+       -DGTKTOPVIEW_GLADE=\""$(gladedir)/gtktopview.glade"\" \
+       -DGTKTOPVIEW_FONT=\""$(fontsdir)/arial.tga"\" \
+       -DGTKTOPVIEW_ICONSDIR=\""$(iconsdir)"\" \
         -I$(top_srcdir) \
         -I$(top_srcdir)/lib/cgraph \
         -I$(top_srcdir)/lib/cdt \
         -I$(top_srcdir)/lib/filter \
         -I$(top_srcdir)/lib/utilities \
         -I$(top_srcdir)/lib/xdot \
-        -I$(top_srcdir)/lib/topfish \
-        -I$(top_srcdir)/lib/gui \
+        -I$(top_srcdir)/lib/GUI \
         -I$(top_srcdir)/lib/common \
        $(GTK_CFLAGS) $(GTKGLEXT_CFLAGS) $(GLADE_CFLAGS) $(FREETYPE2_CFLAGS) $(FONTCONFIG_CFLAGS)
 
-if WITH_SMYRNA
-noinst_HEADERS = draw.h glTemplate.h materials.h support.h topview.h trackball.h tvnodes.h viewport.h hier.h
-bin_PROGRAMS = smyrna
-endif
+noinst_HEADERS = draw.h glTemplate.h materials.h support.h topview.h trackball.h tvnodes.h viewport.h
+bin_PROGRAMS = gtktopview
 
-smyrna_SOURCES = topview.c viewport.c draw.c glTemplate.c main.c support.c template.c trackball.c tvnodes.c hier.c
+gtktopview_SOURCES = topview.c viewport.c draw.c glTemplate.c main.c support.c template.c trackball.c tvnodes.c
 
-smyrna_LDADD = $(top_builddir)/lib/cgraph/libcgraph_C.la \
+gtktopview_LDADD = $(top_builddir)/lib/cgraph/libcgraph_C.la \
                $(top_builddir)/lib/cdt/libcdt_C.la \
                $(top_builddir)/lib/utilities/libutilities_C.la \
                $(top_builddir)/lib/xdot/libxdot_C.la \
-               $(top_builddir)/lib/topfish/libtopfish_C.la \
                $(top_builddir)/lib/filter/libfilter_C.la \
-               $(top_builddir)/lib/gui/libgui_C.la \
+               $(top_builddir)/lib/GUI/libGUI_C.la \
                $(top_builddir)/lib/common/libcommon_C.la \
                $(GTK_LIBS) $(GTKGLEXT_LIBS) $(GLADE_LIBS) $(EXPAT_LIBS)
index 6782bda06cf8cfc44087411c500558d918b51b11..2df967b5da18f7a6773cea954471825674701bcf 100755 (executable)
@@ -21,23 +21,26 @@ XDOT DRAWING FUNCTIONS, maybe need to move them somewhere else
 */
 #include "draw.h"
 #include "topview.h"
+#include "color.h"
+#include "glutils.h"
+#include "math.h"
+
+
 //delta values
 static float dx=0.0;
 static float dy=0.0;
 
-
 GLubyte rasters [24]={
        0xc0,0x00,0xc0,0x00,0xc0,0x00,0xc0,0x00,0xc0,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)
 {
        /*copied from NEHE */
-       //Written by: David Nikdel ( ogapo@ithink.net ) 
-       //
-       
-       // Control points (substitute these values with your own if you like)
+       /*Written by: David Nikdel ( ogapo@ithink.net )*/ 
        double Ax = xp[0]; double Ay = yp[0]; double Az = zp[0];
        double Bx = xp[1]; double By = yp[1]; double Bz = zp[1];
        double Cx = xp[2]; double Cy = yp[2]; double Cz = zp[2];
@@ -49,31 +52,30 @@ void DrawBezier(GLfloat* xp,GLfloat* yp,GLfloat* zp, int filled,int param)
        // Variable
        double a = 1.0;
        double b = 1.0 - a;
-       // Tell OGL to start drawing a line strip
-       glLineWidth(view.LineWidth);
+       /* Tell OGL to start drawing a line strip*/
+       glLineWidth(view->LineWidth);
        if (!filled)
        {
 
                if (param==0)
-                       glColor4f(view.penColor.R,view.penColor.G,view.penColor.B,view.penColor.A);
+                       glColor4f(view->penColor.R,view->penColor.G,view->penColor.B,view->penColor.A);
                if (param==1)   //selected
-                       glColor4f(view.selectColor.R,view.selectColor.G,view.selectColor.B,view.selectColor.A);
-
+                       glColor4f(view->selectColor.R,view->selectColor.G,view->selectColor.B,view->selectColor.A);
                glBegin(GL_LINE_STRIP);
        }
        else
        {
                if (param==0)
-                       glColor4f(view.fillColor.R,view.fillColor.G,view.fillColor.B,view.penColor.A);
+                       glColor4f(view->fillColor.R,view->fillColor.G,view->fillColor.B,view->penColor.A);
                if (param==1)   //selected
-                       glColor4f(view.selectColor.R,view.selectColor.G,view.selectColor.B,view.selectColor.A);
+                       glColor4f(view->selectColor.R,view->selectColor.G,view->selectColor.B,view->selectColor.A);
                glBegin(GL_POLYGON);
        }
        /* We will not actually draw a curve, but we will divide the curve into small
        points and draw a line between each point. If the points are close enough, it
        will appear as a curved line. 20 points are plenty, and since the variable goes
        from 1.0 to 0.0 we must change it by 1/20 = 0.05 each time */
-       for(i = 0; i <= 20; i++)
+       for(i = 0; i <= 20; i++)        
        {
          // Get a point on the curve
                X = Ax*a*a*a + Bx*3*a*a*b + Cx*3*a*b*b + Dx*b*b*b;
@@ -99,7 +101,6 @@ void DrawBeziers(xdot_op* op,int param)
        int temp=0;
        int filled;
        int i=0;
-       float spline_kts=0;
        SelectBeziers(op);
        relocate_spline(op,param);
        if(op->kind == xd_filled_bezier)
@@ -112,27 +113,27 @@ void DrawBeziers(xdot_op* op,int param)
                if (temp==4)
                {
                        DrawBezier(tempX,tempY,tempZ,filled,param);
-                       tempX[0]=op->u.bezier.pts[i-1].x;
-                       tempY[0]=op->u.bezier.pts[i-1].y;
-                       tempZ[0]=op->u.bezier.pts[i-1].z;
+                       tempX[0]=(GLfloat)op->u.bezier.pts[i-1].x;
+                       tempY[0]=(GLfloat)op->u.bezier.pts[i-1].y;
+                       tempZ[0]=(GLfloat)op->u.bezier.pts[i-1].z;
                        temp=1;
-                       tempX[temp]=op->u.bezier.pts[i].x;                      
-                       tempY[temp]=op->u.bezier.pts[i].y;                      
-                       tempZ[temp]=op->u.bezier.pts[i].z;                      
+                       tempX[temp]=(GLfloat)op->u.bezier.pts[i].x;                     
+                       tempY[temp]=(GLfloat)op->u.bezier.pts[i].y;                     
+                       tempZ[temp]=(GLfloat)op->u.bezier.pts[i].z;                     
                        temp=temp+1;
                }
                else
                {
-                       tempX[temp]=op->u.bezier.pts[i].x;
-                       tempY[temp]=op->u.bezier.pts[i].y;
-                       tempZ[temp]=op->u.bezier.pts[i].z;
+                       tempX[temp]=(GLfloat)op->u.bezier.pts[i].x;
+                       tempY[temp]=(GLfloat)op->u.bezier.pts[i].y;
+                       tempZ[temp]=(GLfloat)op->u.bezier.pts[i].z;
                        temp=temp+1;
                }
        }
        DrawBezier(tempX,tempY,tempZ,filled,param);
 }
 
-//function to load .raw files
+/*function to load .raw files*/
 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 - 
@@ -181,58 +182,12 @@ void load_raw_texture ( char *file_name, int width, int height, int depth, GLenu
        free ( raw_bitmap );
 }
 
-//loads texture from bitmap files, bmp
-//hopefully
-int load_bitmap(char *filename) 
-{ 
-#ifdef _WIN32
-       unsigned char *l_texture;
-       int i, j=0;
-       FILE *l_file;
-       BITMAPFILEHEADER fileheader; 
-       BITMAPINFOHEADER infoheader;
-       RGBTRIPLE rgb;
-       l_file = fopen(filename, "r");
-       if(l_file==NULL)
-       {
-               printf("file could not be loaded!.\n");
-               return (-1);
-       }
-       fread(&fileheader, sizeof(fileheader), 1, l_file);
-       fseek(l_file, sizeof(fileheader), SEEK_SET);
-       fread(&infoheader, sizeof(infoheader), 1, l_file);
-       l_texture = (GLubyte *) malloc(infoheader.biWidth * infoheader.biHeight * 4);
-       memset(l_texture, 0, infoheader.biWidth * infoheader.biHeight * 4);
-       for (i=0; i < infoheader.biWidth*infoheader.biHeight; i++)
-       { 
-               fread(&rgb, sizeof(rgb), 1, l_file); 
-               l_texture[j+0] = rgb.rgbtRed; // Red component
-               l_texture[j+1] = rgb.rgbtRed; // Green component
-               l_texture[j+2] = rgb.rgbtBlue; // Blue component
-               l_texture[j+3] = 255; // Alpha value
-               j += 4; // Go to the next position
-       }
-       glBindTexture(GL_TEXTURE_2D, view.font_texture_count);
-       glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S,GL_REPEAT );
-       glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
-       glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
-       glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
-       glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
-       glTexImage2D(GL_TEXTURE_2D, 0, 4, infoheader.biWidth, infoheader.biHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, l_texture);
-       gluBuild2DMipmaps(GL_TEXTURE_2D, 4, infoheader.biWidth, infoheader.biHeight, GL_RGBA, GL_UNSIGNED_BYTE, l_texture);
-       free(l_texture);
-       return (view.font_texture_count);
-#else
-       return 0;
-#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(GLfloat x,GLfloat y,GLfloat xradius, GLfloat yradius,int filled)
 {
-       //if xradius and yradius are same values, output is circle
+       //to draw a circle set xradius and yradius same values
        GLfloat x,y,xradius,yradius;
        int i=0;
        int filled;
@@ -245,23 +200,23 @@ void DrawEllipse(xdot_op* op,int param)
        if(op->kind == xd_filled_ellipse)
        {
                if (param==0)   
-                       glColor4f(view.fillColor.R,view.fillColor.G,view.fillColor.B,view.fillColor.A);
+                       glColor4f(view->fillColor.R,view->fillColor.G,view->fillColor.B,view->fillColor.A);
                if (param==1)   //selected
-                       glColor4f(view.selectColor.R,view.selectColor.G,view.selectColor.B,view.selectColor.A);
+                       glColor4f(view->selectColor.R,view->selectColor.G,view->selectColor.B,view->selectColor.A);
 
                filled=1;
        }
        else
        {
                if (param==0)
-                       glColor4f(view.penColor.R,view.penColor.G,view.penColor.B,view.penColor.A);
+                       glColor4f(view->penColor.R,view->penColor.G,view->penColor.B,view->penColor.A);
                if (param==1)   //selected
-                       glColor4f(view.selectColor.R,view.selectColor.G,view.selectColor.B,view.selectColor.A);
+                       glColor4f(view->selectColor.R,view->selectColor.G,view->selectColor.B,view->selectColor.A);
 
                filled=0;
        }
 
-       glLineWidth(view.LineWidth);
+       glLineWidth(view->LineWidth);
        if (!filled)
                glBegin(GL_LINE_LOOP);
        else
@@ -280,16 +235,15 @@ void DrawPolygon(xdot_op* op,int param)
 {
        int i=0;
        int filled;
-       int select=0;
        SelectPolygon(op);
        set_options(op,param);
 
        if(op->kind == xd_filled_polygon)
        {
                if(param==0)
-                       glColor4f(view.fillColor.R,view.fillColor.G,view.fillColor.B,view.fillColor.A);
+                       glColor4f(view->fillColor.R,view->fillColor.G,view->fillColor.B,view->fillColor.A);
                if (param==1)   //selected
-                       glColor4f(view.selectColor.R,view.selectColor.G,view.selectColor.B,view.selectColor.A);
+                       glColor4f(view->selectColor.R,view->selectColor.G,view->selectColor.B,view->selectColor.A);
 
                filled=1;
        }
@@ -297,46 +251,45 @@ void DrawPolygon(xdot_op* op,int param)
        {       
                filled=0;
                if(param==0)
-                       glColor4f(view.penColor.R,view.penColor.G,view.penColor.B,view.penColor.A);
+                       glColor4f(view->penColor.R,view->penColor.G,view->penColor.B,view->penColor.A);
                if (param==1)   //selected
-                       glColor4f(view.selectColor.R,view.selectColor.G,view.selectColor.B,view.selectColor.A);
+                       glColor4f(view->selectColor.R,view->selectColor.G,view->selectColor.B,view->selectColor.A);
 
        }
-       glLineWidth(view.LineWidth);
+       glLineWidth(view->LineWidth);
        if (!filled)
                glBegin(GL_LINE_STRIP);
        else
                glBegin(GL_POLYGON);
        for (i=0;i < op->u.polygon.cnt ; i=i+1)
        {
-               glVertex3f(op->u.polygon.pts[i].x-dx,op->u.polygon.pts[i].y-dy,op->u.polygon.pts[i].z);
+               glVertex3f((GLfloat)op->u.polygon.pts[i].x-dx,(GLfloat)op->u.polygon.pts[i].y-dy,(GLfloat)op->u.polygon.pts[i].z);
        }       
-       glVertex3f(op->u.polygon.pts[0].x-dx,op->u.polygon.pts[0].y-dy,op->u.polygon.pts[0].z); //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);      //close the polygon
        glEnd();
 }
 
 void DrawPolyline(xdot_op* op,int param)
 {
        int i=0;
-       int select=0;
        if(param==0)    
-               glColor4f(view.penColor.R,view.penColor.G,view.penColor.B,view.penColor.A);
+               glColor4f(view->penColor.R,view->penColor.G,view->penColor.B,view->penColor.A);
        if (param==1)   //selected
-               glColor4f(view.selectColor.R,view.selectColor.G,view.selectColor.B,view.selectColor.A);
+               glColor4f(view->selectColor.R,view->selectColor.G,view->selectColor.B,view->selectColor.A);
        SelectPolyline(op);
        set_options(op,param);
-       glLineWidth(view.LineWidth);
+       glLineWidth(view->LineWidth);
        glBegin(GL_LINE_STRIP);
        for (i=0;i < op->u.polyline.cnt ; i=i+1)
        {
-               glVertex3f(op->u.polyline.pts[i].x-dx,op->u.polyline.pts[i].y-dy,op->u.polyline.pts[i].z);
+               glVertex3f((GLfloat)op->u.polyline.pts[i].x-dx,(GLfloat)op->u.polyline.pts[i].y-dy,(GLfloat)op->u.polyline.pts[i].z);
        }       
        glEnd();
 }
 
 void DrawBitmap(GLfloat bmpX,GLfloat bmpY,GLfloat bmpW,GLfloat bmpH)
 {
-  if(view.texture)
+  if(view->texture)
          glEnable( GL_TEXTURE_2D );
   else
          glDisable( GL_TEXTURE_2D );
@@ -355,19 +308,19 @@ void SetFillColor(xdot_op* op,int param)
 {
        RGBColor c;
        c=GetRGBColor(op->u.color);
-       view.fillColor.R=c.R;
-       view.fillColor.G=c.G;
-       view.fillColor.B=c.B;
-       view.fillColor.A=c.A;
+       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)
 {
        RGBColor c;
        c=GetRGBColor(op->u.color);
-       view.penColor.R=c.R;
-       view.penColor.G=c.G;
-       view.penColor.B=c.B;
-       view.penColor.A=c.A;
+       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)
@@ -378,8 +331,8 @@ void SetStyle(xdot_op* op,int param)
 
 void SetFont(xdot_op* op,int param)
 {
-//     view.FontName=ABSet(op->u.font.name);
-       view.FontSize=op->u.font.size;
+//     view->FontName=ABSet(op->u.font.name);
+       view->FontSize=op->u.font.size;
 }
 
 void InsertImage(xdot_op* op,int param)
@@ -393,39 +346,39 @@ void EmbedText(xdot_op* op,int param)
        SelectText(op);
        set_options(op,param);
        if (op->u.text.align == 1)
-               x=op->u.text.x-op->u.text.width/2;
+               x=(GLfloat)op->u.text.x-(GLfloat)op->u.text.width/2.0;
        if (op->u.text.align == 0)
-               x=op->u.text.x;
+               x=(GLfloat)op->u.text.x;
        if (op->u.text.align == -1)
-               x=op->u.text.x+op->u.text.width;
-       fontSize (view.FontSize);
+               x=(GLfloat)op->u.text.x+op->u.text.width;
+       fontSize (view->FontSize);
        if(param==0)
-               fontColor (view.penColor.R,view.penColor.G,view.penColor.B);
+               fontColor (view->penColor.R,view->penColor.G,view->penColor.B);
        if (param==1)   //selected
-               fontColor (view.selectColor.R,view.selectColor.G,view.selectColor.B);
+               fontColor (view->selectColor.R,view->selectColor.G,view->selectColor.B);
 
-       fontDrawString (x-dx,op->u.text.y-dy,op->u.text.text,op->u.text.width);
+       fontDrawString ((int)(x-dx),op->u.text.y-(int)dy,op->u.text.text,op->u.text.width);
 }
 
 
-void draw_selection_box()
+void draw_selection_box(ViewInfo* view)
 {
-       if(view.mouse.mouse_down==1)    //rectangle selection
+       if(((view->mouse.mouse_mode==4) || (view->mouse.mouse_mode==5))&& view->mouse.mouse_down)
        {
-               glColor4f(view.Selection.SelectionColor.R,view.Selection.SelectionColor.G,view.Selection.SelectionColor.B,view.Selection.SelectionColor.A);
-               if(view.mouse.mouse_mode==5)
+               glColor4f(view->Selection.SelectionColor.R,view->Selection.SelectionColor.G,view->Selection.SelectionColor.B,view->Selection.SelectionColor.A);
+               if(view->mouse.mouse_mode==5)
                {
                        glEnable(GL_LINE_STIPPLE);
                        glLineStipple(1,15);
                }
                glBegin(GL_LINE_STRIP);
-               glVertex3f(view.GLx,view.GLy,0.001);
-               glVertex3f(view.GLx,view.GLy2,0.001);
-               glVertex3f(view.GLx2,view.GLy2,0.001);
-               glVertex3f(view.GLx2,view.GLy,0.001);
-               glVertex3f(view.GLx,view.GLy,0.001);
+               glVertex3f((GLfloat)view->GLx,(GLfloat)view->GLy,(GLfloat)0.001);
+               glVertex3f((GLfloat)view->GLx,(GLfloat)view->GLy2,(GLfloat)0.001);
+               glVertex3f((GLfloat)view->GLx2,(GLfloat)view->GLy2,(GLfloat)0.001);
+               glVertex3f((GLfloat)view->GLx2,(GLfloat)view->GLy,(GLfloat)0.001);
+               glVertex3f((GLfloat)view->GLx,(GLfloat)view->GLy,(GLfloat)0.001);
                glEnd();
-               if(view.mouse.mouse_mode==5)
+               if(view->mouse.mouse_mode==5)
                        glDisable(GL_LINE_STIPPLE);
 
        }
@@ -434,10 +387,10 @@ void draw_selection_box()
 void set_options(xdot_op* op,int param)
 {
        
-       if ((param==1) && (view.mouse.mouse_mode==10) && (view.mouse.mouse_down==1))    //selected, if there is move move it, experimental
+       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;
+               dx=view->GLx-view->GLx2;
+               dy=view->GLy-view->GLy2;
        }
        else
        {
@@ -464,14 +417,14 @@ void relocate_spline(xdot_op* op,int param)
                        {
                                if((dx != 0) || (dy != 0))
                                {
-                                       op->u.bezier.pts[i].x=op->u.bezier.pts[i].x-(dx*(float)i/(float)(op->u.bezier.cnt));
-                                       op->u.bezier.pts[i].y=op->u.bezier.pts[i].y-(dy*(float)i/(float)(op->u.bezier.cnt));
+                                       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-dx;
-                               op->u.bezier.pts[op->u.bezier.cnt-1].y=op->u.bezier.pts[op->u.bezier.cnt-1].y-dy;
+                               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 ( (((custom_object_data*)AGDATA(hn))->Selected==0)&&(((custom_object_data*)AGDATA(tn))->Selected==1))
@@ -481,14 +434,14 @@ void relocate_spline(xdot_op* op,int param)
                        {
                                if((dx != 0) || (dy != 0))
                                {
-                                       op->u.bezier.pts[i].x=op->u.bezier.pts[i].x-(dx*(float)(op->u.bezier.cnt-i)/(float)(op->u.bezier.cnt));
-                                       op->u.bezier.pts[i].y=op->u.bezier.pts[i].y-(dy*(float)(op->u.bezier.cnt-i)/(float)(op->u.bezier.cnt));
+                                       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-dx;
-                               op->u.bezier.pts[0].y=op->u.bezier.pts[0].y-dy;
+                               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;
                        }
                }
 
@@ -499,8 +452,8 @@ void relocate_spline(xdot_op* op,int param)
                        {
                                if((dx != 0) || (dy != 0))
                                {
-                                       op->u.bezier.pts[i].x=op->u.bezier.pts[i].x-dx;
-                                       op->u.bezier.pts[i].y=op->u.bezier.pts[i].y-dy;
+                                       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;
                                }
                        }
                }
@@ -510,61 +463,40 @@ void relocate_spline(xdot_op* op,int param)
 
 }
 
-void draw_letter(GLfloat x,GLfloat y,char c)
-{
-       glRasterPos2i((int)x,(int)y);
-       glBitmap(10,12,0.0,0.0,0.0,0.0,rasters);
-}
-int font_display_list()
-{
-       int a;
-       a=glGenLists(6);
-       //draw 5 Fs
-       glNewList(a,GL_COMPILE);
-       draw_letter(0,0,0);
-       draw_letter(0,0,0);
-       draw_letter(0,0,0);
-       draw_letter(0,0,0);
-       draw_letter(0,0,0);
-       draw_letter(0,0,0);
-       glEndList();
-       return a;
-}
-void draw_cached_letter(GLfloat x,GLfloat y,int letter)
-{
-/*     glPushMatrix();
-       glTranslatef (view.panx+x,view.pany+y,view.zoom);
-       glCallList (view.fontbase+letter-1);
-       glPopMatrix(); */
-
-}
-void draw_magnifier()
+void draw_magnifier(ViewInfo* view)
 {
        
-       if((view.mouse.mouse_mode==MM_MAGNIFIER) && (view.mouse.mouse_down))
+       if((view->mouse.mouse_mode==MM_MAGNIFIER) && (view->mouse.mouse_down))
        {
 
                GLfloat mg_x,mg_y,mg_z,mg_width,mg_height;
                float a;
                int winX,winY,winW,winH;
                //converting screen pixel distaances to GL distances
-               view.mg.GLwidth=GetOGLDistance(view.mg.width)/2.0;
-               view.mg.GLheight=GetOGLDistance(view.mg.height)/2.0;
-               GetOGLPosRef(view.mouse.mouse_X,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;
+               view->mg.GLwidth=GetOGLDistance(view->mg.width)/2.0;
+               view->mg.GLheight=GetOGLDistance(view->mg.height)/2.0;
+               GetOGLPosRef(view->mouse.mouse_X,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);
-               local_zoom(&Topview);
+               local_zoom(&view->Topview);
                //drawing the magnifier borders
                glBegin(GL_LINE_STRIP);
-               glColor4f(0.3,0.1,0.8,1);
-               glVertex3f(view.mg.x-view.mg.GLwidth,view.mg.y-view.mg.GLheight,0.0);
-               glVertex3f(view.mg.x+view.mg.GLwidth,view.mg.y-view.mg.GLheight,0.0);
-               glVertex3f(view.mg.x+view.mg.GLwidth,view.mg.y+view.mg.GLheight,0.0);
-               glVertex3f(view.mg.x-view.mg.GLwidth,view.mg.y+view.mg.GLheight,0.0);
-               glVertex3f(view.mg.x-view.mg.GLwidth,view.mg.y-view.mg.GLheight,0.0);
+               glColor4f((GLfloat)0.3,(GLfloat)0.1,(GLfloat)0.8,(GLfloat)1);
+               glVertex3f(view->mg.x-view->mg.GLwidth,view->mg.y-view->mg.GLheight,Z_MIDDLE_PLANE);
+               glVertex3f(view->mg.x+view->mg.GLwidth,view->mg.y-view->mg.GLheight,Z_MIDDLE_PLANE);
+               glVertex3f(view->mg.x+view->mg.GLwidth,view->mg.y+view->mg.GLheight,Z_MIDDLE_PLANE);
+               glVertex3f(view->mg.x-view->mg.GLwidth,view->mg.y+view->mg.GLheight,Z_MIDDLE_PLANE);
+               glVertex3f(view->mg.x-view->mg.GLwidth,view->mg.y-view->mg.GLheight,Z_MIDDLE_PLANE);
+               glEnd();
+               glBegin(GL_TRIANGLE_FAN);
+               glColor4f(1,1,1,1);
+               glVertex3f(view->mg.x-view->mg.GLwidth+1,view->mg.y-view->mg.GLheight+1,Z_MIDDLE_PLANE);
+               glVertex3f(view->mg.x+view->mg.GLwidth-1,view->mg.y-view->mg.GLheight+1,Z_MIDDLE_PLANE);
+               glVertex3f(view->mg.x+view->mg.GLwidth-1,view->mg.y+view->mg.GLheight-1,Z_MIDDLE_PLANE);
+               glVertex3f(view->mg.x-view->mg.GLwidth+1,view->mg.y+view->mg.GLheight-1,Z_MIDDLE_PLANE);
+               glVertex3f(view->mg.x-view->mg.GLwidth+1,view->mg.y-view->mg.GLheight+1,Z_MIDDLE_PLANE);
                glEnd();
-
                glLineWidth(1);
        }
 
@@ -572,23 +504,23 @@ void draw_magnifier()
 
 
 
-void draw_fisheye_magnifier()
+void draw_fisheye_magnifier(ViewInfo* view)
 {
-       if((view.mouse.mouse_mode==21)  && (view.mouse.mouse_down))
+       if((view->mouse.mouse_mode==21)  && (view->mouse.mouse_down))
        {
                float a;
                GLfloat mg_x,mg_y,mg_z,mg_width,mg_height;
-               a=GetOGLDistance(250);
-               view.fmg.R=a;
-               GetOGLPosRef(view.mouse.mouse_X,view.mouse.mouse_Y,&mg_x,&mg_y,&mg_z);
+               a=GetOGLDistance((int)250);
+               view->fmg.R=a;
+               GetOGLPosRef(view->mouse.mouse_X,view->mouse.mouse_Y,&mg_x,&mg_y,&mg_z);
                glColor4f(0.3,0.1,0.8,1);
-               if ((view.fmg.x != mg_x) || (view.fmg.y != mg_y))
+               if ((view->fmg.x != mg_x) || (view->fmg.y != mg_y))
                {
-                       fisheye_polar(mg_x, mg_y,&Topview);
+                       fisheye_polar(mg_x, mg_y,view->Topview);
                        draw_circle(mg_x,mg_y,a);
                }
-               view.fmg.x=mg_x;
-               view.fmg.y=mg_y;
+               view->fmg.x=mg_x;
+               view->fmg.y=mg_y;
 
        }
 }
@@ -602,28 +534,144 @@ void draw_circle(float originX,float originY,float radius)
        vectorX1=originX;
        glLineWidth(4);
        glBegin(GL_LINE_STRIP);                 
-       for(angle=0.0f;angle<=(2.1f*3.14159);angle+=0.1f)
+       for(angle=0.0;angle<=(2.1*3.14159);angle+=0.1)
        {               
-               vectorX=originX+(radius*(float)sin((double)angle));
-               vectorY=originY+(radius*(float)cos((double)angle));             
+               vectorX=originX+radius*sin(angle);
+               vectorY=originY+radius*cos(angle);              
                glVertex2d(vectorX1,vectorY1);
-               vectorY1=vectorY;
-       vectorX1=vectorX;                       
+                       vectorY1=vectorY;
+                       vectorX1=vectorX;                       
        }
        glEnd();
        glLineWidth(1);
 
 }
+void drawBorders(ViewInfo* view)
+{
+       if(view->bdVisible)
+       {
+               glColor4f(0.8,0.1,0.1,1);
+               glLineWidth(3);
+               glBegin(GL_LINE_STRIP);                 
+               glVertex2d(view->bdxLeft,view->bdyBottom);
+               glVertex2d(view->bdxRight,view->bdyBottom);
+               glVertex2d(view->bdxRight,view->bdyTop);
+               glVertex2d(view->bdxLeft,view->bdyTop);
+               glVertex2d(view->bdxLeft,view->bdyBottom);
+               glEnd();
+               glLineWidth(1);
+       }
+
+
+}
+
+
+void drawGraph(Agraph_t *g)
+{
+       Agnode_t *v;
+       Agedge_t *e;
+       Agraph_t *s;
+       int param=0;
+
+       for (s = agfstsubg(g); s; s = agnxtsubg(s))
+       {
+
+                       ((custom_object_data*)AGDATA(s))->selectionflag=0;
+                       if( ((custom_object_data*)AGDATA(s))->Selected==1)
+                               param=1;
+                       else
+                               param=0;
+                       drawXdotwithattrs(s,param);
+       }
+               
+       for (v = agfstnode(g); v; v = agnxtnode(g, v))
+       {
+               if( ((custom_object_data*)AGDATA(v))->Selected==1)
+                       param=1;
+               else
+                       param=0;
+               ((custom_object_data*)AGDATA(v))->selectionflag=0;
+               drawXdotwithattr(v,"_draw_",param);
+               drawXdotwithattr(v,"_ldraw_",param);
+               for (e = agfstout(g,v) ; e ; e = agnxtout (g,e))
+               {
+                       ((custom_object_data*)AGDATA(e))->selectionflag=0;
+                       if( ((custom_object_data*)AGDATA(e))->Selected==1)
+                               param=1;
+                       else
+                               param=0;
+
+                       drawXdotwithattrs(e,param);
+
+               }
+       }
+       if((view->Selection.Active>0) && (!view->SignalBlock))
+       {
+               view->Selection.Active=0;
+               drawGraph(g);
+               view->SignalBlock=1;
+                       expose_event (view->drawing_area,NULL,NULL);
+               view->SignalBlock=0;
+       }
+
+}
+
+int randomize_color(RGBColor* c,int brightness)
+{
+       float R,B,G;
+       float add;
+       R=(float)(rand() % 255) / 255.0;
+       G=(float)(rand() % 255) / 255.0;
+       B=(float)(rand() % 255) / 255.0;
+       add=(brightness-(R+G+B))/3;
+       R = R;
+       G = G;
+       B = B;
+       c->R=R;
+       c->G=G;
+       c->B=B;
+}
 
-int point_within_ellips_with_coords(float ex,float ey,float ea,float eb,float px,float py)
+
+void drawCircle(float x,float y,float radius,float zdepth)
 {
+       int i;
+       if(radius <0.3)
+               radius=0.4;
+       glBegin(GL_POLYGON);
+       for (i=0; i < 360; i=i+10)
+   {
+      float degInRad = i*DEG2RAD;
+      glVertex3f(x+cos(degInRad)*radius,y+sin(degInRad)*radius,zdepth);
+   }
+   glEnd();
+}
 
-       float dx,dy;
-       float a;
-       dx = px - ex;
-       dy = py - ey;
-       a=(dx*dx)/(ea*ea) + (dy*dy)/(eb*eb);
-       return (a <= 1);
+RGBColor GetRGBColor(char* color)
+{
+       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;
+       }
+       return c;
 }
 
 
+
+
+
+
index c30ac8b4585b503eeed8c568bfd95538975dfad7..33d75e9b7db8c54dd6bd4d056ca26d71947c20d7 100755 (executable)
 
 #ifndef DRAW_H
 #define DRAW_H
-#include "viewport.h"
+#include "smyrnadefs.h"
 #include <gtk/gtkgl.h>
+#include "xdot.h"
 #include <stdlib.h>
 #include <string.h>
 #include <math.h>
-#include <pango/pangoft2.h>
 
-//#include "xdot.h"
+#define Z_MIDDLE_PLANE  -0.00200
+#define Z_BACK_PLANE   -0.00201
+#define Z_FORWARD_PLANE -0.00199
 
-#define ANGLE   30.0
-/* tan (ANGLE * PI / 180.0) */
-#define TANGENT 0.57735
-
-#define TEXT_Z_NEAR  2.0
-#define TEXT_Z_FAR  0.0
-#define TEXT_Z_DIFF  0.005
-
-static GLfloat text_z = TEXT_Z_NEAR;
-static const char *text = "ABCD adasd";
-static PangoContext *ft2_context=NULL;
-
-//DRAWING FUNCTIONS
+/*DRAWING FUNCTIONS 
+these are opengl based xdot drawing functions 
+topview drawings are not here*/
 void DrawBezier(GLfloat* xp,GLfloat* yp,GLfloat* zp, int filled, int param);
 void DrawBeziers(xdot_op* op,int param);
 void DrawEllipse(xdot_op* op,int param);
@@ -52,15 +44,17 @@ void EmbedText(xdot_op* op,int param);
 void InsertImage(xdot_op* op,int param);
 void load_raw_texture ( char *file_name, int width, int height, int depth, GLenum colour_type, GLenum filter_type ); //function to load .raw files
 int load_bitmap(char *filename);
-void draw_selection_box();
+void drawGraph(Agraph_t *g);
+void draw_selection_box(ViewInfo* view);
 void set_options(xdot_op*,int param);
 void relocate_spline(xdot_op*,int param);
-void draw_letter(GLfloat x,GLfloat y,char c);
-int font_display_list();
-void draw_cached_letter(GLfloat x,GLfloat y,int letter);
-void draw_magnifier();
+void draw_magnifier(ViewInfo* view);
 void draw_circle(float originX,float originY,float radius);
-void draw_fisheye_magnifier();
-//int point_within_ellipse(float ex,float ey,float ea,float eb,float px,float py);
+void draw_fisheye_magnifier(ViewInfo* view);
+int randomize_color(RGBColor* c,int brightness);
+void drawCircle(float x,float y,float radius,float zdepth);
+RGBColor GetRGBColor(char* color);
+void drawBorders(ViewInfo* view);
+
 #endif
 
index ad6f939edc1f3a0915cba31595ffe519c541e88c..e0f63d557c3115b63ad9ebbb1005d30f1a0245fb 100755 (executable)
 *              AT&T Research, Florham Park NJ             *
 **********************************************************/
 
+#include <stdlib.h>
+#include <math.h>
 #include "gui.h"
-#include "glTemplate.h"
 #include "viewport.h"
 #include "topview.h"
-
-xdot* testxdot;
-GtkWidget *drawing_area;
-
+#include "glTemplate.h"
+#include "glutils.h"
+#include "glexpose.h"
+#include "glmenu.h"
+#include "selection.h"
 static float begin_x = 0.0;
 static float begin_y = 0.0;
-
 static float dx = 0.0;
 static float dy = 0.0;
-static guint idle_id = 0;
-static GLfloat w,h;
-void
-init_view (void)
-{
-  view_quat[0] = view_quat_diff[0] = 0.0;
-  view_quat[1] = view_quat_diff[1] = 0.0;
-  view_quat[2] = view_quat_diff[2] = 0.0;
-  view_quat[3] = view_quat_diff[3] = 1.0;
-  view_scale = 1.0;
-}
-void
-examine_gl_config_attrib (GdkGLConfig *glconfig)
+
+/*
+       test opengl parameters, configuration.Run this function to see machine's open gl capabilities
+       params:gtk gl config class ,gtk takes care of all these tests
+       return value:none
+*/
+void examine_gl_config_attrib (GdkGLConfig *glconfig)
 {
   g_print ("\nOpenGL visual configurations :\n\n");
-
   g_print ("gdk_gl_config_is_rgba (glconfig) = %s\n",
            gdk_gl_config_is_rgba (glconfig) ? "TRUE" : "FALSE");
   g_print ("gdk_gl_config_is_double_buffered (glconfig) = %s\n",
@@ -57,9 +51,7 @@ examine_gl_config_attrib (GdkGLConfig *glconfig)
            gdk_gl_config_has_stencil_buffer (glconfig) ? "TRUE" : "FALSE");
   g_print ("gdk_gl_config_has_accum_buffer (glconfig) = %s\n",
            gdk_gl_config_has_accum_buffer (glconfig) ? "TRUE" : "FALSE");
-
   g_print ("\n");
-
   print_gl_config_attrib (glconfig, "GDK_GL_USE_GL",           GDK_GL_USE_GL,           TRUE);
   print_gl_config_attrib (glconfig, "GDK_GL_BUFFER_SIZE",      GDK_GL_BUFFER_SIZE,      FALSE);
   print_gl_config_attrib (glconfig, "GDK_GL_LEVEL",            GDK_GL_LEVEL,            FALSE);
@@ -77,12 +69,15 @@ examine_gl_config_attrib (GdkGLConfig *glconfig)
   print_gl_config_attrib (glconfig, "GDK_GL_ACCUM_GREEN_SIZE", GDK_GL_ACCUM_GREEN_SIZE, FALSE);
   print_gl_config_attrib (glconfig, "GDK_GL_ACCUM_BLUE_SIZE",  GDK_GL_ACCUM_BLUE_SIZE,  FALSE);
   print_gl_config_attrib (glconfig, "GDK_GL_ACCUM_ALPHA_SIZE", GDK_GL_ACCUM_ALPHA_SIZE, FALSE);
-
   g_print ("\n");
 }
 
-void
-print_gl_config_attrib (GdkGLConfig *glconfig,
+/*
+       test single opengl parameter, all visual , it doesnt return a value
+       params:gtk gl config class , attribute name and id,if boolean expected send is_boolean true
+       return value:none
+*/
+void print_gl_config_attrib (GdkGLConfig *glconfig,
                         const gchar *attrib_str,
                         int          attrib,
                         gboolean     is_boolean)
@@ -101,42 +96,39 @@ print_gl_config_attrib (GdkGLConfig *glconfig,
     g_print ("*** Cannot get %s attribute value\n", attrib_str);
 }
 
-
-static void
-realize (GtkWidget *widget,
-        gpointer   data)
+/*
+       initialize the gl , run only once!!
+       params:gtk opgn gl canvas and optional data pointer
+       return value:none
+*/
+static void realize (GtkWidget *widget,gpointer   data)
 {
+
        GdkGLContext *glcontext = gtk_widget_get_gl_context (widget);
        GdkGLDrawable *gldrawable = gtk_widget_get_gl_drawable (widget);
 
+       /*smyrna does not use any ligthting affects but can be turned on for more effects in the future*/
        GLfloat ambient[] = {0.0, 0.0, 0.0, 1.0};
        GLfloat diffuse[] = {1.0, 1.0, 1.0, 1.0};
        GLfloat position[] = {0.0, 3.0, 3.0, 0.0};
 
-       GLfloat lmodel_ambient[] = {0.2, 0.2, 0.2, 1.0};
+       GLfloat lmodel_ambient[] = {0.2f, 0.2f, 0.2f, 1.0f};
        GLfloat local_view[] = {0.0};
-  GLuint texture;
-
 
-       init_viewport(&view);
 
-//  if(add_graph_to_viewport_from_file ("C:/GTK/2.0/bin/awilliams.dot"))
-//     if(add_graph_to_viewport_from_file ("c:/__tempfileneato.xdot"))
-       //load default font
-       //
 #ifdef WIN32
-#define SMYRNA_FONT "C:/arial.tga"
+#define SMYRNA_OPENGL_FONT "c:/arial.tga"
 // #else
-// using -DSMYRNA_FONT from Makefile.am and configure.ac
+// using -DGTKTOPVIEW_FONT from Makefile.am and configure.ac
 #endif
 
-  g_print("loading font....%i\n",fontLoad(SMYRNA_FONT));
+  g_print("loading font....%i\n",fontLoad(SMYRNA_OPENGL_FONT));
 
   /*** OpenGL BEGIN ***/
   if (!gdk_gl_drawable_gl_begin (gldrawable, glcontext))
     return;
 
-  glClearColor (view.bgColor.R,view.bgColor.G, view.bgColor.B,view.bgColor.A); //background color
+  glClearColor (view->bgColor.R,view->bgColor.G, view->bgColor.B,view->bgColor.A);     //background color
   glClearDepth (1.0);
 
   glLightfv (GL_LIGHT0, GL_AMBIENT, ambient);
@@ -146,7 +138,7 @@ realize (GtkWidget *widget,
   glLightModelfv (GL_LIGHT_MODEL_LOCAL_VIEWER, local_view);
 
   glFrontFace (GL_CW);
- // glEnable (GL_LIGHTING);
+// glEnable (GL_LIGHTING);
 //  glEnable (GL_LIGHT0);
   glEnable (GL_AUTO_NORMAL);
   glEnable (GL_NORMALIZE);
@@ -156,238 +148,160 @@ realize (GtkWidget *widget,
 
   gdk_gl_drawable_gl_end (gldrawable);
   /*** OpenGL END ***/
-//create fonts
   return;
 }
 
-static gboolean
-configure_event (GtkWidget         *widget,
-                GdkEventConfigure *event,
-                gpointer           data)
+/*
+       set up GL for window size changes, run this when necesary (when window size or monitor resolution is changed)
+       params:gtk opgn gl canvas , GdkEventConfigure object to retrieve window dimensions and custom data
+       return value:true or false, fails (false) if cannot init gl
+*/
+static gboolean configure_event (GtkWidget* widget, GdkEventConfigure *event,gpointer data)
 {
-
-  GLfloat x,y,z;
     int vPort[4];
-  float aspect;
-  int id;      
-
-       
-GdkGLContext *glcontext = gtk_widget_get_gl_context (widget);
-  GdkGLDrawable *gldrawable = gtk_widget_get_gl_drawable (widget);
-
-
-  w = widget->allocation.width;
-  h = widget->allocation.height;
-
-
-  /*** OpenGL BEGIN ***/
-  if (!gdk_gl_drawable_gl_begin (gldrawable, glcontext))
-    return FALSE;
-
-  glViewport (0, 0, w, h);
-
+       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;
+       /*** OpenGL BEGIN ***/
+       if (!gdk_gl_drawable_gl_begin (gldrawable, glcontext))
+               return FALSE;
+       glViewport (0, 0, view->w, view->h);
     /* get current viewport */
     glGetIntegerv (GL_VIEWPORT, vPort);
     /* setup various opengl things that we need */
-  glMatrixMode (GL_PROJECTION);
-  glLoadIdentity ();
-  if (w > h)
+       glMatrixMode (GL_PROJECTION);
+       glLoadIdentity ();
+       if (view->w > view->h)
     {
-      aspect = w / h;
-      glFrustum (-aspect*100, aspect*100, -100.0, 100.0, 1 ,90);
-//      glFrustum (-aspect, aspect, -1.0, 1.0, 5.0, 90.0);
-//             glOrtho(-aspect*100, aspect*100, -100.0, 100.0, 5, 90);
-
-  }
-  else
+               aspect = (float)view->w / (float)view->h;
+               glFrustum (-aspect*100, aspect*100, -100.0, 100.0, 1 ,90);
+       }
+       else
     {
-      aspect = h / w;
-      glFrustum (-100.0, 100.0, -aspect*100, aspect*100,1, 90);
-//      glFrustum (-1.0, 1.0, -aspect, aspect, 5.0, 90.0);
-//             glOrtho(-100.0, 100.0, -aspect*100, aspect*100,5, 90);
+               aspect = (float)view->h / (float)view->w;
+               glFrustum (-100.0, 100.0, -aspect*100, aspect*100,1, 90);
     }
 
-  glMatrixMode (GL_MODELVIEW);
-  gdk_gl_drawable_gl_end (gldrawable);
-
-  /*** OpenGL END ***/
-
-
-  return TRUE;
+       glMatrixMode (GL_MODELVIEW);
+       gdk_gl_drawable_gl_end (gldrawable);
+       /*** OpenGL END ***/
+       return TRUE;
 }
 
-
-static GLuint id_text=NULL;
-
-gboolean
-expose_event (GtkWidget      *widget,
-             GdkEventExpose *event,
-             gpointer        data)
+/*
+       expose function.real drawing takes place here, 
+       params:gtk opgn gl canvas , GdkEventExpose object and custom data
+       return value:true or false, fails (false) if cannot init gl
+*/
+gboolean expose_event (GtkWidget* widget,GdkEventExpose* event,gpointer data)
 {
        GdkGLContext *glcontext = gtk_widget_get_gl_context (widget);
        GdkGLDrawable *gldrawable = gtk_widget_get_gl_drawable (widget);
-       xdot* xDot;
-  GLfloat x,y,z;
-  GLfloat m[4][4];
-
-
-
        /*** OpenGL BEGIN ***/
        if (!gdk_gl_drawable_gl_begin (gldrawable, glcontext))
                return FALSE;
-
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
        glLoadIdentity ();
-
-       /* View transformation. */
-       //0 center for x -> for y to up
-//     glTranslatef (view.panx,view.pany,-20);
-//     glTranslatef (1,1,view.zoom/5);
-       gluLookAt(view.panx,view.pany,view.zoom*-1,view.panx,view.pany,0.0,0.0,1.0,0.0);
-
-//     glScalef (view.zoom/2,view.zoom/2,view.zoom/2*-1);
-
-//     add_quats (view_quat_diff, view_quat, view_quat);
-//     build_rotmatrix (m, view_quat);
-//     glMultMatrixf (&m[0][0]);
-
-//update view clip region values
-  GetOGLPosRef(1,(int)h-5,&view.clipX1,&view.clipY1,&view.clipZ1);
-  GetOGLPosRef((int)w-1,1,&view.clipX2,&view.clipY2,&view.clipZ2);
-  DrawView();
-  if(((view.mouse.mouse_mode==4) || (view.mouse.mouse_mode==5))&& view.mouse.mouse_down)
-               draw_selection_box();
-
-/*     if((view.mouse_mode==10) && view.mousedown)
-               move_nodes(view.g[view.activeGraph],view.GLx2-view.GLx,view.GLy2-view.GLy);     //move selected nodes*/ 
-
-
-
-       //drawing grids
-       if(view.gridVisible)
-       {
-               glPointSize     (1);
-               glBegin(GL_POINTS);
-               glColor4f(view.grR,view.grG,view.grB,view.grA);
-               for (x=view.bdxLeft; x <= view.bdxRight;x=x +view.gridSize)
-               {
-                       for (y=view.bdyBottom; y <=view.bdyTop ;y=y +view.gridSize)
-                       {
-                                       glVertex3f(x,y,0);                      
-                       }
-               }
-               glEnd();
-       }
-       draw_fisheye_magnifier();
-       draw_magnifier();
+       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 ***/
-  return TRUE;
+       return TRUE;
 }
-static gboolean
-button_press_event (GtkWidget      *widget,
-                   GdkEventButton *event,
-                   gpointer        data)
-{
-       if (animate)
-    {
-      if (event->button == 1)
-        toggle_animation (widget);
-    }
-  else
-    {
-      view_quat_diff[0] = 0.0;
-      view_quat_diff[1] = 0.0;
-      view_quat_diff[2] = 0.0;
-      view_quat_diff[3] = 1.0;
-    }
 
+/*
+       when a mouse button is clicked this function is called
+       params:gtk opgn gl canvas , GdkEventButton object and custom data
+       return value:true or false, fails (false) if cannot init gl
+*/
+static gboolean button_press_event (GtkWidget* widget,GdkEventButton *event,gpointer data)
+{
+        if(view->graphCount)
+        {
+               if(glCompSetClick(view->Topview->topviewmenu,event->x,event->y))
+                       expose_event (view->drawing_area,NULL,NULL);
+        }
 
        begin_x = event->x;
        begin_y = event->y;
 
 
-       if(event->button==1)
-       {
-               view.mouse.mouse_down=1;
-               if(GetOGLPos(begin_x,begin_y))
+               if(event->button==1)    //left click
                {
-                       if (view.mouse.mouse_mode == MM_SINGLE_SELECT)  //single select
+                       view->mouse.mouse_down=1;
+                       if(GetOGLPosRef(begin_x,begin_y,&(view->GLx),&(view->GLy),&(view->GLz)))
                        {
-                               view.Selection.Active=1;
-                               view.Selection.Type=0;
-                               view.Selection.AlreadySelected=0;
-                               view.Selection.X=view.GLx-SINGLE_SELECTION_WIDTH/2;
-                               view.Selection.Y=view.GLy-SINGLE_SELECTION_WIDTH/2;
-                               view.Selection.W=SINGLE_SELECTION_WIDTH;
-                               view.Selection.H=SINGLE_SELECTION_WIDTH;
-                               expose_event (drawing_area,NULL,NULL);
+                               if (view->mouse.mouse_mode == MM_SINGLE_SELECT) //single select
+                               {
+                                       view->Selection.Active=1;
+                                       view->Selection.Type=0;
+                                       view->Selection.AlreadySelected=0;
+                                       view->Selection.X=view->GLx-SINGLE_SELECTION_WIDTH/2;
+                                       view->Selection.Y=view->GLy-SINGLE_SELECTION_WIDTH/2;
+                                       view->Selection.W=SINGLE_SELECTION_WIDTH;
+                                       view->Selection.H=SINGLE_SELECTION_WIDTH;
+                                       expose_event (view->drawing_area,NULL,NULL);
+                               }
                        }
-                       view.prevpanx=view.panx;
-                       view.prevpany=view.pany;
                }
-       }       
        return FALSE;
 }
 
-static gboolean
-button_release_event (GtkWidget      *widget,
-                      GdkEventButton *event,
-                      gpointer        data)
+/*
+       when a mouse button is released(always after click) this function is called
+       params:gtk opgn gl canvas , GdkEventButton object and custom data
+       return value:true or false, fails (false) if cannot init gl
+*/
+static gboolean button_release_event (GtkWidget* widget,GdkEventButton *event,gpointer data)
 {
-
        if(event->button==1)    //left click release
        {
-               view.mouse.mouse_down=0;
-               if (view.mouse.mouse_mode==MM_PAN)      //pan
-               {
-/*                     view.panx=view.prevpanx-(view.GLx2-view.GLx);
-                       view.pany=view.prevpany-(view.GLy2-view.GLy);
-                       expose_event (drawing_area,NULL,NULL);*/
-               }
+               if(glCompSetRelease(view->Topview->topviewmenu,event->x_root,event->y_root))
+                       expose_event (view->drawing_area,NULL,NULL);
 
-
-               if ((view.mouse.mouse_mode==MM_RECTANGULAR_SELECT)||(view.mouse.mouse_mode==MM_RECTANGULAR_X_SELECT))
+               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;
+                       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;
+                               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;
+                               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 (drawing_area,NULL,NULL);
+                               view->Selection.Type=2;
+                       view->Selection.Active=1;
+                       expose_event (view->drawing_area,NULL,NULL);
                }
-               if (view.mouse.mouse_mode==MM_MOVE)
+               if (view->mouse.mouse_mode==MM_MOVE)
                {
-                       if(((custom_graph_data*)AGDATA(view.g[view.activeGraph]))->TopView == 0)
-                               move_nodes(view.g[view.activeGraph]);
+                       if(((custom_graph_data*)AGDATA(view->g[view->activeGraph]))->TopView == 0)
+                               move_nodes(view->g[view->activeGraph]);
                        else
                                move_TVnodes();
 
                }
-               if ((view.mouse.mouse_mode==MM_FISHEYE_MAGNIFIER)||(view.mouse.mouse_mode==MM_MAGNIFIER)) //fisheye mag mouse release, stop distortion
+               if ((view->mouse.mouse_mode==MM_FISHEYE_MAGNIFIER)||(view->mouse.mouse_mode==MM_MAGNIFIER)) //fisheye mag mouse release, stop distortion
                {
-                       originate_distorded_coordinates(&Topview);
-                       expose_event (drawing_area,NULL,NULL);
+                       originate_distorded_coordinates(view->Topview);
+                       expose_event (view->drawing_area,NULL,NULL);
                }
        }
   dx = 0.0;
@@ -395,10 +309,12 @@ button_release_event (GtkWidget      *widget,
   return FALSE;
 }
 
-static gboolean
-motion_notify_event (GtkWidget      *widget,
-                    GdkEventMotion *event,
-                    gpointer        data)
+/*
+       when  mouse is moved over glcanvas this function is called
+       params:gtk opgn gl canvas , GdkEventMotion object and custom data
+       return value:always TRUE !!!
+*/
+static gboolean motion_notify_event (GtkWidget* widget,GdkEventMotion *event,gpointer data)
 {
        float w = widget->allocation.width;
        float h = widget->allocation.height;
@@ -406,229 +322,101 @@ motion_notify_event (GtkWidget      *widget,
        float y = event->y;
 
        gboolean redraw = FALSE;
-
-  
-
-       dx = x - begin_x;
+       dx = x - begin_x;
        dy = y - begin_y;
-  //panning
-    if ((event->state & GDK_BUTTON1_MASK) && (view.mouse.mouse_mode==MM_PAN))
+       /*panning*/
+    if ((event->state & GDK_BUTTON1_MASK) && (view->mouse.mouse_mode==MM_PAN))
        {       
-
-//             GetFixedOGLPos((int)x,(int)y,view.GLDepth);
-//             view.panx=view.prevpanx-(view.GLx2-view.GLx);
-//             view.pany=view.prevpany-(view.GLy2-view.GLy);
-               view.panx=view.panx-dx*pow(view.zoom*-1,(1/1));
-               view.pany=view.pany+dy*pow(view.zoom*-1,(1/1));
+               float a,b;
+               a=view->panx-dx*pow(view->zoom*-1,(1/1));
+               b=(view->bdxRight-view->bdxLeft)/2.0;
+               if (ABS(a) < ABS(b))
+                       view->panx=a;
+               else
+                       view->panx=(view->bdxRight-view->bdxLeft)/2.0*ABS(a)/a;
+               a=view->pany+dy*pow(view->zoom*-1,(1/1));
+               b=(view->bdyTop-view->bdyBottom)/2.0;
+               if (ABS(a) < ABS(b))
+                       view->pany=a;
+               else
+                       view->pany=(view->bdyTop-view->bdyBottom)/2.0*ABS(a)/a;
                redraw = TRUE;
        }
-       //zooming
-    if ((event->state & GDK_BUTTON1_MASK) && (view.mouse.mouse_mode==MM_ZOOM))
+       /*zooming*/
+    if ((event->state & GDK_BUTTON1_MASK) && (view->mouse.mouse_mode==MM_ZOOM))
        {       
-               view.zoom=view.zoom+dx/10*(view.zoom*-1/20);
-                       if(view.zoom > MAX_ZOOM)
-                               view.zoom=MAX_ZOOM;
-                       if(view.zoom < MIN_ZOOM)
-                               view.zoom=MIN_ZOOM;
+               view->zoom=view->zoom+dx/10*(view->zoom*-1/20);
+                       if(view->zoom > MAX_ZOOM)
+                               view->zoom=MAX_ZOOM;
+                       if(view->zoom < MIN_ZOOM)
+                               view->zoom=MIN_ZOOM;
                        redraw = TRUE;
-
        }
 
-
-  /* Rotation. */
-       if ((event->state & GDK_BUTTON1_MASK) && (view.mouse.mouse_mode==MM_ROTATE))
+       /*selection rect*/
+       if ((event->state & GDK_BUTTON1_MASK) && ((view->mouse.mouse_mode==MM_RECTANGULAR_SELECT)||(view->mouse.mouse_mode==5)))
        {       
-               trackball (view_quat_diff,
-                       (2.0 * begin_x - w) / w,
-                       (h - 2.0 * begin_y) / h,
-                       (2.0 * x - w) / w,
-                       (h - 2.0 * y) / h);
-
-
+               GetFixedOGLPos((int)x,(int)y,view->GLDepth,&(view->GLx2),&(view->GLy2),&(view->GLz2));
                redraw = TRUE;
        }
-
-  /* Scaling. */
-  if (event->state & GDK_BUTTON2_MASK)
-    {
-      view_scale = view_scale * (1.0 + (y - begin_y) / h);
-      if (view_scale > VIEW_SCALE_MAX)
-       view_scale = VIEW_SCALE_MAX;
-      else if (view_scale < VIEW_SCALE_MIN)
-       view_scale = VIEW_SCALE_MIN;
-
-      redraw = TRUE;
-    }
-  /*selection rect*/
-       if ((event->state & GDK_BUTTON1_MASK) && ((view.mouse.mouse_mode==MM_RECTANGULAR_SELECT)||(view.mouse.mouse_mode==5)))
+       if ((event->state & GDK_BUTTON1_MASK) && (view->mouse.mouse_mode==MM_MOVE))
        {       
-               GetFixedOGLPos((int)x,(int)y,view.GLDepth);
+               GetFixedOGLPos((int)x,(int)y,view->GLDepth,&(view->GLx2),&(view->GLy2),&(view->GLz2));
                redraw = TRUE;
        }
-       if ((event->state & GDK_BUTTON1_MASK) && (view.mouse.mouse_mode==MM_MOVE))
+       if ((event->state & GDK_BUTTON1_MASK) && ((view->mouse.mouse_mode==MM_MAGNIFIER)
+               ||(view->mouse.mouse_mode==MM_FISHEYE_MAGNIFIER) ))
        {       
-               GetFixedOGLPos((int)x,(int)y,view.GLDepth);
-               redraw = TRUE;
-       }
-       if ((event->state & GDK_BUTTON1_MASK) && ((view.mouse.mouse_mode==MM_MAGNIFIER)
-               ||(view.mouse.mouse_mode==MM_FISHEYE_MAGNIFIER) ))
-       {       
-           view.mouse.mouse_X=x;
-               view.mouse.mouse_Y=y;
+           view->mouse.mouse_X=x;
+               view->mouse.mouse_Y=y;
                redraw = TRUE;
        }
 
        
        begin_x = x;
-  begin_y = y;
+       begin_y = y;
 
 
-  if (redraw && !animate)
-    gdk_window_invalidate_rect (widget->window, &widget->allocation, FALSE);
-  return TRUE;
+       if (redraw)
+               gdk_window_invalidate_rect (widget->window, &widget->allocation, FALSE);
+       return TRUE;
 }
 
-static gboolean
-key_press_event (GtkWidget   *widget,
-                GdkEventKey *event,
-                gpointer     data)
+/*
+       when a key is pressed this function is called
+       params:gtk opgn gl canvas , GdkEventKey(to retrieve which key is pressed) object and custom data
+       return value:true or false, fails (false) if listed keys (in switch) are not pressed
+*/
+static gboolean key_press_event (GtkWidget   *widget, GdkEventKey *event, gpointer     data)
 {
   switch (event->keyval)
     {
     case GDK_Escape:
       gtk_main_quit ();
       break;
-
     default:
       return FALSE;
     }
-
-  return TRUE;
-}
-
-static gboolean
-idle (GtkWidget *widget)
-{
-  /* Invalidate the whole window. */
-  gdk_window_invalidate_rect (widget->window, &widget->allocation, FALSE);
-
-  /* Update synchronously. */
-  gdk_window_process_updates (widget->window, FALSE);
-
   return TRUE;
 }
 
-static void
-idle_add (GtkWidget *widget)
+/*
+       call back for mouse mode changes,
+       params:GtkMenuItem is not used, mouse_mode is the new mouse_mode
+       return value:none
+*/
+void switch_Mouse (GtkMenuItem *menuitem,int mouse_mode)
 {
-  if (idle_id == 0)
-    {
-      idle_id = g_idle_add_full (GDK_PRIORITY_REDRAW,
-                                 (GSourceFunc) idle,
-                                 widget,
-                                 NULL);
-    }
-}
-
-static void
-idle_remove (GtkWidget *widget)
-{
-  if (idle_id != 0)
-    {
-      g_source_remove (idle_id);
-      idle_id = 0;
-    }
+       view->mouse.mouse_mode=mouse_mode;
 }
 
 
-
-
-static gboolean
-map_event (GtkWidget *widget,
-          GdkEvent  *event,
-          gpointer   data)
-{
-  if (animate)
-    idle_add (widget);
-
-  return TRUE;
-}
-
-static gboolean
-unmap_event (GtkWidget *widget,
-            GdkEvent  *event,
-            gpointer   data)
-{
-  idle_remove (widget);
-
-  return TRUE;
-}
-
-static gboolean
-visibility_notify_event (GtkWidget          *widget,
-                        GdkEventVisibility *event,
-                        gpointer            data)
-{
-  if (animate)
-    {
-      if (event->state == GDK_VISIBILITY_FULLY_OBSCURED)
-       idle_remove (widget);
-      else
-       idle_add (widget);
-    }
-
-  return TRUE;
-}
-
-/* Toggle animation.*/
-static void
-toggle_animation (GtkWidget *widget)
-{
-  animate = !animate;
-
-  if (animate)
-    {
-      idle_add (widget);
-    }
-  else
-    {
-      idle_remove (widget);
-      view_quat_diff[0] = 0.0;
-      view_quat_diff[1] = 0.0;
-      view_quat_diff[2] = 0.0;
-      view_quat_diff[3] = 1.0;
-      gdk_window_invalidate_rect (widget->window, &widget->allocation, FALSE);
-    }
-}
-
-static void
-change_shape (GtkMenuItem  *menuitem,
-              const GLuint *shape)
-{
-  shape_current = *shape;
-  init_view ();
-}
-
-static void
-change_material (GtkMenuItem  *menuitem,
-                 MaterialProp *mat)
-{
-  mat_current = mat;
-}
-void 
-switch_Mouse (GtkMenuItem *menuitem,int mouse_mode)
-{
-  GdkCursor* cursor;
-       view.mouse.mouse_mode=mouse_mode;
-
-}
-
-
-/* For popup menu. */
-static gboolean
-button_press_event_popup_menu (GtkWidget      *widget,
-                              GdkEventButton *event,
-                              gpointer        data)
+/*
+       call back for mouse right click, this function activates the gtk right click pop up menu
+       params:widget to shop popup , event handler to check click type and custom data
+       return value:true or false, fails (false) if listed keys (in switch) are not pressed
+*/
+static gboolean button_press_event_popup_menu (GtkWidget *widget,GdkEventButton *event,gpointer data)
 {
   if (event->button == 3)
     {
@@ -637,174 +425,51 @@ button_press_event_popup_menu (GtkWidget      *widget,
                      event->button, event->time);
       return TRUE;
     }
-
   return FALSE;
 }
 
-/* Creates the popup menu.*/
-static GtkWidget *
-create_popup_menu (GtkWidget *drawing_area)
-{
-  GtkWidget *shapes_menu;
-  GtkWidget *actions_menu;
-  GtkWidget *editing_menu;
-  GtkWidget *menu;
-  GtkWidget *menu_item;
-       int mm=0;
-  /*actions sub menu*/
-       //PAN   
-
-mm=MM_PAN;
-  actions_menu = gtk_menu_new ();
-  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);
-  gtk_widget_show (menu_item);
-/**********/
-       //ZOOM
-  mm=MM_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);
-  gtk_widget_show (menu_item);
-/**********/
-       //ROTATE
-       mm=MM_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);
-  gtk_widget_show (menu_item);
-/**********/
-/**********/
-       //Single Select
-       mm=MM_SINGLE_SELECT;
-  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);
-  gtk_widget_show (menu_item);
-/**********/
-       //Rectangle Select
-       mm=MM_RECTANGULAR_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);
-  gtk_widget_show (menu_item);
-/**********/
-/**********/
-       //Rectangle -x Select
-       mm=MM_RECTANGULAR_X_SELECT;
-  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);
-  gtk_widget_show (menu_item);
-/**********/
-/**********/
-       //Move
-       mm=MM_MOVE;
-  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);
-  gtk_widget_show (menu_item);
-/**********/
-       //activate magnifier
-  mm=MM_MAGNIFIER;             //magnifier ,fisheye etc starts at 20
-  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);
-  gtk_widget_show (menu_item);
-/**********/
-       //activate fisheye magnifier
-  mm=MM_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);
-  gtk_widget_show (menu_item);
-/**********/
-  editing_menu = gtk_menu_new ();
-  /* NODE */
-  menu_item = gtk_menu_item_new_with_label ("Node");
-  gtk_menu_shell_append (GTK_MENU_SHELL (editing_menu), menu_item);
-  g_signal_connect (G_OBJECT (menu_item), "activate",
-                    G_CALLBACK (change_material), &mat_emerald);
-  gtk_widget_show (menu_item);
-
-  /* EDGE */
-  menu_item = gtk_menu_item_new_with_label ("Edge");
-  gtk_menu_shell_append (GTK_MENU_SHELL (editing_menu), menu_item);
-  g_signal_connect (G_OBJECT (menu_item), "activate",
-                    G_CALLBACK (change_material), &mat_jade);
-  gtk_widget_show (menu_item);
-
-
-  menu = gtk_menu_new ();
-
-  /* Actions */
-  menu_item = gtk_menu_item_new_with_label ("Mouse");
-  gtk_menu_item_set_submenu (GTK_MENU_ITEM (menu_item), actions_menu);
-  gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item);
-  gtk_widget_show (menu_item);
-
-  /* NEW */
-  menu_item = gtk_menu_item_new_with_label ("New");
-  gtk_menu_item_set_submenu (GTK_MENU_ITEM (menu_item), editing_menu);
-  gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item);
-  gtk_widget_show (menu_item);
-
-  /* Quit */
-  menu_item = gtk_menu_item_new_with_label ("Quit");
-  gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item);
-  g_signal_connect (G_OBJECT (menu_item), "activate",
-                   G_CALLBACK (gtk_main_quit), NULL);
-  gtk_widget_show (menu_item);
-  return menu;
-}
-
 
-
-extern GdkGLConfig *
-configure_gl (void)
+/*
+       configures various opengl settings
+       params:none
+       return value:GdkGLConfig object
+*/
+GdkGLConfig* configure_gl (void)
 {
-  GdkGLConfig *glconfig;
-
-  /* Try double-buffered visual */
-  glconfig = gdk_gl_config_new_by_mode (GDK_GL_MODE_RGB    |
+       GdkGLConfig *glconfig;
+       /* Try double-buffered visual */
+       glconfig = gdk_gl_config_new_by_mode (GDK_GL_MODE_RGB    |
                                        GDK_GL_MODE_DEPTH  |
                                        GDK_GL_MODE_DOUBLE);
-  if (glconfig == NULL)
+       if (glconfig == NULL)
     {
-      g_print ("\n*** Cannot find the double-buffered visual.\n");
-      g_print ("\n*** Trying single-buffered visual.\n");
+               g_print ("\n*** Cannot find the double-buffered visual.\n");
+               g_print ("\n*** Trying single-buffered visual.\n");
 
-      /* Try single-buffered visual */
-      glconfig = gdk_gl_config_new_by_mode (GDK_GL_MODE_RGB   |
+               /* Try single-buffered visual */
+               glconfig = gdk_gl_config_new_by_mode (GDK_GL_MODE_RGB   |
                                            GDK_GL_MODE_DEPTH);
-      if (glconfig == NULL)
-       {
-         g_print ("*** No appropriate OpenGL-capable visual found.\n");
-         exit (1);
-       }
+               if (glconfig == NULL)
+               {
+                       g_print ("*** No appropriate OpenGL-capable visual found.\n");
+                       exit (1);
+               }
     }
 
   return glconfig;
 }
 
-
+/*
+       run this function only once to create and customize gtk based opengl canvas
+       all signal, socket connections are done here for opengl interractions
+       params:gl config object, gtk container widget for opengl canvas
+       return value:none
+*/
 void create_window (GdkGLConfig *glconfig,GtkWidget* vbox)
 {
   gint major, minor;
 
-  GtkWidget *window;
   GtkWidget *menu;
-  GtkWidget *button;
   /*
    * Query OpenGL extension version.
    */
@@ -813,280 +478,57 @@ void create_window (GdkGLConfig *glconfig,GtkWidget* vbox)
   g_print ("\nOpenGL extension version - %d.%d\n",
            major, minor);
 
-  /*
-   * Configure OpenGL-capable visual.
-   */
-
   /* Try double-buffered visual */
 
  if (IS_TEST_MODE_ON)  //printf some gl values, to test if your system has opengl stuff
      examine_gl_config_attrib (glconfig); 
- /* Drawing area for drawing OpenGL scene.
-   */
-  drawing_area = gtk_drawing_area_new ();
-  gtk_widget_set_size_request (drawing_area, 300, 300);
+ /* Drawing area for drawing OpenGL scene.*/
+  view->drawing_area = gtk_drawing_area_new ();
+  gtk_widget_set_size_request (view->drawing_area, 300, 300);
   /* Set OpenGL-capability to the widget. */
-  gtk_widget_set_gl_capability (drawing_area,
+  gtk_widget_set_gl_capability (view->drawing_area,
                                glconfig,
                                NULL,
                                TRUE,
                                GDK_GL_RGBA_TYPE);
 
-  gtk_widget_add_events (drawing_area,
+  gtk_widget_add_events (view->drawing_area,
                         GDK_BUTTON1_MOTION_MASK    |
                         GDK_BUTTON2_MOTION_MASK    |
                         GDK_BUTTON_PRESS_MASK      |
                          GDK_BUTTON_RELEASE_MASK    |
                         GDK_VISIBILITY_NOTIFY_MASK);
 
-  g_signal_connect_after (G_OBJECT (drawing_area), "realize",
+  g_signal_connect_after (G_OBJECT (view->drawing_area), "realize",
                           G_CALLBACK (realize), NULL);
-  g_signal_connect (G_OBJECT (drawing_area), "configure_event",
+  g_signal_connect (G_OBJECT (view->drawing_area), "configure_event",
                    G_CALLBACK (configure_event), NULL);
-  g_signal_connect (G_OBJECT (drawing_area), "expose_event",
+  g_signal_connect (G_OBJECT (view->drawing_area), "expose_event",
                    G_CALLBACK (expose_event), NULL);
 
-  g_signal_connect (G_OBJECT (drawing_area), "button_press_event",
+  g_signal_connect (G_OBJECT (view->drawing_area), "button_press_event",
                    G_CALLBACK (button_press_event), NULL);
-  g_signal_connect (G_OBJECT (drawing_area), "button_release_event",
+  g_signal_connect (G_OBJECT (view->drawing_area), "button_release_event",
                    G_CALLBACK (button_release_event), NULL);
-  g_signal_connect (G_OBJECT (drawing_area), "motion_notify_event",
+  g_signal_connect (G_OBJECT (view->drawing_area), "motion_notify_event",
                    G_CALLBACK (motion_notify_event), NULL);
 
-  g_signal_connect (G_OBJECT (drawing_area), "map_event",
-                   G_CALLBACK (map_event), NULL);
-  g_signal_connect (G_OBJECT (drawing_area), "unmap_event",
-                   G_CALLBACK (unmap_event), NULL);
-  g_signal_connect (G_OBJECT (drawing_area), "visibility_notify_event",
-                   G_CALLBACK (visibility_notify_event), NULL);
 
+  gtk_box_pack_start (GTK_BOX (vbox), view->drawing_area, TRUE, TRUE, 0);
 
+  gtk_widget_show (view->drawing_area);
 
+  /* Popup menu. */
 
-
-  gtk_box_pack_start (GTK_BOX (vbox), drawing_area, TRUE, TRUE, 0);
-
-  gtk_widget_show (drawing_area);
-
-  /*
-   * Popup menu.
-   */
-
-  menu = create_popup_menu (drawing_area);
+  menu = create_popup_menu (view->drawing_area);
 
   /* Signal handler */
-  g_signal_connect_swapped (G_OBJECT (drawing_area), "button_press_event",
+  g_signal_connect_swapped (G_OBJECT (view->drawing_area), "button_press_event",
                             G_CALLBACK (button_press_event_popup_menu), menu);
 
 }
 
-//this piece of code returns the opengl coordinates of mouse coordinates
-int GetOGLPos(int x, int y)
-{
-       GLdouble wwinX;
-       GLdouble wwinY;
-       GLdouble wwinZ;
-
-
-       int ind;
-       GLdouble depth[5];
-       GLdouble raster[5];
-       GLint viewport[4];
-       GLdouble modelview[16];
-       GLdouble projection[16];
-       GLfloat winX, winY;
-       GLfloat winZ[36];
-       GLdouble posX, posY, posZ;
-       char buffer [200];
-       float kts=1;
-       //glTranslatef (0.0,0.0,0.0);
-       glGetDoublev( GL_MODELVIEW_MATRIX, modelview );
-       glGetDoublev( GL_PROJECTION_MATRIX, projection );
-       glGetIntegerv( GL_VIEWPORT, viewport );
-
-       //draw a point  to a not important location to get window coordinates
-       glBegin(GL_POINTS);
-               glVertex3f(10.00,10.00,0.00);
-       glEnd();
-    gluProject(10.0,10.0,0.00,modelview,projection,viewport,&wwinX,&wwinY,&wwinZ );
-       winX = (float)x;
-       winY = (float)viewport[3] - (float)y;
-       gluUnProject( winX, winY, wwinZ, modelview, projection, viewport, &posX, &posY, &posZ);
-
-       view.GLx=posX;
-       view.GLy=posY;
-       view.GLz=posZ;
-       view.GLDepth=kts;
-               return 1;
-
-}
-//some functions set the caches the depth value ,view.GLDepth
-int GetFixedOGLPos(int x, int y,float kts)
-{
-       GLdouble wwinX;
-       GLdouble wwinY;
-       GLdouble wwinZ;
-
-       GLint viewport[4];
-       GLdouble modelview[16];
-       GLdouble projection[16];
-       GLfloat winX, winY;
-       GLdouble posX, posY, posZ;
-
-       glBegin(GL_POINTS);
-               glVertex3f(10.00,10.00,0.00);
-       glEnd();
-
-       glGetDoublev( GL_MODELVIEW_MATRIX, modelview );
-       glGetDoublev( GL_PROJECTION_MATRIX, projection );
-       glGetIntegerv( GL_VIEWPORT, viewport );
-
-       gluProject(10.0,10.0,0.00,modelview,projection,viewport,&wwinX,&wwinY,&wwinZ );
-
-
-//     glTranslatef (0.0,0.0,0.0);
-
-       winX = (float)x;
-       winY = (float)viewport[3] - (float)y;
-       gluUnProject( winX, winY, wwinZ, modelview, projection, viewport, &posX, &posY, &posZ);
-       view.GLx2=posX;
-       view.GLy2=posY;
-       view.GLz2=posZ;
-       return 1;
-
-}
-
-int GetOGLPosRef(int x, int y,float* X,float* Y,float* Z)
-{
-
-       GLdouble wwinX;
-       GLdouble wwinY;
-       GLdouble wwinZ;
-       GLdouble posX, posY, posZ;
-
-
-       int ind;
-       GLdouble depth[5];
-       GLdouble raster[5];
-       GLint viewport[4];
-       GLdouble modelview[16];
-       GLdouble projection[16];
-       GLfloat winX, winY;
-       GLfloat winZ[36];
-       char buffer [200];
-       float kts=1;
-       //glTranslatef (0.0,0.0,0.0);
-       glGetDoublev( GL_MODELVIEW_MATRIX, modelview );
-       glGetDoublev( GL_PROJECTION_MATRIX, projection );
-       glGetIntegerv( GL_VIEWPORT, viewport );
-
-       //draw a point  to a not important location to get window coordinates
-       glBegin(GL_POINTS);
-               glVertex3f(10.00,10.00,0.00);
-       glEnd();
-    gluProject(10.0,10.0,0.00,modelview,projection,viewport,&wwinX,&wwinY,&wwinZ );
-       winX = (float)x;
-       winY = (float)viewport[3] - (float)y;
-       gluUnProject( winX, winY, wwinZ, modelview, projection, viewport, &posX, &posY, &posZ);
 
-       *X=posX;
-       *Y=posY;
-       *Z=posZ;
-       return 1;
-
-}
-
-
-float GetOGLDistance(int l)
-{
-
-       int x,y;
-       float*  X,Y, Z;
-       GLdouble wwinX;
-       GLdouble wwinY;
-       GLdouble wwinZ;
-       GLdouble posX, posY, posZ;
-       GLdouble posXX, posYY, posZZ;
-
-
-       int ind;
-       GLdouble depth[5];
-       GLdouble raster[5];
-       GLint viewport[4];
-       GLdouble modelview[16];
-       GLdouble projection[16];
-       GLfloat winX, winY;
-       GLfloat winZ[36];
-       char buffer [200];
-       float kts=1;
-       //glTranslatef (0.0,0.0,0.0);
-       glGetDoublev( GL_MODELVIEW_MATRIX, modelview );
-       glGetDoublev( GL_PROJECTION_MATRIX, projection );
-       glGetIntegerv( GL_VIEWPORT, viewport );
-
-       //draw a point  to a not important location to get window coordinates
-       glBegin(GL_POINTS);
-               glVertex3f(10.00,10.00,0.00);
-       glEnd();
-    gluProject(10.0,10.0,0.00,modelview,projection,viewport,&wwinX,&wwinY,&wwinZ );
-       x=50;
-       y=50;
-       winX = (float)x;
-       winY = (float)viewport[3] - (float)y;
-       gluUnProject( winX, winY, wwinZ, modelview, projection, viewport, &posX, &posY, &posZ);
-       x=x+l;
-       y=50;
-       winX = (float)x;
-       winY = (float)viewport[3] - (float)y;
-       gluUnProject( winX, winY, wwinZ, modelview, projection, viewport, &posXX, &posYY, &posZZ);
-       return (posXX-posX);
-}
-
-
-
-//////////////////////////GGGGGG////////////////////////////////////////////////
-/////////////////////////GG/////G///////////////////////////////////////////////
-/////////////////////////GG/////////////////////////////////////////////////////
-/////////////////////////GG//GGG////////////////////////////////////////////////
-/////////////////////////GG/////G///////////////////////////////////////////////
-/////////////////////////GGG////G///////////////////////////////////////////////
-///////////////////////////GGGGG////////////////////////////////////////////////
-////////////////////////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////////////////////////
-//2D PRIMITIVES
-//all these functions should be moved to another file
-//for testing i ll ise this file
-
-
-#if 0
-void loadDLL (char* file)
-{
-       if(lt_dlinit ()== 0)
-       {
-       //      g_print("libltdl has been successfully initialized\n");
-
-               if(lt_dlopen (file))
-           g_print("%s has been loaded\n", file);
-               else
-           g_print("%s failed\n", file);
-       }
-}
-#endif
-
-void DrawView()
-{
-       if(view.activeGraph > -1)
-       {
-               
-               if(((custom_graph_data*)AGDATA(view.g[view.activeGraph]))->TopView)
-                       drawTopViewGraph(view.g[view.activeGraph]);//topview style dots and straight lines
-               else    
-                       drawGraph(view.g[view.activeGraph]);//xdot based drawing functions
-       }
-
-}
 
 
 
index 037a2738086299fd8d4a1f09441075996f7ffa1c..ff03d4f809a71da799422a24c33d443351a2f5c6 100755 (executable)
 #ifdef _WIN32
 #include <windows.h>
 #endif
-
-#include <stdlib.h>
-#include <math.h>
 #include <GL/gl.h>
-#include <GL/glu.h>                                                    // Header File For The GLu32 Library
-// #include <GL/glaux.h>       
-#include "materials.h"
-
-#include "viewport.h"
-
+#include <GL/glu.h>                                                    
 #include <gtk/gtk.h>
 #include <gdk/gdkkeysyms.h>
 #include <gtk/gtkgl.h>
 #include <gdk/gdkcursor.h>
 
-// #include "guifunctions.h"
-#include "trackball.h"
-#include "cgraph.h"
-#include "xdot.h"
-#include <glTexFont.h>
 
 
-#define DIG_2_RAD (G_PI / 180.0)
-#define RAD_2_DIG (180.0 / G_PI)
-#define ANIMATE_THRESHOLD 25.0
-#define VIEW_SCALE_MAX 2.0
-#define VIEW_SCALE_MIN 0.5
-#define NUM_SHAPES 9
-static float DEG2RAD = 3.14159/180;
-static gboolean animate = FALSE;
-static void toggle_animation (GtkWidget *widget);
 
-// solid shapes
-static const GLuint shape_cube         = 0;
-static const GLuint shape_sphere       = 1;
-static const GLuint shape_cone         = 2;
-static const GLuint shape_torus        = 3;
-static const GLuint shape_tetrahedron  = 4;
-static const GLuint shape_octahedron   = 5;
-static const GLuint shape_dodecahedron = 6;
-static const GLuint shape_icosahedron  = 7;
-static const GLuint shape_teapot       = 8;
-//2D shapes
-static const GLuint shape_dot             = 9;
-static const GLuint shape_polygon      = 10;
-static const GLuint shape_ellipse      = 11;
-static const GLuint shape_spline       = 12;
-static const GLuint shape_text         = 13;
-static GLuint shape_list_base = 0;
-static GLuint shape_current = 8;
-static MaterialProp *mat_current = &mat_silver;
-static float view_quat_diff[4] = { 0.0, 0.0, 0.0, 1.0 };
-static float view_quat[4] = { 0.0, 0.0, 0.0, 1.0 };
-static float view_scale = 1.0;
+
 //mouse modes
 #define MM_PAN                                 0
 #define MM_ZOOM                                        1
@@ -90,43 +47,18 @@ static float view_scale = 1.0;
 #define MM_MAGNIFIER                   20
 #define MM_FISHEYE_MAGNIFIER   21
 
-void loadDLL (char* file);
-extern xdot* testxdot;
-extern GtkWidget *drawing_area;
 
-static void init_view (void);
 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);
-
-
 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);
-static gboolean idle (GtkWidget *widget);
-
-static void idle_add (GtkWidget *widget);
-static void idle_remove (GtkWidget *widget);
-static gboolean map_event (GtkWidget *widget,GdkEvent *event,gpointer   data);
-static gboolean unmap_event (GtkWidget *widget,GdkEvent  *event,gpointer data);
-static gboolean visibility_notify_event (GtkWidget *widget,GdkEventVisibility *event,gpointer data);
-static void toggle_animation (GtkWidget *widget);
-static void change_shape (GtkMenuItem  *menuitem,const GLuint *shape);
-//static void change_material (GtkMenuItem *menuitem,MaterialProp *mat);
 void switch_Mouse (GtkMenuItem *menuitem,int mouse_mode);
 static gboolean button_press_event_popup_menu (GtkWidget *widget,GdkEventButton *event,gpointer data);
-static GtkWidget *create_popup_menu (GtkWidget *drawing_area);
-extern 
-GdkGLConfig *configure_gl (void);
+extern GdkGLConfig *configure_gl (void);
 void create_window (GdkGLConfig *glconfig,GtkWidget* vbox);
-int GetOGLPos(int x, int y);//this piece of code returns the opengl coordinates of mouse coordinates
-int GetFixedOGLPos(int x, int y,float kts);
-int GetOGLPosRef(int x, int y,float* X,float* Y,float* Z);
-float GetOGLDistance(int l);
-void loadDLL (char* file);     //for loading plugins , requires ltdl (libtool)
-void DrawView();//draws view
-
 #endif
index c7ae107ae9949079493b7a06083d3ada960323e4..50ed0721dce762274ccc7f4d473036e27fe37277 100755 (executable)
 *              AT&T Research, Florham Park NJ             *
 **********************************************************/
 
-/*
- * Initial main.c file generated by Glade. Edit as required.
- * Glade will not overwrite this file.
- */
 
 #ifdef HAVE_CONFIG_H
 #  include <config.h>
 #define WIN32_LEAN_AND_MEAN 1
 #include <windows.h>
 #endif
-#include <stdio.h>                                                     // Header File For Standard Input/Output ( NEW )
 #include <gtk/gtk.h>
-#include <gdk/gdkkeysyms.h>
 #include <gtk/gtkgl.h>
 #include <glade/glade.h>
-#include <fontconfig/fontconfig.h>
-#include "callbacks.h"
-#include "regex.h"
-
-// #include "topology.h"
-#include <stdlib.h>
-
-
-
 #include "gui.h"
+#include "viewport.h"
 #include "menucallbacks.h"
-#include "cgraph.h"
-#include "abstring.h"
 
-#ifdef G_OS_WIN32
-/*gchar *package_prefix = PACKAGE_PREFIX;
-gchar *package_data_dir = PACKAGE_DATA_DIR;
-gchar *package_locale_dir = PACKAGE_LOCALE_DIR;*/
-#endif
-gchar *package_prefix = "";
-gchar *package_data_dir = "";
-gchar *package_locale_dir = "";
+gchar *package_prefix ;
+gchar *package_data_dir;
+gchar *package_locale_dir;
 
-//973 768 8826
-//ramy 99 win
-
-int
-main (int argc, char *argv[])
+int main (int argc, char *argv[])
 {
-
-//     DWORD t1,t2;
-       int i=0;
-       int ind=0;
-       regex_t a;
        GdkGLConfig *glconfig;
-       gchar *pixmap_dir;
-//     HMODULE mymodule;
-       char lpFilename[1024];
-       GtkWidget* do_widget=NULL;
-       char str[50]="asdasdasasdas";
-       //topview test starts here**************        
-//     c_interface_draw(5);
-       //testme(&str);
-//     if(c_interface_load_from_file("c:/4elt.dot",graph,nvtxs,nedges,coords,labels,identifiers)!=0)
-       //      c_interface_tp(graph,nvtxs,nedges,coords,labels,identifiers,&hierarchy);
-/*     {
-               for (ind=0;ind < 100 ;ind++)
-               {
-                       printf("%i:  coords:(%f,%f) ",ind ,coords[0][ind],coords[1][ind]);
-//                     printf("TVcoords:(%f,%f)\n",hierarchy.geom_graphs[1][ind].x_coord,hierarchy.geom_graphs[1][ind].y_coord);
-               }
-       }*/
-
-       //topview test end here **************  
        load_attributes();
-       
-//pango test
-//t1=GetTickCount();
-//             pango_main("c:/normal.png");
-       //****
-//     t2=GetTickCount();
-//     printf("recorded tickcounts  %d-%d \n", t1,t2);
-//     printf("difference (Pango):%d \n", t2-t1);
-//    print_children(tree_from_filter_string("(([color=\"brown\",min=\"0\",max=\"30\"])&([color=\"sfsdf\",min=\"15\",max=\"20\"]|[color=\"qqqqq\",min=\"0\",max=\"30\"]))"));
 
 #ifdef G_OS_WIN32
        package_prefix = g_win32_get_package_installation_directory (NULL, NULL);
@@ -107,42 +49,38 @@ main (int argc, char *argv[])
        bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
        textdomain (GETTEXT_PACKAGE);
 #endif
//    mymodule=GetModuleHandle(NULL);
-//     GetModuleFileName(NULL,lpFilename,1024);
-//     printf("dir:%s\n",lpFilename);
-//     printf("pango version is %s\n",pango_version_string ());
      view=malloc(sizeof(ViewInfo));
+       init_viewport(view);
+
+
        gtk_set_locale ();
        gtk_init (&argc, &argv);
 
 #ifdef _WIN32
-#define SMYRNA_ICONSDIR "C:\\Projects\\ATT\\GTK\\GTKTest2\\GUI\\images\\"
+#define GTKTOPVIEW_ICONSDIR "C:\\Projects\\ATT\\GTK\\GTKTest2\\GUI\\images\\"
 #endif
-//     pixmap_dir = g_build_filename (package_data_dir, "", "pixmaps", NULL);
-       printf("pixmap dir:%s \n", SMYRNA_ICONSDIR);
-       add_pixmap_directory (SMYRNA_ICONSDIR);
-//  add_pixmap_directory ("C:\\Projects\\ATT\\GTK\\GTKTest2\\GUI\\images\\");
-//     g_free (pixmap_dir);
-
-       xml = glade_xml_new(SMYRNA_GLADE, NULL, NULL);
+       xml = glade_xml_new(GTKTOPVIEW_GLADE, 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);
-
        gtk_gl_init (0,0);
-  /* Configure OpenGL framebuffer. */
+       /* Configure OpenGL framebuffer. */
        glconfig = configure_gl ();
        gladewidget = glade_xml_get_widget(xml, "vbox2");
-
-
        create_window (glconfig,gladewidget);
+       /*first arg is used as file name*/
+       if(argc>1)
+               add_graph_to_viewport_from_file (argv[1]);
        gtk_main ();
 
+
 #ifdef G_OS_WIN32
        g_free (package_prefix);
        g_free (package_data_dir);
        g_free (package_locale_dir);
 #endif
+       clear_viewport(view);
        return 0;
 }
index 6966aebcfabf72847cc141318ae744374c1dce70..1fb58019a95e2344e394e7135a5adb3a801cd05a 100755 (executable)
@@ -24,102 +24,87 @@ typedef struct _MaterialProp
   GLfloat shininess;
 } MaterialProp;
 
-#ifdef DEFINE_MATERIALS
-MaterialProp mat_emerald = {
+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
 };
 
-MaterialProp mat_jade = {
+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
 };
 
-MaterialProp mat_obsidian = {
+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
 };
 
-MaterialProp mat_pearl = {
+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
 };
 
-MaterialProp mat_ruby = {
+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
 };
 
-MaterialProp mat_turquoise = {
+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
 };
 
-MaterialProp mat_brass = {
+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
 };
 
-MaterialProp mat_bronze = {
+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
 };
 
-MaterialProp mat_chrome = {
+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
 };
 
-MaterialProp mat_copper = {
+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
 };
 
-MaterialProp mat_gold = {
+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
 };
 
-MaterialProp mat_silver = {
+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
 };
-#else
-extern MaterialProp mat_emerald;
-extern MaterialProp mat_jade;
-extern MaterialProp mat_obsidian;
-extern MaterialProp mat_pearl;
-extern MaterialProp mat_ruby;
-extern MaterialProp mat_turquoise;
-extern MaterialProp mat_brass;
-extern MaterialProp mat_bronze;
-extern MaterialProp mat_chrome;
-extern MaterialProp mat_copper;
-extern MaterialProp mat_gold;
-extern MaterialProp mat_silver;
-#endif
 #endif
index 75b85f65551a6f5783a05c495bd99bd328781e60..62db4ac40ccd25dd1c880955bf783c6e62469b0c 100755 (executable)
@@ -1,30 +1,4 @@
-/**************************************************************************
- * template.c
- *
- * Copyright (c) 2002 Alif Wahid <awah005@users.sourceforge.net>
- *
- * This is a template of the essential source code to write useful but
- * simple programs using GtkGLExt and Gtk. It compiles into an executable
- * but obviously the lack of any OpenGL functions in this demonstrates
- * the generic nature. It's heavily commented to aid beginners (especially
- * tertiary students like myself). So use/change it at will.
- *
- * This program is in the public domain and you are using it at
- * your own risk.
- *
- **************************************************************************/
-
-/* 
- * Follow the GTK coding style.
- * Changed idle function management codes.
- * Added popup menu.
- * Added quit button.
- *   Naofumi Yasufuku  <naofumi@users.sourceforge.net>
- */
 
-/**************************************************************************
- * Header file inclusions.
- **************************************************************************/
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -57,8 +31,6 @@
  ***/
 #define DEFAULT_WIDTH  200
 #define DEFAULT_HEIGHT 200
-#define DEFAULT_TITLE  "GtkGLExt Template"
-
 #define TIMEOUT_INTERVAL 10
 
 
@@ -66,7 +38,6 @@
  * Global variable declarations.
  **************************************************************************/
 
-static gboolean animate = FALSE;
 
 
 /**************************************************************************
@@ -388,9 +359,6 @@ map_event (GtkWidget *widget,
           gpointer   data)
 {
   g_print ("%s: \"map_event\":\n", gtk_widget_get_name (widget));
-  if (animate)
-    timeout_add (widget);
-
   return TRUE;
 }
 
@@ -419,41 +387,11 @@ visibility_notify_event (GtkWidget          *widget,
                         GdkEventVisibility *event,
                         gpointer            data)
 {
-  if (animate)
-    {
-      if (event->state == GDK_VISIBILITY_FULLY_OBSCURED)
-       timeout_remove (widget);
-      else
-       timeout_add (widget);
-    }
 
   return TRUE;
 }
 
 
-/**************************************************************************
- * The following section contains some miscellaneous utility functions.
- **************************************************************************/
-
-/***
- *** Toggle animation.
- ***/
-static void
-toggle_animation (GtkWidget *widget)
-{
-  animate = !animate;
-
-  if (animate)
-    {
-      timeout_add (widget);
-    }
-  else
-    {
-      timeout_remove (widget);
-      gdk_window_invalidate_rect (widget->window, &widget->allocation, FALSE);
-    }
-}
-
 
 /**************************************************************************
  * The following section contains the GUI building function definitions.
@@ -504,8 +442,8 @@ create_window (GdkGLConfig *glconfig)
    * Top-level window.
    */
 
-  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
-  gtk_window_set_title (GTK_WINDOW (window), DEFAULT_TITLE);
+//  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+//  gtk_window_set_title (GTK_WINDOW (window), DEFAULT_TITLE);
 
   /* Get automatically redrawn if any of their children changed allocation. */
   gtk_container_set_reallocate_redraws (GTK_CONTAINER (window), TRUE);
@@ -632,38 +570,3 @@ configure_gl (void)
 
   return glconfig;
 }
-
-
-/**************************************************************************
- * The main function is rather trivial.
- **************************************************************************/
-
-/*int
-main (int   argc,
-      char *argv[])
-{
-  GtkWidget *window;
-  GdkGLConfig *glconfig;
-
-  /* Initialize GTK. */
-/*  gtk_init (&argc, &argv);
-
-  /* Initialize GtkGLExt. */
-/*  gtk_gl_init (&argc, &argv);
-
-  /* Configure OpenGL framebuffer. */
-/*  glconfig = configure_gl ();
-
-  /* Create and show the application window. */
-/*  window = create_window (glconfig);
-  gtk_widget_show (window);
-
-  gtk_main ();
-
-  return 0;
-}*/
-
-
-/**************************************************************************
- * End of file.
- **************************************************************************/
index 7581e41fe07c1bc8aae8cca00e05e56cc1357107..e1f9d328170f23c221c6fa4b4e53ec4e97a100af 100755 (executable)
 *        Information and Software Systems Research        *
 *              AT&T Research, Florham Park NJ             *
 **********************************************************/
-#define DEFINE_MATERIALS
+#include "glTexFont.h"
+#include "glTexFontTGA.h"
+#include "glTexFontDefs.h"
+#include "glTexFontInclude.h"
 #include "topview.h"
 #include "math.h"
 #include "btree.h"
-topview Topview;
-GtkButton** gtkhostbtn;
-int gtkhostbtncount;
-GtkColorButton** gtkhostcolor;
-int hostactive[50];   //temporary static, convert to dynamic,realloc
-char** hostregex;
-int fisheye_distortion_fac;
-
-static int font=0;
+#include "viewport.h"
+#include "draw.h"
+#include "selection.h"
+
 static float dx=0.0;
 static float dy=0.0;
-#define NODE_ZOOM_LIMIT        -25.3
-#define NODE_CIRCLE_LIMIT      -7.3
-extern void PrepareTopview(Agraph_t *g)
+void cleartopview(topview* t)
+{
+       int ind=0;
+       /*clear nodes*/
+       free (t->Nodes);
+       /*clear edges*/
+       free(t->Edges);
+       /*clear gl menu*/
+       glCompSetClear(t->topviewmenu);
+       free (t);
+}
+void preparetopview(Agraph_t *g,topview* t)
 {
        int GP_flag=0;  //general purpose flag
        char* str;
@@ -41,30 +48,37 @@ extern void PrepareTopview(Agraph_t *g)
        Agnode_t *v;
        Agedge_t *e;
        GtkTreeIter iter;
-       int ind,ind2,data_type_count;   //number of columns for custom topview data ,IP ,HOST, etc
+       int ind,ind2,data_type_count;   //number of columns for custom view->Topview data ,IP ,HOST, etc
        char buf[256];
        ind=0;ind2=0;
-       //data attributes are read from graph's attributes DataAttribute1 and DataAttribute2
-       //node_data_attribute1; //for topview graphs this is the node data attribute to put as label
-       //node_data_attribute2; //for topview graphs this is the node data attribute to be stored and used for something else
-
-       //data list
-
-       /*      if ( agget(g, "DataCount"))
-       {
-               data_type_count=AToInt(agget(g, "DataCount"));
-       }*/
        gtk_widget_hide(glade_xml_get_widget(xml, "layout6"));  //hide top panel
+       gtk_widget_hide(glade_xml_get_widget(xml, "menubar1")); //hide menu
        data_type_count=0;
        d_attr1=agget(g, "DataAttribute1");
        d_attr2=agget(g, "DataAttribute2");
+       
+       t->Edges=NULL;
+       t->Nodes=NULL;
+       /*initialize node and edge array*/
+       printf ("edge memory required %i \n",sizeof(topview_edge)*agnedges(g));
+       t->Edges=malloc(sizeof(topview_edge)*agnedges(g));
+       if (t->Edges)
+               printf ("Edge malloc is ok\n");
 
+       t->Nodes=malloc(sizeof(topview_node)*agnnodes(g));
+       if (t->Nodes)
+               printf ("Nodes malloc is ok\n");
 
+       printf ("# of edges :%i\n",agnnodes(g));
+       printf ("# of edges :%i\n",agnedges(g));
+
+               /*malloc topviewdata*/
+       t->TopviewData=malloc (sizeof(topviewdata));
 
        for (v = agfstnode(g); v; v = agnxtnode(g, v))
        {
                //set node TV reference
-       ((custom_object_data*)AGDATA(v))->TVRef=ind;            //Topview reference
+       ((custom_object_data*)AGDATA(v))->TVRef=ind;            //view->Topview reference
                strcpy(buf,agget(v, "pos"));
                if(strlen(buf))
                {
@@ -75,40 +89,25 @@ extern void PrepareTopview(Agraph_t *g)
                                c=atof(str);
                        else
                                c=0.0;
-                       if (!GP_flag)
-                       {
-                               Topview.limits[0]=a;
-                               Topview.limits[2]=a;
-                               Topview.limits[1]=b;
-                               Topview.limits[3]=b;
-                               GP_flag=1;
-                       }
-                       if (a < Topview.limits[0])
-                               Topview.limits[0]=a;
-                       if (a > Topview.limits[2])
-                               Topview.limits[2]=a;
-                       if (b < Topview.limits[1])
-                               Topview.limits[1]=b;
-                       if (b > Topview.limits[3])
-                               Topview.limits[3]=b;
                }
-               Topview.Nodes[ind].GroupIndex=-1;
-               randomize_color(&(Topview.Nodes[ind].Color),2);
-               Topview.Nodes[ind].Node=v;
-               Topview.Nodes[ind].x=a;
-               Topview.Nodes[ind].y=b;
-               Topview.Nodes[ind].z=c;
-               Topview.Nodes[ind].distorted_x=a;
-               Topview.Nodes[ind].distorted_y=b;
-               Topview.Nodes[ind].zoom_factor=1;
-               Topview.Nodes[ind].degree=agdegree(g,v,1,1);
-               Topview.Nodes[ind].node_alpha=log((float)Topview.Nodes[ind].degree+0.3);
+               /*initialize group index, -1 means no group*/           
+               t->Nodes[ind].GroupIndex=-1;
+               randomize_color(&(t->Nodes[ind].Color),2);
+               t->Nodes[ind].Node=v;
+               t->Nodes[ind].x=a;
+               t->Nodes[ind].y=b;
+               t->Nodes[ind].z=c;
+               t->Nodes[ind].distorted_x=a;
+               t->Nodes[ind].distorted_y=b;
+               t->Nodes[ind].zoom_factor=1;
+               t->Nodes[ind].degree=agdegree(g,v,1,1);
+               t->Nodes[ind].node_alpha=log((float)t->Nodes[ind].degree+0.3);
                if(d_attr1)
                {
                        str=agget(v,d_attr1);
                        if(str)
                        {
-                               Topview.Nodes[ind].Label=strdup(str);
+                               t->Nodes[ind].Label=strdup(str);
 
                        }
 
@@ -118,16 +117,15 @@ extern void PrepareTopview(Agraph_t *g)
                        str=agget(v,d_attr2);
                        if(str)
                        {
-                               Topview.Nodes[ind].Label2=strdup(str);
-                               //gtk_list_store_set_value(Topview.DataList,&iter,2,str);
+                               t->Nodes[ind].Label2=strdup(str);
                        }
                }
                for (e = agfstout(g,v) ; e ; e = agnxtout (g,e))
                {
-                       Topview.Edges[ind2].Hnode=aghead(e);
-                       Topview.Edges[ind2].Tnode=agtail(e);
-                       Topview.Edges[ind2].Edge=e;
-                       
+                       aghead(e);
+                       t->Edges[ind2].Hnode=aghead(e);
+                       t->Edges[ind2].Tnode=agtail(e);
+                       t->Edges[ind2].Edge=e;
                        strcpy(buf,agget(aghead(e), "pos"));
                        if(strlen(buf))
                        {
@@ -139,9 +137,9 @@ extern void PrepareTopview(Agraph_t *g)
                                else
                                        c=0.0;
 
-                               Topview.Edges[ind2].x1=a;
-                               Topview.Edges[ind2].y1=b;
-                               Topview.Edges[ind2].z1=b;
+                               t->Edges[ind2].x1=a;
+                               t->Edges[ind2].y1=b;
+                               t->Edges[ind2].z1=b;
                        }
                        strcpy(buf,agget(agtail(e), "pos"));
                        if(strlen(buf))
@@ -153,10 +151,9 @@ extern void PrepareTopview(Agraph_t *g)
                                        c=atof(str);
                                else
                                        c=0.0;
-
-                               Topview.Edges[ind2].x2=a;
-                               Topview.Edges[ind2].y2=b;
-                               Topview.Edges[ind2].z2=c;
+                               t->Edges[ind2].x2=a;
+                               t->Edges[ind2].y2=b;
+                               t->Edges[ind2].z2=c;
                        }
                        ind2++;
                }
@@ -169,20 +166,23 @@ extern void PrepareTopview(Agraph_t *g)
                //set node TV reference
                for (e = agfstout(g,v) ; e ; e = agnxtout (g,e))
                {
-                       Topview.Edges[ind2].Node1=  &Topview.Nodes[((custom_object_data*)AGDATA(Topview.Edges[ind2].Tnode))->TVRef];
-                       Topview.Edges[ind2].Node2=  &Topview.Nodes[((custom_object_data*)AGDATA(Topview.Edges[ind2].Hnode))->TVRef];
+                       t->Edges[ind2].Node1=  &t->Nodes[((custom_object_data*)AGDATA(t->Edges[ind2].Tnode))->TVRef];
+                       t->Edges[ind2].Node2=  &t->Nodes[((custom_object_data*)AGDATA(t->Edges[ind2].Hnode))->TVRef];
                        ind2++;
 
                }
                ind++;
        }
-       Topview.Nodecount=ind;
-       Topview.Edgecount=ind2;
-       fisheye_distortion_fac=5; //simdilik burda dursun , need to be hooked to a widget
-       set_boundries();
-       set_update_required(&Topview);
-       set_boundries();
-//     load_host_buttons(g);
+       t->Nodecount=ind;
+       t->Edgecount=ind2;
+       view->fmg.fisheye_distortion_fac=5; //need to be hooked to a widget
+       set_boundries(t);
+       set_update_required(t);
+       t->topviewmenu=glcreate_gl_topview_menu();
+       load_host_buttons(t,g,t->topviewmenu);
+
+
+
 }
 void drawTopViewGraph(Agraph_t *g)
 {
@@ -195,31 +195,45 @@ void drawTopViewGraph(Agraph_t *g)
        int ind=0;
        char buf[50];
        GLfloat a,b;
-       if(view.zoom > NODE_ZOOM_LIMIT)
+       if(view->zoom > NODE_ZOOM_LIMIT)
        {
-               glPointSize(15/view.zoom*-1);
+               glPointSize(15/view->zoom*-1);
                //draw nodes
                set_topview_options();
-               if(view.zoom < NODE_CIRCLE_LIMIT)
+               if(view->zoom < NODE_CIRCLE_LIMIT)
                        glBegin(GL_POINTS);
-               for (ind=0;ind < Topview.Nodecount;ind ++)
+
+               //drawing labels
+               for (ind=0;ind < view->Topview->Nodecount;ind ++)
                {
 
-                       if((Topview.Nodes[ind].x > view.clipX1) && (Topview.Nodes[ind].x < view.clipX2) &&(Topview.Nodes[ind].y > view.clipY1)&&(Topview.Nodes[ind].y < view.clipY2))
+                       v=&view->Topview->Nodes[ind];
+                       if(!node_visible(v->Node))
+                               break;
+
+                       draw_topview_label(v,1);
+
+               }
+               for (ind=0;ind < view->Topview->Nodecount;ind ++)
+               {
+
+                       if((view->Topview->Nodes[ind].x > view->clipX1) && (view->Topview->Nodes[ind].x < view->clipX2) &&(view->Topview->Nodes[ind].y > view->clipY1)&&(view->Topview->Nodes[ind].y < view->clipY2))
                        {
+                               float zdepth;
+
                                if(1)
                                {
-                                       v=&Topview.Nodes[ind];
+                                       v=&view->Topview->Nodes[ind];
                                        if(!node_visible(v->Node))
                                                break;
 
                                        select_topview_node(v);
-                                       //UPDATE topview data from cgraph
+                                       //UPDATE view->Topview data from cgraph
                                        if (v->update_required)
                                                update_topview_node_from_cgraph(v);
                                        if( ((custom_object_data*)AGDATA(v->Node))->Selected==1)
                                        {
-                                               glColor4f(view.selectColor.R,view.selectColor.G,view.selectColor.B,view.selectColor.A);
+                                               glColor4f(view->selectColor.R,view->selectColor.G,view->selectColor.B,view->selectColor.A);
                                                ddx=dx;ddy=dy;
                                        }
                                        else            //get the color from node
@@ -230,41 +244,37 @@ void drawTopViewGraph(Agraph_t *g)
                                                ddx=0;ddy=0;
                                        }
 
-                                       
-                                       if(view.zoom < NODE_CIRCLE_LIMIT)
-                                               glVertex3f(v->distorted_x-ddx,v->distorted_y-ddy,-0.01); 
+                                       if (v->distorted_x!=v->x)
+                                               zdepth=Z_FORWARD_PLANE;
                                        else
-                                               drawCircle(v->distorted_x-ddx,v->distorted_y-ddy,v->node_alpha*v->zoom_factor);
+                                               zdepth=Z_BACK_PLANE;
+                                       if(view->zoom < NODE_CIRCLE_LIMIT)
+                                               glVertex3f(v->distorted_x-ddx,v->distorted_y-ddy,zdepth); 
+                                       else
+                                               drawCircle(v->distorted_x-ddx,v->distorted_y-ddy,v->node_alpha*v->zoom_factor,zdepth);
                                }
                        }
                }
-               if(view.zoom< NODE_CIRCLE_LIMIT)
+               if(view->zoom< NODE_CIRCLE_LIMIT)
                        glEnd();
-               for (ind=0;ind < Topview.Nodecount;ind ++)
-               {
-
-                       v=&Topview.Nodes[ind];
-                       if(!node_visible(v->Node))
-                               break;
-
-                       draw_topview_label(v);
 
-               }
+               
        }
        //draw edges
-//     glLineWidth(5/view.zoom*-1);
+//     glLineWidth(5/view->zoom*-1);
        glBegin(GL_LINES);
        set_topview_options();
-       for (ind=0;ind < Topview.Edgecount;ind ++)
+       for (ind=0;ind < view->Topview->Edgecount;ind ++)
        {
                if(
-                       ((Topview.Edges[ind].x1 > view.clipX1) && (Topview.Edges[ind].x1 < view.clipX2) &&(Topview.Edges[ind].y1 > view.clipY1)&&(Topview.Edges[ind].y1 < view.clipY2))
+                       ((view->Topview->Edges[ind].x1 > view->clipX1) && (view->Topview->Edges[ind].x1 < view->clipX2) &&(view->Topview->Edges[ind].y1 > view->clipY1)&&(view->Topview->Edges[ind].y1 < view->clipY2))
                                                        ||
-                       ((Topview.Edges[ind].x2 > view.clipX1) && (Topview.Edges[ind].x2 < view.clipX2) &&(Topview.Edges[ind].y2 > view.clipY1)&&(Topview.Edges[ind].y2 < view.clipY2))
+                       ((view->Topview->Edges[ind].x2 > view->clipX1) && (view->Topview->Edges[ind].x2 < view->clipX2) &&(view->Topview->Edges[ind].y2 > view->clipY1)&&(view->Topview->Edges[ind].y2 < view->clipY2))
 
                        )
                {
-                       e=&Topview.Edges[ind];
+                       float zdepth1,zdepth2;
+                       e=&view->Topview->Edges[ind];
                        select_topview_edge(e);
                        if( ((custom_object_data*)AGDATA(e->Node1->Node))->Selected==1) //tail is selected
                        {                ddx=dx;ddy=dy;}
@@ -275,22 +285,32 @@ void drawTopViewGraph(Agraph_t *g)
                        else
                        {               dddx=0;dddy=0;}
 
+                       //zdepth
+                       if (e->Node1->distorted_x!=e->Node1->x)
+                                               zdepth1=Z_FORWARD_PLANE;
+                                       else
+                                               zdepth1=Z_BACK_PLANE;
+                       if (e->Node2->distorted_x!=e->Node2->x)
+                                               zdepth2=Z_FORWARD_PLANE;
+                                       else
+                                               zdepth2=Z_BACK_PLANE;
+
 
                        if(get_color_from_edge(e))
                        {
-                               glVertex3f(e->Node1->distorted_x-ddx,e->Node1->distorted_y-ddy,-0.01);
-                               glVertex3f(e->Node2->distorted_x-dddx,e->Node2->distorted_y-dddy,-0.01);
+                               glVertex3f(e->Node1->distorted_x-ddx,e->Node1->distorted_y-ddy,zdepth1);
+                               glVertex3f(e->Node2->distorted_x-dddx,e->Node2->distorted_y-dddy,zdepth2);
                        }
                }
        }
        glEnd();
-       if((view.Selection.Active>0) && (!SignalBlock))
+       if((view->Selection.Active>0) && (!view->SignalBlock))
        {
-                       view.Selection.Active=0;
+                       view->Selection.Active=0;
                        drawTopViewGraph(g);
-                       SignalBlock=1;
-                       expose_event (drawing_area,NULL,NULL);
-                       SignalBlock=0;
+                       view->SignalBlock=1;
+                       expose_event (view->drawing_area,NULL,NULL);
+                       view->SignalBlock=0;
        }
 
 }
@@ -298,38 +318,38 @@ void drawTopViewGraph(Agraph_t *g)
 
 int select_topview_node(topview_node *n)
 {
-       if(!view.Selection.Active)
+       if(!view->Selection.Active)
                return 0;
-       if(is_point_in_rectangle(n->x,n->y,view.Selection.X,view.Selection.Y,view.Selection.W,view.Selection.H))
+       if(is_point_in_rectangle(n->x,n->y,view->Selection.X,view->Selection.Y,view->Selection.W,view->Selection.H))
        {
                        
-               switch (view.Selection.Type)
+               switch (view->Selection.Type)
                {
                case 0:
 
                        if ( ((custom_object_data*)AGDATA(n->Node))->Selected==0)
                        {
                                ((custom_object_data*)AGDATA(n->Node))->Selected=1;
-                               select_object (view.g[view.activeGraph],n->Node);
+                               select_object (view->g[view->activeGraph],n->Node);
                        }
                        else
                        {
                                ((custom_object_data*)AGDATA(n->Node))->Selected=1;
-                               deselect_object (view.g[view.activeGraph],n->Node);
+                               deselect_object (view->g[view->activeGraph],n->Node);
                        }
                        break;
 
                case 1:
                case 2:
-                       if(view.Selection.Anti==0)
+                       if(view->Selection.Anti==0)
                        {
-                               select_object (view.g[view.activeGraph],n->Node);
-                               view.Selection.AlreadySelected=1;
+                               select_object (view->g[view->activeGraph],n->Node);
+                               view->Selection.AlreadySelected=1;
                        }
                        else
                        {
-                               deselect_object (view.g[view.activeGraph],n->Node);
-                               view.Selection.AlreadySelected=1;
+                               deselect_object (view->g[view->activeGraph],n->Node);
+                               view->Selection.AlreadySelected=1;
                        }
                        break;
 
@@ -339,38 +359,38 @@ int select_topview_node(topview_node *n)
 int select_topview_edge(topview_edge *e)
 {
        int r=0;
-       if(!view.Selection.Active)
+       if(!view->Selection.Active)
                return 0;
        r=(lineintersects(e->x1,e->y1,e->x2,e->y2));
        if(r >= 0)
        {
                        
-               switch (view.Selection.Type)
+               switch (view->Selection.Type)
                {
                case 0:
                        if ( ((custom_object_data*)AGDATA(e->Edge))->Selected==0)
                        {
                                ((custom_object_data*)AGDATA(e->Edge))->Selected=1;
-                               select_object (view.g[view.activeGraph],e->Edge);
+                               select_object (view->g[view->activeGraph],e->Edge);
                        }
                        else
                        {
                                ((custom_object_data*)AGDATA(e->Edge))->Selected=1;
-                               deselect_object (view.g[view.activeGraph],e->Edge);
+                               deselect_object (view->g[view->activeGraph],e->Edge);
                        }
                        break;
 
 /*             case 1:
                case 2:
-                       if(view.Selection.Anti==0)
+                       if(view->Selection.Anti==0)
                        {
-                               select_object (view.g[view.activeGraph],n->Node);
-                               view.Selection.AlreadySelected=1;
+                               select_object (view->g[view->activeGraph],n->Node);
+                               view->Selection.AlreadySelected=1;
                        }
                        else
                        {
-                               deselect_object (view.g[view.activeGraph],n->Node);
-                               view.Selection.AlreadySelected=1;
+                               deselect_object (view->g[view->activeGraph],n->Node);
+                               view->Selection.AlreadySelected=1;
                        }
                        break;*/
 
@@ -378,10 +398,10 @@ int select_topview_edge(topview_edge *e)
        }
 
 
-/*     else if (view.Selection.Type==0)
+/*     else if (view->Selection.Type==0)
        {
-                       deselect_object (view.g[view.activeGraph],n->Node);
-                       view.Selection.AlreadySelected=1;
+                       deselect_object (view->g[view->activeGraph],n->Node);
+                       view->Selection.AlreadySelected=1;
        } */
 }
 int update_topview_node_from_cgraph(topview_node* Node)
@@ -396,10 +416,10 @@ int update_topview_node_from_cgraph(topview_node* Node)
        {
                randomize_color(&(Node->Color),2);
 
-               Node->Color.R=view.penColor.R;
-               Node->Color.G=view.penColor.G;
-               Node->Color.B=view.penColor.B;
-               Node->Color.A=view.penColor.A;
+               Node->Color.R=view->penColor.R;
+               Node->Color.G=view->penColor.G;
+               Node->Color.B=view->penColor.B;
+               Node->Color.A=view->penColor.A;
        }*/
        Node->update_required=0;
 }
@@ -413,10 +433,10 @@ int update_topview_edge_from_cgraph(topview_edge* Edge)
                Edge->Color=GetRGBColor(buf);
        else
        {
-               Edge->Color.R=view.penColor.R;
-               Edge->Color.G=view.penColor.G;
-               Edge->Color.B=view.penColor.B;
-               Edge->Color.A=view.penColor.A;
+               Edge->Color.R=view->penColor.R;
+               Edge->Color.G=view->penColor.G;
+               Edge->Color.B=view->penColor.B;
+               Edge->Color.A=view->penColor.A;
        }
        Edge->update_required=0;
 }
@@ -441,7 +461,7 @@ int set_update_required(topview* t)
 
 }
 
-int draw_topview_label(topview_node* v)
+int draw_topview_label(topview_node* v,float zdepth)
 {
 
        float fs=0;
@@ -449,9 +469,9 @@ int draw_topview_label(topview_node* v)
        float ddy=0;
        if(!v->Label)
                return 0;
-       if((view.zoom*-1/v->degree/v->zoom_factor) > 2)
+       if((view->zoom*-1/v->degree/v->zoom_factor) > 2)
                return 0;
-       if((v->distorted_x > view.clipX1) && (v->distorted_x < view.clipX2) &&(v->distorted_y > view.clipY1)&&(v->distorted_y < view.clipY2))
+       if((v->distorted_x > view->clipX1) && (v->distorted_x < view->clipX2) &&(v->distorted_y > view->clipY1)&&(v->distorted_y < view->clipY2))
        {
 
                fs=(v->degree==1) ?log((double)v->degree+1)*7:log((double)v->degree+0.5)*7;
@@ -464,9 +484,14 @@ int draw_topview_label(topview_node* v)
                }
 
                fontSize (fs);
-               fontColorA (log((double)v->degree+1),view.penColor.G,view.penColor.B,view.penColor.A/log((float)v->degree)*-0.6*view.zoom);
-//             printf("%f \n",view.penColor.A/log((float)v->degree)*-0.02*view.zoom);
+               if ((log((float)v->degree)*-0.6*view->zoom) >0)
+                       fontColorA (log((double)v->degree+1),view->penColor.G,view->penColor.B,view->penColor.A/log((float)v->degree)*-0.6*view->zoom);
+               else
+                       fontColorA (log((double)v->degree+1),view->penColor.G,view->penColor.B,1);
+
+//             printf("%f \n",view->penColor.A/log((float)v->degree)*-0.02*view->zoom);
                fontDrawString (v->distorted_x-ddx,v->distorted_y-ddy,v->Label,fs*5);
+
                return 1;
        }
        else
@@ -474,46 +499,14 @@ int draw_topview_label(topview_node* v)
 }
 
 
-int randomize_color(RGBColor* c,int brightness)
-{
-       float R,B,G;
-       float add;
-       R=(float)(rand() % 255) / 255.0;
-       G=(float)(rand() % 255) / 255.0;
-       B=(float)(rand() % 255) / 255.0;
-       add=(brightness-(R+G+B))/3;
-       R = R;
-       G = G;
-       B = B;
-       c->R=R;
-       c->G=G;
-       c->B=B;
-//     printf(" %f %f %f \n",R,G,B);
-}
-
-
-void drawCircle(float x,float y,float radius)
-{
-       int i;
-       if(radius <0.3)
-               radius=0.4;
-       glBegin(GL_POLYGON);
-   for (i=0; i < 360; i=i+10)
-   {
-      float degInRad = i*DEG2RAD;
-      glVertex2f(x+cos(degInRad)*radius,y+sin(degInRad)*radius);
-   }
-   glEnd();
-}
 
 void set_topview_options()
 {
        
-       if ((view.mouse.mouse_mode==10) && (view.mouse.mouse_down==1))  //selected, if there is move move it, experimental
+       if ((view->mouse.mouse_mode==10) && (view->mouse.mouse_down==1))        //selected, if there is move move it, experimental
        {
-               dx=view.GLx-view.GLx2;
-               dy=view.GLy-view.GLy2;
+               dx=view->GLx-view->GLx2;
+               dy=view->GLy-view->GLy2;
        }
        else
        {
@@ -522,24 +515,37 @@ void set_topview_options()
        }
 
 }
-void set_boundries()
+/*refreshes limits of the graph call it when node locations are changed*/
+void set_boundries(topview* t)
 {
-       GLfloat bdxLeft,bdyTop,bdzTop;  //border top coordinates
-       GLfloat bdxRight,bdyBottom,bdzBottom; //border bottom coordinates
 
-       view.bdxLeft=Topview.limits[0];
-       view.bdyTop=Topview.limits[3];
-       view.bdxRight=Topview.limits[2];
-       view.bdyBottom=Topview.limits[1];
-       
-       view.bdzTop=0;
-       view.bdzBottom=0;
-//     view.panx=view.bdxLeft;
-//     view.pany=view.bdyBottom;
-//     view.prevpanx=view.bdxLeft;
-//     view.prevpany=view.bdyBottom;
-
-       printf ("graph boundries (%f,%f)/(%f,%f) \n" , view.bdxLeft,view.bdyTop,view.bdxRight,view.bdyBottom);
+       int ind=0;
+       float left,right,top,bottom;
+       left=t->Nodes[0].distorted_x;
+       right=t->Nodes[0].distorted_x;
+       top=t->Nodes[0].distorted_y;
+       bottom=t->Nodes[0].distorted_y;
+       for (ind=0;ind < t->Nodecount;ind ++)
+       {
+               if(left > t->Nodes[ind].distorted_x)
+                       left=t->Nodes[ind].distorted_x;
+               if(right < t->Nodes[ind].distorted_x)
+                       right=t->Nodes[ind].distorted_x;
+               if(bottom > t->Nodes[ind].distorted_y)
+                       bottom=t->Nodes[ind].distorted_y;
+               if(top < t->Nodes[ind].distorted_y)
+                       top=t->Nodes[ind].distorted_y;
+       }
+       view->bdxLeft=left;
+       view->bdyTop=top;
+       view->bdxRight=right;
+       view->bdyBottom=bottom;
+       view->bdzTop=0;
+       view->bdzBottom=0;
+/*     printf("top view graph boundries\n");
+       printf("------------------------\n");
+       printf("lower left (%f,%f)\n",view->bdxLeft,view->bdyBottom);
+       printf("upper right(%f,%f)\n",view->bdxRight,view->bdyTop);*/
 }
 
 
@@ -567,7 +573,7 @@ int get_color_from_edge(topview_edge *e)
                        )
        {
 //             glColor4f(0,0,1,1);
-               glColor4f(view.selectColor.R,view.selectColor.G,view.selectColor.B,view.selectColor.A);
+               glColor4f(view->selectColor.R,view->selectColor.G,view->selectColor.B,view->selectColor.A);
                return return_value;
        }
        if(             ( ((custom_object_data*)AGDATA(e->Node1->Node))->Highlighted==1)
@@ -582,16 +588,16 @@ int get_color_from_edge(topview_edge *e)
        //group colors
        if((e->Node1->GroupIndex >=0) || (e->Node2->GroupIndex >=0))
        {
-               if (hostactive[e->Node1->GroupIndex]==1)
+               if (view->Topview->TopviewData->hostactive[e->Node1->GroupIndex]==1)
                {
-                       gtk_color_button_get_color(gtkhostcolor[e->Node1->GroupIndex],&color);
+                       gtk_color_button_get_color(view->Topview->TopviewData->gtkhostcolor[e->Node1->GroupIndex],&color);
                        glColor4f(color.red/65535.0,color.green/65535.0,color.blue/65535.0,1);
                        return return_value;
                }else
                {
-                       if (hostactive[e->Node2->GroupIndex]==1)
+                       if (view->Topview->TopviewData->hostactive[e->Node2->GroupIndex]==1)
                        {
-                               gtk_color_button_get_color(gtkhostcolor[e->Node2->GroupIndex],&color);
+                               gtk_color_button_get_color(view->Topview->TopviewData->gtkhostcolor[e->Node2->GroupIndex],&color);
                                glColor4f(color.red/65535.0,color.green/65535.0,color.blue/65535.0,1);
                                return return_value;
                        }
@@ -618,9 +624,9 @@ int move_TVnodes()
 {
        topview_node *v;
        int ind=0;
-       for (ind=0;ind < Topview.Nodecount;ind ++)
+       for (ind=0;ind < view->Topview->Nodecount;ind ++)
        {
-               v=&Topview.Nodes[ind];
+               v=&view->Topview->Nodes[ind];
                if( ((custom_object_data*)AGDATA(v->Node))->Selected==1)
                {
                        v->x=v->x-dx;
@@ -628,31 +634,9 @@ int move_TVnodes()
                }
        }
 }
-int draw_navigation_menu()
-{
-
-    int vPort[4];
-    /* get current viewport */
-    glGetIntegerv (GL_VIEWPORT, vPort);
 
-       glMatrixMode (GL_PROJECTION);
-       glPushMatrix ();
-       glLoadIdentity ();
 
-  
-       glOrtho (0, vPort[2], 0, vPort[3], -1, 1);
-       glMatrixMode (GL_MODELVIEW);
-       glPushMatrix ();
-       glLoadIdentity ();
-               drawCircle(100,100,1);
-
-       glMatrixMode (GL_PROJECTION);
-       glPopMatrix ();
-       glMatrixMode (GL_MODELVIEW);
-       glPopMatrix ();
-}
-
-int load_host_buttons(Agraph_t *g)
+/*int load_host_buttons(Agraph_t *g,glCompSet* s)
 {
        GtkLayout* layout;
        int btncount=0;
@@ -668,6 +652,8 @@ int load_host_buttons(Agraph_t *g)
        int X=10;
        int Y=25;
        GdkColor color;
+       glCompPanel* p;
+       glCompButton* b;
 
        layout=glade_xml_get_widget(xml, "frmHostSelectionFixed");
        str='\0';
@@ -678,9 +664,17 @@ int load_host_buttons(Agraph_t *g)
 //     Graph [hostbtncaption1="AT&T",hostbtnregex1="*.ATT*",hostbtncolorR1="1",hostbtncolorG1="0",hostbtncolorB1="0",hostbtncolorA1="1"];
 
        hostregex=malloc (sizeof(char**)*btncount);
-               gtkhostbtn=malloc(sizeof(GtkButton*)*btncount);
-               gtkhostcolor=malloc(sizeof(GtkColorButton*)*btncount);
-               gtkhostbtncount=btncount;
+       gtkhostbtn=malloc(sizeof(GtkButton*)*btncount);
+       gtkhostcolor=malloc(sizeof(GtkColorButton*)*btncount);
+       gtkhostbtncount=btncount;
+       if (btncount > 0)
+       {
+               p=glCompPanelNew(25,75,165,400);
+               p->data=2;              //data panel
+               p->color.R=0.80;
+               p->color.B=0,2;
+               glCompSetAddPanel(s,p);
+       }
        for (i=0;i < btncount ; i++)
        {
                sprintf(hostbtncaption,"hostbtncaption%i",i);
@@ -697,6 +691,18 @@ int load_host_buttons(Agraph_t *g)
                        agget(g,hostbtncolorB),
                        agget(g,hostbtncolorA));
                hostregex[i]=agget(g,hostbtnregex);
+
+               b=glCompButtonNew(5,7+(i+1)*36,150,35,agget(g,hostbtncaption ),'\0',0,0);
+               b->color.R=atof(agget(g,hostbtncolorR));
+               b->color.G=atof(agget(g,hostbtncolorG));
+               b->color.B=atof(agget(g,hostbtncolorB));
+               b->color.A=1;
+               b->panel=p;
+               b->groupid=-1;
+               b->callbackfunc=glhost_button_clicked_Slot;
+               b->data=i;
+               glCompSetAddButton(s,b);
+
                gtkhostbtn[i]=gtk_button_new_with_label(agget(g,hostbtncaption ));
                g_signal_connect ((gpointer) gtkhostbtn[i], "clicked", G_CALLBACK(host_button_clicked_Slot),i);
 
@@ -720,38 +726,13 @@ int load_host_buttons(Agraph_t *g)
                Y=Y+40;
                hostactive[i]=0;
        }
-       printf ("all regex\n");
-       for (i=0;i < btncount ; i++)
+       p->height=15+(btncount+1)*36;
+/*     for (i=0;i < btncount ; i++)
        {
-
                prepare_nodes_for_groups(i);
-               
        }
-}
-
-int prepare_nodes_for_groups(int groupindex)
-{
-       GdkColor color;
-       int i=0;
-       int count=0;
-       tv_node tvn;
-       gtk_color_button_get_color(gtkhostcolor[0],&color);
+}*/
 
-       for (i;i < Topview.Nodecount ; i++)
-       {
-               tvn.index=i;
-               if(validate_group_node(&tvn,hostregex[groupindex]))
-               {
-                       count ++;
-                       gtk_color_button_get_color(gtkhostcolor[groupindex],&color);
-                       Topview.Nodes[i].GroupIndex=groupindex;
-                       Topview.Nodes[i].GroupColor.R=color.red/65535.0;
-                       Topview.Nodes[i].GroupColor.G=color.green/65535.0;
-                       Topview.Nodes[i].GroupColor.B=color.blue/65535.0;
-               }
-       }
-       printf ("%i matches for group:%i (%s) RGB(%f,%f,%f)\n",count,groupindex,hostregex[groupindex],color.red/65535.0,color.green/65535.0,color.blue/65535.0);
-}
 
 
 int validate_group_node(tv_node* TV_Node,char* regex_string)
@@ -769,45 +750,43 @@ int validate_group_node(tv_node* TV_Node,char* regex_string)
        return valid;
 }
 
-void host_button_clicked_Slot(GtkWidget *widget,gpointer     user_data)
-{
-       //negative active
-       int i;
-       if(hostactive[(int)user_data]==0)
-               hostactive[(int)user_data]=1;
-       else
-               hostactive[(int)user_data]=0;
-       printf("-----------\n");
-       printf ("host%i:%i\n",(int)user_data,hostactive[(int)user_data]);
-       printf("-----------\n");
-       for (i=0;i < gtkhostbtncount ; i++)
-       {
-               printf ("host%i:%i\n",i,hostactive[i]);
-       }
-       expose_event (drawing_area,NULL,NULL);
-}
+
+
 void
 on_host_alpha_change (GtkWidget *widget,gpointer     user_data)
 {
-       expose_event (drawing_area,NULL,NULL);
+       expose_event (view->drawing_area,NULL,NULL);
 }
 
 void local_zoom(topview* t)
 {
        int i;
        double delx,dely,w,h,tempx,tempy;
-       w=view.mg.width;
-       h=view.mg.height;
+       w=view->mg.width;
+       h=view->mg.height;
        for (i=1; i< t->Nodecount; i++) 
        {
-               if(is_point_in_rectangle(t->Nodes[i].x,t->Nodes[i].y,view.mg.x-view.mg.width,view.mg.y-view.mg.height,
-                       view.mg.width*2,view.mg.height*2))
+               if(is_point_in_rectangle(t->Nodes[i].x,t->Nodes[i].y,view->mg.x-view->mg.GLwidth,view->mg.y-view->mg.GLheight,
+                       view->mg.GLwidth*2,view->mg.GLheight*2))
                {
-                       delx=t->Nodes[i].x-view.mg.x;
-                       dely=t->Nodes[i].y-view.mg.y;
+                       delx=t->Nodes[i].x-view->mg.x;
+                       dely=t->Nodes[i].y-view->mg.y;
+                       tempx=view->mg.x+delx*view->mg.kts;
+                       tempy=view->mg.y+dely*view->mg.kts;
+                       if(is_point_in_rectangle(tempx,tempy,view->mg.x-view->mg.GLwidth,view->mg.y-view->mg.GLheight,
+                               view->mg.GLwidth*2,view->mg.GLheight*2))
+                       {
+                               t->Nodes[i].distorted_x=view->mg.x+delx*view->mg.kts;
+                               t->Nodes[i].distorted_y=view->mg.y+dely*view->mg.kts;
+                               t->Nodes[i].zoom_factor=view->mg.kts;
+                       }
+                       else//get intersections and move nodes to edges of magnifier box
+                       {
+                               t->Nodes[i].distorted_x =t->Nodes[i].x;
+                               t->Nodes[i].distorted_y =t->Nodes[i].y;
+                               t->Nodes[i].zoom_factor=1;
+                       }
 
-                       t->Nodes[i].distorted_x=view.mg.x+delx*view.mg.kts;
-                       t->Nodes[i].distorted_y=view.mg.y+dely*view.mg.kts;
                }
                else
                {
@@ -825,7 +804,7 @@ void fisheye_polar(double x_focus, double y_focus,topview* t)
        range=0;
        for (i=1; i< t->Nodecount; i++) 
        {
-               if(point_within_ellips_with_coords(x_focus,y_focus,view.fmg.R,view.fmg.R,t->Nodes[i].x,t->Nodes[i].y))
+               if(point_within_ellips_with_coords(x_focus,y_focus,view->fmg.R,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));
                }
@@ -834,7 +813,7 @@ void fisheye_polar(double x_focus, double y_focus,topview* t)
        for (i=1; i< t->Nodecount; i++) 
        {
 
-               if(point_within_ellips_with_coords(x_focus,y_focus,view.fmg.R,view.fmg.R,t->Nodes[i].x,t->Nodes[i].y))
+               if(point_within_ellips_with_coords(x_focus,y_focus,view->fmg.R,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;
@@ -879,7 +858,239 @@ double dist(double x1, double y1, double x2, double y2)
 double G(double x)
 {
        // distortion function for fisheye display
-       return (fisheye_distortion_fac+1)*x/(fisheye_distortion_fac*x+1);
+       return (view->fmg.fisheye_distortion_fac+1)*x/(view->fmg.fisheye_distortion_fac*x+1);
+}
+
+void test_callback()
+{
+       printf ("test button click\n");
+}
+void menu_click_control(void* p)
+{
+       glCompSet* s;
+       int ind=0;
+       s=((glCompButton*)p)->parentset;
+       for (ind=0;ind < s->panelcount;ind++)
+       {
+               if (s->panels[ind]->data > 0)
+                       glCompPanelHide(s->panels[ind]);//hide all panels
+               if (s->panels[ind]->data==1)    //control panel
+               {
+                       glCompPanelShow(s->panels[ind]);
+               }
+       }
+}
+void menu_click_data(void* p)
+{
+       glCompSet* s;
+       int ind=0;
+       s=((glCompButton*)p)->parentset;
+       for (ind=0;ind < s->panelcount;ind++)
+       {
+               if (s->panels[ind]->data > 0)
+                       glCompPanelHide(s->panels[ind]);//hide all panels
+               if (s->panels[ind]->data==2)    //data panel
+               {
+                       glCompPanelShow(s->panels[ind]);
+               }
+       }
+}
+void menu_click_hide(void* p)
+{
+       glCompSet* s;
+       int ind=0;
+       s=((glCompButton*)p)->parentset;
+       for (ind=0;ind < s->panelcount;ind++)
+       {
+               if (s->panels[ind]->data > 0)
+                       glCompPanelHide(s->panels[ind]);//hide all panels
+       }
+}
+void menu_click_pan(void* p)
+{
+       view->mouse.mouse_mode=MM_PAN;
+
+}
+void menu_click_zoom(void* p)
+{
+       view->mouse.mouse_mode=MM_ZOOM;
+
+}
+void menu_click_fisheye_magnifier(void* p)
+{
+       view->mouse.mouse_mode=MM_FISHEYE_MAGNIFIER;
+
+}
+void menu_click_zoom_minus(void* p)
+{
+       if((view->zoom - ZOOM_STEP) > MIN_ZOOM)
+               view->zoom=view->zoom-ZOOM_STEP;
+       else
+               view->zoom=MIN_ZOOM;
+}
+void menu_click_zoom_plus(void* p)
+{
+       if((view->zoom + ZOOM_STEP) < MAX_ZOOM)
+               view->zoom=view->zoom+ZOOM_STEP;
+       else
+               view->zoom=MAX_ZOOM;
+
+}
+void menu_click_alpha_plus(void* p)
+{
+       if((view->zoom + ZOOM_STEP) < MAX_ZOOM)
+               view->zoom=view->zoom+ZOOM_STEP;
+       else
+               view->zoom=MAX_ZOOM;
+
 }
 
 
+glCompSet* glcreate_gl_topview_menu()
+{
+       glCompSet* s=malloc(sizeof(glCompSet));
+       glCompPanel* p;
+       glCompButton* b;
+       glCompLabel* l;
+       s->panelcount=0;
+       s->panels='\0';
+       s->buttoncount=0;
+       s->buttons='\0';
+       s->labels='\0';
+       s->labelcount=0;
+       /*panel data 
+               0 :small bottom
+               1 :control
+               2 :data
+
+
+       */
+
+       //small panel left bottom
+       p=glCompPanelNew(25,25,245,40);
+       p->data=0;
+       glCompSetAddPanel(s,p);
+       
+       b=glCompButtonNew(5,7,75,25,"CONTROL",'\0',0,0);
+       b->panel=p;
+       b->groupid=1;
+       b->customptr=view;
+       glCompSetAddButton(s,b);
+       b->callbackfunc=menu_click_control;
+
+       b=glCompButtonNew(85,7,75,25,"DATA",'\0',0,0);
+       b->panel=p;
+       b->customptr=view;
+       b->groupid=1;
+       b->callbackfunc=menu_click_data;
+       glCompSetAddButton(s,b);
+
+       b=glCompButtonNew(165,7,75,25,"HIDE",'\0',0,0);
+       b->color.R=1;
+       b->customptr=view;
+       b->panel=p;
+       b->groupid=1;
+       b->callbackfunc=menu_click_hide;
+       glCompSetAddButton(s,b);
+
+       //control panel
+       p=glCompPanelNew(25,75,165,200);
+       p->data=1;              //control panel
+       glCompSetAddPanel(s,p);
+
+       //view mode normal button
+       b=glCompButtonNew(5,7,75,25,"NORMAL",'\0',0,0);
+       b->color.R=0;
+       b->color.G=1;
+       b->color.B=0.1;
+       b->customptr=view;
+       b->panel=p;
+       b->groupid=2;
+       glCompSetAddButton(s,b);
+       //view mode fisheye button
+       b=glCompButtonNew(85,7,75,25,"FISHEYE",'\0',0,0);
+       b->color.R=0;
+       b->color.G=1;
+       b->color.B=0.1;
+       b->customptr=view;
+       b->panel=p;
+       b->groupid=2;
+       glCompSetAddButton(s,b);
+       //pan button
+       b=glCompButtonNew(5,120,72,72,"adasasds","c:/pan.raw",72,72);
+       b->groupid=3;
+       b->customptr=view;
+       b->panel=p;
+       b->callbackfunc=menu_click_pan;
+       glCompSetAddButton(s,b);
+       //zoom
+       b=glCompButtonNew(85,120,72,72,"adasasds","c:/zoom.raw",72,72);
+       b->groupid=3;
+       b->customptr=view;
+       b->panel=p;
+       b->callbackfunc=menu_click_zoom;
+       glCompSetAddButton(s,b);
+       //zoom +
+       b=glCompButtonNew(85,82,36,36,"adasasds","c:/zoomplus.raw",36,36);
+       b->groupid=0;
+       b->customptr=view;
+       b->panel=p;
+       b->callbackfunc=menu_click_zoom_plus;
+       glCompSetAddButton(s,b);
+       //zoom -
+       b=glCompButtonNew(121,82,36,36,"adasasds","c:/zoomminus.raw",36,36);
+       b->groupid=0;
+       b->panel=p;
+       b->customptr=view;
+       b->callbackfunc=menu_click_zoom_minus;
+       glCompSetAddButton(s,b);
+
+       b=glCompButtonNew(5,45,72,72,"adasasds","c:/fisheye.raw",72,72);
+       b->groupid=3;
+       b->panel=p;
+       b->customptr=view;
+       b->callbackfunc=menu_click_fisheye_magnifier;
+       glCompSetAddButton(s,b);
+       //zoom percantage label
+       l=glCompLabelNew(100,45,24,"100");
+       l->panel=p;
+       l->fontsizefactor=0.4;
+       glCompSetAddLabel(s,l);
+       l=glCompLabelNew(93,65,20,"zoom");
+       l->panel=p;
+       l->fontsizefactor=0.4;
+       glCompSetAddLabel(s,l);
+
+       glCompPanelHide(p);
+
+/*     //Data Panel
+       p=glCompPanelNew(25,75,165,400);
+       p->data=2;              //data panel
+       glCompSetAddPanel(s,p);
+       //alpha plus button
+       b=glCompButtonNew(75,3,36,36,"","c:/zoomplus.raw",36,36);
+       b->groupid=0;
+       b->panel=p;
+       b->callbackfunc=menu_click_alpha_plus;
+       glCompSetAddButton(s,b);
+       //alpha minus button
+       b=glCompButtonNew(113,3,36,36,"","c:/zoomminus.raw",36,36);
+       b->groupid=0;
+       b->panel=p;
+       b->callbackfunc=menu_click_alpha_plus;
+       glCompSetAddButton(s,b);
+
+       l=glCompLabelNew(5,8,18,"ALPHA");
+       l->panel=p;
+       l->fontsizefactor=0.4;
+       glCompSetAddLabel(s,l);*/
+
+
+       return s;
+
+}
+//calbacks
+
+
+
+
index 0ef6263670c437de7315706af6f268d87d7c7acf..5e4ed027984e004541d94f5624add69a68cfbef6 100755 (executable)
 *              AT&T Research, Florham Park NJ             *
 **********************************************************/
 
-//Top view
 #ifndef TOPVIEW_H
 #define TOPVIEW_H
-#define MAX_TOP_VIEW_NODE_COUNT                1000000
-#define MAX_TOP_VIEW_EDGE_COUNT                1000000
-#define UNHIGHLIGHTED_ALPHA    0.3
 
-#include "viewport.h"
-#include "gui.h"
-#include "hierarchy.h"
-#include "tvnodes.h"
 
-#ifdef WIN32   //this shit is needed on WIN32 to get libglade see the callback
+#include "smyrnadefs.h"
+#ifdef WIN32   //this is needed on WIN32 to get libglade see the callback
 #define _BB  __declspec(dllexport)
 #else
 #define _BB  
 #endif
 
-
-typedef struct{
-       Agnode_t* Node;
-       GLfloat x;
-       GLfloat y;
-       GLfloat z;
-
-       GLfloat distorted_x;            //geometric fisheye coords
-       GLfloat distorted_y;
-       GLfloat 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;
-
-}topview_node;
-
-typedef struct{
-       Agnode_t* Tnode;        //Tail node
-       Agnode_t* Hnode;        //Tail node
-       Agedge_t *Edge;         //edge itself
-       GLfloat x1;
-       GLfloat y1;
-       GLfloat z1;
-       GLfloat x2;
-       GLfloat y2;
-       GLfloat z2;
-       topview_node* Node1;
-       topview_node* Node2;
-       RGBColor Color;
-       int update_required;
-
-}topview_edge;
-typedef struct {
-       topview_node Nodes[MAX_TOP_VIEW_NODE_COUNT];
-       topview_edge Edges[MAX_TOP_VIEW_EDGE_COUNT];
-       int Nodecount;
-       int Edgecount;
-       int limits[4];
-} topview;
-extern topview Topview;
-extern void PrepareTopview(Agraph_t *g);
+void cleartopview(topview* t);
+void preparetopview(Agraph_t *g,topview* t);
 int select_topview_node(topview_node *n);
 int select_topview_edge(topview_edge *e);
 int update_topview_node_from_cgraph(topview_node* Node);
 int update_topview_edge_from_cgraph(topview_edge* Edge);
 int set_update_required(topview* t);
-int draw_topview_label(topview_node* v);
-int randomize_color(RGBColor* c,int brightness);
-void drawCircle(float x,float y,float radius);
+int draw_topview_label(topview_node* v,float zdepth);
 void set_topview_options();
-void set_boundries();
+void set_boundries(topview* t);
 int get_color_from_edge(topview_edge *e);
 int node_visible(Agnode_t* n);
 int move_TVnodes();
-int draw_navigation_menu();
-int load_host_buttons(Agraph_t *g);
 void originate_distorded_coordinates(topview* t);
-int prepare_nodes_for_groups(int groupindex);
-int validate_group_node(tv_node* TV_Node,char* regex_string);
-int click_group_button(int groupindex);
-_BB void host_button_clicked_Slot(GtkWidget *widget,gpointer     user_data);
 _BB void on_host_alpha_change (GtkWidget *widget,gpointer     user_data);
-//global gui pointers for buttons and color selection boxes
-extern GtkButton** gtkhostbtn;
-extern int gtkhostbtncount;
-extern GtkColorButton** gtkhostcolor;
-extern int hostactive[50];     //temporary static, convert to dynamic,realloc
-extern char** hostregex;
 double dist(double x1, double y1, double x2, double y2);
 double G(double x);
-extern int fisheye_distortion_fac;
+glCompSet* glcreate_gl_topview_menu();
+void fisheye_polar(double x_focus, double y_focus,topview* t);
+
 
 #endif
index 66a88c208710954aa53b71ea067f68404ed1f32a..836cad621bcdb8bea1f643522979b94f61c76fc7 100755 (executable)
@@ -17,6 +17,7 @@
 #include "topview.h"
 #include "tvnodes.h"
 #include "btree.h"
+#include "viewport.h"
 tv_nodes TV_Nodes;
 static char buf [255];
 int MP_Flag=0;
@@ -89,19 +90,19 @@ extern int set_filter(tv_filter* TV_Filter,char* MinData1,char* MaxData1,char* M
 int reverse_selection()
 {
        int i=0;
-       for (i; i < Topview.Nodecount ; i ++)
+       for (i; i < view->Topview->Nodecount ; i ++)
        {
-               if (((custom_object_data*)AGDATA(Topview.Nodes[i].Node))->Selected )
-                       deselect_node(view.g[view.activeGraph],Topview.Nodes[i].Node);
+               if (((custom_object_data*)AGDATA(view->Topview->Nodes[i].Node))->Selected )
+                       deselect_node(view->g[view->activeGraph],view->Topview->Nodes[i].Node);
                else
-                       select_node(view.g[view.activeGraph],Topview.Nodes[i].Node);
+                       select_node(view->g[view->activeGraph],view->Topview->Nodes[i].Node);
        }
-       for (i=0; i < Topview.Edgecount ; i ++)
+       for (i=0; i < view->Topview->Edgecount ; i ++)
        {
-               if (((custom_object_data*)AGDATA(Topview.Edges[i].Edge))->Selected )
-                       deselect_edge(view.g[view.activeGraph],Topview.Edges[i].Edge);
+               if (((custom_object_data*)AGDATA(view->Topview->Edges[i].Edge))->Selected )
+                       deselect_edge(view->g[view->activeGraph],view->Topview->Edges[i].Edge);
                else
-                       select_edge(view.g[view.activeGraph],Topview.Edges[i].Edge);
+                       select_edge(view->g[view->activeGraph],view->Topview->Edges[i].Edge);
        }
 }
 int validate_node(tv_node* TV_Node)
@@ -113,8 +114,8 @@ int validate_node(tv_node* TV_Node)
        char* data2;
 //             n=tree_from_filter_string("([IP=\"^10.*\",min=\"0\",max=\"0\"])");
        // get attributes from graph
-       data_attr1=agget(view.g[view.activeGraph],"DataAttribute1");
-       data_attr2=agget(view.g[view.activeGraph],"DataAttribute2");
+       data_attr1=agget(view->g[view->activeGraph],"DataAttribute1");
+       data_attr2=agget(view->g[view->activeGraph],"DataAttribute2");
 
 
        if (TV_Nodes.filtered)
@@ -124,23 +125,23 @@ int validate_node(tv_node* TV_Node)
                {
                        n=tree_from_filter_string(TV_Nodes.filter.filter_string);
                        MP_Flag=0;
-                       if (strcmp(TV_Nodes.filter.min_data1,  agget(Topview.Nodes[TV_Node->index].Node,data_attr1)   ))
+                       if (strcmp(TV_Nodes.filter.min_data1,  agget(view->Topview->Nodes[TV_Node->index].Node,data_attr1)   ))
                                valid=0;
                }
-               if (data_attr1 && TV_Nodes.filter.max_data1 && agget(Topview.Nodes[TV_Node->index].Node,data_attr1))
+               if (data_attr1 && TV_Nodes.filter.max_data1 && agget(view->Topview->Nodes[TV_Node->index].Node,data_attr1))
                {
-                       if (strcmp(agget(Topview.Nodes[TV_Node->index].Node,data_attr1),TV_Nodes.filter.min_data1))
+                       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 && TV_Nodes.filter.min_data2 && agget(Topview.Nodes[TV_Node->index].Node,data_attr2))
+               if (data_attr2 && TV_Nodes.filter.min_data2 && agget(view->Topview->Nodes[TV_Node->index].Node,data_attr2))
                {
-                       if (strcmp(TV_Nodes.filter.min_data2,  agget(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 && TV_Nodes.filter.max_data2 && agget(Topview.Nodes[TV_Node->index].Node,data_attr2))
+               if (data_attr2 && TV_Nodes.filter.max_data2 && agget(view->Topview->Nodes[TV_Node->index].Node,data_attr2))
                {
-                       if (agget(Topview.Nodes[TV_Node->index].Node,data_attr2),TV_Nodes.filter.min_data2)
+                       if (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)
@@ -148,19 +149,19 @@ int validate_node(tv_node* TV_Node)
                //if show only highlighted 
                if (TV_Nodes.filter.highlighted >= 0)   
                {
-                       if(((custom_object_data*)AGDATA(Topview.Nodes[TV_Node->index].Node))->Highlighted!= TV_Nodes.filter.highlighted)
+                       if(((custom_object_data*)AGDATA(view->Topview->Nodes[TV_Node->index].Node))->Highlighted!= TV_Nodes.filter.highlighted)
                                valid=0;
                }
                //if show only visibles
                if (TV_Nodes.filter.visible >= 0)       
                {
-                       if(((custom_object_data*)AGDATA(Topview.Nodes[TV_Node->index].Node))->Visible!= TV_Nodes.filter.visible)
+                       if(((custom_object_data*)AGDATA(view->Topview->Nodes[TV_Node->index].Node))->Visible!= TV_Nodes.filter.visible)
                                valid=0;
                }
                //if show only selected
                if (TV_Nodes.filter.selected >= 0)      
                {
-                       if(((custom_object_data*)AGDATA(Topview.Nodes[TV_Node->index].Node))->Selected!= TV_Nodes.filter.selected)
+                       if(((custom_object_data*)AGDATA(view->Topview->Nodes[TV_Node->index].Node))->Selected!= TV_Nodes.filter.selected)
                                valid=0;
                }
                return valid;
@@ -177,8 +178,8 @@ int update_node_gui_objects(tv_node* TV_Node)
        GtkLayout* layout;
 
        // get attributes from graph
-       data_attr1=agget(view.g[view.activeGraph],"DataAttribute1");
-       data_attr2=agget(view.g[view.activeGraph],"DataAttribute2");
+       data_attr1=agget(view->g[view->activeGraph],"DataAttribute1");
+       data_attr2=agget(view->g[view->activeGraph],"DataAttribute2");
 
        //create if objects are null    
        layout=glade_xml_get_widget(xml, "layoutTVData");
@@ -189,7 +190,7 @@ int update_node_gui_objects(tv_node* TV_Node)
                gtk_layout_put  (layout,TV_Node->chkSelected,LOCATION_X_CHKSELECTED,TV_Nodes.Y);
        }
        gtk_widget_show(TV_Node->chkSelected);
-       gtk_toggle_button_set_active(TV_Node->chkSelected,((custom_object_data*)AGDATA(Topview.Nodes[TV_Node->index].Node))->Selected);
+       gtk_toggle_button_set_active(TV_Node->chkSelected,((custom_object_data*)AGDATA(view->Topview->Nodes[TV_Node->index].Node))->Selected);
 
        //Id Label
        if (!TV_Node->IDLabel)
@@ -209,7 +210,7 @@ int update_node_gui_objects(tv_node* TV_Node)
        }
 
        gtk_widget_show(TV_Node->chkVisible);
-       gtk_toggle_button_set_active(TV_Node->chkVisible,((custom_object_data*)AGDATA(Topview.Nodes[TV_Node->index].Node))->Visible);
+       gtk_toggle_button_set_active(TV_Node->chkVisible,((custom_object_data*)AGDATA(view->Topview->Nodes[TV_Node->index].Node))->Visible);
        //highlighted
        if (!TV_Node->chkHighlighted)
        {
@@ -217,7 +218,7 @@ int update_node_gui_objects(tv_node* TV_Node)
                gtk_layout_put  (layout,TV_Node->chkHighlighted,LOCATION_X_CHKHIGHLIGHTED,TV_Nodes.Y);
        }
        gtk_widget_show(TV_Node->chkHighlighted);
-       gtk_toggle_button_set_active(TV_Node->chkHighlighted,((custom_object_data*)AGDATA(Topview.Nodes[TV_Node->index].Node))->Highlighted);
+       gtk_toggle_button_set_active(TV_Node->chkHighlighted,((custom_object_data*)AGDATA(view->Topview->Nodes[TV_Node->index].Node))->Highlighted);
 
        
        //DATA 1
@@ -230,7 +231,7 @@ int update_node_gui_objects(tv_node* TV_Node)
        }
        if(data_attr1)
        {
-               gtk_entry_set_text (TV_Node->Data1,agget(Topview.Nodes[TV_Node->index].Node,data_attr1));
+               gtk_entry_set_text (TV_Node->Data1,agget(view->Topview->Nodes[TV_Node->index].Node,data_attr1));
        }
        else
                gtk_entry_set_text (TV_Node->Data1,"");
@@ -245,7 +246,7 @@ int update_node_gui_objects(tv_node* TV_Node)
        }
        if(data_attr2)
        {
-               gtk_entry_set_text (TV_Node->Data2,agget(Topview.Nodes[TV_Node->index].Node,data_attr2));
+               gtk_entry_set_text (TV_Node->Data2,agget(view->Topview->Nodes[TV_Node->index].Node,data_attr2));
        }
        else
                gtk_entry_set_text (TV_Node->Data2,"");
@@ -290,11 +291,11 @@ extern int tv_nodes_goto_page(int page)
        }
        else
                return 0;
-       while ((TV_Nodes.page_data_index < TV_Nodes.recordperpage)&&(TV_Nodes.page_data_node_index < Topview.Nodecount))
+       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(Topview.Nodes[TV_Nodes.page_data_node_index].valid==1)
+               if(view->Topview->Nodes[TV_Nodes.page_data_node_index].valid==1)
                {
                        TV_Nodes.page_data_index++;
                        update_node_gui_objects(tvn);
@@ -416,16 +417,16 @@ extern int prepare_page_history()
        reset_page_History();
        push_to_page_history(0);
        
-       for (i;i < Topview.Nodecount ; i++)
+       for (i;i < view->Topview->Nodecount ; i++)
        {
                tvn.index=i;
                if(validate_node(&tvn))
                {
                        count ++;
-                       Topview.Nodes[i].valid=1;
+                       view->Topview->Nodes[i].valid=1;
                }
                else
-                       Topview.Nodes[i].valid=0;
+                       view->Topview->Nodes[i].valid=0;
                if (count== TV_Nodes.recordperpage)
                {
                        push_to_page_history(i+1);
@@ -451,21 +452,21 @@ static int set_data_attributes()
        char* data_attr2;
        char buf[255];
        // get attributes from graph
-       data_attr1=agget(view.g[view.activeGraph],"DataAttribute1");
-       data_attr2=agget(view.g[view.activeGraph],"DataAttribute2");
+       data_attr1=agget(view->g[view->activeGraph],"DataAttribute1");
+       data_attr2=agget(view->g[view->activeGraph],"DataAttribute2");
        if (!data_attr1)
        {
-               agattr(view.g[view.activeGraph],AGRAPH,"DataAttribute1","DATA1");
-               agattr(view.g[view.activeGraph],AGNODE,"DATA1","");
+               agattr(view->g[view->activeGraph],AGRAPH,"DataAttribute1","DATA1");
+               agattr(view->g[view->activeGraph],AGNODE,"DATA1","");
        }
        if (!data_attr2)
        {
-               agattr(view.g[view.activeGraph],AGRAPH,"DataAttribute2","DATA2");
-               agattr(view.g[view.activeGraph],AGNODE,"DATA2","");
+               agattr(view->g[view->activeGraph],AGRAPH,"DataAttribute2","DATA2");
+               agattr(view->g[view->activeGraph],AGNODE,"DATA2","");
        }
 
-       data_attr1=agget(view.g[view.activeGraph],"DataAttribute1");
-       data_attr2=agget(view.g[view.activeGraph],"DataAttribute2");
+       data_attr1=agget(view->g[view->activeGraph],"DataAttribute1");
+       data_attr2=agget(view->g[view->activeGraph],"DataAttribute2");
 
        lblData1=glade_xml_get_widget(xml, "lblTVData1");
        lblData2=glade_xml_get_widget(xml, "lblTVData2");
@@ -482,51 +483,51 @@ extern int update_TV_data_from_gui()
        char* data_attr1;
        char* data_attr2;
        // get attributes from graph
-       data_attr1=agget(view.g[view.activeGraph],"DataAttribute1");
-       data_attr2=agget(view.g[view.activeGraph],"DataAttribute2");
+       data_attr1=agget(view->g[view->activeGraph],"DataAttribute1");
+       data_attr2=agget(view->g[view->activeGraph],"DataAttribute2");
 
        for (i;i < TV_Nodes.recordperpage ; i++)
        {
                index=TV_Nodes.TV_Node[i].index;
-               if (index < Topview.Nodecount)
+               if (index < view->Topview->Nodecount)
                {
                        // apply if selected
                        if(gtk_toggle_button_get_active(TV_Nodes.TV_Node[i].chkSelected))
                        {
-                               if (!((custom_object_data*)AGDATA(Topview.Nodes[index].Node))->Selected)
-                                       select_node(view.g[view.activeGraph],Topview.Nodes[index].Node);                                        
+                               if (!((custom_object_data*)AGDATA(view->Topview->Nodes[index].Node))->Selected)
+                                       select_node(view->g[view->activeGraph],view->Topview->Nodes[index].Node);                                       
                        }
                        else
                        {
-                               if (((custom_object_data*)AGDATA(Topview.Nodes[index].Node))->Selected)
-                                       deselect_node(view.g[view.activeGraph],Topview.Nodes[index].Node);                                      
+                               if (((custom_object_data*)AGDATA(view->Topview->Nodes[index].Node))->Selected)
+                                       deselect_node(view->g[view->activeGraph],view->Topview->Nodes[index].Node);                                     
                        }
                        // apply if Visible
                        if(gtk_toggle_button_get_active(TV_Nodes.TV_Node[i].chkVisible))
                        {
-                               if (!((custom_object_data*)AGDATA(Topview.Nodes[index].Node))->Visible)
-                                       ((custom_object_data*)AGDATA(Topview.Nodes[index].Node))->Visible=1;
+                               if (!((custom_object_data*)AGDATA(view->Topview->Nodes[index].Node))->Visible)
+                                       ((custom_object_data*)AGDATA(view->Topview->Nodes[index].Node))->Visible=1;
                        }
                        else
                        {
-                               if (((custom_object_data*)AGDATA(Topview.Nodes[index].Node))->Visible)
-                                       ((custom_object_data*)AGDATA(Topview.Nodes[index].Node))->Visible=0;
+                               if (((custom_object_data*)AGDATA(view->Topview->Nodes[index].Node))->Visible)
+                                       ((custom_object_data*)AGDATA(view->Topview->Nodes[index].Node))->Visible=0;
                        }
                        // apply if Highlighted
                        if(gtk_toggle_button_get_active(TV_Nodes.TV_Node[i].chkHighlighted))
                        {
-                               if (!((custom_object_data*)AGDATA(Topview.Nodes[index].Node))->Highlighted)
-                                       ((custom_object_data*)AGDATA(Topview.Nodes[index].Node))->Highlighted=1;
+                               if (!((custom_object_data*)AGDATA(view->Topview->Nodes[index].Node))->Highlighted)
+                                       ((custom_object_data*)AGDATA(view->Topview->Nodes[index].Node))->Highlighted=1;
                        }
                        else
                        {
-                               if (((custom_object_data*)AGDATA(Topview.Nodes[index].Node))->Highlighted)
-                                       ((custom_object_data*)AGDATA(Topview.Nodes[index].Node))->Highlighted=0;
+                               if (((custom_object_data*)AGDATA(view->Topview->Nodes[index].Node))->Highlighted)
+                                       ((custom_object_data*)AGDATA(view->Topview->Nodes[index].Node))->Highlighted=0;
                        }
                        //Data1 
-                       agset(Topview.Nodes[index].Node,data_attr1,gtk_entry_get_text (TV_Nodes.TV_Node[i].Data1));
+                       agset(view->Topview->Nodes[index].Node,data_attr1,gtk_entry_get_text (TV_Nodes.TV_Node[i].Data1));
                        //Data2 
-                       agset(Topview.Nodes[index].Node,data_attr2,gtk_entry_get_text (TV_Nodes.TV_Node[i].Data2));
+                       agset(view->Topview->Nodes[index].Node,data_attr2,gtk_entry_get_text (TV_Nodes.TV_Node[i].Data2));
 
                }
        }
@@ -578,12 +579,12 @@ extern int tv_select_all()
 
        tv_node tvn;
        int i=0;
-       for (i;i < Topview.Nodecount ; i++)
+       for (i;i < view->Topview->Nodecount ; i++)
        {
                tvn.index=i;
                if(validate_node(&tvn))
                {
-                       select_node(view.g[view.activeGraph],Topview.Nodes[i].Node);
+                       select_node(view->g[view->activeGraph],view->Topview->Nodes[i].Node);
                }
        }
        apply_filter_from_gui();
@@ -593,12 +594,12 @@ extern int tv_unselect_all()
 
        tv_node tvn;
        int i=0;
-       for (i;i < Topview.Nodecount ; i++)
+       for (i;i < view->Topview->Nodecount ; i++)
        {
                tvn.index=i;
                if(validate_node(&tvn))
                {
-                       deselect_node(view.g[view.activeGraph],Topview.Nodes[i].Node);
+                       deselect_node(view->g[view->activeGraph],view->Topview->Nodes[i].Node);
                }
        }
        apply_filter_from_gui();
@@ -607,12 +608,12 @@ extern int tv_highligh_all()
 {
        tv_node tvn;
        int i=0;
-       for (i;i < Topview.Nodecount ; i++)
+       for (i;i < view->Topview->Nodecount ; i++)
        {
                tvn.index=i;
                if(validate_node(&tvn))
                {
-                       ((custom_object_data*)AGDATA(Topview.Nodes[i].Node))->Highlighted=1;
+                       ((custom_object_data*)AGDATA(view->Topview->Nodes[i].Node))->Highlighted=1;
                }
        }
        apply_filter_from_gui();
@@ -624,12 +625,12 @@ extern int tv_unhighligh_all()
 {
        tv_node tvn;
        int i=0;
-       for (i;i < Topview.Nodecount ; i++)
+       for (i;i < view->Topview->Nodecount ; i++)
        {
                tvn.index=i;
                if(validate_node(&tvn))
                {
-                       ((custom_object_data*)AGDATA(Topview.Nodes[i].Node))->Highlighted=0;
+                       ((custom_object_data*)AGDATA(view->Topview->Nodes[i].Node))->Highlighted=0;
                }
        }
        apply_filter_from_gui();
@@ -640,12 +641,12 @@ extern int tv_show_all()
 {
        tv_node tvn;
        int i=0;
-       for (i;i < Topview.Nodecount ; i++)
+       for (i;i < view->Topview->Nodecount ; i++)
        {
                tvn.index=i;
                if(validate_node(&tvn))
                {
-                       ((custom_object_data*)AGDATA(Topview.Nodes[i].Node))->Visible=1;
+                       ((custom_object_data*)AGDATA(view->Topview->Nodes[i].Node))->Visible=1;
                }
        }
        apply_filter_from_gui();
@@ -658,12 +659,12 @@ extern int tv_hide_all()
 {
        tv_node tvn;
        int i=0;
-       for (i;i < Topview.Nodecount ; i++)
+       for (i;i < view->Topview->Nodecount ; i++)
        {
                tvn.index=i;
                if(validate_node(&tvn))
                {
-                       ((custom_object_data*)AGDATA(Topview.Nodes[i].Node))->Visible=0;
+                       ((custom_object_data*)AGDATA(view->Topview->Nodes[i].Node))->Visible=0;
                }
        }
        apply_filter_from_gui();
index 7120594fd0313fef7b4d376a35b9fce9d9951444..20f5a051415f85fba34c64868c5123e0479c9deb 100755 (executable)
@@ -18,7 +18,6 @@
 #define TVNODES_H
 
 #include "gui.h"
-
 #define MAX_NODE_PER_PAGE 100
 #define LOCATION_X_CHKSELECTED 16
 #define LOCATION_X_IDLABEL 45
index 9dac28b03f6da592457211923e8970fa20da35e7..949b4bbe8cb1ec3a87bc450de7debeb615e68153 100755 (executable)
@@ -19,6 +19,7 @@
 #endif
 #include "compat.h"
 #include "viewport.h"
+#include "draw.h"
 #include "color.h"
 #include <glade/glade.h>
 #include "gui.h"
 
 #define countof( array ) ( sizeof( array )/sizeof( array[0] ) )
 
-char* globalString;
-ViewInfo       view;
-Agraph_t* tempG;       //helper graph for default attr values,
-int SignalBlock;
-
-float TopViewPointsX [50000];
-float TopViewPointsY [50000];
-
-float TopViewEdgesHeadX[50000];
-float TopViewEdgesHeadY[50000];
-float TopViewEdgesTailX[50000];
-float TopViewEdgesTailY[50000];
-
-int    TopViewNodeCount;
-int    TopViewEdgeCount;
+ViewInfo*      view;
+/*these two global variables should be wrapped in somethign else*/
 GtkMessageDialog*  Dlg;
 int respond;
 
+void clear_viewport(ViewInfo* view)
+{
+       int ind=0;
+       /*free topview if there is one*/
+       if(view->graphCount)
+       {
+               cleartopview(view->Topview);
+               /*all cgraph graphs should be freed*/
+               for (ind=0;ind < view->graphCount;ind ++)
+               {
+                       agclose(view->g[ind]);
+               }
+               /*frees itself*/
+               free(view);
+       }
+}
 void init_viewport(ViewInfo* view)
 {
 
@@ -59,17 +63,18 @@ void init_viewport(ViewInfo* view)
        view->bdzBottom=0;
        view->bdzTop=0;
 
-       view->bdA=1;
-       view->bdR=1;
-       view->bdG=0;
-       view->bdB=0;
-       view->bdVisible=0;              //show borders red
+       view->borderColor.R=1;
+       view->borderColor.G=0;
+       view->borderColor.B=0;
+       view->borderColor.A=1;
+
+       view->bdVisible=1;              //show borders red
        
        view->gridSize=10;
-       view->grR=0.5;  
-       view->grG=0.5;  
-       view->grB=0.5;  
-       view->grA=1;
+       view->gridColor.R=0.5;
+       view->gridColor.G=0.5;
+       view->gridColor.B=0.5;
+       view->gridColor.A=1;
        view->gridVisible=0;    //show grids in light gray
 
        //mouse mode=pan
@@ -111,10 +116,9 @@ void init_viewport(ViewInfo* view)
 
        view->zoom=-20;
        view->texture=1;
-       view->font_textures=NULL;
-       view->font_texture_count=0;     //number of openGL textures, used internally
        view->FontSize=52;
-               
+
+       view->topviewusermode =TOP_VIEW_USER_NOVICE_MODE;       //for demo
        view->mg.active=0;
        view->mg.x=0;
        view->mg.y=0;
@@ -125,13 +129,14 @@ void init_viewport(ViewInfo* view)
        view->fmg.active=0;
        view->mouse.mouse_down=0;
        view->activeGraph=-1;
-       SignalBlock=0;
+       view->SignalBlock=0;
        view->Selection.Active=0;
        view->Selection.SelectionColor.R=0.5;
-       view->Selection.SelectionColor.G=0.2;
+       view->Selection.SelectionColor.G=(float)0.2;
        view->Selection.SelectionColor.B=1;
        view->Selection.SelectionColor.A=1;
        view->Selection.Anti=0;
+       view->Topview=malloc(sizeof(topview));
 }
 
 int add_graph_to_viewport_from_file (char* fileName)
@@ -141,12 +146,12 @@ int add_graph_to_viewport_from_file (char* fileName)
        graph=loadGraph(fileName);
        if(graph)
        {
-               view.graphCount = view.graphCount + 1; 
-               view.g= (Agraph_t**)realloc(view.g,sizeof(Agraph_t*)*view.graphCount);
-               view.g[view.graphCount-1]=graph;
-               view.activeGraph=view.graphCount-1;
+               view->graphCount = view->graphCount + 1; 
+               view->g= (Agraph_t**)realloc(view->g,sizeof(Agraph_t*)*view->graphCount);
+               view->g[view->graphCount-1]=graph;
+               view->activeGraph=view->graphCount-1;
                //GUI update , graph combo box on top-right should be updated
-               refreshControls(&view);
+               refreshControls(view);
                return 1;
        }
        else
@@ -161,9 +166,9 @@ int add_new_graph_to_viewport()
        graph=(Agraph_t*) malloc(sizeof(Agraph_t));
        if(graph)
        {
-               view.graphCount = view.graphCount + 1; 
-               view.g[view.graphCount-1]=graph;
-               return (view.graphCount-1);
+               view->graphCount = view->graphCount + 1; 
+               view->g[view->graphCount-1]=graph;
+               return (view->graphCount-1);
        }
        else
                return -1;
@@ -181,9 +186,9 @@ void refreshControls(ViewInfo* v)
        {
                gtk_combo_box_append_text(widget,((custom_graph_data*)(AGDATA(v->g[i])))->GraphFileName);
        }
-       SignalBlock=1;  //HACK
-       gtk_combo_box_set_active (widget,view.activeGraph);
-       SignalBlock=0;
+       view->SignalBlock=1;    //HACK
+       gtk_combo_box_set_active (widget,view->activeGraph);
+       view->SignalBlock=0;
 
 
        //change button colors
@@ -194,7 +199,7 @@ void refreshControls(ViewInfo* v)
        Color_Widget_bg ("gray",glade_xml_get_widget(xml, "btnFdp"));   
 
 
-       switch( ((custom_graph_data*)(AGDATA(view.g[view.activeGraph])))->Engine )
+       switch( ((custom_graph_data*)(AGDATA(view->g[view->activeGraph])))->Engine )
        {
                case 0: 
                        Color_Widget_bg ("red",glade_xml_get_widget(xml, "btnDot"));    
@@ -218,7 +223,7 @@ void refreshControls(ViewInfo* v)
 
 
        }
-       expose_event (drawing_area,NULL,NULL);
+       expose_event (view->drawing_area,NULL,NULL);
 
                
 
@@ -285,9 +290,9 @@ void load_graph_params(Agraph_t* graph)     //run once right after loading graph
        
        
 /*             if(agget((void*)g, "xdotversion"))      //xdot exists
-                       ((custom_graph_data*)AGDATA(g))->TopView=0; //need to check xdot version attribute
-               else            //we dont know if it is topview or simply a graph with no xdot, for testing i ll use topview
-                       ((custom_graph_data*)AGDATA(g))->TopView=1;  */
+                       ((custom_graph_data*)AGDATA(g))->view->Topview=0; //need to check xdot version attribute
+               else            //we dont know if it is view->Topview or simply a graph with no xdot, for testing i ll use view->Topview
+                       ((custom_graph_data*)AGDATA(g))->view->Topview=1;  */
 
 
 
@@ -298,22 +303,23 @@ void load_graph_params(Agraph_t* graph)   //run once right after loading graph
 int save_graph()       //save without prompt
 {
        //check if there is an active graph
-       if(view.activeGraph > -1)
+       if(view->activeGraph > -1)
        {
                //check if active graph has a file name
-               if (((custom_graph_data*)AGDATA(view.g[view.activeGraph]))->GraphFileName)
+               if (((custom_graph_data*)AGDATA(view->g[view->activeGraph]))->GraphFileName)
                {
-                       return save_graph_with_file_name(view.g[view.activeGraph],((custom_graph_data*)AGDATA(view.g[view.activeGraph]))->GraphFileName);
+                       return save_graph_with_file_name(view->g[view->activeGraph],((custom_graph_data*)AGDATA(view->g[view->activeGraph]))->GraphFileName);
                }
                else
                        return save_as_graph();
        }
+       return 1;
 
 }
 int save_as_graph() //save with prompt
 {
        //check if there is an active graph
-       if(view.activeGraph > -1)
+       if(view->activeGraph > -1)
        {
                GtkWidget *dialog;
                dialog = gtk_file_chooser_dialog_new ("Save File",
@@ -327,7 +333,7 @@ int save_as_graph() //save with prompt
                {
                        char *filename;
                        filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
-                       save_graph_with_file_name(view.g[view.activeGraph],filename);
+                       save_graph_with_file_name(view->g[view->activeGraph],filename);
                        g_free (filename);
                        gtk_widget_destroy (dialog);
 
@@ -339,6 +345,7 @@ int save_as_graph() //save with prompt
                        return 0;
                }
        }
+       return 0;
 }
 int save_graph_with_file_name(Agraph_t* graph,char* fileName)  //saves graph with file name,if file name is NULL save as is ++
 {
@@ -368,6 +375,7 @@ int save_graph_with_file_name(Agraph_t* graph,char* fileName)       //saves graph with
                g_print("%s sucessfully saved \n", fileName);
                        return 1;
        }
+       return 0;
 }
 
 int create_xdot_for_graph(Agraph_t* graph,int keeppos)
@@ -435,6 +443,8 @@ int create_xdot_for_graph(Agraph_t* graph,int keeppos)
        else
                return FALSE;
 
+       return 0;
+
 }
 int do_graph_layout(Agraph_t* graph,int Engine,int keeppos) //changes the layout, all user relocations are reset unless keeppos is set to 1
 {
@@ -445,36 +455,36 @@ int do_graph_layout(Agraph_t* graph,int Engine,int keeppos) //changes the layout
        int cnt;*/
 //     mydata *p;
        FILE* input_file;
-       char* _filename=(char*)malloc((strlen(((custom_graph_data*)(AGDATA(view.g[view.activeGraph])))->GraphFileName)+1)*sizeof(char));
-               strcpy(_filename,((custom_graph_data*)AGDATA(view.g[view.activeGraph]))->GraphFileName); 
+       char* _filename=(char*)malloc((strlen(((custom_graph_data*)(AGDATA(view->g[view->activeGraph])))->GraphFileName)+1)*sizeof(char));
+               strcpy(_filename,((custom_graph_data*)AGDATA(view->g[view->activeGraph]))->GraphFileName); 
 
        
-       ((custom_graph_data*)AGDATA(view.g[view.activeGraph]))->Engine=Engine;
-               create_xdot_for_graph(view.g[view.activeGraph],keeppos);
+       ((custom_graph_data*)AGDATA(view->g[view->activeGraph]))->Engine=Engine;
+               create_xdot_for_graph(view->g[view->activeGraph],keeppos);
 
 #ifdef _WIN32
        input_file = fopen("c:/__tempfile.xdot", "r");
 #else
        input_file = fopen("/tmp/__tempfile.xdot", "r");
 #endif
-       clear_graph(view.g[view.activeGraph]);
-       agclose(view.g[view.activeGraph]);
+       clear_graph(view->g[view->activeGraph]);
+       agclose(view->g[view->activeGraph]);
        if (input_file  == NULL)
                g_print("temp file Cannot open n");
-       else if (view.g[view.activeGraph]= agread(input_file,NIL(Agdisc_t*)))
+       else if (view->g[view->activeGraph]= agread(input_file,NIL(Agdisc_t*)))
        {
                fclose(input_file);
                //attaching rec for graph fields
-               attach_object_custom_data_to_graph(view.g[view.activeGraph]);
+               attach_object_custom_data_to_graph(view->g[view->activeGraph]);
                //set real file name
-               ((custom_graph_data*)AGDATA(view.g[view.activeGraph]))->GraphFileName=(char*)malloc((strlen(_filename)+1)*sizeof(char)); 
-               load_graph_params(view.g[view.activeGraph]);    //init glparams
-               strcpy(((custom_graph_data*)AGDATA(view.g[view.activeGraph]))->GraphFileName,_filename); 
+               ((custom_graph_data*)AGDATA(view->g[view->activeGraph]))->GraphFileName=(char*)malloc((strlen(_filename)+1)*sizeof(char)); 
+               load_graph_params(view->g[view->activeGraph]);  //init glparams
+               strcpy(((custom_graph_data*)AGDATA(view->g[view->activeGraph]))->GraphFileName,_filename); 
                free(_filename);
                //set engine
-               ((custom_graph_data*)AGDATA(view.g[view.activeGraph]))->Engine=Engine;
-               ((custom_graph_data*)AGDATA(view.g[view.activeGraph]))->Modified=1;
-               refreshControls(&view);
+               ((custom_graph_data*)AGDATA(view->g[view->activeGraph]))->Engine=Engine;
+               ((custom_graph_data*)AGDATA(view->g[view->activeGraph]))->Modified=1;
+               refreshControls(view);
                return 1;
        }
        else
@@ -484,7 +494,7 @@ int do_graph_layout(Agraph_t* graph,int Engine,int keeppos) //changes the layout
        }
 
        
-
+       return 0;
 
 }
 
@@ -498,11 +508,6 @@ void clear_graph(Agraph_t* graph)
 Agraph_t* loadGraph(char* filename)
 {
        Agraph_t *g;
-       Agnode_t *v;
-       Agedge_t *e;
-       Agsym_t *attr;
-       Dict_t *d;
-       int cnt;
 //     mydata *p;
        FILE* input_file;
        input_file = fopen(filename, "r");
@@ -555,26 +560,26 @@ Agraph_t* loadGraph(char* filename)
                ((custom_graph_data*)AGDATA(g))->GraphFileName=(char*)malloc((strlen(filename)+1)*sizeof(char)); 
                //attaching rec for graph objects
                strcpy(((custom_graph_data*)AGDATA(g))->GraphFileName,filename); 
-               printf("topview:%s------",agget(g, "TopView"));
-               if(strcasecmp(agget(g, "TopView"),"1")==0)
+               printf("Topview:%s------",agget(g, "TopView"));
+               /*if(strcasecmp(agget(g, "TopView"),"1")==0)
                {
-                       if(TopViewNodeCount > 0)
+                       if(
+                               TopviewNodeCount > 0)
                        {
                                Dlg=gtk_message_dialog_new (NULL,
                                                                        GTK_DIALOG_MODAL,
                                          GTK_MESSAGE_WARNING,
                                                                        GTK_BUTTONS_OK,
-                                                                       "For Performance issues , this program does not support multiple topview graphs!");
+                                                                       "For Performance issues , this program does not support multiple Topview graphs!");
                                respond=gtk_dialog_run (Dlg);
                                gtk_object_destroy (Dlg);
                                agclose(g);
                                return 0;
                        }
                        else
-                       {
                                PrepareTopview(g);
-                       }
-               }
+               }*/
+               preparetopview(g,view->Topview);
                return g;
        }
        else
@@ -582,7 +587,7 @@ Agraph_t* loadGraph(char* filename)
                printf("failed to load %s\n",filename);
                return 0;
        }
-
+       return 0;
 }
 int clear_object_xdot(void* obj)
 {
@@ -661,8 +666,8 @@ int attach_object_custom_data_to_graph(Agraph_t* graph)
                        init_object_custom_data(graph,e);       //attach to edge
                }
        }
+       return 1;
        
-
 }
 
 
@@ -771,24 +776,23 @@ void move_node(void* obj,float dx,float dy)
 void move_nodes(Agraph_t* g)   //move selected nodes 
 {
        Agnode_t* obj;
-       Agedge_t* e;
 
        float dx,dy;
        xdot* bf;
        int i=0;
-       dx=view.GLx-view.GLx2;
-       dy=view.GLy-view.GLy2;
+       dx=view->GLx-view->GLx2;
+       dy=view->GLy-view->GLy2;
 
-       if(((custom_graph_data*)AGDATA(view.g[view.activeGraph]))->TopView == 0)
+       if(((custom_graph_data*)AGDATA(view->g[view->activeGraph]))->TopView == 0)
        {
                for (i=0;i < ((custom_graph_data*)AGDATA(g))->selectedNodesCount;i++)
                {       
                        obj=((custom_graph_data*)AGDATA(g))->selectedNodes[i];
                        bf=parseXDot (agget(obj,"_draw_"));
-                       agset(obj,"_draw_",move_xdot(obj,bf,(int)dx,(int)dy,0.00));
+                       agset(obj,"_draw_",move_xdot(obj,bf,(int)dx,(int)dy,0));
                        free(bf);
                        bf=parseXDot (agget(obj,"_ldraw_"));
-                       agset(obj,"_ldraw_",move_xdot(obj,bf,(int)dx,(int)dy,0.00));
+                       agset(obj,"_ldraw_",move_xdot(obj,bf,(int)dx,(int)dy,0));
                        free(bf);
                        move_node(obj,dx,dy);
                        //iterate edges
@@ -829,39 +833,24 @@ void move_nodes(Agraph_t* g)      //move selected nodes
 
 
 
-RGBColor GetRGBColor(char* color)
-{
-       gvcolor_t cl;   
-       RGBColor c;
-       if(color != '\0')
-       {
-               colorxlate(color, &cl, RGBA_DOUBLE);
-               c.R=cl.u.RGBA[0];
-               c.G=cl.u.RGBA[1];
-               c.B=cl.u.RGBA[2];
-               c.A=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;
-}
 int SetGdkColor(GdkColor* c,char* color)
 {
        gvcolor_t cl;   
        if (color != '\0')
        {
                colorxlate(color, &cl, RGBA_DOUBLE);
-               c->red=cl.u.RGBA[0]*65535;
-               c->green=cl.u.RGBA[1]*65535;
-               c->blue=cl.u.RGBA[2]*65535;
+               c->red=(int)(cl.u.RGBA[0]*65535.0);
+               c->green=(int)(cl.u.RGBA[1]*65535.0);
+               c->blue=(int)(cl.u.RGBA[2]*65535.0);
                return 1;
        }
        else
                return 0;
 
 }
+
+void glexpose()
+{
+       expose_event (view->drawing_area,NULL,NULL);
+}
+
index eebff1b88b268a79f4111b38bbe5ccd12517b55e..84b3339644017b7b3c8e41377adcfa25d536e0f7 100755 (executable)
 #ifndef VIEWPORT_H
 #define VIEWPORT_H
 #define bool int
-#include <glTemplate.h>
+#include "smyrnadefs.h"
 #include <gtk/gtk.h>
-#include <gdk/gdkkeysyms.h>
-#include <gtk/gtkgl.h>
 #include "xdot.h"
-#include <stdlib.h>
-#include <string.h>
-#include <math.h>
-#include <pango/pangoft2.h>
 #include "cgraph.h"
-#include "selection.h"
-#include "draw.h"
-#define IS_TEST_MODE_ON                                0
-#define        DEFAULT_MAGNIFIER_WIDTH         300
-#define        DEFAULT_MAGNIFIER_HEIGHT        225
-#define DEFAULT_MAGNIFIER_KTS          10      //x10
-#define DEFAULT_FISHEYE_MAGNIFIER_RADIUS 250;
-//=======
-#define MAX_ZOOM       -1.000033
-#define MIN_ZOOM       -89.00000
-#define ZOOM_STEP      1;
-//>>>>>>> 1.8
-enum
-{
-  COL_NAME = 0,
-  COL_FILENAME,
-  NUM_COLS
-} ;
-//atributes
-typedef struct _mouse_attr
-{
-       int mouse_down;
-       int mouse_mode;
-       int mouse_X;
-       int mouse_Y;
-}mouse_attr;
 
 
-typedef struct _attribute
-{
-       char Type;
-       char* Name;
-       char* Default;
-       char ApplyTo[4];
-       char Engine[5];
-       char** ComboValues;
-       int ComboValuesCount;
-       GtkWidget* attrWidget;
 
-}attribute;
 
-//bind this to cgraph g
-typedef struct _custom_graph_data
-{
-       Agrec_t h;
-       char* GraphName;
-       char* GraphFileName;
-       int AlwaysShow; //active or not draw it 
-       int TopView;    //default 0, 1 for topview data, dots and lines
-       int Locked;
-       int Engine;     //enum GVEngine{DOT,NEATO,TWOPI,CIRCO,FDP};
-       //graph's location, change these to move the whole graph
-       int Modified;   //if graph has been modified after loading
-       GLfloat offsetx;
-       GLfloat offsety;
-       GLfloat offsetz;
-
-       Agraph_t** selectedGraphs;              //clusters , subgraphs indeed
-       Agnode_t** selectedNodes;
-       Agedge_t** selectedEdges;
-
-       int selectedGraphsCount;
-       int selectedNodesCount;
-       int selectedEdgesCount;
-} custom_graph_data;
-
-
-
-enum GEunit{GEpixels,GEinches,GEmm};
-
-typedef struct{
-       float R;
-       float G;
-       float B;
-       float A;        //Alpha
-} RGBColor;
-
-typedef struct _custom_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
-
-}custom_object_data;
-
-typedef struct _selection
-{
-       int Active;             //0 there is no selection need to be applied
-       char Type;              //0     single selection , 1 rectangle , 2 rectangleX 
-       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;
-
-}selection;
-typedef struct _magnifier
-{
-       GLfloat x,y;
-       GLfloat kts;    //zoom X
-       GLfloat GLwidth,GLheight;
-       int width,height;       //how big is the magnifier referenced from windows
-       int active;
-} magnifier;
-
-typedef struct _fisheye_magnifier
-{
-       GLfloat x,y;//center coords of active circle
-       GLfloat distortion_factor;      //distortion factor ,default 1
-       int R;  //radius of  the magnifier referenced from windows
-       int active;
-} fisheye_magnifier;
-
-typedef struct _ViewInfo
-{
-       GLfloat panx;
-       GLfloat pany;
-       GLfloat panz;
-       GLfloat prevpanx;
-       GLfloat prevpany;
-       GLfloat prevpanz;
-
-       GLfloat zoom;
-
-       RGBColor bgColor;
-       RGBColor penColor;
-       RGBColor fillColor;
-       RGBColor selectColor;
-
-
-       GLfloat LineWidth;
-       GLfloat grR,grG,grB,grA;        //grid color
-       bool gridVisible;       //if the grid sis visible
-       GLfloat gridSize;       //grid cell size
-
-       bool bdVisible; //if borders are visible (boundries of the drawing,
-       GLuint bdR,bdG,bdB,bdA; //border colors
-       GLfloat bdxLeft,bdyTop,bdzTop;  //border top coordinates
-       GLfloat bdxRight,bdyBottom,bdzBottom; //border bottom coordinates
-
-       //defaults
-       enum GEunit unit;       //default pixels :0  
-       //***mouse variables
-       GLfloat GLx,GLy,GLz;            //real GL coordinates of xwin mouse coords
-       GLfloat GLx2,GLy2,GLz2;         //real GL coordinates(second) of win mouse coords
-       float clipX1,clipX2,clipY1,clipY2,clipZ1,clipZ2;
-       Agraph_t** g;
-       int graphCount;         //number of graphs loaded
-       int activeGraph; //
-
-
-
-       int texture;            //boolean , to disable and enable texturing, if graph does not have an embedded image
-       TextTexture* font_textures;     //text textures
-       int font_texture_count; //count of text  textures uploaded to gl engine
-       float GLDepth;          //opengl depth value to convert mouse to GL coords
-
-       GtkWidget* pango_widget;
-       char* FontName;
-       float FontSize;
-       //selection
-//     int mousedown;  //0 down , 1 up , used for selection boxes
-       mouse_attr mouse;
-       selection Selection;
-       magnifier mg;
-       fisheye_magnifier fmg;
-       //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
-
-}ViewInfo;
-
-extern char* globalString;
-extern ViewInfo        view;
-extern Agraph_t* tempG;        //helper graph for default attr values,
-extern int SignalBlock;
-
-extern float TopViewPointsX [50000];
-extern float TopViewPointsY [50000];
-
-extern float TopViewEdgesHeadX[50000];
-extern float TopViewEdgesHeadY[50000];
-extern float TopViewEdgesTailX[50000];
-extern float TopViewEdgesTailY[50000];
-
-extern int     TopViewNodeCount;
-extern int     TopViewEdgeCount;
-extern GtkMessageDialog*  Dlg;
-extern int respond;
-
-//ss
 void init_viewport(ViewInfo* view);
+void clear_viewport(ViewInfo* view);
 int add_graph_to_viewport_from_file (char* fileName);  //returns 1 if successfull else 0 ++
 int add_new_graph_to_viewport();       //returns graph index , otherwise -1
 int create_xdot_for_graph(Agraph_t* graph,int keeppos);        //0 failed , 1 successfull ++
 void update_graph_params(Agraph_t* graph);     //adds gledit params  ++
-extern Agraph_t* loadGraph(char* filename); //dont use directly, use add_graph_to_viewport_from_file instead 
+Agraph_t* loadGraph(char* filename); //dont use directly, use add_graph_to_viewport_from_file instead 
 void load_graph_params(Agraph_t* graph);       //run once right after loading graph++
 void clear_graph(Agraph_t* graph);     //clears custom data binded,
 int save_graph();      //save without prompt
@@ -249,8 +44,7 @@ void refreshControls(ViewInfo* v);
 
 
 int attach_object_custom_data_to_graph(Agraph_t* graph);//run once or to reset all data !! prev data is removed
-// int init_object_custom_data(void* obj);//creates a custom_object_data and return its pointer.obj is used to clear prev data
-int clear_object_custom_data(void* obj);       //frees memory allocated for cutom object data
+int clear_object_custom_data(void* obj);       //frees memory allocated for custom object data
 int add_string_data_to_object_custom_data(void* obj,char* data);
 int add_numeric_data_to_object_custom_data(void* obj,float data);
 int clear_string_data_from_object_custom_data(void* obj);
@@ -262,12 +56,8 @@ int clear_graph_xdot(Agraph_t* graph);      //clears all xdot  attributes, used espec
 char* get_object_attribute(void* obj,char* attr);      //returns an attribute value no matter what,
 
 void move_node(void* n,float dx,float dy);
-
-
-
-
+void glexpose();
 void move_nodes(Agraph_t* g);  //move selected nodes 
 //helper functions
-RGBColor GetRGBColor(char* color);
 int SetGdkColor(GdkColor* c,char* color);
 #endif
index 6ec16c36061c41408570215941b08ac695ac265f..565f157d597f3c6c6267457f988b88f16f89ac9d 100644 (file)
@@ -4,20 +4,17 @@
 AM_CPPFLAGS = \
        -I$(top_srcdir) \
        -I$(top_srcdir)/lib/utilities \
-       -I$(top_srcdir)/lib/gui \
-       -I$(top_srcdir)/lib/topfish \
-       -I$(top_srcdir)/cmd/smyrna \
+       -I$(top_srcdir)/lib/GUI \
+       -I$(top_srcdir)/cmd/gtktopview \
        -I$(top_srcdir)/lib/xdot \
        -I$(top_srcdir)/lib/cgraph \
        -I$(top_srcdir)/lib/cdt \
        $(GTK_CFLAGS) $(GTKGL_CFLAGS) $(GTKGLEXT_CFLAGS) $(GLADE_CFLAGS) $(FREETYPE2_CFLAGS)
 
-if WITH_SMYRNA
 noinst_HEADERS = \
        btree.h filter.h 
 
 noinst_LTLIBRARIES = libfilter_C.la
-endif
 
 libfilter_C_la_SOURCES = \
        Filter.c btree.c
index f68e57e6b048034ff0f9ed04a07327b6b7dbdb94..221638670df80e79d7c24b997e556f1d2b829022 100644 (file)
@@ -16,7 +16,7 @@
 
 #include "btree.h"
 #include "regex.h"
-#include "topview.h"
+#include "viewport.h"
 btree_node* new_node(char* attribute,char* regex, float min, float max)
 {
        btree_node* n;
@@ -293,13 +293,13 @@ int evaluate_filter_atom(char* string,btree_node* Nodes[],char* op)
                c_cursor++;
        }
        
-       n=new_node(attrs[0],values[0],atof(values[1]),atof(values[2]));
+       n=new_node(attrs[0],values[0],(float)atof(values[1]),(float)atof(values[2]));
        n->node_type=2;
        Nodes[0]=n;
 
        if (attrs_count >5)
        {
-               n=new_node(attrs[3],values[3],atof(values[4]),atof(values[5]));
+               n=new_node(attrs[3],values[3],(float)atof(values[4]),(float)atof(values[5]));
                n->node_type=2;
                Nodes[1]=n;
        }
@@ -320,8 +320,6 @@ int  evaluate_expresions (tv_node* TV_Node,btree_node* n)
 {
        regex_t preg;
        char* data;
-       char buff1[1024];
-       char buff2[1024];
        int i=0;
        int ii=0;
        if (!n)
@@ -340,7 +338,7 @@ int  evaluate_expresions (tv_node* TV_Node,btree_node* n)
        }
        if (n->node_type==2)
        {
-               data=agget(Topview.Nodes[TV_Node->index].Node,n->attr_name);
+               data=agget(view->Topview->Nodes[TV_Node->index].Node,n->attr_name);
                if (data)
                {
                                regcomp(&preg,n->regex,REG_NOSUB);