]> granicus.if.org Git - graphviz/commitdiff
Add additional flags, including -c_opacity;
authorEmden Gansner <erg@research.att.com>
Wed, 8 Feb 2012 21:17:16 +0000 (16:17 -0500)
committerEmden Gansner <erg@research.att.com>
Wed, 8 Feb 2012 21:17:16 +0000 (16:17 -0500)
update man page and usage;
fix man page to describe cluster and clustercolor attributes

cmd/gvmap/DotIO.c
cmd/gvmap/colorutil.c
cmd/gvmap/colorutil.h
cmd/gvmap/gvmap.1
cmd/gvmap/gvmap.c
cmd/gvmap/make_map.c
cmd/gvmap/make_map.h

index 0be541188a8ffb983f8db6f7f7f238036edbd7be..d3a4208cc398b60a670a6166cdb1d571f18b785e 100644 (file)
@@ -545,7 +545,7 @@ void Dot_SetClusterColor(Agraph_t* g, float *rgb_r,  float *rgb_g,  float *rgb_b
   for (n = agfstnode (g); n; n = agnxtnode (g, n)) {
     i = ND_id(n);
     if (rgb_r && rgb_g && rgb_b) {
-      rgb2hex((rgb_r)[(clusters)[i]],(rgb_g)[(clusters)[i]],(rgb_b)[(clusters)[i]], scluster);
+      rgb2hex((rgb_r)[(clusters)[i]],(rgb_g)[(clusters)[i]],(rgb_b)[(clusters)[i]], scluster, NULL);
       //sprintf(scluster,"#%2x%2x%2x", (int) (255*((rgb_r)[(clusters)[i]])), (int) (255*((rgb_g)[(clusters)[i]])), (int) (255*((rgb_b)[(clusters)[i]])));
     }
     agxset(n,clust_clr_sym,scluster);
@@ -695,7 +695,7 @@ SparseMatrix Import_coord_clusters_from_dot(Agraph_t* g, int maxcluster, int dim
   }
 
   *label_sizes = MALLOC(sizeof(real)*dim*nnodes);
-  if (pal){
+  if (pal || (!noclusterinfo && clust_clr_sym)){
     *rgb_r = MALLOC(sizeof(float)*(1+MAX_GRPS));
     *rgb_g = MALLOC(sizeof(float)*(1+MAX_GRPS));
     *rgb_b = MALLOC(sizeof(float)*(1+MAX_GRPS));
index 4cf5d9a8be10e665f1dfec936e6a23ed14c9623b..4239fc65985aba2be9926eabbe346858a9f077a1 100644 (file)
@@ -24,15 +24,19 @@ static void r2hex(float r, char *h){
   h[1] = hex[j];
 }
 
-void rgb2hex(float r, float g, float b, char *cstring){
+void rgb2hex(float r, float g, float b, char *cstring, char *opacity){
   cstring[0] = '#';
   r2hex(r, &(cstring[1]));
   r2hex(g, &(cstring[3]));
   r2hex(b, &(cstring[5]));
   //set to semitransparent for multiple sets vis
-  //cstring[7] = cstring[8] = '3';
-  //cstring[9]='\0';
-  cstring[7] = '\0';
+  if (opacity && strlen(opacity) >= 2){
+    cstring[7] = opacity[0];
+    cstring[8] = opacity[1];
+    cstring[9]='\0';
+  } else {
+    cstring[7] = '\0';
+  }
 }
 
 real Hue2RGB(real v1, real v2, real H) {
index e3a7daa1a302224cfb8f5b2236aa20d8774de269..03116f111b3fba4029d5fcfa53dfb3d4499f9059 100644 (file)
@@ -18,7 +18,7 @@
 
 extern int colorxlate(char *str, gvcolor_t * color, color_type_t target_type);
 
-void rgb2hex(float r, float g, float b, char *cstring);/* dimension of cstring must be >=7 */
+void rgb2hex(float r, float g, float b, char *cstring, char* opacity);/* dimension of cstring must be >=7 */
 char* hue2rgb(real hue, char *color);
 void hue2rgb_real(real hue, real *color);
 
index 49419f255021d246637e0cd5c7394eff9bf17182..e2d537940d8a7e3ff226dc29de77e2de16b59aa6 100644 (file)
@@ -8,7 +8,6 @@
 gvmap \- find clusters and create a geographical map highlighting clusters.
 .SH SYNOPSIS
 .B gvmap
-[\fB\-ekv?\fP]
 [
 .I options
 ]
@@ -21,10 +20,11 @@ gvmap \- find clusters and create a geographical map highlighting clusters.
 ]
 .SH DESCRIPTION
 .B gvmap
-takes as input a graph in DOT format, finds node clusters and produces a rendering of the graph as a geographic-style map, with clusters highlighted, in xdot format.
+takes as input a graph in DOT format, finds node clusters and produces a rendering of the graph as a geographic-style map, with clusters highlighted
+as countries, in xdot format.
 .P
-The input graph must have node positions and width/height information defined
-and nodes must not overlap.
+In the input graph, each node must have position, width and height information (pos, width and height attributes
+respectively) defined, and nodes must not overlap.
 .P
 By default, 
 .B gvmap
@@ -36,7 +36,9 @@ all nodes must have a valid value.
 .P
 If the input specifies the desired clustering as described above, it can also
 specify a desired coloring by having some node in each cluster provide a
-\fIclustercolor\fP attribute.
+\fIclustercolor\fP attribute. \fBN.B.\fP Unless one specifies \fI-c0\fP, only the \fIclustercolor\fP
+of the last node in a cluster has an effect. In addition, unless one uses \fI-O\fP, \fBgvmap\fP may
+permute the given colors.
 .SH OPTIONS
 The following options are supported:
 .TP
@@ -65,6 +67,9 @@ The integer k specifies color scheme used to color the countries. By default k =
    7 : sequential single hue lighter red
    8 : light grey
 .TP
+.BI \-c_opacity= xy
+Specifies a two-character hexadecimal string specifying the opacity of the polygons.
+.TP
 .BI \-C " d"
 The integer d specifies the maximum number of clusters (countries) allowed. By default d = 0, which means that there is no limit.
 .TP
@@ -77,26 +82,53 @@ If specified, edges will be included in the final output.
 .BI \-g " c"
 Specifies the bounding box color. If not specified, a bounding box is not drawn. 
 .TP
+.BI \-h " k"
+The number of artificial points added to maintain a bridge between endpoints. By default, this is zero.
+.TP
+.BI \-highlight= k
+Only draw cluster \fIk\fP. By default, all clusters are drawn.
+.TP
 .BI \-k 
 If specified, increases the randomness of outer boundary.
 .TP
-.BI \-r " k"
-The number of random points k (integer) used to define sea and lake boundaries. If 0, auto assigned. By default v = 0
+.BI \-l " s"
+Use the string \fIs\fP as a label for the drawing.
 .TP
-.BI \-s " v"
-The real number v specifies the depth of the sea and lake shores in points. If 0, auto assigned. By default v = 0.
+.BI \-m " v"
+Generate a margin of \fIv\fP points around the drawing. By default, this is determined by \fBgvmap\fP.
 .TP
 .BI \-O  
-Do NOT do color assignment optimization that maximizes color difference between neighboring countries
+Do NOT do color assignment optimization that maximizes color differences between neighboring countries
 .TP
 .BI \-o <file> 
 Put output in <file>. Default output is stdout
 .TP
+.BI \-p " k"
+Indicates what level of points should be shown. By default, no points are shown.
+.TP
+   Acceptable values are:
+   0 : no points
+   1 : all points
+   2 : label points
+   3 : random/artificial points
+.TP
+.BI \-r " k"
+The number of random points k (integer) used to define sea and lake boundaries. If 0, auto assigned. By default v = 0
+.TP
+.BI \-s " v"
+The real number v specifies the depth of the sea and lake shores in points. If 0, auto assigned. By default v = 0.
+.TP
+.BI \-t " n"
+Make \fIn\fP attempts to improve cluster contiguity.
+.TP
 .BI \-v 
 Verbose mode.
 .TP
 .BI \-z " c" 
 Specified the polygon line color. Default is black.
+.TP
+.BI \-? 
+Print usage and exit.
 .SH EXAMPLES
 .PP
 Given a graph foo.gv, one way to generate a layout and highlight the clusters 
index e5a225b294538d07a0e2324e476949878d087fd2..e77fe2e34203a83e5a14da940a66b272073c809e 100644 (file)
@@ -83,6 +83,7 @@ typedef struct {
     int plotedges;
     int color_scheme;
     real line_width;
+    char *opacity;
     char *plot_label;
     real *bg_color;
     int improve_contiguity_n;
@@ -148,7 +149,7 @@ int string_split(char *s, char sp, char ***ss0, int *ntokens0){
 }
 
 static char* usestr =
-"   where graphfile must contain node positions, and width/height of each node. No overlap between nodes should be present. Acceptable options are: \n\
+"   where graphfile must contain node positions, and widths and heights for each node. No overlap between nodes should be present. Acceptable options are: \n\
     -a k - average number of artificial points added along the bounding box of the labels. If < 0, a suitable value is selected automatically. (-1)\n\
     -b v - polygon line width, with v < 0 for no line. (0)\n\
     -c k - polygon color scheme (1)\n\
@@ -161,29 +162,30 @@ static char* usestr =
        6 : sequential single hue red \n\
        7 : sequential single hue lighter red \n\
        8 : light grey\n\
-    -d s - seed used to calculate Fielder vector for optimal coloring\n\
     -C k - generate at most k clusters. (0)\n\
+    -d s - seed used to calculate Fielder vector for optimal coloring\n\
     -e   - show edges\n\
     -g c - bounding box color. If not specified, a bounding box is not drawn.\n\
+    -h k - number of artificial points added to maintain bridge between endpoints (0)\n\
+    -highlight=k - only draw cluster k\n\
     -k   - increase randomesss of boundary\n\
-    -r k - number of random points k used to define sea and lake boundaries. If 0, auto assigned. (0)\n\
-    -s v - depth of the sea and lake shores in points. If 0, auto assigned. (0)\n\
+    -l s - specify label\n\
+    -m v - bounding box margin. If 0, auto-assigned (0)\n\
     -o <file> - put output in <file> (stdout)\n\
     -O   - do NOT do color assignment optimization that maximizes color difference between neighboring countries\n\
-    -v   - verbose\n\
-    -z c - polygon line color (black)\n";
-
-/* 
-
-    -t n - improve contiguity up to n times. (0)\n\
     -p k - show points. (0)\n\
        0 : no points\n\
        1 : all points\n\
        2 : label points\n\
        3 : random/artificial points\n\
-    -h k - number of artificial points added maintain bridge between endpoints (0)\n\
-    -l s - specify label\n\
-    -m v - bounding box margin. If 0, auto assigned (0)\n\
+    -r k - number of random points k used to define sea and lake boundaries. If 0, auto assigned. (0)\n\
+    -s v - depth of the sea and lake shores in points. If 0, auto assigned. (0)\n\
+    -t n - improve contiguity up to n times. (0)\n\
+    -v   - verbose\n\
+    -z c - polygon line color (black)\n";
+
+/* 
+
    -q f - output format (3)\n\
        0 : Mathematica\n\
        1 : PostScript\n\
@@ -239,8 +241,10 @@ init(int argc, char **argv, params_t* pm)
   unsigned int c;
   real s;
   int v, r;
+  char stmp[3];  /* two character string plus '\0' */
 
   pm->outfile = NULL;
+  pm->opacity = NULL;
   pm->nrandom = -1;
   pm->dim = 2;
   pm->shore_depth_tol = 0;
@@ -269,7 +273,7 @@ init(int argc, char **argv, params_t* pm)
   /*  bbox_margin[0] =  bbox_margin[1] = -0.2;*/
   pm->bbox_margin[0] =  pm->bbox_margin[1] = 0;
 
-  while ((c = getopt(argc, argv, ":efvOko:m:s:r:p:c:C:l:b:g:t:a:h:z:d:")) != -1) {
+  while ((c = getopt(argc, argv, ":evOko:m:s:r:p:c:C:l:b:g:t:a:h:z:d:")) != -1) {
     switch (c) {
     case 'm':
       if ((sscanf(optarg,"%lf",&s) > 0) && (s != 0)){
@@ -342,7 +346,9 @@ init(int argc, char **argv, params_t* pm)
       }
       break;
     case 'c':
-      if ((sscanf(optarg,"%d",&r) > 0) && r >= COLOR_SCHEME_NONE && r <= COLOR_SCHEME_GREY){
+      if (sscanf(optarg,"_opacity=%2s", stmp) > 0 && strlen(stmp) == 2){
+        pm->opacity = strdup(stmp);
+      } else if ((sscanf(optarg,"%d",&r) > 0) && r >= COLOR_SCHEME_NONE && r <= COLOR_SCHEME_GREY){
         pm->color_scheme = r;
       } else {
         usage(cmd,1);
@@ -542,7 +548,8 @@ makeMap (SparseMatrix graph, int n, real* x, real* width, int* grouping,
   if (whatout == OUT_DOT){
 #endif
     Dot_SetClusterColor(g, rgb_r,  rgb_g,  rgb_b, grouping);
-    plot_dot_map(g, n, dim, x, polys, poly_lines, pm->line_width, pm->line_color, x_poly, polys_groups, labels, width, fsz, rgb_r, rgb_g, rgb_b, pm->plot_label, pm->bg_color, (pm->plotedges?graph:NULL), pm->outfile);
+    plot_dot_map(g, n, dim, x, polys, poly_lines, pm->line_width, pm->line_color, x_poly, polys_groups, labels, width, fsz, rgb_r, rgb_g, rgb_b, pm->opacity,
+           pm->plot_label, pm->bg_color, (pm->plotedges?graph:NULL), pm->outfile);
 #if 0
     }
     goto RETURN;
index 0d458dfcee072c90fc84923ff9069a24f02ec98e..bf5dde2895dded78e773c3b75dddde6713520a10 100644 (file)
@@ -689,7 +689,7 @@ void processing_one_poly(FILE *f, int use_line, real line_width, int fill, int c
 }
 
 
-void plot_dot_polygons(char **sbuff, int *len, int *len_max, real line_width, char *line_color, SparseMatrix polys, real *x_poly, int *polys_groups, float *r, float *g, float *b){
+void plot_dot_polygons(char **sbuff, int *len, int *len_max, real line_width, char *line_color, SparseMatrix polys, real *x_poly, int *polys_groups, float *r, float *g, float *b, char* opacity){
   int i, j, *ia = polys->ia, *ja = polys->ja, *a = (int*) polys->a, npolys = polys->m, nverts = polys->n, ipoly,first;
   int np = 0, maxlen = 0;
   float *xp, *yp;
@@ -713,7 +713,7 @@ void plot_dot_polygons(char **sbuff, int *len, int *len_max, real line_width, ch
        ipoly = ABS(a[j]);
        is_river = (a[j] < 0);
        if (r && g && b) {
-         rgb2hex(r[polys_groups[i]], g[polys_groups[i]], b[polys_groups[i]], cstring);
+         rgb2hex(r[polys_groups[i]], g[polys_groups[i]], b[polys_groups[i]], cstring, opacity);
        }
        dot_one_poly(sbuff, len, len_max, use_line, line_width, fill, close, is_river, np, xp, yp, cstring);
        np = 0;/* start a new polygon */
@@ -778,7 +778,7 @@ void plot_processing_polygons(FILE *f, real line_width, SparseMatrix polys, real
 
 
 void plot_dot_map(Agraph_t* gr, int n, int dim, real *x, SparseMatrix polys, SparseMatrix poly_lines, real line_width, char *line_color, real *x_poly, int *polys_groups, char **labels, real *width,
-                float *fsz, float *r, float *g, float *b, char *plot_label, real *bg_color, SparseMatrix A, FILE* f){
+                float *fsz, float *r, float *g, float *b, char* opacity, char *plot_label, real *bg_color, SparseMatrix A, FILE* f){
   /* if graph object exist, we just modify some attributes, otherwise we dump the whole graph */
   int plot_polyQ = TRUE;
   char *sbuff;
@@ -806,12 +806,12 @@ void plot_dot_map(Agraph_t* gr, int n, int dim, real *x, SparseMatrix polys, Spa
   /*polygons */
   if (plot_polyQ) {
     if (!gr) fprintf(f,"_draw_ = \"");
-    plot_dot_polygons(&sbuff, &len, &len_max, -1., NULL, polys, x_poly, polys_groups, r, g, b);
+    plot_dot_polygons(&sbuff, &len, &len_max, -1., NULL, polys, x_poly, polys_groups, r, g, b, opacity);
   }
 
   /* polylines: line width is set here */
   if (line_width >= 0){
-    plot_dot_polygons(&sbuff, &len, &len_max, line_width, line_color, poly_lines, x_poly, polys_groups, NULL, NULL, NULL);
+    plot_dot_polygons(&sbuff, &len, &len_max, line_width, line_color, poly_lines, x_poly, polys_groups, NULL, NULL, NULL, NULL);
   }
   if (!gr) {
     fprintf(f,"%s",sbuff);
index 180d7ef60a540d5a697494993b8b161ad3c0065f..84223b478efab55b3698ab3c15c125109e82fce3 100644 (file)
@@ -41,7 +41,7 @@ void plot_ps_map(int n, int dim, real *x, SparseMatrix polys, SparseMatrix poly_
                 float *fsz, float *r, float *g, float *b, char *plot_label, real *bg_color, SparseMatrix A);
 #endif
 
-void plot_dot_map(Agraph_t* gr, int n, int dim, real *x, SparseMatrix polys, SparseMatrix poly_lines, real line_width, char *line_color, real *x_poly, int *polys_groups, char **labels, real *width, float *fsz, float *r, float *g, float *b, char *plot_label, real *bg_color, SparseMatrix A, FILE*);
+void plot_dot_map(Agraph_t* gr, int n, int dim, real *x, SparseMatrix polys, SparseMatrix poly_lines, real line_width, char *line_color, real *x_poly, int *polys_groups, char **labels, real *width, float *fsz, float *r, float *g, float *b, char* opacity, char *plot_label, real *bg_color, SparseMatrix A, FILE*);
 
 #if 0
 void plot_processing_map(Agraph_t* gr, int n, int dim, real *x, SparseMatrix polys, SparseMatrix poly_lines, real line_width, int nverts, real *x_poly, int *polys_groups, char **labels, real *width, float *fsz, float *r, float *g, float *b, char *plot_label, real *bg_color, SparseMatrix A);