Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
mitkBaseApplication.h
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 #ifndef mitkBaseApplication_h
14 #define mitkBaseApplication_h
15 
16 #include <MitkAppUtilExports.h>
17 
18 #include <Poco/Util/Application.h>
19 
20 #include <QString>
21 #include <QVariant>
22 
23 class ctkPluginContext;
24 class ctkPluginFramework;
25 
26 class QCoreApplication;
27 class QTranslator;
28 
29 namespace mitk
30 {
75  class MITKAPPUTIL_EXPORT BaseApplication : public Poco::Util::Application
76  {
77  public:
83  //\{
84  static const QString ARG_APPLICATION;
85  static const QString ARG_CLEAN;
86  static const QString ARG_CONSOLELOG;
87  static const QString ARG_DEBUG;
88  static const QString ARG_FORCE_PLUGIN_INSTALL;
89  static const QString ARG_HOME;
90  static const QString ARG_NEWINSTANCE;
91  static const QString ARG_NO_LAZY_REGISTRY_CACHE_LOADING;
92  static const QString ARG_NO_REGISTRY_CACHE;
93  static const QString ARG_PLUGIN_CACHE;
94  static const QString ARG_PLUGIN_DIRS;
95  static const QString ARG_PRELOAD_LIBRARY;
96  static const QString ARG_PRODUCT;
97  static const QString ARG_PROVISIONING;
98  static const QString ARG_REGISTRY_MULTI_LANGUAGE;
99  static const QString ARG_SPLASH_IMAGE;
100  static const QString ARG_STORAGE_DIR;
101  static const QString ARG_XARGS;
102  static const QString ARG_LOG_QT_MESSAGES;
103  static const QString ARG_SEGMENTATION_LABELSET_PRESET;
104  static const QString ARG_FULL_SCREEN_MODE;
105  static const QString ARG_PREFERENCES_OVERRIDE;
106  static const QString ARG_PREFERENCES_PATCH;
107  //\}
108 
112  //\{
113  static const QString PROP_APPLICATION;
114  static const QString PROP_FORCE_PLUGIN_INSTALL;
115  static const QString PROP_NEWINSTANCE;
116  static const QString PROP_NO_LAZY_REGISTRY_CACHE_LOADING;
117  static const QString PROP_NO_REGISTRY_CACHE;
118  static const QString PROP_PRODUCT;
119  static const QString PROP_REGISTRY_MULTI_LANGUAGE;
120  //\}
121 
127  BaseApplication(int argc, char **argv);
128 
132  ~BaseApplication() override;
133 
140  void initializeQt();
141 
154  int run() override;
155 
164  void printHelp(const std::string &name, const std::string &value);
165 
175  void setApplicationName(const QString &name);
176 
182  QString getApplicationName() const;
183 
192  void setOrganizationName(const QString &name);
193 
198  QString getOrganizationName() const;
199 
208  void setOrganizationDomain(const QString &name);
209 
214  QString getOrganizationDomain() const;
215 
228  void setSingleMode(bool singleMode);
229 
234  bool getSingleMode() const;
235 
246  void setSafeMode(bool safeMode);
247 
252  bool getSafeMode() const;
253 
264  void setFullScreenMode(bool fullScreenMode);
265 
270  bool getFullScreenMode() const;
271 
283  void setPreloadLibraries(const QStringList &libraryBaseNames);
284 
290  QStringList getPreloadLibraries() const;
291 
304  void setProvisioningFilePath(const QString &filePath);
305 
310  QString getProvisioningFilePath() const;
311 
322  void setProperty(const QString &property, const QVariant &value);
323 
329  QVariant getProperty(const QString &property) const;
330 
340  void installTranslator(QTranslator* translator);
341 
351  bool isRunning();
352 
363  void sendMessage(const QByteArray msg);
364 
365  protected:
376  void initialize(Poco::Util::Application &self) override;
377 
384  void uninitialize() override;
385 
390  int getArgc() const;
391 
396  char **getArgv() const;
397 
405  virtual QString getCTKFrameworkStorageDir() const;
406 
419 
430  virtual QCoreApplication *getQApplication() const;
431 
438  virtual void initializeLibraryPaths();
439 
452  int main(const std::vector<std::string> &args) override;
453 
465  void defineOptions(Poco::Util::OptionSet &options) override;
466 
473 
479  ctkPluginContext *getFrameworkContext() const;
480 
491  QHash<QString, QVariant> getFrameworkProperties() const;
492 
503  void initializeSplashScreen(QCoreApplication * application) const;
504 
505 private:
506  struct Impl;
507  Impl* d;
508  };
509 }
510 
511 #endif
#define MITKAPPUTIL_EXPORT
bool getSafeMode() const
Query whether safe mode is currently enabled.
static const QString ARG_SPLASH_IMAGE
Argument key for the splash screen image file path ("BlueBerry.splashscreen").
virtual void initializeCppMicroServices()
void setProperty(const QString &property, const QVariant &value)
Set a CTK plugin framework property.
static const QString ARG_NEWINSTANCE
Argument key to force a new instance in single mode ("BlueBerry.newInstance").
bool getFullScreenMode() const
Query whether full screen mode is enabled.
static const QString PROP_PRODUCT
Framework property key for the product id ("blueberry.product").
static const QString ARG_LOG_QT_MESSAGES
Argument key to enable logging of all Qt messages ("Qt.logMessages").
static const QString PROP_NEWINSTANCE
Framework property key for forcing a new instance.
int run() override
Launch the BlueBerry framework and run the default application.
ctkPluginContext * getFrameworkContext() const
Get the CTK plugin context of the framework.
static const QString ARG_SEGMENTATION_LABELSET_PRESET
Argument key for a label set preset file for new segmentations ("Segmentation.labelSetPreset").
void installTranslator(QTranslator *translator)
Install a QTranslator on the underlying QCoreApplication.
QString getOrganizationName() const
Get the organization name.
virtual QCoreApplication * getQApplication() const
void defineOptions(Poco::Util::OptionSet &options) override
Define the recognized command line options.
static const QString ARG_NO_REGISTRY_CACHE
Argument key to disable the registry cache ("BlueBerry.noRegistryCache").
static const QString ARG_FULL_SCREEN_MODE
Argument key to start the application in full screen mode ("MITK.fullscreen").
void sendMessage(const QByteArray msg)
Send a message to the already running application instance.
static const QString ARG_PREFERENCES_PATCH
Argument key for permanently patching preferences before session start ("MITK.preferences-patch").
QString getProvisioningFilePath() const
static const QString PROP_APPLICATION
Framework property key for the application extension id ("blueberry.application").
static const QString ARG_NO_LAZY_REGISTRY_CACHE_LOADING
Argument key to disable lazy registry cache loading ("BlueBerry.noLazyRegistryCacheLoading").
~BaseApplication() override
Destructor. Releases internal resources.
static const QString ARG_DEBUG
Argument key to enable debug mode ("BlueBerry.debug").
static const QString ARG_PLUGIN_DIRS
Argument key for additional plugin directories ("BlueBerry.plugin_dirs").
int getArgc() const
Get the argument count.
void setProvisioningFilePath(const QString &filePath)
static const QString ARG_REGISTRY_MULTI_LANGUAGE
Argument key to enable multi-language registry support ("BlueBerry.registryMultiLanguage").
void initializeSplashScreen(QCoreApplication *application) const
Initialize and display the splash screen if configured.
static const QString PROP_NO_REGISTRY_CACHE
Framework property key for disabling the registry cache.
void setOrganizationDomain(const QString &name)
Set the organization domain.
void setFullScreenMode(bool fullScreenMode)
Enable or disable full screen mode.
static const QString ARG_PRELOAD_LIBRARY
Argument key for libraries to preload at startup ("BlueBerry.preloadLibrary").
QVariant getProperty(const QString &property) const
Get a CTK plugin framework property.
void setSafeMode(bool safeMode)
Enable or disable safe mode for exception-catching in the Qt event loop.
QSharedPointer< ctkPluginFramework > getFramework() const
Get the CTK plugin framework instance.
void uninitialize() override
Uninitialize the application.
QHash< QString, QVariant > getFrameworkProperties() const
BaseApplication(int argc, char **argv)
Construct a BaseApplication.
void setSingleMode(bool singleMode)
Enable or disable single-instance mode.
static const QString ARG_FORCE_PLUGIN_INSTALL
Argument key to force installing plug-ins with the same symbolic name ("BlueBerry....
char ** getArgv() const
Get the argument vector.
static const QString ARG_APPLICATION
Argument key for specifying the application extension id ("BlueBerry.application").
static const QString PROP_REGISTRY_MULTI_LANGUAGE
Framework property key for multi-language registry support.
static const QString ARG_CONSOLELOG
Argument key to enable console logging ("BlueBerry.consoleLog").
bool isRunning()
Check whether another instance of this application is already running.
QStringList getPreloadLibraries() const
void setApplicationName(const QString &name)
Set the application name.
static const QString ARG_CLEAN
Argument key to clean the plugin cache on first init ("BlueBerry.clean").
static const QString ARG_PLUGIN_CACHE
Argument key for the plugin cache directory ("BlueBerry.plugin_cache_dir").
int main(const std::vector< std::string > &args) override
Run the BlueBerry application via the CTK plugin framework.
virtual QString getCTKFrameworkStorageDir() const
bool getSingleMode() const
Query whether single-instance mode is enabled.
static const QString ARG_PROVISIONING
Argument key for the provisioning file path ("BlueBerry.provisioning").
void initialize(Poco::Util::Application &self) override
Initialize the application.
static const QString ARG_HOME
Argument key for the BlueBerry home directory ("BlueBerry.home").
virtual void initializeLibraryPaths()
QString getApplicationName() const
Get the application name.
static const QString ARG_XARGS
Argument key for extended arguments ("xargs").
static const QString PROP_FORCE_PLUGIN_INSTALL
Framework property key for forcing plugin installation.
static const QString ARG_PRODUCT
Argument key for the product id to launch ("BlueBerry.product").
static const QString ARG_PREFERENCES_OVERRIDE
Argument key for temporarily overriding preferences for this session ("MITK.preferences-override").
static const QString ARG_STORAGE_DIR
Argument key for the persistent storage directory ("BlueBerry.storageDir").
static const QString PROP_NO_LAZY_REGISTRY_CACHE_LOADING
Framework property key for disabling lazy registry cache loading.
void setPreloadLibraries(const QStringList &libraryBaseNames)
void printHelp(const std::string &name, const std::string &value)
Print the command line help text and exit the application.
void setOrganizationName(const QString &name)
Set the organization name.
QString getOrganizationDomain() const
Get the organization domain.
Find image slices visible on a given plane.