Featured post

Qanava

Qanava is an open source LGPL’ed C++ library designed to display graphs in a Qt graphics view. Qanava provide classes to generate various layouts of directed graphs and visualize their nodes with custom styles on a graphic canvas.

Qanava source repository is hosted on Gitorious: https://gitorious.org/qanava

Qanava is primarily developped with Visual C++ 2011 and Qt 5.3 but should compile well with GCC for Linux and GCC-ARM for Android. Qanava depends on Qt property browser: https://qt.gitorious.org/qt-solutions/qt-solutions

For any questions, please contact: benoit@qanava.org

Qanava also include a simple graphics widget container for QGraphicsView with a standalone windowing system (qan::ContainerGraphicsItem could be used without a full Qanava dependency):

Qanava v0.9.2

Qanava-0.9.2 brings full GCC and a preliminary Android support. Actually, Qt Touch support is limited to pinch zomming on Android, using touch for item panning and zomming would probably boost performances in next releases. Creating custom graphics nodes is now easier thanks to a new qan::SimpleNodeItem class, have a look to the new ‘custom’ example that show how to extend Qanava with user defined graphics nodes (a tutorial will be published soon). Standard edge intersection code has been updated to take item shape into account and not only their bounding boxes. Qanava is now primarily developped with QtCreator, build is simplified with a unique ‘qanava.pro’ entry point, you can then select a kit for your favorite platform (I’am still interested in Linux/KDE screenshots…).

Download: http://www.qanava.org/dl/qanava-0.9.2.zip

Gitorious: https://gitorious.org/qanava

20141122_NP_qanava-custom-screenshot

Next Qanava version will bring QTCreator, GCC and Android support

A major Qanava update will be released soon with full GCC (in fact 9.1.0 code wasn’t compiling with GCC, sorry for that) and Android support. The build configuration has been deeply modified for better QT Creator kit support, and you can now easily compile on Windows MSVC or GCC (and MingWin ARM for Android). Projects files for visual studio could still be generated as in 0.9.1 (BTW, Qt Creator is a lot more efficient than Visual…).

Do not hack the code by yourself for GCC, just email me for the latest version until I configure a GIT account for Qanava. I’am looking for feedback and screenshots on a Linux build.

20141115_qtcreator-android-galaxy

Tutorial 1 : Qanava graph model, creating a simple graph

Qanava has a model/view architecture with a graph model encoding graph topology and two intermediate views exposing the graph topology to both Qt Interview widgets and Qt Graphics View:

20141102_NP_tut1-model-view-architecture

Configuring a simple Qanava view :

 // Create a graph model object
 qan::Graph* graph = new qan::Graph( );

 // Create, then configure a graph view object
 qan::GraphView* graphView = new qan::GraphView( this, Qt::white );
 graphView->setGraph( *graph );
 hbox->addWidget( graphView ); // Add the view to an existing layout

Graph model could be populated by adding nodes and edges with dedicated methods, the associated view will be updated automatically :

 qan::Node* q = new qan::Node( "Q" );
 graph->insertNode( q );

 qan::Node* a = new qan::Node( "a" );
 graph->insertNode( a );

 qan::Node* n = new qan::Node( "n" );
 graph->insertNode( a );

 qan::Edge* qa = graph->insertEdge( *q, *a );
 qan::Edge* an = graph->insertEdge( *a, *n );

20141102_NP_tut1-creating-simple-graph-qan-graph

 // Creating a node group
 qan::NodeGroup* group = new qan::NodeGroup( _graph->getM( ), "Node Group" );
 treeGroup->setLayout( new qan::HierarchyTree( ) );
 graph->getM( ).addNodeGroup( *group );
 qan::Node* n1 = graph->insertNode( "N1" );
 qan::Node* n2 = graph->insertNode( "N2" );
 qan::Edge* n1n2 = graph->insertEdge( *n1, *n2 );
 group->addNode( *n1 );
 group->addNode( *n2 );

20141102_NP_tut1-creating-simple-graph-groups

