]> granicus.if.org Git - graphviz/commitdiff
*** empty log message ***
authorarif <devnull@localhost>
Fri, 29 Feb 2008 15:44:33 +0000 (15:44 +0000)
committerarif <devnull@localhost>
Fri, 29 Feb 2008 15:44:33 +0000 (15:44 +0000)
15 files changed:
cmd/smyrna/btree.c [new file with mode: 0644]
cmd/smyrna/btree.h [new file with mode: 0644]
cmd/smyrna/filter.c [new file with mode: 0644]
cmd/smyrna/filter.h [new file with mode: 0644]
cmd/smyrna/gltemplate.h
cmd/smyrna/gui/glmenu.c
cmd/smyrna/selection.c [moved from lib/utilities/selection.c with 100% similarity]
cmd/smyrna/selection.h [moved from lib/utilities/selection.h with 99% similarity, mode: 0644]
cmd/smyrna/topview.c
cmd/smyrna/tvnodes.c
lib/glcomp/glcompset.h
lib/glcomp/glcomptexture.h
lib/utilities/glTexFont.c
lib/xdot/xdot.c
lib/xdot/xdot.h

diff --git a/cmd/smyrna/btree.c b/cmd/smyrna/btree.c
new file mode 100644 (file)
index 0000000..3f78d7c
--- /dev/null
@@ -0,0 +1,370 @@
+/* $Id$ $Revision$ */
+/* vim:set shiftwidth=4 ts=8: */
+
+/**********************************************************
+*      This software is part of the graphviz package      *
+*                http://www.graphviz.org/                 *
+*                                                         *
+*            Copyright (c) 1994-2004 AT&T Corp.           *
+*                and is licensed under the                *
+*            Common Public License, Version 1.0           *
+*                      by AT&T Corp.                      *
+*                                                         *
+*        Information and Software Systems Research        *
+*              AT&T Research, Florham Park NJ             *
+**********************************************************/
+
+#include "btree.h"
+#include "regex.h"
+btree_node* new_node(char* attribute,char* regex, float min, float max)
+{
+       btree_node* n;
+       n=malloc(sizeof(btree_node));
+       n->child_count=0;
+       n->childs=0;
+       n->rank=0;
+       n->attr_name=strdup(attribute);
+       n->regex=strdup(regex);
+       n->min=0;
+       n->max=0;
+       n->value=-1;
+       n->active=1;
+       return n;
+}
+int insert_node (btree_node* parent_n,btree_node* n)
+{
+       parent_n->child_count ++;
+       parent_n->childs=realloc(parent_n->childs,parent_n->child_count*sizeof(btree_node*));
+       parent_n->childs[parent_n->child_count-1]=n;
+       n->rank=parent_n->rank+1;
+       n->parent=parent_n;
+       return 1;
+}
+int delete_node_recursive(btree_node* n)
+{
+       int i=0;
+       int child_found=0;
+       //delete recursively
+       for (i=0;i < n->child_count;i++)
+       {
+               delete_node(n->childs[i]);
+       }
+       free(n->attr_name);
+       free(n->regex);
+       free(n->childs);
+
+       free(n);
+       return 1;
+}
+int delete_node(btree_node* n)
+{
+       int i=0;
+       int child_found=0;
+       //rmeove from parent's child list
+       if (n->parent)
+       {
+               n->parent->child_count--;
+               for (i=0;i < n->parent->child_count; i++)
+               {
+                       if (n->parent->childs[i]==n)
+                       {
+                               child_found=1;
+                       }
+                       if (child_found)
+                               n->parent->childs[i]=n->parent->childs[i+1];
+               }
+       }
+       n->parent->childs=realloc(n->parent->childs,sizeof(btree_node*)*n->parent->child_count);
+       delete_node_recursive(n);
+}
+
+btree_node* look_up_node_with_string(btree_node* n,char* string_to_lookup)
+{
+       int i=0;
+       btree_node* nn;
+       if (validate_lookup(n,string_to_lookup))
+               return n;
+       else
+       {
+               for (i=0;i < n->child_count;i++)
+               {
+                       nn=look_up_node_with_string(n->childs[i],string_to_lookup);
+                       if (nn)
+                               return nn;
+               }
+       }
+       return 0;
+
+}
+int validate_lookup(btree_node* n,char* string_to_lookup)      //it can be anything, in this case attr_name
+{
+       printf ("%s == %s\n",n->attr_name,string_to_lookup);
+       if (strcmp(n->attr_name,string_to_lookup)==0)
+               return 1;
+       return 0;
+}
+int print_tree(btree_node* root)
+{
+       static rank=0;
+       //printf("Node data:%s\n",
+}
+int print_children(btree_node* n)
+{
+       int i=0;
+       static int prev_rank=0;
+       if (n->node_type==2)
+               printf("      %*s=%s(%i)\n", n->rank*5+1,n->attr_name,n->regex,n->rank);
+       else
+               printf("%*s %c(%i)\n", n->rank*5+1,"",n->op,n->rank);
+       prev_rank=n->rank;
+       for (i=0;i < n->child_count;i++)
+       {
+               print_children(n->childs[i]);
+       }
+       return 1;
+
+}
+int sample_tree()
+{
+       btree_node* root;
+       btree_node* n;
+       btree_node* nn;
+       btree_node* kurbanlik;
+       root=new_node("A","R", 0, 0);
+       root->parent=0;
+       insert_node (root,new_node("B","R", 0, 0));
+       insert_node (root,new_node("C","R", 0, 0));
+
+       n=new_node("D","R", 0, 0);
+       kurbanlik=n;
+       insert_node (root,n);
+
+       nn=new_node("E","R", 0, 0);
+       insert_node (n,nn);
+       insert_node (n,new_node("X","R", 0, 0));
+       insert_node (n,new_node("Y","R", 0, 0));
+       insert_node (n,new_node("Z","R", 0, 0));
+       n=new_node("F","R", 0, 0);
+       insert_node (root,n);
+
+       print_children(root);
+       n=look_up_node_with_string(root,"F");
+       if(n)
+               printf("found   value-->%s \n",n->attr_name);
+
+       delete_node(kurbanlik);
+       print_children(root);
+    print_children(tree_from_filter_string("(()(())((())()))"));
+}
+
+btree_node* tree_from_filter_string(char* filter_string)
+{
+       btree_node* root;
+       btree_node* cursor;
+       btree_node* n;
+       btree_node* Nodes[2];
+       char buffer[512];
+       char* b_cursor=0;
+       char* c_cursor;
+       char op='\0';
+       char last_char;
+       int a=0;
+       root=new_node("R","", 0, 0);
+       cursor=root;
+       c_cursor=filter_string;
+       while (*c_cursor!='\0')
+       {
+               switch (*c_cursor)
+               {
+                       case '(' :
+                               n=new_node(".","", 0, 0);
+                               insert_node (cursor,n);
+                               last_char='(';
+                               cursor=n;
+                       break;
+                       case ')':
+                               last_char=')';
+                               cursor=cursor->parent;
+                       break;
+                       default:
+                               if (last_char=='(')
+                               {
+                                       b_cursor=buffer;
+                                       while (*c_cursor !=')')
+                                       {
+                                               *b_cursor=*c_cursor;
+                                               b_cursor++;
+                                               c_cursor++;
+                                       }
+                                       *b_cursor='\0';
+                                       evaluate_filter_atom(buffer,Nodes,&op);
+                                       if (Nodes[1] !=0)
+                                       {
+                                               insert_node(cursor,Nodes[0]);
+                                               insert_node(cursor,Nodes[1]);
+                                               cursor->op=op;
+                                       }
+                                       else    //only one expression in ()
+                                       {
+                                               insert_node(cursor->parent,Nodes[0]);
+                                               delete_node(cursor);
+                                               cursor=Nodes[0];
+                                       }
+
+
+                                       c_cursor--;
+                               }
+                               if (last_char == ')')
+                                       cursor->op=*c_cursor;
+                       break;
+               };
+               c_cursor ++;
+       }
+       return root;
+}
+int evaluate_filter_atom(char* string,btree_node* Nodes[],char* op)
+{
+       char* c_cursor;
+       char** attrs;
+       char buff_attr[512];
+       int c_buff_attr=0;
+       char buff_value[512];
+       int c_buff_value=0;
+       int attrs_count=0;
+       char** values;
+       int values_count=0;
+       int cc=0;
+       btree_node* n;
+       int kp_open=0;  //[ open
+       int qt_open=0; //" open?
+       int error=0;
+       int i=0;
+
+       attrs=0;
+       values=0;
+
+       c_cursor=string;
+       while ( *c_cursor !='\0')
+       {
+               if (kp_open)
+               {
+                       if ((*c_cursor == ',') || ((*c_cursor==']') && (!qt_open)))
+                       {
+                               attrs=realloc(attrs,(attrs_count+1)*sizeof(char*));
+                               attrs[attrs_count]=strdup(buff_attr);
+                               attrs_count++;
+                               values=realloc(values,(values_count+1)*sizeof(char*));
+                               values[values_count]=strdup(buff_value);
+                               values_count++;
+                               buff_attr[0]='\0';buff_value[0]='\0';
+                               c_buff_attr=0;c_buff_value=0;
+                       }
+                       if ( (*c_cursor != '=') &&(*c_cursor != ',')&&(*c_cursor != '\"'))
+                       {
+                               if(!qt_open && (*c_cursor != ']')&&(*c_cursor != '[')) 
+                               {
+                                       buff_attr[c_buff_attr]=*c_cursor;
+                                       buff_attr[c_buff_attr+1]='\0';
+                                       c_buff_attr++;
+                               }
+                               if (qt_open) 
+                               {
+                                       buff_value[c_buff_value]=*c_cursor;
+                                       buff_value[c_buff_value+1]='\0';
+                                       c_buff_value++;
+                               }
+                       }
+                       if ((*c_cursor == '\"')&&(qt_open))
+                               qt_open=0;
+                       else
+                               if ((*c_cursor == '\"')&&(!qt_open))
+                                       qt_open=1;
+                       if ((*c_cursor == ']') && !qt_open)
+                               kp_open=0;
+               }
+               if (*c_cursor == '[')
+                       kp_open=1;
+               if ( *c_cursor == '&')
+                       *op='&';
+               if ( *c_cursor == '|')
+                       *op='|';
+               c_cursor++;
+       }
+       
+       n=new_node(attrs[0],values[0],(float)atof(values[1]),(float)atof(values[2]));
+       n->node_type=2;
+       Nodes[0]=n;
+
+       if (attrs_count >5)
+       {
+               n=new_node(attrs[3],values[3],(float)atof(values[4]),(float)atof(values[5]));
+               n->node_type=2;
+               Nodes[1]=n;
+       }
+       else
+               Nodes[1]=0;
+    
+       for (i=0;i < attrs_count;i++)
+       {
+                       free(attrs[i]);
+                       free(values[i]);
+       }
+       free(attrs);
+       free(values);
+
+       return 1;
+}
+int  evaluate_expresions (tv_node* TV_Node,btree_node* n)
+{
+       regex_t preg;
+       char* data;
+       int i=0;
+       int ii=0;
+       if (!n)
+               return 1;
+       if(n->op=='&')
+               ii=1;
+       for (i=0;i < n->child_count;i++)
+       {
+               evaluate_expresions(TV_Node,n->childs[i]);
+                       if(n->op=='&')
+                               ii =ii && n->childs[i]->value;
+//                     if(n->op=='|')
+                       else
+                               ii =ii || n->childs[i]->value;
+
+       }
+       if (n->node_type==2)
+       {
+//assert(n);
+//assert(n->attr_name);
+//fprintf(stderr,"agget(%d,%s)", TV_Node->index , n->attr_name);
+               data=agget(view->Topview->Nodes[TV_Node->index].Node,n->attr_name);
+//fprintf(stderr,"  = %s\n", data);
+               if (data)
+               {
+                       regcomp(&preg,n->regex,REG_NOSUB);
+                       if (regexec(&preg,data,0,0,0)==0)
+                               n->value=1;
+                       else
+                               n->value=0;
+                       regfree(&preg); 
+               }
+               else
+                       n->value=1;     //no attribute return 1
+       }
+       else
+               n->value=ii;
+       return n->value;
+
+}
+
+
+
+
+
+
+
+
+
diff --git a/cmd/smyrna/btree.h b/cmd/smyrna/btree.h
new file mode 100644 (file)
index 0000000..84c1945
--- /dev/null
@@ -0,0 +1,32 @@
+/* $Id$ $Revision$ */
+/* vim:set shiftwidth=4 ts=8: */
+
+/**********************************************************
+*      This software is part of the graphviz package      *
+*                http://www.graphviz.org/                 *
+*                                                         *
+*            Copyright (c) 1994-2004 AT&T Corp.           *
+*                and is licensed under the                *
+*            Common Public License, Version 1.0           *
+*                      by AT&T Corp.                      *
+*                                                         *
+*        Information and Software Systems Research        *
+*              AT&T Research, Florham Park NJ             *
+**********************************************************/
+
+#ifndef BTREE_H
+#define        BTREE_H
+#include "tvnodes.h"
+
+btree_node* new_node(char* attribute,char* regex, float min, float max);
+int insert_node (btree_node* parent_n,btree_node* n);
+int delete_node(btree_node* n);
+int delete_node_recursive(btree_node* n);      //internal function
+btree_node* look_up_node_with_string(btree_node* n,char* string_to_lookup);
+int validate_lookup(btree_node* n,char* string_to_lookup);     //it can be anything, in this case attr_name
+int print_tree(btree_node* root);
+int print_children(btree_node* n);
+btree_node* tree_from_filter_string(char* filter_string);
+int evaluate_filter_atom(char* string,btree_node* Nodes[],char* op);
+int evaluate_expresions(tv_node* Node,btree_node* root);
+#endif
diff --git a/cmd/smyrna/filter.c b/cmd/smyrna/filter.c
new file mode 100644 (file)
index 0000000..c51da2a
--- /dev/null
@@ -0,0 +1,50 @@
+/* $Id$ $Revision$ */
+/* vim:set shiftwidth=4 ts=8: */
+
+/**********************************************************
+*      This software is part of the graphviz package      *
+*                http://www.graphviz.org/                 *
+*                                                         *
+*            Copyright (c) 1994-2004 AT&T Corp.           *
+*                and is licensed under the                *
+*            Common Public License, Version 1.0           *
+*                      by AT&T Corp.                      *
+*                                                         *
+*        Information and Software Systems Research        *
+*              AT&T Research, Florham Park NJ             *
+**********************************************************/
+
+#include "filter.h"
+
+int clear_filter(tv_filter* f)
+{
+       delete_node(f->root);
+}
+
+int init_filters(tv_filters* filters)
+{
+       filters->filter_count=0;
+       filters->filters=0;
+}
+int add_filter_to_filters(tv_filters* filters,tv_filter* filter)
+{
+       filters->filters=realloc(filters->filters,sizeof(tv_filter*)*(filters->filter_count+1));
+       filters->filters[filters->filter_count]=filter;
+       filters->filter_count++;
+}
+int clear_filters(tv_filters* filters)
+{
+       //deep clear
+       int ind=0;
+       for (ind =0;ind < filters->filter_count ; ind ++)
+       {
+               clear_filter(filters->filters[ind]);
+               free(filters->filters[ind]);
+       }
+       filters->filter_count=0;
+}
+int union_filter(tv_filter* f1,tv_filter* f2)
+{
+               
+}
+int intersect_filter(tv_filter* f1,tv_filter* f2);
diff --git a/cmd/smyrna/filter.h b/cmd/smyrna/filter.h
new file mode 100644 (file)
index 0000000..a39e82b
--- /dev/null
@@ -0,0 +1,34 @@
+/* $Id$ $Revision$ */
+/* vim:set shiftwidth=4 ts=8: */
+
+/**********************************************************
+*      This software is part of the graphviz package      *
+*                http://www.graphviz.org/                 *
+*                                                         *
+*            Copyright (c) 1994-2004 AT&T Corp.           *
+*                and is licensed under the                *
+*            Common Public License, Version 1.0           *
+*                      by AT&T Corp.                      *
+*                                                         *
+*        Information and Software Systems Research        *
+*              AT&T Research, Florham Park NJ             *
+**********************************************************/
+
+#ifndef FILTER_H
+#define FILTER_H
+#include "btree.h"
+
+typedef struct _tv_filters
+{
+       tv_filter** filters;
+       int filter_count;
+}tv_filters;
+
+int clear_filter(tv_filter* f);
+int init_filters(tv_filters* filters);
+int add_filter_to_filters(tv_filters* filters,tv_filter* filter);
+int clear_filters(tv_filters* filters);
+int union_filter(tv_filter* f1,tv_filter* f2);
+int intersect_filter(tv_filter* f1,tv_filter* f2);
+
+#endif
index ff03d4f809a71da799422a24c33d443351a2f5c6..9e65076a009dd32b1fcb6e60cbb542721b087bda 100755 (executable)
 #include <gtk/gtkgl.h>
 #include <gdk/gdkcursor.h>
 
