From: arif Date: Fri, 14 Mar 2008 14:46:20 +0000 (+0000) Subject: *** empty log message *** X-Git-Tag: LAST_LIBGRAPH~32^2~4508 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=cfd58215b04642d8b353891e044f46591a5bade5;p=graphviz *** empty log message *** --- diff --git a/cmd/smyrna/draw.c b/cmd/smyrna/draw.c index 180558571..5aa0d447f 100755 --- a/cmd/smyrna/draw.c +++ b/cmd/smyrna/draw.c @@ -63,7 +63,7 @@ void DrawBezier(GLfloat* xp,GLfloat* yp,GLfloat* zp, int filled,int param) if (param==0) glColor4f(view->penColor.R,view->penColor.G,view->penColor.B,view->penColor.A); if (param==1) //selected - glColor4f(view->selectColor.R,view->selectColor.G,view->selectColor.B,view->selectColor.A); + glColor4f(view->selectedNodeColor.R,view->selectedNodeColor.G,view->selectedNodeColor.B,view->selectedNodeColor.A); glBegin(GL_LINE_STRIP); } else @@ -71,7 +71,7 @@ void DrawBezier(GLfloat* xp,GLfloat* yp,GLfloat* zp, int filled,int param) if (param==0) glColor4f(view->fillColor.R,view->fillColor.G,view->fillColor.B,view->penColor.A); if (param==1) //selected - glColor4f(view->selectColor.R,view->selectColor.G,view->selectColor.B,view->selectColor.A); + glColor4f(view->selectedNodeColor.R,view->selectedNodeColor.G,view->selectedNodeColor.B,view->selectedNodeColor.A); glBegin(GL_POLYGON); } /* We will not actually draw a curve, but we will divide the curve into small @@ -205,7 +205,7 @@ void DrawEllipse(xdot_op* op,int param) if (param==0) glColor4f(view->fillColor.R,view->fillColor.G,view->fillColor.B,view->fillColor.A); if (param==1) //selected - glColor4f(view->selectColor.R,view->selectColor.G,view->selectColor.B,view->selectColor.A); + glColor4f(view->selectedNodeColor.R,view->selectedNodeColor.G,view->selectedNodeColor.B,view->selectedNodeColor.A); filled=1; } @@ -214,7 +214,7 @@ void DrawEllipse(xdot_op* op,int param) if (param==0) glColor4f(view->penColor.R,view->penColor.G,view->penColor.B,view->penColor.A); if (param==1) //selected - glColor4f(view->selectColor.R,view->selectColor.G,view->selectColor.B,view->selectColor.A); + glColor4f(view->selectedNodeColor.R,view->selectedNodeColor.G,view->selectedNodeColor.B,view->selectedNodeColor.A); filled=0; } @@ -246,7 +246,7 @@ void DrawPolygon(xdot_op* op,int param) if(param==0) glColor4f(view->fillColor.R,view->fillColor.G,view->fillColor.B,view->fillColor.A); if (param==1) //selected - glColor4f(view->selectColor.R,view->selectColor.G,view->selectColor.B,view->selectColor.A); + glColor4f(view->selectedNodeColor.R,view->selectedNodeColor.G,view->selectedNodeColor.B,view->selectedNodeColor.A); filled=1; } @@ -256,7 +256,7 @@ void DrawPolygon(xdot_op* op,int param) if(param==0) glColor4f(view->penColor.R,view->penColor.G,view->penColor.B,view->penColor.A); if (param==1) //selected - glColor4f(view->selectColor.R,view->selectColor.G,view->selectColor.B,view->selectColor.A); + glColor4f(view->selectedNodeColor.R,view->selectedNodeColor.G,view->selectedNodeColor.B,view->selectedNodeColor.A); } glLineWidth(view->LineWidth); @@ -278,7 +278,7 @@ void DrawPolyline(xdot_op* op,int param) if(param==0) glColor4f(view->penColor.R,view->penColor.G,view->penColor.B,view->penColor.A); if (param==1) //selected - glColor4f(view->selectColor.R,view->selectColor.G,view->selectColor.B,view->selectColor.A); + glColor4f(view->selectedNodeColor.R,view->selectedNodeColor.G,view->selectedNodeColor.B,view->selectedNodeColor.A); SelectPolyline(op); set_options(op,param); glLineWidth(view->LineWidth); @@ -358,7 +358,7 @@ void EmbedText(xdot_op* op,int param) if(param==0) fontColor (view->penColor.R,view->penColor.G,view->penColor.B); if (param==1) //selected - fontColor (view->selectColor.R,view->selectColor.G,view->selectColor.B); + fontColor (view->selectedNodeColor.R,view->selectedNodeColor.G,view->selectedNodeColor.B); fontDrawString ((int)(x-dx),op->u.text.y-(int)dy,op->u.text.text,op->u.text.width); } diff --git a/cmd/smyrna/gui/menucallbacks.c b/cmd/smyrna/gui/menucallbacks.c index 27cee7af9..6a5b08e40 100755 --- a/cmd/smyrna/gui/menucallbacks.c +++ b/cmd/smyrna/gui/menucallbacks.c @@ -18,6 +18,7 @@ #include "viewport.h" #include "tvnodes.h" #include "selection.h" +#include "topviewsettings.h" //file @@ -120,6 +121,10 @@ void mNewSlot (GtkWidget *widget,gpointer user_data) void mDeleteSlot (GtkWidget *widget,gpointer user_data) { } +void mTopviewSettingsSlot (GtkWidget *widget,gpointer user_data) +{ + show_settings_form(); +} diff --git a/cmd/smyrna/gui/menucallbacks.h b/cmd/smyrna/gui/menucallbacks.h index 4d1ebd512..1b8bc15ee 100755 --- a/cmd/smyrna/gui/menucallbacks.h +++ b/cmd/smyrna/gui/menucallbacks.h @@ -33,6 +33,7 @@ _BB void mCutSlot (GtkWidget *widget,gpointer user_data); _BB void mCopySlot (GtkWidget *widget,gpointer user_data); _BB void mPasteSlot (GtkWidget *widget,gpointer user_data); _BB void mDeleteSlot (GtkWidget *widget,gpointer user_data); +_BB void mTopviewSettingsSlot (GtkWidget *widget,gpointer user_data); //view _BB void mShowToolBoxSlot(GtkWidget *widget,gpointer user_data); diff --git a/cmd/smyrna/hier.c b/cmd/smyrna/hier.c index e0ca07226..557c3140c 100644 --- a/cmd/smyrna/hier.c +++ b/cmd/smyrna/hier.c @@ -29,7 +29,7 @@ set_active_levels(hierarchy, fs->foci_nodes, fs->num_foci); positionAllItems(hierarchy, fs, parms) - When done: + When done:973 377 2462 release (hierarchy); */ @@ -186,4 +186,13 @@ makeHier (int nn, int ne, vtx_data* graph, double* x_coords, double* y_coords) return hp; } +focus_t* initFocus (int ncnt) +{ + focus_t* fs = NEW(focus_t); + fs->num_foci = 0; + fs->foci_nodes = N_NEW(ncnt, int); + fs->x_foci = N_NEW(ncnt, double); + fs->y_foci = N_NEW(ncnt,double); + return fs; +} diff --git a/cmd/smyrna/hier.h b/cmd/smyrna/hier.h index 1a3a9e52d..433954d6f 100644 --- a/cmd/smyrna/hier.h +++ b/cmd/smyrna/hier.h @@ -1,9 +1,8 @@ #ifndef HIER_H #define HIER_H -#include "topview.h" #include "hierarchy.h" - +#include "topview.h" typedef struct { int num_foci; int* foci_nodes; @@ -22,5 +21,6 @@ typedef struct { void positionAllItems (Hierarchy* hp, focus_t* fs, hierparms_t* parms); vtx_data* makeGraph (topview* tv, int* nedges); Hierarchy* makeHier (int nnodes, int nedges, vtx_data*, double*, double*); +focus_t* initFocus (int ncnt); #endif diff --git a/cmd/smyrna/smyrnadefs.h b/cmd/smyrna/smyrnadefs.h index 74bb9632e..02bc3198f 100644 --- a/cmd/smyrna/smyrnadefs.h +++ b/cmd/smyrna/smyrnadefs.h @@ -3,11 +3,12 @@ #ifdef WIN32 #include "windows.h" -#define SMYRNA_GLADE "C:/Projects/graphviz2/share/gui/smyrna.glade" +//#define SMYRNA_GLADE "C:/Projects/graphviz2/share/gui/smyrna.glade" #define SMYRNA_ATTRS "c:/Projects/graphviz2/share/gui/attrs.txt" #endif #ifdef _WIN32 -#define GTKTOPVIEW_GLADE "c:\\Projects\\ATT\\GTK\\gtktopview\\lib\\GUI\\smyrna.glade" +//#define GTKTOPVIEW_GLADE "c:\\Projects\\ATT\\GTK\\gtktopview\\lib\\GUI\\smyrna.glade" +#define SMYRNA_GLADE "c:\\Projects\\ATT\\GTK\\gtktopview\\lib\\GUI\\smyrna.glade" #define GTKTOPVIEW_ATTRS "c:\\Projects\\ATT\\GTK\\GTKTest2\\attrs.txt" // #else // using -DGTKTOPVIEW_GLADE from Makefile.am and configure.ac @@ -29,6 +30,8 @@ #include #include #include "glcompset.h" +#include "hierarchy.h" + #define IS_TEST_MODE_ON 0 #define DEFAULT_MAGNIFIER_WIDTH 300 @@ -125,6 +128,9 @@ typedef struct { glCompSet* topviewmenu; //for novice user open gl menu topviewdata* TopviewData; void* customptr; + Hierarchy* h; + + } topview; enum { @@ -255,10 +261,18 @@ typedef struct _ViewInfo RGBColor penColor; /*default fill color*/ RGBColor fillColor; - /*selection color, selected items appear in this color*/ - RGBColor selectColor; + /*highlighted Node Color*/ + RGBColor highlightedNodeColor; + /*highlighted Edge Color*/ + RGBColor highlightedEdgeColor; /*grid color*/ RGBColor gridColor; //grid color + /*border color*/ + RGBColor borderColor; + /*selected node color*/ + RGBColor selectedNodeColor; + /*selected edge color*/ + RGBColor selectedEdgeColor; /*default line width*/ float LineWidth; @@ -270,9 +284,10 @@ typedef struct _ViewInfo /*draws a border in border colors if it is 1*/ int bdVisible; //if borders are visible (boundries of the drawing, - /*border color*/ - RGBColor borderColor; /*border coordinates, needs to be calculated for each graph*/ + + + float bdxLeft,bdyTop,bdzTop; float bdxRight,bdyBottom,bdzBottom; diff --git a/cmd/smyrna/topview.c b/cmd/smyrna/topview.c index 4875c1fdd..8c5321ba0 100755 --- a/cmd/smyrna/topview.c +++ b/cmd/smyrna/topview.c @@ -24,6 +24,7 @@ #include "draw.h" #include "selection.h" #include "topviewdata.h" +#include "hier.h" static float dx=0.0; static float dy=0.0; @@ -189,7 +190,8 @@ void preparetopview(Agraph_t *g,topview* t) set_boundries(t); set_update_required(t); t->topviewmenu=glcreate_gl_topview_menu(); - load_host_buttons(t,g,t->topviewmenu); + //load_host_buttons(t,g,t->topviewmenu); + prepare_topological_fisheye(t); @@ -240,7 +242,7 @@ void drawTopViewGraph(Agraph_t *g) update_topview_node_from_cgraph(v); if( ((custom_object_data*)AGDATA(v->Node))->Selected==1) { - glColor4f(view->selectColor.R,view->selectColor.G,view->selectColor.B,view->selectColor.A); + glColor4f(view->selectedNodeColor.R,view->selectedNodeColor.G,view->selectedNodeColor.B,view->selectedNodeColor.A); ddx=dx;ddy=dy; } else //get the color from node @@ -559,7 +561,7 @@ int get_color_from_edge(topview_edge *e) ) { // glColor4f(0,0,1,1); - glColor4f(view->selectColor.R,view->selectColor.G,view->selectColor.B,view->selectColor.A); + glColor4f(view->selectedNodeColor.R,view->selectedNodeColor.G,view->selectedNodeColor.B,view->selectedNodeColor.A); return return_value; } if( ( ((custom_object_data*)AGDATA(e->Node1->Node))->Highlighted==1) @@ -1081,7 +1083,75 @@ glCompSet* glcreate_gl_topview_menu() return s; } -//calbacks + +void prepare_topological_fisheye(topview* t) +{ +/* To use: + double* x_coords; // initial x coordinates + double* y_coords; // initial y coordinates + focus_t* fs; + int ne; + vtx_data* graph = makeGraph (topview*, &ne); + hierarchy = makeHier(topview->NodeCount, ne, graph, x_coords, y_coords); + freeGraph (graph); + fs = initFocus (topview->Nodecount); // create focus set + + In loop, + update fs. + For example, if user clicks mouse at (p.x,p.y) to pick a single new focus, + int closest_fine_node; + find_closest_active_node(hierarchy, p.x, p.y, &closest_fine_node); + fs->num_foci = 1; + fs->foci_nodes[0] = closest_fine_node; + fs->x_foci[0] = hierarchy->geom_graphs[cur_level][closest_fine_node].x_coord; + fs->y_foci[0] = hierarchy->geom_graphs[cur_level][closest_fine_node].y_coord; + + + + set_active_levels(hierarchy, fs->foci_nodes, fs->num_foci); + positionAllItems(hierarchy, fs, parms) + + When done: + release (hierarchy); +*/ + double* x_coords=0; // initial x coordinates + double* y_coords=0; // initial y coordinates + focus_t* fs; + int ne; + int ind; + int closest_fine_node; + int cur_level=0; + hierparms_t parms; + vtx_data* graph = makeGraph (t, &ne); + t->h = makeHier(t->Nodecount, ne, graph, x_coords, y_coords); + freeGraph (graph); + fs = initFocus (t->Nodecount); // create focus set + + find_closest_active_node(t->h, 50.0, 50.0, &closest_fine_node); + fs->num_foci = 1; + fs->foci_nodes[0] = closest_fine_node; + fs->x_foci[0] = t->h->geom_graphs[cur_level][closest_fine_node].x_coord; + fs->y_foci[0] = t->h->geom_graphs[cur_level][closest_fine_node].y_coord; + + + set_active_levels(t->h, fs->foci_nodes, fs->num_foci); + positionAllItems(t->h, fs, &parms); + //DEBUG + //show coordinates and active levels + for (ind ; ind < t->Nodecount;ind ++) + { + + printf ("original coords (%f,%f)\n",t->Nodes[ind].x,t->Nodes[ind].y); + printf ("local coords (%f,%f)\n",t->h->geom_graphs[cur_level][ind].local_x_coord,t->h->geom_graphs[cur_level][ind].local_y_coord); + printf ("physical coords (%f,%f)\n",t->h->geom_graphs[cur_level][ind].new_physical_x_coord,t->h->geom_graphs[cur_level][ind].new_physical_y_coord); + printf ("local coords (%f,%f)\n",t->h->geom_graphs[cur_level][ind].local_x_coord,t->h->geom_graphs[cur_level][ind].local_y_coord); + } + + + + +} + diff --git a/cmd/smyrna/topview.h b/cmd/smyrna/topview.h index 1c5ded7f5..098555eb7 100755 --- a/cmd/smyrna/topview.h +++ b/cmd/smyrna/topview.h @@ -46,6 +46,7 @@ double dist(double x1, double y1, double x2, double y2); double G(double x); glCompSet* glcreate_gl_topview_menu(); void fisheye_polar(double x_focus, double y_focus,topview* t); +void prepare_topological_fisheye(topview* t); #endif diff --git a/cmd/smyrna/viewport.c b/cmd/smyrna/viewport.c index 306f31b84..24279377e 100755 --- a/cmd/smyrna/viewport.c +++ b/cmd/smyrna/viewport.c @@ -100,10 +100,10 @@ void init_viewport(ViewInfo* view) view->bgColor.A=1; //selected objets are drawn with this color - view->selectColor.R=1; - view->selectColor.G=0; - view->selectColor.B=0; - view->selectColor.A=1; + view->selectedNodeColor.R=1; + view->selectedNodeColor.G=0; + view->selectedNodeColor.B=0; + view->selectedNodeColor.A=1; //default line width; view->LineWidth=1; @@ -141,6 +141,7 @@ void init_viewport(ViewInfo* view) view->Selection.SelectionColor.A=1; view->Selection.Anti=0; view->Topview=malloc(sizeof(topview)); + view->Topview->topviewmenu='\0'; } int add_graph_to_viewport_from_file (char* fileName) diff --git a/lib/glcomp/glcompset.c b/lib/glcomp/glcompset.c index b8a0f9c6f..1e7674576 100644 --- a/lib/glcomp/glcompset.c +++ b/lib/glcomp/glcompset.c @@ -464,13 +464,16 @@ int glCompSetRelease(glCompSet* s,int x,int y) { int ind=0; - for (ind=0 ; ind < s->buttoncount; ind ++) + if (s) { - if((s->buttons[ind]->visible) && (s->buttons[ind]->enabled)) + for (ind=0 ; ind < s->buttoncount; ind ++) { - if((glCompPointInButton(s->buttons[ind],s->clickedX,s->clickedY))) + if((s->buttons[ind]->visible) && (s->buttons[ind]->enabled)) { - glCompButtonClick(s->buttons[ind]); + if((glCompPointInButton(s->buttons[ind],s->clickedX,s->clickedY))) + { + glCompButtonClick(s->buttons[ind]); + } } } } diff --git a/lib/topfish/delaunay.c b/lib/topfish/delaunay.c index 62ede31de..998793f60 100644 --- a/lib/topfish/delaunay.c +++ b/lib/topfish/delaunay.c @@ -126,6 +126,7 @@ vtx_data *UG_graph(double *x, double *y, int n, int accurate_computation) double dist_ij, dist_ik, dist_jk, x_i, y_i, x_j, y_j; int j, k, neighbor_j, neighbor_k; int removed; + int source, dest; in.pointlist = N_NEW(2 * n, REAL); for (i = 0; i < n; i++) { @@ -208,7 +209,6 @@ vtx_data *UG_graph(double *x, double *y, int n, int accurate_computation) delaunay[i].edges[0] = i; delaunay[i].nedges = 1; } - int source, dest; for (i = 0; i < nedges; i++) { source = out.edgelist[2 * i]; dest = out.edgelist[2 * i + 1]; diff --git a/lib/topfish/hierarchy.c b/lib/topfish/hierarchy.c index e2b25d601..cf74ffaef 100644 --- a/lib/topfish/hierarchy.c +++ b/lib/topfish/hierarchy.c @@ -164,11 +164,21 @@ static int maxmatch(vtx_data * graph, /* array of vtx data for graph */ int neighbor; /* neighbor of a vertex */ int nmerged = 0; /* number of edges in matching */ int i, j; /* loop counters */ + float max_norm_edge_weight; + double inv_size; + double *matchability = N_NEW(nvtxs, double); + double min_edge_len; + double closest_val = -1, val; + int closest_neighbor; + float *vtx_vec = N_NEW(nvtxs, float); + float *weighted_vtx_vec = N_NEW(nvtxs, float); + float sum_weights; // gather statistics, to enable normalizing the values double avg_edge_len = 0, avg_deg_2 = 0; int nedges = 0; - for (i = 0; i < nvtxs; i++) { + + for (i = 0; i < nvtxs; i++) { avg_deg_2 += graph[i].nedges; for (j = 1; j < graph[i].nedges; j++) { avg_edge_len += dist(geom_graph, i, graph[i].edges[j]); @@ -182,8 +192,6 @@ static int maxmatch(vtx_data * graph, /* array of vtx data for graph */ // the normalized edge weight of edge is defined as: // weight()/sqrt(size(v)*size(u)) // Now we compute the maximal normalized weight - float max_norm_edge_weight; - double inv_size; if (graph[0].ewgts != NULL) { max_norm_edge_weight = -1; for (i = 0; i < nvtxs; i++) { @@ -221,8 +229,6 @@ static int maxmatch(vtx_data * graph, /* array of vtx data for graph */ } */ // Option 2: sort the nodes begining with the ones highly approriate for matching - double *matchability = N_NEW(nvtxs, double); - double min_edge_len; for (i = 0; i < nvtxs; i++) { vtx = order[i]; matchability[vtx] = graph[vtx].nedges; // we less want to match high degree nodes @@ -241,11 +247,6 @@ static int maxmatch(vtx_data * graph, /* array of vtx data for graph */ free(matchability); // Start determining the matched pairs - double closest_val = -1, val; - int closest_neighbor; - float *vtx_vec = N_NEW(nvtxs, float); - float *weighted_vtx_vec = N_NEW(nvtxs, float); - float sum_weights; for (i = 0; i < nvtxs; i++) { vtx_vec[i] = 0; } @@ -1364,15 +1365,16 @@ static int isActiveAncestorOfNeighbors(Hierarchy * hierarchy, int node, int level, int activeAncestorIdx) { - int i; - vtx_data neighborsInLevel; + int i, active_level ; + + vtx_data neighborsInLevel; int neighbor, neighborLevel; assert(hierarchy); neighborsInLevel = hierarchy->graphs[level][node]; for (i = 1; i < neighborsInLevel.nedges; i++) { neighbor = neighborsInLevel.edges[i]; - int active_level = + active_level = hierarchy->geom_graphs[level][neighbor].active_level; if (active_level > level) { // ancestor of neighbor is active @@ -1402,7 +1404,7 @@ findGlobalIndexesOfActiveNeighbors(Hierarchy * hierarchy, int index, int numNeighbors = 0; int *neighbors; int i, j; - int level, node; + int level, node,active_level,found; vtx_data neighborsInLevel; int nAllocNeighbors; int *stack; // 4*hierarchy->nlevels should be enough for the DFS scan @@ -1423,7 +1425,7 @@ findGlobalIndexesOfActiveNeighbors(Hierarchy * hierarchy, int index, for (i = 1; i < neighborsInLevel.nedges; i++) { neighbor = neighborsInLevel.edges[i]; - int active_level = + active_level = hierarchy->geom_graphs[level][neighbor].active_level; if (active_level == level) { // neighbor is active - add it @@ -1442,7 +1444,7 @@ findGlobalIndexesOfActiveNeighbors(Hierarchy * hierarchy, int index, neighbor = hierarchy->v2cv[neighborLevel][neighbor]; neighborLevel++; } while (active_level > neighborLevel); - int found = 0; + found = 0; for (j = 0; j < numNeighbors && !found; j++) { if (neighbors[j] == hierarchy->geom_graphs[neighborLevel][neighbor]. diff --git a/lib/topfish/rescale_layout.c b/lib/topfish/rescale_layout.c index 972607e06..65b292a80 100644 --- a/lib/topfish/rescale_layout.c +++ b/lib/topfish/rescale_layout.c @@ -84,9 +84,10 @@ static double *smooth_vec(double *vec, int *ordering, int n, int interval, { // smooth 'vec' by setting each components to the average of is 'interval'-neighborhood in 'ordering' int len, i, n1; + double sum; smoothed_vec = RALLOC(n, smoothed_vec, double); n1 = MIN(1 + interval, n); - double sum = 0; + sum = 0; for (i = 0; i < n1; i++) { sum += vec[ordering[i]]; }