From 0c0500de1cfbb7dffa65feece669e9c8f95970f2 Mon Sep 17 00:00:00 2001 From: arif Date: Mon, 2 Aug 2010 16:40:04 +0000 Subject: [PATCH] full screen support for WIN32 (mac doesnt support , linux behaviour is unknown) --- cmd/smyrna/glexpose.c | 6 +- cmd/smyrna/gui/topviewsettings.c | 60 +++------- cmd/smyrna/main.c | 121 ++++++++++++-------- cmd/smyrna/smyrna.vcproj | 4 + cmd/smyrna/smyrna.vcproj.RESEARCH.arif.user | 4 +- cmd/smyrna/smyrnadefs.h | 3 + cmd/smyrna/viewport.c | 37 +++++- 7 files changed, 139 insertions(+), 96 deletions(-) diff --git a/cmd/smyrna/glexpose.c b/cmd/smyrna/glexpose.c index 73bd0a0e6..662c2d8a4 100644 --- a/cmd/smyrna/glexpose.c +++ b/cmd/smyrna/glexpose.c @@ -24,7 +24,6 @@ #include "hotkeymap.h" #include "polytess.h" -#if 0 static void draw_cube() { @@ -61,7 +60,6 @@ static void draw_cube() glVertex3f(100.0f, -100.0f, -100.0f); // Bottom Right Of The Quad (Right) glEnd(); } -#endif static void drawRotatingAxis(void) { @@ -261,6 +259,9 @@ int glexpose_main(ViewInfo * view) if (!glupdatecamera(view)) return 0; + draw_cube(); + + if (view->activeGraph >= 0) { if (!doonce) { doonce = 1; @@ -277,7 +278,6 @@ int glexpose_main(ViewInfo * view) drawBorders(view); glexpose_drawgraph(view); // drawRotatingTools(); -// draw_cube(); drawRotatingAxis(); draw_selpoly(&view->Topview->sel.selPoly); // draw_stuff(); diff --git a/cmd/smyrna/gui/topviewsettings.c b/cmd/smyrna/gui/topviewsettings.c index 3ad1e13cd..906bc06fa 100644 --- a/cmd/smyrna/gui/topviewsettings.c +++ b/cmd/smyrna/gui/topviewsettings.c @@ -278,52 +278,25 @@ static int get_combobox_widget_to_attribute(char *attribute, int load_settings_from_graph(Agraph_t * g) { Agsym_t* sym=NULL; - while ((sym = agnxtattr(view->systemGraphs.attrs_widgets,AGRAPH, sym))) - { - if(strncmp (sym->name,"color_button",strlen("color_button"))==0) - set_color_button_widget(sym->name, agget(view->systemGraphs.attrs_widgets,sym->name)); - if(strncmp (sym->name,"check_box",strlen("check_box"))==0) - set_checkbox_widget(sym->name, agget(view->systemGraphs.attrs_widgets,sym->name)); - if(strncmp (sym->name,"text_box",strlen("text_box"))==0) - set_text_widget(sym->name, agget(view->systemGraphs.attrs_widgets,sym->name)); - if(strncmp (sym->name,"combobox",strlen("combobox"))==0) - set_combobox_widget(sym->name, agget(view->systemGraphs.attrs_widgets,sym->name)); - if(strncmp (sym->name,"spin_button",strlen("spin_button"))==0) - 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)); - - } + while ((sym = agnxtattr(view->systemGraphs.attrs_widgets,AGRAPH, sym))) + { + if(strncmp (sym->name,"color_button",strlen("color_button"))==0) + set_color_button_widget(sym->name, agget(view->systemGraphs.attrs_widgets,sym->name)); + if(strncmp (sym->name,"check_box",strlen("check_box"))==0) + set_checkbox_widget(sym->name, agget(view->systemGraphs.attrs_widgets,sym->name)); + if(strncmp (sym->name,"text_box",strlen("text_box"))==0) + set_text_widget(sym->name, agget(view->systemGraphs.attrs_widgets,sym->name)); + if(strncmp (sym->name,"combobox",strlen("combobox"))==0) + set_combobox_widget(sym->name, agget(view->systemGraphs.attrs_widgets,sym->name)); + if(strncmp (sym->name,"spin_button",strlen("spin_button"))==0) + 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*/ } -/* graphRecord: - * add graphRec to graph if necessary. - * update fields of graphRec. - * We assume the graph has attributes nodelabelattribute, edgelabelattribute, - * nodelabelcolor and edgelabelcolor from template.dot. - * We assume nodes have pos attributes. - */ -static void -graphRecord (Agraph_t* g) -{ - agbindrec(g, "graphRec", sizeof(graphRec), 1); - - GG_nodelabelcolor(g) = agattr (g, AGRAPH, "nodelabelcolor", 0); - GG_edgelabelcolor(g) = agattr (g, AGRAPH, "edgelabelcolor", 0); - - GN_pos(g) = agattr (g, AGNODE, "pos", 0); - GN_size(g) = agattr (g, AGNODE, "size", 0); - GN_visible(g) = agattr (g, AGNODE, "visible", 0); - GN_selected(g) = agattr (g, AGNODE, "selected", 0); - GN_labelattribute(g) = agattr (g, AGNODE, agget(g,"nodelabelattribute"), 0); - - GE_visible(g) = agattr (g, AGEDGE, "visible", 0); - GE_selected(g) = agattr (g, AGEDGE, "selected", 0); - GE_labelattribute(g) = agattr (g, AGEDGE, agget(g,"edgelabelattribute"), 0); -} - - int update_graph_from_settings(Agraph_t * g) { Agsym_t* sym=NULL; @@ -342,7 +315,6 @@ int update_graph_from_settings(Agraph_t * g) if(strncmp (sym->name,"scale_button",strlen("scale_button"))==0) get_scalebtn_widget_to_attribute(sym->name, agget(view->systemGraphs.attrs_widgets,sym->name),g); } - graphRecord(g); return 1; } diff --git a/cmd/smyrna/main.c b/cmd/smyrna/main.c index dd4e21d7b..8980aa30a 100755 --- a/cmd/smyrna/main.c +++ b/cmd/smyrna/main.c @@ -39,6 +39,7 @@ #include "libintl.h" #endif #include +#include "glutrender.h" #ifdef HAVE_GETOPT_H #include @@ -101,7 +102,7 @@ static char *parseArgs(int argc, char *argv[], ViewInfo * view) { unsigned int c; - while ((c = getopt(argc, argv, ":K:txv?")) != -1) { + while ((c = getopt(argc, argv, ":K:txvf?")) != -1) { switch (c) { case 'v': SmyrnaVerbose = 1; @@ -117,6 +118,10 @@ static char *parseArgs(int argc, char *argv[], ViewInfo * view) view->dfltEngine = s2layout(optarg); break; #endif + case 'f': + view->guiMode=GUI_FULLSCREEN; + break; + case '?': if (optopt == '?') usage(0); @@ -145,14 +150,76 @@ static void close_cgraph(Agraph_t * g) } #endif +void display() +{ + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + glLoadIdentity(); + glexpose_main(view); + glutSwapBuffers(); -int main(int argc, char *argv[]) +} +static void glutMode() +{ + glutInitWindowSize(512,512); + glutInitDisplayMode ( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH); + glutCreateWindow("The glut hello world program"); + glutDisplayFunc(display); + + glutMainLoop(); // Infinite event loop +} + + +static void windowedMode(int argc, char *argv[]) { GdkGLConfig *glconfig; - char *initFileName; /*combo box to show loaded graphs */ GtkComboBox *graphComboBox; + gtk_set_locale(); + gtk_init(&argc, &argv); + if (!(smyrnaGlade)) + smyrnaGlade = smyrnaPath("smyrna.glade"); + xml = glade_xml_new(smyrnaGlade, 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. */ + glconfig = configure_gl(); +// gladewidget = glade_xml_get_widget(xml, "vbox2"); + gladewidget = glade_xml_get_widget(xml, "hbox11"); + + gtk_widget_hide(glade_xml_get_widget(xml, "vbox13")); + gtk_window_set_deletable ((GtkWindow*)glade_xml_get_widget(xml, "dlgSettings"),0); + gtk_window_set_deletable ((GtkWindow*)glade_xml_get_widget(xml, "frmTVNodes"),0); + create_window(glconfig, gladewidget); + change_cursor(GDK_TOP_LEFT_ARROW); + +#ifndef WIN32 + glutInit(&argc, argv); +#endif + + gladewidget = glade_xml_get_widget(xml, "hbox13"); + graphComboBox = (GtkComboBox *) gtk_combo_box_new_text(); + gtk_box_pack_end((GtkBox*)gladewidget, (GtkWidget*)graphComboBox, 1, 1, 10); + gtk_widget_show((GtkWidget*)graphComboBox); + view->graphComboBox = graphComboBox; + + if(view->guiMode==GUI_FULLSCREEN) + gtk_window_fullscreen(glade_xml_get_widget(xml, "frmMain")); + gtk_main(); +} + + + + +int main(int argc, char *argv[]) +{ + char *initFileName; + smyrnaDir = getenv("SMYRNA_PATH"); @@ -187,52 +254,16 @@ int main(int argc, char *argv[]) textdomain(GETTEXT_PACKAGE); #endif view = NEW(ViewInfo); - init_viewport(view); - gtk_set_locale(); - gtk_init(&argc, &argv); - initFileName = parseArgs(argc, argv, view); - if (!(smyrnaGlade)) - smyrnaGlade = smyrnaPath("smyrna.glade"); - xml = glade_xml_new(smyrnaGlade, 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); - if (initFileName) { - view->initFile = 1; - view->initFileName = strdup(initFileName); - } - gtk_gl_init(0, 0); - /* Configure OpenGL framebuffer. */ - glconfig = configure_gl(); -// gladewidget = glade_xml_get_widget(xml, "vbox2"); - gladewidget = glade_xml_get_widget(xml, "hbox11"); - - gtk_widget_hide(glade_xml_get_widget(xml, "vbox13")); - gtk_window_set_deletable ((GtkWindow*)glade_xml_get_widget(xml, "dlgSettings"),0); - gtk_window_set_deletable ((GtkWindow*)glade_xml_get_widget(xml, "frmTVNodes"),0); - - - create_window(glconfig, gladewidget); - - change_cursor(GDK_TOP_LEFT_ARROW); - + view->initFileName = parseArgs(argc, argv, view); + if(view->initFileName) + view->initFile=1; #ifndef WIN32 glutInit(&argc, argv); #endif - - gladewidget = glade_xml_get_widget(xml, "hbox13"); - graphComboBox = (GtkComboBox *) gtk_combo_box_new_text(); - gtk_box_pack_end((GtkBox*)gladewidget, (GtkWidget*)graphComboBox, 1, 1, 10); - gtk_widget_show((GtkWidget*)graphComboBox); - view->graphComboBox = graphComboBox; - gtk_main(); - - - + windowedMode(argc, argv); +// view->guiMode=GUI_GLUT; + sm_glutinit(800,600,0); #ifdef G_OS_WIN32 g_free(package_prefix); g_free(package_data_dir); diff --git a/cmd/smyrna/smyrna.vcproj b/cmd/smyrna/smyrna.vcproj index 4ba47dd11..05c546b01 100644 --- a/cmd/smyrna/smyrna.vcproj +++ b/cmd/smyrna/smyrna.vcproj @@ -376,6 +376,10 @@ RelativePath=".\gltemplate.c" > + + diff --git a/cmd/smyrna/smyrna.vcproj.RESEARCH.arif.user b/cmd/smyrna/smyrna.vcproj.RESEARCH.arif.user index dfdb79522..3dd9b1604 100644 --- a/cmd/smyrna/smyrna.vcproj.RESEARCH.arif.user +++ b/cmd/smyrna/smyrna.vcproj.RESEARCH.arif.user @@ -2,7 +2,7 @@ E_selected) #define GG_edgelabelcolor(g) (GREC(g)->G_edgelabelcolor) #define GE_labelattribute(g) (GREC(g)->E_labelattribute) +#define GUI_WINDOWED 0 +#define GUI_FULLSCREEN 1 typedef struct _selection { glCompPoly selPoly; @@ -716,6 +718,7 @@ typedef struct refresh_filter refresh; int edgerendertype; float nodeScale; + int guiMode; } ViewInfo; /*rotation steps*/ diff --git a/cmd/smyrna/viewport.c b/cmd/smyrna/viewport.c index fa709ed21..01e759b2c 100755 --- a/cmd/smyrna/viewport.c +++ b/cmd/smyrna/viewport.c @@ -47,6 +47,7 @@ static void refresh_borders(Agraph_t * g); static colorschemaset *create_color_theme(int themeid); static md5_byte_t *get_md5_key(Agraph_t * graph); + #define countof( array ) ( sizeof( array )/sizeof( array[0] ) ) ViewInfo *view; @@ -292,6 +293,8 @@ 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; @@ -514,8 +517,8 @@ void init_viewport(ViewInfo * view) view->refresh.visibility=1; view->refresh.nodesize=1; view->edgerendertype=0; - /*add default camera */ - //create fontset + if(view->guiMode!=GUI_FULLSCREEN) + view->guiMode=GUI_WINDOWED; } @@ -637,6 +640,35 @@ int add_graph_to_viewport_from_file(char *fileName) return add_graph_to_viewport(graph, fileName); } + +/* graphRecord: + * add graphRec to graph if necessary. + * update fields of graphRec. + * We assume the graph has attributes nodelabelattribute, edgelabelattribute, + * nodelabelcolor and edgelabelcolor from template.dot. + * We assume nodes have pos attributes. + */ +static void +graphRecord (Agraph_t* g) +{ + agbindrec(g, "graphRec", sizeof(graphRec), 1); + + GG_nodelabelcolor(g) = agattr (g, AGRAPH, "nodelabelcolor", 0); + GG_edgelabelcolor(g) = agattr (g, AGRAPH, "edgelabelcolor", 0); + + GN_pos(g) = agattr (g, AGNODE, "pos", 0); + GN_size(g) = agattr (g, AGNODE, "size", 0); + GN_visible(g) = agattr (g, AGNODE, "visible", 0); + GN_selected(g) = agattr (g, AGNODE, "selected", 0); + GN_labelattribute(g) = agattr (g, AGNODE, agget(g,"nodelabelattribute"), 0); + + GE_visible(g) = agattr (g, AGEDGE, "visible", 0); + GE_selected(g) = agattr (g, AGEDGE, "selected", 0); + GE_labelattribute(g) = agattr (g, AGEDGE, agget(g,"edgelabelattribute"), 0); +} + + + void refreshViewport(int doClear) { Agraph_t *graph = view->g[view->activeGraph]; @@ -648,6 +680,7 @@ void refreshViewport(int doClear) load_settings_from_graph(graph); update_graph_from_settings(graph); set_viewport_settings_from_template(view, graph); + graphRecord(graph); initSmGraph(graph,view->Topview); // update_topview(graph, view->Topview, 1); -- 2.50.1