Slicer  5.1
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
List of all members | Public Types | Public Slots | Signals | Public Member Functions | Static Public Member Functions | Protected Slots | Protected Member Functions
qSlicerApplication Class Reference

#include <Base/QTGUI/qSlicerApplication.h>

Inheritance diagram for qSlicerApplication:
Inheritance graph
[legend]
Collaboration diagram for qSlicerApplication:
Collaboration graph
[legend]

Public Types

typedef qSlicerCoreApplication Superclass
 
- Public Types inherited from qSlicerCoreApplication
enum  ApplicationAttribute { AA_DisablePython = 1000, AA_EnableTesting }
 
enum  ReturnCode { ExitNotRequested = -1, ExitSuccess = EXIT_SUCCESS, ExitFailure = EXIT_FAILURE }
 
typedef QApplication Superclass
 

Public Slots

void confirmRestart (QString reason=QString())
 
QString currentLogFile () const
 
bool launchDesigner (const QStringList &args=QStringList())
 
bool loadFiles (const QStringList &filePaths, vtkMRMLMessageCollection *userMessages=nullptr) override
 Override the qSlicerCoreApplication implementation to also show error messages in a popup window. More...
 
int numberOfRecentLogFilesToKeep ()
 Number of recent log files to keep. Older log files are deleted automatically. More...
 
void openNodeModule (vtkMRMLNode *node, QString role=QString(), QString context=QString())
 
void pauseRender () override
 
QStringList recentLogFiles ()
 Paths of recent log files. More...
 
void resumeRender () override
 
void setHasBorderInFullScreen (bool)
 
void setRenderPaused (bool pause) override
 
- Public Slots inherited from qSlicerCoreApplication
static void restart ()
 
virtual void setRenderPaused (bool pause)
 
bool unregisterResource (int handle)
 

Signals

void renderPaused (bool)
 
void startupCompleted ()
 
- Signals inherited from qSlicerCoreApplication
void invokeEventRequested (unsigned int delay, void *caller, unsigned long event, void *callData)
 
void mrmlSceneChanged (vtkMRMLScene *mrmlScene)
 
void urlReceived (QString url)
 

Public Member Functions

Q_INVOKABLE qSlicerCommandOptionscommandOptions () const
 Get commandOptions. More...
 
Q_INVOKABLE qSlicerIOManagerioManager ()
 Get IO Manager. More...
 
Q_INVOKABLE qSlicerLayoutManagerlayoutManager () const
 Set/Get layout manager. More...
 
virtual Q_INVOKABLE void logApplicationInformation () const
 
QMainWindow * mainWindow () const
 Return a pointer on the main window of the application if any. More...
 
QString nodeModule (vtkMRMLNode *node, double *confidence=nullptr) const
 
bool notify (QObject *receiver, QEvent *event) override
 
Q_INVOKABLE void openSettingsDialog (const QString &settingsPanel=QString())
 
 qSlicerApplication (int &argc, char **argv)
 
Q_INVOKABLE void setLayoutManager (qSlicerLayoutManager *layoutManager)
 
Q_INVOKABLE ctkSettingsDialog * settingsDialog () const
 
void setToolTipsEnabled (bool enable)
 Enable/Disable tooltips. More...
 
 ~qSlicerApplication () override
 
- Public Member Functions inherited from qSlicerCoreApplication
virtual QString acknowledgment () const
 Return the acknowledgment text of Slicer. More...
 
Q_INVOKABLE void addModuleAssociatedNodeType (const QString &nodeClassName, const QString &moduleName)
 
Q_INVOKABLE QStringList allModuleAssociatedNodeTypes () const
 List of all node types that are associated with any module. More...
 
Q_INVOKABLE void appendEnvironmentVariable (const QString &key, const QString &value, QChar separator=';')
 
Q_INVOKABLE vtkSlicerApplicationLogicapplicationLogic () const
 Get application logic. More...
 
QString arch () const
 
QString cachePath () const
 
virtual QString copyrights () const
 Return the copyrights of Slicer. More...
 
qSlicerCoreCommandOptionscoreCommandOptions () const
 Get coreCommandOptions. More...
 
Q_INVOKABLE qSlicerCoreIOManagercoreIOManager () const
 Get the IO manager. More...
 
