From b30b4c7f7ce48b0fb575f3710dbcc459a89c9ab9 Mon Sep 17 00:00:00 2001 From: arif Date: Wed, 11 Aug 2010 21:44:17 +0000 Subject: [PATCH] Smyrna:Alpha and picking works together. Full screen tune up --- cmd/smyrna/draw.c | 4 - cmd/smyrna/glexpose.c | 115 ++++++++++- cmd/smyrna/gltemplate.c | 4 +- cmd/smyrna/glutrender.c | 213 +++++++++++++++----- cmd/smyrna/glutrender.h | 2 +- cmd/smyrna/gui/appmouse.c | 6 +- cmd/smyrna/gui/glcompui.c | 10 +- cmd/smyrna/gui/topviewsettings.c | 30 ++- cmd/smyrna/hotkeymap.c | 40 +++- cmd/smyrna/main.c | 17 +- cmd/smyrna/smyrna.vcproj.RESEARCH.arif.user | 2 +- cmd/smyrna/smyrnadefs.h | 1 + cmd/smyrna/topviewfuncs.c | 44 ++-- cmd/smyrna/viewport.c | 10 +- 14 files changed, 379 insertions(+), 119 deletions(-) diff --git a/cmd/smyrna/draw.c b/cmd/smyrna/draw.c index bb546e2aa..4b273cd59 100755 --- a/cmd/smyrna/draw.c +++ b/cmd/smyrna/draw.c @@ -966,7 +966,6 @@ void draw_selpoly(glCompPoly* selPoly) int i; /* glColor4f(view->gridColor.R, view->gridColor.G, view->gridColor.B, view->gridColor.A);*/ - glDisable(GL_DEPTH_TEST); glColor4f(1,0,0,1); glBegin(GL_LINE_STRIP); for (i = 0;i < selPoly->cnt ; i++) @@ -981,9 +980,6 @@ void draw_selpoly(glCompPoly* selPoly) glVertex3f(view->mouse.GLpos.x,view->mouse.GLpos.y,0); glEnd(); } - glEnable(GL_DEPTH_TEST); - - } #ifdef UNUSED diff --git a/cmd/smyrna/glexpose.c b/cmd/smyrna/glexpose.c index 77ec5ab2f..8f1f1c0b5 100644 --- a/cmd/smyrna/glexpose.c +++ b/cmd/smyrna/glexpose.c @@ -13,7 +13,6 @@ * Information and Software Systems Research * * AT&T Research, Florham Park NJ * **********************************************************/ - #include "glexpose.h" #include "draw.h" #include "topviewfuncs.h" @@ -24,21 +23,117 @@ #include "hotkeymap.h" #include "polytess.h" -static void draw_cube() +int texture[3]; +static int Status=0; // Status Indicator + +void LoadGLTextures() // Load Bitmaps And Convert To Textures +{ + int imageWidth,imageHeight; + + unsigned char *data = glCompLoadPng ("c:/graphviz-ms/bin/Data/Crate.png", &imageWidth, &imageHeight); + + if (!data) + { + printf ("Data/Crate.bmp could not be located\n"); + exit(-1); + } + // Load The Bitmap, Check For Errors, If Bitmap's Not Found Quit + glGenTextures(3, &texture[0]); // Create Three Textures + + // Create Nearest Filtered Texture + glBindTexture(GL_TEXTURE_2D, texture[0]); + glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST); + glTexImage2D(GL_TEXTURE_2D, 0, 3, imageWidth,imageHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, data); + + // Create Linear Filtered Texture + glBindTexture(GL_TEXTURE_2D, texture[1]); + glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); + glTexImage2D(GL_TEXTURE_2D, 0, 3, imageWidth,imageHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, data); + + // Create MipMapped Texture + glBindTexture(GL_TEXTURE_2D, texture[2]); + glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST); + gluBuild2DMipmaps(GL_TEXTURE_2D, 3, imageWidth,imageHeight, GL_RGBA, GL_UNSIGNED_BYTE,data); + Status=1; // Set The Status To TRUE +} + + + +void draw_cube_tex() { + + glRotatef(45,1,1,1); + glEnable(GL_TEXTURE_2D); // Enable Texture Mapping + glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); // Really Nice Perspective Calculations + if(!Status) + LoadGLTextures(); + if(!Status) + return; + glBindTexture(GL_TEXTURE_2D,texture[1]); + glBegin(GL_QUADS); + // Front Face + glColor4f(1, 1, 1,1); // Color Blue + + glNormal3f( 0.0f, 0.0f, 1.0f); + glTexCoord2f(0.0f, 0.0f); glVertex3f(-100.0f, -100.0f, 100.0f); + glTexCoord2f(1.0f, 0.0f); glVertex3f( 100.0f, -100.0f, 100.0f); + glTexCoord2f(1.0f, 1.0f); glVertex3f( 100.0f, 100.0f, 100.0f); + glTexCoord2f(0.0f, 1.0f); glVertex3f(-100.0f, 100.0f, 100.0f); + // Back Face + glNormal3f( 0.0f, 0.0f,-1.0f); + glTexCoord2f(1.0f, 0.0f); glVertex3f(-100.0f, -100.0f, -100.0f); + glTexCoord2f(1.0f, 1.0f); glVertex3f(-100.0f, 100.0f, -100.0f); + glTexCoord2f(0.0f, 1.0f); glVertex3f( 100.0f, 100.0f, -100.0f); + glTexCoord2f(0.0f, 0.0f); glVertex3f( 100.0f, -100.0f, -100.0f); + // Top Face + glNormal3f( 0.0f, 1.0f, 0.0f); + glTexCoord2f(0.0f, 1.0f); glVertex3f(-100.0f, 100.0f, -100.0f); + glTexCoord2f(0.0f, 0.0f); glVertex3f(-100.0f, 100.0f, 100.0f); + glTexCoord2f(1.0f, 0.0f); glVertex3f( 100.0f, 100.0f, 100.0f); + glTexCoord2f(1.0f, 1.0f); glVertex3f( 100.0f, 100.0f, -100.0f); + // Bottom Face + glNormal3f( 0.0f,-1.0f, 0.0f); + glTexCoord2f(1.0f, 1.0f); glVertex3f(-100.0f, -100.0f, -100.0f); + glTexCoord2f(0.0f, 1.0f); glVertex3f( 100.0f, -100.0f, -100.0f); + glTexCoord2f(0.0f, 0.0f); glVertex3f( 100.0f, -100.0f, 100.0f); + glTexCoord2f(1.0f, 0.0f); glVertex3f(-100.0f, -100.0f, 100.0f); + // Right face + glNormal3f( 1.0f, 0.0f, 0.0f); + glTexCoord2f(1.0f, 0.0f); glVertex3f( 100.0f, -100.0f, -100.0f); + glTexCoord2f(1.0f, 1.0f); glVertex3f( 100.0f, 100.0f, -100.0f); + glTexCoord2f(0.0f, 1.0f); glVertex3f( 100.0f, 100.0f, 100.0f); + glTexCoord2f(0.0f, 0.0f); glVertex3f( 100.0f, -100.0f, 100.0f); + // Left Face + glNormal3f(-1.0f, 0.0f, 0.0f); + glTexCoord2f(0.0f, 0.0f); glVertex3f(-100.0f, -100.0f, -100.0f); + glTexCoord2f(1.0f, 0.0f); glVertex3f(-100.0f, -100.0f, 100.0f); + glTexCoord2f(1.0f, 1.0f); glVertex3f(-100.0f, 100.0f, 100.0f); + glTexCoord2f(0.0f, 1.0f); glVertex3f(-100.0f, 100.0f, -100.0f); + glEnd(); + glDisable(GL_TEXTURE_2D); // Enable Texture Mapping + + + +} +static void draw_cube() +{ + glRotatef(30,1,1,1); glBegin(GL_QUADS); // Draw The Cube Using quads - glColor3f(0.0f, 100.0f, 0.0f); // Color Blue + glColor4f(0.0f, 100.0f, 0.0f,0.5); // Color Blue glVertex3f(100.0f, 100.0f, -100.0f); // Top Right Of The Quad (Top) glVertex3f(-100.0f, 100.0f, -100.0f); // Top Left Of The Quad (Top) glVertex3f(-100.0f, 100.0f, 100.0f); // Bottom Left Of The Quad (Top) glVertex3f(100.0f, 100.0f, 100.0f); // Bottom Right Of The Quad (Top) - glColor3f(100.0f, 0.5f, 0.0f); // Color Orange + glColor4f(100.0f, 0.5f, 0.0f,0.5); // Color Orange glVertex3f(100.0f, -100.0f, 100.0f); // Top Right Of The Quad (Bottom) glVertex3f(-100.0f, -100.0f, 100.0f); // Top Left Of The Quad (Bottom) glVertex3f(-100.0f, -100.0f, -100.0f); // Bottom Left Of The Quad (Bottom) glVertex3f(100.0f, -100.0f, -100.0f); // Bottom Right Of The Quad (Bottom) - glColor3f(100.0f, 0.0f, 0.0f); // Color Red + glColor4f(100.0f, 0.0f, 0.0f,0.5); // Color Red glVertex3f(100.0f, 100.0f, 100.0f); // Top Right Of The Quad (Front) glVertex3f(-100.0f, 100.0f, 100.0f); // Top Left Of The Quad (Front) glVertex3f(-100.0f, -100.0f, 100.0f); // Bottom Left Of The Quad (Front) @@ -219,7 +314,6 @@ static int glexpose_drawgraph(ViewInfo * view) // } // else // drawGraph(view->g[view->activeGraph]); //xdot based drawing functions - glCompSetDraw(view->widgets); return 1; } return 0; @@ -259,7 +353,9 @@ int glexpose_main(ViewInfo * view) if (!glupdatecamera(view)) return 0; -// draw_cube(); +// glEnable(GL_DEPTH_TEST); +// draw_cube(); +// draw_cube_tex(); if (view->activeGraph >= 0) { @@ -272,14 +368,17 @@ int glexpose_main(ViewInfo * view) else return 0; + + glexpose_grid(view); draw_fisheye_magnifier(view); draw_magnifier(view); drawBorders(view); glexpose_drawgraph(view); -// drawRotatingTools(); drawRotatingAxis(); draw_selpoly(&view->Topview->sel.selPoly); + glCompSetDraw(view->widgets); + // draw_stuff(); // test_color_pallete(); // drawtestpoly(); diff --git a/cmd/smyrna/gltemplate.c b/cmd/smyrna/gltemplate.c index df2818d51..75d3fa1d7 100755 --- a/cmd/smyrna/gltemplate.c +++ b/cmd/smyrna/gltemplate.c @@ -174,10 +174,8 @@ static void realize(GtkWidget * widget, gpointer data) // glEnable (GL_NORMALIZE); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glDepthFunc(GL_LESS); - glDisable(GL_DEPTH); +// glDepthFunc(GL_LESS); // glEnable(GL_LINE_SMOOTH); - gdk_gl_drawable_gl_end(gldrawable); diff --git a/cmd/smyrna/glutrender.c b/cmd/smyrna/glutrender.c index 9b41bc042..f51cca747 100644 --- a/cmd/smyrna/glutrender.c +++ b/cmd/smyrna/glutrender.c @@ -21,6 +21,7 @@ #include "glexpose.h" + /*call backs */ static float begin_x = 0.0; @@ -45,7 +46,7 @@ static glMouseButtonType getGlCompMouseType(int n) } -void cb_glutreshape(int width, int height) +void cb_reshape(int width, int height) { /* static int doonce=0; */ int vPort[4]; @@ -73,15 +74,17 @@ void cb_glutreshape(int width, int height) } glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); /*** OpenGL END ***/ } -void cb_glutdisplay() +void cb_display(void ) { +// glClearColor(view->bgColor.R, view->bgColor.G, view->bgColor.B, view->bgColor.A); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - glClearColor(view->bgColor.R, view->bgColor.G, view->bgColor.B, view->bgColor.A); glLoadIdentity(); glexpose_main(view); //draw all stuff +// draw_cube_tex(); glutSwapBuffers(); if (view->initFile) { view->initFile = 0; @@ -124,7 +127,7 @@ void cb_mouseclick(int button, int state,int x, int y) dx = 0.0; dy = 0.0; } - cb_glutdisplay(); + cb_display(); } void cb_mouseover(int x,int y)/*no mouse click only mouse pointer moving on context*/ @@ -138,7 +141,7 @@ void cb_mouseover(int x,int y)/*no mouse click only mouse pointer moving on cont } -void cb_mouseover2(int X,int Y)/*mouse moving witha button clicked (dragging)*/ +void cb_drag(int X,int Y)/*mouse moving witha button clicked (dragging)*/ { float x = (float) X; @@ -161,63 +164,163 @@ void cb_mouseover2(int X,int Y)/*mouse moving witha button clicked (dragging)*/ appmouse_middle_drag(view,x,y); begin_x = x; begin_y = y; - cb_glutdisplay(); + cb_display(); + +} +void cb_mouseentry(int state) +{ + if(state==GLUT_LEFT) + { + //TODO when mouse leaves the scene (which might be impossible in full screen modes with one monitor + } + else // GLUT_ENTERED + { + //TODO mouse is back in scene + } } +void cb_keyboard(unsigned char key,int x, int y) +{ + if (key==27) /*ESC*/ + exit (1); + if(key=='3') + switch2D3D(NULL, 0, 0,glMouseLeftButton); + if(key=='c') + menu_click_center(NULL, 0, 0,glMouseLeftButton); + + if(key=='+') + menu_click_zoom_plus(NULL, 0, 0,glMouseLeftButton); + if(key=='-') + menu_click_zoom_minus(NULL, 0, 0,glMouseLeftButton); + if(key=='p') + menu_click_pan(NULL, 0, 0,glMouseLeftButton); + + + appmouse_key_press(view,key); +} +void cb_keyboard_up(unsigned char key,int x, int y) +{ + appmouse_key_release(view,key);; +} -void sm_glutinit(int w,int h,int full) +void cb_special_key(int key, int x, int y) { - glutInitWindowSize(512,512); - glutInitDisplayMode(GLUT_DOUBLE|GLUT_DEPTH|GLUT_RGBA|GLUT_ALPHA|GLUT_STENCIL); + if(key==GLUT_KEY_F1) + { + printf("Currently help is not available\n"); + } + appmouse_key_press(view,key); +} +void cb_special_key_up(int key, int x, int y) +{ + if(key==GLUT_KEY_F1) + { + printf("Currently help is not available\n"); + } + appmouse_key_release(view,key); -// glutInitDisplayMode ( GLUT_RGBA | GLUT_DOUBLE); - glutCreateWindow("The glut hello world program"); - glutDisplayFunc(cb_glutdisplay); - glutReshapeFunc(cb_glutreshape); +} + +static int cb_game_mode(char* optArg) +{ + + glutGameModeString(optArg); + if (glutGameModeGet(GLUT_GAME_MODE_POSSIBLE)) + { + glutEnterGameMode(); + return 1; + + } + else + { + printf("smyrna cannot initialize requested screen resolution and rate!\n"); + exit(-1); + + } + +} +static int cb_windowed_mode(int w,int h) +{ + glutInitWindowSize(w, h); + glutInitDisplayMode(GLUT_RGBA | GLUT_DEPTH | GLUT_ACCUM | GLUT_DOUBLE); + glutCreateWindow("smyrna"); + return 1; + +} + +int cb_glutinit(int x,int y,int w,int h, int bits,int s_rate,int fullscreen,int* argcp, char *argv[],char* optArg) +{ + /* + x,y:window position , unless in full screen mode + w,h: width and height of the window in pixels + bits: display color bit count + s_rate: for full screen mode this value represents refresh rate in hertz + fullscreen: if it will be a fullscreen window, + argcp argv: main function's parameters, required for glutinit + */ + + + + glutInit(argcp,argv); //this is required by some OS. + +// glutInitDisplayMode( GLUT_ALPHA | GLUT_DOUBLE | GLUT_RGBA); + glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH); + // The Type Of Depth Testing To Do +/* glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glShadeModel(GL_SMOOTH);*/ + glDisable(GL_DEPTH); + glClearDepth(1.0f); // Depth Buffer Setup + glEnable(GL_DEPTH_TEST); // Enables Depth Testing + glDepthFunc(GL_LEQUAL); // The Type Of Depth Testing To + glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); // Really Nice Perspective Calculations + + + if (fullscreen) + cb_game_mode(optArg); + else //well, use gtk then + { + cb_windowed_mode(w,h); + + } + + /*register callbacks here*/ + glutDisplayFunc(cb_display); + glutReshapeFunc(cb_reshape); + glutKeyboardFunc(cb_keyboard); + glutKeyboardUpFunc( cb_keyboard_up); glutMouseFunc(cb_mouseclick); - glutMotionFunc(cb_mouseover2); - glutFullScreen(); - - glClearColor(view->bgColor.R, view->bgColor.G, view->bgColor.B, view->bgColor.A); //background color - glClearDepth(1.0); - glClear(GL_COLOR_BUFFER_BIT); - - - glFrontFace(GL_CW); -// glEnable (GL_LIGHTING); -// glEnable (GL_LIGHT0); -// glEnable (GL_AUTO_NORMAL); -// glEnable (GL_NORMALIZE); - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glDepthFunc(GL_LESS); - glDisable(GL_DEPTH); -// glEnable(GL_LINE_SMOOTH); - - - -/* * 7.1 glutDisplayFunc - * 7.2 glutOverlayDisplayFunc - * 7.3 glutReshapeFunc - * 7.4 glutKeyboardFunc - * 7.5 glutMouseFunc - * 7.6 glutMotionFunc, glutPassiveMotionFunc - * 7.7 glutVisibilityFunc - * 7.8 glutEntryFunc - * 7.9 glutSpecialFunc - * 7.10 glutSpaceballMotionFunc - * 7.11 glutSpaceballRotateFunc - * 7.12 glutSpaceballButtonFunc - * 7.13 glutButtonBoxFunc - * 7.14 glutDialsFunc - * 7.15 glutTabletMotionFunc - * 7.16 glutTabletButtonFunc - * 7.17 glutMenuStatusFunc - * 7.18 glutIdleFunc - * 7.19 glutTimerFunc - */ - glutMainLoop(); // Infinite event loop + glutMotionFunc(cb_drag); + glutPassiveMotionFunc(cb_mouseover); + glutVisibilityFunc(NULL); + glutEntryFunc(cb_mouseentry);//if mouse pointer left or entered the scene + glutSpecialFunc(cb_special_key); + glutSpecialUpFunc(cb_special_key_up); + + //Attach extra call backs if needed in the future +/* glutOverlayDisplayFunc + glutSpaceballMotionFunc + glutSpaceballRotateFunc + glutSpaceballButtonFunc + glutButtonBoxFunc + glutDialsFunc + glutTabletMotionFunc + glutTabletButtonFunc + glutMenuStatusFunc + glutIdleFunc + glutTimerFunc +*/ + + + //pass control to glut + cb_reshape(w,h); + glutMainLoop (); + + + return 0; //we should never reach here + } + diff --git a/cmd/smyrna/glutrender.h b/cmd/smyrna/glutrender.h index 7fce19745..7e74e742f 100644 --- a/cmd/smyrna/glutrender.h +++ b/cmd/smyrna/glutrender.h @@ -6,7 +6,7 @@ extern "C" { #endif - void sm_glutinit(int w,int h,int full); + int cb_glutinit(int x,int y,int w,int h, int bits,int s_rate,int fullscreen,int* argcp, char *argv[],char* optArg); #ifdef __cplusplus } /* end extern "C" */ diff --git a/cmd/smyrna/gui/appmouse.c b/cmd/smyrna/gui/appmouse.c index 6474f6d50..d3ddf849f 100644 --- a/cmd/smyrna/gui/appmouse.c +++ b/cmd/smyrna/gui/appmouse.c @@ -34,8 +34,10 @@ static void apply_actions(ViewInfo* v,int x,int y) { int a; gdouble seconds; - - switch ((a=get_mode(v))) { + a=get_mode(v); + if((a==MM_PAN) && (view->guiMode==GUI_FULLSCREEN) &&((v->active_camera >= 0))) + a=MM_ROTATE; + switch (a) { case MM_ROTATE : seconds = g_timer_elapsed(view->timer3, NULL); if (seconds > 0.1) { diff --git a/cmd/smyrna/gui/glcompui.c b/cmd/smyrna/gui/glcompui.c index 4ca368b4a..28ba7b1ba 100644 --- a/cmd/smyrna/gui/glcompui.c +++ b/cmd/smyrna/gui/glcompui.c @@ -42,7 +42,7 @@ static glCompImage *img3D; static glCompButton *panBtn; -static void menu_click_pan(glCompObj *obj, GLfloat x, GLfloat y, +void menu_click_pan(glCompObj *obj, GLfloat x, GLfloat y, glMouseButtonType t) { deselect_all(view->g[view->activeGraph]); @@ -57,13 +57,13 @@ static void menu_click_zoom(void *obj, GLfloat x, GLfloat y, #endif -static void menu_click_zoom_minus(glCompObj *obj, GLfloat x, GLfloat y, +void menu_click_zoom_minus(glCompObj *obj, GLfloat x, GLfloat y, glMouseButtonType t) { glmotion_zoom_inc(0); } -static void menu_click_zoom_plus(glCompObj *obj, GLfloat x, GLfloat y, +void menu_click_zoom_plus(glCompObj *obj, GLfloat x, GLfloat y, glMouseButtonType t) { glmotion_zoom_inc(1); @@ -97,7 +97,7 @@ static void menu_switch_to_fisheye(glCompObj *obj, GLfloat x, GLfloat y, -static void menu_click_center(glCompObj *obj, GLfloat x, GLfloat y, +void menu_click_center(glCompObj *obj, GLfloat x, GLfloat y, glMouseButtonType t) { if (view->active_camera == -1) { /*2D mode */ @@ -110,7 +110,7 @@ static void menu_click_center(glCompObj *obj, GLfloat x, GLfloat y, } } -static void switch2D3D(glCompObj *obj, GLfloat x, GLfloat y, +void switch2D3D(glCompObj *obj, GLfloat x, GLfloat y, glMouseButtonType t) { if (t == glMouseLeftButton) { diff --git a/cmd/smyrna/gui/topviewsettings.c b/cmd/smyrna/gui/topviewsettings.c index 906bc06fa..c3eda39f1 100644 --- a/cmd/smyrna/gui/topviewsettings.c +++ b/cmd/smyrna/gui/topviewsettings.c @@ -56,6 +56,10 @@ void on_settingsCancelBtn_clicked(GtkWidget * widget, gpointer user_data) { gtk_widget_hide(glade_xml_get_widget(xml, "dlgSettings")); } +void copy_attr(Agraph_t* destG,char* attr,Agraph_t* g) +{ + agattr(g,AGRAPH,attr,agget(destG,attr)); +} static int set_color_button_widget(char *attribute, char *widget_name) @@ -67,7 +71,10 @@ static int set_color_button_widget(char *attribute, char *widget_name) attribute=attribute +13; buf = agget(view->g[view->activeGraph], attribute); if ((!buf) || (strcmp(buf, "") == 0)) + { buf = agget(view->systemGraphs.def_attrs, attribute); + copy_attr(view->systemGraphs.def_attrs, attribute,view->g[view->activeGraph]); + } if (buf) { colorxlate(buf, &cl, RGBA_DOUBLE); color.red = (int) (cl.u.RGBA[0] * 65535.0); @@ -119,7 +126,11 @@ static int set_text_widget(char *attribute, char *widget_name) buf = agget(view->g[view->activeGraph], attribute); if ((!buf) || (strcmp(buf, "") == 0)) + { buf = agget(view->systemGraphs.def_attrs, attribute); + copy_attr(view->systemGraphs.def_attrs, attribute,view->g[view->activeGraph]); + } + if (buf) { gtk_entry_set_text((GtkEntry *) glade_xml_get_widget(xml, widget_name), buf); @@ -136,7 +147,12 @@ static int set_checkbox_widget(char *attribute, char *widget_name) buf = agget(view->g[view->activeGraph], attribute); if ((!buf) || (strcmp(buf, "") == 0)) + { buf = agget(view->systemGraphs.def_attrs, attribute); + copy_attr(view->systemGraphs.def_attrs, attribute,view->g[view->activeGraph]); + } + + if (buf) { value = atoi(buf); gtk_toggle_button_set_active((GtkToggleButton *) @@ -163,7 +179,7 @@ static int get_checkbox_widget_to_attribute(char *attribute, widget_name)); sprintf(buf, "%d", value); agattr(g, AGRAPH, attribute, buf); - return 1; + return 1; } static int set_spinbtn_widget(char *attribute, char *widget_name) @@ -174,7 +190,10 @@ static int set_spinbtn_widget(char *attribute, char *widget_name) buf = agget(view->g[view->activeGraph], attribute); if ((!buf) || (strcmp(buf, "") == 0)) + { buf = agget(view->systemGraphs.def_attrs, attribute); + copy_attr(view->systemGraphs.def_attrs, attribute,view->g[view->activeGraph]); + } if (buf) { value = (float) atof(buf); gtk_spin_button_set_value((GtkSpinButton *) @@ -225,7 +244,11 @@ static int set_scalebtn_widget_to_attribute(char *attribute, buf = agget(view->g[view->activeGraph], attribute); if ((!buf) || (strcmp(buf, "") == 0)) + { buf = agget(view->systemGraphs.def_attrs, attribute); + copy_attr(view->systemGraphs.def_attrs, attribute,view->g[view->activeGraph]); + + } if (buf) { value = (float) atof(buf); gtk_range_set_value((GtkRange *) @@ -242,7 +265,10 @@ static int set_combobox_widget(char *attribute, char *widget_name) attribute=attribute +9; buf = agget(view->g[view->activeGraph], attribute); if ((!buf) || (strcmp(buf, "") == 0)) + { buf = agget(view->systemGraphs.def_attrs, attribute); + copy_attr(view->systemGraphs.def_attrs, attribute,view->g[view->activeGraph]); + } if (buf) { value = (int) atoi(buf); gtk_combo_box_set_active((GtkComboBox *) @@ -292,9 +318,9 @@ int load_settings_from_graph(Agraph_t * g) set_spinbtn_widget(sym->name, agget(view->systemGraphs.attrs_widgets,sym->name)); if(strncmp (sym->name,"scale_button",strlen("scale_button"))==0) set_scalebtn_widget_to_attribute(sym->name, agget(view->systemGraphs.attrs_widgets,sym->name)); + } return 1; - /*P.S: if I can find a way too make gtk windows get along with glut window this might be possible*/ } int update_graph_from_settings(Agraph_t * g) diff --git a/cmd/smyrna/hotkeymap.c b/cmd/smyrna/hotkeymap.c index 1b1929634..8e401dbe2 100644 --- a/cmd/smyrna/hotkeymap.c +++ b/cmd/smyrna/hotkeymap.c @@ -53,17 +53,35 @@ int static get_mouse_mode(const char *s) int static get_button(const char *s) { - - if (strcmp(s, "B_LSHIFT") == 0) - return B_LSHIFT; - if (strcmp(s, "B_RSHIFT") == 0) - return B_RSHIFT; - if (strcmp(s, "B_LCTRL") == 0) - return B_LCTRL; - if (strcmp(s, "B_RCTRL") == 0) - return B_RCTRL; - if (strcmp(s, "0") == 0) - return 0; + if(view->guiMode != GUI_FULLSCREEN) + { + if (strcmp(s, "B_LSHIFT") == 0) + return B_LSHIFT; + if (strcmp(s, "B_RSHIFT") == 0) + return B_RSHIFT; + if (strcmp(s, "B_LCTRL") == 0) + return B_LCTRL; + if (strcmp(s, "B_RCTRL") == 0) + return B_RCTRL; + if (strcmp(s, "0") == 0) + return 0; + } + else + { + int mod = glutGetModifiers(); + if (mod == GLUT_ACTIVE_ALT) + + if (strcmp(s, "B_LSHIFT") == 0) + return GLUT_ACTIVE_SHIFT; + if (strcmp(s, "B_RSHIFT") == 0) + return GLUT_ACTIVE_SHIFT; + if (strcmp(s, "B_LCTRL") == 0) + return GLUT_ACTIVE_CTRL; + if (strcmp(s, "B_RCTRL") == 0) + return GLUT_ACTIVE_CTRL; + if (strcmp(s, "0") == 0) + return 0; + } return 0; } diff --git a/cmd/smyrna/main.c b/cmd/smyrna/main.c index fd460336a..5e316eea1 100755 --- a/cmd/smyrna/main.c +++ b/cmd/smyrna/main.c @@ -56,6 +56,7 @@ gchar *package_locale_dir; static char *smyrnaDir; /* path to directory containin smyrna data files */ char *smyrnaGlade; unsigned char SmyrnaVerbose; +int width,height;/*glut window size*/ /* smyrnaPath: @@ -103,7 +104,7 @@ static char *parseArgs(int argc, char *argv[], ViewInfo * view) { unsigned int c; - while ((c = getopt(argc, argv, ":K:txvf?")) != -1) { + while ((c = getopt(argc, argv, ":Kf:txv?")) != -1) { switch (c) { case 'v': SmyrnaVerbose = 1; @@ -121,6 +122,7 @@ static char *parseArgs(int argc, char *argv[], ViewInfo * view) #endif case 'f': view->guiMode=GUI_FULLSCREEN; + view->optArg=strdup(optarg); break; case '?': @@ -210,9 +212,8 @@ static void windowedMode(int argc, char *argv[]) gtk_widget_show((GtkWidget*)graphComboBox); view->graphComboBox = graphComboBox; - if(view->guiMode==GUI_FULLSCREEN) - gtk_window_fullscreen(glade_xml_get_widget(xml, "frmMain")); - gtk_main(); + if(view->guiMode!=GUI_FULLSCREEN) + gtk_main(); } @@ -259,9 +260,11 @@ int main(int argc, char *argv[]) #ifndef WIN32 glutInit(&argc, argv); #endif - windowedMode(argc, argv); -// view->guiMode=GUI_GLUT; - sm_glutinit(800,600,0); + + if(view->guiMode==GUI_FULLSCREEN) + cb_glutinit(0,0,800,600,32,75,1,&argc,argv,view->optArg); + else + windowedMode(argc, argv); #ifdef G_OS_WIN32 g_free(package_prefix); g_free(package_data_dir); diff --git a/cmd/smyrna/smyrna.vcproj.RESEARCH.arif.user b/cmd/smyrna/smyrna.vcproj.RESEARCH.arif.user index f97efcafa..13f4c52f5 100644 --- a/cmd/smyrna/smyrna.vcproj.RESEARCH.arif.user +++ b/cmd/smyrna/smyrna.vcproj.RESEARCH.arif.user @@ -11,7 +11,7 @@ avgedgelength = totalELength / t->Edgecount; // t->init_node_size=init_node_size(g, t); view->Topview=t; - cacheNodes(g,t); + + + /*render nodes once to get set some attributes set,THIS IS A HACK, FIX IT*/ + renderNodes(g); cacheEdges(g,t); - cacheSelectedNodes(g,t); cacheSelectedEdges(g,t); - cacheNodeLabels(g,t); + cacheNodes(g,t); + cacheSelectedNodes(g,t); cacheEdgeLabels(g,t); + cacheNodeLabels(g,t); } void initSmGraph(Agraph_t * g,topview* rv) { rv->maxnodedegree = 1; - /*create glcomp menu system */ - view->widgets = glcreate_gl_topview_menu(); /*create attribute list*/ rv->attributes=load_attr_list(view->g[view->activeGraph]); @@ -774,9 +776,28 @@ void initSmGraph(Agraph_t * g,topview* rv) void renderSmGraph(Agraph_t * g,topview* t) { + /* + we like to have blending affect where node and edge overlap + to achive this depth test should be turned off. + */ glEnable(GL_POINT_SMOOTH); + glEnable(GL_DEPTH_TEST); + glDepthFunc (GL_ALWAYS); + glEnable(GL_DEPTH); +// glDepthMask(0); + if(view->drawedges) + { + glCallList(t->cache.edge_id); + glCallList(t->cache.seledge_id); + if(view->drawedgelabels) + { + if(view->zoom*-1 < t->fitin_zoom /(float)view->labelnumberofnodes*-1) + glCallList(t->cache.edgelabel_id); + + } + } if(view->drawnodes) { glPointSize(view->nodeScale*t->fitin_zoom/view->zoom); @@ -789,17 +810,6 @@ void renderSmGraph(Agraph_t * g,topview* t) } } - if(view->drawedges) - { - glCallList(t->cache.edge_id); - glCallList(t->cache.seledge_id); - if(view->drawedgelabels) - { - if(view->zoom*-1 < t->fitin_zoom /(float)view->labelnumberofnodes*-1) - glCallList(t->cache.edgelabel_id); - - } - } } void freeSmGraph(Agraph_t * g,topview* t) diff --git a/cmd/smyrna/viewport.c b/cmd/smyrna/viewport.c index fe5e1801c..ba949c3ba 100755 --- a/cmd/smyrna/viewport.c +++ b/cmd/smyrna/viewport.c @@ -293,8 +293,6 @@ void set_viewport_settings_from_template(ViewInfo * view, Agraph_t * g) ("defaultfisheyemagnifierdistort", view, g)); view->drawnodes = atoi(get_attribute_value("drawnodes", view, g)); view->drawedges = atoi(get_attribute_value("drawedges", view, g)); - view->drawnodes=1; - view->drawedges=1; view->drawnodelabels=atoi(get_attribute_value("labelshownodes", view, g)); view->drawedgelabels=atoi(get_attribute_value("labelshowedges", view, g)); view->nodeScale=atof(get_attribute_value("nodesize", view, g))*.30; @@ -519,6 +517,10 @@ void init_viewport(ViewInfo * view) view->edgerendertype=0; if(view->guiMode!=GUI_FULLSCREEN) view->guiMode=GUI_WINDOWED; + + /*create glcomp menu system */ + view->widgets = glcreate_gl_topview_menu(); + } @@ -679,7 +681,9 @@ void refreshViewport(int doClear) view->refresh.selection=1; view->refresh.visibility=1; load_settings_from_graph(graph); - update_graph_from_settings(graph); + + if(view->guiMode!=GUI_FULLSCREEN) + update_graph_from_settings(graph); set_viewport_settings_from_template(view, graph); graphRecord(graph); initSmGraph(graph,view->Topview); -- 2.50.1