Guess the lib

BlitzMax Forums/BlitzMax Programming/Guess the lib

Brucey(Posted 2007) [#1]
Seems I just can't help myself... Here's one I started yesterday.



This one I'm very happy with so far.

I've written a BlitzMax native renderer for it, which involved me learning how to draw beziers and non-filled shapes. But, for a days work I think it's looking not too bad. I think it has a lot of potential.
Max-class-diagram-generator anyone? :-p

Can you guess what library it is ?


Dreamora(Posted 2007) [#2]
cairo? :)


Brucey(Posted 2007) [#3]
Nope... this library's primary use is to layout and render things like the screenshot above.

It is true that you can use Cairo with it, but I chose to have Max render the graphics directly - rather than have it use something like Cairo to render to an image surface, and then draw that. So in theory this way is more efficient, as it's making direct calls to the graphics card to draw the lines etc.


LarsG(Posted 2007) [#4]
I don't know what it is, but it sure does look nice..
I can think of a couple of uses for it.. :)


N(Posted 2007) [#5]
Random guess: graphviz?


Brucey(Posted 2007) [#6]
We have a winner ;-)


assari(Posted 2007) [#7]
This is good. I would like to use this


Blitzplotter(Posted 2007) [#8]
Brucey, think you could produce another version of this on your work logs on how you've reached your coding plateau ? I am intrigued, have been coding on and off for 22 years and am interested in your coding path....


Brucey(Posted 2007) [#9]
22 years! That's a long time...
... hmm.. I started when I got my 48k... that's prolly just as long, come to think of it ... :-/

Doesn't time fly when you're having fun? :-)


LAB[au](Posted 2007) [#10]
Wow nice lib! I could use this.


Grey Alien(Posted 2007) [#11]
I started when I got my 48k...
me too, 24 years a few days ago :-)


Brucey(Posted 2007) [#12]
Now that I'm beginning to understand the API more...

The text is now rendering properly (using the FreeType module), colours are sorted, and the graph is drawing the right way up (kind of important that!).

Now for the re-write.... :-p

Apparently, it has an "event" model that allows you to link mouse position, clicks, keys, etc to nodes on the graph, as well as have it lay out according to a configurable display size.... all of which I'm hoping won't be too hard to implement.... yeah...


Brucey(Posted 2007) [#13]
Hmmm... I want it to cope with dashed lines too... I've seen something in the Red Book about line styles for GL. It's a shame Max only seems to support line width, and not styles (like custom dashing).

Anyone have any experience with that on either GL or DX ?

And ailiasing would be nice too....


LarsG(Posted 2007) [#14]
oooohh.. looking better and better, Brucey... :)
me like!

would be cool if you could control it in a way that you could select and drag the different objects around a "canvas"..
one question; are the object shape predefined, or can you draw whatever you want?
Say if I wanted to use this as a schematic view of a technical drawing (network), would it be possible?


Brucey(Posted 2007) [#15]
if you could control it in a way that you could select and drag the different objects around

Not sure yet. Will let you know once I've implemented the "device" plugin.

Graphviz uses a format called dot. It's very easy to use.

http://www.graphviz.org/Gallery/directed/datastruct.html
(click the image to see the dot file that defines the graph)

Graphviz itself decides how best to layout the graph. There are different layout engines that are better for different types of graph

More examples here : http://www.graphviz.org/Gallery.php

:o)


LAB[au](Posted 2007) [#16]
I have been reading your worklog on this and I love the direction it takes :) Please keep us informed!


Brucey(Posted 2007) [#17]
*Finally* solved my zooming issue!!!

It only took the better part of a week for me to realize that I had to go back to some old high-school math to sort it out. (Yes, Miss Maths teacher, it finally came in useful, 20 years later... ;-)

Anyhoo...

This is a nice example showing a zoomed in section of a graph with GL_LINE_SMOOTH enabled.

I'm leaving it up to the user to enable this kind of functionality or not. Since the module is drawing via Max2D, you can enable or disable the features you want, and hopefully the drawing routines will pick them up.
Seems to work fine for line smoothing in my test app.

Things that would be nice to implement are :
* different line styles - a look in the Red Book shows that you can do this in GL.
* Line widths.

and of course access to node/edge attributes, which I'm currently working on :-)

Has anyone tried using line styles at all?


Brucey(Posted 2007) [#18]
I'm wondering if it might be useful to anyone if I were to expose the part of the API that allows you to create a graph programmatically... ie. create a graph object, create a couple of nodes, join the nodes with an edge... etc.. ??

Or... you could generate the digraph text and pass it to the engine that way...

Any thoughts ?


LAB[au](Posted 2007) [#19]
I would love to have this part of the API. I would use graphviz in a script/logic editor, using its automatic layout/styles (and your mouse inetraction/events) but without ever needing to save the graph.


Brucey(Posted 2007) [#20]
The in-memory graph stuff is working rather well. One of the possibly useful features is that a graph object will take any attribute name/value pair, which could be useful for using as a reference back into your code, perhaps (like looking up value in a TMap).

At the moment, only object selection (ie. when you click on something) is catered for. Would anyone find it useful to have access to the same object information when the mouse is "over" that object, rather than having to select it first?

The reason it's not done (yet) is that this isn't so easily accessible through the API, and will require some C-coding to get everything out of the structures.

So, kind of almost ready for some beta-testing if anyone is daring enough. I've only been building it on Linux/Mac (PPC) until now, so no Windows builds for the present. If you're interested, *mail* me (see profile for addy) and I'll let you know when a beta is up. As usual, you will need my "tweaked" BMK, so if you don't already have it (available on my site)...
Am also interested to see how it does on an Intel Mac... :-)


UByte(Posted 2007) [#21]
With regard to line styles, look up glLineStipple.

This link should be useful. When using with Max2D, as the openGL driver simply wraps the GL line rasteriser it should work. I have no idea what the DX alternative is. Alternatively use a 1D texture alphamap.


LAB[au](Posted 2007) [#22]
I will have some time end of next week, I'll watch this thread to see if I can still help with testing by then.


Brucey(Posted 2007) [#23]
Here's the second beta release of the graphviz module... (0.96)

You can download it via : THIS LINK (1.5mb)

Since it's beta, it doesn't have everything finished yet... like win32 support, or the documentation. So a bit of a limited audience for now - until I get back to work and can sort out any win32 features.
Still, it's running fine on Linux and Mac (PPC). I'd be interested in hearing of any issues on Mac Intel.

Things you'll need to try this :
* My expat module to enable enhanced text formatting on the graphs.
* My BMK tweak because the modules need to compile with non-standard compiler options.

Source only too, so you'll need to compile everything up yourself - (This assumes you know how to Build Modules).

The documentation is available, but unfinished. There are three working examples.

Comments, bug reports, are most welcome.
Thanks to Dafs for the line stipple information :-)


(I was almost tempted to post something in the Showcase, but since I already have a thread on the topic here it might be deemed as some as a double post, and might not go down too well with various forum members. So in an effort to prevent my thread being hijacked, I won't be posting anything in the Showcase concerning this topic...)


LAB[au](Posted 2007) [#24]
Downloaded ! Will give it a try soon. Thanks


Brucey(Posted 2007) [#25]
Hi folks.

Just a small update (0.97) which fixes win32 issues. The current examples seem to be running fine now on Windows (win2k, anyway). This release also includes win32 module binaries (hence the increase in size), which means you may not need the tweaked BMK to build an exe on Windows - although this is untested.

You can download it via : THIS LINK (2.3mb)

All the other notes and requirements in my previous post above still apply.

Any questions or problems, please let me know.

Thanks :o)


LAB[au](Posted 2007) [#26]
Hello, thanks for that! Module compiles fine on Linux. Compiling expat module on WinXp return this error:

Build Error: failed to compile C:/Program Files/BlitzMax/mod/bah.mod/expat.mod/src/xmlparse.cC:/Program Files/BlitzMax/mod/bah.mod/expat.mod/src/xmlparse.c:81:2: #error memmove does not exist on this platform, nor is a substitute available
Build Error: failed to compile C:/Program Files/BlitzMax/mod/bah.mod/expat.mod/src/xmlparse.c
Process complete


Brucey(Posted 2007) [#27]
It compiles here using the required tweaked BMK (as mentioned previously).

Actually, all I did was drop the expat module I was using on Linux onto the Win2k box and Build Modules.

of course, the answer here is that for the next release of BlitzMax, they are nice enough to include this ability to customize compilation of modules.
(either that, or I spend too much time hacking modules to build without the need for special settings etc... but it makes it harder to update when a new release of a library appears).


LAB[au](Posted 2007) [#28]
My bad... I thought I had the modified bmk on Win32 (I think I have an older version of the modified bmk!), it compiles fine now. I have been running all 4 examples (on Linux and Win32) and all compiles and behaves like it should, this is a terribly usefull module Brucey! I like it a lot!