jheinen / GR.jl

Plotting for Julia based on GR, a framework for visualisation applications
Other
354 stars 76 forks source link

Using gr #19

Closed ma-laforge closed 8 years ago

ma-laforge commented 8 years ago

Hi Josef,

Thanks for GR (+other developers). It looks very promising. It seems faster than other alternatives out there.

Problem: Documentation seems limited, and so are examples.

Question 1: GR appears to be usable as an alternative for the functionality that Cairo provides. Am I understanding this correctly?

Question 2: How would I render a plot on Gtk backend instead of the standard GKS pop-up window?

It looks like you can use openws() for workstation_type = 371, but I am unsure what the other parameters are for. I also am not clear on how to use this particular API (none of the drawing functions appear to take workstation_id as an argument).

Question 3: Can you have a "workstation" that writes to an uncompressed (RAW) bitmap (as opposed to PNG, for example)?

Once open, can this bitmap be rendered on another canvas (ex: the Cairo backend of a Gtk window?)

Thanks,

MA

jheinen commented 8 years ago

Answer 1: Well, I think, GR is more than just a "graphics backend". In the meantime, there are powerful plot functions for Julia (as known from MATLAB), both for 2D and 3D. Python support for this convenience layer is coming soon.

Answer 2: Unfortunately, the GTK part had been temporary removed due to build problems. I added a Cairo driver to the GR graphics subsystem some days ago - this should allow us to re-enable the GTK part (which itself uses Cairo). So, your request is on my radar ...

At the moment, you can only embed GR graphics in Qt 4.x and wxWidgets GUIs. The are simple demos in the examples directory (pyqt4_ex.py, pyside_ex.py, wx_ex.py), that have been tested an all platforms. The embedding mechanism for GTK will be similar to Qt and wxWidgets.

Answer 3: You can use the GR.drawimage() function to plot an image given as an array of RGBA Integer values (32 Bit) or use the (new MATLAB-like) imshow() function.

I will provide documentation for the new convenience layer ASAP.

jheinen commented 8 years ago

Today, I added support for Gtk widgets. Here, you can find a simple example, how to use GR to draw in a Gtk drawing area (via the new CairoGraphics driver). Tomorrow, we'll probably tag a new GR release, providing this (and other new) feature(s). Will add a more sophisticated Gtk example, too.

ma-laforge commented 8 years ago

Thanks for that! I will have to look at these examples in more detail.

Thanks for pointing me to drawimage() & imshow() as well.

I hope I can get things working with Gtk directly from Julia. I would rather not have to load up Python (significant load times).

PS

I am very anxious to see GR.jl examples saving to cgm.

I found cgm still has better application support out there than svg (yes, it even has good support in Windows apps)...

...And Windows metafiles mostly only work in Windows.

jheinen commented 8 years ago

ed31350 contains a simple Gtk example. Unfortunately, I had to apply an ugly workaround to avoid Cairo crashes when getting the text extent (https://github.com/jheinen/gr/commit/dc27f781a5399942113c43cbdfb4fe4f4f8e4972). I will provide new binaries next week, so you can rebuild you GR.jl package.