GooData: diagrams for screen / printer / files

User projects written in or related to FreeBASIC.
TJF
Posts: 3809
Joined: Dec 06, 2009 22:27
Location: N47°, E15°
Contact:

GooData: diagrams for screen / printer / files

Post by TJF »

I started a new project. The working title is GooData. It aims to create a library for presenting data in diagrams in a technical syle. The library should be similar to DisLin, but it should
  • be based on cairo for high-quality screen, file and printer output (win32 and LINUX)
  • use PangoCairo for system fonts and international characters (UTF-8)
  • be modular, so the user can arrange his page by using a custom set of items (with one or more diagrams on a page)
  • use GooCanvas for arranging the diagram items (in a graphical manner on the screen)
As of now the concept is done and I've about 2000 LOC for two new items
  • GooAxis and
  • GooCurve
Here's an overview of what they can do.

Screenshots and corresponding source code

Image 60 LOC:

Code: Select all

' This is file ex_line_markers.bas
'
' Licence: GPLv3
' (C) 2012 Thomas[ dot ]Freiherr[ at ]gmx[ dot ]net

VAR root = goo_canvas_group_new(Glob, _
            "line_width", line_group, _
             NULL)

VAR title = goo_canvas_text_new(root, _
            "<span size=""xx-large"">"_
            "Line Graph With Markers" _
           !"</span>\n", _
            0.0, 0.0, W, GOO_CANVAS_ANCHOR_SW, _
            "use_markup", TRUE, _
            "alignment", PANGO_ALIGN_CENTER, _
             NULL)

VAR grid = goo_canvas_rect_new(root, _
             0.0, 0.0, W, H, _
            "fill_color", "#F7F19E", _
            "stroke_pattern", NULL, _
             NULL)

VAR x = goo_axis_new(root, grid, Tx, GOO_AXIS_SOUTH, _
            "text_align", PANGO_ALIGN_RIGHT, _
            "offset", "-" & H / 2, _
            "borders", "-3.3 3.3", _
            "tick_length", "5 5", _
            "ticks", "-3 -2 -1 1 2 3", _
             NULL)

VAR y = goo_axis_new(root, grid, Ty, GOO_AXIS_WEST, _
            "text_align", PANGO_ALIGN_RIGHT, _
            "offset", "-" & W / 2, _
            "text_offset", 0., _
            "borders", "-1.15 1.15", _
            "ticks", "-1 -.5 .5 1", _
            "tick_length", "5 5", _
             NULL)

VAR zz = goo_curve_new(root, x, y, Dat, 0, 2, 0, _
            "marker_type", GOO_MARKER_CIRCLE, _
            NULL)

goo_curve_set_markers_properties(zz, _
_            "stroke_color", "green", _
            "stroke_color", "brown", _
            "fill_color", "green", _
             NULL)

VAR z = goo_curve_new(root, x, y, Dat, 0, 1, 0, _
            "marker_type", GOO_MARKER_RHOMBUS, _
            "marker_size", 10., _
             NULL)

goo_curve_set_markers_properties(z, _
            "stroke_color", "brown", _
            "fill_color", "red", _
             NULL)
Image 61 LOC:

Code: Select all

' This is file ex_box_area.bas
'
' Licence: GPLv3
' (C) 2012 Thomas[ dot ]Freiherr[ at ]gmx[ dot ]net

VAR root = goo_canvas_group_new(Glob, _
            "line_width", line_group, _
            "font", "Arial", _
             NULL)

VAR title = goo_canvas_text_new(root, _
            "<span size=""xx-large"">"_
            "Areas in a Grid Box" _
           !"</span>\n", _
            0.0, 0.0, W, GOO_CANVAS_ANCHOR_SW, _
            "use_markup", TRUE, _
            "alignment", PANGO_ALIGN_CENTER, _
             NULL)

VAR grid = goo_canvas_rect_new(root, _
            0.0, 0.0, W, H, _
            "line_width", line_group, _
             NULL)

VAR x = goo_axis_new(root, grid, Tx, GOO_GRIDAXIS_SOUTH, _
            "borders", "-3.3 3.3", _
            "ticks", "1", _
             NULL)

goo_axis_set_grid_properties(x, _
            "stroke_color", "lightgray", _
             NULL)