-
-
-
-
-//mouse modes
-#define MM_PAN                                 0
-#define MM_ZOOM                                        1
-#define MM_ROTATE                              2
-#define MM_SINGLE_SELECT               3
-#define MM_RECTANGULAR_SELECT  4
-#define MM_RECTANGULAR_X_SELECT        5
-#define MM_MOVE                                        10
-#define MM_MAGNIFIER                   20
-#define MM_FISHEYE_MAGNIFIER   21
-
-
 void examine_gl_config_attrib (GdkGLConfig *glconfig);
 void print_gl_config_attrib (GdkGLConfig *glconfig,const gchar *attrib_str,int attrib,gboolean is_boolean);
 static void realize (GtkWidget *widget,gpointer   data);
index 02c60dcc03e09990350a6ab1e8a833d0fac33d0e..14569d484b8527a6201cc4cf17f2d6a24eaea8a3 100644 (file)
@@ -1,4 +1,5 @@
 #include "glmenu.h"
+#include "gltemplate.h"
 /*
        creates the right click menu for open gl canvas
        params:gtk widget to assign menu
old mode 100755 (executable)
new mode 100644 (file)
similarity index 99%
rename from lib/utilities/selection.h
rename to cmd/smyrna/selection.h
index 41562e3..2d4ab72
@@ -17,7 +17,7 @@
 #ifndef SELECTION_H
 #define SELECTION_H
 
-#include "viewport.h"
+#include "xdot.h"
 
 #define        SELECTION_SEGMENT_DIVIDER       5.0     //control points count to check if a line segment is withing clipping rect
 #define SINGLE_SELECTION_WIDTH 10      //width of the rect clip for single selections , higher values more catches less sensitivity
index 7dc135886f63e03ca71d3db237cea54a9818ab68..e04406ae44acf24193558ab786a3eff204f26fb0 100755 (executable)
@@ -53,7 +53,7 @@ void preparetopview(Agraph_t *g,topview* t)
        char buf[256];
        ind=0;ind2=0;
        gtk_widget_hide(glade_xml_get_widget(xml, "layout6"));  //hide top panel
-       gtk_widget_hide(glade_xml_get_widget(xml, "menubar1")); //hide menu
+//     gtk_widget_hide(glade_xml_get_widget(xml, "menubar1")); //hide menu
        data_type_count=0;
        d_attr1=agget(g, "DataAttribute1");
        if (d_attr1) {
index 836cad621bcdb8bea1f643522979b94f61c76fc7..df27756578a6c30c121960b2818a52dd0889aa44 100755 (executable)
@@ -112,6 +112,7 @@ int validate_node(tv_node* TV_Node)
        char* data_attr2;
        char* data1;
        char* data2;
+       char* buf;
 //             n=tree_from_filter_string("([IP=\"^10.*\",min=\"0\",max=\"0\"])");
        // get attributes from graph
        data_attr1=agget(view->g[view->activeGraph],"DataAttribute1");
@@ -125,8 +126,12 @@ int validate_node(tv_node* TV_Node)
                {
                        n=tree_from_filter_string(TV_Nodes.filter.filter_string);
                        MP_Flag=0;
-                       if (strcmp(TV_Nodes.filter.min_data1,  agget(view->Topview->Nodes[TV_Node->index].Node,data_attr1)   ))
-                               valid=0;
+                       buf=agget(view->Topview->Nodes[TV_Node->index].Node,data_attr1);
+                       if(buf)
+                       {
+                               if (strcmp(TV_Nodes.filter.min_data1,buf))
+                                       valid=0;
+                       }
                }
                if (data_attr1 && TV_Nodes.filter.max_data1 && agget(view->Topview->Nodes[TV_Node->index].Node,data_attr1))
                {
index c2421a709972af16d99a101857a4a8a42c44a1d8..ebfa56234ae7b014dc58b2536ad23add21f4975d 100644 (file)
@@ -8,7 +8,7 @@
 #include "glTexFontTGA.h"
 #include "glTexFontDefs.h"
 #include "glTexFontInclude.h"
-#include "gltemplate.h"
+//#include "gltemplate.h"
 #include "glcomptexture.h"
 
 #define        GLCOMPSET_PANEL_COLOR_R         0.16
index 121abeae10f2225c110b3b88920075f96fef8eb7..eacfd33b52daf1a68603374099a3b32971127cfa 100644 (file)
@@ -1,12 +1,18 @@
 /*Open GL texture handling and storing mechanism
   includes glPanel,glCompButton,glCompCustomButton,clCompLabel,glCompStyle
 */
