[Gammaray-interest] Graph library

Kevin Funk kevin.funk at kdab.com
Wed May 22 16:31:36 CEST 2019


On Tuesday, 21 May 2019 17:46:39 CEST Christian Gagneraud wrote:
> Hi there,
> 
> I've been working on implementing a Qt/C++ wrapper library for
> GraphViz's libcgraph/libgvc. Surprisingly, I couldn't find anything
> re-usable and flexible.

Heya,

What about KDStateMachineEditor, which in fact does exactly that?

Here's the project page:
  https://github.com/KDAB/kdstatemachineeditor

It's the state chart visualization backend for GammaRay. It in fact uses 
Graphviz to do the layouting. But somehow I get the feeling you already know 
that and you'd like to start a fresh implementation? :)

I just improved the top-level ReadMe of the project a bit more, so one gets a 
better overview about KDSME's capabilities.

Please especially note the features overview. KDSME might not be perfect, but 
it has lots of things covered already. Especially the Qt integration bits, 
such as a QStateMachine/QtSCXML debugger, .scxml importer, etc. pp.. 

Due to lack of time, it currently uses an outdated Graphviz version. Something 
which should be fixed. Fine-tuning the layouting parameters (to create more 
dense state charts) would be another well-seen improvement.

Let me know what you think about KDSME, and (potentially) why it doesn't fit 
your use-case?

Cheers,
Kevin


> Are you interested?
> 
> If so, then i would like to submit the first part: libcgraph.
> These wrappers allows to create, manipulate and "walk" graphs. These
> are value class that encapsulate underlying C pointers (and hide the
> cgraph crazy/messy API). My value class based approach is IMHO very
> efficient, but has few drawbacks. I'm happy to discuss and rework it.
> 
> Next stage would be the wrapper for the layout and the rendering, I've
> already implemented the layout wrappers and a "hot-pluggable" render
> plugin  that renders a layed out graph into a QGraphicsScene. It's
> surprisingly very lightweight and was easy too. This is IMHO way
> better than invoking "dot" from the command line to display an SVG.
> This will allow to access the full layed out graph structure,
> including clusters, sub-graph, etc...
> 
> After that, i would like to propose "attributes" handling, which i'm
> still working on.
> The attributes allows you to configure the layout algorithms (dot,
> neato, ...)  and tweak a few geometric/visual things at
> graph/node/edge level. So far, i've taken the path of wrapping the
> whole graphviz string pairs attribute zoo [1] behind a carefully
> selected and named sub-set implemented as enums/qvariant, I think the
> pain was worth the effort.
> 
> Finally, there will be a need for export in dot/xdot files, and a
> proper "GraphWidget" UI. I am confident with handling this too, see
> eg. [2].
> 
> But then, ... We'll need some real usage within gammaray! :)
> 
> Chris
> 
> [1] https://www.graphviz.org/doc/info/attrs.html
> [2]
> https://gitlab.com/chgans/le-ipc2581-viewer/raw/master/Screenshot_20170109_
> 135029.png
> 
> PS: Demo time!
> using namespace graphviz;
> void test3()
> {
>     auto rootGraph = Graph("root", DirectedGraph);
>     auto graph1 = rootGraph.addSubgraph("cluster_1");
>     graph1.setLabel("Cluster#1");
> 
>     auto node1 = graph1.addNode("1 circle/solid");
>     node1.setShape("circle");
>     node1.setStyle("solid");
>      ...
> }
> int main(int argc, char *argv[])
> {
>     QApplication a(argc, argv);
>     auto l = new Layout();
>     auto w = new QMainWindow();
>     w->showMaximized();
>     auto s = new QGraphicsScene(w);
>     auto r = new Render(s);
>     auto v = new QGraphicsView();
>     v->setScene(s);
>     v->scale(1.0, -1.0); // Y down
>     w->setCentralWidget(v);
>     auto g = test3();
>     l->render(r, g, HierarchicalLayout);
>     return a.exec();
> }
> 
> and the result: https://i.imgur.com/MInEFJX.png
> _______________________________________________
> Gammaray-interest mailing list
> Gammaray-interest at mail.kdab.com
> https://mail.kdab.com/mailman/listinfo/gammaray-interest


-- 
Kevin Funk | kevin.funk at kdab.com | Senior Software Engineer
KDAB (Deutschland) GmbH, a KDAB Group company
Tel: +49-30-521325470
KDAB - The Qt, C++ and OpenGL Experts
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 5322 bytes
Desc: not available
URL: <http://mail.kdab.com/pipermail/gammaray-interest/attachments/20190522/35e2aa2e/attachment.p7s>


More information about the Gammaray-interest mailing list