arohl / gdis

A visualization program for the display, manipulation, and analysis of isolated molecules and periodic structures
GNU General Public License v2.0
43 stars 17 forks source link

FIX missing text #29

Closed ovhpa closed 5 years ago

ovhpa commented 5 years ago

Dear Prof. Rohl,

I believe the following 2 commits will fix the "disappearing text" trouble. The issue was that I previously used cairo to prepare and write text over the pango_print function (previously gl_print_window). On some machine/configuration, this is OK because the gdk_gl_drawable_wait_gl and gdk_gl_drawable_wait_gdk ensure that cairo and openGL draw will not compete. Unfortunately this calls are completely ignored on some software rendering or new configurations. Without these call, cairo will not draw anything on the screen outside of an expose_event.

So I resort to an old (and simple) trick: I create a buffer which I fill with text drawings, using cairo. I then blit the buffer on the screen last using glDrawPixels. It is the same trick that I previously used on the pango_print_world function (previously gl_print_world function).

The second commit fixes a problem in which setting the raster position (using the glRasterPos functions) to the edge of a screen will sometimes fails. I believe this is due to some rounding problem in converting the position from 2D window to 3D raster coordinate. Unfortunately, even a fraction of a pixel outside the view will invalidate the whole drawing! This is the reason for the lines:

glRasterPos2i(canvas->x,canvas->y);
glBitmap(0, 0, 0, 0, -0.5*canvas->width,0.5*canvas->height, NULL);

which are really just a "position to the center, then slide to the edge" trick. However, using that trick, the raster position is always valid.

There is probably a better way to achieve the same result, but I can't figure it out while staying within GTK2/GTKGLEXT.

Would you be so kind as to confirm whether labels are now correctly displayed.

Sincerely,

PS: There is a render efficiency penalty in using glDrawPixels but I think it is quite small, and I think equivalent to the previous state with gl_print_window and gl_print_world functions, minus the GdkGLExt-WARNING **: cannot load PangoFont troubles ;) Anyway, please tell me if you see a decrease of GDIS performances.

arohl commented 5 years ago

I can now see labels. Only one slight oddity; when I click on a peak, the labelled line with the (hkl) appears to the left of it

[cid:02AE2D6D-3950-457E-89F1-B58A15655D9F@fritz.box]

Is this by design?

Andrew

ovhpa commented 5 years ago

I don't understand what you mean, can you provide a picture? Here is how it is supposed to look: diffract when I click on (2 -1 0) peak.