+#ifdef _WIN32
+#include "windows.h"
+#endif
+#include <stdio.h>
+#include <GL/gl.h>
+#include <GL/glu.h>                                                    
+
 #ifndef GLCOMPTEXTURE_H
 #define GLCOMPTEXTURE_H
-#include "gltemplate.h"
 typedef struct{
        int id;
-       GLfloat w,h;
+       float w,h;
 } glCompTexture;
 
 glCompTexture* glCompCreateTextureFromRaw(char* filename,int width,int height,int wrap);
index c5b0c79e7c009cf1c5ebb6a4fbac00310b224f2a..4f3a361e6373ae2a9f7dd45b698aeb3ddacea196 100755 (executable)
@@ -19,7 +19,6 @@
 #include "glTexFontTGA.h"
 #include "glTexFontDefs.h"
 #include "glTexFontInclude.h"
-#include "viewport.h"
 
 
 /* just a global for our default colors */
index a2732ac62d4c019cb734200444470b81a181b6ae..dfe2d00449115cfdf5e4574a2af80ce7d34aaa9e 100755 (executable)
@@ -15,7 +15,7 @@
 
 
 #include <xdot.h>
-#include <viewport.h>
+//#include <viewport.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
index f832066daa9034e229dfde1fce4c5f3e7bfd5dd1..f2868004da1e43b482565923801e80011b3a8049 100755 (executable)
 #include <stdio.h>
 #ifdef _WIN32
 #include <windows.h>
-#include <strcasecmp.h>
 #endif
 #include <GL/gl.h>
-
 #include "cgraph.h"
 #define MAXIMUM_POS_COUNT      100     
 typedef struct _TextTexture {