QString defaultCachePath () const
 
QString defaultExtensionsInstallPath () const
 Get slicer default extensions path. More...
 
QString defaultScenePath () const
 
Q_INVOKABLE QSettings * defaultSettings () const
 
QString defaultTemporaryPath () const
 Get slicer default temporary directory. More...
 
QString documentationBaseUrl () const
 
QString documentationLanguage () const
 
QString documentationVersion () const
 
Q_INVOKABLE QProcessEnvironment environment () const
 Returns the current environment. More...
 
Q_INVOKABLE ctkErrorLogAbstractModel * errorLogModel () const
 Get errorLogModel. More...
 
QString extensionsInstallPath () const
 Get slicer extension directory. More...
 
QString intDir () const
 
bool isCustomMainApplication () const
 Return if main application is custom application (not Slicer). More...
 
bool isEmbeddedModule (const QString &moduleFileName) const
 
Q_INVOKABLE bool isEnvironmentVariableValueSet (const QString &key, const QString &value)
 Returns True if environment variable identified by key is set to value. More...
 
bool isInstalled () const
 Return true is this instance of Slicer is running from an installed directory. More...
 
QString launcherExecutableFilePath () const
 If any, return slicer launcher executable file path. More...
 
QString launcherRevisionSpecificUserSettingsFilePath () const
 If any, return slicer user settings file path specific to a given revision of Slicer. More...
 
QString launcherSettingsFilePath () const
 If any, return slicer launcher settings file path. More...
 
virtual QString libraries () const
 Return the libraries of Slicer. More...
 
virtual bool loadFiles (const QStringList &filePaths, vtkMRMLMessageCollection *userMessages=nullptr)
 
int mainApplicationMajorVersion () const
 
int mainApplicationMinorVersion () const
 
QString mainApplicationName () const
 Return the name of the main application. More...
 
int mainApplicationPatchVersion () const
 
QString mainApplicationRepositoryRevision () const
 
QString mainApplicationRepositoryUrl () const
 
QString mainApplicationRevision () const
 
int majorVersion () const
 Return the Slicer major version number. More...
 
int minorVersion () const
 Return the Slicer minor version number. More...
 
Q_INVOKABLE QString moduleDocumentationUrl (const QString &moduleName) const
 
Q_INVOKABLE vtkMRMLAbstractLogicmoduleLogic (const QString &moduleName) const
 
Q_INVOKABLE qSlicerModuleManagermoduleManager () const
 Get the module manager. More...
 
Q_INVOKABLE QStringList modulesAssociatedWithNodeType (const QString &nodeClassName) const
 List of all modules that are associated with the specified node type. More...
 
Q_INVOKABLE vtkMRMLScenemrmlScene () const
 Get MRML Scene. More...
 
virtual void openUrl (const QString &url)
 
QString os () const
 
void parseArguments (bool &exitWhenDone)
 
virtual void pauseRender ()
 
QString platform () const
 
Q_INVOKABLE void prependEnvironmentVariable (const QString &key, const QString &value, QChar separator=';')
 
 qSlicerCoreApplication (int &argc, char **argv)
 
Q_INVOKABLE int registerResource (const QByteArray &data)
 
QString releaseType () const
 Return the release type of this instance of Slicer. More...
 
Q_INVOKABLE void removeModuleAssociatedNodeType (const QString &nodeClassName, const QString &moduleName)
 Remove association between a module and a node type. More...
 
QString repositoryBranch () const
 
QString repositoryRevision () const
 
QString repositoryUrl () const
 
virtual void resumeRender ()
 
int returnCode () const
 
QString revision () const
 Return Slicer's user-friendly revision identifier. More...
 
Q_INVOKABLE QSettings * revisionUserSettings () const
 
void setCachePath (const QString &path)
 
void setCoreCommandOptions (qSlicerCoreCommandOptions *options)
 
void setCoreIOManager (qSlicerCoreIOManager *ioManager)
 
void setDefaultScenePath (const QString &path)
 Set default slicer scene directory. More...
 
Q_INVOKABLE void setEnvironmentVariable (const QString &key, const QString &value)
 Convenient function to set an environment variable. More...
 
void setExtensionsInstallPath (const QString &path)
 Set slicer extension directory. More...
 
