]> granicus.if.org Git - graphviz/commitdiff
Make the rescaling functions more consistent
authorerg <devnull@localhost>
Tue, 1 Apr 2008 16:39:11 +0000 (16:39 +0000)
committererg <devnull@localhost>
Tue, 1 Apr 2008 16:39:11 +0000 (16:39 +0000)
Add additional comments

cmd/smyrna/hier.c
cmd/smyrna/hier.h
cmd/smyrna/topview.c
lib/topfish/hierarchy.h
lib/topfish/rescale_layout.c

index ea9389888f487c154fc3ed1869dd82ff3d44d085..8fe9f75c54040147b85f31cee287e1958d465143 100644 (file)
@@ -37,8 +37,6 @@
         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)
  */
 static void
 scale_coords(double *x_coords, double *y_coords, int n,
-            hierparms_t * parms)
+            double w, double h, double margin)
 {
     int i;
-    double w = parms->ClientWidth;
-    double h = parms->ClientHeight;
-    double margin = parms->margin;
     double minX, maxX, minY, maxY;
     double scale_ratioX;
     double scale_ratioY;
     double scale_ratio;
 
-    w *= parms->graphSize / 100.0;
-    h *= parms->graphSize / 100.0;
     w -= 2 * margin;
     h -= 2 * margin;
 
@@ -108,9 +101,9 @@ void positionAllItems(Hierarchy * hp, focus_t * fs, hierparms_t * parms)
     double *x_coords = N_NEW(hp->nvtxs[0], double);
     double *y_coords = N_NEW(hp->nvtxs[0], double);
     int max_level = hp->nlevels - 1;   // coarsest level
-    int ClientWidth = parms->ClientWidth;
-    int ClientHeight = parms->ClientHeight;
-    int margin = parms->margin;
+    double width = parms->width;
+    double height = parms->height;
+    double margin = parms->margin;
 
     /* get all logical coordinates of active nodes */
     for (i = 0; i < hp->nvtxs[max_level]; i++) {
@@ -122,23 +115,24 @@ void positionAllItems(Hierarchy * hp, focus_t * fs, hierparms_t * parms)
     /* distort logical coordinates in order to get uniform density
      * (equivalent to concentrating on the focus area)
      */
+    width *= parms->graphSize / 100.0;
+    height *= parms->graphSize / 100.0;
     if (fs->num_foci == 0) {
-       if (parms->rescale_type == Scale)
-           scale_coords(x_coords, y_coords, counter, parms);
+       if (parms->rescale == Scale)
+           scale_coords(x_coords, y_coords, counter, width, height, margin);
     } else
-       switch (parms->rescale_type) {
+       switch (parms->rescale) {
        case Polar:
            rescale_layout_polar(x_coords, y_coords, fs->x_foci,
                                 fs->y_foci, fs->num_foci, counter,
-                                interval, ClientWidth, ClientHeight,
-                                margin);
+                                interval, width, height, margin);
            break;
        case Rectilinear:
            rescale_layout(x_coords, y_coords, counter, interval,
-                          ClientWidth, ClientHeight, margin);
+                          width, height, margin);
            break;
        case Scale:
-           scale_coords(x_coords, y_coords, counter, parms);
+           scale_coords(x_coords, y_coords, counter, width, height, margin);
            break;
        case NoRescale:
            break;
index 3392fd7f8034d31b11d6686aea91918ee4164bda..7fa407f956c32e002703ddc4beaf55ae3e1b9683 100644 (file)
@@ -25,14 +25,25 @@ typedef struct {
     double *y_foci;
 } focus_t;
 
+/* Conversion from logical to physical coordinates:
+ * NoRescale - simple copy
+ * For Scale, Polar and Rectilinear, the coordinates are all
+ * scaled and translated to map into the rectangle
+ *   ((margin,margin),(w,h)) 
+ * where w = width*graphSize/100 - 2*margin
+ * and   h = height*graphSize/100 - 2*margin
+ * 
+ * For Scale, this is all that is done.
+ * For Polar and Rectilinear, more space is provided around the foci. 
+ */
 typedef enum {NoRescale, Scale, Polar, Rectilinear} RescaleType;
 
 typedef struct {
-    int graphSize;
-    int ClientWidth;
-    int ClientHeight;
-    int margin;
-    RescaleType rescale_type;
+    int width;      /* viewport width */
+    int height;     /* viewport height */
+    int margin;     /* viewport margin */
+    int graphSize;  /* viewport scale : 0 -- 100 */
+    RescaleType rescale;
 } hierparms_t;
 
 void positionAllItems(Hierarchy * hp, focus_t * fs, hierparms_t * parms);
index 54068ab398e653ce4a04a26dc0cc100e496a53da..17bec3ca9f6478d086d13d583b30a2309e2ce7e5 100755 (executable)
@@ -1185,5 +1185,7 @@ void prepare_topological_fisheye(topview * t)
        t->h->geom_graphs[cur_level][closest_fine_node].y_coord;
 
     set_active_levels(t->h, fs->foci_nodes, fs->num_foci);
+
+    parms.rescale = NoRescale;
     positionAllItems(t->h, fs, &parms);
 }
index 7f62c57def6eb24082d37ead14a420411b3bcbc5..88e4b12995ba90af8d6f1eddebc5284811028a04 100644 (file)
@@ -77,11 +77,11 @@ vtx_data *UG_graph(double *x, double *y, int n, int accurate_computation);
 
 // layout distortion:
 void rescale_layout(double *x_coords, double *y_coords,
-    int n, int interval, int width, int height,
-    int margin);
+    int n, int interval, double width, double height,
+    double margin);
 void rescale_layout_polar(double * x_coords, double * y_coords, 
     double * x_foci, double * y_foci, int num_foci,
-    int n, int interval, int width, int height, int margin);
+    int n, int interval, double width, double height, double margin);
 
 void find_physical_coords(Hierarchy*, int, int, double *x, double *y);
 int find_active_ancestor(Hierarchy*, int, int);
index dfaea8d1bcb7825a9ab0c5c2bc8135ff177bb97c..c619f13533c4e4a6ea8a4f4851939e11721a2a5a 100644 (file)
@@ -248,8 +248,8 @@ rescaleLayout(vtx_data * graph, int n, double *x_coords, double *y_coords,
 
 void
 rescale_layout(double *x_coords, double *y_coords,
-              int n, int interval, int width, int height,
-              int margin)
+              int n, int interval, double width, double height,
+              double margin)
 {
     // Rectlinear distortion - main function
     int i;
@@ -402,8 +402,8 @@ rescale_layout_polarFocus(vtx_data * graph, int n,
 void
 rescale_layout_polar(double *x_coords, double *y_coords,
                     double *x_foci, double *y_foci, int num_foci,
-                    int n, int interval, int width,
-                    int height, int margin)
+                    int n, int interval, double width,
+                    double height, double margin)
 {
     // Polar distortion - main function
     int i;