Plugin
All ManiVault plugins are descendants of this plugin base class. The example plugins repository has several examples that show how to create new plugins.
Qualified name: mv::plugin::Plugin
-
class Plugin : public mv::gui::WidgetAction
Subclassed by mv::plugin::AnalysisPlugin, mv::plugin::LoaderPlugin, mv::plugin::RawData, mv::plugin::TransformationPlugin, mv::plugin::ViewPlugin, mv::plugin::WriterPlugin
Public Functions
-
Plugin(const PluginFactory *factory)
Construct with pointer to plugin
factory.- Parameters:
factory – Pointer to plugin factory
-
QIcon icon() const
Get icon.
- Returns:
Icon
-
inline virtual void init()
Can be implemented to initialize the plugin to a certain state.
This function gets called when the plugin is first instantiated.
-
const PluginFactory *getFactory() const
Get the plugin factory for the plugin.
- Returns:
Pointer to plugin factory
-
QString getName() const
Returns the unique name of this plugin.
-
QString getGuiName() const
Returns the GUI name of this plugin.
-
QString getKind() const
Returns the kind of plugin.
The kind is specific to the particular implementation of a plugin type.
-
Type getType() const
Returns the type of plugin, see all types in PluginType.
-
virtual util::Version getVersion() const
Returns the version of the plugin.
- Returns:
Plugin version
-
PluginShortcuts &getShortcuts()
Get shortcuts.
- Returns:
Plugin shortcuts
-
const PluginShortcuts &getShortcuts() const
Get shortcuts.
- Returns:
Plugin shortcuts
-
QVariant getProperty(const QString &name, const QVariant &defaultValue = QVariant()) const
Get property in variant form.
- Parameters:
name – Name of the property
defaultValue – Default value
- Returns:
Property in variant form
-
void setProperty(const QString &name, const QVariant &value)
Set property.
- Parameters:
name – Name of the property
value – Property value
-
bool hasProperty(const QString &name) const
Determines whether a property with a give name exists.
- Parameters:
name – Name of the property
value – If property with the given name exists
-
QStringList propertyNames() const
Returns a list of available property names.
-
QVariant getSetting(const QString &path, const QVariant &defaultValue = QVariant()) const
Load setting.
- Parameters:
path – Path of the setting (e.g. General/Computation/NumberOfIterations)
defaultValue – Value to return if the setting with
pathwas not found
- Returns:
Plugin setting in variant form
-
void setSetting(const QString &path, const QVariant &value)
Save setting.
- Parameters:
path – Path of the setting (e.g. General/Computation/NumberOfIterations)
value – Value in variant form
-
QString getGlobalSettingsPrefix() const
Get global settings prefix (facade for the PluginFactory class)
- Returns:
Plugin global settings prefix
-
gui::PluginGlobalSettingsGroupAction *getGlobalSettingsAction() const
Get global settings action (facade for the PluginFactory class)
- Returns:
Pointer to plugin global settings action (maybe nullptr if plugin does not have global settings)
-
virtual void fromVariantMap(const QVariantMap &variantMap) override
Load widget action from variant.
- Parameters:
Variant – representation of the widget action
-
virtual QVariantMap toVariantMap() const override
Save widget action to variant.
- Returns:
Variant representation of the widget action
-
void destroy()
Destroys the plugin and removes it from the plugin manager.
-
void addNotification(const QString &description, const util::Notification::DurationType &durationType = util::Notification::DurationType::Fixed, std::int32_t delayMs = 0) const
Add plugin notification in the main window.
- Parameters:
description – Message description (maybe HTML)
durationType – Duration type of the notification
delayMs – Delay in milliseconds before the notification is shown
-
inline virtual gui::ScriptTriggerActions getScriptTriggerActions(const Datasets &datasets) const
Get script trigger actions given
datasets.Example:
ScriptTriggerActions scriptTriggerActions; if (datasets.count() == 1 && datasets.first()->getDataType() == PointType) scriptTriggerActions << new ScriptTriggerAction(nullptr, std::make_shared<PythonScript>(“Min”, Script::Type::Analysis, “”, datasets), “Analysis/Min”); return scriptTriggerActions;
- Parameters:
datasets – Vector of input datasets
- Returns:
Vector of script trigger actions
Protected Attributes
-
const PluginFactory *_factory
Pointer to the core interface.
-
const QString _name
Pointer to plugin factory.
-
QMap<QString, QVariant> _properties
Unique plugin name.
-
EventListener _eventListener
Properties map.
-
gui::StringAction _guiNameAction
Listen to public events.
-
gui::TriggerAction _destroyAction
Action for the GUI name.
-
PluginShortcuts _shortcuts
Action for destroying the plugin.
-
gui::PluginLearningCenterAction _learningCenterAction
Plugin shortcuts.
Friends
- friend class PluginFactory
-
Plugin(const PluginFactory *factory)