MeVisLab Scripting Reference
|
Public Slots | |
void | copyInstanceName () |
void | editInstanceNameWithRequester () |
void | editModuleHelp () |
QString | exampleNetworkFile () |
QStringList | exampleNetworkFiles () |
virtual void | forceReload () |
QString | getMLABFile () |
QString | getModuleDefinitionFolder () |
QString | getModuleHelpFile () |
QString | getModuleSourcesFolder () |
QStringList | getScriptSourceFiles () |
bool | hasModuleHelp () |
bool | isDefinedInsideProject () const |
bool | isLazyLoading () const |
MLABTree * | mdlTree () |
void | openMLABFile () |
void | openModuleDefinition () |
void | openScriptSourceFiles () |
virtual void | reload () |
void | restoreDefaultValues () |
virtual bool | shouldReload () |
void | showContextMenu () |
void | showDLLDependency () |
void | showExampleNetwork () |
void | showHtmlHelp () |
void | showModuleInNetwork (bool openNetworkTabAfterCurrentNetworkTab=false) |
MLABWindowControl * | showScriptConsole () |
void | updateModuleHelp () |
Access to owning and internal network/macros. | |
MLABMacroModule * | parentMacro () const |
MLABMacroModule * | parent () |
MLABMacroModule * | applicationMacro (bool shouldWarnIfNotMacro=true) |
bool | isDescendentOf (MLABModule *module) |
bool | isDescendentOfNetwork (MLABNetwork *network) |
MLABNetwork * | parentNetwork () const override |
MLABNetwork * | owner () |
virtual MLABNetwork * | network () |
virtual bool | isMacroModule () |
Scripting access to fields, modules, and controls. | |
| |
void | createScriptingContext (const QString &language) |
bool | hasFunction (const QString &functionName) |
QVariant | scriptVariable (const QString &name) |
void | setScriptVariable (const QString &name, const QVariant &value) |
void | deleteScriptVariable (const QString &name) |
QVariant | call (const QString &function, const QVariantList &args) |
QVariant | call (const QString &function) |
QVariant | call (const QString &function, QObject *obj) |
QObject * | callWithObjectReturn (const QString &function, const QVariantList &args) |
QObject * | callWithObjectReturn (const QString &function) |
QObject * | callWithObjectReturn (const QString &function, QObject *obj) |
int | callLater (double seconds, const QVariant &function, const QVariantList &args=QVariantList()) |
int | callWithInterval (double seconds, const QVariant &function, const QVariantList &args=QVariantList()) |
void | callOnGUIThread (const QVariant &function, const QVariantList &args=QVariantList()) |
QStringList | callableFunctions () |
QStringList | deprecatedFieldNames (const QString &fieldName) |
QStringList | deprecatedFieldNames (MLABField *field) |
QVariantMap | deprecatedFieldNames () |
void | removeTimer (int id) |
void | removeTimers () |
QObject * | commandHandler (const QString &name) |
bool | connectField (const QString &dst, const QString &src) |
bool | disconnectField (const QString &input) |
virtual void | clearCache () |
virtual MLABField * | field (const QString &name) |
bool | hasField (const QString &name) |
virtual MLABModule * | module (const QString &name) |
bool | hasModule (const QString &name) |
QStringList | modules () |
QList< MLABModule * > | modulesAsObjects () |
virtual MLABModule * | addModule (const QString &name) |
virtual MLABModule * | addLocalModule (const QString &name) |
virtual MLABModule * | addMacroModuleFromString (const QString &string) |
virtual MLABModule * | addMacroModuleFromFile (const QString &file) |
virtual MLABModule * | addRemoteModule (const QString &name) |
virtual MLABWidgetControl * | control (const QString &name) |
bool | hasControl (const QString &name) |
MLABWidgetControl * | controlDebug (const QString &name) |
virtual void | closeWindow () |
MLABWindowControl * | window () |
QString | unexpandFilename (const QString &file) |
QString | expandFilename (const QString &file, bool doCleanPath=true) |
QString | localPath () |
QString | networkPath () |
void | log (const QString &msg) |
void | logFixed (const QString &text) |
void | logHTML (const QString &msg) |
void | logWarning (const QString &msg) |
void | logError (const QString &msg) |
int | currentWindowID () |
int | setCurrentWindowID (int windowID) |
void | remove () |
void | py_delete () |
void | removeUndoable () |
QMap< QString, QVariant > | getDependency () |
bool | exportWindows (const QStringList &windowNames=QStringList()<< "_default") |
bool | callRemoteFunction (const QString &functionName, const QVariantList &arguments=QVariantList(), const QVariant &replyHandler=QVariant()) |
QString | translate (const QString &text, const QString &disambiguation=QString()) |
Information about the module. | |
QStringList | inputs () |
QStringList | outputs () |
QStringList | parameters () |
QList< MLABField * > | inputFields () |
QList< MLABField * > | outputFields () |
QList< MLABField * > | parameterFields () |
bool | isValid () |
void | setNonPersistent () |
bool | isPersistent () override |
QString | type () const |
virtual bool | isRemote () |
virtual bool | isLocalMacro () |
bool | shouldAvoidSideEffects () const |
QString | fullName () override |
QRect | frame () const |
void | setFrame (const QRect &frame) |
void | setFrameTopLeft (int x, int y) |
void | setFrameCenter (int x, int y) |
bool | isSelected () const override |
void | setSelected (bool flag, bool notifyModuleListener=true) |
void | setSingleSelected () |
MLABPackage * | package () |
MLABPackage * | getPackage () |
Showing windows of the module | |
MLABWindowControl * | showWindow (MLABWindowControl *parent=nullptr) |
MLABWindowControl * | showWindow (const QString &name, MLABWindowControl *parent=nullptr) |
MLABWindowControl * | showWindowFromString (const QString &string, MLABWindowControl *parent=nullptr) |
MLABWindowControl * | showWindowFromFile (const QString &file, MLABWindowControl *parent=nullptr) |
MLABWindowControl * | showAutomaticWindow () |
int | showModalDialog (const QString &name, const QString &title) |
int | showModalDialog (const QString &name) |
int | showModalDialog () |
int | showModalDialog (const QString &name, MLABWindowControl *parent) |
int | showModalDialogFromString (const QString &mdlString, const QString &title) |
int | showModalDialogFromString (const QString &mdlString) |
int | showModalDialogFromString (const QString &mdlString, MLABWindowControl *parent) |
int | showModalDialogFromFile (const QString &file, const QString &title) |
int | showModalDialogFromFile (const QString &file) |
int | showModalDialogFromFile (const QString &file, MLABWindowControl *parent) |
MLABWindowControl * | createWindow () |
MLABWindowControl * | createWindow (MLABWindowControl *parent) |
MLABWindowControl * | createWindow (const QString &name) |
MLABWindowControl * | createWindow (const QString &name, MLABWindowControl *parent) |
MLABWindowControl * | createWindowFromFile (const QString &file) |
MLABWindowControl * | createWindowFromFile (const QString &file, MLABWindowControl *parent) |
MLABWindowControl * | createWindowFromString (const QString &string) |
MLABWindowControl * | createWindowFromString (const QString &string, MLABWindowControl *parent) |
MLABWindowControl * | createBorderlessWindow (const QString &name, MLABWindowControl *parent) |
MLABWindowControl * | createPopupWindow (const QString &name, MLABWindowControl *parent) |
MLABWindowControl * | createModalDialog (const QString &name, MLABWindowControl *parent) |
bool | hasWindow (const QString &name) |
void | closeAllWindows (bool emitDestroyedCommandImmediately=false) |
void | reshowClosedWindows () |
virtual MLABWindowControl * | showParameterWindow () |
void | updateLayout () |
void | createConnectors () |
MLABFieldListener * | addFieldListener (MLABField *field, const QVariant &script, bool init) |
void | removeFieldListener (MLABFieldListener *listener) |
QString | groupName () const |
void | addToGroup (const QString &name) |
Public Slots inherited from MLABFieldOwner | |
virtual bool | isSelected () const =0 |
virtual bool | isPersistent ()=0 |
virtual MLABNetwork * | parentNetwork () const =0 |
virtual QString | fullName ()=0 |
Friends | |
class | MLABNetwork |
Baseclass for modules in an MLABNetwork
.
All scripts contexts in MeVisLab have a global 'context' variable (alias: 'ctx'), which can be accessed from the script. This context variable always points to an MLABModule, which is either an MLABMacroModule, MLABMLModule, or MLABInventorModule. All methods given in this documentation can be called by:
Typical used methods in a module are:
Utility functions:
Methods concerning windows (panels):
Less typical methods in a module are:
MDL reference: Module
|
slot |
Adds a field listener to the module at runtime.
The passed-in script
can be a string or a callable Python object (e.g., a function or instance method). For example, if you have a scripting function called myFieldChanged(), you can register it like this:
field | The field to attach to. |
script | The script is executed in the context the module you call this method on. |
init | If this flag is true , the myFieldChanged function is called and the current field value is propagated. |
|
virtualslot |
|
virtualslot |
Adds a new module from a string to the internal network temporarily.
The module type will be MacroFromFile.
This should only be used for application-specific macros that should not be visible in the global MLAB database and that are generated on-the-fly in scripting, the module is not persisted on saving the network.
|
virtualslot |
Adds a new module from a string to the internal network temporarily.
The module type will be MacroFromString.
This should only be used for very small macros that are generated on-the-fly in scripting, the module is not persisted on saving the network.
|
virtualslot |
Adds a new module to the internal network. Returns null or new module.
The module can be a name from the MLAB database or a local macro. If the module is a local macro module, looks for networkPath() + "name.script".
|
inlinevirtualslot |
Adds a new module executed by a worker instance of MeVisLab in another process.
Some restrictions on GUI scripting and allowed input and output field types apply.
This does not work for local modules or OpenInventor modules.
References addRemoteModule().
Referenced by addRemoteModule().
|
slot |
Adds the module to the given group.
If the name
does not exist, a new group with that name is created. If the name
is empty, the module is moved to the top network level.
|
slot |
Returns the MacroModule that is the top most in the parent chain. This is the started application.
|
slot |
Like call() method but without arguments.
|
slot |
Calls the given function inside of the module.
The method can be global or fully qualified (e.g., someobject.somefunction), arguments are a Python list of values. These args can not be objects or classes.
|
slot |
Like call() method but with object as argument.
|
slot |
Returns a list of callable scripting functions (callable with call()).
|
slot |
Like call() method but calls after the given number of seconds.
If seconds is 0, it is guaranteed that the call is done AFTER the current event loop. The passed-in function can be a string or a callable Python object (e.g., a function or instance method).
|
slot |
Calls the given function (a Python function object or the name of a function) asynchronously in the GUI/main thread.
This method needs to be used when you want to talk to the GUI thread from another Python thread.
|
slot |
Calls a function on a remote client.
If this module is not running in a worker process, an error is printed.
functionName | The name of the function. |
arguments | The argument list. This is optional. |
replyHandler | A callable that is called with the reply argument list as parameters. This is optional. |
true
if the module is managed by a remote connection and the sendGenericRequest() signal was emitted, false
otherwise.
|
slot |
Like call() method but calls repeatedly in the given interval.
To stop the timer, use the kill() method on the returned timer object. The passed-in function can be a string or a callable Python object (e.g., a function or instance method).
|
slot |
Like call() method but with object as return value.
|
slot |
Like call() method but with object as return value.
|
slot |
Like call() method but with object as return value.
|
virtualslot |
Clears the ML cache of all output fields of this module and also of all modules inside of the internal network if it is a macro network.
|
slot |
Closes all windows (you can reshow the windows at the same screen positions by calling reshowClosedWindows).
|
virtualslot |
Closes the current window (depending on current window).
|
slot |
Returns the command handler named name
. If the name is empty, it returns the first unnamed commandHandler.
|
slot |
Connects input field dst to output field src.
Fields are given by their string name. Note: this is a shortcut to MLABField connectFrom().
|
virtualslot |
Searches for control with given name (in current active window, see currentWindowID()).
Searches for a control which must be declared in the current active window by the MDL tag 'instanceName' (alias: 'name'). Note that control() will only return the correct control if the script code is called from somewhere in the MDL GUI, not if you try to call it from commands of the MDL Commands section or from the scripting console.
Example:
If called from a scripting console, the method will automatically use controlDebug() and return the first control it finds with that name in any of the opened windows.
|
slot |
Like hasControl() but ignores the current window context and searches through all open windows.
This method is for debugging in the scripting console, because control() will not return a control that is not in the correct window context.
|
slot |
Copies the instance name to the clipboard.
|
slot |
Creates a borderless window that is a child of the given window parent
(if window is omitted, it will have no parent).
This function can be used to create information windows that are shown/hidden by the application and can not be moved/closed by the user. Note that the window is not shown after creation, you have to call show() to make it visible and you can use one of the methods of MLABWindowControl to place it at the correct position, e.g., move() or moveTo().
|
slot |
Creates the field connectors of the visual by communicating with the module listener.
If the module listener is NULL, nothing is done.
|
slot |
Creates a modal dialog that is a child of the given window parent
(if window is omitted, it will have no parent).
Note that the window is not shown after creation, you have to call MLABWindowControl::exec()
on the window to show it (exec() then returns the accept/reject code).
|
slot |
Creates a popup window that is a child of the given window parent
(if window is omitted, it will have no parent).
Note that the window is not shown after creation, you have to call show() to make it visible and you can use one of the methods of MLABWindowControl to place it at the correct position, e.g., move() or moveTo().
|
slot |
Creates scripting context for given language
if not already done.
|
slot |
Creates the module's default window.
This is the first window found in the tree, or with the name _default. Creating does not show the window; use methods from MLABWindowControl to show the window after creation. If window was already created, this method returns the pointer to the previously instantiated window.
|
slot |
Creates a window with name
.
_default, _automatic and _viewer, are special names that can be used. Creating does not show the window; use methods from MLABWindowControl to show the window after creation. If window was already created, this method returns the pointer to the previously instantiated window.
|
slot |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
slot |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
slot |
Createsa window that is read from file.
|
slot |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
slot |
Creates a window that is parsed from the given string.
|
slot |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
slot |
Returns the currently active window ID.
|
slot |
Deletes the script variable from the script context.
|
slot |
Returns a dictionary of deprecated names for all fields.
|
slot |
Returns a list of deprecated names for the given field name.
|
slot |
Returns a list of deprecated names for the given field
.
|
slot |
Disconnects input field from output field.
The input field is given as its string name. Note: this is a shortcut to MLABField disconnect().
|
slot |
Edits the instance name with a requester.
|
slot |
Opens an existing .mhelp module help file with information about the current module.
If it does not exist, it will be created.
|
slot |
Returns the path to first example network (may be empty).
|
slot |
Returns the paths to all example networks (may be empty).
|
slot |
Expands variable strings starting with $(...) in the given filename.
Trailing (back-)slashes are removed if the result is a directory.
This function supports:
It also supports all variables that are given in mevislab.prefs file. If doCleanPath
is set, multiple directory separators are removed and any '.' and '..' are resolved.
|
slot |
Makes the given window and relevant fields available to remote clients by exporting the fields and MDL window definitions.
This function will do nothing if this module is not running in a worker process. It must be called on the application module, otherwise it has no effect.
windowNames | An optional list of windows to export. If it is omitted, the default window of this module will be exported. The names may contain dots to specify windows of submodules. |
true
if the module is managed by a module server connection and the exportWindowDefinitions() signal was emitted, false
otherwise.
|
virtualslot |
Searches for field with given name
in dotted notation.
Searches the field by its name. The name can be the name of a field in this module, or a field in the internal network of the macro module. If an internal field is accessed, the name is constructed with the module's instanceName, ".", and the field name.
Example for a simple module field and an internal field:
See MLABField and its derived classes to learn which methods are available on fields.
You can also access field in the parent module of the current module. You can go up with "parent:" and go down with "." as you wish. This is an advanced feature and should only be used if really needed because it breaks encapsulation!
Example for a parent module's field:
|
virtualslot |
Reloads the module. Also ensures that the MDL files are re-read in the global tree.
Reimplemented in MLABMacroModule.
|
slot |
Returns the frame of module in world coordinates on the network sheet.
|
overrideslot |
Returns the full name (type + instanceName) for debugging only.
|
slot |
Returns the dependency of the module.
map contains string lists for the keys:
|
slot |
Returns the path to .mlab file (may not exist).
|
slot |
Returns the path to module definition folder.
|
slot |
Returns the module help file (.mhelp) for the module (may not exist).
|
slot |
Returns the path to module sources folder.
|
inlineslot |
Returns access to the package of the module.
May be NULL if the module is not registered with any package, e.g., a local macro module. This method is the same as package().
|
slot |
Returns the absolute paths to source files of this module.
|
inlineslot |
Returns the group to which the module belongs.
Do not return a reference to the group name, as only None will be returned in Python otherwise.
|
slot |
Returns whether a control with name
exists in the current context.
|
slot |
Returns whether the module has this field and can be read by field().
|
slot |
Checks whether the module has the given script function to call with MLABModule::call.
|
slot |
Returns whether the module exists in the network.
|
slot |
Returns whether the module has a .mhelp file.
|
slot |
Checks whether a window with the given name
is defined.
|
slot |
Returns a list of all input fields as scriptable objects.
|
slot |
Returns the input fields as a list of field names.
|
slot |
Returns true
if the module is defined in a self-contained project.
|
slot |
Returns whether this module is a descendant of the given module
.
That means that this module is inside the given module (macro) in any recursion level.
|
slot |
Returns whether this module is a descendant of the given network
.
That means that this module is inside the given network in any recursion level.
|
inlineslot |
Checks whether this module loads lazily.
Only available for macro modules.
|
inlinevirtualslot |
Returns whether this module is a local macro module.
|
inlinevirtualslot |
Returns whether this module is a macro module.
Reimplemented in MLABMacroModule.
|
inlineoverrideslot |
Returns whether the module is persistent and will be written to an .mlab file if saved or copied.
|
inlinevirtualslot |
Returns whether the module is remotely executed in a worker instance.
Reimplemented in MLABRemoteModule.
|
overrideslot |
Returns whether the module is selected.
|
inlineslot |
Returns whether this module is valid.
|
slot |
Returns the local path of module's .def/.script file.
|
slot |
Logs a message for this module.
|
slot |
Logs an error message for this module.
|
slot |
Logs a message for this module, using a fixed size font and replacing spaces with " ".
|
slot |
Logs a message for this module (using HTML).
|
slot |
Logs a warning message for this module.
|
inlineslot |
Returns the current MDL definition tree of this module.
|
virtualslot |
Searches for a module with given name.
Searches for a module with a given instanceName inside the internal network of this module.
Example:
Reimplemented in MLABMacroModule.
|
slot |
Returns the instanceNames of all modules in the network.
|
slot |
Returns a list of all modules in the network as scriptable objects.
|
inlinevirtualslot |
Returns the internal network. Used in MacroModules, do not mix this up with parentNetwork()!
Reimplemented in MLABMacroModule.
|
slot |
Returns the local path of network the module instance is in (may be empty if network was not saved).
|
slot |
Opens the associated .mlab file in a new network window (if an .mlab file exists).
|
slot |
Opens the module definition of the module in a text editor.
|
slot |
Opens all script source files in associated editor.
|
slot |
Returns a list of all output fields as scriptable objects.
|
slot |
Returns the output fields as a list of field names.
|
inlineslot |
Deprecated. Please use parentNetwork() instead.
References MLABFieldOwner::parentNetwork().
|
slot |
Returns access to the package of the module.
May be NULL if the module is not registered with any package, e.g., a local macro module.
|
slot |
Returns a list of all parameter fields as scriptable objects.
|
slot |
Returns the parameter fields as a list of field names.
|
inlineslot |
Deprecated, since this is an overload of the QObject::parent() call. Please use parentMacro() instead.
|
slot |
Returns the parent MacroModule. This can be used to call scripting methods on the owning MacroModule.
|
overrideslot |
Returns the owning parent network.
|
virtualslot |
Reloads the module.
Reimplemented in MLABRemoteModule, and MLABMacroModule.
|
slot |
Removes this module from the network, this will cause an immediate deletion of the module.
|
slot |
Removes the given field listener.
|
slot |
Removes (stops) the given timer. id
is from callLater or callWithTimer, the timer must be created in this context.
|
slot |
Removes (stops) all timers inside of this context. This is automatically called on reload and on removal of the module.
|
slot |
Removes this module from the network and puts it into the undo history (the module will not be deleted immediately).
|
slot |
Re-shows panels that have been previously closed.
|
slot |
Restores default values of fields if possible.
|
slot |
Returns the given variable from scripting.
|
slot |
Sets the currently active window ID and returns the old ID.
|
slot |
Sets the frame of module in world coordintes on the network sheet.
Typically, one should better use setFrameTopLeft() or setFrameCenter(). To update the layout of the module, call updateLayout().
|
slot |
Sets the frame center of the module in world coordintes on the network sheet.
The module is moved to the given center while keeping its size.
|
slot |
Sets the frame topleft of the module in world coordinates on the network sheet.
The module is moved to the given topleft position while keeping its size.
|
inlineslot |
Sets that the module is not persistent, so it will not be written to an .mlab file. Also, the module is not copy/pastable.
|
slot |
Sets the given variable in the script context to the given value.
|
slot |
Sets whether the module is selected; does not deselect other modules.
|
slot |
Sets only this module selected. Ddeselects all other modules first.
|
slot |
Returns whether this module should not cause any side effects (for example, printing into the console, initializing singletons, creating database connections).
Modules created for auto-completion in MATE have this flag set to true
.
|
virtualslot |
Returns whether the module should be reloaded.
Reimplemented in MLABRemoteModule, and MLABMacroModule.
|
slot |
Shows the module's automatic window displaying all fields of the module.
|
slot |
Shows the context menu for this module.
|
slot |
Runs an external program to show the dependencies of this module's DLL.
|
slot |
Shows an example network.
|
slot |
Shows the HTML help and creates the file to avoid old documents.
|
slot |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
slot |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
slot |
Shows a modal dialog (returns 1 on accept and 0 on cancel).
The shown dialog can be closed by calling
to close and accept (return value 1)
to close and reject (return value 0) or you can call
where the result gets returned to the caller of showModalDialog().
|
slot |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
slot |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
slot |
Shows a modal dialog that is read from file.
|
slot |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
slot |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
slot |
Shows a modal dialog that is parsed from the given string.
|
slot |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
slot |
Selects and shows the module in its network, showing the network (or internal network) in the MeVisLab IDE.
|
virtualslot |
Shows the default window as a panel.
|
slot |
Shows a scripting console for this module as a context.
|
slot |
Shows a window with a name
.
_default, _automatic, and _viewer are special names that can be used.
|
slot |
Shows the module's default window. This the first window found in the tree, or with the name _default.
|
slot |
Shows a window created from file.
|
slot |
Shows a window created from string.
|
slot |
Translates the given text (considering the modules type).
See the MDL reference for more information about translations: Translations.
|
slot |
Returns the type of the contained object as a string.
|
slot |
Unexpands a filename string containing variables starting with $(...) See expandFilename() for details.
|
slot |
Updates the layout of module (string position, connectors, etc.).
If the module listener is NULL, nothing is done.
|
slot |
Updates an existing .mhelp module help file with information about the current module.
If it does not exist, it will be created.
|
slot |
Returns the current window (depending on current window).