[GRASSLIST:8770] Re: Querying display monitor locations as percent from origin (0,0)?

Hamish hamish_nospam at yahoo.com
Thu Oct 27 00:07:09 EDT 2005


> > > I'm trying to create a simple legend for sediment grainsize
> > > analyses (attributes consist of % gravel, % sand, % silt, % clay).
> > > I already have some really nice looking pie charts created using
> > > d.vect.chart, and now I want an accompanying legend in the
> > > upper-right corner of the monitor for a screen capture. Is there a
> > > way to query the coordinates of locations on the monitor as
> > > percentages from the lower-left corner?
> > >
> > > I could make a reasonable guess as to where I think the legend
> > > should appear in display coordinates, but I want to use d.graph to
> > > build a little window containing all the legend elements; having
> > > the exact queried coordinates could just be pasted into the
> > > d.graph command.
> >
> > I think the best you can do is kruler and a hand calculator.. :/
> >
> [snip]
> 
> Really? I wonder how hard it would be to adjust the monitor commands
> to accept a slightly more useful form of location directives... I
> have spent a bit of time fussing around with percentage values until
> I finally got a reasonable legend...

what do you mean by slightly more useful? Remeber the result should look
somehwhat the same regardless of the window size, so absolute pixel
placement isn't always great. e.g. try it with d.text.freetype -p,-n.

My method with d.legend ususally is to get it where I want it with the
mouse placement and then do trial and error with the at= command until
it was correct. d.legend could do what d.barscale does which is after a
mouse placement figure out, translate, and remember the placement as the
at= option instead of the -m flag, but d.legend is more complicated...

Maybe spit out the placement answer as a G_debug(1,) message for
those who want it? That would be pretty easy to add to the mouse code.


Another general idea to automate figuring out screen percentages is to
use "g.region -g", figure out a y=mx+b 0-100% releationship with the
screen postion, then pipe the output of d.where through a conversion
calculation; it's all linear. Use d.info if you want absolute pixel
positions.

Or d.frame in 10% chunks ;)


Hamish




More information about the grass-user mailing list