x

Qanava features

Qanava models directed node/edge graphs who are internally stored in a standard node/edge list model. Edges are not weighted by default, but a weight property can be added dynamically. The main class for modeling graphs is qan::Graph who store lists of qan::Node and qan::Edge.

The graph model class can be viewed Qt Interview or Qt Graphics View via qan::GraphScene and qan::GraphModel classes. A qan::Graph instance automatically maintain theses two corresponding objects (via a standard listener) that could be accessed by the user to populate the needed views. Have a look at tutorial 1: Creating a simple graph.

Library comes with ready to use widgets allowing the user to interact with the graph :

  • View tools : simple toolbar widget controlling a Qt Graphics View (and qan::GraphView) to allow user to zoom in/out, navigate via panning or select an area to perform a « window zoom ».

  • Style management : associate style to node and edge and provide a complete style graphic editor (qan::StyleEditor) and a graphics widget allowing to apply styles dynamically by dropping a style preview to an arbitrary node.

  • Grid drawing : qan::Grid subclasses could draw simple grids (actually that code is quite outdated and is just an efficient way to draw check-board style grids).

  • Group management : nodes could be sorted by groups, and the user can drag an drop nodes to populate its groups (qan::NodeGroup), groups could actually be seen like a pure hyper-edge implementation.

  • Custom window container : qan::ContainerItem avoid the use of QGraphicsWidget that generate platform dependent windows decorations with an easy to use and fast QGraphicsItem based container showing a window decoration (it could actually display a title, allow window moving, resizing and minimization).

Qanava is not designed to visualize large graphs using complex layout algorithms, but rather to display very specific medium sized graphs with complex properties in an advanced graphical user interface.

Qanava 0.9.1 installation

For Windows with QT 5.3 and Visual Studio > 2011:

First, you need to get the latest Qanava archive on : http://www.qanava.org/dl (qanava-0.9.1-ceyx.zip), and unzip it in a local directory, for example : c:\qanava-0.9.1 (referred as $(QANAVADIR))

Now, get qtpropertybrowser in he qt-tools (and not in qt-solutions) GIT repository : https://qt.gitorious.org/qt/qttools (in the src/shared/propertybrowser directory, altough it is now largely unmaintened)

Or directly from an official Qt release .zip archive, for example for Qt 5.3.2: http://download.qt-project.org/official_releases/qt/5.3/5.3.2/submodules/qttools-opensource-src-5.3.2.zip

Now, qtpropertybrowser, by modifying the qtpropertybrowser.pri file to support static linking in both release and debug mode. Add the following configuration settings at the head of the .pri file :

LANGUAGE = C++
DEFINES += QT_QTPROPERTYBROWSER_EXPORT 
TARGET = libpropertybrowser
DESTDIR =  
CONFIG += debug warn_on qt thread staticlib
TEMPLATE = lib 

Release:DESTDIR = release
Release:TARGET = libpropertybrowser
Release:OBJECTS_DIR = release/.obj
Release:MOC_DIR = release/.moc
Release:RCC_DIR = release/.rcc
Release:UI_DIR = release/.ui

Debug:DESTDIR = debug
Debug:TARGET = libpropertybrowserd
Debug:OBJECTS_DIR = debug/.obj
Debug:MOC_DIR = debug/.moc
Debug:RCC_DIR = debug/.rcc
Debug:UI_DIR = debug/.ui

Then, generate a visual studio project file to compile libpropertbrowser with the following command : “qmake -t vclib qtpropertybrowser.pri” and compile in both release and debug from the visual studio IDE. Do not forget to add a QTPROPERTYBROWSER environnement variable pointing to the root of this source directory, since it is used later in Qanava build configuration.

Then, in $(QANAVADIR)\build\qan, just use the following command “qmake -t vclib” to generate Qanava project file.

Examples and tests could be built in the same way, generating their project’s file using the “qmake -t vcapp” command, and inserting the resulting project in a solution with qanava.vcproj.