From: arif Date: Wed, 11 Nov 2009 18:43:28 +0000 (+0000) Subject: Smyrna X-Git-Tag: LAST_LIBGRAPH~32^2~1571 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2afb78bee29bf1324c676e3622c6f870d88da553;p=graphviz Smyrna 1.Regular Expression Search 2.Xue's object summary request 3.Warning clean up --- diff --git a/cmd/smyrna/gui/beacon.c b/cmd/smyrna/gui/beacon.c index 8f7cac6f9..e0579b59d 100644 --- a/cmd/smyrna/gui/beacon.c +++ b/cmd/smyrna/gui/beacon.c @@ -19,6 +19,9 @@ #include "gltemplate.h" #include "glutils.h" #include "toolboxcallbacks.h" +#include "sfstr.h" + +static void print_object(void* obj); static int remove_edge_from_pick_list(topview_edge * e) { @@ -52,6 +55,8 @@ static int add_edge_to_pick_list(topview_edge * e) sizeof(topview_edge *) * view->Topview->picked_edge_count); view->Topview->picked_edges[view->Topview->picked_edge_count - 1] = e; select_edge(e); + print_object((void*) e->Edge); + return 1; } @@ -205,27 +210,60 @@ int remove_from_pick_list(topview_node * n) } return 0; } -static void print_node(topview_node * n) + +/* +You can then use sf as you would FILE* for writing, but using sfio functions. For example, + + sfprintf(sf, "", op); + +You can write to your heart's content; sfio will take care of memory. +When you are ready to use the +string, call + + char* ptr = sfstruse(sf); + +This adds a '\0'-byte at the end and returns a pointer to the beginning of the buffer. This also resets the write pointer, so you can use sf over again. Note, therefore, that this means you don't want to call sfstruse(sf) twice, as the second time will put a '\0' at the beginning of the buffer. + +Once you have ptr set, you can use it to insert the character string into the console window. + +To clean up, call + + sfclose (sf); + +This codes requires the vmalloc, ast, and sfio libraries, but these are already being loaded because gvpr needs them. +*/ + +static void print_object(void* obj) { + static Sfio_t *sf; int ind=0; char* val; + char* str; attr_list* l=view->Topview->attributes; - printf("Node Summary\n"); - printf("-------------\n"); - printf("name: %s\n",agnameof(n->Node)); + if (!sf) + sf= sfstropen(); + if(AGTYPE(obj)==AGNODE) + sfprintf(sf,"Node Summary\n"); + if(AGTYPE(obj)==AGEDGE) + sfprintf(sf,"Edge Summary\n"); + sfprintf(sf,"-------------\n"); + sfprintf(sf,"name: %s\n",agnameof(obj)); for (;ind < l->attr_count;ind ++) { if(l->attributes[ind]->propagate) { - val=agget(n->Node,l->attributes[ind]->name); + val=agget(obj,l->attributes[ind]->name); if (val) { - printf("%s:%s\n",l->attributes[ind]->name,val); + sfprintf(sf,"%s:%s\n",l->attributes[ind]->name,val); } } } - printf("-------------\n"); + sfprintf(sf,"-------------\n"); + str=sfstruse(sf); + append_textview((GtkTextView *)glade_xml_get_widget(xml, "mainconsole"), str, strlen(str)); + } @@ -237,8 +275,7 @@ int add_to_pick_list(topview_node * n) sizeof(topview_node *) * view->Topview->picked_node_count); view->Topview->picked_nodes[view->Topview->picked_node_count - 1] = n; select_node(n); - print_node( n); - + print_object((void*) n->Node); return 1; } diff --git a/cmd/smyrna/gui/frmobjectui.c b/cmd/smyrna/gui/frmobjectui.c index 5e13f3d6f..b061ecef0 100644 --- a/cmd/smyrna/gui/frmobjectui.c +++ b/cmd/smyrna/gui/frmobjectui.c @@ -27,6 +27,8 @@ #include "memory.h" #include "frmobjectui.h" #include +#include "sfstr.h" + #ifdef WIN32 #define STRCASECMP stricmp @@ -409,14 +411,17 @@ void filter_attributes(char* prefix,topview* t) gtk_widget_set_sensitive(glade_xml_get_widget(xml, "txtDefValue"),1); gtk_widget_show(glade_xml_get_widget(xml, "attrAddBtn")); gtk_widget_hide(glade_xml_get_widget(xml, "attrApplyBtn")); + gtk_widget_hide(glade_xml_get_widget(xml, "attrSearchBtn")); gtk_toggle_button_set_active ((GtkToggleButton*)glade_xml_get_widget(xml, "attrProg"),0); + if(strlen(prefix)==0) { gtk_widget_hide(glade_xml_get_widget(xml, "attrAddBtn")); gtk_widget_hide(glade_xml_get_widget(xml, "attrApplyBtn")); + gtk_widget_hide(glade_xml_get_widget(xml, "attrSearchBtn")); gtk_widget_hide(glade_xml_get_widget(xml, "attrAddBtn")); gtk_widget_hide(glade_xml_get_widget(xml, "txtValue")); gtk_widget_hide(glade_xml_get_widget(xml, "txtDefValue")); @@ -441,14 +446,15 @@ void filter_attributes(char* prefix,topview* t) gtk_widget_set_sensitive(glade_xml_get_widget(xml, "txtDefValue"),0); gtk_widget_hide(glade_xml_get_widget(xml, "attrAddBtn")); gtk_widget_show(glade_xml_get_widget(xml, "attrApplyBtn")); + gtk_widget_show(glade_xml_get_widget(xml, "attrSearchBtn")); gtk_toggle_button_set_active ((GtkToggleButton*)glade_xml_get_widget(xml, "attrProg"),fl->attributes[0]->propagate); break; } } - tmp=(((objKind==AGNODE) &&(sel_node)) || ((objKind==AGEDGE) &&(sel_edge)) || ((objKind==AGRAPH) &&(sel_graph))); - gtk_widget_set_sensitive(glade_xml_get_widget(xml, "txtValue"),tmp); + tmp=(((objKind==AGNODE) &&(sel_node)) ||((objKind==AGEDGE) &&(sel_edge))||((objKind==AGRAPH) &&(sel_graph))); + gtk_widget_set_sensitive(glade_xml_get_widget(xml, "attrApplyBtn"),tmp); } /*asttribute text changed call back*/ @@ -458,6 +464,7 @@ _BB void on_txtAttr_changed(GtkWidget * widget, gpointer user_data) filter_attributes((char*)gtk_entry_get_text((GtkEntry*)widget),view->Topview); } + _BB void on_attrApplyBtn_clicked (GtkWidget * widget, gpointer user_data) { int ind; @@ -686,33 +693,45 @@ attr_list* load_attr_list(Agraph_t* g) sym=NULL; while ((sym = agnxtattr(g,AGRAPH, sym))) { - if(!binarySearch( l, sym->name)) + attr=binarySearch(l, sym->name); + if (attr) + attr->objType[0]=1; + else { - attr=new_attr_with_ref(sym); - attr_list_add(l,attr); - + attr=new_attr_with_ref(sym); + attr_list_add(l,attr); } } sym=NULL; while ((sym = agnxtattr(g,AGNODE, sym))) { - if(!binarySearch(l, sym->name)) + + attr=binarySearch(l, sym->name); + if (attr) { - attr=new_attr_with_ref(sym); - attr_list_add(l,attr); + attr->objType[1]=1; } + else + { + attr=new_attr_with_ref(sym); + attr_list_add(l,attr); + } + } sym=NULL; while ((sym = agnxtattr(g,AGEDGE, sym))) { - if(!binarySearch(l, sym->name)) + + attr=binarySearch(l, sym->name); + if (attr) + attr->objType[2]=1; + else { - attr=new_attr_with_ref(sym); - attr_list_add(l,attr); + attr=new_attr_with_ref(sym); + attr_list_add(l,attr); } } - return l; } @@ -775,6 +794,51 @@ void showAttrsWidget(topview* t) } +static void gvpr_select(char* attr,char* regex_str,int objType) +{ + + static Sfio_t *sf; + char *bf2; + int i, j, argc; + char **argv; + + if (!sf) + sf= sfstropen(); + + if (objType==AGNODE) + sfprintf (sf,"N[%s==\"%s\"]{selected = \"1\"}",attr,regex_str); + if (objType==AGEDGE) + sfprintf (sf,"E[%s==\"%s\"]{selected = \"1\"}",attr,regex_str); + + + + bf2 =sfstruse(sf); + + argc = 1; + if (*bf2 != '\0') + argc++; + argv = N_NEW(argc + 1, char *); + j = 0; + argv[j++] = "smyrna"; + argv[j++] = strdup(bf2); + + run_gvpr(view->g[view->activeGraph], j, argv); + for (i = 1; i < argc; i++) + free(argv[i]); + free(argv); + set_header_text(); +} + + +_BB void on_attrSearchBtn_clicked (GtkWidget * widget, gpointer user_data) +{ + + char *attr=(char*)gtk_entry_get_text((GtkEntry*)glade_xml_get_widget(xml, "txtAttr")); + char* regex_str=(char*)gtk_entry_get_text((GtkEntry*)glade_xml_get_widget(xml, "txtValue")); + gvpr_select(attr,regex_str,get_object_type()); + +} + #if 0 diff --git a/cmd/smyrna/gui/frmobjectui.h b/cmd/smyrna/gui/frmobjectui.h index d775ba8bb..fedd720aa 100644 --- a/cmd/smyrna/gui/frmobjectui.h +++ b/cmd/smyrna/gui/frmobjectui.h @@ -39,6 +39,7 @@ _BB void on_txtAttr_changed(GtkWidget * widget, gpointer user_data); _BB void attr_label_motion(GtkWidget * widget,GdkEventMotion * event, gpointer data); _BB void on_attrApplyBtn_clicked (GtkWidget * widget, gpointer user_data); _BB void on_attrAddBtn_clicked (GtkWidget * widget, gpointer user_data); +_BB void on_attrSearchBtn_clicked (GtkWidget * widget, gpointer user_data); extern attr_list* load_attr_list(Agraph_t* g); extern void showAttrsWidget(topview* t); diff --git a/cmd/smyrna/gui/menucallbacks.c b/cmd/smyrna/gui/menucallbacks.c index 1ee4cab7e..171ee679e 100755 --- a/cmd/smyrna/gui/menucallbacks.c +++ b/cmd/smyrna/gui/menucallbacks.c @@ -496,6 +496,8 @@ static char **splitArgs(const char *args, int *argcp) } #endif + + void mTestgvpr(GtkWidget * widget, gpointer user_data) { char *bf2; @@ -561,6 +563,9 @@ void mTestgvpr(GtkWidget * widget, gpointer user_data) g_free(bf2); } assert(j == argc); + for (i = 0; i < j; i++) + printf("%s ",argv[i]); + run_gvpr(view->g[view->activeGraph], argc, argv); for (i = 1; i < argc; i++) diff --git a/share/gui/smyrna.glade b/share/gui/smyrna.glade index b7e64703b..176e821e4 100755 --- a/share/gui/smyrna.glade +++ b/share/gui/smyrna.glade @@ -29,242 +29,320 @@ 0 - + True - GTK_PACK_DIRECTION_LTR - GTK_PACK_DIRECTION_LTR + False + 0 - + + 540 True - _File - True + GTK_PACK_DIRECTION_LTR + GTK_PACK_DIRECTION_LTR - + + True + _File + True - - True - gtk-open - True - - - + - - - True - gtk-save - True - - - + + + True + gtk-open + True + + + - - - True - gtk-save-as - True - - - + + + True + gtk-save + True + + + - - - True - - + + + True + gtk-save-as + True + + + - - - True - gtk-quit - True - + + + True + + + + + + True + gtk-quit + True + + + - - - - - - True - _Edit - True - + + True + _Edit + True - - True - Smyrna Settings - True - - - + - - - True - Attributes - True - - - + + + True + Smyrna Settings + True + + + - - - True - Node List - True - + + + True + Attributes + True + + + + + + + True + Node List + True + + + - - - - - - True - _View - True - + + True + _View + True - - True - Show Console - True - - - + - - - True - Hide Console - True - + + + True + Show Console + True + + + + + + + True + Hide Console + True + + + - - - - - - True - Select - True - + + True + Select + True - - True - gtk-select-all - True - - - + - - - True - Unselect All - True - - - + + + True + gtk-select-all + True + + + - - - True - Select All Nodes - True - - - + + + True + Unselect All + True + + + - - - True - Select All Edges - True - - - + + + True + Select All Nodes + True + + + - - - True - Select All Clusters - True - - - + + + True + Select All Edges + True + + + - - - True - Unselect All Nodes - True - - - + + + True + Select All Clusters + True + + + - - - True - Unselect All Edges - True - + + + True + Unselect All Nodes + True + + + + + + + True + Unselect All Edges + True + + + + + + + True + Unselect All Clusters + True + + + + + + + + + True + _Help + True - - True - Unselect All Clusters - True - + + + + + True + gtk-about + True + + + + + 0 + False + True + + + + + + True + Active Graph: + False + False + GTK_JUSTIFY_RIGHT + False + False + 1 + 0.5 + 5 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + True + True + - + True - _Help + True + Remove True + GTK_RELIEF_NORMAL + True + + + 0 + False + False + GTK_PACK_END + + - - + + + - - - True - gtk-about - True - - - - - + + + True + True + Activate + True + GTK_RELIEF_NORMAL + True + + + 0 + False + False + GTK_PACK_END + @@ -832,36 +910,11 @@ - - True - True - Activate - True - GTK_RELIEF_NORMAL - True - - - - 0 - False - False - + - - True - True - Remove - True - GTK_RELIEF_NORMAL - True - - - 0 - False - False - + @@ -2513,7 +2566,7 @@ 5 - 462 + 676 505 GTK_WINDOW_TOPLEVEL @@ -2598,7 +2651,7 @@ True 400 400 - 0 0 444 0 399.6 444 + 0 0 658 0 592.2 658 0 0 425 0 382.5 425 @@ -3267,18 +3320,6 @@ Rain Forest 0 - - - - 51 - 25 - True - - - 293 - 14 - - False @@ -3315,7 +3356,7 @@ Rain Forest True 400 400 - 0 0 444 0 399.6 444 + 0 0 658 0 592.2 658 0 0 425 0 382.5 425 @@ -3825,7 +3866,7 @@ GLUT_BITMAP_HELVETICA_18 True 400 400 - 0 0 444 0 399.6 444 + 0 0 658 0 592.2 658 0 0 425 0 382.5 425 @@ -4204,7 +4245,7 @@ Custom True 400 400 - 0 0 444 0 399.6 444 + 0 0 658 0 592.2 658 0 0 425 0 382.5 425 @@ -4596,7 +4637,7 @@ Custom True 400 400 - 0 0 444 0 399.6 444 + 0 0 658 0 592.2 658 0 0 425 0 382.5 425 @@ -5202,7 +5243,7 @@ Custom True 400 400 - 0 0 444 0 399.6 444 + 0 0 658 0 592.2 658 0 0 425 0 382.5 425 @@ -5551,207 +5592,6 @@ Custom 381 True - - - 88 - 21 - True - True - True - True - 0 - - True - * - False - - - - 8 - 58 - - - - - - 88 - 21 - True - True - True - True - 0 - - True - * - False - - - 112 - 58 - - - - - - 88 - 21 - True - True - True - True - 0 - - True - * - False - - - 216 - 58 - - - - - - 96 - 16 - True - Attribute Name - False - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 8 - 40 - - - - - - 40 - 16 - True - Value - False - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 112 - 40 - - - - - - 88 - 16 - True - Default Value - False - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 216 - 40 - - - - - - 32 - 24 - True - True - + - True - GTK_RELIEF_NORMAL - True - - - - 384 - 56 - - - - - - 54 - 23 - True - True - Apply - True - GTK_RELIEF_NORMAL - True - - - - 368 - 56 - - - - - - 72 - 16 - True - Propagate - False - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 312 - 40 - - - 428 @@ -5828,23 +5668,296 @@ Custom - - 24 - 16 + + 562 + 68 True - True - - True - GTK_RELIEF_NORMAL - True - False - False - True - + 3 + 6 + False + 0 + 0 + + + + 88 + 21 + True + True + True + True + 0 + + True + * + False + + + + 0 + 1 + 1 + 2 + + + + + + + 88 + 21 + True + True + True + True + 0 + + True + * + False + + + 1 + 2 + 1 + 2 + + + + + + + 88 + 21 + True + True + True + True + 0 + + True + * + False + + + 2 + 3 + 1 + 2 + + + + + + + 40 + 16 + True + Value + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 1 + 2 + 0 + 1 + fill + + + + + + + 88 + 16 + True + Default Value + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 2 + 3 + 0 + 1 + fill + + + + + + + 96 + 16 + True + Attribute Name + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + 1 + 0 + 1 + fill + + + + + + + 72 + 16 + True + Publish + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 3 + 4 + 0 + 1 + fill + + + + + + + 24 + 16 + True + True + + True + GTK_RELIEF_NORMAL + True + False + False + True + + + + 3 + 4 + 1 + 2 + fill + + + + + + + 32 + 23 + True + True + + + True + GTK_RELIEF_NORMAL + True + + + + 5 + 6 + 1 + 2 + fill + + + + + + + True + True + Apply + True + GTK_RELIEF_NORMAL + True + + + + 4 + 5 + 1 + 2 + fill + + + + + + + True + True + Search + True + GTK_RELIEF_NORMAL + True + + + + 4 + 5 + 2 + 3 + fill + + + - 323 - 60 + 12 + 41