return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2) +
(z1 - z2) * (z1 - z2));
}
+static void drawtopologicalfisheyestatic(topview * t);
static double G(double x)
double distance, distorted_distance, ratio, range;
range = 0;
- for (i = 1; i < t->Nodecount; i++) {
- if (point_within_ellips_with_coords
- ((float) x_focus, (float) y_focus, (float) view->fmg.R,
- (float) view->fmg.R, t->Nodes[i].x, t->Nodes[i].y)) {
- range =
- MAX(range,
+ for (i = 1; i < t->Nodecount; i++)
+ {
+ if (point_within_ellips_with_coords
+ ((float) x_focus, (float) y_focus, (float) view->fmg.R,
+ (float) view->fmg.R, t->Nodes[i].x, t->Nodes[i].y))
+ {
+ range = MAX(range,
dist(t->Nodes[i].x, t->Nodes[i].y, x_focus, y_focus));
- }
+ }
}
- for (i = 1; i < t->Nodecount; i++) {
+ for (i = 1; i < t->Nodecount; i++)
+ {
- if (point_within_ellips_with_coords
- ((float) x_focus, (float) y_focus, (float) view->fmg.R,
- (float) view->fmg.R, t->Nodes[i].x, t->Nodes[i].y)) {
- distance =
- dist(t->Nodes[i].x, t->Nodes[i].y, x_focus, y_focus);
- distorted_distance = G(distance / range) * range;
- if (distance != 0) {
- ratio = distorted_distance / distance;
- } else {
- ratio = 0;
- }
- t->Nodes[i].distorted_x =
- (float) x_focus + (t->Nodes[i].x -
- (float) x_focus) * (float) ratio;
- t->Nodes[i].distorted_y =
- (float) y_focus + (t->Nodes[i].y -
- (float) y_focus) * (float) ratio;
- t->Nodes[i].zoom_factor =
- (float) 1 *(float) distorted_distance / (float) distance;
- } else {
- t->Nodes[i].distorted_x = t->Nodes[i].x;
- t->Nodes[i].distorted_y = t->Nodes[i].y;
- t->Nodes[i].zoom_factor = 1;
+ if (point_within_ellips_with_coords
+ ((float) x_focus, (float) y_focus, (float) view->fmg.R,
+ (float) view->fmg.R, t->Nodes[i].x, t->Nodes[i].y))
+ {
+ distance =
+ dist(t->Nodes[i].x, t->Nodes[i].y, x_focus, y_focus);
+ distorted_distance = G(distance / range) * range;
+ if (distance != 0)
+ {
+ ratio = distorted_distance / distance;
+ }
+ else
+ {
+ ratio = 0;
+ }
+ t->Nodes[i].distorted_x =
+ (float) x_focus + (t->Nodes[i].x - (float) x_focus) * (float) ratio;
+ t->Nodes[i].distorted_y =
+ (float) y_focus + (t->Nodes[i].y - (float) y_focus) * (float) ratio;
+ t->Nodes[i].zoom_factor =(float) 1 *(float) distorted_distance / (float) distance;
+ }
+ else
+ {
+ t->Nodes[i].distorted_x = t->Nodes[i].x;
+ t->Nodes[i].distorted_y = t->Nodes[i].y;
+ t->Nodes[i].zoom_factor = 1;
+ }
}
- }
}
void fisheye_spherical(double x_focus, double y_focus, double z_focus,
topview * t)
view->Topview->parms.repos.width =(int) (view->bdxRight-view->bdxLeft);
view->Topview->parms.repos.height =(int) (view->bdyTop-view->bdyBottom);
+ view->Topview->parms.repos.rescale=Polar;
+
sscanf(agget(view->g[0],"topologicalfisheyedistortionfactor"),"%lf",&view->Topview->parms.repos.distortion);
sscanf(agget(view->g[0],"topologicalfisheyefinenodes"),"%d",&view->Topview->parms.level.num_fine_nodes);
sscanf(agget(view->g[0],"topologicalfisheyecoarseningfactor"),"%lf",&view->Topview->parms.level.coarsening_rate);
sscanf(agget(view->g[0],"topologicalfisheyedist2limit"),"%d",&view->Topview->parms.hier.dist2_limit);
sscanf(agget(view->g[0],"topologicalfisheyeanimate"),"%d",&view->Topview->animate);
-
set_active_levels(hp, fs->foci_nodes, fs->num_foci, &(t->parms.level));
positionAllItems(hp, fs, &(t->parms.repos));
fontColorA(view->fontset->fonts[view->fontset->activefont],0, 0, 1, 1);
fontSize(view->fontset->fonts[view->fontset->activefont],fs);
fontDrawString(view->fontset->fonts[view->fontset->activefont],gg[v].physical_x_coord,gg[v].physical_y_coord, (fs*strlen(buf)*0.4),buf);
+ printf ("focus coords : %f , %f\n",gg[v].physical_x_coord,gg[v].physical_y_coord);
}
else if (finenodes)
{
{
get_active_frame(t);
drawtopfishnodes(t);
+// drawtopologicalfisheyestatic(t);
+
drawtopfishedges(t);
if(!t->animate)
drawtopfishnodelabels(t);
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].physical_x_coord;
+ hp->geom_graphs[cur_level][closest_fine_node].x_coord;
fs->y_foci[i] =
- hp->geom_graphs[cur_level][closest_fine_node].physical_y_coord;
+ 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);
+ set_active_levels(hp, fs->foci_nodes, fs->num_foci, &(t->parms.level));
positionAllItems(hp, fs, &(t->parms.repos));
}
+void drawtopologicalfisheyestatic(topview * t)
+{
+ int level, v, i, n;
+ Hierarchy* hp = t->h;
+
+ glPointSize(15);
+ glBegin(GL_POINTS);
+ for (level=0;level < hp->nlevels;level++) {
+ for (v=0;v < hp->nvtxs[level]; v++) {
+ ex_vtx_data* gg = hp->geom_graphs[level];
+ vtx_data* g = hp->graphs[level];
+ if(gg[v].active_level==level) {
+ double x0 = gg[v].physical_x_coord;
+ double y0 = gg[v].physical_y_coord;
+// glColor3f((GLfloat)(hp->nlevels-level)/(GLfloat)hp->nlevels,(GLfloat)level/(GLfloat)hp->nlevels,0);
+ glColor4f(0,1,0,0.2);
+ glVertex3f((GLfloat)x0,(GLfloat)y0,(GLfloat)0);
+ }
+ }
+ }
+ glEnd();
+
+
+
+
+/* glBegin(GL_LINES);
+ for (level=0;level < hp->nlevels;level++) {
+ for (v=0;v < hp->nvtxs[level]; v++) {
+ ex_vtx_data* gg = hp->geom_graphs[level];
+ vtx_data* g = hp->graphs[level];
+ if(gg[v].active_level==level) {
+ double x0 = gg[v].physical_x_coord;
+ double y0 = gg[v].physical_y_coord;
+
+ for (i=1;i < g[v].nedges;i++) {
+ double x,y;
+ n = g[v].edges[i];
+ glColor3f((GLfloat)(hp->nlevels-level)/(GLfloat)hp->nlevels,(GLfloat)level/(GLfloat)hp->nlevels,0);
+ if (gg[n].active_level == level) {
+ if (v < n) {
+ x = gg[n].physical_x_coord;
+ y = gg[n].physical_y_coord;
+ glVertex3f((GLfloat)x0,(GLfloat)y0,(GLfloat)0);
+ glVertex3f((GLfloat)x,(GLfloat)y,(GLfloat)0);
+ }
+ }
+ else if (gg[n].active_level > level) {
+ find_physical_coords(hp, level, n, &x, &y);
+ glVertex3f((GLfloat)x0,(GLfloat)y0,(GLfloat)0);
+ glVertex3f((GLfloat)x,(GLfloat)y,(GLfloat)0);
+ }
+ }
+ }
+ }
+ }
+ glEnd();*/
+}
+
int *ordering;
double ratio;
- for (i = 0; i < n; i++) {
- distances[i] = DIST(x_coords[i], y_coords[i], x_focus, y_focus);
+ for (i = 0; i < n; i++)
+ {
+ distances[i] = DIST(x_coords[i], y_coords[i], x_focus, y_focus);
}
cpvec(orig_distances, 0, n - 1, distances);
ordering = N_NEW(n, int);
- for (i = 0; i < n; i++) {
- ordering[i] = i;
+ for (i = 0; i < n; i++)
+ {
+ ordering[i] = i;
}
quicksort_place(distances, ordering, 0, n - 1);
smoothed_densities = smooth_vec(densities, ordering, n, interval, smoothed_densities);
// rescale distances
- if (distortion < 1.01 && distortion > 0.99) {
- for (i = 1; i < n; i++) {
- distances[ordering[i]] =
- distances[ordering[i - 1]] + (orig_distances[ordering[i]] -
+ if (distortion < 1.01 && distortion > 0.99)
+ {
+ for (i = 1; i < n; i++)
+ {
+ distances[ordering[i]] = distances[ordering[i - 1]] + (orig_distances[ordering[i]] -
orig_distances[ordering
[i -
1]]) / smoothed_densities[ordering[i]];
- }
- } else {
- double factor;
- // just to make milder behavior:
- if (distortion >= 0) {
- factor = sqrt(distortion);
- } else {
- factor = -sqrt(-distortion);
- }
- for (i = 1; i < n; i++) {
- distances[ordering[i]] =
- distances[ordering[i - 1]] + (orig_distances[ordering[i]] -
+ }
+ } else
+ {
+ double factor;
+ // just to make milder behavior:
+ if (distortion >= 0)
+ {
+ factor = sqrt(distortion);
+ }
+ else
+ {
+ factor = -sqrt(-distortion);
+ }
+ for (i = 1; i < n; i++)
+ {
+ distances[ordering[i]] =
+ distances[ordering[i - 1]] + (orig_distances[ordering[i]] -
orig_distances[ordering
[i -
1]]) /
- pow(smoothed_densities[ordering[i]], factor);
- }
+ pow(smoothed_densities[ordering[i]], factor);
+ }
}
// compute new coordinate:
- for (i = 0; i < n; i++) {
- if (orig_distances[i] == 0) {
- ratio = 0;
- } else {
- ratio = distances[i] / orig_distances[i];
- }
- x_coords[i] = x_focus + (x_coords[i] - x_focus) * ratio;
- y_coords[i] = y_focus + (y_coords[i] - y_focus) * ratio;
+ for (i = 0; i < n; i++)
+ {
+ if (orig_distances[i] == 0)
+ {
+ ratio = 0;
+ }
+ else
+ {
+ ratio = distances[i] / orig_distances[i];
+ }
+ x_coords[i] = x_focus + (x_coords[i] - x_focus) * ratio;
+ y_coords[i] = y_focus + (y_coords[i] - y_focus) * ratio;
}
free(densities);
width -= 2 * margin;
height -= 2 * margin;
+ printf ("polar focus coords : %f , %f\n",x_foci[0],y_foci[0]);
+
// compute original aspect ratio
minX = maxX = x_coords[0];
minY = maxY = y_coords[0];
- for (i = 1; i < n; i++) {
- if (x_coords[i] < minX)
- minX = x_coords[i];
- if (y_coords[i] < minY)
- minY = y_coords[i];
- if (x_coords[i] > maxX)
- maxX = x_coords[i];
- if (y_coords[i] > maxY)
- maxY = y_coords[i];
+ for (i = 1; i < n; i++)
+ {
+ if (x_coords[i] < minX)
+ minX = x_coords[i];
+ if (y_coords[i] < minY)
+ minY = y_coords[i];
+ if (x_coords[i] > maxX)
+ maxX = x_coords[i];
+ if (y_coords[i] > maxY)
+ maxY = y_coords[i];
}
aspect_ratio = (maxX - minX) / (maxY - minY);
// construct mutual neighborhood graph
graph = UG_graph(x_coords, y_coords, n, 0);
- if (num_foci == 1) { // accelerate execution of most common case
- rescale_layout_polarFocus(graph, n, x_coords, y_coords, x_foci[0],
+ if (num_foci == 1)
+ { // accelerate execution of most common case
+ rescale_layout_polarFocus(graph, n, x_coords, y_coords, x_foci[0],
y_foci[0], interval, distortion);
- } else {
+ } else
+ {
// average-based rescale
double *final_x_coords = N_NEW(n, double);
double *final_y_coords = N_NEW(n, double);