From feda1b55d1a91822db0fccc034617ab9b34cf2f3 Mon Sep 17 00:00:00 2001 From: arif Date: Tue, 16 Mar 2010 18:18:24 +0000 Subject: [PATCH] topological fisheye is back! but it doesnt have labels --- cmd/smyrna/gui/glcompui.c | 2 +- cmd/smyrna/smyrnadefs.h | 1 + cmd/smyrna/topfisheyeview.c | 84 +++++++++++++++++++++++++++++++------ cmd/smyrna/topfisheyeview.h | 2 +- cmd/smyrna/topviewfuncs.c | 9 ++-- cmd/smyrna/topviewfuncs.h | 2 +- cmd/smyrna/viewport.c | 2 +- 7 files changed, 82 insertions(+), 20 deletions(-) diff --git a/cmd/smyrna/gui/glcompui.c b/cmd/smyrna/gui/glcompui.c index e33869eef..cc9c74ed4 100644 --- a/cmd/smyrna/gui/glcompui.c +++ b/cmd/smyrna/gui/glcompui.c @@ -75,7 +75,7 @@ static void menu_switch_to_fisheye(glCompObj *obj, GLfloat x, GLfloat y, if (!view->Topview->fisheyeParams.active) { if (!view->Topview->fisheyeParams.h) { - prepare_topological_fisheye(view->Topview); + prepare_topological_fisheye(view->g[view->activeGraph],view->Topview); g_timer_start(view->timer); } view->Topview->fisheyeParams.active = 1; diff --git a/cmd/smyrna/smyrnadefs.h b/cmd/smyrna/smyrnadefs.h index 6f9f05816..c9067ed4e 100644 --- a/cmd/smyrna/smyrnadefs.h +++ b/cmd/smyrna/smyrnadefs.h @@ -391,6 +391,7 @@ typedef struct int selected; int visible; int printLabel; + int TVref; }nodeRec; typedef struct{ Agrec_t h; diff --git a/cmd/smyrna/topfisheyeview.c b/cmd/smyrna/topfisheyeview.c index e8bd14281..a39d055d9 100644 --- a/cmd/smyrna/topfisheyeview.c +++ b/cmd/smyrna/topfisheyeview.c @@ -185,7 +185,63 @@ void fisheye_spherical(double x_focus, double y_focus, double z_focus, } } -static v_data *makeGraph(topview * tv, int *nedges) +static v_data *makeGraph(Agraph_t* gg, int *nedges) +{ + int i; + int ne = agnedges(gg); + int nv = agnnodes(gg); + v_data *graph = N_NEW(nv, v_data); + int *edges = N_NEW(2 * ne + nv, int); /* reserve space for self loops */ + float *ewgts = N_NEW(2 * ne + nv, float); + Agnode_t *np; + Agedge_t *ep; + Agraph_t *g = NULL; + int i_nedges; + ne = 0; + i=0; +// for (i = 0; i < nv; i++) { + for (np = agfstnode(gg); np; np = agnxtnode(gg, np)) + { + graph[i].edges = edges++; /* reserve space for the self loop */ + graph[i].ewgts = ewgts++; +#ifdef STYLES + graph[i].styles = NULL; +#endif + i_nedges = 1; /* one for the self */ + + if (!g) + g = agraphof(np); + for (ep = agfstedge(g, np); ep; ep = agnxtedge(g, ep, np)) + { + Agnode_t *vp; + Agnode_t *tp = agtail(ep); + Agnode_t *hp = aghead(ep); + assert(hp != tp); + /* FIX: handle multiedges */ + vp = (tp == np ? hp : tp); + ne++; + i_nedges++; +// *edges++ = ((temp_node_record *) AGDATA(vp))->TVref; + *edges++ =((nodeRec*)(aggetrec(vp,"nodeRec",0)))->TVref; + *ewgts++ = 1; + + } + + graph[i].nedges = i_nedges; + graph[i].edges[0] = i; + graph[i].ewgts[0] = 1 - i_nedges; + i++; + } + ne /= 2; /* each edge counted twice */ + *nedges = ne; + return graph; +} + + + + + +static v_data *makeGraph_old(topview * tv, int *nedges) { int i; int ne = tv->Edgecount; /* upper bound */ @@ -210,7 +266,8 @@ static v_data *makeGraph(topview * tv, int *nedges) np = tv->Nodes[i].Node; if (!g) g = agraphof(np); - for (ep = agfstedge(g, np); ep; ep = agnxtedge(g, ep, np)) { + for (ep = agfstedge(g, np); ep; ep = agnxtedge(g, ep, np)) + { Agnode_t *vp; Agnode_t *tp = agtail(ep); Agnode_t *hp = aghead(ep); @@ -243,7 +300,7 @@ static v_data *makeGraph(topview * tv, int *nedges) * freeGraph (graph); * fs = initFocus (topview->Nodecount); // create focus set */ -void prepare_topological_fisheye(topview * t) +void prepare_topological_fisheye(Agraph_t* g,topview * t) { double *x_coords = N_NEW(t->Nodecount, double); // initial x coordinates double *y_coords = N_NEW(t->Nodecount, double); // initial y coordinates @@ -254,24 +311,27 @@ void prepare_topological_fisheye(topview * t) int cur_level = 0; Hierarchy *hp; ex_vtx_data *gg; - topview_node *np; gvcolor_t cl; + Agnode_t *np; - v_data *graph = makeGraph(t, &ne); + v_data *graph = makeGraph(g, &ne); // t->fisheyeParams.animate=1; //turn the animation on - for (i = 0, np = t->Nodes; i < t->Nodecount; i++, np++) { - x_coords[i] = np->x; - y_coords[i] = np->y; + i=0; + for (np = agfstnode(g); np; np = agnxtnode(g, np)) + { + x_coords[i]=((nodeRec*)(aggetrec(np,"nodeRec",0)))->A.x; + y_coords[i]=((nodeRec*)(aggetrec(np,"nodeRec",0)))->A.y; + i++; } hp = t->fisheyeParams.h = - makeHier(t->Nodecount, ne, graph, x_coords, y_coords, + makeHier(agnnodes(g), ne, graph, x_coords, y_coords, &(t->fisheyeParams.hier)); freeGraph(graph); free(x_coords); free(y_coords); - fs = t->fisheyeParams.fs = initFocus(t->Nodecount); // create focus set + fs = t->fisheyeParams.fs = initFocus(agnnodes(g)); // create focus set gg = hp->geom_graphs[0]; closest_fine_node = 0; /* first node */ @@ -539,8 +599,8 @@ void drawtopologicalfisheye(topview * t) get_active_frame(t); drawtopfishnodes(t); drawtopfishedges(t); - if (!t->fisheyeParams.animate) - drawtopfishnodelabels(t); +/* if (!t->fisheyeParams.animate) + drawtopfishnodelabels(t);*/ } diff --git a/cmd/smyrna/topfisheyeview.h b/cmd/smyrna/topfisheyeview.h index 941002cb6..51d4e762c 100644 --- a/cmd/smyrna/topfisheyeview.h +++ b/cmd/smyrna/topfisheyeview.h @@ -26,7 +26,6 @@ extern "C" { void fisheye_polar(double x_focus, double y_focus, topview * t); void fisheye_spherical(double x_focus, double y_focus, double z_focus, topview * t); - void prepare_topological_fisheye(topview *); void drawtopologicalfisheye(topview * t); void drawtopologicalfisheye2(topview * t); void changetopfishfocus(topview * t, float *x, float *y, @@ -36,6 +35,7 @@ extern "C" { double y1, int fr, int total_fr, double *x, double *y); int get_active_frame(topview * t); + void prepare_topological_fisheye(Agraph_t* g,topview * t); #ifdef __cplusplus } /* end extern "C" */ diff --git a/cmd/smyrna/topviewfuncs.c b/cmd/smyrna/topviewfuncs.c index 23ec52b81..e3a3cbe47 100644 --- a/cmd/smyrna/topviewfuncs.c +++ b/cmd/smyrna/topviewfuncs.c @@ -288,6 +288,7 @@ void renderNodes(Agraph_t * g) static GLfloat nodeSize=0; static glCompColor c; xdot * x; + int ind; defaultNodeShape=getAttrBool(g,g,"defaultnodeshape",0); @@ -321,10 +322,11 @@ void renderNodes(Agraph_t * g) - + ind=0; for (v = agfstnode(g); v; v = agnxtnode(g, v)) { + ((nodeRec*)(aggetrec(v,"nodeRec",0)))->TVref=ind; if(!object_color(v,&c)) { ((nodeRec*)(aggetrec(v,"nodeRec",0)))->visible=0; @@ -355,6 +357,7 @@ void renderNodes(Agraph_t * g) glVertex3f(pos.x,pos.y,pos.z); else if (defaultNodeShape == 1) drawCircle(pos.x,pos.y,nodeSize,pos.z); + ind++; } if(defaultNodeShape==0) glEnd(); @@ -708,9 +711,8 @@ void updateSmGraph(Agraph_t * g,topview* t) cacheNodeLabels(g,t); cacheEdgeLabels(g,t); } -topview* initSmGraph(Agraph_t * g) +void initSmGraph(Agraph_t * g,topview* rv) { - topview* rv=(topview*)malloc(sizeof(topview)); rv->maxnodedegree = 1; @@ -736,7 +738,6 @@ topview* initSmGraph(Agraph_t * g) rv->sel.selectNodes=1; updateSmGraph(g,rv); - return rv; } void renderSmGraph(Agraph_t * g,topview* t) diff --git a/cmd/smyrna/topviewfuncs.h b/cmd/smyrna/topviewfuncs.h index 2996c4140..bf68dacd2 100644 --- a/cmd/smyrna/topviewfuncs.h +++ b/cmd/smyrna/topviewfuncs.h @@ -23,7 +23,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 initSmGraph(Agraph_t * g,topview* rv); extern void updateSmGraph(Agraph_t * g,topview* t); extern void renderSmGraph(Agraph_t * g,topview* t); extern void freeSmGraph(Agraph_t * g,topview* t); diff --git a/cmd/smyrna/viewport.c b/cmd/smyrna/viewport.c index ed3f71614..28ab15df1 100755 --- a/cmd/smyrna/viewport.c +++ b/cmd/smyrna/viewport.c @@ -642,7 +642,7 @@ void refreshViewport(int doClear) load_settings_from_graph(graph); update_graph_from_settings(graph); set_viewport_settings_from_template(view, graph); - view->Topview=initSmGraph(graph); + initSmGraph(graph,view->Topview); // update_topview(graph, view->Topview, 1); fill_key(view->orig_key, get_md5_key(graph)); -- 2.40.0