void setTemporaryPath (const QString &path)
 Set slicer temporary directory. More...
 
Q_INVOKABLE QSettings * settings () const
 
Q_INVOKABLE void showConsoleMessage (QString message, bool error=true) const
 
QString slicerDefaultSettingsFilePath () const
 
QString slicerHome () const
 
QString slicerRevisionUserSettingsFilePath () const
 
QString slicerSharePath () const
 
QString slicerUserSettingsFilePath () const
 
Q_INVOKABLE QProcessEnvironment startupEnvironment () const
 Returns the environment without the Slicer specific values. More...
 
QString startupWorkingPath () const
 Current working directory at the time the application was started. More...
 
QString temporaryPath () const
 Get slicer temporary directory. More...
 
Q_INVOKABLE QString toSlicerHomeAbsolutePath (const QString &path) const
 
Q_INVOKABLE QStringList toSlicerHomeAbsolutePaths (const QStringList &path) const
 
Q_INVOKABLE QString toSlicerHomeRelativePath (const QString &path) const
 
Q_INVOKABLE QStringList toSlicerHomeRelativePaths (const QStringList &path) const
 
Q_INVOKABLE QSettings * userSettings () const
 
 ~qSlicerCoreApplication () override
 

Static Public Member Functions

static qSlicerApplicationapplication ()
 Return a reference to the application singleton. More...
 
static Q_INVOKABLE bool isCodePageUtf8 ()
 
- Static Public Member Functions inherited from qSlicerCoreApplication
static qSlicerCoreApplicationapplication ()
 
static int exec ()
 
static Q_INVOKABLE bool loadCaCertificates (const QString &slicerHome)
 
static Q_INVOKABLE void loadLanguage ()
 
static Q_INVOKABLE void loadTranslations (const QString &dir)
 
static void setAttribute (qSlicerCoreApplication::ApplicationAttribute attribute, bool on=true)
 
static bool testAttribute (qSlicerCoreApplication::ApplicationAttribute attribute)
 
static Q_INVOKABLE QStringList translationFolders ()
 Return list of folders where the application looks for translations (*.qm files) More...
 

Protected Slots

void editNode (vtkObject *, void *, unsigned long) override
 Request editing of a MRML node. More...
 
- Protected Slots inherited from qSlicerCoreApplication
virtual void editNode (vtkObject *, void *, unsigned long)
 
void onSlicerApplicationLogicRequest (vtkObject *, void *, unsigned long)
 
virtual void onUserInformationModified ()
 
void processAppLogicModified ()
 
void processAppLogicReadData ()
 
void processAppLogicWriteData ()
 

Protected Member Functions

void handleCommandLineArguments () override
 
void handlePreApplicationCommandLineArguments () override
 Reimplemented from qSlicerCoreApplication. More...
 
void onSlicerApplicationLogicModified () override
 
void setupFileLogging ()
 
- Protected Member Functions inherited from qSlicerCoreApplication
void invokeEvent ()
 
virtual void onAboutToQuit ()
 Perform application cleanup following a call to QCoreApplication::exit(). More...
 
 qSlicerCoreApplication (qSlicerCoreApplicationPrivate *pimpl, int &argc, char **argv)
 
void requestInvokeEvent (vtkObject *caller, void *callData)
 
void scheduleInvokeEvent (unsigned int delay, void *caller, unsigned long event, void *callData)
 
virtual void setMRMLScene (vtkMRMLScene *scene)
 
void terminate (int exitCode=qSlicerCoreApplication::ExitSuccess)
 Set the ReturnCode flag and call QCoreApplication::exit() More...
 

Additional Inherited Members

- Properties inherited from qSlicerCoreApplication
QString arch
 
QString cachePath
 
QString defaultScenePath
 
QString documentationBaseUrl
 
QString documentationLanguage
 
QString documentationVersion
 
QString extensionsInstallPath
 
QString intDir
 
bool isCustomMainApplication
 
bool isInstalled
 
QString launcherExecutableFilePath
 
QString launcherSettingsFilePath
 
int mainApplicationMajorVersion
 
int mainApplicationMinorVersion
 
QString mainApplicationName
 
int mainApplicationPatchVersion
 
QString mainApplicationRepositoryRevision
 
