]> granicus.if.org Git - graphviz/commitdiff
topological fisheye is back!
authorarif <devnull@localhost>
Tue, 16 Mar 2010 18:18:24 +0000 (18:18 +0000)
committerarif <devnull@localhost>
Tue, 16 Mar 2010 18:18:24 +0000 (18:18 +0000)
but it doesnt have labels

cmd/smyrna/gui/glcompui.c
cmd/smyrna/smyrnadefs.h
cmd/smyrna/topfisheyeview.c
cmd/smyrna/topfisheyeview.h
cmd/smyrna/topviewfuncs.c
cmd/smyrna/topviewfuncs.h
cmd/smyrna/viewport.c

index e33869eef8d909a35c82d0989bb0953eaf086390..cc9c74ed49ba3f6b0173d50ced13e9de8df57963 100644 (file)
@@ -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;
index 6f9f058166032a0744fcdf14c0ddbeab43717089..c9067ed4e1dc3fd755af90a2d998a2dc954ae5c2 100644 (file)
@@ -391,6 +391,7 @@ typedef struct
        int selected;
        int visible;
        int printLabel;
+       int TVref;
     }nodeRec;
     typedef struct{
        Agrec_t h;
index e8bd1428167bb7ed55cd444135ae89979ad7f2a6..a39d055d945e50c3582d3a6ea62efff63704e5e7 100644 (file)
@@ -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);*/
 
 }
 
index 941002cb652fa746e06343683e005d9e1407fd53..51d4e762cd60e5027bc40ef6207ce279ead800a4 100644 (file)
@@ -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" */
index 23ec52b8182c42804cc45285ab5608fcca486dbb..e3a3cbe47b913479d0b10bc14813b45172a722ca 100644 (file)
@@ -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)
index 2996c41400a6570c7831eb5d70814d1803c6c4bb..bf68dacd2c83e5e9d51f2802738b86771d91dc0c 100644 (file)
@@ -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);
index ed3f716144d33ed1622add0d0fea4f5d23454c1f..28ab15df169504843d265b044f3b73be0aa6f64e 100755 (executable)
@@ -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));