MLABModule Class Reference
[Modules and NetworksScripting]

Baseclass for modules in an MLABNetwork. More...

Inherits MLABFieldOwner.

Inherited by MLABInvalidModule, MLABMacroModule, and MLABMLModule.

List of all members.

Public Slots

Showing windows of the module
MLABFieldListeneraddFieldListener (MLABField *f, const QString &script, bool init)
void addToGroup (const QString &name)
void closeAllWindows ()
MLABWindowControlcreateBorderlessWindow (const QString &name, MLABWindowControl *parent)
void createConnectors ()
MLABWindowControlcreateModalDialog (const QString &name, MLABWindowControl *parent)
MLABWindowControlcreatePopupWindow (const QString &name, MLABWindowControl *parent)
MLABWindowControlcreateWindow (const QString &name, MLABWindowControl *parent)
MLABWindowControlcreateWindow (const QString &name)
MLABWindowControlcreateWindow (MLABWindowControl *parent)
MLABWindowControlcreateWindow ()
MLABWindowControlcreateWindowFromFile (const QString &file, MLABWindowControl *parent)
MLABWindowControlcreateWindowFromFile (const QString &file)
MLABWindowControlcreateWindowFromString (const QString &string, MLABWindowControl *parent)
MLABWindowControlcreateWindowFromString (const QString &string)
QString groupName () const
bool hasWindow (const QString &name)
void removeFieldListener (MLABFieldListener *listener)
void reshowClosedWindows ()
MLABWindowControlshowAutomaticWindow ()
int showModalDialog (const QString &name, MLABWindowControl *parent)
int showModalDialog ()
int showModalDialog (const QString &name)
int showModalDialog (const QString &name, const QString &title)
int showModalDialogFromFile (const QString &file, MLABWindowControl *parent)
int showModalDialogFromFile (const QString &file)
int showModalDialogFromFile (const QString &file, const QString &title)
int showModalDialogFromString (const QString &mdlString, MLABWindowControl *parent)
int showModalDialogFromString (const QString &mdlString)
int showModalDialogFromString (const QString &mdlString, const QString &title)
virtual MLABWindowControlshowParameterWindow ()
MLABWindowControlshowWindow (const QString &name, MLABWindowControl *parent=NULL)
MLABWindowControlshowWindow (MLABWindowControl *parent=NULL)
MLABWindowControlshowWindowFromFile (const QString &file)
MLABWindowControlshowWindowFromString (const QString &string)
void updateLayout ()
Scripting access to fields, modules and controls
virtual MLABModuleaddMacroModuleFromFile (const QString &file)
virtual MLABModuleaddMacroModuleFromString (const QString &string)
virtual MLABModuleaddModule (const QString &name)
QVariant call (const QString &func, QObject *obj)
QVariant call (const QString &func)
QVariant call (const QString &func, const QVariantList &args)
QStringList callableFunctions ()
int callLater (double seconds, const QString &func, const QVariantList &args)
int callLater (double seconds, const QString &func)
int callWithInterval (double seconds, const QString &func, const QVariantList &args)
int callWithInterval (double seconds, const QString &func)
QObject * callWithObjectReturn (const QString &func, QObject *obj)
QObject * callWithObjectReturn (const QString &func)
QObject * callWithObjectReturn (const QString &func, const QVariantList &args)
virtual void clearCache ()
virtual void closeWindow ()
QObject * commandHandler (const QString &name)
bool connectField (const QString &dst, const QString &src)
virtual MLABWidgetControlcontrol (const QString &name)
MLABWidgetControlcontrolDebug (const QString &name)
void createScriptingContext (const QString &language)
int currentWindowID ()
void deleteScriptVariable (const QString &name)
QVariantMap deprecatedFieldNames ()
QVariantList deprecatedFieldNames (MLABField *field)
QVariantList deprecatedFieldNames (const QString &fieldName)
bool disconnectField (const QString &input)
QString expandFilename (const QString &file)
virtual MLABFieldfield (const QString &name)
QMap< QString, QVariant > getDependency ()
bool hasControl (const QString &name)
bool hasField (const QString &name)
bool hasFunction (const QString &functionName)
bool hasModule (const QString &name)
QString localPath ()
void log (const QString &msg)
void logFixed (const QString &text)
void logHTML (const QString &msg)
virtual MLABModulemodule (const QString &name)
QStringList modules ()
QString networkPath ()
void remove ()
void removeTimer (int id)
void removeTimers ()
void removeUndoable ()
QVariant scriptVariable (const QString &name)
int setCurrentWindowID (int windowID)
void setScriptVariable (const QString &name, const QVariant &value)
QString unexpandFilename (const QString &file)
MLABWindowControlwindow ()
Access to owning and internal network/macros
MLABMacroModuleapplicationMacro (bool shouldWarnIfNotMacro=true)
bool isDescendentOf (MLABModule *module)
bool isDescendentOfNetwork (MLABNetwork *network)
virtual MLABNetworknetwork ()
MLABNetworkowner ()
MLABMacroModuleparent ()
Information about the module
QRect frame () const
virtual QString fullName ()
MLABPackagegetPackage ()
QStringList inputs ()
virtual bool isPersistent ()
virtual bool isRemote ()
virtual bool isSelected () const
bool isValid ()
QStringList outputs ()
MLABPackagepackage ()
QStringList parameters ()
void setFrame (const QRect &frame)
void setFrameCenter (int x, int y)
void setFrameTopLeft (int x, int y)
void setNonPersistent ()
void setSelected (bool flag, bool notifyModuleListener=true)
void setSingleSelected ()
QString type () const


Detailed Description

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:

   ctx.methodName(arg1,arg2,...);

Typical used methods in a module are:

Utility functions:

Methods concerning windows (panels):

Less typical methods in a module are:

MDL reference: Module


Member Function Documentation

MLABFieldListener* MLABModule::addFieldListener ( MLABField f,
const QString &  script,
bool  init 
) [slot]

add a field listener to the module at runtime, the field can be any field from any module, the script is executed in the context the module you call this method on

virtual MLABModule* MLABModule::addMacroModuleFromFile ( const QString &  file  )  [virtual, slot]

adds a new module from a string to the internal network temporarily (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)

virtual MLABModule* MLABModule::addMacroModuleFromString ( const QString &  string  )  [virtual, slot]

adds a new module from a string to the internal network temporarily (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)

virtual MLABModule* MLABModule::addModule ( const QString &  name  )  [virtual, slot]

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")

void MLABModule::addToGroup ( const QString &  name  )  [slot]

add 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

MLABMacroModule* MLABModule::applicationMacro ( bool  shouldWarnIfNotMacro = true  )  [slot]

get the MacroModule which is the top most in the parent chain, being the started application

QVariant MLABModule::call ( const QString &  func,
QObject *  obj 
) [slot]

like call() method, but with object as argument

QVariant MLABModule::call ( const QString &  func  )  [slot]

like call() method, but without arguments

QVariant MLABModule::call ( const QString &  func,
const QVariantList &  args 
) [slot]

call the given function inside of the module, the method can be global or fully qualified (e.g. someobject.somefunction) , arguments are a JS Array of values (these args can not be objects or classes)

QStringList MLABModule::callableFunctions (  )  [slot]

returns a list of callable scripting functions (callable with call())

