]> granicus.if.org Git - graphviz/commitdiff
smyrna selected node list
authorarif <devnull@localhost>
Thu, 11 Mar 2010 15:57:36 +0000 (15:57 +0000)
committerarif <devnull@localhost>
Thu, 11 Mar 2010 15:57:36 +0000 (15:57 +0000)
cmd/smyrna/gui/datalistcallbacks.c
cmd/smyrna/gui/glcompui.c
cmd/smyrna/gui/menucallbacks.c
cmd/smyrna/selectionfuncs.c
cmd/smyrna/topviewfuncs.c
cmd/smyrna/topviewfuncs.h
cmd/smyrna/tvnodes.c
cmd/smyrna/tvnodes.h
lib/glcomp/glcompfont.c

index 5439c9b03b152cb1d16b8f9a165e7ac2cb67b6f7..90461314eee199b8d1a7ee38c826e291be0a77b4 100755 (executable)
@@ -23,20 +23,6 @@ void btnTVEdit_clicked_cb(GtkWidget * widget, gpointer user_data)
 void btnTVDelete_clicked_cb(GtkWidget * widget, gpointer user_data)
 {
 }
-void btnTVFilter_clicked_cb(GtkWidget * widget, gpointer user_data)
-{
-    int respond;
-
-//      gtk_dialog_set_response_sensitive   (glade_xml_get_widget(xml, "dlgOpenGraph"),1,1);
-//      gtk_dialog_set_response_sensitive   (glade_xml_get_widget(xml, "dlgOpenGraph"),2,1);
-    respond = gtk_dialog_run((GtkDialog *)
-                            glade_xml_get_widget(xml, "dlgTVFilter"));
-//      respond=gtk_dialog_run (glade_xml_get_widget(xml, "dlgFilters"));
-    gtk_widget_hide(glade_xml_get_widget(xml, "dlgTVFilter"));
-    if (respond == 1)
-       apply_filter_from_gui();
-}
-
 void btnTVFirst_clicked_cb(GtkWidget * widget, gpointer user_data)
 {
     tv_nodes_first_page();
@@ -71,7 +57,6 @@ void btnTVCancel_clicked_cb(GtkWidget * widget, gpointer user_data)
 }
 void btnTVOK_clicked_cb(GtkWidget * widget, gpointer user_data)
 {
-    update_TV_data_from_gui();
     gtk_widget_hide(glade_xml_get_widget(xml, "frmTVNodes"));
 }
 
@@ -108,39 +93,6 @@ void btnTVFilterApply_clicked_cb(GtkWidget * widget, gpointer user_data)
 
 }
 
-void btnTVFilterClear_clicked_cb(GtkWidget * widget, gpointer user_data)
-{
-    gtk_entry_set_text((GtkEntry *)
-                      glade_xml_get_widget(xml, "edtTVFilterMinData1"),
-                      "");
-    gtk_entry_set_text((GtkEntry *)
-                      glade_xml_get_widget(xml, "edtTVFilterMaxData1"),
-                      "");
-    gtk_entry_set_text((GtkEntry *)
-                      glade_xml_get_widget(xml, "edtTVFilterMinData2"),
-                      "");
-    gtk_entry_set_text((GtkEntry *)
-                      glade_xml_get_widget(xml, "edtTVFilterMaxData2"),
-                      "");
-    gtk_entry_set_text((GtkEntry *)
-                      glade_xml_get_widget(xml, "edtTVFilterString"), "");
-
-
-    gtk_toggle_button_set_active((GtkToggleButton *)
-                                glade_xml_get_widget(xml,
-                                                     "rbTVFilterHigh1"),
-                                1);
-    gtk_toggle_button_set_active((GtkToggleButton *)
-                                glade_xml_get_widget(xml,
-                                                     "rbTVFilterSel1"),
-                                1);
-    gtk_toggle_button_set_active((GtkToggleButton *)
-                                glade_xml_get_widget(xml,
-                                                     "rbTVFilterVisible1"),
-                                1);
-    apply_filter_from_gui();
-}
-
 void btnTVSelectAll_clicked_cb(GtkWidget * widget, gpointer user_data)
 {
     tv_select_all();
index f2976e9057c4a55ae21f20fc513ccf8f4e036db8..cb2a6b7a0bc5f15ad67b864141bda558006057a7 100644 (file)
@@ -199,6 +199,7 @@ void selectnodes(glCompObj *obj, GLfloat x, GLfloat y)
     else
        view->Topview->sel.selectNodes=0;
 
+
 }
 
 
index b0ba4232213357a23e2c640102fbd22b51738947..535878ed0eb9faf0e6862b11bb2a612ec8ba6d91 100755 (executable)
@@ -189,8 +189,7 @@ void mHideConsoleSlot(GtkWidget * widget, gpointer user_data)
 void mNodeListSlot(GtkWidget * widget, gpointer user_data)
 {
     gtk_widget_show(glade_xml_get_widget(xml, "ListForm"));
-
-//    execute_tv_nodes();
+    execute_tv_nodes();
 }
 
 void mNewNodeSlot(GtkWidget * widget, gpointer user_data)
