[GRASS5] Re: [GRASSLIST:1560] Re: back ground

(mv'ed to grass5)

On Mon, Oct 27, 2003 at 08:43:07PM +1300, Hamish wrote:

> how can i change the back ground,black to white,to viwe the maps in
> GRASS 5.0.0?

d.erase color=white

Which change is necessary for GRASS 5.7 to keep the white
standard background when resizing the monitor?

d.mon x0
#-> white background as desired

#now mouse resize
#-> background switches to black (undesired)

?

Markus

Markus Neteler wrote:

(mv'ed to grass5)

On Mon, Oct 27, 2003 at 08:43:07PM +1300, Hamish wrote:
> > how can i change the back ground,black to white,to viwe the maps in
> > GRASS 5.0.0?
>
> d.erase color=white

Which change is necessary for GRASS 5.7 to keep the white
standard background when resizing the monitor?

Copy Serve_Xevent.c; on line 292, change BlackPixel to WhitePixel.

BTW, I'm not sure if these lines (266+) have any relevance.

    /* set standard color to black and erase */
    Standard_color(BLACK);
    Erase();

--
Glynn Clements <glynn.clements@virgin.net>

On Tue, Oct 28, 2003 at 09:41:54AM +0000, Glynn Clements wrote:

Markus Neteler wrote:

> (mv'ed to grass5)
>
> On Mon, Oct 27, 2003 at 08:43:07PM +1300, Hamish wrote:
> > > how can i change the back ground,black to white,to viwe the maps in
> > > GRASS 5.0.0?
> >
> > d.erase color=white
>
> Which change is necessary for GRASS 5.7 to keep the white
> standard background when resizing the monitor?

Copy Serve_Xevent.c; on line 292, change BlackPixel to WhitePixel.

Thanks. I have subitted
     if (strcmp(DEFAULT_FG_COLOR, "black"))
       XSetForeground(dpy, gc, BlackPixel(dpy, scrn));
     else
       XSetForeground(dpy, gc, WhitePixel(dpy, scrn));

to CVS. Now it works both for 5.3 and 5.7.

BTW, I'm not sure if these lines (266+) have any relevance.

    /* set standard color to black and erase */
    Standard_color(BLACK);
    Erase();

They don't harm in this context. Do you mean that they are useless?

Thanks for the quick hint,

Markus

Markus Neteler wrote:

> > > > how can i change the back ground,black to white,to viwe the maps in
> > > > GRASS 5.0.0?
> > >
> > > d.erase color=white
> >
> > Which change is necessary for GRASS 5.7 to keep the white
> > standard background when resizing the monitor?
>
> Copy Serve_Xevent.c; on line 292, change BlackPixel to WhitePixel.

Thanks. I have subitted
     if (strcmp(DEFAULT_FG_COLOR, "black"))
       XSetForeground(dpy, gc, BlackPixel(dpy, scrn));
     else
       XSetForeground(dpy, gc, WhitePixel(dpy, scrn));

to CVS. Now it works both for 5.3 and 5.7.

For consistency, you should do this in both Graph_Set.c and
Serve_Xevent.c. Graph_Set.c sets the background colour at startup,
Serve_Xevent.c does it when the window is resized. Presumably you want
them both to be the same, right?

The 5.7 version of Graph_Set.c uses WhitePixel regardless of the
DEFAULT_FG_COLOR setting (line 385).

Better still, use XLookupColor() instead of {Black,White}Pixel(). Note
that {Black,White}Pixel() don't necessarily return the values for
black and white respectively, but for the nominal "black" and "white"
pixels (e.g. if a server has an option for inverse video, black and
white will be swapped; XFree86 4.x allows the nominal black/white
colours to be set in XF86Config).

> BTW, I'm not sure if these lines (266+) have any relevance.
>
> /* set standard color to black and erase */
> Standard_color(BLACK);
> Erase();

They don't harm in this context. Do you mean that they are useless?

I mean that they appear to be useless, although I'm not entirely sure.
Maybe the display library needs to be told what the background colour
is?

--
Glynn Clements <glynn.clements@virgin.net>

On Tue, Oct 28, 2003 at 11:07:45AM +0000, Glynn Clements wrote:

Markus Neteler wrote:

> > > > > how can i change the back ground,black to white,to viwe the maps in
> > > > > GRASS 5.0.0?
> > > >
> > > > d.erase color=white
> > >
> > > Which change is necessary for GRASS 5.7 to keep the white
> > > standard background when resizing the monitor?
> >
> > Copy Serve_Xevent.c; on line 292, change BlackPixel to WhitePixel.
>
> Thanks. I have subitted
> if (strcmp(DEFAULT_FG_COLOR, "black"))
> XSetForeground(dpy, gc, BlackPixel(dpy, scrn));
> else
> XSetForeground(dpy, gc, WhitePixel(dpy, scrn));
>
> to CVS. Now it works both for 5.3 and 5.7.

For consistency, you should do this in both Graph_Set.c and
Serve_Xevent.c. Graph_Set.c sets the background colour at startup,
Serve_Xevent.c does it when the window is resized. Presumably you want
them both to be the same, right?

The file Graph_Set.c is not linked from 5.3 into 5.7 but
a slightly different version (includes new cursor definition etc
and the change for WhitePixel).

The 5.7 version of Graph_Set.c uses WhitePixel regardless of the
DEFAULT_FG_COLOR setting (line 385).

Do you mean line 374 (5.7)? This part of the file is a bit cryptic for
me (from line 369 onwards):

    XSetWindowBackgroundPixmap(dpy, grwin, bkupmap);
    XSetForeground(dpy, gc, BlackPixel(dpy, scrn)); <===== !?
    XFillRectangle(dpy, bkupmap, gc, 0, 0, xwa.width, xwa.height);

    XSetBackground(dpy, gc, BlackPixel(dpy, scrn));
    XSetForeground(dpy, gc, WhitePixel(dpy, scrn)); <===== !?

In fact, I don't know X functions at all.

Better still, use XLookupColor() instead of {Black,White}Pixel(). Note
that {Black,White}Pixel() don't necessarily return the values for
black and white respectively, but for the nominal "black" and "white"
pixels (e.g. if a server has an option for inverse video, black and
white will be swapped; XFree86 4.x allows the nominal black/white
colours to be set in XF86Config).

Unfortunately I don't know anything about these details.

> > BTW, I'm not sure if these lines (266+) have any relevance.
> >
> > /* set standard color to black and erase */
> > Standard_color(BLACK);
> > Erase();
>
> They don't harm in this context. Do you mean that they are useless?

I mean that they appear to be useless, although I'm not entirely sure.
Maybe the display library needs to be told what the background colour
is?

No idea. Does
src/libes/D/Derase.c
tell us something?

-> int Derase(char *color)

So far it works, I prefer to leave further changes to X experts.

Markus Neteler wrote:

> > > > > > how can i change the back ground,black to white,to viwe the maps in
> > > > > > GRASS 5.0.0?
> > > > >
> > > > > d.erase color=white
> > > >
> > > > Which change is necessary for GRASS 5.7 to keep the white
> > > > standard background when resizing the monitor?
> > >
> > > Copy Serve_Xevent.c; on line 292, change BlackPixel to WhitePixel.
> >
> > Thanks. I have subitted
> > if (strcmp(DEFAULT_FG_COLOR, "black"))
> > XSetForeground(dpy, gc, BlackPixel(dpy, scrn));
> > else
> > XSetForeground(dpy, gc, WhitePixel(dpy, scrn));
> >
> > to CVS. Now it works both for 5.3 and 5.7.
>
> For consistency, you should do this in both Graph_Set.c and
> Serve_Xevent.c. Graph_Set.c sets the background colour at startup,
> Serve_Xevent.c does it when the window is resized. Presumably you want
> them both to be the same, right?

The file Graph_Set.c is not linked from 5.3 into 5.7 but
a slightly different version (includes new cursor definition etc
and the change for WhitePixel).

I know. Either:

a) copy Serve_Xevent.c, and revert the 5.3 version so it is consistent
with the 5.3 version of Graph_Set.c, or:

b) modify the 5.3 version of Graph_Set.c so that it is consistent with
the shared version of Serve_Xevent.c.

My point is that the behaviour should be the same for both the startup
and resize cases. Given that, currently, Serve_Xevent.c is shared
between 5.3 and 5.7, both the 5.3 and 5.7 versions of Graph_Set.c need
to be consistent with it.

> The 5.7 version of Graph_Set.c uses WhitePixel regardless of the
> DEFAULT_FG_COLOR setting (line 385).

Do you mean line 374 (5.7)? This part of the file is a bit cryptic for
me (from line 369 onwards):

    XSetWindowBackgroundPixmap(dpy, grwin, bkupmap);
    XSetForeground(dpy, gc, BlackPixel(dpy, scrn)); <===== !?
    XFillRectangle(dpy, bkupmap, gc, 0, 0, xwa.width, xwa.height);

These are the lines in question; in my local copy, they look like
this (starting at 381):

    /* Now create a pixmap that will contain same contents as the
     * window. It will be used to redraw from after expose events */
    bkupmap = XCreatePixmap(dpy, grwin, xwa.width, xwa.height, xwa.depth);
    XSetWindowBackgroundPixmap(dpy, grwin, bkupmap);
    XSetForeground(dpy, gc, WhitePixel(dpy, scrn));
    XFillRectangle(dpy, bkupmap, gc, 0, 0, xwa.width, xwa.height);

Presumably this has been changed since I last did a "cvs update" for
5.7 (I haven't really been following it, so updates aren't
particularly frequent.).

--
Glynn Clements <glynn.clements@virgin.net>

On Wed, Oct 29, 2003 at 07:20:35AM +0000, Glynn Clements wrote:

Markus Neteler wrote:

> > > > > > > how can i change the back ground,black to white,to viwe the maps in
> > > > > > > GRASS 5.0.0?
> > > > > >
> > > > > > d.erase color=white
> > > > >
> > > > > Which change is necessary for GRASS 5.7 to keep the white
> > > > > standard background when resizing the monitor?
> > > >
> > > > Copy Serve_Xevent.c; on line 292, change BlackPixel to WhitePixel.
> > >
> > > Thanks. I have subitted
> > > if (strcmp(DEFAULT_FG_COLOR, "black"))
> > > XSetForeground(dpy, gc, BlackPixel(dpy, scrn));
> > > else
> > > XSetForeground(dpy, gc, WhitePixel(dpy, scrn));
> > >
> > > to CVS. Now it works both for 5.3 and 5.7.
> >
> > For consistency, you should do this in both Graph_Set.c and
> > Serve_Xevent.c. Graph_Set.c sets the background colour at startup,
> > Serve_Xevent.c does it when the window is resized. Presumably you want
> > them both to be the same, right?
>
> The file Graph_Set.c is not linked from 5.3 into 5.7 but
> a slightly different version (includes new cursor definition etc
> and the change for WhitePixel).

I know. Either:

a) copy Serve_Xevent.c, and revert the 5.3 version so it is consistent
with the 5.3 version of Graph_Set.c, or:

