Cube GUI Plugin User Guide  (CubeGUI 4.6, revision ff50a50d)
How to develop a Cube GUI Plugin, road map and examples
Signals | Public Member Functions | Static Public Member Functions | List of all members
cubepluginapi::PluginServices Class Reference

#include <PluginServices.h>

Inheritance diagram for cubepluginapi::PluginServices:
QObject

Signals

void treeItemIsSelected (cubepluginapi::TreeItem *item)
 
void orderHasChanged (const QList< cubepluginapi::DisplayType > &order)
 
void contextMenuIsShown (cubepluginapi::DisplayType type, cubepluginapi::TreeItem *item)
 
void genericUserAction (cubepluginapi::UserAction action)
 
void globalValueChanged (const QString &name)
 
void tabActivated (cubepluginapi::DisplayType type)
 

Public Member Functions

cube::CubeProxy * getCube () const
 
const QString & getCubeFileName () const
 
QString getCubeBaseName () const
 
QString getStatName () const
 
QWidget * getParentWidget () const
 
const QList< TreeItem * > & getTreeItems (DisplayType type) const
 
const QList< TreeItem * > & getTreeItems (TreeType type) const
 
const QList< TreeItem * > getTopLevelItems (DisplayType type) const
 
TreeItem * getSystemTreeItem (uint32_t sysId) const
 
TreeItem * getCallTreeItem (uint32_t cnodeId) const
 
TreeItem * getMetricTreeItem (std::string metricId) const
 
void addMarker (const TreeItemMarker *marker, TreeItem *metric, TreeItem *call, TreeItem *system)
 
void addMarker (TreeItem *item, const TreeItemMarker *marker, bool isDependency=false)
 
void removeMarker (TreeItem *item, const TreeItemMarker *marker)
 
void removeMarker ()
 
void removeMarker (DisplayType type)
 
const TreeItemMarker * getTreeItemMarker (const QString &label, const QList< QPixmap > &icons=QList< QPixmap >(), bool isInsignificant=false, MarkerLabel *markerLabel=0)
 
const QList< cubepluginapi::DisplayType > & getOrder () const
 
ValueModus getValueModus () const
 
TreeItem * getSelection (DisplayType type) const
 
const QList< TreeItem * > & getSelections (DisplayType type) const
 
bool intMetricSelected () const
 
void selectItem (TreeItem *item, bool add)
 
QAction * addContextMenuItem (DisplayType type, const QString &menuItemText)
 
QMenu * enablePluginMenu ()
 
void addToolBar (QToolBar *toolbar, TabInterface *tab=0)
 
void removeToolBar (QToolBar *toolbar, TabInterface *tab=0)
 
void setMessage (const QString &str, cubepluginapi::MessageType type=cubepluginapi::Information)
 
int getActiveSubsetIndex () const
 
const QList< TreeItem * > & getActiveSubset () const
 
void setActiveSubset (int index)
 
QStringList getSubsetLabelList () const
 
int defineSystemTab (const QString &label, TabType tabType=DEFAULT_TAB)
 
void addTab (cubepluginapi::DisplayType type, TabInterface *tab, int tabWidgetID=DEFAULT_TAB)
 
void removeTab (TabInterface *tab)
 
void enableTab (TabInterface *tab, bool enabled)
 
void toFront (TabInterface *tab)
 
void clearValueWidget ()
 
void updateValueWidget (TabInterface *tc, double minValue, double maxValue, double value=std::nan(""), double minAbsValue=std::nan(""), double maxAbsValue=std::nan(""), double absValue=std::nan(""), double mean=std::nan(""), double varianceSqrt=std::nan(""))
 
void addSettingsHandler (SettingsHandler *s)
 
void addColorMap (ColorMap *map)
 
void addValueView (ValueView *view)
 
void setGlobalValue (const QString &name, const QVariant &value, bool notifyMyself=false)
 
QVariant getGlobalValue (const QString &name) const
 
QColor getColor (double value, double minValue, double maxValue, bool whiteForZero=true) const
 
QPair< QString, QString > formatNumberAndUnit (double value, const QString &unit, PrecisionFormat format, bool integerType=false) const
 
QString formatNumber (double value, PrecisionFormat format, bool integerType=false) const
 
QString formatNumber (double value, bool integerType=false) const
 
void recalculateTreeItems ()
 
void recalculateTreeItem (cubegui::TreeItem *item)
 
void updateTreeItems ()
 
