sciapp / gr

GR framework: a graphics library for visualisation applications
Other
328 stars 55 forks source link

Struggling with the documentation #111

Closed mantielero closed 4 years ago

mantielero commented 4 years ago

I have created some bindings for the Nim programming language. But I am having issues when I try to use the library (I am not very familiar with GR).

There are some functions that are undocumented in the C api. For instance, I am struggling to put the appropriate size for the window.

I have checked this and this. But inqdspsize is undocumented.

jheinen commented 4 years ago

With gr_setwsviewport(), you can set the metric size. You should always use this function in conjunction with gr_setwswindow() to set the correct aspect ratio.

Example (A4 format):

gr_setwsviewport(0, 0.297, 0, 0.21)
gr_setwswindow(0, 1, 0, 0.21/0.297)

or (in portrait orientation):

gr_setwsviewport(0, 0.21, 0, 0.297)
gr_setwswindow(0, 0.21/0.297, 0, 1)
mantielero commented 4 years ago

Thanks a lot. And what about inqdspsize?

jheinen commented 4 years ago

inqdspsize returns the display size (in metric and pixel coordinates). (0.5965504497563073, 0.33555962798792294, 2560, 1440) => 59.7 x 0.34 cm with a pixel resolution of 2560 x 1440

FlorianRhiem commented 4 years ago

I am currently investigating some strange behavior of gr_inqdspsize() with gksqt, after that I will document it.

Thanks for you work on bringing GR to Nim!

mantielero commented 4 years ago

Probably this is what was confusing me. I am working on the screen After running inqdspsize I had:

mwidth: 0.2856   width: 1280
dpi: 113.8375350140056

This means that it should be 0.28cm in the screen. If I take a ruler, it is something like 8cm. If I do gr_setwsviewport with mwidth=0.20 I get a window with 20cm in the screen, so it looks like inqdspsize is not returning proper mwidth.

mantielero commented 4 years ago

Another topic that I don't really understand gr_setwswindow purpose. I guess that it is not only to set the aspect ratio. But I don't understand what it does.

For instance, if I have gr_setwsviewport(0, 0.1, 0, 0.1) (a 10x10 cm window), what happens if I do: gr_setwswindow(0.5,1.0,0.0,1.0). It looks like the image is displaced in the viewport, not deformed.

mantielero commented 4 years ago

Addtionaly, if I do: gr_setwsviewport(0.5, 0.1, 0.5, 0.1), shouldn't the window measure 5 x 5 cm?

FlorianRhiem commented 4 years ago

I have documented the function in the code this will be part of the online documentation with the next release.

gksqt did not report the display size before that commit, so you might have to use the current develop branch or wait until the next release for gr_inqdspsize to return correct values when using gksqt.