MeVisLab Scripting Reference
|
#include <mlabModule.h>
Inherits MLABFieldOwner.
Inherited by MLABInvalidModule, MLABMLModule, and MLABMacroModule.
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 | 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 MLAB have a global "context" variable (alias: "ctx") which can be accessed from the script. This context variable always points to an MLABModule, 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(), then 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 |
Same as above, but local macro modules take precedence over modules from the MLAB database.
|
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 persistent when you save 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 persistent when you save the network.)
|
virtualslot |
Adds a new module to the internal network (return 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 which is the top most in the parent chain, being 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 on 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, then 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. |
|
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 current window (depending on current window).
|
slot |
Returns the command handler named name
, if name is empty 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 when you try to call it from commands of the MDL Commands section or from the scripting console.
Example:
When 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 window.
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 |
Copy the instance name to the clipboard.
|
slot |
Creates a borderless window that is a child of the given window (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 (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 (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 (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 old instantiated window.
|
slot |
Creates 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 old 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 |
Creates window which 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 window which 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 (input field is given as 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 of 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 given filename.
Trailing (back-)slashes are removed if the result is a directory.
This function supports:
and all variables that are given in mevislab.prefs file. If doCleanPath is set multiple directory separators are removed and any '.' and '..' is 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, then the default window of this module will be exported. The names may contain dots to specify windows of sub modules. |
|
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 what methods are available on fields.
You can also access field in the parent module of the current module. And you can go up with "parent:" and go done 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 makes sure that the MDL files are re-read in the global tree.
Reimplemented in MLABMacroModule.
|
slot |
Returns the frame of module (world coords) on 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 be existent).
|
slot |
Returns the path to module definition folder.
|
slot |
Returns the module help file (.mhelp) for the module (may not be existent).
|
slot |
Returns the path to module sources folder.
|
inlineslot |
Returns access to the package of the module (may be NULL if 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, because only None will be returned in Python then.
|
slot |
Returns whether a control with name
exists in the current context.
|
slot |
Returns whether the module has this field and it 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 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 a *.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 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 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 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 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 MLABMacroModule, and MLABRemoteModule.
|
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 remove of the module).
|
slot |
Removes this module from the network and put it into the undo history (the module will not be deleted immediately).
|
slot |
Re-shows panels that have been previously closed.
|
slot |
Restore default values of fields (if possible)
|
slot |
Returns the given variable from scripting.
|
slot |
Sets the currently active window id (returns old id).
|
slot |
Sets the frame of module (world coords) on 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 coords) on network sheet, module is moved to given center, the size is kept.
|
slot |
Sets the frame topleft of the module (in world coords) on network sheet, module is moved to given topleft position, the size is kept.
|
inlineslot |
Sets that the module is not persistent, so it will not be written to *.mlab files (and not be 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 (deselects 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 MLABMacroModule, and MLABRemoteModule.
|
slot |
Shows the module's automatic window showing all fields of the module.
|
slot |
Shows the context menu for this module.
|
slot |
Runs external program to show the dependencies of this module's DLL.
|
slot |
Shows example network.
|
slot |
Shows HTML help (and creates the file to avoid old docs).
|
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 modal dialog (returns 1 on accept and 0 on cancel).
Rhe 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 |
Show a modal dialog which 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 which 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 MeVisLab IDE.
|
virtualslot |
Shows the default window as a panel.
|
slot |
Shows a scripting console for this context.
|
slot |
Shows window with name (_default, _automatic and _viewer are special names that can be used).
|
slot |
Shows the module's default window (the first window found in the tree, or with the name _default).
|
slot |
Shows window created from file.
|
slot |
Shows 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 contained object (as 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 of the current module.
If it does not exist, it will be created.
|
slot |
Returns the current window (depending on current window).