MeVisLab Scripting Reference
MLAB Class Reference

Inherits QObject.

Public Types

enum  LoadDicomTreeOptions { DicomNoOptions = 0, DicomReadPixelData = 1, DicomReadPrivateTags = 2 }
 
enum  macAuthorizationError {
  macErrAuthorizationUnknown = -1, macErrAuthorizationSuccess = 0, macErrAuthorizationCanceled = 1, macErrAuthorizationDenied = 2,
  macErrAuthorizationToolExecuteFailure = 3, macErrAuthorizationToolEnvironmentError = 4
}
 

Public Slots

Global state utility functions.
void clearMLCache ()
 
int getCacheAndLockedMemorySizeInKB ()
 
int getCacheAndLockedMemorySizeLimitInKB ()
 
int setNumberOfImageProcessingThreads (int numThreads)
 
int getNumberOfImageProcessingThreads ()
 
bool isDebug ()
 
bool isModuleProfilingEnabled ()
 
void setModuleProfilingEnabled (bool enabled)
 
QDateTime buildDate ()
 
bool isWindows ()
 
bool isUnix ()
 
bool isLinux ()
 
bool isMacOS ()
 
QString systemId ()
 
QString detailedSystemId ()
 
QString systemInfo ()
 
QString computerModelInfo ()
 
QString compilerInfo ()
 
QString standaloneApplicationName ()
 
bool isStandaloneApplication ()
 
void writeRegistry ()
 
QString getenv (const QString &str)
 
bool hasVariable (const QString &name)
 
QString variable (const QString &name)
 
void setVariable (const QString &name, const QString &value)
 
void unsetVariable (const QString &name)
 
bool variableIsTrue (const QString &name)
 
QString readKey (const QString &application, const QString &key)
 
void writeKey (const QString &application, const QString &key, const QString &value)
 
bool isSpelledCorrectly (const QString &word)
 
QStringList getSpellingCorrectionSuggestions (const QString &word)
 
QString getAutomaticFieldTitle (const QString &name, bool splitUppercase)
 
bool loadLibrary (const QString &libraryName)
 
Running commands as external processes.
bool runActionOnFile (const QString &action, const QString &abspath)
 
bool openFile (const QString &abspath, int lineno=-1)
 
bool editFile (const QString &abspath)
 
bool openUrl (const QString &abspath)
 
bool runCommandDetached (const QString &command, const QStringList &arguments=QStringList(), const QString &workingDirectory=QString(), bool makeFrontmost=true)
 
bool runCommand (const QString &command, const QStringList &arguments=QStringList(), const QString &workingDir=QString())
 
QMap< QString, QVariant > runCommandStdInOut (const QString &command, const QStringList &arguments=QStringList(), const QString &workingDir=QString(), const QString &standardIn=QString())
 
bool runCommandInConsole (const QString &command, const QStringList &arguments=QStringList(), const QString &workingDir=QString(), const QString &standardIn=QString(), const QString &title=QString(), MLABWidgetControl *parent=NULL)
 
QMap< QString, QVariant > macRunPrivilegedCommand (const QString &command, const QStringList &arguments, const QString &securityEventId=QString(), const QString &prompt=QString())
 
bool macIsApplicationRunning (const QString &bundleId)
 
MLABScriptProcess * newProcess ()
 
void deleteProcess (MLABScriptProcess *process)
 
MLABHttpDownloadnewHttpDownload ()
 
Printing
MLABScriptPrinter * newPrinter ()
 
void deletePrinter (MLABScriptPrinter *process)
 
Logging to console.
void log (const QString &text)
 
void logFixed (const QString &text)
 
void logWarning (const QString &text)
 
void logError (const QString &text)
 
void logHTML (const QString &text)
 
void logWarningHTML (const QString &text)
 
void logErrorHTML (const QString &text)
 
QString createHyperLink (const QString &absfile)
 
QString createHyperLinkFullPath (const QString &absfile)
 
QString createHyperLinkWithLine (const QString &absfile, long lineno)
 
Event processing
void processInventorQueue ()
 
bool shouldStop ()
 
void processEvents ()
 
void processEvents (bool allowUserInput)
 
void terminate ()
 
void exit (int code)
 
void setDontExitAfterConsoleCommand (bool dontExitAfterConsoleCommand)
 
bool enableBusyStateIndication (bool trueOrFalse)
 
void indicateBusyState (const QString &message=QString())
 
void setWaitCursor ()
 
void removeBusyStateIndicator ()
 
void removeWaitCursor ()
 
void setOverrideCursor (const QPixmap &pixmap)
 
void setOverrideCursor (const QString &filename)
 
void setOverrideCursor (const QString &filename, int hotspotx, int hotspoty)
 
void removeOverrideCursor ()
 
QPoint cursorPos ()
 
MLABWidgetControlmdlControlAtCurrentCursorPosition ()
 
MLABWidgetControlmdlControlAtGlobalPosition (const QPoint &globalPosition)
 
MLABWidgetControlmdlControlAtGlobalPosition (int x, int y)
 
void sleep (int secs)
 
void msleep (int msecs)
 
void usleep (int usecs)
 
MLABWidgetControlenterModalClickGrabber ()
 
Dragging

You can optionally specify an icon to show while dragging.

If you don't give a hot spot location for the icon, it will be in the center of the icon.

bool startTextDrag (const QString &text, const QPixmap &icon=QPixmap(), int hotSpotX=-1, int hotSpotY=-1)
 
bool startNewModuleDrag (const QString &mod, const QPixmap &icon=QPixmap(), int hotSpotX=-1, int hotSpotY=-1)
 
bool startModuleDrag (MLABModule *mod, const QPixmap &icon=QPixmap(), int hotSpotX=-1, int hotSpotY=-1)
 
bool startFieldDrag (MLABField *field, const QPixmap &icon=QPixmap(), int hotSpotX=-1, int hotSpotY=-1)
 
bool startObjectDrag (QObject *object, const QPixmap &icon=QPixmap(), int hotSpotX=-1, int hotSpotY=-1)
 
bool startColorDrag (const QColor &color, const QPixmap &icon=QPixmap(), int hotSpotX=-1, int hotSpotY=-1)
 
bool startImageDrag (const QPixmap &pixmap, const QPixmap &icon=QPixmap(), int hotSpotX=-1, int hotSpotY=-1)
 
bool startImageDrag (const QImage &image, const QPixmap &icon=QPixmap(), int hotSpotX=-1, int hotSpotY=-1)
 
bool startFileDrag (const QStringList &files, const QPixmap &icon=QPixmap(), int hotSpotX=-1, int hotSpotY=-1)
 
bool startFileDrag (const QString &file, const QPixmap &icon=QPixmap(), int hotSpotX=-1, int hotSpotY=-1)
 
Dialogs
void showInformation (const QString &text, const QString &detail, const QString &title, MLABWidgetControl *parent=NULL)
 
void showInformation (const QString &text, const QString &title=MEVISLAB_TITLESTRING)
 
void showWarning (const QString &text, const QString &detail, const QString &title, MLABWidgetControl *parent=NULL)
 
void showWarning (const QString &text, const QString &title=MEVISLAB_TITLESTRING)
 
void showCritical (const QString &text, const QString &detail, const QString &title, MLABWidgetControl *parent=NULL)
 
void showCritical (const QString &text, const QString &title=MEVISLAB_TITLESTRING)
 
int showQuestion (const QString &text, const QString &detail, const QString &title, const QStringList &buttonTexts, int defaultButtonNumber, MLABWidgetControl *parent=NULL)
 
int showQuestion (const QString &text, const QString &title, const QStringList &buttonTexts, int defaultButtonNumber)
 
int showInformation (const QString &text, const QString &detail, const QString &title, const QStringList &buttonTexts, int defaultButtonNumber, MLABWidgetControl *parent=NULL)
 
int showInformation (const QString &text, const QString &title, const QStringList &buttonTexts, int defaultButtonNumber)
 
int showWarning (const QString &text, const QString &detail, const QString &title, const QStringList &buttonTexts, int defaultButtonNumber, MLABWidgetControl *parent=NULL)
 
int showWarning (const QString &text, const QString &title, const QStringList &buttonTexts, int defaultButtonNumber)
 
int showCritical (const QString &text, const QString &detail, const QString &title, const QStringList &buttonTexts, int defaultButtonNumber, MLABWidgetControl *parent=NULL)
 
int showCritical (const QString &text, const QString &title, const QStringList &buttonTexts, int defaultButtonNumber)
 
QString getMultiLineText (const QString &text, const QString &title, bool richtext, MLABWidgetControl *parent=NULL)
 
void showMultiLineText (const QString &text, const QString &title, bool richtext, MLABWidgetControl *parent=NULL)
 
QColor showColorDialog (const QColor &initialColor=Qt::white, MLABWidgetControl *parent=NULL)
 
QColor showColorDialog (const QString &initialColor, MLABWidgetControl *parent=NULL)
 
void about (MLABWidgetControl *parent=NULL)
 
QWidget * IDE ()
 
Misc methods
void copyToPasteboard (const QString &string)
 
QMimeData * newMimeData ()
 
QString intToString (int value, const QString &format)
 
QString doubleToString (double value, const QString &format)
 
QString stringToEncodedUrlString (const QString &string)
 
QString dateToString (QDateTime date, const QString &format)
 
QString translate (const QByteArray &context, const QString &sourceText, const QString &disambiguation=QString()) const
 
QString escapeString (const QString &value)
 
QString readWindowsRegistry (const QString &type, const QString &key, const QString &subkey)
 
QStringList getProgramFromWindowsRegistry (const QString &type, const QString &key, const QString &subkey)
 
bool valueIsTrue (const QString &val)
 
MLABFieldlastClickedOutputField ()
 
bool hasFeature (const QString &feature)
 
QString licenseFileName ()
 
void help ()
 
void help (QObject *o)
 
void help (const QString &name)
 
QString cryptString (const QString &data)
 
QString decryptString (const QString &data)
 
QString cryptString (const QString &data, const QString &password)
 
QString decryptString (const QString &data, const QString &password)
 
QString hashStringMD5 (const QString &data)
 
QString hashStringMD5Latin1 (const QString &data)
 
bool qobjectInherits (QObject *object, const QString &classname)
 
MeVisLab module introspection.
QStringList modules ()
 
QStringList macroModules ()
 
QStringList mlModules ()
 
QStringList inventorModules ()
 
QStringList allModulesForPackageIdentifier (const QString &packageIdentifier)
 
QMap< QString, QVariant > moduleInfo (const QString &module)
 
QMap< QString, QVariant > getFileFormatLoader (const QString &filename)
 
QStringList findModuleGroups ()
 
QStringList allModules ()
 
QStringList allMacroModules ()
 
QStringList allMLModules ()
 
QStringList allInventorModules ()
 
QVariantMap getModuleDependencies (const QStringList &moduleNames, bool includeModuleDirectories=true, QStringList ignoredPackages=QStringList()<< "MeVis/ThirdParty", bool includeWebContents=false, bool includeModuleHelpFiles=false, MLABNetwork *scannedNetwork=NULL)
 
MLABModuleDependencyWrapper * getModuleDependency (const QStringList &moduleNames, bool includeModuleDirectories=true, bool includeWebContents=false, bool includeModuleHelpFiles=false, MLABNetwork *scannedNetwork=NULL)
 
MDL (MeVisLab Definition Language) parsing.
MLABTreereadTreeFromString (const QString &str, bool replaceVars)
 
MLABTreereadTreeFromFile (const QString &filename, bool replaceVars)
 
bool setMDLTagValue (const QString &fileName, const QStringList &treePath, const QString &value)
 
bool writeTreeToFile (MLABTree *tree, const QString &filename)
 
QString writeTreeToString (MLABTree *tree)
 
MLABTreenewTree ()
 
MLABTreenewTree (const QString &name, const QString &value)
 
MLABTreeValidatornewTreeValidator (MLABTree *validatorDefinition)
 
void deleteTreeValidator (MLABTreeValidator *treeValidator)
 
MLABTreeValidatormdlValidator ()
 
bool runMDLValidatorOnTree (MLABTree *tree)
 
QString replaceMDLVariables (const QString &text, const QString &localPath=QString())
 
Reading DICOM files.
MLABDicomTreeloadDicomTree (const QString &filename, LoadDicomTreeOptions options=DicomNoOptions)
 
QString createDicomUid ()
 
Running MeVisLab macro modules as applications.
MLABApplicationRunnerrunApplication (const QString &name)
 
MLABApplicationRunnerrunApplication (const QString &name, const QStringList &args)
 
MLABApplicationRunnerrunApplication (const QString &name, const QStringList &args, MLABWidgetControl *parent)
 
User activity measurement.
void setUserActivityThreshold (int seconds)
 
void resetUserActivity ()
 
bool isUserActive ()
 
Sign files.
bool signFilesRecursive (const QString &path, const QString &filter, bool crypt)
 
bool signFilesRecursive (const QString &path, const QString &filter, bool crypt, const QString &license)
 
bool signFiles (const QStringList &files, const QString &filter, bool crypt)
 
bool signFiles (const QStringList &files, const QString &filter, bool crypt, const QString &license)
 
Script extensions.
bool hasScriptExtension (const QString &extension)
 
QObject * getScriptExtension (const QString &extension)
 
QObject * createMLBaseObject (const QString &baseClassName, const QVariantList &arguments=QVariantList())
 
SoFieldContainer * createInventorObject (const QString &className)
 
MLABModulegetModuleForInventorObject (SoFieldContainer *object)
 
SQL databases
MLABScriptSqlDatabase * addSqlDatabase (const QString &type)
 
void removeSqlDatabase (MLABScriptSqlDatabase *db)
 

Properties

MLABMLScriptWrapper ML
 

Detailed Description

Access to all global functions and objects of MLAB.

An instance of this class is available as global "MLAB" object in scripting.

Member Function Documentation

void MLAB::about ( MLABWidgetControl parent = NULL)
slot

Show the "about" screen.

MLABScriptSqlDatabase* MLAB::addSqlDatabase ( const QString &  type)
slot

Adds a new database connection of type (where type can be "sqlite", "postgres", or "odbc").

Example:

db = MLAB.addSqlDatabase("postgres")
db.setUserName("myuser")
db.setPassword("mypassword")
db.setDatabaseName("mydatabase")
db.setHostName("myhost.mevis.de")
# optional port, default port is used otherwise
#db.setPort(123412);
# open the database connection
if db.open():
pass # OK
else:
# print error
MLAB.log(db.lastError()["message"])
QStringList MLAB::allInventorModules ( )
slot

Returns all known Inventor modules (even when not visible to the user).

QStringList MLAB::allMacroModules ( )
slot

Returns all known macro modules (even when not visible to the user).

QStringList MLAB::allMLModules ( )
slot

Returns all known ML modules (even when not visible to the user).

QStringList MLAB::allModules ( )
slot

Returns all known modules (even when not visible to the user).

QStringList MLAB::allModulesForPackageIdentifier ( const QString &  packageIdentifier)
slot

Returns all modules contained in the specified package.

The package needs to be specified by "PackageGroup/Package", e.g., "MeVisLab/Standard".

QDateTime MLAB::buildDate ( )
slot

Returns the build date of MeVisLab.

void MLAB::clearMLCache ( )
slot

Clears the complete ML Cache.

QString MLAB::compilerInfo ( )
slot

Returns information about the used compiler.

QString MLAB::computerModelInfo ( )
slot

Returns information about the computer model (e.g., for diagnostic purposes).

void MLAB::copyToPasteboard ( const QString &  string)
slot

Copies a string to the pasteboard.

QString MLAB::createDicomUid ( )
slot

Returns a unique dicom uid with MeVis prefix and software type MeVisLab.

The method uses the DCMTree_Utils::UIDGenerator and offers a globally unique id using the process id, the time stamp and the mac address.

QString MLAB::createHyperLink ( const QString &  absfile)
slot

Creates a hyper link string with file part.

QString MLAB::createHyperLinkFullPath ( const QString &  absfile)
slot

Creates a hyper link string with full path.

QString MLAB::createHyperLinkWithLine ( const QString &  absfile,
long  lineno 
)
slot

Creates a hyper link string with line number.

SoFieldContainer* MLAB::createInventorObject ( const QString &  className)
slot

Creates a new Inventor node or engine.

MeVisLab will load the DLL in which the object is registered if there is an InventorModule with that name. No MLABModule is created, the returned object is the pure OpenInventor node/engine.

QObject* MLAB::createMLBaseObject ( const QString &  baseClassName,
const QVariantList &  arguments = QVariantList() 
)
slot

Creates a new reference-counted ml::Base object, conveniently wrapped for scripting; which arguments must be supplied to this method depends on the Base class.

QString MLAB::cryptString ( const QString &  data)
slot

Crypts the given string and encodes it into base 64 string (with an internal default password).

QString MLAB::cryptString ( const QString &  data,
const QString &  password 
)
slot

Crypts the given string and encodes it into base64 string.

QPoint MLAB::cursorPos ( )
slot

Returns the global cursor position.

QString MLAB::dateToString ( QDateTime  date,
const QString &  format 
)
slot

Converts a date to string with the given format.

TODO: explain format in more detail Examples: dd.MM.yyyy 21.05.2001 ddd MMMM d yy Tue May 21 01 hh:mm:ss.zzz 14:13:09.042 h:m:s ap 2:13:9 pm

QString MLAB::decryptString ( const QString &  data)
slot

Decrypts the given base64 encoded string and returns a decrypted string (with an internal default password), returns an empty string on error.

QString MLAB::decryptString ( const QString &  data,
const QString &  password 
)
slot

Decrypts the given base64 encoded string and returns a decrypted string, returns an empty string on error.

void MLAB::deletePrinter ( MLABScriptPrinter *  process)
slot

Deletes an MLABPrinter object.

void MLAB::deleteProcess ( MLABScriptProcess *  process)
slot

sDelete a MLABProcess object (does NOT kill a started process, use kill() instead).

void MLAB::deleteTreeValidator ( MLABTreeValidator treeValidator)
slot

Deletes the given tree validator.

QString MLAB::detailedSystemId ( )
slot

Returns the current system identification MLAB is running on.

Returns the following string depending on the system mlab is running on:

  • "windows [95|98|Me|NT|2000|XP|7]" (on windows)
  • "macos [10.5.6|unknown] [i386|x86_64|unknown] [(cpu count)]" (on macintosh)
  • "linux [system releaseversion]" (on any linux system, using uname)
  • "unknown" (on any other system)
QString MLAB::doubleToString ( double  value,
const QString &  format 
)
slot

Converts a double to string with given format (format is as in printf, e.g., '%5.4f').

bool MLAB::editFile ( const QString &  abspath)
slot

Opens the file with an external program (in edit mode).

bool MLAB::enableBusyStateIndication ( bool  trueOrFalse)
slot

Allows/Prevents the display of the global wait cursor (or any other system specific mean to inidicate the busy state).

It does remove any current indication of busy state if set to false. It only enables the indication if it was enabled beforehand. The function returns the previously set value.

MLABWidgetControl* MLAB::enterModalClickGrabber ( )
slot

Enters a global event mode, where MeVisLab catches mouse clicks on controls and returns the control the mouse click happened in (NULL is returned when the user presses the escape key or clicks onto a widget that is not inside of a control).

QString MLAB::escapeString ( const QString &  value)
slot

Escapes the given string so that RichText elements in the text are visible as literal text.

The result can safely be logged via the log() function.

void MLAB::exit ( int  code)
slot

Exit MeVisLab the hard way, scripting still goes on after this, its better to use terminate().

QStringList MLAB::findModuleGroups ( )
slot

Returns a list of known module groups in the form "group":"number of modules":"names of modules".

QString MLAB::getAutomaticFieldTitle ( const QString &  name,
bool  splitUppercase 
)
slot

Returns the field name with the components separated by space.

int MLAB::getCacheAndLockedMemorySizeInKB ( )
slot

Returns the cache and locked memory size of the memory manager in KB.

int MLAB::getCacheAndLockedMemorySizeLimitInKB ( )
slot

Returns the cache and locked memory size limit of the memory manager in KB.

QString MLAB::getenv ( const QString &  str)
slot

Returns the value of the environment variable.

QMap<QString, QVariant> MLAB::getFileFormatLoader ( const QString &  filename)
slot

Returns the file format loader for the extension of the given filename.

If a loader exists, this method returns a map with the following keys:

  • module : the module that can handle the extension
  • filenameField : the field that should be set with the filename

If no loader exists, the map is empty.

QVariantMap MLAB::getModuleDependencies ( const QStringList &  moduleNames,
bool  includeModuleDirectories = true,
QStringList  ignoredPackages = QStringList()<< "MeVis/ThirdParty",
bool  includeWebContents = false,
bool  includeModuleHelpFiles = false,
MLABNetwork scannedNetwork = NULL 
)
slot

Returns a dictionary containing all files and directories on which the given macro modules depend.

The dictionary contains string lists for the keys:

  • "dirs"
  • "dlls"
  • "files"
  • "modules"
  • "scriptFiles"
    Parameters
    includeModuleDirectoriesspecifies whether the directories in which the module definitions exist are included
    ignoredPackagescan be specified to ignore dependencies from certain packages
MLABModuleDependencyWrapper* MLAB::getModuleDependency ( const QStringList &  moduleNames,
bool  includeModuleDirectories = true,
bool  includeWebContents = false,
bool  includeModuleHelpFiles = false,
MLABNetwork scannedNetwork = NULL 
)
slot

Returns an MLABModuleDependency object for accessing the dependency data.

MLABModule* MLAB::getModuleForInventorObject ( SoFieldContainer *  object)
slot

Returns the MLABModule for a C++ Open Inventor node/engine.

If the node/engine has no associated MLABInventorModule, NULL is returned.

QString MLAB::getMultiLineText ( const QString &  text,
const QString &  title,
bool  richtext,
MLABWidgetControl parent = NULL 
)
slot

Ask for a multi line requester which returns the text.

int MLAB::getNumberOfImageProcessingThreads ( )
slot

Returns the number of parallel worker threads that the ML host is allowed to use.

This calls ml::Host::getMaxNumThreads() on the C++ layer.

QStringList MLAB::getProgramFromWindowsRegistry ( const QString &  type,
const QString &  key,
const QString &  subkey 
)
slot

Reads the windows key, where type may be one of CLASSES_ROOT, LOCAL_MACHINE, CURRENT_USER, USERS, and returns a list of strings where the first string is the program name and the remaining strings are arguments.

If the list is empty, no program was found. The returned list items do not contain any quotes.

QObject* MLAB::getScriptExtension ( const QString &  extension)
slot

Returns access to the given script extension.

QStringList MLAB::getSpellingCorrectionSuggestions ( const QString &  word)
slot

Checks spelling and returns a list of suggestions if the given word has not been recognized.

bool MLAB::hasFeature ( const QString &  feature)
slot

Returns whether license has a given feature.

QString MLAB::hashStringMD5 ( const QString &  data)
slot

Returns the md5 hash string for the given data string (converted from Unicode to UTF8).

QString MLAB::hashStringMD5Latin1 ( const QString &  data)
slot

Returns the md5 hash string for the given data string (converted from Unicode to Latin1).

bool MLAB::hasScriptExtension ( const QString &  extension)
slot

Returns whether the given script extension is defined. The method doesn't try to load it.

bool MLAB::hasVariable ( const QString &  name)
slot

Returns whether a global pref variable exists (from MeVisLab prefs and registry).

void MLAB::help ( )
slot

Gives scripting help for the MLAB object itself.

void MLAB::help ( QObject *  o)
slot

Gives scripting help for the given object (if available).

void MLAB::help ( const QString &  name)
slot

Gives scripting help for the given class name (if available).

QWidget* MLAB::IDE ( )
slot

Returns access to the IDE, especially for User Scripts.

void MLAB::indicateBusyState ( const QString &  message = QString())
slot

Shows the global wait cursor (be sure to call removeBusyStateIndicator the same number of times as indicateBusyState).

A message may be given to indicate a reason.

Referenced by setWaitCursor().

QString MLAB::intToString ( int  value,
const QString &  format 
)
slot

Converts an integer to string with given format (format is as in printf, e.g., 'x').

QStringList MLAB::inventorModules ( )
slot

Returns all known inventor modules (that are visible to the user).

bool MLAB::isDebug ( )
slot

Returns whether MLAB is compiled in debug mode (release mode otherwise).

bool MLAB::isLinux ( )
slot

Returns whether system is Linux.

bool MLAB::isMacOS ( )
slot

Returns whether system is Mac OS X.

bool MLAB::isModuleProfilingEnabled ( )
slot

Returns whether module profiling is enabled.

bool MLAB::isSpelledCorrectly ( const QString &  word)
slot

Returns whether the spelling of the given word is correct.

bool MLAB::isStandaloneApplication ( )
slot

Returns whether MeVisLab runs a macro as standalone application.

bool MLAB::isUnix ( )
slot

Returns whether system is Linux or Mac OS X.

bool MLAB::isUserActive ( )
slot

Returns whether the user is currently active (within the threshold).

bool MLAB::isWindows ( )
slot

Returns whether system is Windows.

MLABField* MLAB::lastClickedOutputField ( )
slot

Returns last clicked output field in an MeVislab network (might be NULL).

QString MLAB::licenseFileName ( )
slot

Returns the absolute path to the license that MeVisLab is currently using.

MLABDicomTree* MLAB::loadDicomTree ( const QString &  filename,
LoadDicomTreeOptions  options = DicomNoOptions 
)
slot

Loads a DICOM file and returns it as a tree object.

The tree is freed again when the last reference to it is removed.

With the options parameter you can specify what tags should be read:

  • DicomReadPixelData - read tags containing pixel data
  • DicomReadPrivateTags - read private tags

The values must be or'ed together.

bool MLAB::loadLibrary ( const QString &  libraryName)
slot

Loads the given library and returns whether the loading succeeded.

The name should not contain a debug postfix, not a platform specific prefix/ending, this is added automatically. If a library was already loaded successfully before, it will not be loaded again and this method will return true.

void MLAB::log ( const QString &  text)
slot

Logs the given text to the console.

void MLAB::logError ( const QString &  text)
slot

Log an error to the console.

void MLAB::logErrorHTML ( const QString &  text)
slot

Logs an error to the console (using HTML).

void MLAB::logFixed ( const QString &  text)
slot

Logs the given text to the console, using a fixed size font and replacing spaces with  .

void MLAB::logHTML ( const QString &  text)
slot

Logs the given text to the console (using HTML).

void MLAB::logWarning ( const QString &  text)
slot

Logs a warning to the console.

void MLAB::logWarningHTML ( const QString &  text)
slot

Logs a warning to the console (using HTML).

bool MLAB::macIsApplicationRunning ( const QString &  bundleId)
slot

Returns whether a specific application specified by its bundle id is already running (Mac OS X only).

QStringList MLAB::macroModules ( )
slot

Returns all known macro modules (that are visible to the user).

QMap<QString, QVariant> MLAB::macRunPrivilegedCommand ( const QString &  command,
const QStringList &  arguments,
const QString &  securityEventId = QString(),
const QString &  prompt = QString() 
)
slot

Executes the given command with access to restricted areas of the operating system if user is authorized. Use with care (Mac OS X only).

Calling the function multiple times will reuse an existing authorization reference if and only if the securityEventId is still the same. The same security event id should only be used to authorize calls that "belong together", in the sense that the user should consider them a single security event. If they are meant to be separate, so that a user could meaningfully approve one but decline another, you should use a different security event id. An empty security event id will generate a new, unique security event id.

MLABWidgetControl* MLAB::mdlControlAtCurrentCursorPosition ( )
slot

Returns the MDL control that is located at the current cursor position (or NULL if there is none).

MLABWidgetControl* MLAB::mdlControlAtGlobalPosition ( const QPoint &  globalPosition)
slot

Returns the MDL control that is located at the given global screen position (or NULL if there is none).

MLABWidgetControl* MLAB::mdlControlAtGlobalPosition ( int  x,
int  y 
)
slot

Returns the MDL control that is located at the given global screen position (or NULL if there is none).

MLABTreeValidator* MLAB::mdlValidator ( )
slot

Returns the MDL validator (used for module scripts / MDL GUI), the ownership stays with MeVisLab.

QStringList MLAB::mlModules ( )
slot

Returns all known ML modules (that are visible to the user).

QMap<QString, QVariant> MLAB::moduleInfo ( const QString &  module)
slot

Returns info for the given module; the returned array contains the tag=value keys from the module definition.

The module type is given as type=[MLModule|InventorModule|MacroModule]. The module name is given as name=NAME. The module package is given package=PACKAGENAME. The module filename+linenumber are given as file=abspath lineno=4711 If module is not found, the array is empty.

QStringList MLAB::modules ( )
slot

Returns all known modules (that are visible to the user).

void MLAB::msleep ( int  msecs)
slot

Causes MLAB to sleep msecs milli seconds.

MLABHttpDownload* MLAB::newHttpDownload ( )
slot

Creates a new HTTP download object (which is automatically garbage collected).

QMimeData* MLAB::newMimeData ( )
slot

Creates a new mime data object that is owned by C++ and will not be deleted by PythonQt.