void updateTreeView (DisplayType treeType)
 
void updateTreeView (TreeType type)
 
QTextStream & debug ()
 
void setUserDefinedMinMaxValues (DisplayType type)
 
bool getUserDefinedMinValues (DisplayType type, double &min, double &max) const
 
void addMetric (cube::Metric *metric, TreeItem *parent=0)
 
void removeMetric (TreeItem *metricItem)
 
void updateMetric (TreeItem *metricItem)
 
Tree * getActiveTree (cubegui::DisplayType type) const
 
bool hasIterations ()
 
Future * createFuture (TabInterface *tab=0)
 
QStringList getBookmarks ()
 
void loadBookmark (const QString &name, bool loadGlobals=false)
 
QString getBookmarkDescription (const QString &name)
 
QList< cubegui::TabInterface * > getTabList ()
 

Static Public Member Functions

static QTextStream & debug (const QString &sender)
 

Member Function Documentation

void cubepluginapi::PluginServices::addColorMap ( ColorMap map)

Adds a colormap to the list of available colormaps from which the user can choose the active one.

QAction* cubepluginapi::PluginServices::addContextMenuItem ( DisplayType  type,
const QString &  menuItemText 
)

Inserts a menu item to the context menu of the treeWidget of the given type and returns the corresponding action. The action is automatically deleted after the context menu is closed.

Parameters
typeMETRIC, CALL, SYSTEM
menuItemTextthe label of the created context menu item
void cubepluginapi::PluginServices::addMarker ( const TreeItemMarker *  marker,
TreeItem *  metric,
TreeItem *  call,
TreeItem *  system 
)

Marks the given tree item item combination with a marker. The items of the left and the middle tree are marked as dependency, the item of the rightmost tree is marked with the given marker. If an item with NULL value is given, the rightmost item left to this item is marked. Examples: DemoPlugin, StatisticPlugin, LaunchPlugin

Parameters
markersee getTreeItemMarker
See also
Pluginservices::getTreeItemMarker
void cubepluginapi::PluginServices::addMarker ( TreeItem *  item,
const TreeItemMarker *  marker,
bool  isDependency = false 
)

Marks the given tree item with a marker, use updateTreeView to activate it. The plugin has to manage the dependencies, e.g. to add or remove the markers if the tree order changes. This function should only be used, if the marker depends on runtime values.

Parameters
itemthe item to which the marker is added
markersee getTreeItemMarker
isDependencyif true, the item is marked as a dependency to another marked item (usually of another tree)
void cubepluginapi::PluginServices::addMetric ( cube::Metric *  metric,
TreeItem *  parent = 0 
)

adds a new metric to the metric tree

Parameters
metricthe new metric to add
parentthe parent item or NULL for top level metrics
void cubepluginapi::PluginServices::addSettingsHandler ( SettingsHandler s)

Allows the plugin to save and load settings.

See also
cubepluginapi::SettingsHandler
void cubepluginapi::PluginServices::addTab ( cubepluginapi::DisplayType  type,
TabInterface tab,
int  tabWidgetID = DEFAULT_TAB 
)

Adds a tab to METRICTAB, CALLTAB or SYSTEMTAB Adds a the given tab. Currently only SYSTEMTAB is supported.

Parameters
typecubepluginapi::SYSTEMTAB
addAtIndexthe desired position of the tab
tabWidgetIDuse OTHER_PLUGIN_TAB, if the plugin isn't related to the system tree. In that case, the value mode combo box and the value view aren't shown, use defineSystemTab to create a new system tab category
void cubepluginapi::PluginServices::addToolBar ( QToolBar *  toolbar,
TabInterface tab = 0 
)

Adds the given toolbar below the menu bar.

Parameters
tabIf tab is 0, the toolbar is always visible. Otherwise the toolbar is initially hidden and gets only visible, if the corresponding tab becomes visible. If the tab is detached, the toolbar is moved from the main panel to the new window.
void cubepluginapi::PluginServices::addValueView ( ValueView view)

Adds a value view to the list of available views from which the user can choose the active one.

void cubepluginapi::PluginServices::clearValueWidget ( )

Clears the value widget, the widget only shows an empty area.

void cubepluginapi::PluginServices::contextMenuIsShown ( cubepluginapi::DisplayType  type,
cubepluginapi::TreeItem *  item 
)
signal

This signal is emitted if the context menu in a tree widget type will be shown. Additional menu items may be added now.

Parameters
typeMETRIC, CALL or SYSTEM
itemthe item, the user has clicked with the right mouse or nullptr if clicked on the background
Future* cubepluginapi::PluginServices::createFuture ( TabInterface tab = 0)

Creates a Future object to execute tasks in parallel. The object is deleted after the plugin has been closed.

Parameters
tabif exists, a progress bar will be displayed in the given tab while the tasks are running
QTextStream& cubepluginapi::PluginServices::debug ( )

Returns a stream to write debug messages; only active if -verbose command line option is set.

static QTextStream& cubepluginapi::PluginServices::debug ( const QString &  sender)
static

Returns a stream to write debug messages; only active if -verbose command line option is set.

Parameters
sendera short identifier of the sender of the debug message
int cubepluginapi::PluginServices::defineSystemTab ( const QString &  label,
TabType  tabType = DEFAULT_TAB 
)

Adds an additional sub-tabwidget to the SYSTEMTAB with the given label. The following tabs already exist: DEFAULT_TAB ("System view") and OTHER_PLUGIN_TAB ("General")

Returns
the id of the tabWidget to be used in PluginServices::addTab
QMenu* cubepluginapi::PluginServices::enablePluginMenu ( )

Adds a submenu with the plugin label to the plugin menu and returns a pointer to the created QMenu.

void cubepluginapi::PluginServices::enableTab ( TabInterface tab,
bool  enabled 
)

Enables or disables the given tab. If disabled, the tab gets inactive and greyed out.

QString cubepluginapi::PluginServices::formatNumber ( double  value,
PrecisionFormat  format,
bool  integerType = false 
) const

formatNumber writes the given value into a string using the given format. If integerType is true, the value is formatted without decimal places.

Parameters
formatFORMAT_TREES for treeWidgets and FORMAT_DEFAULT for all other widgets
QString cubepluginapi::PluginServices::formatNumber ( double  value,
bool  integerType = false 
) const

Convenience function, equivalent to formatNumber(double value, PrecisionFormat format, bool integerType = false) with PrecisionFormat = FORMAT_DEFAULT

QPair<QString, QString> cubepluginapi::PluginServices::formatNumberAndUnit ( double  value,
const QString &  unit,
PrecisionFormat  format,
bool  integerType = false 
) const

formatNumberAndUnit writes the given value into a string using the given format. If integerType is true, the value is formatted without decimal places.

Parameters
formatFORMAT_TREES for treeWidgets and FORMAT_DEFAULT for all other widgets
void cubepluginapi::PluginServices::genericUserAction ( cubepluginapi::UserAction  action)
signal

This signal is emitted for special user actions, eg. if a tree item is marked as loop.

const QList<TreeItem*>& cubepluginapi::PluginServices::getActiveSubset ( ) const

Returns the contents of the currenly selected subset of the system tree.

int cubepluginapi::PluginServices::getActiveSubsetIndex ( ) const

Returns the index of the currenly selected subset of the system tree.

Tree* cubepluginapi::PluginServices::getActiveTree ( cubegui::DisplayType  type) const

Returns the active tree in the tab of the given type

QString cubepluginapi::PluginServices::getBookmarkDescription ( const QString &  name)

returns the description for the given bookmark name

QStringList cubepluginapi::PluginServices::getBookmarks ( )

returns a list with the names of the saved states of a cube

TreeItem* cubepluginapi::PluginServices::getCallTreeItem ( uint32_t  cnodeId) const

Returns the call tree item with the given id.

QColor cubepluginapi::PluginServices::getColor ( double  value,
double  minValue,
double  maxValue,
bool  whiteForZero = true 
) const

Calculates a color corresponding to the value parameter having minValue at color position 0.0 and maxValue at color position 1.0 on the color scale. If whiteForZero is set to true, the zero value is assigned the color white.

cube::CubeProxy* cubepluginapi::PluginServices::getCube ( ) const

Returns a pointer to the cube data.

QString cubepluginapi::PluginServices::getCubeBaseName ( ) const

Returns the basename of the currently loaded cube file including the path.

const QString& cubepluginapi::PluginServices::getCubeFileName ( ) const

Returns the name of the loaded cube file including the path.

QVariant cubepluginapi::PluginServices::getGlobalValue ( const QString &  name) const

Retreives the global value of the given identifier name.

TreeItem* cubepluginapi::PluginServices::getMetricTreeItem ( std::string  metricId) const

