![]() |
Cube GUI Plugin User Guide
(CubeGUI 4.8.2, revision 7895e762)
How to develop a Cube GUI Plugin, road map and examples
|
The following sections describe the steps that are required to create a plugin. For simplicity, a separate project is created and the generated binary will to be copied to the plugin directory of the given cube installation.
Files of the simple cube plugin project:
To create a cube plugin, a makefile and source files have to be generated. The makefile can be generated automatically from a Qt project file
First we specify the path to the "cube-config" script of the cube installation. This script delivers correct flags for compiling and linking.
qmake && make will build the first plugin example libExamplePluginSimple.so. The plugin will be copied to the plugin directory, e.g. /opt/cube/lib64/plugins.
The example describes a minimal cube plugin, which is inserted as an additional tab next to the SystemTree. It shows the text of the recently selected tree item. The complete source of the example can be found in $CUBE_INSTALL_PREFIX/share/doc/cube/example/gui/plugin-example
.
Every cube plugin has to derive from cubepluginapi::CubePlugin. To use Qt's signal and slot mechanism it also has to derive from QObject. If the plugin should be added as a tab next to a tree widget, it has to derive from cubegui::TabInterface.
The class header is followed by the following macro definitions:
Q_OBJECT
is required to handle signals and slots.
Q_INTERFACES( cubepluginapi::CubePlugin )
tells Qt that the class implements the CubePlugin interface and generates the method qt_metacast(char*)
to cast the plugin object to CubePlugin using the class name given as as character array.
Q_PLUGIN_METADATA()
macro. The unique plugin name "SimpleExamplePlugin" is assigned. For Qt versions < 5.0, Q_EXPORT_PLUGIN2
has be be used (see Section SimpleExample.cpp). The class SimpleExample has to implement the pure virtual methods from cubepluginapi::CubePlugin and cubegui::TabInterface.
For Qt versions < 5.0, Q_EXPORT_PLUGIN2
is used to export the plugin. The first argument is a unique name for the plugin, the second the name of the class.
The function cubeOpened(PluginServices* service)
is the starting point of our plugin. Allocation of data and GUI objects should be done here, not in the constructor. This allows to free the resources, if the plugin is deactivated.
Here we create the main widget, which should be added as a system tab. Our plugin derives from TabInterface, so service->addTab(SYSTEMTAB, this)
can be called.
If the user selects a tree item, service will emit a corresponding signal. To react on this event, the signal has to be connected to the slot treeItemIsSelected()
of our plugin class.
The function returns true, if the plugin should be started. It it returns false, the plugin is closed and deleted.
The function cubeClosed()
is called if the cube file is closed or if the plugin is unloaded by the user. All resources which have been allocated in cubeOpened
have to be deleted here.
Each plugin has to set a version number. If several plugins with the same identifier (see function name()
) exist, the one with the highest version number will be loaded.
This function returns the unique plugin name. Only one plugin with this name will be loaded.
The following function returns a text to describe the plugin. It will be used by help menu of the cube GUI.
The following two functions contain the implementation of TabInterface.
The function widget()
returns the QWidget that will be placed into the tab, which has been created with service->addTab
in initialize()
.
The function label()
returns the label of the new tab.
This method is a slot, which is called if a tree item is selected. The argument provides information about the selected item. With item->getDisplayType(), the location (METRIC, CALL, SYSTEM) can be identified.
![]() |
Copyright © 1998–2022 Forschungszentrum Jülich GmbH,
Jülich Supercomputing Centre
Copyright © 2009–2015 German Research School for Simulation Sciences GmbH, Laboratory for Parallel Programming |