MLABScriptPrinter* MLAB::newPrinter ( )
slot

Creates a new process, see MLABPrinter class for its API.

You have to delete the returned pointer later on with deletePrinter!

MLABScriptProcess* MLAB::newProcess ( )
slot

Creates a new process, see MLABProcess class for its API.

You have to delete the returned pointer later on with deleteProcess!

MLABTree* MLAB::newTree ( )
slot

Creates and returns a new tree element.

MLABTree* MLAB::newTree ( const QString &  name,
const QString &  value 
)
slot

Creates and returns a new tree element.

MLABTreeValidator* MLAB::newTreeValidator ( MLABTree validatorDefinition)
slot

Create and returns a new tree validator from the given MDL validator definition.

bool MLAB::openFile ( const QString &  abspath,
int  lineno = -1 
)
slot

Opens the file with an external program (in open mode).

bool MLAB::openUrl ( const QString &  abspath)
slot

Opens the given URL with an external program.

void MLAB::processEvents ( )
slot

Processes events (user events are filtered, just redrawing and timers are processed).

void MLAB::processEvents ( bool  allowUserInput)
slot

Processes events,.

If user input is allowed be careful with side effects, since the user can e.g. press a button and execute another script etc.

void MLAB::processInventorQueue ( )
slot

Processes the delay queue of OpenInventor.

This is needed if you want to make sure that all pending OpenInventor notifications are processed.

bool MLAB::qobjectInherits ( QObject *  object,
const QString &  classname 
)
slot

Returns whether the given QObject inherits from the given classname.

QString MLAB::readKey ( const QString &  application,
const QString &  key 
)
slot

Reads an application specific key for its value, e.g., "ILabNeuro", "FileDialogPath".

This method can be used to easily store machine/user dependent settings in the registry. Returns an empty string if the key is not set.

MLABTree* MLAB::readTreeFromFile ( const QString &  filename,
bool  replaceVars 
)
slot

Parses the given MDL file, returns an empty tree on error.

MLABTree* MLAB::readTreeFromString ( const QString &  str,
bool  replaceVars 
)
slot

Parses the given MDL file, returns an empty tree on error.

QString MLAB::readWindowsRegistry ( const QString &  type,
const QString &  key,
const QString &  subkey 
)
slot

Reads the windows key, type may be one of CLASSES_ROOT, LOCAL_MACHINE, CURRENT_USER, USERS.

void MLAB::removeBusyStateIndicator ( )
slot

Removes the global wait cursor.

Referenced by removeWaitCursor().

void MLAB::removeOverrideCursor ( )
slot

Removes the last override cursor.

void MLAB::removeSqlDatabase ( MLABScriptSqlDatabase *  db)
slot

Remove the given database.

void MLAB::removeWaitCursor ( )
inlineslot
QString MLAB::replaceMDLVariables ( const QString &  text,
const QString &  localPath = QString() 
)
slot

Replaces MDL variables in a given string and returns it.

void MLAB::resetUserActivity ( )
slot

Resets the user activity measurement.

bool MLAB::runActionOnFile ( const QString &  action,
const QString &  abspath 
)
slot

Runs the given abstract action on given absolute file path (this does the same as opening files in MeVisLab, e.g., it can "open" .mlab files, .def files, etc.).

The command executed by the given action depends on the settings in your mevislab.prefs file. On Windows, the default behavior is using ShellExecute(), so the command is the same as clicking "open", "edit", "explore", etc. on the file in the Explorer.

Available commands:

  • "open" opens a file
  • "edit" opens a file for editing (e.g., for HTML there is a difference in opening for viewing and for editing)
  • "explore" opens a directory explorer
  • "windowsDefault" does the default action (like double clicking on a file in explorer) WINDOWS ONLY!
MLABApplicationRunner* MLAB::runApplication ( const QString &  name)
slot

Runs a macro module as an application.

MLABApplicationRunner* MLAB::runApplication ( const QString &  name,
const QStringList &  args 
)
slot

Runs the application given by name.

The arguments are given as an array of strings. All arguments are optional. Possible entries are:

  • "name" "WINDOWNAME" - run a named window instead of the default window of the module
  • "style" "STYLENAME" - root style to use, e.g., Application, Panel, or custom style
  • "noshow" - don't show the window of the application
  • "fullscreen" - show the window fullscreen without window bar
  • "maximized" - run in fullscreen mode (not when modal!)
  • "childwindow" - run as child window of MeVisLab (or of the passes application window as parent, see next method)
  • "modal" - run as a modal dialog
  • "popup" - show the application as a popup window
MLABApplicationRunner* MLAB::runApplication ( const QString &  name,
const QStringList &  args,
MLABWidgetControl parent 
)
slot

Like above but with a given parent application window.

bool MLAB::runCommand ( const QString &  command,
const QStringList &  arguments = QStringList(),
const QString &  workingDir = QString() 
)
slot

Run the given executable command with given arguments array and return whether it was successful.

Parameters
commandexecutable, may be absolute path or local in PATH environment
argumentslist of arguments passed to command
workingDirworking directory passed to command
Returns
returns true if successful

TODO: example code This command runs synchronously, so the command was definitely executed when this function returns. If you need more control on the command, use the MLABProcess class instead.

bool MLAB::runCommandDetached ( const QString &  command,
const QStringList &  arguments = QStringList(),
const QString &  workingDirectory = QString(),
bool  makeFrontmost = true 
)
slot

Runs the given executable command with given arguments array in a new process and detach from it.

Returns whether launch has been successful.

Parameters
commandexecutable, may be absolute path or local in PATH environment
argumentslist of arguments passed to command (can be empty list)
workingDirectory,commandwill be started in this directory (uses current directory if none is given)
makeFrontmost,makeapplication front most on Mac OS X if set 'true' (default)
Returns
returns true if successful
bool MLAB::runCommandInConsole ( const QString &  command,
const QStringList &  arguments = QStringList(),
const QString &  workingDir = QString(),
const QString &  standardIn = QString(),
const QString &  title = QString(),
MLABWidgetControl parent = NULL 
)
slot