Both done.

b) modify the 5.3 version of Graph_Set.c so that it is consistent with
the shared version of Serve_Xevent.c.

My point is that the behaviour should be the same for both the startup
and resize cases. Given that, currently, Serve_Xevent.c is shared
between 5.3 and 5.7, both the 5.3 and 5.7 versions of Graph_Set.c need
to be consistent with it.

I agree.

> > The 5.7 version of Graph_Set.c uses WhitePixel regardless of the
> > DEFAULT_FG_COLOR setting (line 385).
>
> Do you mean line 374 (5.7)? This part of the file is a bit cryptic for
> me (from line 369 onwards):
>
> XSetWindowBackgroundPixmap(dpy, grwin, bkupmap);
> XSetForeground(dpy, gc, BlackPixel(dpy, scrn)); <===== !?
> XFillRectangle(dpy, bkupmap, gc, 0, 0, xwa.width, xwa.height);

These are the lines in question; in my local copy, they look like
this (starting at 381):

    /* Now create a pixmap that will contain same contents as the
     * window. It will be used to redraw from after expose events */
    bkupmap = XCreatePixmap(dpy, grwin, xwa.width, xwa.height, xwa.depth);
    XSetWindowBackgroundPixmap(dpy, grwin, bkupmap);
    XSetForeground(dpy, gc, WhitePixel(dpy, scrn));
    XFillRectangle(dpy, bkupmap, gc, 0, 0, xwa.width, xwa.height);

