AvogadroLibs 2.1.0-20261111
Loading...
Searching...
No Matches
ExtensionPlugin Class Referenceabstract

The base class for extension plugin factories in Avogadro. More...

#include <avogadro/qtgui/extensionplugin.h>

Inheritance diagram for ExtensionPlugin:

Public Slots

virtual void setMolecule (QtGui::Molecule *mol)=0
virtual bool readMolecule (QtGui::Molecule &mol)
virtual void setScene (Rendering::Scene *scene)
virtual void setCamera (Rendering::Camera *camera)
virtual void setActiveWidget (QWidget *widget)
virtual bool handleCommand (const QString &command, const QVariantMap &options)

Signals

void moleculeReady (int numberOfMolecules)
void fileFormatsReady ()
void requestActiveTool (QString toolName)
void requestActiveDisplayTypes (QStringList displayTypes)
void registerCommand (QString command, QString description)
void commandStarted ()
void commandFinished (const QString &message=QString(), const QVariantMap &result=QVariantMap())
void commandFailed (const QString &message=QString())
void actionsChanged ()

Public Member Functions

 ExtensionPlugin (QObject *parent=nullptr)
virtual QString name () const =0
virtual QString description () const =0
virtual QList< QAction * > actions () const =0
virtual QStringList menuPath (QAction *action=nullptr) const =0
virtual QList< Io::FileFormat * > fileFormats () const
virtual void registerCommands ()
virtual QList< QDockWidget * > dockWidgets () const
virtual Qt::DockWidgetArea preferredDockArea (QDockWidget *widget) const

Detailed Description

Author
Marcus D. Hanwell

Member Function Documentation

◆ name()

virtual QString name ( ) const
pure virtual

The name of the extension plugin, will be displayed in the user interface.

◆ description()

virtual QString description ( ) const
pure virtual

A description of the extension plugin, may be displayed in the user interface.

◆ actions()

virtual QList< QAction * > actions ( ) const
pure virtual
Returns
The QActions for this extension (should be at least one).

◆ menuPath()

virtual QStringList menuPath ( QAction * action = nullptr) const
pure virtual
Returns
The menu path of the supplied action. This can be empty if the action was not recognized, or contain two or more strings (top level, plus name, e.g. File, &Open).

◆ fileFormats()

virtual QList< Io::FileFormat * > fileFormats ( ) const
virtual
Returns
A list of file format readers/writers.

The caller takes ownership of the objects in the returned list.

◆ registerCommands()

virtual void registerCommands ( )
virtual

If the extension plugin has script commands, this method should be implemented to emit the registerCommand signals.

◆ dockWidgets()

virtual QList< QDockWidget * > dockWidgets ( ) const
virtual
Returns
The dock widgets this extension contributes to the main window.

Most extensions contribute none and need not implement this. The application adds what is returned to its window; the plugin keeps ownership and decides what the dock contains.

A contributed dock starts hidden, since the window already carries several of its own. Showing it is the plugin's business: give it a checkable QAction through actions() and menuPath() like any other menu entry, and QDockWidget::toggleViewAction() is usually the action you want. Set a windowTitle() on each dock, since that is what its title bar shows, and a unique objectName() so window state can be saved and restored. This is consulted once, when the application starts.

◆ preferredDockArea()

virtual Qt::DockWidgetArea preferredDockArea ( QDockWidget * widget) const
virtual
Returns
The dock area widget should be placed in when it is first added. Defaults to the right area, since the left already carries the tool, display, file and layer docks.

◆ setMolecule

virtual void setMolecule ( QtGui::Molecule * mol)
pure virtualslot

Called when the current molecule changes.

◆ readMolecule

virtual bool readMolecule ( QtGui::Molecule & mol)
virtualslot

Call this slot when the moleculeReady signal indicated that a molecule is ready to be read. The molecule will have the data read into it. The slot will

Returns
true if a molecule was successfully read in.

◆ setScene

virtual void setScene ( Rendering::Scene * scene)
virtualslot

Called when the current scene changes.

◆ setCamera

virtual void setCamera ( Rendering::Camera * camera)
virtualslot

Called when the active camera for the view changes.

◆ setActiveWidget

virtual void setActiveWidget ( QWidget * widget)
virtualslot

Called when the active widget changes. This must be used carefully, and should check that the widget has been cast if used.

◆ handleCommand

virtual bool handleCommand ( const QString & command,
const QVariantMap & options )
virtualslot

Called by the app to handle a command registered by the extension. (e.g., "renderMovie" or "generateSurface", etc.)

The app will turn the command into a string and pass it to the extension. and any options will go from a JSON dictionary to a QVariantMap.

Returns
true if the command was handled, false otherwise.

◆ moleculeReady

void moleculeReady ( int numberOfMolecules)
signal

Signal that the extension has a new molecule that is ready to be loaded. The application must call readMolecule in order to actually read the molecule(s).

◆ fileFormatsReady

void fileFormatsReady ( )
signal

Signal that the extension has file formats that are ready to be registered. If emitted the application should call fileFormats to get the formats the extension is registering.

◆ requestActiveTool

void requestActiveTool ( QString toolName)
signal

Signal to request a particular tool is set as the active tool. This is useful when loading a structure outside of the normal file API and setting "Navigator" to active instead of "Editor" (the default).

◆ requestActiveDisplayTypes

void requestActiveDisplayTypes ( QStringList displayTypes)
signal

Request a specific display type (or types) are made active. This can be useful when loading a specific type of data that would be most readily viewed with a specialized view.

◆ registerCommand

void registerCommand ( QString command,
QString description )
signal

Register a new command with the application. The command will be available through scripting (e.g., "renderMovie" or "generateSurface", etc.)

Parameters
commandThe name of the command to register.
descriptionA description of the command.
See also
handleCommand

◆ commandStarted

void commandStarted ( )
signal

Indicate that a command has been started, but is not yet finished – for example, work that handleCommand() handed to a background thread.

The application holds the caller's reply until the command completes. Once this is emitted, every code path must end in commandFinished() or commandFailed(), or the caller waits until the command times out.

See also
commandFinished, commandFailed

◆ commandFinished

void commandFinished ( const QString & message = QString(),
const QVariantMap & result = QVariantMap() )
signal

Indicate that a particular script command is finished. (e.g., from handleCommand)

Parameters
messageAn optional message to the script or user
resultOptional results for the caller, e.g. an energy or a gradient. Only types with a JSON equivalent survive the trip to a script, so convert Eigen and Core::Array values to lists of numbers before adding them.

◆ commandFailed

void commandFailed ( const QString & message = QString())
signal

Indicate that a command that was started cannot be completed.

Parameters
messageA message to the script or user explaining the failure
See also
commandStarted

◆ actionsChanged

void actionsChanged ( )
signal

Indicate that the list of actions for this extension has changed. The application should rebuild menus to reflect the new action list.


The documentation for this class was generated from the following file: