Tulip  4.2.0
Better Visualization Through Research
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Groups Pages

This example gives a minimalistic approach of importing a graph and displaying it with Tulip OpenGL rendering engineIn this example, we are making a standalone program that will load a graph file passed as argument to the program and display it into a new window.

The code contains a step-by-step explanation of the process, please refer to classes documentation for more informations about their usage.

#include <tulip/TlpQtTools.h>
#include <tulip/GlMainWidget.h>
#include <tulip/MouseInteractors.h>
#include <QtGui/QApplication>
using namespace tlp;
int main(int argc, char** argv) {
A QApplication must always be declared at the beginning of the main function in order for Tulip to work.
This must be done before calling tlp::initTulipSoftware()
QApplication app(argc,argv);
Initialize the library, load plugins and set application runtime pathes accordingly to the host operating system
This method should always be called if you intend to use plugins in your application.
Load the file passed as first argument into a graph.
This method will select the default Tulip algorithm plugin (TLP)
Graph* g = tlp::loadGraph(argv[1]);
// Creates the main widget that will display our graph
GlMainWidget* mainWidget = new GlMainWidget(NULL);
// Adds a layer to the scene
GlLayer* mainLayer = mainWidget->getScene()->createLayer("Main");
// Adds the graph to this layer
// Display the widget
// Flush event loop in order to let paint events pass through in order for the scene to be initialized.
// Center the camera and draw the graph
// Adds Zoom and pan navigation to the widget
mainWidget->installEventFilter(new MouseNKeysNavigator);
return app.exec();