VAR y = goo_axis_new(root, grid, Ty, GOO_GRIDAXIS_WEST, _
            "text_offset", 7., _
            "borders", "-1.15 1.15", _
            "ticks", ".5", _
             NULL)

goo_axis_set_grid_properties(y, _
            "stroke_color", "lightgray", _
             NULL)

VAR zz = goo_curve_new(root, x, y, Dat, 0, 2, 0, _
            "stroke_color", "green", _
            "area", "y0", _
             NULL)

goo_curve_set_area_properties(zz, _
            "fill-color-rgba", &h00C00030, _
             NULL)

VAR z = goo_curve_new(root, x, y, Dat, 0, 1, 0, _
            "fill_color", "lightred", _
            "stroke_color", "red", _
            "area", "y0", _
             NULL)

goo_curve_set_area_properties(z, _
            "fill-color-rgba", &hC0000030, _
             NULL)
Image 86 LOC:

Code: Select all

' This is file ex_3d_perpens.bas
'
' Licence: GPLv3
' (C) 2012 Thomas[ dot ]Freiherr[ at ]gmx[ dot ]net

VAR root = goo_canvas_group_new(Glob, _
            "line_width", line_group, _
             NULL)

VAR title = goo_canvas_text_new(root, _
            "<span size=""xx-large"">"_
            "3D Effect, Perpendiculars, Background Pixbuf" _
           !"</span>\n", _
            0.0, 0.0, W, GOO_CANVAS_ANCHOR_SW, _
            "font", "Purisa Bold Italic", _
            "use_markup", TRUE, _
            "alignment", PANGO_ALIGN_CENTER, _
             NULL)

VAR pixbuf = gdk_pixbuf_new_from_file("FreeBasic.png", 0)
VAR grid = goo_canvas_rect_new(root, _
             0.0, 0.0, W, H, _
            "stroke_color", "yellow", _
            "fill_color", "lightyellow", _
            "line_width", line_group, _
             NULL)

VAR image = goo_canvas_image_new(root, _
            pixbuf, _
            0.0, 0.0, _
            "width", W, _
            "height", H, _
            "scale-to-fit", TRUE, _
             NULL)

VAR x = goo_axis_new(root, grid, Tx, GOO_AXIS_SOUTH, _
            "stroke_color", "yellow", _
            "fill_color", "yellow", _
            "offset", "25 27", _
            "borders", "-3.3 3.3", _
            "tick_length", "0.01", _
            "tick_angle", -30.0, _
            "ticks", "1", _
             NULL)

goo_axis_set_ticks_properties(x, _
            "stroke_color", "black", _
             NULL)

goo_axis_set_text_properties(x, _
            "fill_color", "black", _
             NULL)

VAR y = goo_axis_new(root, grid, Ty, GOO_AXIS_EAST, _
            "stroke_color", "yellow", _
            "fill_color", "yellow", _
            "offset", "25 -27", _
            "text_offset", 7., _
            "borders", "-1.15 1.15", _
            "ticks", ".5", _
            "tick_length", "0.01", _
            "tick_angle", -30.0, _
             NULL)

goo_axis_set_ticks_properties(y, _
            "stroke_color", "black", _
             NULL)

goo_axis_set_text_properties(y, _
            "fill_color", "black", _
             NULL)

VAR zz = goo_curve_new(root, x, y, Dat, 0, 2, 0, _
            "stroke_color", "green", _
            "perpendiculars", "C1", _
             NULL)

goo_curve_set_perpens_properties(zz, _
            "stroke_color_rgba", &hC0C0C090, _
             NULL)

VAR z = goo_curve_new(root, x, y, Dat, 0, 1, 0, _
            "stroke_color", "red", _
             NULL)

goo_canvas_item_set_simple_transform(root, W / 2, h / 2, 1.0, 30.0)
Anybody interested in
  • A) using this library,
    B) participating in the project?
In case of B) I'm looking for
  • beta-testers with good ideas how to make the API more powerful and easier to use
  • authors for the documentation
  • programmers keen on (or able and willing to learn) GLib, Cairo, GooCanvas, ...
  • an PR expert for creating and maintaining a website with repository and Wiki (ie at sourceforge)
agamemnus
Posts: 1842
Joined: Jun 02, 2005 4:48

Re: GooData: diagrams for screen / printer / files