QString mainApplicationRepositoryUrl
 
QString mainApplicationRevision
 
int majorVersion
 
int minorVersion
 
QString os
 
QString platform
 
QString releaseType
 
QString repositoryBranch
 
QString repositoryRevision
 
QString repositoryUrl
 
QString revision
 
QString slicerDefaultSettingsFilePath
 
QString slicerHome
 
QString slicerRevisionUserSettingsFilePath
 
QString slicerSharePath
 
QString slicerUserSettingsFilePath
 
QString startupWorkingPath
 
QString temporaryPath
 
- Protected Attributes inherited from qSlicerCoreApplication
QScopedPointer< qSlicerCoreApplicationPrivate > d_ptr
 

Detailed Description

Definition at line 59 of file qSlicerApplication.h.

Member Typedef Documentation

◆ Superclass

Definition at line 64 of file qSlicerApplication.h.

Constructor & Destructor Documentation

◆ qSlicerApplication()

qSlicerApplication::qSlicerApplication ( int &  argc,
char **  argv 
)

◆ ~qSlicerApplication()

qSlicerApplication::~qSlicerApplication ( )
override

Member Function Documentation

◆ application()

static qSlicerApplication* qSlicerApplication::application ( )
static

Return a reference to the application singleton.

◆ commandOptions()

Q_INVOKABLE qSlicerCommandOptions* qSlicerApplication::commandOptions ( ) const

Get commandOptions.

◆ confirmRestart

void qSlicerApplication::confirmRestart ( QString  reason = QString())
slot

Popup a dialog asking the user if the application should be restarted. If no reason is given, the text will default to ""Are you sure you want to restart?"

◆ currentLogFile

QString qSlicerApplication::currentLogFile ( ) const
slot

Path of the current log file

See also
recentLogFiles(), setupFileLogging()

◆ editNode

void qSlicerApplication::editNode ( vtkObject *  ,
void *  ,
unsigned  long 
)
overrideprotectedslot

Request editing of a MRML node.

◆ handleCommandLineArguments()

void qSlicerApplication::handleCommandLineArguments ( )
overrideprotectedvirtual

Process command line arguments atfer the application event loop is started.

See also
handlePreApplicationCommandLineArguments()
qSlicerApplication::startupCompleted()

Reimplemented from qSlicerCoreApplication.

◆ handlePreApplicationCommandLineArguments()

void qSlicerApplication::handlePreApplicationCommandLineArguments ( )
overrideprotectedvirtual

Reimplemented from qSlicerCoreApplication.

Reimplemented from qSlicerCoreApplication.

◆ ioManager()

Q_INVOKABLE qSlicerIOManager* qSlicerApplication::ioManager ( )

Get IO Manager.

◆ isCodePageUtf8()

static Q_INVOKABLE bool qSlicerApplication::isCodePageUtf8 ( )
static

Return true if process code page is UTF-8. It is true for all MacOS and Linux versions and for Windows version 1903 (May 2019 Update) or later.

◆ launchDesigner

bool qSlicerApplication::launchDesigner ( const QStringList &  args = QStringList())
slot

Launch Qt Designer application (bundled with the application). If uiFile argument is specified then designer loads that UI file on startup.

◆ layoutManager()

Q_INVOKABLE qSlicerLayoutManager* qSlicerApplication::layoutManager ( ) const

Set/Get layout manager.

◆ loadFiles

bool qSlicerApplication::loadFiles ( const QStringList &  filePaths,
vtkMRMLMessageCollection userMessages = nullptr 
)
overrideslot

Override the qSlicerCoreApplication implementation to also show error messages in a popup window.

◆ logApplicationInformation()

virtual Q_INVOKABLE void qSlicerApplication::logApplicationInformation ( ) const
virtual

Log application information.

This function will log the following details:

  • Session start time
  • Slicer version
  • Operating system
  • Memory
  • CPU
  • Developer mode enabled
  • Additional module paths
Note
Starting the application with --application-information will also print the information to standard output.
See also
qSlicerCoreCommandOptions::displayApplicationInformation()

◆ mainWindow()

QMainWindow* qSlicerApplication::mainWindow ( ) const

Return a pointer on the main window of the application if any.

◆ nodeModule()