int MLABModule::callLater ( double  seconds,
const QString &  func,
const QVariantList &  args 
) [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

Returns:
returns a unique timer id that can be used with removeTimer() to stop the timer

int MLABModule::callLater ( double  seconds,
const QString &  func 
) [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

Returns:
returns a unique timer id that can be used with removeTimer() to stop the timer

int MLABModule::callWithInterval ( double  seconds,
const QString &  func,
const QVariantList &  args 
) [slot]

like call() method but calls repeatedly in the given interval.

To stop the timer, use the kill() method on the returned timer object

Returns:
returns a unique timer id that can be used with removeTimer() to stop the timer

int MLABModule::callWithInterval ( double  seconds,
const QString &  func 
) [slot]

like call() method but calls repeatedly in the given interval.

To stop the timer, use the kill() method on the returned timer object

Returns:
returns a unique timer id that can be used with removeTimer() to stop the timer

QObject* MLABModule::callWithObjectReturn ( const QString &  func,
QObject *  obj 
) [slot]

like call() method, but with object as return value

QObject* MLABModule::callWithObjectReturn ( const QString &  func  )  [slot]

like call() method, but with object as return value

QObject* MLABModule::callWithObjectReturn ( const QString &  func,
const QVariantList &  args 
) [slot]

like call() method, but with object as return value

virtual void MLABModule::clearCache (  )  [virtual, slot]

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

void MLABModule::closeAllWindows (  )  [slot]

close all windows (you can reshow the windows at the same screen positions by calling reshowClosedWindows)

virtual void MLABModule::closeWindow (  )  [virtual, slot]

close current window (depending on current window)

QObject* MLABModule::commandHandler ( const QString &  name  )  [slot]

get the command handler named name, if name is empty returns the first unnamed commandHandler

bool MLABModule::connectField ( const QString &  dst,
const QString &  src 
) [slot]

connect input field dst to output field src, fields are given by their string name (Note: this is a shortcut to MLABField connectFrom())

virtual MLABWidgetControl* MLABModule::control ( const QString &  name  )  [virtual, slot]

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:

      Button {
        title = "Button1"
        name = button1
        command = "*js: var b = ctx.control("button1"); b.setTitle("SomeText");  } *"
      }

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.

MLABWidgetControl* MLABModule::controlDebug ( const QString &  name  )  [slot]

like above method, 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

MLABWindowControl* MLABModule::createBorderlessWindow ( const QString &  name,
MLABWindowControl parent 
) [slot]

create 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()

void MLABModule::createConnectors (  )  [slot]

creates the field connectors of the visual by communicating with the module listener.

If the module listener is NULL, nothing is done.

MLABWindowControl* MLABModule::createModalDialog ( const QString &  name,
MLABWindowControl parent 
) [slot]

create 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)

MLABWindowControl* MLABModule::createPopupWindow ( const QString &  name,
MLABWindowControl parent 
) [slot]

create 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()

void MLABModule::createScriptingContext ( const QString &  language  )  [slot]

create scripting context for given language if not already done

MLABWindowControl* MLABModule::createWindow ( const QString &  name,
MLABWindowControl parent 
) [slot]

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

MLABWindowControl* MLABModule::createWindow ( const QString &  name  )  [slot]

create window with name (_default, _automatic and _viewer are special names that can be used) create does not show the window, use methods from MLABWindowControl to show the window after creation if window was already created, returns the pointer to the old instantiated window

MLABWindowControl* MLABModule::createWindow ( MLABWindowControl parent  )  [slot]

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

MLABWindowControl* MLABModule::createWindow (  )  [slot]

create the module's default window (the first window found in the tree, or with the name _default) create does not show the window, use methods from MLABWindowControl to show the window after creation if window was already created, returns the pointer to the old instantiated window

MLABWindowControl* MLABModule::createWindowFromFile ( const QString &  file,
MLABWindowControl parent 
) [slot]

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

MLABWindowControl* MLABModule::createWindowFromFile ( const QString &  file  )  [slot]

create window which is read from file

MLABWindowControl* MLABModule::createWindowFromString ( const QString &  string,
MLABWindowControl parent 
) [slot]

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

MLABWindowControl* MLABModule::createWindowFromString ( const QString &  string  )  [slot]

create window which is parsed from the given string

int MLABModule::currentWindowID (  )  [slot]

returns the currently active window id

void MLABModule::deleteScriptVariable ( const QString &  name  )  [slot]

deletes the script variable from the script context

QVariantMap MLABModule::deprecatedFieldNames (  )  [slot]

returns a dictionary of deprecated names for all fields.

QVariantList MLABModule::deprecatedFieldNames ( MLABField field  )  [slot]

returns a list of deprecated names for the given field.

QVariantList MLABModule::deprecatedFieldNames ( const QString &  fieldName  )  [slot]

returns a list of deprecated names for the given field name.

bool MLABModule::disconnectField ( const QString &  input  )  [slot]

disconnect input field from output field (input field is given as string name) (Note: this is a shortcut to MLABField disconnect())

QString MLABModule::expandFilename ( const QString &  file  )  [slot]

expands starting $(...) variable in given filename

Trailing (back-)slashes are removed, if the result is a directory.

This function supports:

  • LOCAL - local path of def/script file this module is defined in
  • NETWORK - local path of network file this module instance is in
  • MLAB_xxx_yyy - where xxx is an existing package group and yyy an existing package name
  • DemoDataPath - path for MeVisLab DemoData

and all variables that are given in mevislab.prefs file.

virtual MLABField* MLABModule::field ( const QString &  name  )  [virtual, slot]

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:

      var f1 = ctx.field("somefield");
      var f2 = ctx.field("somemodule.somefield");

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:

      var f1 = ctx.field("parent:somefield");
      var f2 = ctx.field("parent:somemodule.somefield");

QRect MLABModule::frame (  )  const [slot]

get frame of module (World coords) on network sheet

virtual QString MLABModule::fullName (  )  [virtual, slot]

get full name (type + instanceName) for debugging only

Implements MLABFieldOwner.

QMap<QString, QVariant> MLABModule::getDependency (  )  [slot]

returns the dependency of the module

map contains string lists for the keys:

  • "dirs"
  • "dlls"
  • "modules"

MLABPackage* MLABModule::getPackage (  )  [inline, slot]

get 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(), but is required for JavaScript users, since "package" is a QSA keyword

QString MLABModule::groupName (  )  const [inline, slot]

returns the name of the group to which the module belongs.

bool MLABModule::hasControl ( const QString &  name  )  [slot]

returns if a control with name exists in the current context

bool MLABModule::hasField ( const QString &  name  )  [slot]

returns true if the module has this field and it can be read by field()

bool MLABModule::hasFunction ( const QString &  functionName  )  [slot]

check if the module has the given script function to call with MLABModule::call

bool MLABModule::hasModule ( const QString &  name  )  [slot]

returns true if the module exists in the network

bool MLABModule::hasWindow ( const QString &  name  )  [slot]

check if a window with the given name is defined

QStringList MLABModule::inputs (  )  [slot]

get the input fields (as list of field names)

bool MLABModule::isDescendentOf ( MLABModule module  )  [slot]

Returns if this module is a descendant of the given module.

That means that this module is inside the given module (macro) in any recursion level.

bool MLABModule::isDescendentOfNetwork ( MLABNetwork network  )  [slot]

Returns if this module is a descendant of the given network.

That means that this module is inside the given network in any recursion level.

virtual bool MLABModule::isPersistent (  )  [inline, virtual, slot]

returns if the module is persistent and will be written to a *.mlab file if saved or copied

Implements MLABFieldOwner.

virtual bool MLABModule::isRemote (  )  [inline, virtual, slot]

is the module remotely executed in a worker instance

Reimplemented in MLABRemoteModule.

virtual bool MLABModule::isSelected (  )  const [virtual, slot]

is module selected

Implements MLABFieldOwner.

bool MLABModule::isValid (  )  [inline, slot]

is module valid

QString MLABModule::localPath (  )  [slot]

get local path of module's def/script file

void MLABModule::log ( const QString &  msg  )  [slot]

log a message for this module

void MLABModule::logFixed ( const QString &  text  )  [slot]

log a message for this module, using a fixed size font and replacing spaces with  

void MLABModule::logHTML ( const QString &  msg  )  [slot]

log a message for this module (using HTML)

virtual MLABModule* MLABModule::module ( const QString &  name  )  [virtual, slot]

searches for module with given name

Searched for a module with a given instanceName inside the internal network of this module.

Example:

      var mod = ctx.module("imgload");

Reimplemented in MLABMacroModule.

QStringList MLABModule::modules (  )  [slot]

returns the instanceNames of all modules in the network

virtual MLABNetwork* MLABModule::network (  )  [inline, virtual, slot]

get internal network (used in MacroModules, do not mix this up with owner()! )

Reimplemented in MLABMacroModule.

QString MLABModule::networkPath (  )  [slot]

get local path of network the module instance is in (may be empty if network was not saved)

QStringList MLABModule::outputs (  )  [slot]

get the output fields (as list of field names)

MLABNetwork* MLABModule::owner (  )  [virtual, slot]

get owning network

Implements MLABFieldOwner.

MLABPackage* MLABModule::package (  )  [slot]

get access to the package of the module (may be NULL if not registered with any package, e.g. a local macro module)

QStringList MLABModule::parameters (  )  [slot]

get the parameter fields (as list of field names)

MLABMacroModule* MLABModule::parent (  )  [slot]

get parent MacroModule (this can be used to call scripting methods on the owning MacroModule)

void MLABModule::remove (  )  [slot]

remove this module from the network, this will cause an immediate deletion of the module

void MLABModule::removeFieldListener ( MLABFieldListener listener  )  [slot]

remove field listener

void MLABModule::removeTimer ( int  id  )  [slot]

remove (stops) the given timer (id is from callLater or callWithTimer, the timer must be created in this context)

void MLABModule::removeTimers (  )  [slot]

remove (stops) all timers inside of this context (this is automatically called on reload and remove of the module)

void MLABModule::removeUndoable (  )  [slot]

remove this module from the network and put it into the undo history (the module will not be deleted immediately)

void MLABModule::reshowClosedWindows (  )  [slot]

reshow panels that have been previously closed

QVariant MLABModule::scriptVariable ( const QString &  name  )  [slot]

get the given variable from scripting

int MLABModule::setCurrentWindowID ( int  windowID  )  [slot]

set the currently active window id (returns old id)

void MLABModule::setFrame ( const QRect &  frame  )  [slot]

set 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()

void MLABModule::setFrameCenter ( int  x,
int  y 
) [slot]

set frame center of the module (in world coords) on network sheet, module is moved to given center, the size is kept

void MLABModule::setFrameTopLeft ( int  x,
int  y 
) [slot]

set frame topleft of the module (in world coords) on network sheet, module is moved to given topleft position, the size is kept

void MLABModule::setNonPersistent (  )  [inline, slot]

sets that the module is not persistent, so it will not be written to *.mlab files (and not be copy/pastable)

Reimplemented in MLABMacroModule.

void MLABModule::setScriptVariable ( const QString &  name,
const QVariant &  value 
) [slot]

set the given variable in the script context to the given value

void MLABModule::setSelected ( bool  flag,
bool  notifyModuleListener = true 
) [slot]

set select state

void MLABModule::setSingleSelected (  )  [slot]

sets only this module selected (deselects all other modules first)

MLABWindowControl* MLABModule::showAutomaticWindow (  )  [slot]

show the module's automatic window showing all fields of the module

int MLABModule::showModalDialog ( const QString &  name,
MLABWindowControl parent 
) [slot]

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

int MLABModule::showModalDialog (  )  [slot]

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

int MLABModule::showModalDialog ( const QString &  name  )  [slot]

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

int MLABModule::showModalDialog ( const QString &  name,
const QString &  title 
) [slot]

show modal dialog (return 1 on accept and 0 on cancel)

the shown dialog can be closed by calling

 ctx.window()->accept() 
to close and accept (return value 1)
 ctx.window()->reject() 
to close and reject (return value 0) or you can call
 ctx.window()->done(int result) 
where the result gets returned to the caller of showModalDialog().

int MLABModule::showModalDialogFromFile ( const QString &  file,
MLABWindowControl parent 
) [slot]

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

int MLABModule::showModalDialogFromFile ( const QString &  file  )  [slot]

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

int MLABModule::showModalDialogFromFile ( const QString &  file,
const QString &  title 
) [slot]

show a modal dialog which is read from file

int MLABModule::showModalDialogFromString ( const QString &  mdlString,
MLABWindowControl parent 
) [slot]

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

int MLABModule::showModalDialogFromString ( const QString &  mdlString  )  [slot]

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

int MLABModule::showModalDialogFromString ( const QString &  mdlString,
const QString &  title 
) [slot]

show a modal dialog which is parsed from the given string

virtual MLABWindowControl* MLABModule::showParameterWindow (  )  [virtual, slot]

show the default window as a panel

MLABWindowControl* MLABModule::showWindow ( const QString &  name,
MLABWindowControl parent = NULL 
) [slot]

show window with name (_default, _automatic and _viewer are special names that can be used)

MLABWindowControl* MLABModule::showWindow ( MLABWindowControl parent = NULL  )  [slot]

show the module's default window (the first window found in the tree, or with the name _default)

MLABWindowControl* MLABModule::showWindowFromFile ( const QString &  file  )  [slot]

show window created from file

MLABWindowControl* MLABModule::showWindowFromString ( const QString &  string  )  [slot]

show window created from string

QString MLABModule::type (  )  const [slot]

get type of contained object (as string)

QString MLABModule::unexpandFilename ( const QString &  file  )  [slot]

unexpands starting $(.

..) variable in given string (see expandFilename() for details)

void MLABModule::updateLayout (  )  [slot]

update the layout of module (string position, connectors etc.

). If the module listener is NULL, nothing is done.

MLABWindowControl* MLABModule::window (  )  [slot]

get the current window (depending on current window)


Generated on Sat Sep 3 18:38:03 2011 for MeVisLab Scripting Reference by  doxygen 1.5.8