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 developed with Qt Creator (MSVC 2012) and Qt 5.4 but compiles well with G++ 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: firstname.lastname@example.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 GIT repository has been updated with the latest development version coming with a lot of changes and bug-fixes:
– Majors changes in node rendering architecture: drawing code has been simplified, and node content layout is now done with Qt graphics layouts instead of (buggy) proprietary code.
– Updates in QML menu bar: menu bar can now be used on top of standard Qt widget (ie it is transparent for mouse and user inputs on areas not covered by menu items) and support a transparent style and new configuration options.
– Style browser has been re-activated.
Default “rounded” nodes with gradient painting and shadows
QML menu bar (in a QQuickWidget) with transparent style and background widget
QanMenuBar is a simple dynamic QML based menu (with both a declarative and c++ interface based on QAction). QanMenuBar will be used in Qanava samples, and maintained in the library into a separate directory. (‘qmlmenubar’). QanMenuBar is reusable outside of the library without any dependency on Qanava (just add Qan*.qml files to your project resources, then configure project .pro as in ‘qmlmenubar.pro’).
Documentation will come with the 0.9.3 final release, have a look to: https://gitorious.org/qanava/qanava/source/qmlmenubar
Qanava 0.9.3 preview has been pushed to the GITorious repository. Nodes groups management has been deeply modified and the existing graphics container item has been totally rewritten in a more clean and modular way :
- Class qan::GraphicsContainer now replace qan::ContainerGraphicsItem to provide an efficient graphics widget (and graphics item) container system. Graphics container now provide a rectangular (“square” setting) area for tour graphics widgets with a Qt Creator style window decoration (but without the cost of QGraphicsWidget and its horrible Qt::Window creation flag). Original “round” style is still fully supported.
- Qanava provide two new controllers items:
- qan::GraphicsController add a close, minimize/maximize and develop/unvlop button, along with automatic focus shadow.
- qan::GraphicsResizer add resizing support for any QGraphicsItem object implementing the standard graphics layout interface (QGraphicsLayoutItem).
- Qanava nodes groups could now be laid out with graphics linear layout (QGraphicsLinearLayout). Linear layout can also be used inside groups along with Qanava layouts such has hierarchy trees or dynamic undirected graphs.
QTextEdit widgets in a graphics view in the content area of a Qanava graphics container
QGraphicsView with a a graphics pixmap item used as a Qanava container content trough a graphics widget proxy
Graphics view showing a label based on QLabel trough a graphics widget proxy with a Qanava controller (with a close/minimize/maximize and focus shadow)
Class qan::ContainerGraphicsItem is now deprecated and has been removed from the source tree.
Warning 1 : Qanava controllers relies on scene events filters, using controller on existing graphics items using events filters could lead to events ventilation problems in your code (contact me if it is open source).
Warning 2 : Qt >=5.4 should be used or Qanava will be affected by QTBUG-20132 : https://bugreports.qt-project.org/browse/QTBUG-20132, and graphics controllers expand button will not work (it will not lead to a crash with previous versions).
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…).
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.
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:
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 );
// 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 );
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::GraphicsContainer 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.
If you are a developper, please contact me directly if you have any troubles compiling Qanava on your plateform: email@example.com