gnudatalanguage / gdl

GDL - GNU Data Language
GNU General Public License v2.0
274 stars 61 forks source link

Graphics functions (device, set_graphics_function=n). #1288

Closed jtappin closed 5 months ago

jtappin commented 2 years ago

Since the switch to local versions of the plplot drivers, there is an issue with setting the graphics function via device, set_graphics_function=n, which appears to be ignored (at least on draw widgets).

The case that I noticed is the implementation of cross hairs in graffer which work fine with a version built to update 07cda31f, but leave persistent lines on the plot with the current (039fa02a) update. The cross hair routine uses function 10 (not destination) rather than the more usual 6 (source xor destination) for some long-forgotten reason possibly related to a problem in old versions of IDL. However changing it to 6 or even 5 (noop) does not change the result.

Is this a known / expected problem. If not I can probably run up a simplified demo, but only if it will be useful.

GillesDuvert commented 2 years ago

Thanks James I noticed that also and it is on my short todo list. This probably comes from a change of type of wxWidgets draw area object I believe (double buffering). No such problem with the wx11 version.

jtappin commented 2 years ago

Thanks Gilles.

jtappin commented 2 years ago

Come to think of it, this might be quite non-trivial. The Fortran version of Graffer doesn't have cross hairs because I wasn't able to get the proper behaviour with PLPLOT + GTK+ drawing area + cairo context, though it was about 8-10 years back so I don't recall the reason.

GillesDuvert commented 2 years ago

Hi James, You are right, wxWidgets uses Cairo and Cairo does not know about INVERT https://github.com/wxWidgets/wxWidgets/issues/16890

GillesDuvert commented 2 years ago

Almost impossible to circumvent in wxWidgets 3. (OK for the Windows version due to the absence of PANGO) Made a remark in the WIKI Should work with wxGTK version 2.x however.

GillesDuvert commented 2 years ago

Concerning Graffer (but also Look.pro) removing the crosshairs if GDL and !version.os_family eq unix would save the day IMHO.

GillesDuvert commented 5 months ago

Hi James, with #1802 I get the crosshairs in graffer, too. But, as graffer works in decomposed=0, it is necessary to do a tiny change in gr_cross_hair.pro:

(...) 
device, set_graphics_function = 10 ; Set graphics function to
                                ; Invert mode
OLDC=!P.COLOR
!P.COLOR=0
case pdefs.transient.mode of
(...) //code of gr_cross_hair
endcase
!P.COLOR=OLDC
device, set_graphics_function = 3 ; Set graphics function

and voilà

jtappin commented 5 months ago

Hi Gilles. Actually since 2016, GRAFFER has used decomposed=1 (so that multiple colour tables could be used in the same window) and mapped the plot colours itself.

I'm not sure why I use graphics function 10 rather than the more usual 6 (XOR), I expect that there was something odd about the way 6 worked (or didn't work) on Sun workstations in the late 1990's, or possibly the non-standard use of !p.color.

GillesDuvert commented 5 months ago

Hi, I just downloaded https://github.com/jtappin/graffer-gdl.git and, after re-enabling crosshair for gdl, the crosshairs will work ok but with !P.COLOR=-1 (not 0 as in comment above). I suspect some other gdl workarounds in Graffer are not necessary anymore...