QString qSlicerApplication::nodeModule ( vtkMRMLNode node,
double *  confidence = nullptr 
) const

Return the module name that is most suitable for editing the specified node. If a valid pointer is provided for confidence then the confidence value for the found module is returned. Confidence value = 0 means that the found module can probably not do much with that node, while 1.0 means that the found module is certainly the best module to manage than node.

◆ notify()

bool qSlicerApplication::notify ( QObject *  receiver,
QEvent *  event 
)
override

Avoid some crashes due to exceptions thrown during inside event handlers (such as slots). When exceptions are thrown from slots, Qt generates this message:

Qt has caught an exception thrown from an event handler. Throwing exceptions from an event handler is not supported in Qt. You must reimplement QApplication::notify() and catch all exceptions there.

so we follow the pattern suggested here:

https://stackoverflow.com/questions/13878373/where-am-i-supposed-to-reimplement-qapplicationnotify-function

◆ numberOfRecentLogFilesToKeep

int qSlicerApplication::numberOfRecentLogFilesToKeep ( )
slot

Number of recent log files to keep. Older log files are deleted automatically.

◆ onSlicerApplicationLogicModified()

void qSlicerApplication::onSlicerApplicationLogicModified ( )
overrideprotectedvirtual

Reimplemented from qSlicerCoreApplication.

◆ openNodeModule

void qSlicerApplication::openNodeModule ( vtkMRMLNode node,
QString  role = QString(),
QString  context = QString() 
)
slot

Utility function that retrieve the best module for a node and trigger its associated QAction which eventually opens the module.

Note
qSlicerApplication is a temporary host for the function as it should be moved into a DataManager where module can register new node types/modules

◆ openSettingsDialog()

Q_INVOKABLE void qSlicerApplication::openSettingsDialog ( const QString &  settingsPanel = QString())

◆ pauseRender

void qSlicerApplication::pauseRender ( )
overrideslot

Equivalent to setRenderPaused(true)

See also
setRenderPaused

◆ recentLogFiles

QStringList qSlicerApplication::recentLogFiles ( )
slot

Paths of recent log files.

◆ renderPaused

void qSlicerApplication::renderPaused ( bool  )
signal

Emitted when setRenderPaused() is called. This can be used by modules that manage their own viewers to pause and resume rendering.

See also
setRenderPaused

◆ resumeRender

void qSlicerApplication::resumeRender ( )
overrideslot

Equivalent to setRenderPaused(false)

See also
setRenderPaused

◆ setHasBorderInFullScreen

void qSlicerApplication::setHasBorderInFullScreen ( bool  )
slot

When turning on OpenGL and using the full screen mode, menus and tooltips are no longer visible. By enabling hasBorderInFullScreen, a one-pixel border is added around the window, which fixes the problem. Border has to be enabled before going to full screen mode. This method has only effect when using Qt5 on Windows. See http://doc.qt.io/qt-5/windows-issues.html#fullscreen-opengl-based-windows

◆ setLayoutManager()

Q_INVOKABLE void qSlicerApplication::setLayoutManager ( qSlicerLayoutManager layoutManager)

◆ setRenderPaused

void qSlicerApplication::setRenderPaused ( bool  pause)
overrideslot

Calls setRenderPaused(pause) on the current layout manager. Emits pauseRenderRequested() if pause is true and resumeRenderRequested() if pause is false. The caller is responsible for making sure that each setRenderPaused(true) is paired with setRenderPaused(false).

See also
qMRMLLayoutManager::setRenderPaused()

◆ settingsDialog()

Q_INVOKABLE ctkSettingsDialog* qSlicerApplication::settingsDialog ( ) const

◆ setToolTipsEnabled()

void qSlicerApplication::setToolTipsEnabled ( bool  enable)

◆ setupFileLogging()

void qSlicerApplication::setupFileLogging ( )
protected

Set up file logging. Creates and sets new log file and deletes the oldest one from the stored queue

◆ startupCompleted

void qSlicerApplication::startupCompleted ( )
signal

Emitted when the startup phase has been completed.

Startup is complete when all the modules have been initialized and the main window is shown to the user.

Note
If the application is started without the mainwindow, the signal is emitted after the modules are initialized.
See also
qSlicerAppMainWindow::initialWindowShown()

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