Returns the metric tree item with the given id.

const QList<cubepluginapi::DisplayType>& cubepluginapi::PluginServices::getOrder ( ) const

Returns order of tabs, default order is METRIC, CALL, SYSTEM

QWidget* cubepluginapi::PluginServices::getParentWidget ( ) const

Returns a widget which can be used e.g. as parent widget of dialogs, if the plugins doesn't define tabs.

TreeItem* cubepluginapi::PluginServices::getSelection ( DisplayType  type) const

Returns last selected item in the active tree.

Parameters
typeMETRIC, CALL, SYSTEM
const QList<TreeItem*>& cubepluginapi::PluginServices::getSelections ( DisplayType  type) const

Returns selected items in the active tree.

Parameters
typeMETRIC, CALL, SYSTEM
QString cubepluginapi::PluginServices::getStatName ( ) const

If a statistics file exists, the filename of that file is returned, otherwise an empty string.

QStringList cubepluginapi::PluginServices::getSubsetLabelList ( ) const

Returns a list of all names of the defined subsets for the system tree.

TreeItem* cubepluginapi::PluginServices::getSystemTreeItem ( uint32_t  sysId) const

Returns the system tree item with the given id.

QList<cubegui::TabInterface*> cubepluginapi::PluginServices::getTabList ( )

returns list of tabs, which the plugin has created

const QList<TreeItem*> cubepluginapi::PluginServices::getTopLevelItems ( DisplayType  type) const

Returns a list with the top level tree items of the given tree. For the calltree and systemtree, the top level tree items refer to the visible root nodes in CUBE.

const TreeItemMarker* cubepluginapi::PluginServices::getTreeItemMarker ( const QString &  label,
const QList< QPixmap > &  icons = QList< QPixmap >(),
bool  isInsignificant = false,
MarkerLabel *  markerLabel = 0 
)

returns a new tree item marker, which can be used to marks tree items with different background color or other attributes, which can be chosen by the user

Parameters
labeltext for the color legend
iconslist of pixmaps of ascending size. The best fitting icon will be shrunk to tree item height and displayed for each marked item.
isInsignificantmarks item as insignificant, if true. Insignificant items will be grayed out.
markerLabelcontains a function, that returns a label which depends on the choosen tree item; if markerLabel is not set, the first parameter (label) is always used. Example: TreeItemMarker plugin
const QList<TreeItem*>& cubepluginapi::PluginServices::getTreeItems ( DisplayType  type) const

Returns a list with all tree items of the active tree.

const QList<TreeItem*>& cubepluginapi::PluginServices::getTreeItems ( TreeType  type) const

Returns a list with all tree items of the given tree.

bool cubepluginapi::PluginServices::getUserDefinedMinValues ( DisplayType  type,
double &  min,
double &  max 
) const

Returns true, if user defined values are set.

ValueModus cubepluginapi::PluginServices::getValueModus ( ) const

Returns the currenly selected value modus.

void cubepluginapi::PluginServices::globalValueChanged ( const QString &  name)
signal

This signal is emitted if a global value has changed.

Parameters
namethe name of the global value
See also
PluginServices::getGlobalValue
bool cubepluginapi::PluginServices::hasIterations ( )

true, if iterations are defined in calltree

bool cubepluginapi::PluginServices::intMetricSelected ( ) const

Returns true, if the currenly selected metric item uses integer values.

void cubepluginapi::PluginServices::loadBookmark ( const QString &  name,
bool  loadGlobals = false 
)

loads the saved state of a cube and applies it

Parameters
loadGlobalsalso load global settings like colormap, fonts ...
void cubepluginapi::PluginServices::orderHasChanged ( const QList< cubepluginapi::DisplayType > &  order)
signal

This signal is emitted if the order of the tabs has changed.

Parameters
orderlist which contains METRICWIDGET, CALLWIDGET, SYSTEMWIDGET in the order the user has selected
void cubepluginapi::PluginServices::recalculateTreeItem ( cubegui::TreeItem *  item)

Recalculates the value of the given item and its dependent items and updates the corresponding view.

void cubepluginapi::PluginServices::recalculateTreeItems ( )

Recalculates the values of the items of all trees and updates the views.

void cubepluginapi::PluginServices::removeMarker ( TreeItem *  item,
const TreeItemMarker *  marker 
)

Removes the given marker from the given tree item.

void cubepluginapi::PluginServices::removeMarker ( )

