Monitor Size

Conn Copas cvc at itd.dsto.gov.au
Thu Feb 23 22:02:41 EST 1995


eb?22??95?09?45?21?am at bnr.ca>
Reply-To: grassu-list at max.cecer.army.mil
NNTP-Posting-Host: ux1.cso.uiuc.edu
Mime-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Originator: daemon at ux1.cso.uiuc.edu


Amy writes:

"How can I specify what size the
monitor will be __right__  after
I open it with 'd.mon'?  I'm writing
a script and would prefer that the
user does not have to enlarge the
monitor before displaying any maps.
Please respond directly to me."

I recently hacked the X driver to do something which may be of general interest
so, if you can stand a small amount of C code, here it is. The idea is that the
default aspect ratio of the monitor reflects the aspect ratio of the data
within the current region, unless this is overridden by the presence of
XDRIVER_HEIGHT/WIDTH environment variables. So, no more ugly black borders
around rectangular data within square monitors. Also, if you zoom into some
tiny region, the monitor is magnified to a size which occupies a reasonable
amount of screen real-estate; around 20%. If the monitor is resized
interactively, the aspect ratio is preserved.

I've also done this for the IRIS driver, but try this first and e-mail me if
you want more details.

1. Make back-up copies of /src/display/devices/XDRIVER/XDRIVER/Gmakefile and
/src/display/devices/XDRIVER/XDRIVER/Graph_Set.c

2. In the file /src/display/devices/XDRIVER/XDRIVER/Gmakefile, add the GIS
library by substituting

        $(CC) $(LDFLAGS) $(XLDFLAGS) $(OFILES) $(LIB) ...
with
        $(CC) $(LDFLAGS) $(XLDFLAGS) $(OFILES) $(LIB) $(GISLIB) ...


3. In the file /src/display/devices/XDRIVER/XDRIVER/Graph_Set.c,
substitute

    szhints->flags = (USPosition | USSize | PMinSize | PMaxSize);
        szhints->max_width      = DisplayWidth(dpy, scrn) - 20;
        szhints->min_width      = 0;
        szhints->min_height = 0;
        szhints->max_height = DisplayHeight(dpy, scrn) - 30 ;
        get_user ("XDRIVER_HEIGHT", &szhints->height, 400);
        get_user ("XDRIVER_WIDTH",  &szhints->width,  450);
        get_user ("XDRIVER_LEFT",   &szhints->x,      10);
        get_user ("XDRIVER_TOP",    &szhints->y,      10);

with

    szhints->flags = (USPosition | USSize | PMinSize | PMaxSize | PAspect);
        szhints->max_width      = DisplayWidth(dpy, scrn) - 20;
        szhints->min_width      = 0;
        szhints->min_height = 0;
        szhints->max_height = DisplayHeight(dpy, scrn) - 30 ;
        get_aspect(&szhints->height,&szhints->width,argv[0],dpy, scrn);
        szhints->min_aspect.x = szhints->width;
        szhints->min_aspect.y = szhints->height;
        szhints->max_aspect.x = szhints->width;
        szhints->max_aspect.y = szhints->height;
        get_user ("XDRIVER_LEFT",   &szhints->x,      10);
        get_user ("XDRIVER_TOP",    &szhints->y,      10);

Then insert the following function second from last, ie, after
'GetRealNumberOfColors' and before 'get_user':

---------------- cut here ----------------------------------------------------

get_aspect(pref_rows,pref_cols,me,dpy, scrn)
int *pref_rows, *pref_cols;
char *me;

{
    float rows, cols, row_frac, col_frac, side, temp;
    int mag = 1;
    int x, y;

        get_user ("XDRIVER_HEIGHT",pref_rows,0);
        get_user ("XDRIVER_WIDTH",pref_cols,0);

        if (*pref_rows <= 0 || *pref_cols <= 0)
        {
        G_gisinit(me);
        rows = G_window_rows();
        cols = G_window_cols();
        row_frac = rows/DisplayHeight(dpy, scrn);
        col_frac = cols/DisplayWidth(dpy, scrn);
        if (rows > cols)
                side = row_frac;
        else
                side = col_frac;

        do
                {
                mag++;
                temp = mag*side;
                }
        while (temp <= 0.5);

        *pref_rows = rows*--mag;
        *pref_cols = cols*mag;
        }
}

------------------------ cut here ----------------------------------

4. In the directory /src/display/devices/XDRIVER/XDRIVER, run the script
gmake4.1. The path for this script may be found from the UNIX_BIN variable,
which is defined in $GISBASE/src/CMD/head/<arch>.
If the compile fails, don't worry, you will still have the old
X driver. If you experience run-time problems, restore the backed-up files to
their rightful place, run gmake4.1 again, and you will be back where you
started.

I know, some of these effects can be achieved by creative aliasing of d.mon,
d.zoom and g.region through scripts, but that probably means that Grass9.9 will
still behave in a less intelligent fashion than we would prefer. You may want
to check my calculations; should the window_width necessarily equal
data_columns?

--
Conn V Copas
Information Technology Division
Defence Science and Technology Organisation
PO Box 1500
Salisbury            tel: +61 (0)8 25 95349
SA  5108             fax: +61 (0)8 25 96781
Australia       e-mail: cvc at itd.dsto.gov.au
-------------------------------------------




More information about the grass-user mailing list