Presumably this has been changed since I last did a "cvs update" for
5.7 (I haven't really been following it, so updates aren't
particularly frequent.).

Next thing to tackle is the black background in the PNG driver.
Again I am not sure how to do that. It seems to be a change needed
in
PNG/Graph_Set.c

Markus

Markus Neteler wrote:

Next thing to tackle is the black background in the PNG driver.
Again I am not sure how to do that. It seems to be a change needed
in
PNG/Graph_Set.c

Look at the handling of GRASS_BACKGROUNDCOLOR.

Note that you won't find any code which explicitly sets a black
background; if neither GRASS_BACKGROUNDCOLOR nor GRASS_TRANSPARENT are
set, the image starts out however GD initialises it (which happens to
be black).

--
Glynn Clements <glynn.clements@virgin.net>

Next thing to tackle is the black background in the PNG driver.
Again I am not sure how to do that. It seems to be a change needed
in PNG/Graph_Set.c

while we're on the PNG driver, there's a bug in it somewhere which makes
R_polygon_rel and R_polygon_abs draw one pixel too far to the right and
one pixel too far down.
Presumably in src/display/devices/PNGdriver/Polygn_abs.c ?

e.g.
http://bambi.otago.ac.nz/hamish/bad_png_driver.png

seen in d.legend, d.histogram, and d.colortable ...