Removes all plugin managed marker which have been set by this plugin.

void cubepluginapi::PluginServices::removeMarker ( DisplayType  type)

Removes all plugin managed marker from the active tree which have been set by this plugin.

void cubepluginapi::PluginServices::removeMetric ( TreeItem *  metricItem)

Removes the given metric item from the metric tree.

void cubepluginapi::PluginServices::removeTab ( TabInterface tab)

Removes the previously added tab.

See also
PluginServices::addTab
void cubepluginapi::PluginServices::removeToolBar ( QToolBar *  toolbar,
TabInterface tab = 0 
)

Removes the previously added toolbar.

void cubepluginapi::PluginServices::selectItem ( TreeItem *  item,
bool  add 
)

Selects the given item.

Parameters
itemThe tree item to select
addIf add is false, all previously selected items are deselected. If add is true and the item already is selected, it becomes deselected.
void cubepluginapi::PluginServices::setActiveSubset ( int  index)

Sets the currenly selected subset of the system tree to the given index.

void cubepluginapi::PluginServices::setGlobalValue ( const QString &  name,
const QVariant &  value,
bool  notifyMyself = false 
)

Sets a global value:

Parameters
nameidentifier of the value
valuethe value which can be of any type
notifyMyselfif true, the signal globalValueChanged is also sent to the caller of this method. Causes infinite recursion, if called inside the slot connected to globalValueChanged.
void cubepluginapi::PluginServices::setMessage ( const QString &  str,
cubepluginapi::MessageType  type = cubepluginapi::Information 
)

Writes the given message to the status line at the bottom of the cube window.

void cubepluginapi::PluginServices::setUserDefinedMinMaxValues ( DisplayType  type)

Shows a dialog to let the user set the minimum and maximum value for coloring.

void cubepluginapi::PluginServices::tabActivated ( cubepluginapi::DisplayType  type)
signal

This signal is emitted if the selected tree has changed

void cubepluginapi::PluginServices::toFront ( TabInterface tab)

Sets the given tab selected or brings the detached tab to front.

void cubepluginapi::PluginServices::treeItemIsSelected ( cubepluginapi::TreeItem *  item)
signal

This signal is emitted if the user selects one ore more tree items. To get all selected items

See also
Pluginservices::getSelections( TreeType type ) The calculation of the corresponding tree values may not finished, when this signal is emitted. Use TabInterface::valuesChanged if the plugin depends on tree values.
Parameters
itemthe recently selected item
void cubepluginapi::PluginServices::updateMetric ( TreeItem *  metricItem)

Recalculates the values of the given metric item.

void cubepluginapi::PluginServices::updateTreeItems ( )

Updates the items of all trees, if their values (cube::Values) have been changed by a plugin and notifies all tabs that values have been changed.

void cubepluginapi::PluginServices::updateTreeView ( DisplayType  treeType)

Updates the properties (label, color, font...) of the active tree. This method has to be called if tree items have been marked

void cubepluginapi::PluginServices::updateTreeView ( TreeType  type)

Updates the properties (label, color, font...) of the given tree. This method has to be called if tree items have been marked

void cubepluginapi::PluginServices::updateValueWidget ( TabInterface tc,
double  minValue,
double  maxValue,
double  value = std::nan(""),
double  minAbsValue = std::nan(""),
double  maxAbsValue = std::nan(""),
double  absValue = std::nan(""),
double  mean = std::nan(""),
double  varianceSqrt = std::nan("") 
)

Updates the value widget at the bottom of a plugin tab. This method has to be called, if the default behaviour (see value widget below the tree) doesn't fit. The value widget consists of two rows:

  • The first row shows: minValue | value (% of max-min) | maxValue. Set value to NaN to hide it.
  • The second row shows: minAbsValue | absValue | maxAbsValue If absValue is NaN but mean and varianceSqrt exist, the value field is replaced with mean +/- varianceSqrt
Parameters
minValuethe minimum value
maxValuethe maximum value
valuethe value to display in the center
minAbsValuethe minimum absolute value
maxAbsValuethe maximum absolute value
absValuethe absolute value of the parameter "value"
meanthe mean of all values
varianceSqrtthe standard deviation of all values

Cube Writer Library    Copyright © 1998–2021 Forschungszentrum Jülich GmbH, Jülich Supercomputing Centre
Copyright © 2009–2015 German Research School for Simulation Sciences GmbH, Laboratory for Parallel Programming