index bc19cd8f9567830eb17f15e1739418fe520edc5b..8d4e8a65e55cae9624f4e41c6604b457c699c83e 100644 (file)
@@ -91,7 +91,9 @@ static void pick_objects_in_rect(Agraph_t* g,GLfloat x1,GLfloat y1,GLfloat x2,GL
        if(view->Topview->sel.selectNodes==1)
        {
            posN=((nodeRec*)(aggetrec(v,"nodeRec",0)))->A;
-           if(is_point_in_rectangle(posN.x,posN.y,x1,y1,x2-x1,y2-y1))
+           if(!((nodeRec*)(aggetrec(v,"nodeRec",0)))->visible)
+               continue;
+           if(is_point_in_rectangle(posN.x,posN.y,x1,y1,x2-x1,y2-y1) )
                select_node(g,v,0);
        }
        if(view->Topview->sel.selectEdges==1)
@@ -134,6 +136,8 @@ static void* pick_object(Agraph_t* g,glCompPoint p)
 
     for (v = agfstnode(g); v; v = agnxtnode(g, v)) 
     {
+       if(!((nodeRec*)(aggetrec(v,"nodeRec",0)))->visible)
+           continue;
        posN=((nodeRec*)(aggetrec(v,"nodeRec",0)))->A;
        nodeSize=(GLfloat)l_float(v, size_attr,0);
        if (nodeSize > 0)
index 9b76b00f1b4bec25acb61379927096915bede65e..de354d01aade01e0bebb3113316524f4f6a7144c 100644 (file)
@@ -432,6 +432,12 @@ void renderEdges(Agraph_t * g)
     {
        for (e = agfstout(g, v); e; e = agnxtout(g, e)) 
        {
+           if(
+           (((nodeRec*)(aggetrec(agtail(e),"nodeRec",0)))->visible==0)
+                   ||
+           (((nodeRec*)(aggetrec(aghead(e),"nodeRec",0)))->visible==0))
+               continue;
+
            if(!object_color(e,&c))
            {
                ((edgeRec*)(aggetrec(e,"edgeRec",0)))->visible=0;
@@ -456,6 +462,12 @@ void renderEdges(Agraph_t * g)
     {
        for (e = agfstout(g, v); e; e = agnxtout(g, e)) 
        {
+           if(
+           (((nodeRec*)(aggetrec(agtail(e),"nodeRec",0)))->visible==0)
+                   ||
+           (((nodeRec*)(aggetrec(aghead(e),"nodeRec",0)))->visible==0))
+               continue;
+
            if(!object_color(e,&c))
                continue;
            if(((edgeRec*)(aggetrec(e,"edgeRec",0)))->selected)
index f2d3b7302621f307dde162dd81a9db1ea08b98ca..2996c41400a6570c7831eb5d70814d1803c6c4bb 100644 (file)
@@ -24,6 +24,7 @@ extern "C" {
 #endif
 extern void pick_object_xyz(Agraph_t* g,topview* t,GLfloat x,GLfloat y,GLfloat z) ;
 extern topview* initSmGraph(Agraph_t * g);
+extern void updateSmGraph(Agraph_t * g,topview* t);
 extern void renderSmGraph(Agraph_t * g,topview* t);
 extern void freeSmGraph(Agraph_t * g,topview* t);
 extern void cacheSelectedEdges(Agraph_t * g,topview* t);
index 02d2fda0449b9c591e373496583ae18b8eda3522..1637d758a8a4aa19cf9a624d06fc95a3b5f743f8 100755 (executable)
 #include "tvnodes.h"
 #include "btree.h"
 #include "viewport.h"
+#include "topviewfuncs.h"
 
 #include "memory.h"
 
-tv_nodes TV_Nodes;
-static char buf[255];
-int MP_Flag = 0;
-
-static
-void init_tv_nodes(tv_nodes * TV_Nodes)
+typedef struct{
+    GType type;
+    char* name;
+    int editable;
+}gridCol;
+typedef struct
 {
-    int i;
-    TV_Nodes->filtered = 0;
-    TV_Nodes->activepage = -1;
-    TV_Nodes->firstnodeid = 0;
-    TV_Nodes->pagecount = 0;
-    TV_Nodes->recordperpage = 22;
-    TV_Nodes->page_data_index = 0;
-    TV_Nodes->Y_Gap = 25;
-    TV_Nodes->Y = 12;
-    TV_Nodes->initial_Y = 12;
-    TV_Nodes->chkSelected_X = 5;
-    TV_Nodes->IDLabel_X = 10;
-    TV_Nodes->chkVisible_X = 55;
-    TV_Nodes->chkHighlighted_X = 85;
-    TV_Nodes->Data1_X = 105;
-    TV_Nodes->Data2_X = 305;
-    TV_Nodes->page_data_node_index = 0;
-    reset_page_History();
-
-    //null gui elemetns
-    for (i = 0; i < MAX_NODE_PER_PAGE; i++) {
-       TV_Nodes->TV_Node[i].chkHighlighted = NULL;
-       TV_Nodes->TV_Node[i].chkSelected = NULL;
-       TV_Nodes->TV_Node[i].chkVisible = NULL;
-       TV_Nodes->TV_Node[i].Name = NULL;
-       TV_Nodes->TV_Node[i].Data1 = NULL;
-       TV_Nodes->TV_Node[i].Data2 = NULL;
-       TV_Nodes->TV_Node[i].IDLabel = NULL;
-    }
-    TV_Nodes->initialized = 1;
-}
+    int count;
+    gridCol** columns;
+    GtkTreeStore *store;
 
-int
-set_filter(tv_filter * TV_Filter, char *MinData1, char *MaxData1,
-          char *MinData2, char *MaxData2, char *Filter_String,
-          int selected, int visible, int highlighted)
-{
-    TV_Filter->selected = selected;
-    TV_Filter->highlighted = highlighted;
-    TV_Filter->visible = visible;
-    TV_Filter->min_data1 = MinData1;
-    TV_Filter->max_data1 = MaxData1;
-    TV_Filter->min_data2 = MinData2;
-    TV_Filter->max_data2 = MaxData2;
-    TV_Filter->filter_string = Filter_String;
-    TV_Nodes.filtered = 1;
-    return 1;
-}
+}grid;
 
+/*
+       call this function to create a subgraph from filtered nodes and maybe edges
+*/
 
-static
-int validate_node(tv_node * TV_Node)
+int create_save_subgraph_from_filter(char *filename)
 {
-    /* static btree_node *n = 0; */
-    char *data_attr1;
-    char *data_attr2;
-//              n=tree_from_filter_string("([IP=\"^10.*\",min=\"0\",max=\"0\"])");
-    // get attributes from graph
-    data_attr1 = agget(view->g[view->activeGraph], "DataAttribute1");
-    data_attr2 = agget(view->g[view->activeGraph], "DataAttribute2");
-
-
-    if (TV_Nodes.filtered) {
-       int valid = 1;
-       if (TV_Nodes.filter.visible >= 0) {
-           if (view->Topview->Nodes[TV_Node->index].data.Visible !=
-               TV_Nodes.filter.visible)
-               valid = 0;
-       }
-       //if show only selected
-       if (TV_Nodes.filter.selected >= 0) {
-           if (view->Topview->Nodes[TV_Node->index].data.Selected !=
-               TV_Nodes.filter.selected)
-               valid = 0;
-       }
-       return valid;
-    } else
-       return 1;
-}
 
-static int update_node_gui_objects(tv_node * TV_Node)
-{
-    char *data_attr1;
-    char *data_attr2;
-    char buf[255];
-    GtkLayout *layout;
-
-    // get attributes from graph
-    data_attr1 = agget(view->g[view->activeGraph], "DataAttribute1");
-    data_attr2 = agget(view->g[view->activeGraph], "DataAttribute2");
-
-    //create if objects are null    
-    layout = (GtkLayout *) glade_xml_get_widget(xml, "layoutTVData");
-    //select box
-    if (!TV_Node->chkSelected) {
-       TV_Node->chkSelected = (GtkCheckButton *) gtk_check_button_new();
-       gtk_layout_put(layout, (GtkWidget *) TV_Node->chkSelected,
-                      LOCATION_X_CHKSELECTED, TV_Nodes.Y);
-    }
-    gtk_widget_show((GtkWidget *) TV_Node->chkSelected);
-    gtk_toggle_button_set_active((GtkToggleButton *) TV_Node->chkSelected,
-                                view->Topview->Nodes[TV_Node->index].data.
-                                Selected);
-
-    //Id Label
-    if (!TV_Node->IDLabel) {
-       TV_Node->IDLabel = (GtkLabel *) gtk_label_new("");
-       gtk_layout_put(layout, (GtkWidget *) TV_Node->IDLabel,
-                      LOCATION_X_IDLABEL, TV_Nodes.Y);
-    }
-    sprintf(buf, "%d", TV_Node->index);
-    gtk_label_set_text(TV_Node->IDLabel, buf);
-    gtk_widget_show((GtkWidget *) TV_Node->IDLabel);
-
-    //visible
-    if (!TV_Node->chkVisible) {
-       TV_Node->chkVisible = (GtkCheckButton *) gtk_check_button_new();
-       gtk_layout_put(layout, (GtkWidget *) TV_Node->chkVisible,
-                      LOCATION_X_CHKVISIBLE, TV_Nodes.Y);
+    int i = 0;
+    Agraph_t *subg = agsubg(view->g[view->activeGraph], "temp", 1);
+    FILE *outputfile;
+    for (i = 0; i < view->Topview->Nodecount; i++) {
+       if (view->Topview->Nodes[i].valid == 1) {
+           agsubnode(subg, view->Topview->Nodes[i].Node, 1);
+       }
     }
 
-    gtk_widget_show((GtkWidget *) TV_Node->chkVisible);
-    gtk_toggle_button_set_active((GtkToggleButton *) TV_Node->chkVisible,
-                                view->Topview->Nodes[TV_Node->index].data.
-                                Visible);
-    //highlighted
-    if (!TV_Node->chkHighlighted) {
-       TV_Node->chkHighlighted =
-           (GtkCheckButton *) gtk_check_button_new();
-       gtk_layout_put(layout, (GtkWidget *) TV_Node->chkHighlighted,
-                      LOCATION_X_CHKHIGHLIGHTED, TV_Nodes.Y);
+    if ((outputfile = fopen(filename, "w"))) {
+       int ret = agwrite(subg, outputfile);
+       fclose (outputfile);
+       if (ret) {
+           agdelsubg(view->g[view->activeGraph], subg);
+           return 1;
+       } else {
+           agdelsubg(view->g[view->activeGraph], subg);
+           return 0;
+       }
+    } else {
+       agdelsubg(view->g[view->activeGraph], subg);
+       return 0;
     }
-    gtk_widget_show((GtkWidget *) TV_Node->chkHighlighted);
 
 
-    //NAME
-    if (!TV_Node->Name) {
-       TV_Node->Name = (GtkEntry *) gtk_entry_new();
-       gtk_layout_put(layout, (GtkWidget *) TV_Node->Name,
-                      LOCATION_X_NAME, TV_Nodes.Y);
-       gtk_widget_set_size_request((GtkWidget *) TV_Node->Name, 75, 23);
+}
 
-    }
-    gtk_entry_set_text(TV_Node->Name,
-                      agnameof(view->Topview->Nodes[TV_Node->index].
-                               Node));
-    gtk_widget_show((GtkWidget *) TV_Node->Name);
-    //DATA 1
-    if (!TV_Node->Data1) {
-       TV_Node->Data1 = (GtkEntry *) gtk_entry_new();
-       gtk_layout_put(layout, (GtkWidget *) TV_Node->Data1,
-                      LOCATION_X_DATA1, TV_Nodes.Y);
-       gtk_widget_set_size_request((GtkWidget *) TV_Node->Data1, 200, 23);
 
+static void set_visibility(Agraph_t* g,int visibility)
+{
+
+    Agnode_t *v;
+    static char bf1[2];
+    static char* bf2;
+    static Agsym_t* visible_attr=(Agsym_t*)0;
+    static Agsym_t* selected_attr=(Agsym_t*)0;
+    if(!visible_attr)
+       visible_attr=agattr(g, AGNODE,"visible","1");
+    if(!selected_attr)
+       selected_attr=agattr(g, AGNODE,"selected",0);
+    sprintf(bf1,"%d",visibility);
+    for (v = agfstnode(g); v; v = agnxtnode(g, v)) 
+    {
+       bf2=agxget(v,selected_attr);
+       if((!bf2) || (strcmp(bf2,"0")==0))
+               continue;
+       agxset(v,visible_attr,bf1);
     }
-    if (data_attr1) {
-       gtk_entry_set_text(TV_Node->Data1,
-                          agget(view->Topview->Nodes[TV_Node->index].Node,
-                                data_attr1));
-    } else
-       gtk_entry_set_text(TV_Node->Data1, "");
-    gtk_widget_show((GtkWidget *) TV_Node->Data1);
-
-    //DATA 2
-    if (!TV_Node->Data2) {
-       TV_Node->Data2 = (GtkEntry *) gtk_entry_new();
-       gtk_layout_put(layout, (GtkWidget *) TV_Node->Data2,
-                      LOCATION_X_DATA2, TV_Nodes.Y);
-       gtk_widget_set_size_request((GtkWidget *) TV_Node->Data2, 200, 23);
-    }
-    if (data_attr2) {
-       gtk_entry_set_text(TV_Node->Data2,
-                          agget(view->Topview->Nodes[TV_Node->index].Node,
-                                data_attr2));
-    } else
-       gtk_entry_set_text(TV_Node->Data2, "");
-    gtk_widget_show((GtkWidget *) TV_Node->Data2);
-    return 1;
 
 }
 
-
-int tv_nodes_last_page(void)
+int tv_show_all(void)
 {
-    if (TV_Nodes.activepage < TV_Nodes.pagecount)
-       return tv_nodes_goto_page(TV_Nodes.pagecount);
-    else
-       return 0;
+    set_visibility(view->g[view->activeGraph],1);
+    updateSmGraph(view->g[view->activeGraph],view->Topview);
+    return 1;
 }
 
-int tv_nodes_first_page(void)
+int tv_hide_all(void)
 {
-    if (TV_Nodes.activepage > 0)
-       return tv_nodes_goto_page(0);
-    else
-       return 0;
-}
+    set_visibility(view->g[view->activeGraph],0);
+    updateSmGraph(view->g[view->activeGraph],view->Topview);
 
-static int hide_data_widgets(void)
-{
-    int i;
-    for (i = 0; i < MAX_NODE_PER_PAGE; i++) {
-       if (TV_Nodes.TV_Node[i].chkHighlighted) {
-           gtk_widget_hide((GtkWidget *) TV_Nodes.TV_Node[i].
-                           chkHighlighted);
-           gtk_widget_hide((GtkWidget *) TV_Nodes.TV_Node[i].chkSelected);
-           gtk_widget_hide((GtkWidget *) TV_Nodes.TV_Node[i].chkVisible);
-           gtk_widget_hide((GtkWidget *) TV_Nodes.TV_Node[i].Name);
-           gtk_widget_hide((GtkWidget *) TV_Nodes.TV_Node[i].Data1);
-           gtk_widget_hide((GtkWidget *) TV_Nodes.TV_Node[i].Data2);
-           gtk_widget_hide((GtkWidget *) TV_Nodes.TV_Node[i].IDLabel);
-       }
-    }
     return 1;
-
-
 }
-int tv_nodes_goto_page(int page)
+int tv_save_as(void)
 {
-    GtkSpinButton *spn;
-    tv_node *tvn;
-    GtkLabel *lblTVPage;
-
-    if ((page >= 0) && page <= TV_Nodes.pagecount) {
-       if (TV_Nodes.general_purpose_flag == 1) {
-           update_TV_data_from_gui();
-           TV_Nodes.general_purpose_flag = 0;
-       }
-       TV_Nodes.activepage = page;
-       TV_Nodes.page_data_node_index =
-           TV_Nodes.page_history[TV_Nodes.activepage];
-       TV_Nodes.page_data_index = 0;
-       TV_Nodes.firstnodeid = TV_Nodes.page_data_node_index;
-       TV_Nodes.Y = TV_Nodes.initial_Y;
-       hide_data_widgets();
-    } else
+    GtkWidget *dialog;
+    dialog = gtk_file_chooser_dialog_new("Save File",
+                                        NULL,
+                                        GTK_FILE_CHOOSER_ACTION_SAVE,
+                                        GTK_STOCK_CANCEL,
+                                        GTK_RESPONSE_CANCEL,
+                                        GTK_STOCK_SAVE,
+                                        GTK_RESPONSE_ACCEPT, NULL);
+    gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER
+                                                  (dialog), TRUE);
+    if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) {
+       char *filename;
+       filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
+
+       create_save_subgraph_from_filter(filename);
+       g_free(filename);
+       gtk_widget_destroy(dialog);
+
+       return 1;
+    } else {
+       gtk_widget_destroy(dialog);
        return 0;
-    while ((TV_Nodes.page_data_index < TV_Nodes.recordperpage)
-          && (TV_Nodes.page_data_node_index < view->Topview->Nodecount)) {
-       tvn = &TV_Nodes.TV_Node[TV_Nodes.page_data_index];
-       tvn->index = TV_Nodes.page_data_node_index;
-       if (view->Topview->Nodes[TV_Nodes.page_data_node_index].valid == 1) {
-           TV_Nodes.page_data_index++;
-           update_node_gui_objects(tvn);
-           TV_Nodes.Y = TV_Nodes.Y + TV_Nodes.Y_Gap;
-       }
-       TV_Nodes.page_data_node_index++;
     }
-    lblTVPage = (GtkLabel *) glade_xml_get_widget(xml, "lblTVPage");
-    sprintf(buf, "(%i / %i)", TV_Nodes.activepage + 1,
-           TV_Nodes.pagecount + 1);
-    gtk_label_set_text(lblTVPage, buf);
-    spn = (GtkSpinButton *) glade_xml_get_widget(xml, "spnTVGotopage");
-    gtk_spin_button_set_value(spn, page + 1);
-    return 1;
+    return 0;
 }
 
-int tv_nodes_prior_page(void)
-{
-    if (TV_Nodes.activepage > 0) {
-       return tv_nodes_goto_page(TV_Nodes.activepage - 1);
-    } else
-       return 0;
-}
 
 
-int tv_nodes_next_page(void)
+static void create_text_column(char* Title,GtkTreeView* tree,int asso,int editable)
 {
-    if (TV_Nodes.activepage < TV_Nodes.pagecount) {
-       return tv_nodes_goto_page(TV_Nodes.activepage + 1);
-    } else
-       return 0;
-}
+   PangoColor c;
+    GtkTreeViewColumn *column;
+    GtkCellRendererText *renderer;
 
-void execute_tv_nodes(void)
-{
 
-    gtk_widget_hide(glade_xml_get_widget(xml, "frmTVNodes"));
-    gtk_widget_show(glade_xml_get_widget(xml, "frmTVNodes"));
-//              gtk_window_set_keep_above           (glade_xml_get_widget(xml, "frmTVNodes"),1);
-    if (TV_Nodes.initialized < 1) {
-       init_tv_nodes(&TV_Nodes);
-    }
-    //test filter
-    prepare_page_history();
-//    TV_Nodes.general_purpose_flag = 1;
-    tv_nodes_next_page();
-}
+   renderer = (GtkCellRendererText*)gtk_cell_renderer_text_new ();
+    ((GtkCellRenderer*)renderer)->mode=GTK_CELL_RENDERER_MODE_EDITABLE;
+   renderer->editable=editable;
+   c.blue=0;
+   c.green=1;
+   c.red=0;
+   renderer->foreground=c;
 
 
-int reset_page_History(void)
-{
-/*     if(TV_Nodes.page_history_count > 0)
-       {
-               free(TV_Nodes.page_history);
-               TV_Nodes.page_history_count=0;
-       }*/
-    TV_Nodes.page_history_count = 0;
-    TV_Nodes.page_history =
-       RALLOC(TV_Nodes.page_history_count, TV_Nodes.page_history, int);
-    return 1;
-}
+   column = gtk_tree_view_column_new_with_attributes (Title,(GtkCellRenderer*)renderer,"text",asso,NULL);
 
-static int push_to_page_history(int index)
-{
-    TV_Nodes.page_history_count++;
-    TV_Nodes.page_history =
-       RALLOC(TV_Nodes.page_history_count, TV_Nodes.page_history, int);
-    TV_Nodes.page_history[TV_Nodes.page_history_count - 1] = index;
-    return 1;
-}
+   gtk_tree_view_append_column (GTK_TREE_VIEW (tree), column);
+   gtk_tree_view_column_set_resizable  (column,1);
 
-#ifdef UNUSED
-static int pop_from_page_history(void)
-{
-    if (TV_Nodes.page_history_count > 0) {
-       int return_value;
-       return_value =
-           TV_Nodes.page_history[TV_Nodes.page_history_count - 1];
-       TV_Nodes.page_history_count--;
-       TV_Nodes.page_history =
-           RALLOC(TV_Nodes.page_history_count, TV_Nodes.page_history,
-                  int);
-       return return_value;
-    }
-    return 0;
 }
-#endif
-
-static int set_data_attributes(void)
+static void create_toggle_column(char* Title,GtkTreeView* tree,int asso,int editable)
 {
-    GtkLabel *lblData1;
-    GtkLabel *lblData2;
-    char *data_attr1;
-    char *data_attr2;
-    // get attributes from graph
-    data_attr1 = agget(view->g[view->activeGraph], "DataAttribute1");
-    data_attr2 = agget(view->g[view->activeGraph], "DataAttribute2");
-    if (!data_attr1) {
-       agattr(view->g[view->activeGraph], AGRAPH, "DataAttribute1",
-              "DATA1");
-       agattr(view->g[view->activeGraph], AGNODE, "DATA1", "");
-    }
-    if (!data_attr2) {
-       agattr(view->g[view->activeGraph], AGRAPH, "DataAttribute2",
-              "DATA2");
-       agattr(view->g[view->activeGraph], AGNODE, "DATA2", "");
-    }
-
-    data_attr1 = agget(view->g[view->activeGraph], "DataAttribute1");
-    data_attr2 = agget(view->g[view->activeGraph], "DataAttribute2");
+   GtkTreeViewColumn *column;
+    GtkCellRendererToggle* renderer;
+   renderer =(GtkCellRendererToggle*)gtk_cell_renderer_toggle_new ();
+   renderer->activatable=editable;
+   g_object_set (G_OBJECT (renderer),"foreground", "red",NULL);
 
-    lblData1 = (GtkLabel *) glade_xml_get_widget(xml, "lblTVData1");
-    lblData2 = (GtkLabel *) glade_xml_get_widget(xml, "lblTVData2");
-    if (!strcmp(data_attr1, "\\N"))
-       data_attr1 = "Name";
-    gtk_label_set_text(lblData1, data_attr1);
-    gtk_label_set_text(lblData2, data_attr2);
-    return 1;
+   column =  gtk_tree_view_column_new_with_attributes (Title,(GtkCellRenderer*)renderer,"active",asso,NULL);
+   gtk_tree_view_append_column (GTK_TREE_VIEW (tree), column);
+    gtk_tree_view_column_set_resizable  (column,1);
 
 }
-
-int prepare_page_history(void)
+static int boolStrMap(char* str)
 {
-    GtkLabel *lblTVPage;
-    GtkSpinButton *spn;
-    int i;
-    int count = 0;
-    tv_node tvn;
-    TV_Nodes.pagecount = 0;
-    TV_Nodes.activepage = -1;
-    reset_page_History();
-    push_to_page_history(0);
-    for (i = 0; i < view->Topview->Nodecount; i++) {
-       tvn.index = i;
-       if (validate_node(&tvn)) {
-           count++;
-           view->Topview->Nodes[i].valid = 1;
-       } else
-           view->Topview->Nodes[i].valid = 0;
-       if (count == TV_Nodes.recordperpage) {
-           push_to_page_history(i + 1);
-           TV_Nodes.pagecount++;
-           count = 0;
-       }
-    }
-    spn = (GtkSpinButton *) glade_xml_get_widget(xml, "spnTVGotopage");
-    gtk_spin_button_set_value(spn, 0);
-    gtk_spin_button_set_range(spn, 0, TV_Nodes.pagecount + 1);
+    if (strcmp(str,"1") ||strcmp(str,"true")|| strcmp(str,"TRUE") || strcmp(str,"True"))
+       return 1;
+    return 0;
 
+}
 
-    lblTVPage = (GtkLabel *) glade_xml_get_widget(xml, "lblTVPage");
-    sprintf(buf, "(%i / %i)", 1, TV_Nodes.pagecount + 1);
-    gtk_label_set_text(lblTVPage, buf);
-    set_data_attributes();
-    return 1;
 
-}
 
-/*
-       call this function to create a subgraph from filtered nodes and maybe edges
-*/
 
-int create_save_subgraph_from_filter(char *filename)
+
+void populate_data(Agraph_t* g,grid* grid)
 {
+    Agnode_t *v;
+    int id=0;
+    GtkTreeIter iter;
+    static GValue valueData;
+    static GValue* value;
+
+    char* bf;
+    value=&valueData;
+
+    //GValue* g_value_init (GValue *value,GType g_type);
+/*    if(!value)
+       value=(GValue*)malloc(sizeof(GValue));*/
+    value=g_value_init (value,G_TYPE_STRING);
+
+    for (v = agfstnode(g); v; v = agnxtnode(g, v)) 
+    {
+       bf=agget(v,"selected");
+       if((!bf) || (strcmp(bf,"0")==0))
+       continue;
+       gtk_tree_store_append (grid->store, &iter, NULL);
+
+       for (id=1;id < grid->count;id ++)
+       {
+           g_value_unset (value);
+           value=g_value_init (value,grid->columns[id]->type);
+           if(id==1)
+               bf=agnameof(v);
+           else
+           bf=agget(v,grid->columns[id]->name);
+           if((!bf) && (id !=2))
+               continue;
+
+           switch(grid->columns[id]->type)
+           {
+           case G_TYPE_BOOLEAN:
+                   if(bf)
+                   {
+                       if((strcmp(bf,"1")==0) || (strcmp(bf,"true")==0) || (strcmp(bf,"True")==0))
+                           g_value_set_boolean (value, 1);
+                       else
+                           g_value_set_boolean (value, 0);
+                   }
+                   else
+                   {
+                       if(id==2)
+                           g_value_set_boolean (value, 1);
+                   }
+
+               break;
+           default:
+                   g_value_set_string (value, bf);
 
-    int i = 0;
-    Agraph_t *subg = agsubg(view->g[view->activeGraph], "temp", 1);
-    FILE *outputfile;
-    for (i = 0; i < view->Topview->Nodecount; i++) {
-       if (view->Topview->Nodes[i].valid == 1) {
-           agsubnode(subg, view->Topview->Nodes[i].Node, 1);
-       }
-    }
+           }
+           gtk_tree_store_set_value(grid->store,&iter,id,value);
+        }
 
-    if ((outputfile = fopen(filename, "w"))) {
-       int ret = agwrite(subg, outputfile);
-       fclose (outputfile);
-       if (ret) {
-           agdelsubg(view->g[view->activeGraph], subg);
-           return 1;
-       } else {
-           agdelsubg(view->g[view->activeGraph], subg);
-           return 0;
-       }
-    } else {
-       agdelsubg(view->g[view->activeGraph], subg);
-       return 0;
     }
 
-
 }
 
-int update_TV_data_from_gui(void)
-{
-/*    int i;
-    int index = 0;
-    char *data_attr1;
-    char *data_attr2;
-    // get attributes from graph
-    data_attr1 = agget(view->g[view->activeGraph], "DataAttribute1");
-    data_attr2 = agget(view->g[view->activeGraph], "DataAttribute2");
-
-    for (i = 0; i < TV_Nodes.recordperpage; i++) {
-       index = TV_Nodes.TV_Node[i].index;
-       if (index < view->Topview->Nodecount) {
-           // apply if selected
-           if (gtk_toggle_button_get_active
-               ((GtkToggleButton *) TV_Nodes.TV_Node[i].chkSelected)) {
-               if (!view->Topview->Nodes[index].data.Selected)
-                   select_node(&view->Topview->Nodes[index]);
-           } else {
-               if (view->Topview->Nodes[index].data.Selected)
-                   deselect_node(&view->Topview->Nodes[index]);
-           }
-           // apply if Visible
-           if (gtk_toggle_button_get_active
-               ((GtkToggleButton *) TV_Nodes.TV_Node[i].chkVisible)) {
-               if (!view->Topview->Nodes[index].data.Visible)
-                   view->Topview->Nodes[index].data.Visible = 1;
-           } else {
-               if (view->Topview->Nodes[index].data.Visible)
-                   view->Topview->Nodes[index].data.Visible = 0;
-           }
-           agset((void *) view->Topview->Nodes[index].Node, data_attr1,
-                 (char *) gtk_entry_get_text(TV_Nodes.TV_Node[i].Data1));
-           agset(view->Topview->Nodes[index].Node, data_attr2,
-                 (char *) gtk_entry_get_text(TV_Nodes.TV_Node[i].Data2));
 
-       }
-    }*/
-    return 1;
 
 
-}
 
-int apply_filter_from_gui(void)
-{
-    int selected;
-    int visible;
-    int highlighted;
-
-    if (gtk_toggle_button_get_active
-       ((GtkToggleButton *) glade_xml_get_widget(xml, "rbTVFilterSel1")))
-       selected = -1;
-    if (gtk_toggle_button_get_active
-       ((GtkToggleButton *) glade_xml_get_widget(xml, "rbTVFilterSel2")))
-       selected = 1;
-    if (gtk_toggle_button_get_active
-       ((GtkToggleButton *) glade_xml_get_widget(xml, "rbTVFilterSel3")))
-       selected = 0;
-
-    if (gtk_toggle_button_get_active((GtkToggleButton *)
-                                    glade_xml_get_widget(xml,
-                                                         "rbTVFilterVisible1")))
-       visible = -1;
-    if (gtk_toggle_button_get_active((GtkToggleButton *)
-                                    glade_xml_get_widget(xml,
-                                                         "rbTVFilterVisible2")))
-       visible = 1;
-    if (gtk_toggle_button_get_active((GtkToggleButton *)
-                                    glade_xml_get_widget(xml,
-                                                         "rbTVFilterVisible3")))
-       visible = 0;
-
-    if (gtk_toggle_button_get_active
-       ((GtkToggleButton *) glade_xml_get_widget(xml, "rbTVFilterHigh1")))
-       highlighted = -1;
-    if (gtk_toggle_button_get_active
-       ((GtkToggleButton *) glade_xml_get_widget(xml, "rbTVFilterHigh2")))
-       highlighted = 1;
-    if (gtk_toggle_button_get_active
-       ((GtkToggleButton *) glade_xml_get_widget(xml, "rbTVFilterHigh3")))
-       highlighted = 0;
-    set_filter(&TV_Nodes.filter, (char *) gtk_entry_get_text((GtkEntry *)
-                                                            glade_xml_get_widget
-                                                            (xml,
-                                                             "edtTVFilterMinData1")),
-              (char *) gtk_entry_get_text((GtkEntry *)
-                                          glade_xml_get_widget(xml,
-                                                               "edtTVFilterMaxData1")),
-              (char *) gtk_entry_get_text((GtkEntry *)
-                                          glade_xml_get_widget(xml,
-                                                               "edtTVFilterMinData2")),
-              (char *) gtk_entry_get_text((GtkEntry *)
-                                          glade_xml_get_widget(xml,
-                                                               "edtTVFilterMaxData2")),
-              (char *) gtk_entry_get_text((GtkEntry *)
-                                          glade_xml_get_widget(xml,
-                                                               "edtTVFilterString")),
-              selected, visible, highlighted);
-    MP_Flag = 1;
-    prepare_page_history();
-    tv_nodes_next_page();
-    return 1;
-}
 
 
-static int cache_validate_node(tv_node * tvn)
+GtkTreeStore* update_tree_store(GtkTreeStore* store,int ncolumns,GType *types)
 {
-
-    return view->Topview->Nodes[tvn->index].valid;
-}
-
-int tv_select_all(void)
-{
-
-/*    tv_node tvn;
-    int i;
-    for (i = 0; i < view->Topview->Nodecount; i++) {
-       tvn.index = i;
-       if (cache_validate_node(&tvn)) {
-           select_node(&view->Topview->Nodes[i]);
-       }
+    if ((ncolumns ==0) || (types==NULL))
+       return NULL;
+    if(store)
+    {
+       gtk_tree_store_clear(store);
+       g_object_unref(store);
     }
-    apply_filter_from_gui();
-*/
-    return 1;
-
+       
+    store=gtk_tree_store_newv (ncolumns,types);
+    return store;
 }
 
-int tv_unselect_all()
+
+static void create_column(gridCol* c,GtkTreeView *tree,int id)
 {
-/*
-    tv_node tvn;
-    int i;
-    for (i = 0; i < view->Topview->Nodecount; i++) {
-       tvn.index = i;
-       if (cache_validate_node(&tvn)) {
-           deselect_node(&view->Topview->Nodes[i]);
-       }
+    if (!c)
+       return;
+    switch (c->type)
+    {
+    case G_TYPE_STRING:
+    case G_TYPE_INT:
+       create_text_column(c->name,tree,id,c->editable);
+       break;
+    case G_TYPE_BOOLEAN:
+       create_toggle_column(c->name,tree,id,c->editable);
+       break;
+    default:
+       create_text_column(c->name,tree,id,c->editable);
     }
-    apply_filter_from_gui();
-*/
-
-    return 1;
 }
 
 
 
-int tv_show_all(void)
+
+GtkTreeView* update_tree (GtkTreeView *tree,grid* g)
 {
-    tv_node tvn;
-    int i;
-    for (i = 0; i < view->Topview->Nodecount; i++) {
-       tvn.index = i;
-       if (cache_validate_node(&tvn)) {
-           view->Topview->Nodes[i].data.Visible = 1;
-       }
+
+    GtkTreeStore* store=NULL;
+    GtkTreeViewColumn* column;
+    GType *types;
+    int id=0;
+    if(tree!=NULL)
+    {
+        while(column=gtk_tree_view_get_column(tree,0)) /*clear all columns*/
+           gtk_tree_view_remove_column(tree,column);
+       store=(GtkTreeStore*)gtk_tree_view_get_model(tree);
     }
-    apply_filter_from_gui();
-    return 1;
+    else
+    {
+       tree=(GtkTreeView*)gtk_tree_view_new();
+        gtk_widget_show((GtkWidget*)tree);
 
+       gtk_container_add((GtkContainer*)glade_xml_get_widget(xml, "scrolledwindow9"),(GtkWidget*)tree);
 
+    }
+    if(g->count > 0)
+    {
+       types=(GType*)malloc(g->count*sizeof(GType));
+       for (id=0;id < g->count;id++)
+           types[id]=g->columns[id]->type;
+        store=update_tree_store(store,g->count,types);
+        gtk_tree_view_set_model(tree,(GtkTreeModel*)store);
+       /*insert columns*/
+       for (id=0;id < g->count;id ++)
+           create_column(g->columns[id],tree,id);
+    }
+    g->store=store;
+    return tree;
 
-}
 
-int tv_hide_all(void)
+}
+static void add_column(grid* g,char* name,int editable,GType g_type)
 {
-    tv_node tvn;
-    int i;
-    for (i = 0; i < view->Topview->Nodecount; i++) {
-       tvn.index = i;
-       if (cache_validate_node(&tvn)) {
-           view->Topview->Nodes[i].data.Visible = 0;
+    g->columns=(gridCol**)realloc(g->columns,sizeof(gridCol*)*(g->count+1));
+    g->columns[g->count]=(gridCol*)malloc(sizeof(gridCol));
+    g->columns[g->count]->editable=editable;
+    g->columns[g->count]->name=strdup(name);
+    g->columns[g->count]->type=g_type;
+    g->count++;
+}
+static void clear_grid(grid* g)
+{
+    int id=0;
+    if (g->count >0)
+    {
+        for (id=0;id < g->count ; id++)
+       {
+           free(g->columns[id]->name);
+           free (g->columns[id]);
        }
+       
     }
-    apply_filter_from_gui();
-    return 1;
-
 
 }
-int tv_save_as(void)
+static grid* initGrid()
 {
-    GtkWidget *dialog;
-    dialog = gtk_file_chooser_dialog_new("Save File",
-                                        NULL,
-                                        GTK_FILE_CHOOSER_ACTION_SAVE,
-                                        GTK_STOCK_CANCEL,
-                                        GTK_RESPONSE_CANCEL,
-                                        GTK_STOCK_SAVE,
-                                        GTK_RESPONSE_ACCEPT, NULL);
-    gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER
-                                                  (dialog), TRUE);
-    if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) {
-       char *filename;
-       filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
+    grid* gr;
+    gr=(grid*)malloc(sizeof(grid));
+    gr->columns=NULL;
+    gr->count=0;
+    return gr;
+}
 
-       create_save_subgraph_from_filter(filename);
-       g_free(filename);
-       gtk_widget_destroy(dialog);
 
-       return 1;
-    } else {
-       gtk_widget_destroy(dialog);
-       return 0;
-    }
-    return 0;
+
+grid* update_colums(grid* g,char* str)
+{
+    /*free memory for existing c*/
+    char* a;
+    if(g)
+        clear_grid(g);
+    else
+       g=initGrid();
+    add_column(g,"ID",0,G_TYPE_STRING);
+    add_column(g,"Name",0,G_TYPE_STRING);
+    add_column(g,"visible",0,G_TYPE_BOOLEAN);
+
+    a=strtok(str,",");
+    add_column(g,a,1,G_TYPE_STRING);
+    while ((a=strtok(NULL,",")))
+        add_column(g,a,1,G_TYPE_STRING);
+    return g;
 }
+void setup_tree (Agraph_t* g)
+{
+    /*
+    G_TYPE_STRING:
+    G_TYPE_INT:
+    G_TYPE_BOOLEAN:
+    */
+    char buf[]="IP,HOST,DATA3,COLOR,FALAN,FILAN";
+    static GtkTreeStore *store=NULL;
+    static GtkTreeView *tree=NULL;
+    grid* gr=NULL;
+//    tree=(GtkTreeView *) glade_xml_get_widget(xml, "treeview1");
+    gr=update_colums(gr,buf);
+    tree=update_tree (tree,gr);
+    populate_data(g,gr);
+}
+
index 1f3ebdef12b22b80b0601b8a6ea4f2bbc0a34cdf..0d3d02304a16a212e4060b994a5ead8ab1269652 100755 (executable)
@@ -130,6 +130,7 @@ extern "C" {
     int tv_show_all(void);
     int tv_hide_all(void);
     int tv_save_as(void);
+    void setup_tree (Agraph_t* g);
 
 #ifdef __cplusplus
 }                              /* end extern "C" */
index 17433cbdba4bb22ef66b61d91b867b2eec60b2b4..ca9905e9c7f10616f8add5e3dda04ce0b0097cfc 100644 (file)
@@ -418,7 +418,7 @@ static void change_fontC(unsigned char* d,int w,int h,glCompColor* c)
 
 void glCompDrawText(glCompFont * f,GLfloat x,GLfloat y)
 {
-    change_fontC(f->tex->data,f->tex->width,f->tex->height,&f->color);
+//    change_fontC(f->tex->data,f->tex->width,f->tex->height,&f->color);
     glRasterPos2f(x, y);
     glDrawPixels(f->tex->width, f->tex->height, GL_RGBA, GL_UNSIGNED_BYTE,  f->tex->data);
 }