Drawing commands pass the same coordinates regardless of driver..
(ie it isn't different window size used for setting the coordinate?)

?,
Hamish

Hamish wrote:

> Next thing to tackle is the black background in the PNG driver.
> Again I am not sure how to do that. It seems to be a change needed
> in PNG/Graph_Set.c

while we're on the PNG driver, there's a bug in it somewhere which makes
R_polygon_rel and R_polygon_abs draw one pixel too far to the right and
one pixel too far down.
Presumably in src/display/devices/PNGdriver/Polygn_abs.c ?

OK; I appear to have overestimated the competence of GD's authors.
I can add a work-around for the rectangle case easily enough; fixing
the general polygon case is harder.

I'll re-write PNGdriver not to use GD; that will have the added
benefit of eliminating all GD dependency issues.

--
Glynn Clements <glynn.clements@virgin.net>

On Thu, Oct 30, 2003 at 05:05:53PM +0000, Glynn Clements wrote:

Markus Neteler wrote:

> Next thing to tackle is the black background in the PNG driver.
> Again I am not sure how to do that. It seems to be a change needed
> in
> PNG/Graph_Set.c

Look at the handling of GRASS_BACKGROUNDCOLOR.

Note that you won't find any code which explicitly sets a black
background; if neither GRASS_BACKGROUNDCOLOR nor GRASS_TRANSPARENT are
set, the image starts out however GD initialises it (which happens to
be black).

I have submitted a patch to 5.3-CVS.

Markus

Glynn Clements wrote:

I'll re-write PNGdriver not to use GD; that will have the added
benefit of eliminating all GD dependency issues.

Done.

Testing would be appreciated. I'm particularly interested in comments
regarding both the behaviour and performance of filled polygons.

--
Glynn Clements <glynn.clements@virgin.net>

On Fri, Oct 31, 2003 at 04:24:21PM +0000, Glynn Clements wrote:

Glynn Clements wrote:

> I'll re-write PNGdriver not to use GD; that will have the added
> benefit of eliminating all GD dependency issues.

Done.

Testing would be appreciated. I'm particularly interested in comments
regarding both the behaviour and performance of filled polygons.

--
Glynn Clements <glynn.clements@virgin.net>

The new PNG driver seems to work fine in 5.7. I have made
the relevant updates in the configure[.in] and the Makefile
(commented GD lib stuff). Someone should do the same for
5.3 configure[.in] and REQUIREMENTS.html.

Markus