[GRASS-SVN] r69063 - grass-addons/grass7/display/d.legend.vect

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Aug 2 12:45:54 PDT 2016


Author: lazaa
Date: 2016-08-02 12:45:54 -0700 (Tue, 02 Aug 2016)
New Revision: 69063

Modified:
   grass-addons/grass7/display/d.legend.vect/draw.c
   grass-addons/grass7/display/d.legend.vect/main.c
Log:
Different legend symbol according to geometry type

Modified: grass-addons/grass7/display/d.legend.vect/draw.c
===================================================================
--- grass-addons/grass7/display/d.legend.vect/draw.c	2016-08-02 19:44:57 UTC (rev 69062)
+++ grass-addons/grass7/display/d.legend.vect/draw.c	2016-08-02 19:45:54 UTC (rev 69063)
@@ -40,6 +40,7 @@
     double it_per_col;
     double margin, bg_h, bg_w;
     char *sep;
+    int type_count;
 
 
     D_get_src(&dt, &db, &dl, &dr);
@@ -77,32 +78,20 @@
     G_strip(buf);
     while (got_new) {
         /* Get the maximum symbol size */
+        label = G_malloc(strlen(buf) + 1);
         symb_name = G_malloc(strlen(buf) + 1);
-        type_str = G_malloc(strlen(buf) + 1);
-        line_color_str = G_malloc(strlen(buf) + 1);
-        fill_color_str = G_malloc(strlen(buf) + 1);
 
         part = strtok(buf, sep);
+        sscanf(part, "%s", label);
+        part = strtok(NULL, sep);
         sscanf(part, "%s", symb_name);
         part = strtok(NULL, sep);
-        sscanf(part, "%s", type_str);
-        part = strtok(NULL, sep);
-        sscanf(part, "%s", line_color_str);
-        part = strtok(NULL, sep);
-        sscanf(part, "%s", fill_color_str);
-        part = strtok(NULL, sep);
         sscanf(part, "%lf", &size);
 
+
         /* Symbol */
-        if (strcmp(type_str,"area")==0) {
-            symb_name = "legend/area";
+        if ((strcmp(symb_name,"legend/area")==0) || (strcmp(symb_name,"legend/line")==0))
             size = symb_size;
-        }
-        else if (strcmp(type_str,"line")==0) {
-            symb_name = "legend/line";
-            size = symb_size;
-        }
-
         Symb = S_read(symb_name);
         if (Symb == NULL)
             G_warning(_("Cannot read symbol"));
@@ -130,8 +119,6 @@
     sub_delim = G_malloc(strlen(buf)+1);
     snprintf(sub_delim, sizeof(strlen(buf)+1), "%s%s%s%s%s", sep, sep, sep, sep, sep);
 
-
-
     got_new = G_getl2(buf, sizeof(buf), file_in);
     G_strip(buf);
 
@@ -185,29 +172,25 @@
             fill_color = G_malloc(sizeof(RGBA_Color));
 
             part = strtok(buf, sep);
+            sscanf(part, "%s", label);
+            part = strtok(NULL, sep);
             sscanf(part, "%s", symb_name);
             part = strtok(NULL, sep);
-            sscanf(part, "%s", type_str);
+            sscanf(part, "%lf", &size);
             part = strtok(NULL, sep);
             sscanf(part, "%s", line_color_str);
             part = strtok(NULL, sep);
             sscanf(part, "%s", fill_color_str);
             part = strtok(NULL, sep);
-            sscanf(part, "%lf", &size);
-            part = strtok(NULL, sep);
             sscanf(part, "%lf", &line_width);
             part = strtok(NULL, sep);
-            sscanf(part, "%s", label);
+            sscanf(part, "%s", type_str);
+            part = strtok(NULL, sep);
+            sscanf(part, "%d", &type_count);
 
             /* Symbol */
-            if (strcmp(type_str,"area")==0) {
-                symb_name = "legend/area";
+            if ((strcmp(symb_name,"legend/area")==0) || (strcmp(symb_name,"legend/line")==0))
                 size = symb_size;
-            }
-            else if (strcmp(type_str,"line")==0) {
-                symb_name = "legend/line";
-                size = symb_size;
-            }
             Symb = S_read(symb_name);
             if (Symb == NULL)
                 G_warning(_("Cannot read symbol"));
@@ -268,7 +251,7 @@
                 D_use_color(fontcolor);
                 D_text(label);
             }
-        } /* end of Parse the line */
+        }
 
         got_new = G_getl2(buf, sizeof(buf), file_in);
         G_strip(buf);

Modified: grass-addons/grass7/display/d.legend.vect/main.c
===================================================================
--- grass-addons/grass7/display/d.legend.vect/main.c	2016-08-02 19:44:57 UTC (rev 69062)
+++ grass-addons/grass7/display/d.legend.vect/main.c	2016-08-02 19:45:54 UTC (rev 69063)
@@ -47,14 +47,6 @@
     _("Displays a vector legend "
       "in the active graphics frame.");
 
-//    opt_input = G_define_standard_option(G_OPT_F_INPUT);
-//    opt_input->key = "input";
-//    opt_input->description = _("Input file");
-//    opt_input->guisection = _("Input");
-
-//    opt_sep = G_define_standard_option(G_OPT_F_SEP);
-//    opt_sep->guisection = _("Input");
-
     opt_at = G_define_option();
     opt_at->key = "at";
     opt_at->key_desc = "left,top";



More information about the grass-commit mailing list