Runs the given command in a console window.

This method returns immediately, stdout+stderr are going to the console. The window must be closed by the user. If an error occurres the processError(QProcess*,QProcess::ProcessError) signal is emitted.

example:

MLAB.runCommandInConsole("eatDicom", ["-help"], "", "", "Running eatDicom")
QMap<QString, QVariant> MLAB::runCommandStdInOut ( const QString &  command,
const QStringList &  arguments = QStringList(),
const QString &  workingDir = QString(),
const QString &  standardIn = QString() 
)
slot

Runs the given command, passing additional stdin text and returning a map with the result and the stdout.

This command runs synchronously. The result is a map that contains:

  • ok (true if call succeeded)
  • status (exit status if call succeeded)
  • stdout (stdoutput of the started process)
  • stderr (stderror of the started process)
  • error (error code if call failed, doesn't exist otherwise)

Example:

result = MLAB.runCommandStdInOut("cat",[""],"","test data...")
if result["ok"]:
MLAB.log("result: " + str(result["status"]) + " " + result["stdout"] + " " + result["stderr"])
bool MLAB::runMDLValidatorOnTree ( MLABTree tree)
slot

Runs the MDL validator on the given tree and returns whether the tree was valid.

void MLAB::setDontExitAfterConsoleCommand ( bool  dontExitAfterConsoleCommand)
slot

Sets whether MeVisLab will exit (and thus stop the Qt event loop) after the consoleCommand/runApplicationCommand has finished.

bool MLAB::setMDLTagValue ( const QString &  fileName,
const QStringList &  treePath,
const QString &  value 
)
slot

Sets the value of an MDL tag in the given MDL file.

The tree path resembles the tree hierarchy of the tag. The first tag whose hierarchy matches the tree path will be modified. For example, a tree path can look like Window::windowName > Vertical > Field::fieldName > dependsOn.

Parameters
fileNameThe filename.
treePathList of tree names, and optionally values append to the tag name after a '#', that resembles the target tree hierarchy.
valueThe new value for the MDL tag.
Returns
Returns true on success, false otherwise.
void MLAB::setModuleProfilingEnabled ( bool  enabled)
slot

Sets whether module profiling is enabled.

int MLAB::setNumberOfImageProcessingThreads ( int  numThreads)
slot

Sets the number of parallel worker threads that the ML host is allowed to use.

It returns the previous value. This calls ml::Host::setMaxNumThreads() on the C++ layer.

void MLAB::setOverrideCursor ( const QPixmap &  pixmap)
slot

Sets the global override cursor to the given pixmap.

void MLAB::setOverrideCursor ( const QString &  filename)
slot

Sets the global override cursor to the given pixmap file.

void MLAB::setOverrideCursor ( const QString &  filename,
int  hotspotx,
int  hotspoty 
)
slot

Sets the global override cursor to the given pixmap file and sets the hot spot within that pixmap.

void MLAB::setUserActivityThreshold ( int  seconds)
slot

Sets the global user activity threshold in seconds, this also resets the user activity measurement.

void MLAB::setVariable ( const QString &  name,
const QString &  value 
)
slot

Sets the value of a global pref variable (only transient, will be default on next restart).

void MLAB::setWaitCursor ( )
inlineslot

References indicateBusyState().

bool MLAB::shouldStop ( )
slot

Global break checking which can be called from the scripting to allow pressing buttons which have the globalStop tag set to true.

Returns
returns true if a stop button was pressed
QColor MLAB::showColorDialog ( const QColor &  initialColor = Qt::white,
MLABWidgetControl parent = NULL 
)
slot

Returns a QColor from a color dialog.

QColor MLAB::showColorDialog ( const QString &  initialColor,
MLABWidgetControl parent = NULL 
)
slot

Returns a QColor from a color dialog, initialColor is given as a name (e.g., "white") or in hexadecimal notation (e.g., "#44cc88").

void MLAB::showCritical ( const QString &  text,
const QString &  detail,
const QString &  title,
MLABWidgetControl parent = NULL 
)
slot

Shows a critical message box with graphically separated details and OK button.

void MLAB::showCritical ( const QString &  text,
const QString &  title = MEVISLAB_TITLESTRING 
)
slot

Shows a critical message box with OK button.

int MLAB::showCritical ( const QString &  text,
const QString &  detail,
const QString &  title,
const QStringList &  buttonTexts,
int  defaultButtonNumber,
MLABWidgetControl parent = NULL 
)
slot

Shows a critical error panel with given parameters, for details see showQuestion(), defaultButtonNumber gives the default button starting from 0.

int MLAB::showCritical ( const QString &  text,
const QString &  title,
const QStringList &  buttonTexts,
int  defaultButtonNumber 
)
slot

Shows a critical error panel with given parameters, for details see showQuestion(), defaultButtonNumber gives the default button starting from 0.

void MLAB::showInformation ( const QString &  text,
const QString &  detail,
const QString &  title,
MLABWidgetControl parent = NULL 
)
slot

Shows an information message box with graphically separated details and OK button.

void MLAB::showInformation ( const QString &  text,
const QString &  title = MEVISLAB_TITLESTRING 
)
slot

Shows an information message box with OK button.

int MLAB::showInformation ( const QString &  text,
const QString &  detail,
const QString &  title,
const QStringList &  buttonTexts,
int  defaultButtonNumber,
MLABWidgetControl parent = NULL 
)
slot

Shows an information panel with given parameters, for details see showQuestion(), defaultButtonNumber gives the default button starting from 0.

int MLAB::showInformation ( const QString &  text,
const QString &  title,
const QStringList &  buttonTexts,
int  defaultButtonNumber 
)
slot

Shows an information panel with given parameters, for details see showQuestion(), defaultButtonNumber gives the default button starting from 0.

void MLAB::showMultiLineText ( const QString &  text,
const QString &  title,
bool  richtext,
MLABWidgetControl parent = NULL 
)
slot

Shows a window with multi line text.

int MLAB::showQuestion ( const QString &  text,
const QString &  detail,
const QString &  title,
const QStringList &  buttonTexts,
int  defaultButtonNumber,
MLABWidgetControl parent = NULL 
)
slot

Shows a question panel with given parameters.

Returns
number of pressed button, starting with 0
Parameters
texttext to show
detaildetailed information to show (e.g. a file or directory name)
titlewindow title to show
buttonTextslist of button texts to show on the buttons, e.g., ["Ok", "Cancel"] or ["Retry", "Abort", "Ignore"]. Please use the following standard button texts if at all possible (ensures display of buttons in right order on any platform / ESC detection): Ok, Open, Save, Cancel, Close, Discard, Apply, Reset, Restore Defaults, Help, Save All, Yes, Yes To All, No, No To All, Abort, Retry, Ignore
defaultButtonNumberbutton that is used when user presses return, starting from 0 for the first button
parentparent window, e.g. ctx.window(), the dialog becomes becomes modal relative to parent or application modal if NULL Script example:
i = MLAB.showQuestion("How about some coffee?", "I've got a new espresso machine", "MeVisLab", ["Yes", "No", "Cancel"], 0)
if i == 0:
pass # handle "Yes"
elif i == 1:
pass # handle "No"
elif i == 2:
pass # handle "Cancel" / Pressing of ESC
int MLAB::showQuestion ( const QString &  text,
const QString &  title,
const QStringList &  buttonTexts,
int  defaultButtonNumber 
)
slot

Shows a question panel with given parameters, defaultButtonNumber gives the default button starting from 0.

void MLAB::showWarning ( const QString &  text,
const QString &  detail,
const QString &  title,
MLABWidgetControl parent = NULL 
)
slot

Shows a warning message box with graphically separated details and OK button.

void MLAB::showWarning ( const QString &  text,
const QString &  title = MEVISLAB_TITLESTRING 
)
slot

Shows a warning message box with OK button.

int MLAB::showWarning ( const QString &  text,
const QString &  detail,
const QString &  title,
const QStringList &  buttonTexts,
int  defaultButtonNumber,
MLABWidgetControl parent = NULL 
)
slot

Shows a warning message panel with given parameters, for details see showQuestion(), defaultButtonNumber gives the default button starting from 0.

int MLAB::showWarning ( const QString &  text,
const QString &  title,
const QStringList &  buttonTexts,
int  defaultButtonNumber 
)
slot

Shows a warning message panel with given parameters, for details see showQuestion(), defaultButtonNumber gives the default button starting from 0.

bool MLAB::signFiles ( const QStringList &  files,
const QString &  filter,
bool  crypt 
)
slot

Signs the files (absolute filenames) with the license that MeVisLab was started with.

bool MLAB::signFiles ( const QStringList &  files,
const QString &  filter,
bool  crypt,
const QString &  license 
)
slot

Signs the files (absolute filenames) with the license file given as license.

bool MLAB::signFilesRecursive ( const QString &  path,
const QString &  filter,
bool  crypt 
)
slot

Signs the files with the license that MeVisLab was started with.

bool MLAB::signFilesRecursive ( const QString &  path,
const QString &  filter,
bool  crypt,
const QString &  license 
)
slot

Signs the files with the license file given as license.

void MLAB::sleep ( int  secs)
slot

Causes MLAB to sleep secs seconds.

QString MLAB::standaloneApplicationName ( )
slot

Returns the name of the Macro module that is running as a MeVisLabApp standalone application (or empty string if MeVisLab itself is running).

bool MLAB::startObjectDrag ( QObject *  object,
const QPixmap &  icon = QPixmap(),
int  hotSpotX = -1,
int  hotSpotY = -1 
)
slot

Start dragging a QObject.

QString MLAB::stringToEncodedUrlString ( const QString &  string)
slot

Converts a string URL to an encoded URL string (using xx encoding).

QString MLAB::systemId ( )
slot

Returns the current system identification MLAB is running on/.

Returns the following string depending on the system mlab is running on:

  • windows
  • macos
  • linux
  • unknown (on any other system)

If you want to get specific system information, use systemIdDetail().

QString MLAB::systemInfo ( )
slot

Returns a detailed info string about the system, should not be used for checking purposes, use systemId() or detailedSystemId() instead.

void MLAB::terminate ( )
slot

Terminates the whole MeVisLab application, note that scripting goes on after this call and MLAB closes in the next event processing.

QString MLAB::translate ( const QByteArray &  context,
const QString &  sourceText,
const QString &  disambiguation = QString() 
) const
slot

Translate a string with Qt's translation infrastructure.

void MLAB::unsetVariable ( const QString &  name)
slot

Unsets a global pref variable (only transient, will be default on next restart).

void MLAB::usleep ( int  usecs)
slot

Causes MLAB to sleep usecs micro seconds.

bool MLAB::valueIsTrue ( const QString &  val)
slot

Returns whether the string value is true in the MeVisLab sense (Yes|1|On|True).

QString MLAB::variable ( const QString &  name)
slot

Returns the value of a global pref variable (read from MeVisLab prefs and registry).

bool MLAB::variableIsTrue ( const QString &  name)
slot

Returns whether variable has YES/TRUE/1 as value.

void MLAB::writeKey ( const QString &  application,
const QString &  key,
const QString &  value 
)
slot

Write a permanent key/value pair for the given application.

This method can be used to easily retrieve machine/user settings information from the registry. If you want to immediately save you settings, you have to call writeRegistry() after your writeKey() calls.

void MLAB::writeRegistry ( )
slot

To make sure that settings set via setRegistryKey() are stored immediately, call this method.

bool MLAB::writeTreeToFile ( MLABTree tree,
const QString &  filename 
)
slot

Writes the given tree to a file.

QString MLAB::writeTreeToString ( MLABTree tree)
slot

Writes the given tree to a file.

Property Documentation

MLABMLScriptWrapper MLAB::ML
read

Provides access to ML global type functions.