Post by agamemnus »

I would definitely use this library at some point. I've made crude graphing stuff in the past, for my own mini-projects...
TJF
Posts: 3809
Joined: Dec 06, 2009 22:27
Location: N47°, E15°
Contact:

Re: GooData: diagrams for screen / printer / files

Post by TJF »

@agamemnus

Thanks for your interest. I think I'll do some documentation work before I'll publish the first version (any help is welcome).

@All

Has anybody generated GNOME style html documentation for a FB project?
Sebastian
Posts: 131
Joined: Jun 18, 2005 14:01
Location: Europe / Germany
Contact:

Re: GooData: diagrams for screen / printer / files

Post by Sebastian »

Hey TJF,

This is definitely a very neat, interesting project. I can think of several project ideas in which it was quite handy to have such a library.

Sebastian
TJF
Posts: 3809
Joined: Dec 06, 2009 22:27
Location: N47°, E15°
Contact:

Re: GooData: diagrams for screen / printer / files

Post by TJF »

@Sebastian

thanks for your 'thumb-up'.

I'm working on the documentation now (snapshot here) and hopefully I'll get a complete version for the first upload soon.

And hopefully the first upload will animate not only users but also developers to participate in this project ;-)
TJF
Posts: 3809
Joined: Dec 06, 2009 22:27
Location: N47°, E15°
Contact:

Re: GooData: diagrams for screen / printer / files

Post by TJF »

The source is now available at

https://github.com/dtjf/GooData
MrSwiss
Posts: 3910
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: GooData: diagrams for screen / printer / files

Post by MrSwiss »

@TJF,

your Libraries do all have a problem and that is, the licensing under GPLv3.
This may also be the reason, why it is so difficult (for you) to get any collaborators on
them. I'd not use any of them, if I could not use them in commercial applications,
without having to disclose its source (source of the application itself).

You might want to consider using the LGPL instead ... maybe even with exclusion, for
static linking? (like FB's lib's are)

Just my 2 cents.
Munair
Posts: 1286
Joined: Oct 19, 2017 15:00
Location: Netherlands
Contact:

Re: GooData: diagrams for screen / printer / files

Post by Munair »

The MLGPL might be a good choice. It also applies to Lazarus code. Here is a copy:
http://www.basicstudio.org/mlgpl.html

Pay special attention to the modification, which is the last paragraph.
TJF
Posts: 3809
Joined: Dec 06, 2009 22:27
Location: N47°, E15°
Contact:

Re: GooData: diagrams for screen / printer / files

Post by TJF »

MrSwiss wrote:@TJF,

... the licensing under GPLv3.

You might want to consider using the LGPL instead ... maybe even with exclusion, for
static linking? (like FB's lib's are)

Just my 2 cents.
Thanks for your feedback, but what are you talking about?
Did you read the license file? Where did you find GPLv3 in that lib (or any other)?
MrSwiss
Posts: 3910
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: GooData: diagrams for screen / printer / files

Post by MrSwiss »

Code: Select all

' This is file ex_3d_perpens.bas
'
' Licence: GPLv3
' (C) 2012 Thomas[ dot ]Freiherr[ at ]gmx[ dot ]net
Isn't this clear enough?
TJF
Posts: 3809
Joined: Dec 06, 2009 22:27
Location: N47°, E15°
Contact:

Re: GooData: diagrams for screen / printer / files

Post by TJF »

MrSwiss wrote:

Code: Select all

' This is file ex_3d_perpens.bas
'
' Licence: GPLv3
' (C) 2012 Thomas[ dot ]Freiherr[ at ]gmx[ dot ]net
Isn't this clear enough?
This is example code, not the library.
MrSwiss
Posts: 3910
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: GooData: diagrams for screen / printer / files

Post by MrSwiss »

OK got it from GIT, it says 'Lesser GPL', which I find somewhat confusing,
should read 'LGPL', IMO. Apologies.
badidea
Posts: 2586
Joined: May 24, 2007 22:10
Location: The Netherlands

Re: GooData: diagrams for screen / printer / files

Post by badidea »

I tried to get this working on linux with 64-bit fbc, but no luck so far.
I have libgoocanvas installed (although not sure which version)

When I try to compile "GooData-master/examples/test.bas" I get:
ld: cannot find -lGoo_Data

