From d661aa2b1b63f7d3828b89183741904cbcc9f8df Mon Sep 17 00:00:00 2001 From: arif Date: Tue, 23 Jun 2009 21:38:59 +0000 Subject: [PATCH] gvpr + multiplle graphs --- cmd/smyrna/gui/menucallbacks.c | 8 +-- cmd/smyrna/gui/toolboxcallbacks.c | 9 +++ cmd/smyrna/gui/toolboxcallbacks.h | 1 + cmd/smyrna/gvprpipe.c | 14 ++++- cmd/smyrna/main.c | 10 ++- cmd/smyrna/smyrna.vcproj | 6 +- cmd/smyrna/smyrnadefs.h | 1 + cmd/smyrna/topfisheyeview.c | 20 +++--- cmd/smyrna/topview.c | 46 +++++++------- cmd/smyrna/viewport.c | 45 ++++++++----- graphviz.sln | 18 ++++-- lib/sfdpgen/sfdp.vcproj | 2 +- share/gui/smyrna.glade | 101 ++++++++++++++++++++++++++++++ 13 files changed, 218 insertions(+), 63 deletions(-) diff --git a/cmd/smyrna/gui/menucallbacks.c b/cmd/smyrna/gui/menucallbacks.c index 0ad14826a..d8568dc7c 100755 --- a/cmd/smyrna/gui/menucallbacks.c +++ b/cmd/smyrna/gui/menucallbacks.c @@ -55,8 +55,8 @@ void mOpenSlot(GtkWidget * widget, gpointer user_data) if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) { char *filename; filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog)); - if (view->activeGraph == 0) - close_graph(view,0); +/* if (view->activeGraph == 0) + close_graph(view,0);*/ add_graph_to_viewport_from_file(filename); g_free(filename); } @@ -536,9 +536,9 @@ void mTestgvpr(GtkWidget * widget, gpointer user_data) assert (j == argc); run_gvpr (view->g[view->activeGraph], argc, argv); - for (i = 1; i < argc; i++) +/* for (i = 1; i < argc; i++) free (argv[i]); - free (argv); + free (argv);*/ } diff --git a/cmd/smyrna/gui/toolboxcallbacks.c b/cmd/smyrna/gui/toolboxcallbacks.c index c4d557284..a556173ac 100755 --- a/cmd/smyrna/gui/toolboxcallbacks.c +++ b/cmd/smyrna/gui/toolboxcallbacks.c @@ -183,3 +183,12 @@ void write_to_console(char* text) gtk_text_buffer_insert (view->consoleText,&iter,text,-1); gtk_text_view_set_buffer ((GtkTextView*)glade_xml_get_widget(xml, "consoleText"),view->consoleText); } +extern void switch_graph(int graphId); +void on_btnActivateGraph_clicked(GtkWidget * widget, gpointer user_data) +{ + int graphId; + graphId=gtk_combo_box_get_active(view->graphComboBox); + printf ("%d\n",graphId); + switch_graph(graphId); +} + diff --git a/cmd/smyrna/gui/toolboxcallbacks.h b/cmd/smyrna/gui/toolboxcallbacks.h index 8f14e60a7..b14db995b 100755 --- a/cmd/smyrna/gui/toolboxcallbacks.h +++ b/cmd/smyrna/gui/toolboxcallbacks.h @@ -50,6 +50,7 @@ _BB void btnToolAddEdge_clicked(GtkWidget * widget, gpointer user_data); _BB void btnToolDeleteEdge_clicked(GtkWidget * widget, gpointer user_data); _BB void btnToolFindEdge_clicked(GtkWidget * widget, gpointer user_data); _BB void btnToolCursor_clicked(GtkWidget * widget, gpointer user_data); +_BB void on_btnActivateGraph_clicked(GtkWidget * widget, gpointer user_data); void write_to_console(char* text); diff --git a/cmd/smyrna/gvprpipe.c b/cmd/smyrna/gvprpipe.c index b83d8981f..f5045f65a 100644 --- a/cmd/smyrna/gvprpipe.c +++ b/cmd/smyrna/gvprpipe.c @@ -30,10 +30,20 @@ extern GladeXML* xml; static void refreshViewport () { - update_graph_from_settings(view->g[view->activeGraph]); + view->Topview->Graphdata.GraphFileName = strdup ("unnamed"); + load_settings_from_graph(view->g[view->activeGraph]); + update_graph_from_settings(view->g[view->activeGraph]); + set_viewport_settings_from_template(view, view->g[view->activeGraph]); + update_topview(view->g[view->activeGraph], view->Topview,1); + fill_key(view->orig_key,get_md5_key(view->g[view->activeGraph])); + expose_event(view->drawing_area, NULL, NULL); +/* + update_graph_from_settings(view->g[view->activeGraph]); set_viewport_settings_from_template(view, view->g[view->activeGraph]); settvcolorinfo(view->g[view->activeGraph],view->Topview); - glexpose (); + glexpose ();*/ + + } static ssize_t outfn (void* sp, const char *buf, size_t nbyte, void* dp) diff --git a/cmd/smyrna/main.c b/cmd/smyrna/main.c index d1cf87482..4845de327 100755 --- a/cmd/smyrna/main.c +++ b/cmd/smyrna/main.c @@ -203,6 +203,8 @@ int main(int argc, char *argv[]) { GdkGLConfig *glconfig; char* initFileName; + /*combo box to show loaded graphs*/ + GtkComboBox * graphComboBox; smyrnaDir = getenv ("SMYRNA_PATH"); if (!smyrnaDir) { @@ -263,7 +265,7 @@ int main(int argc, char *argv[]) gtk_gl_init(0, 0); /* Configure OpenGL framebuffer. */ glconfig = configure_gl(); - gladewidget = glade_xml_get_widget(xml, "vbox2"); + gladewidget = glade_xml_get_widget(xml, "vbox2"); create_window(glconfig, gladewidget); change_cursor(GDK_TOP_LEFT_ARROW); @@ -271,6 +273,12 @@ int main(int argc, char *argv[]) #ifndef WIN32 glutInit(&argc,argv); #endif + + gladewidget = glade_xml_get_widget(xml, "hbox10"); + graphComboBox=(GtkComboBox*)gtk_combo_box_new_text(); + gtk_box_pack_end(gladewidget,graphComboBox,1,1,10); + gtk_widget_show(graphComboBox); + view->graphComboBox=graphComboBox; gtk_main(); diff --git a/cmd/smyrna/smyrna.vcproj b/cmd/smyrna/smyrna.vcproj index f6ffdbc19..72ea120b6 100644 --- a/cmd/smyrna/smyrna.vcproj +++ b/cmd/smyrna/smyrna.vcproj @@ -40,7 +40,7 @@ Name="VCCLCompilerTool" AdditionalOptions="/D "_CRT_SECURE_NO_DEPRECATE"" Optimization="0" - AdditionalIncludeDirectories=""C:\graphviz-ms\graphviz2\lib\windirent";"$(SolutionDir)/lib/gvc";"C:\gtk\include\libglade-2.0";"$(SolutionDir)/lib/neatogen";"$(SolutionDir)/lib/sparse";"$(SolutionDir)/lib/topfish";"C:\gtk\lib\gtkglext-1.0\include";"C:\gtk\include\gtkglext-1.0\";C:\gtk\include\cairo;"C:\gtk\include\atk-1.0";"C:\gtk\lib\gtk-2.0\include\cairo";"C:\gtk\lib\gtk-2.0\include";"C:\gtk\include\gtk-2.0\";"$(SolutionDir)/cmd/smyrna/gui";"$(SolutionDir)/cmd/smyrna";"$(SolutionDir)";"$(SolutionDir)/lib/glcomp";"C:\gtk\lib\glib-2.0\include";"C:\gtk\include\glib-2.0";"C:\gtk\include\pango-1.0\";C:\gtk\include;"$(SolutionDir)/lib/common";"$(SolutionDir)/lib/cdt";"$(SolutionDir)/lib/cgraph";"$(SolutionDir)/windows\lib\ingraphs";"$(SolutionDir)/lib/xdot";"$(SolutionDir)/lib/glut/glut-3.7.6-bin"" + AdditionalIncludeDirectories=""$(SolutionDir)/lib/gvc";"C:\gtk\include\libglade-2.0";"$(SolutionDir)/lib/neatogen";"$(SolutionDir)/lib/sparse";"$(SolutionDir)/lib/topfish";"C:\gtk\lib\gtkglext-1.0\include";"C:\gtk\include\gtkglext-1.0\";C:\gtk\include\cairo;"C:\gtk\include\atk-1.0";"C:\gtk\lib\gtk-2.0\include\cairo";"C:\gtk\lib\gtk-2.0\include";"C:\gtk\include\gtk-2.0\";"$(SolutionDir)/cmd/smyrna/gui";"$(SolutionDir)/cmd/smyrna";"$(SolutionDir)";"$(SolutionDir)/lib/glcomp";"C:\gtk\lib\glib-2.0\include";"C:\gtk\include\glib-2.0";"C:\gtk\include\pango-1.0\";C:\gtk\include;"$(SolutionDir)/lib/common";"$(SolutionDir)/lib/gvpr";"$(SolutionDir)/lib/cdt";"$(SolutionDir)/lib/cgraph";"$(SolutionDir)/lib/glut/glut-3.7.6-bin";"$(SolutionDir)/lib/xdot"" PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;HAVE_TRIANGLE;HAVE_CONFIG_H;HAVE_GTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;WIN32_DLL" MinimalRebuild="true" BasicRuntimeChecks="3" @@ -62,7 +62,7 @@ /> Topview->tarColor.B = (float) cl.u.RGBA[2]; - sscanf(agget(view->g[0],"topologicalfisheyedistortionfactor"),"%lf",&view->Topview->parms.repos.distortion); - sscanf(agget(view->g[0],"topologicalfisheyefinenodes"),"%d",&view->Topview->parms.level.num_fine_nodes); - sscanf(agget(view->g[0],"topologicalfisheyecoarseningfactor"),"%lf",&view->Topview->parms.level.coarsening_rate); - sscanf(agget(view->g[0],"topologicalfisheyedist2limit"),"%d",&view->Topview->parms.hier.dist2_limit); - sscanf(agget(view->g[0],"topologicalfisheyeanimate"),"%d",&view->Topview->animate); + sscanf(agget(view->g[view->activeGraph],"topologicalfisheyedistortionfactor"),"%lf",&view->Topview->parms.repos.distortion); + sscanf(agget(view->g[view->activeGraph],"topologicalfisheyefinenodes"),"%d",&view->Topview->parms.level.num_fine_nodes); + sscanf(agget(view->g[view->activeGraph],"topologicalfisheyecoarseningfactor"),"%lf",&view->Topview->parms.level.coarsening_rate); + sscanf(agget(view->g[view->activeGraph],"topologicalfisheyedist2limit"),"%d",&view->Topview->parms.hier.dist2_limit); + sscanf(agget(view->g[view->activeGraph],"topologicalfisheyeanimate"),"%d",&view->Topview->animate); set_active_levels(hp, fs->foci_nodes, fs->num_foci, &(t->parms.level)); positionAllItems(hp, fs, &(t->parms.repos)); @@ -656,11 +656,11 @@ void changetopfishfocus(topview * t, float *x, float *y, - sscanf(agget(view->g[0],"topologicalfisheyedistortionfactor"),"%lf",&view->Topview->parms.repos.distortion); - sscanf(agget(view->g[0],"topologicalfisheyefinenodes"),"%d",&view->Topview->parms.level.num_fine_nodes); - sscanf(agget(view->g[0],"topologicalfisheyecoarseningfactor"),"%lf",&view->Topview->parms.level.coarsening_rate); - sscanf(agget(view->g[0],"topologicalfisheyedist2limit"),"%d",&view->Topview->parms.hier.dist2_limit); - sscanf(agget(view->g[0],"topologicalfisheyeanimate"),"%d",&view->Topview->animate); + sscanf(agget(view->g[view->activeGraph],"topologicalfisheyedistortionfactor"),"%lf",&view->Topview->parms.repos.distortion); + sscanf(agget(view->g[view->activeGraph],"topologicalfisheyefinenodes"),"%d",&view->Topview->parms.level.num_fine_nodes); + sscanf(agget(view->g[view->activeGraph],"topologicalfisheyecoarseningfactor"),"%lf",&view->Topview->parms.level.coarsening_rate); + sscanf(agget(view->g[view->activeGraph],"topologicalfisheyedist2limit"),"%d",&view->Topview->parms.hier.dist2_limit); + sscanf(agget(view->g[view->activeGraph],"topologicalfisheyeanimate"),"%d",&view->Topview->animate); diff --git a/cmd/smyrna/topview.c b/cmd/smyrna/topview.c index d8c939e1d..8ca15f81a 100755 --- a/cmd/smyrna/topview.c +++ b/cmd/smyrna/topview.c @@ -154,36 +154,38 @@ void settvposinfo(Agraph_t* g,topview* t) /*loop nodes*/ - for (ind=0;ind < t->Nodecount ; ind ++) { - np = t->Nodes + ind; - setpositioninfo(&np->x,&np->y,&np->z,agxget(np->Node, poss)); - - /*distorted coordiates, same with original ones at the beginning*/ - np->distorted_x = t->Nodes[ind].x; - np->distorted_y = t->Nodes[ind].y; - np->distorted_z = t->Nodes[ind].z; - xmax = MAX(xmax, np->x); - xmin = MIN(xmin, np->x); - ymax = MAX(ymax, np->y); - ymin = MIN(ymin, np->y); + for (ind=0;ind < t->Nodecount ; ind ++) + { + np = t->Nodes + ind; + setpositioninfo(&np->x,&np->y,&np->z,agxget(np->Node, poss)); + + /*distorted coordiates, same with original ones at the beginning*/ + np->distorted_x = t->Nodes[ind].x; + np->distorted_y = t->Nodes[ind].y; + np->distorted_z = t->Nodes[ind].z; + xmax = MAX(xmax, np->x); + xmin = MIN(xmin, np->x); + ymax = MAX(ymax, np->y); + ymin = MIN(ymin, np->y); } /*loop edges*/ - for (ind=0;ind < t->Edgecount ; ind ++) { - ep = t->Edges + ind; + for (ind=0;ind < t->Edgecount ; ind ++) + { + ep = t->Edges + ind; ep->x1 = ep->Node1->x; ep->y1 = ep->Node1->y; ep->z1 = ep->Node1->z; ep->x2 = ep->Node2->x; ep->y2 = ep->Node2->y; ep->z2 = ep->Node2->z; - len=(float)DIST(ep->x2 - ep->x1, ep->y2 - ep->y1); - totallen = totallen + len; - if (len > maxedgelen) - maxedgelen=len; - if(len < minedgelen) - minedgelen=len; - ep->length=len; + len=(float)DIST(ep->x2 - ep->x1, ep->y2 - ep->y1); + totallen = totallen + len; + if (len > maxedgelen) + maxedgelen=len; + if(len < minedgelen) + minedgelen=len; + ep->length=len; } t->maxedgelen=maxedgelen; @@ -372,6 +374,8 @@ void preparetopview(Agraph_t * g, topview * t) /*set some stats for topview*/ t->Nodecount = ind; t->Edgecount = ind2; + printf("node count:%d\n",ind); + printf("edge count:%d\n",ind2); /*create glcomp menu system*/ diff --git a/cmd/smyrna/viewport.c b/cmd/smyrna/viewport.c index 59482bd43..5240f6474 100755 --- a/cmd/smyrna/viewport.c +++ b/cmd/smyrna/viewport.c @@ -97,7 +97,7 @@ static void* get_glut_font(int ind) } } -static void fill_key(md5_byte_t* b,md5_byte_t* data) +void fill_key(md5_byte_t* b,md5_byte_t* data) { int ind=0; for (ind=0;ind < 16;ind ++) @@ -593,24 +593,39 @@ int add_graph_to_viewport_from_file(char *fileName) int add_graph_to_viewport(Agraph_t* graph) { - 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; + 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; + load_settings_from_graph(view->g[view->activeGraph]); + update_graph_from_settings(view->g[view->activeGraph]); + set_viewport_settings_from_template(view, view->g[view->activeGraph]); + update_topview(graph, view->Topview,1); + gtk_combo_box_append_text(view->graphComboBox,view->Topview->Graphdata.GraphFileName); + fill_key(view->orig_key,get_md5_key(graph)); + expose_event(view->drawing_area, NULL, NULL); + return 1; + } + else + { + return 0; + } + +} +void switch_graph(int graphId) +{ + if (graphId >= view->graphCount) + return;/*wrong entry*/ + view->activeGraph = graphId; load_settings_from_graph(view->g[view->activeGraph]); update_graph_from_settings(view->g[view->activeGraph]); set_viewport_settings_from_template(view, view->g[view->activeGraph]); - update_topview(graph, view->Topview,1); - fill_key(view->orig_key,get_md5_key(graph)); + cleartopview(view->Topview); + update_topview(view->g[view->activeGraph], view->Topview,1); + fill_key(view->orig_key,get_md5_key(view->g[view->activeGraph])); expose_event(view->drawing_area, NULL, NULL); - return 1; - } - else { - return 0; - } } diff --git a/graphviz.sln b/graphviz.sln index 5fe434854..925556ead 100644 --- a/graphviz.sln +++ b/graphviz.sln @@ -195,12 +195,14 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gvtest", "cmd\tester\gvtest EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "osage", "lib\osage\osage.vcproj", "{8E82D6BD-74D0-48C3-887A-1754EA71DA5A}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gvprlib", "cmd\gvprlib\gvprlib.vcproj", "{1068DA13-0BB3-43A7-8776-6F519003EEBD}" -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sfdp", "lib\sfdpgen\sfdp.vcproj", "{443EB1A7-C634-4292-9F2D-C752BB2BF40F}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "rbtree", "lib\rbtree\rbtree.vcproj", "{D6CEB142-BF8E-471C-AE16-4300F2D5DEDA}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gts", "lib\GTS\gts.vcproj", "{0DEA7FAC-4190-4B39-BEF0-1C055758FED3}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gvprlib", "lib\gvpr\gvprlib.vcproj", "{8C103DE9-BC35-4173-A08D-63906EC5EEFD}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 @@ -423,10 +425,6 @@ Global {8E82D6BD-74D0-48C3-887A-1754EA71DA5A}.Debug|Win32.Build.0 = Debug|Win32 {8E82D6BD-74D0-48C3-887A-1754EA71DA5A}.Release|Win32.ActiveCfg = Release|Win32 {8E82D6BD-74D0-48C3-887A-1754EA71DA5A}.Release|Win32.Build.0 = Release|Win32 - {1068DA13-0BB3-43A7-8776-6F519003EEBD}.Debug|Win32.ActiveCfg = Debug|Win32 - {1068DA13-0BB3-43A7-8776-6F519003EEBD}.Debug|Win32.Build.0 = Debug|Win32 - {1068DA13-0BB3-43A7-8776-6F519003EEBD}.Release|Win32.ActiveCfg = Release|Win32 - {1068DA13-0BB3-43A7-8776-6F519003EEBD}.Release|Win32.Build.0 = Release|Win32 {443EB1A7-C634-4292-9F2D-C752BB2BF40F}.Debug|Win32.ActiveCfg = Debug|Win32 {443EB1A7-C634-4292-9F2D-C752BB2BF40F}.Debug|Win32.Build.0 = Debug|Win32 {443EB1A7-C634-4292-9F2D-C752BB2BF40F}.Release|Win32.ActiveCfg = Release|Win32 @@ -435,6 +433,14 @@ Global {D6CEB142-BF8E-471C-AE16-4300F2D5DEDA}.Debug|Win32.Build.0 = Debug|Win32 {D6CEB142-BF8E-471C-AE16-4300F2D5DEDA}.Release|Win32.ActiveCfg = Release|Win32 {D6CEB142-BF8E-471C-AE16-4300F2D5DEDA}.Release|Win32.Build.0 = Release|Win32 + {0DEA7FAC-4190-4B39-BEF0-1C055758FED3}.Debug|Win32.ActiveCfg = Debug|Win32 + {0DEA7FAC-4190-4B39-BEF0-1C055758FED3}.Debug|Win32.Build.0 = Debug|Win32 + {0DEA7FAC-4190-4B39-BEF0-1C055758FED3}.Release|Win32.ActiveCfg = Release|Win32 + {0DEA7FAC-4190-4B39-BEF0-1C055758FED3}.Release|Win32.Build.0 = Release|Win32 + {8C103DE9-BC35-4173-A08D-63906EC5EEFD}.Debug|Win32.ActiveCfg = Debug|Win32 + {8C103DE9-BC35-4173-A08D-63906EC5EEFD}.Debug|Win32.Build.0 = Debug|Win32 + {8C103DE9-BC35-4173-A08D-63906EC5EEFD}.Release|Win32.ActiveCfg = Release|Win32 + {8C103DE9-BC35-4173-A08D-63906EC5EEFD}.Release|Win32.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/lib/sfdpgen/sfdp.vcproj b/lib/sfdpgen/sfdp.vcproj index 3802665a9..1f13e1405 100644 --- a/lib/sfdpgen/sfdp.vcproj +++ b/lib/sfdpgen/sfdp.vcproj @@ -39,7 +39,7 @@ True + + + + True + False + 0 + + + + 46 + True + + + + 66 + 16 + True + Graph Array + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 5 + 27 + + + + + 0 + False + False + + + + + + True + False + 0 + + + + + + + + True + True + Activate + True + GTK_RELIEF_NORMAL + True + + + + 0 + False + False + + + + + + True + True + Remove + True + GTK_RELIEF_NORMAL + True + + + 0 + False + False + + + + + 0 + True + True + + + + + 0 + True + True + + 0 -- 2.40.0