/* 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) */ void changetopfishfocus(topview * t, float *x, float *y, float *z, int num_foci) { focus_t *fs = t->fs; int i; int closest_fine_node; int cur_level = 0; Hierarchy *hp = t->h; refresh_old_values(t); fs->num_foci = num_foci; for (i = 0; i < num_foci; i++) { find_closest_active_node(hp, x[i], y[i], &closest_fine_node); fs->foci_nodes[i] = closest_fine_node; fs->x_foci[i] = hp->geom_graphs[cur_level][closest_fine_node].x_coord; fs->y_foci[i] = hp->geom_graphs[cur_level][closest_fine_node].y_coord; } set_active_levels(hp, fs->foci_nodes, fs->num_foci, &(t->parms.level)); view->Topview->parms.repos.width =(int) (view->bdxRight-view->bdxLeft); view->Topview->parms.repos.height =(int) (view->bdyTop-view->bdyBottom); positionAllItems(hp, fs, &(t->parms.repos)); t->animate=1; if(t->animate) { view->active_frame=0; g_timer_start(view->timer); } }
/* To use: * double* x_coords; // initial x coordinates * double* y_coords; // initial y coordinates * focus_t* fs; * int ne; * v_data* graph = makeGraph (topview*, &ne); * hierarchy = makeHier(topview->NodeCount, ne, graph, x_coords, y_coords); * freeGraph (graph); * fs = initFocus (topview->Nodecount); // create focus set */ void prepare_topological_fisheye(topview* t) { double *x_coords = N_NEW(t->Nodecount, double); // initial x coordinates double *y_coords = N_NEW(t->Nodecount, double); // initial y coordinates focus_t *fs; int ne; int i; int closest_fine_node; int cur_level = 0; Hierarchy *hp; ex_vtx_data *gg; topview_node *np; v_data *graph = makeGraph(t, &ne); // t->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; } hp = t->h = makeHier(t->Nodecount, ne, graph, x_coords, y_coords, &(t->parms.hier)); freeGraph(graph); free(x_coords); free(y_coords); fs = t->fs = initFocus(t->Nodecount); // create focus set gg = hp->geom_graphs[0]; closest_fine_node = 0; /* first node */ fs->num_foci = 1; fs->foci_nodes[0] = closest_fine_node; fs->x_foci[0] = hp->geom_graphs[cur_level][closest_fine_node].x_coord; fs->y_foci[0] = hp->geom_graphs[cur_level][closest_fine_node].y_coord; view->Topview->parms.repos.width =(int) (view->bdxRight-view->bdxLeft); view->Topview->parms.repos.height =(int) (view->bdyTop-view->bdyBottom); set_active_levels(hp, fs->foci_nodes, fs->num_foci, &(t->parms.level)); positionAllItems(hp, fs, &(t->parms.repos)); refresh_old_values(t); /* fprintf (stderr, "No. of active nodes = %d\n", count_active_nodes(hp)); */ }
void changetopfishfocus(topview * t, float *x, float *y, float *z, int num_foci) { gvcolor_t cl; focus_t *fs = t->fisheyeParams.fs; int i; int closest_fine_node; int cur_level = 0; Hierarchy *hp = t->fisheyeParams.h; refresh_old_values(t); fs->num_foci = num_foci; for (i = 0; i < num_foci; i++) { find_closest_active_node(hp, x[i], y[i], &closest_fine_node); fs->foci_nodes[i] = closest_fine_node; fs->x_foci[i] = hp->geom_graphs[cur_level][closest_fine_node].x_coord; fs->y_foci[i] = hp->geom_graphs[cur_level][closest_fine_node].y_coord; } view->Topview->fisheyeParams.repos.width = (int) (view->bdxRight - view->bdxLeft); view->Topview->fisheyeParams.repos.height = (int) (view->bdyTop - view->bdyBottom); colorxlate(get_attribute_value ("topologicalfisheyefinestcolor", view, view->g[view->activeGraph]), &cl, RGBA_DOUBLE); view->Topview->fisheyeParams.srcColor.R = (float) cl.u.RGBA[0]; view->Topview->fisheyeParams.srcColor.G = (float) cl.u.RGBA[1]; view->Topview->fisheyeParams.srcColor.B = (float) cl.u.RGBA[2]; colorxlate(get_attribute_value ("topologicalfisheyecoarsestcolor", view, view->g[view->activeGraph]), &cl, RGBA_DOUBLE); view->Topview->fisheyeParams.tarColor.R = (float) cl.u.RGBA[0]; view->Topview->fisheyeParams.tarColor.G = (float) cl.u.RGBA[1]; view->Topview->fisheyeParams.tarColor.B = (float) cl.u.RGBA[2]; sscanf(agget (view->g[view->activeGraph], "topologicalfisheyedistortionfactor"), "%lf", &view->Topview->fisheyeParams.repos.distortion); sscanf(agget (view->g[view->activeGraph], "topologicalfisheyefinenodes"), "%d", &view->Topview->fisheyeParams.level.num_fine_nodes); sscanf(agget (view->g[view->activeGraph], "topologicalfisheyecoarseningfactor"), "%lf", &view->Topview->fisheyeParams.level.coarsening_rate); sscanf(agget (view->g[view->activeGraph], "topologicalfisheyedist2limit"), "%d", &view->Topview->fisheyeParams.hier.dist2_limit); sscanf(agget(view->g[view->activeGraph], "topologicalfisheyeanimate"), "%d", &view->Topview->fisheyeParams.animate); set_active_levels(hp, fs->foci_nodes, fs->num_foci, &(t->fisheyeParams.level)); positionAllItems(hp, fs, &(t->fisheyeParams.repos)); view->Topview->fisheyeParams.animate = 1; if (t->fisheyeParams.animate) { view->active_frame = 0; g_timer_start(view->timer); } }
/* To use: * double* x_coords; // initial x coordinates * double* y_coords; // initial y coordinates * focus_t* fs; * int ne; * v_data* graph = makeGraph (topview*, &ne); * hierarchy = makeHier(topview->NodeCount, ne, graph, x_coords, y_coords); * freeGraph (graph); * fs = initFocus (topview->Nodecount); // create focus set */ 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 focus_t *fs; int ne; int i; int closest_fine_node; int cur_level = 0; Hierarchy *hp; ex_vtx_data *gg; gvcolor_t cl; Agnode_t *np; v_data *graph = makeGraph(g, &ne); // t->fisheyeParams.animate=1; //turn the animation on i=0; for (np = agfstnode(g); np; np = agnxtnode(g, np)) { x_coords[i]=ND_A(np).x; y_coords[i]=ND_A(np).y; i++; } hp = t->fisheyeParams.h = 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(agnnodes(g)); // create focus set gg = hp->geom_graphs[0]; closest_fine_node = 0; /* first node */ fs->num_foci = 1; fs->foci_nodes[0] = closest_fine_node; fs->x_foci[0] = hp->geom_graphs[cur_level][closest_fine_node].x_coord; fs->y_foci[0] = hp->geom_graphs[cur_level][closest_fine_node].y_coord; view->Topview->fisheyeParams.repos.width = (int) (view->bdxRight - view->bdxLeft); view->Topview->fisheyeParams.repos.height = (int) (view->bdyTop - view->bdyBottom); view->Topview->fisheyeParams.repos.rescale = Polar; //topological fisheye colorxlate(get_attribute_value ("topologicalfisheyefinestcolor", view, view->g[view->activeGraph]), &cl, RGBA_DOUBLE); view->Topview->fisheyeParams.srcColor.R = (float) cl.u.RGBA[0]; view->Topview->fisheyeParams.srcColor.G = (float) cl.u.RGBA[1]; view->Topview->fisheyeParams.srcColor.B = (float) cl.u.RGBA[2]; colorxlate(get_attribute_value ("topologicalfisheyecoarsestcolor", view, view->g[view->activeGraph]), &cl, RGBA_DOUBLE); view->Topview->fisheyeParams.tarColor.R = (float) cl.u.RGBA[0]; view->Topview->fisheyeParams.tarColor.G = (float) cl.u.RGBA[1]; view->Topview->fisheyeParams.tarColor.B = (float) cl.u.RGBA[2]; sscanf(agget (view->g[view->activeGraph], "topologicalfisheyedistortionfactor"), "%lf", &view->Topview->fisheyeParams.repos.distortion); sscanf(agget (view->g[view->activeGraph], "topologicalfisheyefinenodes"), "%d", &view->Topview->fisheyeParams.level.num_fine_nodes); sscanf(agget (view->g[view->activeGraph], "topologicalfisheyecoarseningfactor"), "%lf", &view->Topview->fisheyeParams.level.coarsening_rate); sscanf(agget (view->g[view->activeGraph], "topologicalfisheyedist2limit"), "%d", &view->Topview->fisheyeParams.hier.dist2_limit); sscanf(agget(view->g[view->activeGraph], "topologicalfisheyeanimate"), "%d", &view->Topview->fisheyeParams.animate); set_active_levels(hp, fs->foci_nodes, fs->num_foci, &(t->fisheyeParams.level)); positionAllItems(hp, fs, &(t->fisheyeParams.repos)); refresh_old_values(t); /* fprintf (stderr, "No. of active nodes = %d\n", count_active_nodes(hp)); */ }