When I try to compile "GooData-master/src/Goo_Data.bas" I get multiple errors:
Goo_Data.bas(179) error 1: Argument count mismatch, found ')' in 'goo_data_points_unref)'
Goo_Data.bas(241) error 41: Variable not declared, __func__ in 'g_return_if_fail(Row < .Row)'
Goo_Data.bas(242) error 9: Expected expression, found '__func__' in 'g_return_if_fail(Column < .Col)'
etc...


What is going wrong?

BTW, when I try "FreeBASIC-1.05.0-linux-x86_64/examples/GUI/GTK+/GooCanvas/GooGrid.bas" it works perfect:
Image
TJF
Posts: 3809
Joined: Dec 06, 2009 22:27
Location: N47°, E15°
Contact:

Re: GooData: diagrams for screen / printer / files

Post by TJF »

Hi badidea!

Please note: this is old code from 2013, before fbc got 64 bit support!
badidea wrote:I tried to get this working on linux with 64-bit fbc, but no luck so far.
I have libgoocanvas installed (although not sure which version)
The command dpkg -l libgoocanvas* should show the version.
badidea wrote:When I try to compile "GooData-master/examples/test.bas" I get:
ld: cannot find -lGoo_Data
This is intentional. You've to compile and install the library first. Note: The linker has to create a shared library (not an executable binary). But ...
badidea wrote:When I try to compile "GooData-master/src/Goo_Data.bas" I get multiple errors:
Goo_Data.bas(179) error 1: Argument count mismatch, found ')' in 'goo_data_points_unref)'
Goo_Data.bas(241) error 41: Variable not declared, __func__ in 'g_return_if_fail(Row < .Row)'
Goo_Data.bas(242) error 9: Expected expression, found '__func__' in 'g_return_if_fail(Column < .Col)'
etc...


What is going wrong?
goo_data_points_unref in line 179 is part of a macro. The compiler should just store, but not compile that source. Is your code distorted? The messages regarding __func__ seems to be related to a faulty header file. __func__ is the C equivalent to __FUNCTION__ in FreeBASIC. Obviously as miss-translation from fb-frog.

To be on the safe side, replace in file Goo_Data.bi the line '#INCLUDE ONCE "goocanvas.bi" by

Code: Select all

#INCLUDE ONCE "Gir/GooCanvas-2.0.bi"
#INCLUDE ONCE "Gir/_GLibMacros-2.0.bi"
#INCLUDE ONCE "Gir/_GObjectMacros-2.0.bi"
And download the header files from gir_headers project.
badidea wrote:BTW, when I try "FreeBASIC-1.05.0-linux-x86_64/examples/GUI/GTK+/GooCanvas/GooGrid.bas" it works perfect:
This is a good message, the LINUX part of your box is well prepared.

Now the bad message: Goo_Data uses a lot of VA_ARG commands. This works well with -gen gas backend, but the compiler doesn't support it with -gen gcc. And gcc is mandatory for 64 bit. So the current Goo_Data cannot get compiled for 64 bit.

In order to compile that library, you have to either use a 32 bit environment (seems more easy for a quick test). Or you've to adapt the source to cva_list for 64 bit/gcc.

Regards
badidea
Posts: 2586
Joined: May 24, 2007 22:10
Location: The Netherlands

Re: GooData: diagrams for screen / printer / files

Post by badidea »

TJF wrote:Now the bad message: Goo_Data uses a lot of VA_ARG commands. This works well with -gen gas backend, but the compiler doesn't support it with -gen gcc. And gcc is mandatory for 64 bit. So the current Goo_Data cannot get compiled for 64 bit.
I see, Jeff Marshall on https://sourceforge.net/p/fbc/bugs/881/ : "There are, no plans to support VA_FIRST(), VA_NEXT(), VA_ARG() on 64-bit version. These macros depend on arguments passed on stack only and won't be modified to handle arguments passed by register."
TJF wrote:In order to compile that library, you have to either use a 32 bit environment (seems more easy for a quick test). Or you've to adapt the source to cva_list for 64 bit/gcc.
I have problems with getting the 32-bit libs installed on my 64-bit linux. The package manager wants remove libraries went I try install the 32-bit libs. Which I don't like. So I guess, have have to look into the 2nd option: cva_list. Which I have not used before.
Post Reply