[GRASS5] d.legend, once again

H. Bowman ihatejunkyabastards at yahoo.com
Wed Jan 8 21:17:00 EST 2003


Happy New Year all,


The newest changes to d.legend (aka d.leg.thin) are now in CVS/HEAD.
This one is mostly the same, but slightly cleaned up, as the version
announced at the end of November. I'd like it to have some more testing
before I add any more features (see below).

what's new:

key:   + new feature      o misc tweak     ! minor bugfix

+  Legend text for floating point rasters is now much prettier. (%f ->
    %.2f, etc)
+  at=x1,y1,x2,y2 implemented. Module is now scriptable / survives
    d.redraw
+  reimplemented -n flag: skip categories without labels. lines=
    takes on a new meaning when using this flag; means "up to category
    #". Its meaning becomes more blurry when you use lines=, thin=, and
    the-n flag together. This is a feature.
+  added range=min,max option. works on both cat & floating point
    rasters
+  added -f flag for explicit flipping.
+  Auto-scales text to fit in display window if bounds not manually set
    with at= or with mouse. Always auto-scales the "4 of 16 categories"
    text as needed.

o  Floating point rasters now have the highest values at the top, lowest
    at the bottom.
o  You can now select the legend box with the mouse from any two corners
    and it will work.
o  If you select a lower corner before a higher corner, the legend will
    reverse vertically. This also happens if the y values in at= are
    reversed. Works for horizontal legends as well.
o Misc. code clean up, cleaned out some duplicate and unused code.

!  lines=x would not display exactly x lines. Fixed.
!  fixed smoothed color display limits
!  uses full height of legend box to draw, even when using thin= or
    lines=.
!  better determines when to force a smoothed legend when using-n,
    lines=, &/or thin=.
!  smoothed legends with <5 categories now show<5 text labels.


I leave it up to the experts to decide whether this should end up in the
5.0.x or 5.1 branch. [I haven't been able to break the latest (r1.15),
but it isn't as proven as revision 1.13, which is just the 5.0.0 version
with major bugfixes applied, so tag whichever one you choose for the release branch.]


==============================================================
(below)

There is also a second version which is more experimental at this point.
It required several changes, so there might be bugs/mistakes. As such
I'd like to get the above CVS version perfect before pushing this one
out to cut down on any future debugging effort:

+ added use= option to provide the ability to make discrete category
    legends (as in SG3d). works on both cat & floating point rasters
- bug: use= by itself doesn't fall over to USAGE: screen
- cleanup: compiler warns 'catlist' might be used uninitialized.
    Don't think it is possible, but needs to be looked into.
- nagging doubts: Is G_calloc used correctly?

If anyone would like to try it out, here it is:
http://bambi.otago.ac.nz/hamish/main.c.withUSE

So this one could use some C experts looking it over before it is let
loose, but all in all, it seems to work fine.. With all the permutations
and combinations now available, testing all the possibilities is getting
beyond what I can do. There are also minor inconsistencies with regards
to the text sizing using different options (thin=large number,
use=oneCategory, range=oneCat,oneCat, and lines=1; and combinations of
the -v, -c, &/or -n flag may not all be identical) but all should fit on
the screen and not look wrong.

Also, horizontal legends still do not generate text labels. I'm not
really planning on doing anything about this, but it remains on the
module's TODO list.




enjoy,
Hamish




More information about the grass-dev mailing list