From: erg Date: Thu, 9 Sep 2010 18:00:21 +0000 (+0000) Subject: Fix commit of older versions X-Git-Tag: LAST_LIBGRAPH~32^2~1191 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7bfe3c0d255829ff9a837ff85e3c14dd63636771;p=graphviz Fix commit of older versions --- diff --git a/cmd/smyrna/gui/frmobjectui.c b/cmd/smyrna/gui/frmobjectui.c index 91b52fb88..ae81f5d85 100644 --- a/cmd/smyrna/gui/frmobjectui.c +++ b/cmd/smyrna/gui/frmobjectui.c @@ -842,697 +842,3 @@ _BB void on_attrSearchBtn_clicked(GtkWidget * widget, gpointer user_data) } - - -#if 0 - -static char guibuffer[BUFSIZ]; //general purpose buffer - -#ifdef WIN32 -extern int STRCASECMP(const char *s1, const char *s2); -extern int strncasecmp(const char *s1, const char *s2, unsigned int n); -#endif - -GdkWindow *window1; -GtkWidget *statusbar1; - -GladeXML *xml; //global libglade vars -GtkWidget *gladewidget; - -//1 subgraph 2 node 3 edge -int frmObjectTypeIndex; -Agraph_t *frmObjectg; - - -GtkComboBox *cbSelectGraph; //combo at top left - -GtkWidget *AttrWidgets[MAXIMUM_WIDGET_COUNT]; -GtkWidget *AttrLabels[MAXIMUM_WIDGET_COUNT]; -int attr_widgets_modified[MAXIMUM_WIDGET_COUNT]; -int widgetcounter; //number of attributes counted dynamically, might be removed in the future -attribute attr[MAXIMUM_WIDGET_COUNT]; - - - -//loads object properties form and does some fixes -//call this function only ones -void create_object_properties() -{ -#ifdef UNUSED - char *data0 = "TEST0"; - char *data1 = "TEST1"; - char *data2 = "TEST2"; - char *data3 = "TEST3"; - char *data4 = "TEST4"; -#endif - GladeXML *xml; - GtkWidget *widget; - xml = glade_xml_new(smyrnaGlade, NULL, NULL); - - widget = glade_xml_get_widget(xml, "listPoints"); - gtk_clist_set_column_title((GtkCList *) widget, 0, "Def"); - gtk_clist_set_column_title((GtkCList *) widget, 1, "x"); - gtk_clist_set_column_title((GtkCList *) widget, 2, "y"); - gtk_clist_set_column_title((GtkCList *) widget, 3, "z"); - gtk_clist_column_titles_show((GtkCList *) widget); - gtk_widget_show(widget); - widget = glade_xml_get_widget(xml, "win"); - gtk_widget_show(widget); - - -} - -//call this after create_object_properties() -void object_properties_node_init() -{ - -} -void object_properties_edge_init() //customize window for Edges -{ -} -void object_properties_cluster_init() //customize window for Cluster -{ - -} -void object_properties_graph_init() //customize window for Graph , this shows the graph default values -{ - -} - - -void graph_properties_init(int newgraph) //initialize little open graph dialog -{ - //newgraph 0 : open graph mode - //newgraph 1 : new graph mode - - - gint result = 0; - xml = glade_xml_new(smyrnaGlade, NULL, NULL); - gladewidget = glade_xml_get_widget(xml, "entryGraphFileName"); - - //signals - //OK - gladewidget = glade_xml_get_widget(xml, "btnOK"); - - - g_signal_connect((gpointer) gladewidget, "clicked", - G_CALLBACK(dlgOpenGraph_OK_Clicked), &newgraph); - - - - if (newgraph) { - gladewidget = glade_xml_get_widget(xml, "entryGraphName"); - gtk_entry_set_text((GtkEntry *) gladewidget, "Untitled"); - gladewidget = glade_xml_get_widget(xml, "entryGraphFileName"); - gtk_entry_set_text((GtkEntry *) gladewidget, "Untitled.dot"); - } else { - gladewidget = glade_xml_get_widget(xml, "entryGraphName"); - gtk_entry_set_text((GtkEntry *) gladewidget, ""); - gladewidget = glade_xml_get_widget(xml, "entryGraphFileName"); - gtk_entry_set_text((GtkEntry *) gladewidget, ""); - } - gladewidget = glade_xml_get_widget(xml, "dlgOpenGraph"); - result = gtk_dialog_run(GTK_DIALOG(gladewidget)); -} - -GtkComboBox *get_SelectGraph() -{ - GtkComboBox *cb; - if (!cbSelectGraph) { - - cb = (GtkComboBox *) gtk_combo_box_new_text(); - gtk_widget_show((GtkWidget *) cb); - gladewidget = glade_xml_get_widget(xml, "layout6"); - gtk_box_pack_start(GTK_BOX(gladewidget), (GtkWidget *) cb, FALSE, - FALSE, 0); - - - gtk_layout_put((GtkLayout *) gladewidget, (GtkWidget *) cb, 780, - 3); - //signal - g_signal_connect((gpointer) cb, "changed", - G_CALLBACK(graph_select_change), NULL); - - - return cb; - } else - return cbSelectGraph; -} - - -void Color_Widget_bg(char *colorstring, GtkWidget * widget) -{ - GdkColor color; - gdk_color_parse(colorstring, &color); - gtk_widget_modify_bg(widget, GTK_STATE_NORMAL, &color); - gtk_widget_modify_base(widget, GTK_STATE_NORMAL, &color); -} - - -#if 0 -void Color_Widget_fg(int r, int g, int b, GtkWidget * widget) -{ - GdkColor color; - gdk_color_parse("red", &color); - gtk_widget_modify_fg(widget, GTK_STATE_NORMAL, &color); - -} -#endif - -void load_graph_properties(Agraph_t * graph) -{ - //dlgOpenGraph , GtkDialog - gtk_entry_set_text((GtkEntry *) - glade_xml_get_widget(xml, "entryGraphName"), - GD_GraphName(graph)); - gtk_entry_set_text((GtkEntry *) - glade_xml_get_widget(xml, "entryGraphFileName"), - GD_GraphFileName(graph)); - gtk_combo_box_set_active((GtkComboBox *) - glade_xml_get_widget(xml, "cbLayout"), - GD_Engine(graph)); - gtk_toggle_button_set_active((GtkToggleButton *) - glade_xml_get_widget(xml, "chkVisible"), - GD_AlwaysShow(graph)); - gtk_toggle_button_set_active((GtkToggleButton *) - glade_xml_get_widget(xml, "chkLocked"), - GD_Locked(graph)); - gtk_toggle_button_set_active((GtkToggleButton *) - glade_xml_get_widget(xml, "chkTopView"), - GD_TopView(graph)); -} - -int update_graph_properties(Agraph_t * graph) //updates graph from gui -{ - FILE *file; - int respond = 0; - int id = 0; - //check the graph name should not be duplicated graph names - for (id = 0; id < view->graphCount; id++) { - if (graph != view->g[id]) { - if (STRCASECMP - (gtk_entry_get_text - ((GtkEntry *) - glade_xml_get_widget(xml, "entryGraphName")), - GD_GraphName(view->g[id])) == 0) { - Dlg = - (GtkMessageDialog *) gtk_message_dialog_new(NULL, - GTK_DIALOG_MODAL, - GTK_MESSAGE_WARNING, - GTK_BUTTONS_OK, - "There is another graph with this name!"); - respond = gtk_dialog_run((GtkDialog *) Dlg); - gtk_object_destroy((GtkObject *) Dlg); - return 0; - - } - - } - } - - //check if file is changed - if (STRCASECMP - (gtk_entry_get_text - ((GtkEntry *) glade_xml_get_widget(xml, "entryGraphFileName")), - GD_GraphFileName(graph)) != 0) { - - - if ((file = fopen(gtk_entry_get_text((GtkEntry *) - glade_xml_get_widget(xml, - "entryGraphFileName")), - "r"))) { - fclose(file); - Dlg = (GtkMessageDialog *) gtk_message_dialog_new(NULL, - GTK_DIALOG_MODAL, - GTK_MESSAGE_QUESTION, - GTK_BUTTONS_YES_NO, - "File name you have entered already exists\n,this will cause overwriting on existing file.\nAre you sure?"); - respond = gtk_dialog_run((GtkDialog *) Dlg); - gtk_object_destroy((GtkObject *) Dlg); - - if (respond == GTK_RESPONSE_NO) - return 0; - } - //now check if filename is legal, try to open it to write - if ((file = fopen(gtk_entry_get_text((GtkEntry *) - glade_xml_get_widget(xml, - "entryGraphFileName")), - "w"))) - fclose(file); - else { - Dlg = (GtkMessageDialog *) gtk_message_dialog_new(NULL, - GTK_DIALOG_MODAL, - GTK_MESSAGE_WARNING, - GTK_BUTTONS_OK, - "File name is invalid or I/O error!"); - - respond = gtk_dialog_run((GtkDialog *) Dlg); - gtk_object_destroy((GtkObject *) Dlg); - GTK_DIALOG(Dlg); - - return 0; - } - - } - - //if it comes so far graph deserves new values - - GD_GraphName(graph) = (char *) gtk_entry_get_text((GtkEntry *) - glade_xml_get_widget - (xml, - "entryGraphName")); - GD_GraphFileName(graph) = (char *) gtk_entry_get_text((GtkEntry *) - glade_xml_get_widget - (xml, - "entryGraphFileName")); - - GD_AlwaysShow(graph) = gtk_toggle_button_get_active((GtkToggleButton *) - glade_xml_get_widget - (xml, - "chkVisible")); - GD_Locked(graph) = gtk_toggle_button_get_active((GtkToggleButton *) - glade_xml_get_widget - (xml, "chkLocked")); - GD_TopView(graph) = gtk_toggle_button_get_active((GtkToggleButton *) - glade_xml_get_widget - (xml, "chkTopView")); - - - //check if the engine has been changed, if so do new layout - if (GD_Engine(graph) != gtk_combo_box_get_active((GtkComboBox *) - glade_xml_get_widget - (xml, "cbLayout"))) { - Dlg = - (GtkMessageDialog *) gtk_message_dialog_new(NULL, - GTK_DIALOG_MODAL, - GTK_MESSAGE_QUESTION, - GTK_BUTTONS_YES_NO, - "You have changed the layout of the graph,this will change the graph layout\n all your position changes will be lost\n Are you sure?"); - respond = gtk_dialog_run((GtkDialog *) Dlg); - if (respond == GTK_RESPONSE_YES) - do_graph_layout(graph, gtk_combo_box_get_active((GtkComboBox *) - glade_xml_get_widget - (xml, - "cbLayout")), - 0); - gtk_object_destroy((GtkObject *) Dlg); - } - return 1; -} - - - -int load_object_properties(gve_element typeIndex, Agraph_t * g) //load from object to gui; -{ - //load attr from first selected object - GtkLayout *layout; - GdkColor color; - char buf[BUFSIZ]; - /* int ind=0; */ - int Y = 45; - int X = 90; - int Yinc = 25; - /* int Xinc=30; */ - /* int OriginalX= 90; */ - int OriginalY = 45; - int widget_per_page = 21; - void *obj; - char line[BUFSIZ]; - float a, b; - layout = (GtkLayout *) glade_xml_get_widget(xml, "layout4"); - frmObjectTypeIndex = typeIndex; - frmObjectg = g; - widgetcounter = 0; - //values should be set from first selected object - //according to object type (typeIndex) set the reference object - switch (typeIndex) //typeindex 0 means new object - { - case GVE_CLUSTER: //graph sub graph (cluster) - obj = GD_selectedGraphs(g)[0]; - break; - case GVE_NODE: //Node - obj = GD_selectedNodes(g)[0]; - break; - case GVE_EDGE: //Edge - obj = GD_selectedEdges(g)[0]; - break; - default: - break; - } - for (widgetcounter = 0; widgetcounter < MAXIMUM_WIDGET_COUNT; - widgetcounter++) { - //create the labels and widget here - attr[widgetcounter].ComboValuesCount = 0; - attr[widgetcounter].ComboValues = '\0'; - - if (!AttrWidgets[widgetcounter]) { - AttrLabels[widgetcounter] = - gtk_label_new(attr[widgetcounter].Name); - switch (attr[widgetcounter].Type) { - case 'F': //float - AttrWidgets[widgetcounter] = - gtk_spin_button_new_with_range(0, 100, 0.001); - g_signal_connect((gpointer) AttrWidgets[widgetcounter], - "value-changed", - G_CALLBACK(attr_widgets_modifiedSlot), - (gpointer) widgetcounter); - - break; - case 'C': //color box - AttrWidgets[widgetcounter] = gtk_color_button_new(); - gtk_widget_set_size_request(AttrWidgets[widgetcounter], 50, - 23); - g_signal_connect((gpointer) AttrWidgets[widgetcounter], - "color-set", - G_CALLBACK(attr_widgets_modifiedSlot), - (gpointer) widgetcounter); - - break; - default: //alphanumreric GTK Entry - AttrWidgets[widgetcounter] = gtk_entry_new(); - gtk_widget_set_size_request(AttrWidgets[widgetcounter], - 130, 23); - g_signal_connect((gpointer) AttrWidgets[widgetcounter], - "changed", - G_CALLBACK(attr_widgets_modifiedSlot), - (gpointer) widgetcounter); - break; - } - attr[widgetcounter].attrWidget = AttrWidgets[widgetcounter]; - } - //locate widget on the GtkLayout* layout - if (attr[widgetcounter].ApplyTo[typeIndex] == 1) { - gtk_layout_put(layout, AttrWidgets[widgetcounter], X, Y); - gtk_layout_put(layout, AttrLabels[widgetcounter], X - 80, Y); - gtk_widget_show(AttrWidgets[widgetcounter]); - gtk_widget_show(AttrLabels[widgetcounter]); - Y = Y + Yinc; - switch (attr[widgetcounter].Type) { - case 'F': - if (agget(obj, attr[widgetcounter].Name)) - gtk_spin_button_set_value((GtkSpinButton *) - AttrWidgets[widgetcounter], - atof(agget - (obj, - attr[widgetcounter]. - Name))); - else - gtk_spin_button_set_value((GtkSpinButton *) - AttrWidgets[widgetcounter], - atof(attr[widgetcounter]. - Default)); - break; - case 'C': - if (agget(obj, attr[widgetcounter].Name)) - setGdkColor(&color, - agget(obj, attr[widgetcounter].Name)); - else - setGdkColor(&color, attr[widgetcounter].Default); - - gtk_color_button_set_color((GtkColorButton *) - AttrWidgets[widgetcounter], - &color); - break; - default: - if (agget(obj, attr[widgetcounter].Name)) - gtk_entry_set_text((GtkEntry *) - AttrWidgets[widgetcounter], - agget(obj, - attr[widgetcounter].Name)); - else - gtk_entry_set_text((GtkEntry *) - AttrWidgets[widgetcounter], - attr[widgetcounter].Default); - } - gtk_widget_show(AttrWidgets[widgetcounter]); - gtk_widget_show(AttrLabels[widgetcounter]); - } else { - gtk_widget_hide(AttrWidgets[widgetcounter]); - gtk_widget_hide(AttrLabels[widgetcounter]); - } - if (Y > widget_per_page * Yinc) { - X = 320; - Y = OriginalY; - } - attr_widgets_modified[widgetcounter] = 0; //set to unmodified - } - - - //first part, common attributes - sprintf(buf, "%i", OD_ID(obj)); - gtk_entry_set_text((GtkEntry *) - glade_xml_get_widget(xml, "objEntryName"), - OD_ObjName(obj)); - gtk_entry_set_text((GtkEntry *) - glade_xml_get_widget(xml, "objEntryLabel"), - agnameof(obj)); - gtk_toggle_button_set_active((GtkToggleButton *) - glade_xml_get_widget(xml, - "frmObjectchkVisible"), - OD_Visible(obj)); - gtk_toggle_button_set_active((GtkToggleButton *) - glade_xml_get_widget(xml, - "frmObjectchkLocked"), - OD_Locked(obj)); - gtk_toggle_button_set_active((GtkToggleButton *) - glade_xml_get_widget(xml, - "frmObjectchkHighlighted"), - OD_Highlighted(obj)); - //get the position info // show only one item is selected - if (((GD_selectedNodesCount(g) == 1) && (typeIndex == GVE_NODE)) - || ((GD_selectedEdgesCount(g) == 1) && (typeIndex == GVE_EDGE)) - || ((GD_selectedGraphsCount(g) == 1) && (typeIndex == GVE_EDGE))) { - sprintf(line, "%s", agget(obj, "pos")); - a = (float) atof(strtok(line, ",")); - b = (float) atof(strtok(NULL, ",")); - gtk_spin_button_set_value((GtkSpinButton *) - glade_xml_get_widget(xml, - "frmObjectPosX"), - a); - gtk_spin_button_set_value((GtkSpinButton *) - glade_xml_get_widget(xml, - "frmObjectPosY"), - b); - gtk_spin_button_set_value((GtkSpinButton *) - glade_xml_get_widget(xml, - "frmObjectPosZ"), - 0); - gtk_widget_show(glade_xml_get_widget(xml, "frmObjectPosX")); - gtk_widget_show(glade_xml_get_widget(xml, "frmObjectPosY")); - gtk_widget_show(glade_xml_get_widget(xml, "frmObjectPosZ")); - gtk_widget_show(glade_xml_get_widget(xml, "frmObjectlabel3")); - gtk_label_set_text((GtkLabel *) - glade_xml_get_widget(xml, "frmObjectPosLabelX"), - "X:"); - } else { - gtk_widget_hide(glade_xml_get_widget(xml, "frmObjectPosX")); - gtk_widget_hide(glade_xml_get_widget(xml, "frmObjectPosY")); - gtk_widget_hide(glade_xml_get_widget(xml, "frmObjectPosZ")); - gtk_widget_hide(glade_xml_get_widget(xml, "frmObjectlabel3")); - gtk_widget_hide(glade_xml_get_widget(xml, "frmObjectPosLabelY")); - gtk_widget_hide(glade_xml_get_widget(xml, "frmObjectPosLabelZ")); - switch (typeIndex) //typeindex 0 means new object - { - case GVE_CLUSTER: //graph sub graph (cluster) - gtk_label_set_text((GtkLabel *) - glade_xml_get_widget(xml, - "frmObjectPosLabelX"), - "Changes that you make will be applied to all selected clusters"); - break; - case GVE_NODE: //Node - gtk_label_set_text((GtkLabel *) - glade_xml_get_widget(xml, - "frmObjectPosLabelX"), - "Changes that you make will be applied to all selected nodes!"); - break; - case GVE_EDGE: //Edge - gtk_label_set_text((GtkLabel *) - glade_xml_get_widget(xml, - "frmObjectPosLabelX"), - "Changes that you make will be applied to all selected edges!"); - break; - default: - break; - } - } - return 1; -} -void update_object_properties(int typeIndex, Agraph_t * g) //updates objects from gui(node ,edge, cluster) -{ - int ind = 0; - for (ind = 0; ind < widgetcounter; ind++) { - //if widget has been changed - if (attr_widgets_modified[ind] == 1) { - switch (typeIndex) //typeindex 0 means new object - { - case GVE_CLUSTER: //graph sub graph (cluster) - change_selected_graph_attributes(g, attr[ind].Name, - get_attribute_string_value_from_widget - (&attr[ind])); - break; - case GVE_NODE: //Node - change_selected_node_attributes(g, attr[ind].Name, - get_attribute_string_value_from_widget - (&attr[ind])); - break; - case GVE_EDGE: //Edge - change_selected_edge_attributes(g, attr[ind].Name, - get_attribute_string_value_from_widget - (&attr[ind])); - break; - } - } - - } -} -char *get_attribute_string_value_from_widget(attribute * att) -{ - GdkColor color; - switch (att->Type) { - case 'F': - sprintf(guibuffer, "%f", - gtk_spin_button_get_value((GtkSpinButton *) att-> - attrWidget)); - return guibuffer; - break; - case 'C': - gtk_color_button_get_color((GtkColorButton *) att->attrWidget, - &color); - sprintf(guibuffer, "#%x%x%x", color.red / 255, color.green / 255, - color.blue / 255); - return guibuffer; - break; - default: - strcpy(guibuffer, - gtk_entry_get_text((GtkEntry *) att->attrWidget)); - return guibuffer; - } -} -void change_selected_graph_attributes(Agraph_t * g, char *attrname, - char *attrvalue) -{ - int ind = 0; - agattr(g, AGRAPH, attrname, ""); - - for (ind = 0; ind < GD_selectedGraphsCount(g); ind++) { - agset(GD_selectedGraphs(g)[ind], attrname, attrvalue); - } - - -} -void change_selected_node_attributes(Agraph_t * g, char *attrname, - char *attrvalue) -{ - int ind = 0; - agattr(g, AGNODE, attrname, ""); - - for (ind = 0; ind < GD_selectedNodesCount(g); ind++) { - agset(GD_selectedNodes(g)[ind], attrname, attrvalue); - } -} -void change_selected_edge_attributes(Agraph_t * g, char *attrname, - char *attrvalue) -{ - int ind = 0; - agattr(g, AGEDGE, attrname, ""); - - for (ind = 0; ind < GD_selectedEdgesCount(g); ind++) { - agset(GD_selectedEdges(g)[ind], attrname, attrvalue); - - } -} - -void load_attributes() -{ - FILE *file; - char line[BUFSIZ]; - char *ss; - char *pch; - int ind = 0; - int attrcount = 0; - static char *smyrna_attrs; - - if (!smyrna_attrs) { -#if WIN32 - smyrna_attrs = SMYRNA_ATTRS; -#else - smyrna_attrs = smyrnaPath("attrs.txt"); -#endif - } - //loads attributes from a text file - file = fopen(smyrna_attrs, "r"); - if (file != NULL) { - while (fgets(line, sizeof line, file) != NULL) { - pch = strtok(line, ","); - ind = 0; - while (pch != NULL) { - ss = safestrdup(pch); -// ABRemove(&ss,'\"'); -// ABRemove(&ss,' '); - pch = strtok(NULL, ","); - switch (ind) { - case 0: - attr[attrcount].Type = ss[0]; - break; - case 1: - attr[attrcount].Name = safestrdup(ss); - break; - case 2: - attr[attrcount].Default = safestrdup(ss); - break; - case 3: - if (strstr(ss, "ANY_ELEMENT")) { - attr[attrcount].ApplyTo[GVE_GRAPH] = 1; - attr[attrcount].ApplyTo[GVE_CLUSTER] = 1; - attr[attrcount].ApplyTo[GVE_NODE] = 1; - attr[attrcount].ApplyTo[GVE_EDGE] = 1; - } else { - attr[attrcount].ApplyTo[GVE_GRAPH] = - strstr(ss, "GRAPH") ? 1 : 0; - attr[attrcount].ApplyTo[GVE_CLUSTER] = - strstr(ss, "CLUSTER") ? 1 : 0; - attr[attrcount].ApplyTo[GVE_NODE] = - strstr(ss, "NODE") ? 1 : 0; - attr[attrcount].ApplyTo[GVE_EDGE] = - strstr(ss, "EDGE") ? 1 : 0; - } - break; - case 4: - if (strstr(ss, "ALL_ENGINES")) { - attr[attrcount].Engine[GVK_DOT] = 1; - attr[attrcount].Engine[GVK_NEATO] = 1; - attr[attrcount].Engine[GVK_TWOPI] = 1; - attr[attrcount].Engine[GVK_CIRCO] = 1; - attr[attrcount].Engine[GVK_FDP] = 1; - } else { - attr[attrcount].Engine[GVK_DOT] = - strstr(ss, "DOT") ? 1 : 0; - attr[attrcount].Engine[GVK_NEATO] = - strstr(ss, "NEATO") ? 1 : 0; - attr[attrcount].Engine[GVK_TWOPI] = - strstr(ss, "TWOPI") ? 1 : 0; - attr[attrcount].Engine[GVK_CIRCO] = - strstr(ss, "CIRCO") ? 1 : 0; - attr[attrcount].Engine[GVK_FDP] = - strstr(ss, "FDP") ? 1 : 0; - } - break; - default: - attr[attrcount].ComboValues = - RALLOC(attr[attrcount].ComboValuesCount, - attr[attrcount].ComboValues, char *); - attr[attrcount].ComboValues[attr[attrcount]. - ComboValuesCount] = - safestrdup(ss); - attr[attrcount].ComboValuesCount++; - break; - } - ind++; - } - attrcount++; - } - fclose(file); - } -} - -#endif diff --git a/cmd/smyrna/gui/topviewsettings.c b/cmd/smyrna/gui/topviewsettings.c index 78dd3d0d0..cc8bf45f2 100644 --- a/cmd/smyrna/gui/topviewsettings.c +++ b/cmd/smyrna/gui/topviewsettings.c @@ -40,9 +40,11 @@ void on_settingsApplyBtn_clicked(GtkWidget * widget, gpointer user_data) { 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, 0); -/* settvcolorinfo(view->g[view->activeGraph],view->Topview); - init_node_size(view->g[view->activeGraph])*/ +#if 0 + update_topview(view->g[view->activeGraph], view->Topview, 0); + settvcolorinfo(view->g[view->activeGraph],view->Topview); + init_node_size(view->g[view->activeGraph]); +#endif updateSmGraph(view->g[view->activeGraph],view->Topview); } void on_dlgSettings_close (GtkWidget * widget, gpointer user_data) @@ -303,8 +305,7 @@ 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))) - { + 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) diff --git a/cmd/smyrna/smyrnadefs.h b/cmd/smyrna/smyrnadefs.h index f0596308d..988b8839e 100644 --- a/cmd/smyrna/smyrnadefs.h +++ b/cmd/smyrna/smyrnadefs.h @@ -422,12 +422,14 @@ typedef struct Agsym_t* N_visible; Agsym_t* N_selected; Agsym_t* G_nodelabelcolor; + Agsym_t* GN_labelattribute; Agsym_t* N_labelattribute; Agsym_t* E_visible; Agsym_t* E_selected; Agsym_t* E_pos; Agsym_t* G_edgelabelcolor; Agsym_t* E_labelattribute; + Agsym_t* GE_labelattribute; } graphRec; #define GREC(g) ((graphRec*)(AGDATA(g))) #define GN_pos(g) (GREC(g)->N_pos) @@ -436,11 +438,13 @@ typedef struct #define GN_selected(g) (GREC(g)->N_selected) #define GG_nodelabelcolor(g) (GREC(g)->G_nodelabelcolor) #define GN_labelattribute(g) (GREC(g)->N_labelattribute) +#define GG_labelattribute(g) (GREC(g)->GN_labelattribute) #define GE_pos(g) (GREC(g)->E_pos) #define GE_visible(g) (GREC(g)->E_visible) #define GE_selected(g) (GREC(g)->E_selected) #define GG_edgelabelcolor(g) (GREC(g)->G_edgelabelcolor) #define GE_labelattribute(g) (GREC(g)->E_labelattribute) +#define GG_elabelattribute(g) (GREC(g)->GE_labelattribute) #define GUI_WINDOWED 0 #define GUI_FULLSCREEN 1 diff --git a/cmd/smyrna/topviewfuncs.c b/cmd/smyrna/topviewfuncs.c index 1b4b77b4f..976a14a5c 100644 --- a/cmd/smyrna/topviewfuncs.c +++ b/cmd/smyrna/topviewfuncs.c @@ -263,10 +263,29 @@ static void draw_edge(glCompPoint* posT,glCompPoint* posH, GLfloat length,int de } } + +static char* labelOf (Agraph_t* g, Agnode_t* v) +{ + char* lbl; + char* s; + + Agsym_t* data_attr = GN_labelattribute(g); + if (data_attr) + s = agxget (v, data_attr); + else + s = agxget (g, GG_labelattribute(g)); + if ((*s == '\0') || !strcmp (s, "name")) + lbl = agnameof (v); + else { + lbl = agget (v, s); + if (!lbl) lbl = ""; + } + return lbl; +} + static void renderSelectedNodes(Agraph_t * g) { Agnode_t *v; - Agsym_t* data_attr = GN_labelattribute(g); xdot * x; glCompPoint pos; Agsym_t* l_color_attr = GG_nodelabelcolor(g); @@ -311,11 +330,9 @@ static void renderSelectedNodes(Agraph_t * g) continue; if (ND_printLabel(v)==1) { + pos = ND_A(v); glColor4f(c.R, c.G,c.B, c.A); - if(!data_attr) - glprintfglut(view->glutfont,pos.x,pos.y,pos.z+0.002,agnameof(v)); - else - glprintfglut(view->glutfont,pos.x,pos.y,pos.z+0.002,agxget(v,data_attr)); + glprintfglut(view->glutfont,pos.x,pos.y,pos.z+0.002,labelOf(g,v)); } } } diff --git a/cmd/smyrna/viewport.c b/cmd/smyrna/viewport.c index 3f13027ad..d4aeeba0f 100755 --- a/cmd/smyrna/viewport.c +++ b/cmd/smyrna/viewport.c @@ -651,10 +651,12 @@ void updateRecord (Agraph_t* g) 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, "nodelabelattribute", 0); GE_pos(g)=agattr(g,AGEDGE,"pos",0); GE_visible(g) = agattr (g, AGEDGE, "visible", 0); GE_selected(g) = agattr (g, AGEDGE, "selected", 0); + GE_labelattribute(g) = agattr (g, AGEDGE, "edgelabelattribute", 0); } /* graphRecord: @@ -672,11 +674,11 @@ graphRecord (Agraph_t* g) GG_nodelabelcolor(g) = agattr (g, AGRAPH, "nodelabelcolor", 0); GG_edgelabelcolor(g) = agattr (g, AGRAPH, "edgelabelcolor", 0); + GG_labelattribute(g) = agattr (g, AGRAPH, "nodelabelattribute", 0); + GG_elabelattribute(g) = agattr (g, AGRAPH, "edgelabelattribute", 0); GN_pos(g) = agattr (g, AGNODE, "pos", 0); - GN_labelattribute(g) = agattr (g, AGNODE, agget(g,"nodelabelattribute"), 0); - GE_labelattribute(g) = agattr (g, AGEDGE, agget(g,"edgelabelattribute"), 0); updateRecord (g); }