From: erg Date: Wed, 19 Mar 2008 21:43:58 +0000 (+0000) Subject: Clean up smyrna files: X-Git-Tag: LAST_LIBGRAPH~32^2~4477 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=748fa5bdaab5817837125a0d29cfb71a24d1c6df;p=graphviz Clean up smyrna files: remove unnecessary globals modify libraries not to rely on code in cmd/smyrna remove static declarations from .h files remove unnecessary libraries mark unused code and clean up warnings --- diff --git a/cmd/smyrna/glexpose.c b/cmd/smyrna/glexpose.c index c6c1896b1..761f6f52b 100644 --- a/cmd/smyrna/glexpose.c +++ b/cmd/smyrna/glexpose.c @@ -1,3 +1,18 @@ +/* vim:set shiftwidth=4 ts=8: */ + +/********************************************************** +* This software is part of the graphviz package * +* http://www.graphviz.org/ * +* * +* Copyright (c) 1994-2004 AT&T Corp. * +* and is licensed under the * +* Common Public License, Version 1.0 * +* by AT&T Corp. * +* * +* Information and Software Systems Research * +* AT&T Research, Florham Park NJ * +**********************************************************/ + #include "glexpose.h" #include "draw.h" #include "topview.h" @@ -8,13 +23,16 @@ params:ViewInfo , global view variable defined in viewport.c return value:always 1 */ -int glupdatecamera(ViewInfo* view) +int glupdatecamera(ViewInfo * view) { - gluLookAt(view->panx,view->pany,view->zoom*-1,view->panx,view->pany,0.0,0.0,1.0,0.0); - GetOGLPosRef(1,view->h-5,&(view->clipX1),&(view->clipY1),&(view->clipZ1)); - GetOGLPosRef(view->w-1,1,&(view->clipX2),&(view->clipY2),&(view->clipZ2)); - return 1; + gluLookAt(view->panx, view->pany, view->zoom * -1, view->panx, + view->pany, 0.0, 0.0, 1.0, 0.0); + GetOGLPosRef(1, view->h - 5, &(view->clipX1), &(view->clipY1), + &(view->clipZ1)); + GetOGLPosRef(view->w - 1, 1, &(view->clipX2), &(view->clipY2), + &(view->clipZ2)); + return 1; } /* @@ -23,17 +41,17 @@ int glupdatecamera(ViewInfo* view) params:ViewInfo , global view variable defined in viewport.c return value:0 if something goes wrong with GL 1 , otherwise */ -int glexpose_main(ViewInfo* view) +int glexpose_main(ViewInfo * view) { - if(!glupdatecamera(view)) - return 0; - glexpose_grid(view); - draw_fisheye_magnifier(view); - draw_magnifier(view); - glexpose_drawgraph(view); - draw_selection_box(view); - drawBorders(view); - return 1; + if (!glupdatecamera(view)) + return 0; + glexpose_grid(view); + draw_fisheye_magnifier(view); + draw_magnifier(view); + glexpose_drawgraph(view); + draw_selection_box(view); + drawBorders(view); + return 1; } /* @@ -41,24 +59,24 @@ int glexpose_main(ViewInfo* view) params:ViewInfo , global view variable defined in viewport.c return value:none */ -void glexpose_grid(ViewInfo* view) +void glexpose_grid(ViewInfo * view) { - //drawing grids - float x,y; - if(view->gridVisible) - { - glPointSize (1); - glBegin(GL_POINTS); - glColor4f(view->gridColor.R,view->gridColor.G,view->gridColor.B,view->gridColor.A); - 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(); + //drawing grids + float x, y; + if (view->gridVisible) { + glPointSize(1); + glBegin(GL_POINTS); + glColor4f(view->gridColor.R, view->gridColor.G, view->gridColor.B, + view->gridColor.A); + 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(); + } } /* @@ -66,20 +84,17 @@ void glexpose_grid(ViewInfo* view) params:ViewInfo , global view variable defined in viewport.c return value:1 if there is a graph to draw else 0 */ -int glexpose_drawgraph(ViewInfo* view) +int glexpose_drawgraph(ViewInfo * view) { - if(view->activeGraph > -1) - { - if(((custom_graph_data*)AGDATA(view->g[view->activeGraph]))->TopView) - { - drawTopViewGraph(view->g[view->activeGraph]);//view->Topview style dots and straight lines - glCompSetDraw(view->Topview->topviewmenu); - } - else - drawGraph(view->g[view->activeGraph]);//xdot based drawing functions + if (view->activeGraph > -1) { + if (((custom_graph_data *) AGDATA(view->g[view->activeGraph]))-> + TopView) { + drawTopViewGraph(view->g[view->activeGraph]); //view->Topview style dots and straight lines + glCompSetDraw(view->Topview->topviewmenu); + } else + drawGraph(view->g[view->activeGraph]); //xdot based drawing functions - return 1; - } - return 0; + return 1; + } + return 0; } - diff --git a/cmd/smyrna/glexpose.h b/cmd/smyrna/glexpose.h index 765b4d08b..ca1deb950 100644 --- a/cmd/smyrna/glexpose.h +++ b/cmd/smyrna/glexpose.h @@ -1,10 +1,25 @@ +/* vim:set shiftwidth=4 ts=8: */ + +/********************************************************** +* This software is part of the graphviz package * +* http://www.graphviz.org/ * +* * +* Copyright (c) 1994-2004 AT&T Corp. * +* and is licensed under the * +* Common Public License, Version 1.0 * +* by AT&T Corp. * +* * +* Information and Software Systems Research * +* AT&T Research, Florham Park NJ * +**********************************************************/ + #ifndef GLEXPOSE_H #define GLEXPOSE_H #include "viewport.h" -int glupdatecamera(ViewInfo* v); -int glexpose_main(ViewInfo* v); -void glexpose_grid(ViewInfo* v); -int glexpose_drawgraph(ViewInfo* view); +int glupdatecamera(ViewInfo * v); +int glexpose_main(ViewInfo * v); +void glexpose_grid(ViewInfo * v); +int glexpose_drawgraph(ViewInfo * view); #endif diff --git a/cmd/smyrna/gltemplate.c b/cmd/smyrna/gltemplate.c index b0a33f8e3..268480467 100755 --- a/cmd/smyrna/gltemplate.c +++ b/cmd/smyrna/gltemplate.c @@ -35,42 +35,55 @@ static float dy = 0.0; params:gtk gl config class ,gtk takes care of all these tests return value:none */ -void examine_gl_config_attrib (GdkGLConfig *glconfig) +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", - gdk_gl_config_is_double_buffered (glconfig) ? "TRUE" : "FALSE"); - g_print ("gdk_gl_config_is_stereo (glconfig) = %s\n", - gdk_gl_config_is_stereo (glconfig) ? "TRUE" : "FALSE"); - g_print ("gdk_gl_config_has_alpha (glconfig) = %s\n", - gdk_gl_config_has_alpha (glconfig) ? "TRUE" : "FALSE"); - g_print ("gdk_gl_config_has_depth_buffer (glconfig) = %s\n", - gdk_gl_config_has_depth_buffer (glconfig) ? "TRUE" : "FALSE"); - g_print ("gdk_gl_config_has_stencil_buffer (glconfig) = %s\n", - 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); - print_gl_config_attrib (glconfig, "GDK_GL_RGBA", GDK_GL_RGBA, TRUE); - print_gl_config_attrib (glconfig, "GDK_GL_DOUBLEBUFFER", GDK_GL_DOUBLEBUFFER, TRUE); - print_gl_config_attrib (glconfig, "GDK_GL_STEREO", GDK_GL_STEREO, TRUE); - print_gl_config_attrib (glconfig, "GDK_GL_AUX_BUFFERS", GDK_GL_AUX_BUFFERS, FALSE); - print_gl_config_attrib (glconfig, "GDK_GL_RED_SIZE", GDK_GL_RED_SIZE, FALSE); - print_gl_config_attrib (glconfig, "GDK_GL_GREEN_SIZE", GDK_GL_GREEN_SIZE, FALSE); - print_gl_config_attrib (glconfig, "GDK_GL_BLUE_SIZE", GDK_GL_BLUE_SIZE, FALSE); - print_gl_config_attrib (glconfig, "GDK_GL_ALPHA_SIZE", GDK_GL_ALPHA_SIZE, FALSE); - print_gl_config_attrib (glconfig, "GDK_GL_DEPTH_SIZE", GDK_GL_DEPTH_SIZE, FALSE); - print_gl_config_attrib (glconfig, "GDK_GL_STENCIL_SIZE", GDK_GL_STENCIL_SIZE, FALSE); - print_gl_config_attrib (glconfig, "GDK_GL_ACCUM_RED_SIZE", GDK_GL_ACCUM_RED_SIZE, FALSE); - 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"); + 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", + gdk_gl_config_is_double_buffered(glconfig) ? "TRUE" : "FALSE"); + g_print("gdk_gl_config_is_stereo (glconfig) = %s\n", + gdk_gl_config_is_stereo(glconfig) ? "TRUE" : "FALSE"); + g_print("gdk_gl_config_has_alpha (glconfig) = %s\n", + gdk_gl_config_has_alpha(glconfig) ? "TRUE" : "FALSE"); + g_print("gdk_gl_config_has_depth_buffer (glconfig) = %s\n", + gdk_gl_config_has_depth_buffer(glconfig) ? "TRUE" : "FALSE"); + g_print("gdk_gl_config_has_stencil_buffer (glconfig) = %s\n", + 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); + print_gl_config_attrib(glconfig, "GDK_GL_RGBA", GDK_GL_RGBA, TRUE); + print_gl_config_attrib(glconfig, "GDK_GL_DOUBLEBUFFER", + GDK_GL_DOUBLEBUFFER, TRUE); + print_gl_config_attrib(glconfig, "GDK_GL_STEREO", GDK_GL_STEREO, TRUE); + print_gl_config_attrib(glconfig, "GDK_GL_AUX_BUFFERS", + GDK_GL_AUX_BUFFERS, FALSE); + print_gl_config_attrib(glconfig, "GDK_GL_RED_SIZE", GDK_GL_RED_SIZE, + FALSE); + print_gl_config_attrib(glconfig, "GDK_GL_GREEN_SIZE", + GDK_GL_GREEN_SIZE, FALSE); + print_gl_config_attrib(glconfig, "GDK_GL_BLUE_SIZE", GDK_GL_BLUE_SIZE, + FALSE); + print_gl_config_attrib(glconfig, "GDK_GL_ALPHA_SIZE", + GDK_GL_ALPHA_SIZE, FALSE); + print_gl_config_attrib(glconfig, "GDK_GL_DEPTH_SIZE", + GDK_GL_DEPTH_SIZE, FALSE); + print_gl_config_attrib(glconfig, "GDK_GL_STENCIL_SIZE", + GDK_GL_STENCIL_SIZE, FALSE); + print_gl_config_attrib(glconfig, "GDK_GL_ACCUM_RED_SIZE", + GDK_GL_ACCUM_RED_SIZE, FALSE); + 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"); } /* @@ -78,23 +91,20 @@ void examine_gl_config_attrib (GdkGLConfig *glconfig) 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) +void print_gl_config_attrib(GdkGLConfig * glconfig, + const gchar * attrib_str, + int attrib, gboolean is_boolean) { - int value; + int value; - g_print ("%s = ", attrib_str); - if (gdk_gl_config_get_attrib (glconfig, attrib, &value)) - { - if (is_boolean) - g_print ("%s\n", value == TRUE ? "TRUE" : "FALSE"); - else - g_print ("%d\n", value); - } - else - g_print ("*** Cannot get %s attribute value\n", attrib_str); + g_print("%s = ", attrib_str); + if (gdk_gl_config_get_attrib(glconfig, attrib, &value)) { + if (is_boolean) + g_print("%s\n", value == TRUE ? "TRUE" : "FALSE"); + else + g_print("%d\n", value); + } else + g_print("*** Cannot get %s attribute value\n", attrib_str); } /* @@ -102,19 +112,19 @@ void print_gl_config_attrib (GdkGLConfig *glconfig, params:gtk opgn gl canvas and optional data pointer return value:none */ -static void realize (GtkWidget *widget,gpointer data) +static void realize(GtkWidget * widget, gpointer data) { - GdkGLContext *glcontext = gtk_widget_get_gl_context (widget); - GdkGLDrawable *gldrawable = gtk_widget_get_gl_drawable (widget); + 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}; + /*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.2f, 0.2f, 0.2f, 1.0f}; - GLfloat local_view[] = {0.0}; + GLfloat lmodel_ambient[] = { 0.2f, 0.2f, 0.2f, 1.0f }; + GLfloat local_view[] = { 0.0 }; #ifdef WIN32 @@ -123,34 +133,35 @@ static void realize (GtkWidget *widget,gpointer data) // using -DSMYRNA_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_FONT)); /*** OpenGL BEGIN ***/ - if (!gdk_gl_drawable_gl_begin (gldrawable, glcontext)) - return; + if (!gdk_gl_drawable_gl_begin(gldrawable, glcontext)) + return; - glClearColor (view->bgColor.R,view->bgColor.G, view->bgColor.B,view->bgColor.A); //background color - glClearDepth (1.0); + glClearColor(view->bgColor.R, view->bgColor.G, view->bgColor.B, view->bgColor.A); //background color + glClearDepth(1.0); - glLightfv (GL_LIGHT0, GL_AMBIENT, ambient); - glLightfv (GL_LIGHT0, GL_DIFFUSE, diffuse); - glLightfv (GL_LIGHT0, GL_POSITION, position); - glLightModelfv (GL_LIGHT_MODEL_AMBIENT, lmodel_ambient); - glLightModelfv (GL_LIGHT_MODEL_LOCAL_VIEWER, local_view); + glLightfv(GL_LIGHT0, GL_AMBIENT, ambient); + glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse); + glLightfv(GL_LIGHT0, GL_POSITION, position); + glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient); + glLightModelfv(GL_LIGHT_MODEL_LOCAL_VIEWER, local_view); - glFrontFace (GL_CW); + glFrontFace(GL_CW); // glEnable (GL_LIGHTING); // glEnable (GL_LIGHT0); // glEnable (GL_AUTO_NORMAL); // glEnable (GL_NORMALIZE); - glEnable (GL_DEPTH_TEST); - glEnable (GL_BLEND); glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glDepthFunc (GL_LESS); + glEnable(GL_DEPTH_TEST); + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glDepthFunc(GL_LESS); // glEnable(GL_LINE_SMOOTH); - gdk_gl_drawable_gl_end (gldrawable); + gdk_gl_drawable_gl_end(gldrawable); /*** OpenGL END ***/ - return; + return; } /* @@ -158,38 +169,36 @@ static void realize (GtkWidget *widget,gpointer data) 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) +static gboolean configure_event(GtkWidget * widget, + GdkEventConfigure * event, gpointer data) { int vPort[4]; - float aspect; - GdkGLContext *glcontext = gtk_widget_get_gl_context (widget); - GdkGLDrawable *gldrawable = gtk_widget_get_gl_drawable (widget); - view->w=widget->allocation.width; - view->h=widget->allocation.height; + 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); + if (!gdk_gl_drawable_gl_begin(gldrawable, glcontext)) + return FALSE; + glViewport(0, 0, view->w, view->h); /* get current viewport */ - glGetIntegerv (GL_VIEWPORT, vPort); + glGetIntegerv(GL_VIEWPORT, vPort); /* setup various opengl things that we need */ - glMatrixMode (GL_PROJECTION); - glLoadIdentity (); - if (view->w > view->h) - { - aspect = (float)view->w / (float)view->h; - glFrustum (-aspect*100, aspect*100, -100.0, 100.0, 1 ,90); - } - else - { - aspect = (float)view->h / (float)view->w; - glFrustum (-100.0, 100.0, -aspect*100, aspect*100,1, 90); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + if (view->w > view->h) { + aspect = (float) view->w / (float) view->h; + glFrustum(-aspect * 100, aspect * 100, -100.0, 100.0, 1, 90); + } else { + 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); + glMatrixMode(GL_MODELVIEW); + gdk_gl_drawable_gl_end(gldrawable); /*** OpenGL END ***/ - return TRUE; + return TRUE; } /* @@ -197,24 +206,25 @@ static gboolean configure_event (GtkWidget* widget, GdkEventConfigure *event,gpo 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) +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); + GdkGLContext *glcontext = gtk_widget_get_gl_context(widget); + GdkGLDrawable *gldrawable = gtk_widget_get_gl_drawable(widget); /*** OpenGL BEGIN ***/ - if (!gdk_gl_drawable_gl_begin (gldrawable, glcontext)) - return FALSE; - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - glLoadIdentity (); - glexpose_main(view); //draw all stuff - /* 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_gl_begin(gldrawable, glcontext)) + return FALSE; + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + glLoadIdentity(); + glexpose_main(view); //draw all stuff + /* Swap buffers */ + if (gdk_gl_drawable_is_double_buffered(gldrawable)) + gdk_gl_drawable_swap_buffers(gldrawable); + else + glFlush(); + gdk_gl_drawable_gl_end(gldrawable); /*** OpenGL END ***/ - return TRUE; + return TRUE; } /* @@ -222,37 +232,39 @@ gboolean expose_event (GtkWidget* widget,GdkEventExpose* event,gpointer data) 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) +static gboolean button_press_event(GtkWidget * widget, + GdkEventButton * event, gpointer data) { - if(view->graphCount) - { - if(glCompSetClick(view->Topview->topviewmenu,(int)event->x,(int)event->y)) - expose_event (view->drawing_area,NULL,NULL); - } - - begin_x = (float)event->x; - begin_y = (float)event->y; - - - if(event->button==1) //left click - { - view->mouse.mouse_down=1; - if(GetOGLPosRef((int)begin_x,(int)begin_y,&(view->GLx),&(view->GLy),&(view->GLz))) - { - 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); - } - } - } - return FALSE; + if (view->graphCount) { + if (glCompSetClick + (view->Topview->topviewmenu, (int) event->x, (int) event->y)) + expose_event(view->drawing_area, NULL, NULL); + } + + begin_x = (float) event->x; + begin_y = (float) event->y; + + + if (event->button == 1) //left click + { + view->mouse.mouse_down = 1; + if (GetOGLPosRef + ((int) begin_x, (int) begin_y, &(view->GLx), &(view->GLy), + &(view->GLz))) { + 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); + } + } + } + return FALSE; } /* @@ -260,55 +272,58 @@ static gboolean button_press_event (GtkWidget* widget,GdkEventButton *event,gpoi 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) +static gboolean button_release_event(GtkWidget * widget, + GdkEventButton * event, gpointer data) { - if(event->button==1) //left click release + if (event->button == 1) //left click release + { + if (glCompSetRelease + (view->Topview->topviewmenu, (int) event->x_root, + (int) event->y_root)) + expose_event(view->drawing_area, NULL, NULL); + + view->mouse.mouse_down = 0; + if ((view->mouse.mouse_mode == MM_RECTANGULAR_SELECT) + || (view->mouse.mouse_mode == MM_RECTANGULAR_X_SELECT)) { + if (view->GLx <= view->GLx2) + view->Selection.X = view->GLx; + else + view->Selection.X = view->GLx2; + if (view->GLy <= view->GLy2) + view->Selection.Y = view->GLy; + else + view->Selection.Y = view->GLy2; + + view->Selection.W = view->GLx2 - view->GLx; + if (view->Selection.W < 0) + view->Selection.W = view->Selection.W * -1; + view->Selection.H = view->GLy2 - view->GLy; + if (view->Selection.H < 0) + view->Selection.H = view->Selection.H * -1; + if (view->mouse.mouse_mode == 4) + view->Selection.Type = 1; + else + view->Selection.Type = 2; + view->Selection.Active = 1; + expose_event(view->drawing_area, NULL, NULL); + } + if (view->mouse.mouse_mode == MM_MOVE) { + 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(glCompSetRelease(view->Topview->topviewmenu,(int)event->x_root,(int)event->y_root)) - expose_event (view->drawing_area,NULL,NULL); - - view->mouse.mouse_down=0; - if ((view->mouse.mouse_mode==MM_RECTANGULAR_SELECT)||(view->mouse.mouse_mode==MM_RECTANGULAR_X_SELECT)) - { - if (view->GLx <= view->GLx2) - view->Selection.X=view->GLx; - else - view->Selection.X=view->GLx2; - if(view->GLy <= view->GLy2) - view->Selection.Y=view->GLy; - else - view->Selection.Y=view->GLy2; - - view->Selection.W=view->GLx2-view->GLx; - if(view->Selection.W < 0) - view->Selection.W=view->Selection.W*-1; - view->Selection.H=view->GLy2-view->GLy; - if(view->Selection.H < 0) - view->Selection.H=view->Selection.H*-1; - if(view->mouse.mouse_mode==4) - view->Selection.Type=1; - else - view->Selection.Type=2; - view->Selection.Active=1; - expose_event (view->drawing_area,NULL,NULL); - } - if (view->mouse.mouse_mode==MM_MOVE) - { - 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 - { - originate_distorded_coordinates(view->Topview); - expose_event (view->drawing_area,NULL,NULL); - } + originate_distorded_coordinates(view->Topview); + expose_event(view->drawing_area, NULL, NULL); } - dx = 0.0; - dy = 0.0; - return FALSE; + } + dx = 0.0; + dy = 0.0; + return FALSE; } /* @@ -316,79 +331,88 @@ static gboolean button_release_event (GtkWidget* widget,GdkEventButton *event,gp 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) +static gboolean motion_notify_event(GtkWidget * widget, + GdkEventMotion * event, gpointer data) { - float w = (float)widget->allocation.width; - float h = (float)widget->allocation.height; - float x = (float)event->x; - float y = (float)event->y; - char buf[50]; - - - gboolean redraw = FALSE; - dx = x - begin_x; - dy = y - begin_y; - /*panning*/ - if ((event->state & GDK_BUTTON1_MASK) && (view->mouse.mouse_mode==MM_PAN)) - { - float a,b; - a=view->panx-dx*(float)pow(view->zoom*-1,(1/1)); - b=(view->bdxRight-view->bdxLeft)/(float)2.0; - if (ABS(a) < ABS(b)) - view->panx=a; - else - view->panx=(view->bdxRight-view->bdxLeft)/(float)2.0*ABS(a)/a; - a=view->pany+dy*(float)(pow(view->zoom*-1,(1/1))); - b=(view->bdyTop-view->bdyBottom)/(float)2.0; - if (ABS(a) < ABS(b)) - view->pany=a; - else - view->pany=(view->bdyTop-view->bdyBottom)/(float)2.0*ABS(a)/a; - redraw = TRUE; - } - /*zooming*/ - if ((event->state & GDK_BUTTON1_MASK) && (view->mouse.mouse_mode==MM_ZOOM)) - { - float x; - view->zoom=view->zoom+dx/10*(view->zoom*-1/20); - if(view->zoom > MAX_ZOOM) - view->zoom=(float)MAX_ZOOM; - if(view->zoom < MIN_ZOOM) - view->zoom=(float)MIN_ZOOM; - /*set label to new zoom value*/ - x=((float)100.0-(float)1.0)*(view->zoom-(float)MIN_ZOOM)/((float)MAX_ZOOM-(float)MIN_ZOOM)+(float)1.0; - sprintf(buf,"%i",(int)x); - glCompLabelSetText((glCompLabel*)view->Topview->customptr,buf); - redraw = TRUE; - } + /* float w = (float)widget->allocation.width; */ + /* float h = (float)widget->allocation.height; */ + float x = (float) event->x; + float y = (float) event->y; + char buf[50]; + + + gboolean redraw = FALSE; + dx = x - begin_x; + dy = y - begin_y; + /*panning */ + if ((event->state & GDK_BUTTON1_MASK) + && (view->mouse.mouse_mode == MM_PAN)) { + float a, b; + a = view->panx - dx * (float) pow(view->zoom * -1, (1 / 1)); + b = (view->bdxRight - view->bdxLeft) / (float) 2.0; + if (ABS(a) < ABS(b)) + view->panx = a; + else + view->panx = + (view->bdxRight - view->bdxLeft) / (float) 2.0 *ABS(a) / a; + a = view->pany + dy * (float) (pow(view->zoom * -1, (1 / 1))); + b = (view->bdyTop - view->bdyBottom) / (float) 2.0; + if (ABS(a) < ABS(b)) + view->pany = a; + else + view->pany = + (view->bdyTop - view->bdyBottom) / (float) 2.0 *ABS(a) / a; + redraw = TRUE; + } + /*zooming */ + if ((event->state & GDK_BUTTON1_MASK) + && (view->mouse.mouse_mode == MM_ZOOM)) { + float x; + view->zoom = view->zoom + dx / 10 * (view->zoom * -1 / 20); + if (view->zoom > MAX_ZOOM) + view->zoom = (float) MAX_ZOOM; + if (view->zoom < MIN_ZOOM) + view->zoom = (float) MIN_ZOOM; + /*set label to new zoom value */ + x = ((float) 100.0 - (float) 1.0) * (view->zoom - + (float) MIN_ZOOM) / + ((float) MAX_ZOOM - (float) MIN_ZOOM) + (float) 1.0; + sprintf(buf, "%i", (int) x); + glCompLabelSetText((glCompLabel *) view->Topview->customptr, buf); + redraw = TRUE; + } - /*selection rect*/ - if ((event->state & GDK_BUTTON1_MASK) && ((view->mouse.mouse_mode==MM_RECTANGULAR_SELECT)||(view->mouse.mouse_mode==5))) - { - 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)) - { - 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_MAGNIFIER) - ||(view->mouse.mouse_mode==MM_FISHEYE_MAGNIFIER) )) - { - view->mouse.mouse_X=(int)x; - view->mouse.mouse_Y=(int)y; - redraw = TRUE; - } + /*selection rect */ + if ((event->state & GDK_BUTTON1_MASK) + && ((view->mouse.mouse_mode == MM_RECTANGULAR_SELECT) + || (view->mouse.mouse_mode == 5))) { + 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)) { + 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_MAGNIFIER) + || (view->mouse.mouse_mode == MM_FISHEYE_MAGNIFIER))) { + view->mouse.mouse_X = (int) x; + view->mouse.mouse_Y = (int) y; + redraw = TRUE; + } - - begin_x = x; - begin_y = y; + begin_x = x; + begin_y = y; - if (redraw) - gdk_window_invalidate_rect (widget->window, &widget->allocation, FALSE); - return TRUE; + + if (redraw) + gdk_window_invalidate_rect(widget->window, &widget->allocation, + FALSE); + return TRUE; } /* @@ -396,27 +420,29 @@ static gboolean motion_notify_event (GtkWidget* widget,GdkEventMotion *event,gpo 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) +#ifdef UNUSED +static gboolean key_press_event(GtkWidget * widget, GdkEventKey * event, + gpointer data) { - switch (event->keyval) - { + switch (event->keyval) { case GDK_Escape: - gtk_main_quit (); - break; + gtk_main_quit(); + break; default: - return FALSE; + return FALSE; } - return TRUE; + return TRUE; } +#endif /* 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) +void switch_Mouse(GtkMenuItem * menuitem, int mouse_mode) { - view->mouse.mouse_mode=mouse_mode; + view->mouse.mouse_mode = mouse_mode; } @@ -425,16 +451,17 @@ void switch_Mouse (GtkMenuItem *menuitem,int mouse_mode) 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) +static gboolean button_press_event_popup_menu(GtkWidget * widget, + GdkEventButton * event, + gpointer data) { - if (event->button == 3) - { - /* Popup menu. */ - gtk_menu_popup (GTK_MENU (widget), NULL, NULL, NULL, NULL, - event->button, event->time); - return TRUE; + if (event->button == 3) { + /* Popup menu. */ + gtk_menu_popup(GTK_MENU(widget), NULL, NULL, NULL, NULL, + event->button, event->time); + return TRUE; } - return FALSE; + return FALSE; } @@ -443,29 +470,27 @@ static gboolean button_press_event_popup_menu (GtkWidget *widget,GdkEventButton params:none return value:GdkGLConfig object */ -GdkGLConfig* configure_gl (void) +GdkGLConfig *configure_gl(void) { - 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) - { - 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 | - GDK_GL_MODE_DEPTH); - if (glconfig == NULL) - { - g_print ("*** No appropriate OpenGL-capable visual found.\n"); - exit (1); - } + 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) { + 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 | + GDK_GL_MODE_DEPTH); + if (glconfig == NULL) { + g_print("*** No appropriate OpenGL-capable visual found.\n"); + exit(1); + } } - return glconfig; + return glconfig; } /* @@ -474,70 +499,63 @@ GdkGLConfig* configure_gl (void) params:gl config object, gtk container widget for opengl canvas return value:none */ -void create_window (GdkGLConfig *glconfig,GtkWidget* vbox) +void create_window(GdkGLConfig * glconfig, GtkWidget * vbox) { - gint major, minor; + gint major, minor; - GtkWidget *menu; - /* - * Query OpenGL extension version. - */ + GtkWidget *menu; + /* + * Query OpenGL extension version. + */ - gdk_gl_query_version (&major, &minor); - g_print ("\nOpenGL extension version - %d.%d\n", - major, minor); + gdk_gl_query_version(&major, &minor); + g_print("\nOpenGL extension version - %d.%d\n", major, minor); - /* Try double-buffered 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.*/ - 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 (view->drawing_area, - glconfig, - NULL, - TRUE, - GDK_GL_RGBA_TYPE); + 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. */ + 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(view->drawing_area, + glconfig, NULL, TRUE, GDK_GL_RGBA_TYPE); - 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); + 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 (view->drawing_area), "realize", - G_CALLBACK (realize), NULL); - g_signal_connect (G_OBJECT (view->drawing_area), "configure_event", - G_CALLBACK (configure_event), NULL); - g_signal_connect (G_OBJECT (view->drawing_area), "expose_event", - G_CALLBACK (expose_event), NULL); + g_signal_connect_after(G_OBJECT(view->drawing_area), "realize", + G_CALLBACK(realize), NULL); + g_signal_connect(G_OBJECT(view->drawing_area), "configure_event", + G_CALLBACK(configure_event), NULL); + g_signal_connect(G_OBJECT(view->drawing_area), "expose_event", + G_CALLBACK(expose_event), NULL); - g_signal_connect (G_OBJECT (view->drawing_area), "button_press_event", - G_CALLBACK (button_press_event), NULL); - g_signal_connect (G_OBJECT (view->drawing_area), "button_release_event", - G_CALLBACK (button_release_event), NULL); - g_signal_connect (G_OBJECT (view->drawing_area), "motion_notify_event", - G_CALLBACK (motion_notify_event), NULL); + g_signal_connect(G_OBJECT(view->drawing_area), "button_press_event", + G_CALLBACK(button_press_event), NULL); + g_signal_connect(G_OBJECT(view->drawing_area), "button_release_event", + G_CALLBACK(button_release_event), NULL); + g_signal_connect(G_OBJECT(view->drawing_area), "motion_notify_event", + G_CALLBACK(motion_notify_event), NULL); - gtk_box_pack_start (GTK_BOX (vbox), view->drawing_area, TRUE, TRUE, 0); + gtk_box_pack_start(GTK_BOX(vbox), view->drawing_area, TRUE, TRUE, 0); - gtk_widget_show (view->drawing_area); + gtk_widget_show(view->drawing_area); - /* Popup menu. */ + /* Popup menu. */ - menu = create_popup_menu (view->drawing_area); + menu = create_popup_menu(view->drawing_area); - /* Signal handler */ - g_signal_connect_swapped (G_OBJECT (view->drawing_area), "button_press_event", - G_CALLBACK (button_press_event_popup_menu), menu); + /* Signal handler */ + g_signal_connect_swapped(G_OBJECT(view->drawing_area), + "button_press_event", + G_CALLBACK(button_press_event_popup_menu), + menu); } - - - - -