diff --git a/Applications/PluginGenerator/ctkCommandLineParser.h b/Applications/PluginGenerator/ctkCommandLineParser.h index 2c9afeccce..daee3816fe 100644 --- a/Applications/PluginGenerator/ctkCommandLineParser.h +++ b/Applications/PluginGenerator/ctkCommandLineParser.h @@ -1,418 +1,418 @@ /*========================================================================= Library: CTK Copyright (c) Kitware Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.txt Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. =========================================================================*/ #ifndef __ctkCommandLineParser_h #define __ctkCommandLineParser_h // Qt includes #include #include #include class QSettings; /** * \ingroup Core * * The CTK command line parser. * * Use this class to add information about the command line arguments * your program understands and to easily parse them from a given list * of strings. * * This parser provides the following features: * *
    *
  • Add arguments by supplying a long name and/or a short name. * Arguments are validated using a regular expression. They can have * a default value and a help string.
  • *
  • Deprecated arguments.
  • *
  • Custom regular expressions for argument validation.
  • *
  • Set different argument name prefixes for native platform look and feel.
  • *
  • QSettings support. Default values for arguments can be read from * a QSettings object.
  • *
  • Create a help text for the command line arguments with support for * grouping arguments.
  • *
* * Here is an example how to use this class inside a main function: * * \code * #include * #include * #include * * int main(int argc, char** argv) * { * QCoreApplication app(argc, argv); * // This is used by QSettings * QCoreApplication::setOrganizationName("MyOrg"); * QCoreApplication::setApplicationName("MyApp"); * * ctkCommandLineParser parser; * // Use Unix-style argument names * parser.setArgumentPrefix("--", "-"); * // Enable QSettings support * parser.enableSettings("disable-settings"); * * // Add command line argument names * parser.addArgument("disable-settings", "", QVariant::Bool, "Do not use QSettings"); * parser.addArgument("help", "h", QVariant::Bool, "Show this help text"); * parser.addArgument("search-paths", "s", QVariant::StringList, "A list of paths to search"); * * // Parse the command line arguments * bool ok = false; * QHash parsedArgs = parser.parseArguments(QCoreApplication::arguments(), &ok); * if (!ok) * { * QTextStream(stderr, QIODevice::WriteOnly) << "Error parsing arguments: " * << parser.errorString() << "\n"; * return EXIT_FAILURE; * } * * // Show a help message * if (parsedArgs.contains("help") || parsedArgs.contains("h")) * { * QTextStream(stdout, QIODevice::WriteOnly) << parser.helpText(); * return EXIT_SUCCESS; * } * * // Do something * * return EXIT_SUCCESS; * } * \endcode */ class ctkCommandLineParser : public QObject { Q_OBJECT Q_PROPERTY(QString errorString READ errorString) Q_PROPERTY(QStringList unparsedArguments READ unparsedArguments) Q_PROPERTY(bool settingsEnabled READ settingsEnabled) public: typedef QObject Superclass; /** * Constructs a parser instance. * * If QSettings support is enabled by a call to enableSettings() * a default constructed QSettings instance will be used when parsing * the command line arguments. Make sure to call QCoreApplication::setOrganizationName() * and QCoreApplication::setApplicationName() before using default * constructed QSettings objects. * * @param newParent The QObject parent. */ ctkCommandLineParser(QObject *newParent = nullptr); /** * Constructs a parser instance. * * If QSettings support is enabled by a call to enableSettings() * the provided QSettings instance will be used. If the QSettings instance is * zero, a default constructed QSettings instance will be used when parsing * the command line arguments. Using a default constructed instance is usually * what you want, if you have called QCoreApplication::setOrganizationName() * and QCoreApplication::setApplicationName(). * * @param settings A QSettings instance which should be used. * @param newParent The QObject parent. * * */ ctkCommandLineParser(QSettings *settings, QObject *newParent = nullptr); - ~ctkCommandLineParser(); + ~ctkCommandLineParser() override; /** * Parse a given list of command line arguments. * * This method parses a list of QString elements considering the known arguments * added by calls to addArgument(). If any one of the argument * values does not match the corresponding regular expression, * ok is set to false and an empty QHash object is returned. * * The keys in the returned QHash object correspond to the long argument string, * if it is not empty. Otherwise, the short argument string is used as key. The * QVariant values can safely be converted to the type specified in the * addArgument() method call. * * @param arguments A QStringList containing command line arguments. Usually * given by QCoreApplication::arguments(). * @param ok A pointer to a boolean variable. Will be set to true * if all regular expressions matched, false otherwise. * @return A QHash object mapping the long argument (if empty, the short one) * to a QVariant containing the value. */ QHash parseArguments(const QStringList &arguments, bool *ok = nullptr); /** * Convenient method allowing to parse a given list of command line arguments. * @see parseArguments(const QStringList &, bool*) */ QHash parseArguments(int argc, char **argv, bool *ok = nullptr); /** * Returns a detailed error description if a call to parseArguments() * failed. * * @return The error description, empty if no error occured. * @see parseArguments(const QStringList&, bool*) */ QString errorString() const; /** * This method returns all unparsed arguments, i.e. all arguments * for which no long or short name has been registered via a call * to addArgument(). * * @see addArgument() * * @return A list containing unparsed arguments. */ const QStringList &unparsedArguments() const; /** * Checks if the given argument has been added via a call * to addArgument(). * * @see addArgument() * * @param argument The argument to be checked. * @return true if the argument was added, false * otherwise. */ Q_INVOKABLE bool argumentAdded(const QString &argument) const; /** * Checks if the given argument has been parsed successfully by a previous * call to parseArguments(). * * @param argument The argument to be checked. * @return true if the argument was parsed, false * otherwise. */ Q_INVOKABLE bool argumentParsed(const QString &argument) const; /** * Adds a command line argument. An argument can have a long name * (like --long-argument-name), a short name (like -l), or both. The type * of the argument can be specified by using the type parameter. * The following types are supported: * * * * * * * * *
Type# of parametersDefault regular exprExample
QVariant::String1.*--test-string StringParameter
QVariant::Bool0does not apply--enable-something
QVariant::StringList-1.*--test-list string1 string2
QVariant::Int1-?[0-9]+--test-int -5
* * The regular expressions are used to validate the parameters of command line * arguments. You can restrict the valid set of parameters by calling * setExactMatchRegularExpression() for your argument. * * Optionally, a help string and a default value can be provided for the argument. If * the QVariant type of the default value does not match type, an * exception is thrown. Arguments with default values are always returned by * parseArguments(). * * You can also declare an argument deprecated, by setting deprecated * to true. Alternatively you can add a deprecated argument by calling * addDeprecatedArgument(). * * If the long or short argument has already been added, or if both are empty strings, * the method call has no effect. * * @param longarg The long argument name. * @param shortarg The short argument name. * @param type The argument type (see the list above for supported types). * @param argHelp A help string describing the argument. * @param defaultValue A default value for the argument. * @param ignoreRest All arguments after the current one will be ignored. * @param deprecated Declares the argument deprecated. * * @see setExactMatchRegularExpression() * @see addDeprecatedArgument() * @throws std::logic_error If the QVariant type of defaultValue * does not match type, a std::logic_error is thrown. */ void addArgument(const QString &longarg, const QString &shortarg, QVariant::Type type, const QString &argHelp = QString(), const QVariant &defaultValue = QVariant(), bool ignoreRest = false, bool deprecated = false); /** * Adds a deprecated command line argument. If a deprecated argument is provided * on the command line, argHelp is displayed in the console and * processing continues with the next argument. * * Deprecated arguments are grouped separately at the end of the help text * returned by helpText(). * * @param longarg The long argument name. * @param shortarg The short argument name. * @param argHelp A help string describing alternatives to the deprecated argument. */ void addDeprecatedArgument(const QString &longarg, const QString &shortarg, const QString &argHelp); /** * Sets a custom regular expression for validating argument parameters. The method * errorString() can be used the get the last error description. * * @param argument The previously added long or short argument name. * @param expression A regular expression which the arugment parameters must match. * @param exactMatchFailedMessage An error message explaining why the parameter did * not match. * * @return true if the argument was found and the regular expression was set, * false otherwise. * * @see errorString() */ bool setExactMatchRegularExpression(const QString &argument, const QString &expression, const QString &exactMatchFailedMessage); /** * The field width for the argument names without the help text. * * @return The argument names field width in the help text. */ int fieldWidth() const; /** * Creates a help text containing properly formatted argument names and help strings * provided by calls to addArgument(). The arguments can be grouped by * using beginGroup() and endGroup(). * * @param charPad The padding character. * @return The formatted help text. */ QString helpText(const char charPad = ' ') const; /** * Sets the argument prefix for long and short argument names. This can be used * to create native command line arguments without changing the calls to * addArgument(). For example on Unix-based systems, long argument * names start with "--" and short names with "-", while on Windows argument names * always start with "/". * * Note that all methods in ctkCommandLineParser which take an argument name * expect the name as it was supplied to addArgument. * * Example usage: * * \code * ctkCommandLineParser parser; * parser.setArgumentPrefix("--", "-"); * parser.addArgument("long-argument", "l", QVariant::String); * QStringList args; * args << "program name" << "--long-argument Hi"; * parser.parseArguments(args); * \endcode * * @param longPrefix The prefix for long argument names. * @param shortPrefix The prefix for short argument names. */ void setArgumentPrefix(const QString &longPrefix, const QString &shortPrefix); /** * Begins a new group for documenting arguments. All newly added arguments via * addArgument() will be put in the new group. You can close the * current group by calling endGroup() or be opening a new group. * * Note that groups cannot be nested and all arguments which do not belong to * a group will be listed at the top of the text created by helpText(). * * @param description The description of the group */ void beginGroup(const QString &description); /** * Ends the current group. * * @see beginGroup(const QString&) */ void endGroup(); /** * Enables QSettings support in ctkCommandLineParser. If an argument name is found * in the QSettings instance with a valid QVariant, the value is considered as * a default value and overwrites default values registered with * addArgument(). User supplied values on the command line overwrite * values in the QSettings instance, except for arguments with multiple parameters * which are merged with QSettings values. Call mergeSettings(false) * to disable merging. * * See ctkCommandLineParser(QSettings*) for information about how to * supply a QSettings instance. * * Additionally, a long and short argument name can be specified which will disable * QSettings support if supplied on the command line. The argument name must be * registered as a regular argument via addArgument(). * * @param disableLongArg Long argument name. * @param disableShortArg Short argument name. * * @see ctkCommandLineParser(QSettings*) */ void enableSettings(const QString &disableLongArg = "", const QString &disableShortArg = ""); /** * Controlls the merging behavior of user values and QSettings values. * * If merging is on (the default), user supplied values for an argument * which can take more than one parameter are merged with values stored * in the QSettings instance. If merging is off, the user values overwrite * the QSettings values. * * @param merge true enables QSettings merging, false * disables it. */ void mergeSettings(bool merge); /** * Can be used to check if QSettings support has been enabled by a call to * enableSettings(). * * @return true if QSettings support is enabled, false * otherwise. */ bool settingsEnabled() const; /** * Can be used to teach the parser to stop parsing the arguments and return False when * an unknown argument is encountered. By default StrictMode is disabled. * * @see parseArguments(const QStringList &, bool*) */ void setStrictModeEnabled(bool strictMode); private: class ctkInternal; ctkInternal *Internal; }; #endif diff --git a/Documentation/Snippets/org.blueberry.ui.qt.help-config/main.cpp b/Documentation/Snippets/org.blueberry.ui.qt.help-config/main.cpp index f49b044e86..3e115bc6a9 100644 --- a/Documentation/Snippets/org.blueberry.ui.qt.help-config/main.cpp +++ b/Documentation/Snippets/org.blueberry.ui.qt.help-config/main.cpp @@ -1,127 +1,127 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include #include #include #include #include #include class MyApplicationPlugin : public QObject, public ctkPluginActivator { Q_OBJECT Q_INTERFACES(ctkPluginActivator) public: MyApplicationPlugin(); - ~MyApplicationPlugin(); + ~MyApplicationPlugin() override; //! [0] void start(ctkPluginContext *context) override { // Get a service reference for the Config Admin service ctkServiceReference cmRef = context->getServiceReference(); ctkConfigurationAdmin *configAdmin = nullptr; if (cmRef) { configAdmin = context->getService(cmRef); } // Use the CTK Configuration Admin service to configure the BlueBerry help system. // This assumes that the plug-in providing the Config Admin implementation is // already active. if (configAdmin) { // Get a ctkConfiguration object for the PID "org.blueberry.services.help" // (or create an unbound instance if it does not exist yet). ctkConfigurationPtr conf = configAdmin->getConfiguration("org.blueberry.services.help", QString()); // Configure the help system using a custom home page ctkDictionary helpProps; helpProps.insert("homePage", "qthelp://org.company.plugin/bundle/index.html"); conf->update(helpProps); // Unget the service context->ungetService(cmRef); } else { // Warn that the Config Admin service is unavailable } } //! [0] void stop(ctkPluginContext *context) override; //! [1] void requestHelp(ctkPluginContext *context) { if (context == nullptr) { // Warn that the plugin context is zero return; } // Check if the org.blueberry.ui.qt.help plug-in is installed and started QList> plugins = context->getPlugins(); foreach (QSharedPointer p, plugins) { if (p->getSymbolicName() == "org.blueberry.ui.qt.help" && p->getState() != ctkPlugin::ACTIVE) { // The plug-in is in RESOLVED state but is not started yet. // Try to activate the plug-in explicitly, so that it can react // to events send via the CTK Event Admin. try { p->start(ctkPlugin::START_TRANSIENT); } catch (const ctkPluginException &) { // Warn that activating the org.blueberry.ui.qt.help plug-in failed return; } } } ctkServiceReference eventAdminRef = context->getServiceReference(); ctkEventAdmin *eventAdmin = nullptr; if (eventAdminRef) { eventAdmin = context->getService(eventAdminRef); } if (eventAdmin == nullptr) { // Warn that the ctkEventAdmin service was not found } else { // Create the event and send it asynchronuously ctkEvent ev("org/blueberry/ui/help/CONTEXTHELP_REQUESTED"); eventAdmin->postEvent(ev); } } //! [1] private: }; int main(int /*argc*/, char * /*argv*/ []) { return 0; } diff --git a/Modules/AppUtil/src/mitkBaseApplication.cpp b/Modules/AppUtil/src/mitkBaseApplication.cpp index bcd8f76dc7..9e1a5fbda5 100644 --- a/Modules/AppUtil/src/mitkBaseApplication.cpp +++ b/Modules/AppUtil/src/mitkBaseApplication.cpp @@ -1,828 +1,828 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "mitkBaseApplication.h" #include "mitkLogMacros.h" #include "QmitkSafeApplication.h" #include "QmitkSingleApplication.h" #include "mitkProvisioningInfo.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include namespace mitk { QString BaseApplication::ARG_NEWINSTANCE = "BlueBerry.newInstance"; QString BaseApplication::ARG_CLEAN = "BlueBerry.clean"; QString BaseApplication::ARG_APPLICATION = "BlueBerry.application"; QString BaseApplication::ARG_PRODUCT = "BlueBerry.product"; QString BaseApplication::ARG_HOME = "BlueBerry.home"; QString BaseApplication::ARG_STORAGE_DIR = "BlueBerry.storageDir"; QString BaseApplication::ARG_PLUGIN_CACHE = "BlueBerry.plugin_cache_dir"; QString BaseApplication::ARG_PLUGIN_DIRS = "BlueBerry.plugin_dirs"; QString BaseApplication::ARG_FORCE_PLUGIN_INSTALL = "BlueBerry.forcePlugins"; QString BaseApplication::ARG_PRELOAD_LIBRARY = "BlueBerry.preloadLibrary"; QString BaseApplication::ARG_PROVISIONING = "BlueBerry.provisioning"; QString BaseApplication::ARG_DEBUG = "BlueBerry.debug"; QString BaseApplication::ARG_CONSOLELOG = "BlueBerry.consoleLog"; QString BaseApplication::ARG_TESTPLUGIN = "BlueBerry.testplugin"; QString BaseApplication::ARG_TESTAPPLICATION = "BlueBerry.testapplication"; QString BaseApplication::ARG_SPLASH_IMAGE = "BlueBerry.splashscreen"; QString BaseApplication::ARG_NO_REGISTRY_CACHE = "BlueBerry.noRegistryCache"; QString BaseApplication::ARG_NO_LAZY_REGISTRY_CACHE_LOADING = "BlueBerry.noLazyRegistryCacheLoading"; QString BaseApplication::ARG_REGISTRY_MULTI_LANGUAGE = "BlueBerry.registryMultiLanguage"; QString BaseApplication::ARG_XARGS = "xargs"; QString BaseApplication::PROP_NEWINSTANCE = BaseApplication::ARG_NEWINSTANCE; QString BaseApplication::PROP_FORCE_PLUGIN_INSTALL = BaseApplication::ARG_FORCE_PLUGIN_INSTALL; QString BaseApplication::PROP_NO_REGISTRY_CACHE = BaseApplication::ARG_NO_REGISTRY_CACHE; QString BaseApplication::PROP_NO_LAZY_REGISTRY_CACHE_LOADING = BaseApplication::ARG_NO_LAZY_REGISTRY_CACHE_LOADING; QString BaseApplication::PROP_REGISTRY_MULTI_LANGUAGE = BaseApplication::ARG_REGISTRY_MULTI_LANGUAGE; QString BaseApplication::PROP_PRODUCT = "blueberry.product"; QString BaseApplication::PROP_APPLICATION = "blueberry.application"; QString BaseApplication::PROP_TESTPLUGIN = "BlueBerry.testplugin"; QString BaseApplication::PROP_TESTAPPLICATION = "BlueBerry.testapplication"; class SplashCloserCallback : public QRunnable { public: SplashCloserCallback(QSplashScreen* splashscreen) { this->m_Splashscreen = splashscreen; } - void run() + void run() override { this->m_Splashscreen->close(); } private: QSplashScreen* m_Splashscreen; }; struct BaseApplication::Impl { ctkProperties m_FWProps; QScopedPointer m_QApp; int m_Argc; char **m_Argv; QString m_AppName; QString m_OrgaName; QString m_OrgaDomain; bool m_SingleMode; bool m_SafeMode; QSplashScreen* m_Splashscreen; SplashCloserCallback* m_SplashscreenClosingCallback; QStringList m_PreloadLibs; QString m_ProvFile; Impl(int argc, char **argv) : m_Argc(argc), m_Argv(argv), m_SingleMode(false), m_SafeMode(true), m_Splashscreen(0), m_SplashscreenClosingCallback(nullptr) { #ifdef Q_OS_MAC /* * This is a workaround for bug 19080: * On Mac OS X the prosess serial number is passed as an commandline argument (-psn_) * if the application is started via the.app bundle. * This option is unknown, which causes a Poco exception. * Since this is done by the system we have to manually remove the argument here. */ int newArgc = m_Argc - 1; char **newArgs = new char *[newArgc]; bool argFound(false); for (int i = 0; i < m_Argc; ++i) { if (QString::fromLatin1(m_Argv[i]).contains("-psn")) { argFound = true; } else { newArgs[i] = m_Argv[i]; } } if (argFound) { m_Argc = newArgc; m_Argv = newArgs; } #endif } QVariant getProperty(const QString &property) const { auto iter = m_FWProps.find(property); return iter == m_FWProps.end() ? QVariant() : iter.value(); } void handleBooleanOption(const std::string &name, const std::string & /*value*/) { QString fwKey = QString::fromStdString(name); // translate some keys to proper framework properties if (fwKey == ARG_CONSOLELOG) { fwKey = ctkPluginFrameworkLauncher::PROP_CONSOLE_LOG; } // For all other options we use the command line option name as the // framework property key. m_FWProps[fwKey] = true; } void handlePreloadLibraryOption(const std::string & /*name*/, const std::string &value) { m_PreloadLibs.push_back(QString::fromStdString(value)); } void handleClean(const std::string & /*name*/, const std::string & /*value*/) { m_FWProps[ctkPluginConstants::FRAMEWORK_STORAGE_CLEAN] = ctkPluginConstants::FRAMEWORK_STORAGE_CLEAN_ONFIRSTINIT; } void initializeCTKPluginFrameworkProperties(Poco::Util::LayeredConfiguration &configuration) { // add all configuration key / value pairs as framework properties Poco::Util::LayeredConfiguration::Keys keys; Poco::Util::LayeredConfiguration::Keys keyStack; configuration.keys(keyStack); std::vector keyChain; while (!keyStack.empty()) { std::string currSubKey = keyStack.back(); if (!keyChain.empty() && keyChain.back() == currSubKey) { keyChain.pop_back(); keyStack.pop_back(); continue; } Poco::Util::LayeredConfiguration::Keys subKeys; configuration.keys(currSubKey, subKeys); if (subKeys.empty()) { keyStack.pop_back(); std::string finalKey; for (auto k = keyChain.begin(); k != keyChain.end(); ++k) { finalKey += *k + "."; } finalKey += currSubKey; keys.push_back(finalKey); } else { keyChain.push_back(currSubKey); for (auto s : subKeys) { keyStack.push_back(s); } } } for (auto key : keys) { QString qKey = QString::fromStdString(key); if (configuration.hasProperty(key)) { // ini and command line options overwrite already inserted keys m_FWProps[qKey] = QString::fromStdString(configuration.getString(key)); } } } void parseProvisioningFile(const QString &filePath) { // Skip parsing if the file path is empty if (filePath.isEmpty()) return; bool consoleLog = this->getProperty(ctkPluginFrameworkLauncher::PROP_CONSOLE_LOG).toBool(); // read initial plugins from a provisioning file QStringList pluginsToStart; QFileInfo provFile(filePath); if (provFile.exists()) { MITK_INFO(consoleLog) << "Using provisioning file: " << qPrintable(provFile.absoluteFilePath()); ProvisioningInfo provInfo(provFile.absoluteFilePath()); // it can still happen, that the encoding is not compatible with the fromUtf8 function ( i.e. when manipulating // the LANG variable // in such case, the QStringList in provInfo is empty which we can easily check for if (provInfo.getPluginDirs().empty()) { MITK_ERROR << "Cannot search for provisioning file, the retrieved directory list is empty.\n" << "This can occur if there are some special (non-ascii) characters in the install path."; } else { foreach (QString pluginPath, provInfo.getPluginDirs()) { ctkPluginFrameworkLauncher::addSearchPath(pluginPath); } // bool forcePluginOverwrite = this->getProperty(ARG_FORCE_PLUGIN_INSTALL).toBool(); QList pluginUrlsToStart = provInfo.getPluginsToStart(); for (auto url : pluginUrlsToStart) { pluginsToStart.push_back(url.toString()); } // foreach(QUrl pluginUrl, provInfo.getPluginsToInstall()) //{ // TODO for "uninstall", we need a proper configuration agent, e.g. a dedicated // plug-in for provisioning of the platform /* if (forcePluginOverwrite) { uninstallPugin(pluginUrl, context); } */ // try //{ // MITK_INFO(consoleLog) << "Installing CTK plug-in from: " << pluginUrl.toString().toStdString(); /* QSharedPointer plugin = context->installPlugin(pluginUrl); if (pluginsToStart.contains(pluginUrl)) { m_CTKPluginsToStart << plugin->getPluginId(); } */ /* } catch (const ctkPluginException& e) { QString errorMsg; QDebug dbg(&errorMsg); dbg << e.printStackTrace(); BERRY_ERROR << qPrintable(errorMsg); } */ //} } } else { MITK_INFO(consoleLog) << "No provisioning file set."; } if (!pluginsToStart.isEmpty()) { m_FWProps[ctkPluginFrameworkLauncher::PROP_PLUGINS] = pluginsToStart; // Use transient start with declared activation policy (this helps when // the provisioning file changes and some plug-ins should not be installed // in the application any more). ctkPlugin::StartOptions startOptions(ctkPlugin::START_TRANSIENT | ctkPlugin::START_ACTIVATION_POLICY); m_FWProps[ctkPluginFrameworkLauncher::PROP_PLUGINS_START_OPTIONS] = static_cast(startOptions); } } }; BaseApplication::BaseApplication(int argc, char **argv) : Application(), d(new Impl(argc, argv)) { } BaseApplication::~BaseApplication() { if (d->m_Splashscreen != 0) { delete(d->m_Splashscreen); } if (d->m_SplashscreenClosingCallback != 0) { delete(d->m_SplashscreenClosingCallback); } } void BaseApplication::printHelp(const std::string & /*name*/, const std::string & /*value*/) { Poco::Util::HelpFormatter help(this->options()); help.setAutoIndent(); help.setCommand(this->commandName()); help.format(std::cout); exit(EXIT_OK); } void BaseApplication::setApplicationName(const QString &name) { if (qApp) { qApp->setApplicationName(name); } d->m_AppName = name; } QString BaseApplication::getApplicationName() const { if (qApp) { return qApp->applicationName(); } return d->m_AppName; } void BaseApplication::setOrganizationName(const QString &name) { if (qApp) { qApp->setOrganizationName(name); } d->m_OrgaName = name; } QString BaseApplication::getOrganizationName() const { if (qApp) return qApp->organizationName(); return d->m_OrgaName; } void BaseApplication::setOrganizationDomain(const QString &domain) { if (qApp) { qApp->setOrganizationDomain(domain); } d->m_OrgaDomain = domain; } QString BaseApplication::getOrganizationDomain() const { if (qApp) return qApp->organizationDomain(); return d->m_OrgaDomain; } void BaseApplication::setSingleMode(bool singleMode) { if (qApp) return; d->m_SingleMode = singleMode; } bool BaseApplication::getSingleMode() const { return d->m_SingleMode; } void BaseApplication::setSafeMode(bool safeMode) { if (qApp && !d->m_QApp) return; d->m_SafeMode = safeMode; if (d->m_QApp) { if (getSingleMode()) { static_cast(d->m_QApp.data())->setSafeMode(safeMode); } else { static_cast(d->m_QApp.data())->setSafeMode(safeMode); } } } bool BaseApplication::getSafeMode() const { return d->m_SafeMode; } void BaseApplication::setPreloadLibraries(const QStringList &libraryBaseNames) { d->m_PreloadLibs = libraryBaseNames; } QStringList BaseApplication::getPreloadLibraries() const { return d->m_PreloadLibs; } void BaseApplication::setProvisioningFilePath(const QString &filePath) { d->m_ProvFile = filePath; } QString BaseApplication::getProvisioningFilePath() const { QString provFilePath = d->m_ProvFile; // A null QString means look up a default provisioning file if (provFilePath.isNull() && qApp) { QFileInfo appFilePath(QCoreApplication::applicationFilePath()); QDir basePath(QCoreApplication::applicationDirPath()); QString provFileName = appFilePath.baseName() + ".provisioning"; QFileInfo provFile(basePath.absoluteFilePath(provFileName)); #ifdef Q_OS_MAC /* * On Mac, if started from the build directory the .provisioning file is located at: * * but the executable path is: * * In this case we have to cdUp threetimes. * * During packaging however the MitkWorkbench.provisioning file is placed at the same * level like the executable, hence nothing has to be done. */ if (!provFile.exists()) { basePath.cdUp(); basePath.cdUp(); basePath.cdUp(); provFile = basePath.absoluteFilePath(provFileName); } #endif if (provFile.exists()) { provFilePath = provFile.absoluteFilePath(); } #ifdef CMAKE_INTDIR else { basePath.cdUp(); provFile.setFile(basePath.absoluteFilePath(provFileName)); if (provFile.exists()) { provFilePath = provFile.absoluteFilePath(); } } #endif } return provFilePath; } void BaseApplication::initializeQt() { if (qApp) return; // If previously parameters have been set we have to store them // to hand them through to the application QString appName = this->getApplicationName(); QString orgName = this->getOrganizationName(); QString orgDomain = this->getOrganizationDomain(); // Create a QCoreApplication instance this->getQApplication(); // provide parameters to QCoreApplication this->setApplicationName(appName); this->setOrganizationName(orgName); this->setOrganizationDomain(orgDomain); } void BaseApplication::initialize(Poco::Util::Application &self) { // 1. Call the super-class method Poco::Util::Application::initialize(self); // 2. Initialize the Qt framework (by creating a QCoreApplication) this->initializeQt(); // 3. Seed the random number generator, once at startup. QTime time = QTime::currentTime(); qsrand((uint)time.msec()); // 4. Load the "default" configuration, which involves parsing // an optional .ini file and parsing any // command line arguments this->loadConfiguration(); // 5. Add configuration data from the command line and the // optional .ini file as CTK plugin // framework properties. d->initializeCTKPluginFrameworkProperties(this->config()); // 6. Initialize splash screen if an image path is provided // in the .ini file this->initializeSplashScreen(qApp); // 7. Set the custom CTK Plugin Framework storage directory QString storageDir = this->getCTKFrameworkStorageDir(); if (!storageDir.isEmpty()) { d->m_FWProps[ctkPluginConstants::FRAMEWORK_STORAGE] = storageDir; } // 8. Set the library search paths and the pre-load library property this->initializeLibraryPaths(); QStringList preloadLibs = this->getPreloadLibraries(); if (!preloadLibs.isEmpty()) { d->m_FWProps[ctkPluginConstants::FRAMEWORK_PRELOAD_LIBRARIES] = preloadLibs; } // 9. Initialize the CppMicroServices library. // The initializeCppMicroServices() method reuses the // FRAMEWORK_STORAGE property, so we call it after the // getCTKFrameworkStorageDir method. this->initializeCppMicroServices(); // 10. Parse the (optional) provisioning file and set the // correct framework properties. d->parseProvisioningFile(this->getProvisioningFilePath()); // Finally, set the CTK Plugin Framework properties ctkPluginFrameworkLauncher::setFrameworkProperties(d->m_FWProps); } void BaseApplication::uninitialize() { QSharedPointer pfw = this->getFramework(); if (pfw) { pfw->stop(); // wait 10 seconds for the CTK plugin framework to stop pfw->waitForStop(10000); } Poco::Util::Application::uninitialize(); } int BaseApplication::getArgc() const { return d->m_Argc; } char **BaseApplication::getArgv() const { return d->m_Argv; } QString BaseApplication::getCTKFrameworkStorageDir() const { QString storageDir; if (this->getSingleMode()) { // This function checks if an instance is already running // and either sends a message to it (containing the command // line arguments) or checks if a new instance was forced by // providing the BlueBerry.newInstance command line argument. // In the latter case, a path to a temporary directory for // the new application's storage directory is returned. storageDir = handleNewAppInstance( static_cast(d->m_QApp.data()), d->m_Argc, d->m_Argv, ARG_NEWINSTANCE); } if (storageDir.isEmpty()) { // This is a new instance and no other instance is already running. We specify // the storage directory here (this is the same code as in berryInternalPlatform.cpp // so that we can re-use the location for the persistent data location of the // the CppMicroServices library. // Append a hash value of the absolute path of the executable to the data location. // This allows to start the same application from different build or install trees. storageDir = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + "/" + this->getOrganizationName() + "/" + this->getApplicationName() + '_'; storageDir += QString::number(qHash(QCoreApplication::applicationDirPath())) + "/"; } return storageDir; } void BaseApplication::initializeCppMicroServices() { QString storageDir = this->getProperty(ctkPluginConstants::FRAMEWORK_STORAGE).toString(); if (!storageDir.isEmpty()) { us::ModuleSettings::SetStoragePath((storageDir + QString("us") + QDir::separator()).toStdString()); } } QCoreApplication *BaseApplication::getQApplication() const { QCoreApplication *qCoreApp = qApp; // Needed to fix bug #18521, i.e. not responding GUI on Mac OS X with Qt5 #ifdef Q_OS_OSX qCoreApp->setAttribute(Qt::AA_DontCreateNativeWidgetSiblings); #endif qCoreApp->setAttribute(Qt::AA_ShareOpenGLContexts); if (!qCoreApp) { if (getSingleMode()) { qCoreApp = new QmitkSingleApplication(d->m_Argc, d->m_Argv, getSafeMode()); } else { auto safeApp = new QmitkSafeApplication(d->m_Argc, d->m_Argv); safeApp->setSafeMode(d->m_SafeMode); qCoreApp = safeApp; } d->m_QApp.reset(qCoreApp); } return qCoreApp; } void BaseApplication::initializeLibraryPaths() { QStringList suffixes; suffixes << "plugins"; #ifdef Q_OS_WINDOWS suffixes << "bin/plugins"; #ifdef CMAKE_INTDIR suffixes << "bin/" CMAKE_INTDIR "/plugins"; #endif #else suffixes << "lib/plugins"; #ifdef CMAKE_INTDIR suffixes << "lib/" CMAKE_INTDIR "/plugins"; #endif #endif #ifdef Q_OS_MAC suffixes << "../../plugins"; #endif // we add a couple of standard library search paths for plug-ins QDir appDir(QCoreApplication::applicationDirPath()); // walk one directory up and add bin and lib sub-dirs; this // might be redundant appDir.cdUp(); foreach (QString suffix, suffixes) { ctkPluginFrameworkLauncher::addSearchPath(appDir.absoluteFilePath(suffix)); } } int BaseApplication::main(const std::vector &args) { // Start the plugin framework and all installed plug-ins according with // their auto-start setting. QStringList arguments; for (auto const &arg : args) { arguments.push_back(QString::fromStdString(arg)); } if (d->m_Splashscreen != 0) { // a splash screen is displayed, // creating the closing callback d->m_SplashscreenClosingCallback = new SplashCloserCallback(d->m_Splashscreen); } return ctkPluginFrameworkLauncher::run(d->m_SplashscreenClosingCallback, QVariant::fromValue(arguments)).toInt(); } void BaseApplication::defineOptions(Poco::Util::OptionSet &options) { Poco::Util::Option helpOption("help", "h", "print this help text"); helpOption.callback(Poco::Util::OptionCallback(this, &BaseApplication::printHelp)); options.addOption(helpOption); Poco::Util::Option newInstanceOption( ARG_NEWINSTANCE.toStdString(), "", "forces a new instance of this application"); newInstanceOption.callback(Poco::Util::OptionCallback(d.data(), &Impl::handleBooleanOption)); options.addOption(newInstanceOption); Poco::Util::Option cleanOption(ARG_CLEAN.toStdString(), "", "cleans the plugin cache"); cleanOption.callback(Poco::Util::OptionCallback(d.data(), &Impl::handleClean)); options.addOption(cleanOption); Poco::Util::Option productOption(ARG_PRODUCT.toStdString(), "", "the id of the product to be launched"); productOption.argument("").binding(PROP_PRODUCT.toStdString()); options.addOption(productOption); Poco::Util::Option appOption( ARG_APPLICATION.toStdString(), "", "the id of the application extension to be executed"); appOption.argument("").binding(PROP_APPLICATION.toStdString()); options.addOption(appOption); Poco::Util::Option provOption(ARG_PROVISIONING.toStdString(), "", "the location of a provisioning file"); provOption.argument("").binding(ARG_PROVISIONING.toStdString()); options.addOption(provOption); Poco::Util::Option storageDirOption( ARG_STORAGE_DIR.toStdString(), "", "the location for storing persistent application data"); storageDirOption.argument("").binding(ctkPluginConstants::FRAMEWORK_STORAGE.toStdString()); options.addOption(storageDirOption); Poco::Util::Option consoleLogOption(ARG_CONSOLELOG.toStdString(), "", "log messages to the console"); consoleLogOption.callback(Poco::Util::OptionCallback(d.data(), &Impl::handleBooleanOption)); options.addOption(consoleLogOption); Poco::Util::Option debugOption(ARG_DEBUG.toStdString(), "", "enable debug mode"); debugOption.argument("", false).binding(ctkPluginFrameworkLauncher::PROP_DEBUG.toStdString()); options.addOption(debugOption); Poco::Util::Option forcePluginOption( ARG_FORCE_PLUGIN_INSTALL.toStdString(), "", "force installing plug-ins with same symbolic name"); forcePluginOption.callback(Poco::Util::OptionCallback(d.data(), &Impl::handleBooleanOption)); options.addOption(forcePluginOption); Poco::Util::Option preloadLibsOption(ARG_PRELOAD_LIBRARY.toStdString(), "", "preload a library"); preloadLibsOption.argument("") .repeatable(true) .callback(Poco::Util::OptionCallback(d.data(), &Impl::handlePreloadLibraryOption)); options.addOption(preloadLibsOption); Poco::Util::Option testPluginOption(ARG_TESTPLUGIN.toStdString(), "", "the plug-in to be tested"); testPluginOption.argument("").binding(PROP_TESTPLUGIN.toStdString()); options.addOption(testPluginOption); Poco::Util::Option testAppOption(ARG_TESTAPPLICATION.toStdString(), "", "the application to be tested"); testAppOption.argument("").binding(PROP_TESTAPPLICATION.toStdString()); options.addOption(testAppOption); Poco::Util::Option noRegistryCacheOption( ARG_NO_REGISTRY_CACHE.toStdString(), "", "do not use a cache for the registry"); noRegistryCacheOption.callback(Poco::Util::OptionCallback(d.data(), &Impl::handleBooleanOption)); options.addOption(noRegistryCacheOption); Poco::Util::Option noLazyRegistryCacheLoadingOption( ARG_NO_LAZY_REGISTRY_CACHE_LOADING.toStdString(), "", "do not use lazy cache loading for the registry"); noLazyRegistryCacheLoadingOption.callback(Poco::Util::OptionCallback(d.data(), &Impl::handleBooleanOption)); options.addOption(noLazyRegistryCacheLoadingOption); Poco::Util::Option registryMultiLanguageOption( ARG_REGISTRY_MULTI_LANGUAGE.toStdString(), "", "enable multi-language support for the registry"); registryMultiLanguageOption.callback(Poco::Util::OptionCallback(d.data(), &Impl::handleBooleanOption)); options.addOption(registryMultiLanguageOption); Poco::Util::Option splashScreenOption(ARG_SPLASH_IMAGE.toStdString(), "", "optional picture to use as a splash screen"); splashScreenOption.argument("").binding(ARG_SPLASH_IMAGE.toStdString()); options.addOption(splashScreenOption); Poco::Util::Option xargsOption(ARG_XARGS.toStdString(), "", "Extended argument list"); xargsOption.argument("").binding(ARG_XARGS.toStdString()); options.addOption(xargsOption); Poco::Util::Application::defineOptions(options); } QSharedPointer BaseApplication::getFramework() const { return ctkPluginFrameworkLauncher::getPluginFramework(); } ctkPluginContext *BaseApplication::getFrameworkContext() const { QSharedPointer framework = getFramework(); if (framework) return framework->getPluginContext(); return nullptr; } void BaseApplication::initializeSplashScreen(QCoreApplication * application) const { QVariant pixmapFileNameProp = d->getProperty(ARG_SPLASH_IMAGE); if (!pixmapFileNameProp.isNull()) { QString pixmapFileName = pixmapFileNameProp.toString(); QFileInfo checkFile(pixmapFileName); if (checkFile.exists() && checkFile.isFile()) { QPixmap pixmap(checkFile.absoluteFilePath()); d->m_Splashscreen = new QSplashScreen(pixmap, Qt::WindowStaysOnTopHint); d->m_Splashscreen->show(); application->processEvents(); } } } QHash BaseApplication::getFrameworkProperties() const { return d->m_FWProps; } int BaseApplication::run() { this->init(d->m_Argc, d->m_Argv); return Application::run(); } void BaseApplication::setProperty(const QString &property, const QVariant &value) { d->m_FWProps[property] = value; } QVariant BaseApplication::getProperty(const QString &property) const { return d->getProperty(property); } } diff --git a/Modules/Chart/include/QmitkChartWidget.h b/Modules/Chart/include/QmitkChartWidget.h index 65a1810f9d..da2439b76f 100644 --- a/Modules/Chart/include/QmitkChartWidget.h +++ b/Modules/Chart/include/QmitkChartWidget.h @@ -1,196 +1,196 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QmitkC3jsWidget_h #define QmitkC3jsWidget_h #include #include #include /*! \brief QmitkChartWidget is a widget to display various charts based on the javascript chart library C3js. Currently, bar charts, line charts and pie charts are supported. * \details Data is added via AddData1D() or AddData2D().\n * There can be multiple charts (of the same type) created by calling AddData1D or AddData2D multiple times.\n\n * The following chart types are supported: * * line chart: http://c3js.org/samples/simple_multiple.html * * bar chart: http://c3js.org/samples/chart_bar.html * * spline chart: http://c3js.org/samples/chart_spline.html * * pie chart: http://c3js.org/samples/chart_pie.html * \n Technical details: The javascript code is embedded in a QWebEngineView. The actual js code is implemented in resource\Chart.js. * \sa http://c3js.org for further information about the used javaScript library. * \warning Pie is significantly different than the other types. Here, the data given by AddData1D is summed. Each entry represents a different category. * \ingroup Modules/Chart */ class MITKCHART_EXPORT QmitkChartWidget : public QWidget { Q_OBJECT public: /*! * \brief enum of diagram types. Supported are bar, line, spline (a smoothed line) and pie. */ enum class ChartType { bar, /*!< bar chart, see http://c3js.org/samples/chart_bar.html */ line, /*!< line chart, see http://c3js.org/samples/simple_multiple.html */ spline, /*!< spline chart (smoothed line chart), see http://c3js.org/samples/chart_spline.html */ pie, /*!< pie chart, see http://c3js.org/samples/chart_pie.html*/ area, /*!< area chart, see http://c3js.org/samples/chart_area.html*/ area_spline /*!< area-spline chart, see http://c3js.org/samples/chart_area.html*/ }; enum class ChartStyle { defaultstyle, darkstyle }; enum class LineStyle { solid, dashed }; enum class AxisScale { linear, log }; /*! * \brief enum of legend position. Supported are bottom, right, inset. * See http://c3js.org/reference.html#legend-position */ enum class LegendPosition { bottom, right, inset }; explicit QmitkChartWidget(QWidget* parent = nullptr); - virtual ~QmitkChartWidget(); + ~QmitkChartWidget() override; /*! * \brief Adds 1D data to the widget * \details internally, the list is converted to a map with increasing integers keys starting at 0. * \param label the name of the data that is also used as identifier. * \param type the chart type that should be used for this data entry * \note the data can be cleared with ClearDiagram() * \note If the label name already exists, the name is replaced with a unique one by concatenating numbers to it. */ void AddData1D(const std::vector& data1D, const std::string& label, ChartType type = ChartType::bar); /*! * \brief Adds 2D data to the widget. Call repeatedly for displaying multiple charts. * \details each entry represents a data point: key: value --> x-value: y-value. * \param label the name of the data that is also used as identifier. * \param type the chart type that should be used for this data entry * \note the data can be cleared with ClearDiagram() * \note If the label name already exists, the name is replaced with a unique one by concatenating numbers to it. */ void AddData2D(const std::map& data2D, const std::string& label, ChartType type = ChartType::bar); /*! * \brief Removes data from the widget, works for 1D and 2D Data * \param label the name of the data that is also used as identifier. * \note the data can be cleared with ClearDiagram() * \throws Invalid Argument Exception when the label cannot be found */ void RemoveData(const std::string& label); /*! * \brief sets the color of one data entry (identifier is previously assigned label) * \details the color name can be "red" or a hex number (#FF0000). * Either define all data entries with a color or none. If a mixed approach is used, different data entries could have the same color. * If an unknown label is given, nothing happens. * \sa https://www.w3schools.com/cssref/css_colors.asp */ void SetColor(const std::string& label, const std::string& colorName); /*! * \brief sets the line style of one data entry (identifier is previously assigned label) * \details two line styles are possible: LineStyle::solid and LineStyle::dashed. * The default linestyle is solid. * If an unknown label is given, nothing happens. * \warning only sets the line style if the current chart type is ChartType::line. However, the line style remains also if the chart changes (e.g. new chart type) */ void SetLineStyle(const std::string& label, LineStyle style); void SetYAxisScale(AxisScale scale); void SetXAxisLabel(const std::string& label); std::string GetXAxisLabel() const; void SetYAxisLabel(const std::string& label); std::string GetYAxisLabel() const; void SetTitle(const std::string &title); std::string GetTitle() const; /*! * \brief sets the chart type for a data entry * \details for available types, see ChartType * If an unknown label is given, nothing happens. * \sa DiagramType for available types */ void SetChartType(const std::string& label, ChartType type); void SetLegendPosition(LegendPosition position); LegendPosition GetLegendPosition() const; /*! * \brief Changes the chart type for all data entries and reloads the chart */ void SetChartTypeForAllDataAndReload(ChartType type); /*! * \brief Displays the chart in the widget * \param showSubChart if a subchart is displayed inside the widget or not (see http://c3js.org/samples/options_subchart.html). * \exception if no data has been provided (\sa AddData1D AddData2D) */ void Show(bool showSubChart=false); /*! * \brief Displays the dataPoints or not * \param showDataPoints if dataPoints are displayed inside the widget or not. */ void SetShowDataPoints(bool showDataPoints); bool GetShowDataPoints() const; /*! * \brief Clears all data inside and resets the widget. */ void Clear(); /*! * \brief Changes the theme of the widget. */ void SetTheme(ChartStyle themeEnabled); /*! * \brief Reloads the chart in the widget * \details reloading may be needed to display added data in an existing chart * \param showSubChart if a subchart is displayed inside the widget or not. */ void Reload(bool showSubChart); private: class Impl; Impl* m_Impl; public slots: void OnLoadFinished(bool isLoadSuccessfull); signals: void PageSuccessfullyLoaded(); }; #endif diff --git a/Modules/Classification/CLVigraRandomForest/src/mitkModuleActivator.cpp b/Modules/Classification/CLVigraRandomForest/src/mitkModuleActivator.cpp index f51aae6e53..b523bac27e 100644 --- a/Modules/Classification/CLVigraRandomForest/src/mitkModuleActivator.cpp +++ b/Modules/Classification/CLVigraRandomForest/src/mitkModuleActivator.cpp @@ -1,55 +1,55 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include #include #include #include "mitkNodePredicateDataType.h" #include namespace mitk { /** \brief Registers services for segmentation module. */ class ModuleActivator : public us::ModuleActivator { public: - void Load(us::ModuleContext*) + void Load(us::ModuleContext*) override { // *-----------------* // * IO // *-----------------* m_DecisionForestIO = new mitk::RandomForestFileIO(); m_DummyLsetReader = new mitk::DummyLsetFileReader(); } - void Unload(us::ModuleContext*) + void Unload(us::ModuleContext*) override { delete m_DecisionForestIO; delete m_DummyLsetReader; } private: mitk::RandomForestFileIO * m_DecisionForestIO; mitk::DummyLsetFileReader * m_DummyLsetReader; }; } US_EXPORT_MODULE_ACTIVATOR(mitk::ModuleActivator) diff --git a/Modules/Classification/CLVigraRandomForest/test/mitkVigraRandomForestTest.cpp b/Modules/Classification/CLVigraRandomForest/test/mitkVigraRandomForestTest.cpp index 9327552672..92e3ed1295 100644 --- a/Modules/Classification/CLVigraRandomForest/test/mitkVigraRandomForestTest.cpp +++ b/Modules/Classification/CLVigraRandomForest/test/mitkVigraRandomForestTest.cpp @@ -1,327 +1,327 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include #include #include "mitkIOUtil.h" #include "itkArray2D.h" #include #include #include #include #include #include #include class mitkVigraRandomForestTestSuite : public mitk::TestFixture { CPPUNIT_TEST_SUITE(mitkVigraRandomForestTestSuite ); // MITK_TEST(Load_RandomForestBaseDataUsingIOUtil_shouldReturnTrue); // MITK_TEST(Save_RandomForestBaseDataUsingIOUtil_shouldReturnTrue); // MITK_TEST(LoadWithMitkOptions_RandomForestBaseDataUsingIOUtil_shouldReturnTrue); // MITK_TEST(SaveWithMitkOptions_RandomForestBaseDataUsingIOUtil_shouldReturnTrue); MITK_TEST(TrainThreadedDecisionForest_MatlabDataSet_shouldReturnTrue); MITK_TEST(PredictWeightedDecisionForest_SetWeightsToZero_shouldReturnTrue); MITK_TEST(TrainThreadedDecisionForest_BreastCancerDataSet_shouldReturnTrue); CPPUNIT_TEST_SUITE_END(); private: typedef Eigen::Matrix MatrixDoubleType; typedef Eigen::Matrix MatrixIntType; std::pair FeatureData_Cancer; std::pair LabelData_Cancer; std::pair FeatureData_Matlab; std::pair LabelData_Matlab; mitk::VigraRandomForestClassifier::Pointer classifier; public: // ------------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------------ - void setUp() + void setUp() override { FeatureData_Cancer = convertCSVToMatrix(GetTestDataFilePath("Classification/FeaturematrixBreastcancer.csv"),';',0.5,true); LabelData_Cancer = convertCSVToMatrix(GetTestDataFilePath("Classification/LabelmatrixBreastcancer.csv"),';',0.5,false); FeatureData_Matlab = convertCSVToMatrix(GetTestDataFilePath("Classification/FeaturematrixMatlab.csv"),';',0.5,true); LabelData_Matlab = convertCSVToMatrix(GetTestDataFilePath("Classification/LabelmatrixMatlab.csv"),';',0.5,false); classifier = mitk::VigraRandomForestClassifier::New(); } - void tearDown() + void tearDown() override { classifier = nullptr; } // ------------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------------ /* Train the classifier with an exampledataset of mattlab. Note: The included data are gaußan normaldistributed. */ void TrainThreadedDecisionForest_MatlabDataSet_shouldReturnTrue() { auto & Features_Training = FeatureData_Matlab.first; auto & Labels_Training = LabelData_Matlab.first; auto & Features_Testing = FeatureData_Matlab.second; auto & Labels_Testing = LabelData_Matlab.second; /* Train the classifier, by giving trainingdataset for the labels and features. The result in an colunmvector of the labels.*/ classifier->Train(Features_Training,Labels_Training); Eigen::MatrixXi classes = classifier->Predict(Features_Testing); /* Testing the matching between the calculated colunmvector and the result of the RandomForest */ unsigned int testmatrix_rows = classes.rows(); unsigned int correctly_classified_rows = 0; for(unsigned int i= 0; i < testmatrix_rows; i++){ if(classes(i,0) == Labels_Testing(i,0)){ correctly_classified_rows++; } } MITK_TEST_CONDITION(correctly_classified_rows == testmatrix_rows, "Matlab Data correctly classified"); } // ------------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------------ /* Train the classifier with the dataset of breastcancer patients from the LibSVM Libary */ void TrainThreadedDecisionForest_BreastCancerDataSet_shouldReturnTrue() { auto & Features_Training = FeatureData_Cancer.first; auto & Features_Testing = FeatureData_Cancer.second; auto & Labels_Training = LabelData_Cancer.first; auto & Labels_Testing = LabelData_Cancer.second; /* Train the classifier, by giving trainingdataset for the labels and features. The result in an colunmvector of the labels.*/ classifier->Train(Features_Training,Labels_Training); Eigen::MatrixXi classes = classifier->Predict(Features_Testing); /* Testing the matching between the calculated colunmvector and the result of the RandomForest */ unsigned int maxrows = classes.rows(); int count = 0; for(unsigned int i= 0; i < maxrows; i++){ if(classes(i,0) == Labels_Testing(i,0)){ count++; } } MITK_TEST_CONDITION(isIntervall(Labels_Testing,classes,98,99),"Testvalue of cancer data set is in range."); } // ------------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------------ void PredictWeightedDecisionForest_SetWeightsToZero_shouldReturnTrue() { auto & Features_Training = FeatureData_Matlab.first; auto & Features_Testing = FeatureData_Matlab.second; auto & Labels_Training = LabelData_Matlab.first; // auto & Labels_Testing = LabelData_Matlab.second; classifier->Train(Features_Training,Labels_Training); // get weights type resize it and set all weights to zero auto weights = classifier->GetTreeWeights(); weights.resize(classifier->GetRandomForest().tree_count(),1); weights.fill(0); classifier->SetTreeWeights(weights); // if all wieghts zero the missclassification rate mus be high Eigen::MatrixXi classes = classifier->PredictWeighted(Features_Testing); /* Testing the matching between the calculated colunmvector and the result of the RandomForest */ unsigned int maxrows = classes.rows(); unsigned int count = 0; // check if all predictions are of class 1 for(unsigned int i= 0; i < maxrows; i++) if(classes(i,0) == 1) count++; MITK_TEST_CONDITION( (count == maxrows) ,"Weighted prediction - weights applied (all weights = 0)."); } // ------------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------------ /*Reading an file, which includes the trainingdataset and the testdataset, and convert the content of the file into an 2dim matrixpair. There are an delimiter, which separates the matrix into an trainingmatrix and testmatrix */ template std::pair,Eigen::Matrix >convertCSVToMatrix(const std::string &path, char delimiter,double range, bool isXMatrix) { typename itk::CSVArray2DFileReader::Pointer fr = itk::CSVArray2DFileReader::New(); fr->SetFileName(path); fr->SetFieldDelimiterCharacter(delimiter); fr->HasColumnHeadersOff(); fr->HasRowHeadersOff(); fr->Parse(); try{ fr->Update(); }catch(itk::ExceptionObject& ex){ cout << "Exception caught!" << std::endl; cout << ex << std::endl; } typename itk::CSVArray2DDataObject::Pointer p = fr->GetOutput(); unsigned int maxrowrange = p->GetMatrix().rows(); unsigned int c = p->GetMatrix().cols(); unsigned int percentRange = (unsigned int)(maxrowrange*range); if(isXMatrix == true){ Eigen::Matrix trainMatrixX(percentRange,c); Eigen::Matrix testMatrixXPredict(maxrowrange-percentRange,c); for(unsigned int row = 0; row < percentRange; row++){ for(unsigned int col = 0; col < c; col++){ trainMatrixX(row,col) = p->GetData(row,col); } } for(unsigned int row = percentRange; row < maxrowrange; row++){ for(unsigned int col = 0; col < c; col++){ testMatrixXPredict(row-percentRange,col) = p->GetData(row,col); } } return std::make_pair(trainMatrixX,testMatrixXPredict); } else{ Eigen::Matrix trainLabelMatrixY(percentRange,c); Eigen::Matrix testMatrixYPredict(maxrowrange-percentRange,c); for(unsigned int row = 0; row < percentRange; row++){ for(unsigned int col = 0; col < c; col++){ trainLabelMatrixY(row,col) = p->GetData(row,col); } } for(unsigned int row = percentRange; row < maxrowrange; row++){ for(unsigned int col = 0; col < c; col++){ testMatrixYPredict(row-percentRange,col) = p->GetData(row,col); } } return std::make_pair(trainLabelMatrixY,testMatrixYPredict); } } /* Reading an csv-data and transfer the included datas into an matrix. */ template Eigen::Matrix readCsvData(const std::string &path, char delimiter) { typename itk::CSVArray2DFileReader::Pointer fr = itk::CSVArray2DFileReader::New(); fr->SetFileName(path); fr->SetFieldDelimiterCharacter(delimiter); fr->HasColumnHeadersOff(); fr->HasRowHeadersOff(); fr->Parse(); try{ fr->Update(); }catch(itk::ExceptionObject& ex){ cout << "Exception caught!" << std::endl; cout << ex << std::endl; } typename itk::CSVArray2DDataObject::Pointer p = fr->GetOutput(); unsigned int maxrowrange = p->GetMatrix().rows(); unsigned int maxcols = p->GetMatrix().cols(); Eigen::Matrix matrix(maxrowrange,maxcols); for(unsigned int rows = 0; rows < maxrowrange; rows++){ for(unsigned int cols = 0; cols < maxcols; cols++ ){ matrix(rows,cols) = p->GetData(rows,cols); } } return matrix; } /* Write the content of the array into an own csv-data in the following sequence: root.csv: 1 2 3 0 0 4 writen.csv: 1 1:2 2:3 3:0 4:0 5:4 */ template void writeMatrixToCsv(Eigen::Matrix paramMatrix,const std::string &path) { std::ofstream outputstream (path,std::ofstream::out); // 682 if(outputstream.is_open()){ for(int i = 0; i < paramMatrix.rows(); i++){ outputstream << paramMatrix(i,0); for(int j = 1; j < 11; j++){ outputstream << " " << j << ":" << paramMatrix(i,j); } outputstream << endl; } outputstream.close(); } else{ cout << "Unable to write into CSV" << endl; } } // Method for intervalltesting template bool isIntervall(Eigen::Matrix expected, Eigen::Matrix actual, double lowrange, double toprange) { bool isInIntervall = false; int count = 0; unsigned int rowRange = expected.rows(); unsigned int colRange = expected.cols(); for(unsigned int i = 0; i < rowRange; i++){ for(unsigned int j = 0; j < colRange; j++){ if(expected(i,j) == actual(i,j)){ count++; } } double valueOfMatch = 100*count/(double)(rowRange); if((lowrange <= valueOfMatch) && (toprange >= valueOfMatch)){ isInIntervall = true; } } return isInIntervall; } }; MITK_TEST_SUITE_REGISTRATION(mitkVigraRandomForest) diff --git a/Modules/DicomUI/include/QmitkDicomExternalDataWidget.h b/Modules/DicomUI/include/QmitkDicomExternalDataWidget.h index 6ca4a23394..e5159dc0ce 100644 --- a/Modules/DicomUI/include/QmitkDicomExternalDataWidget.h +++ b/Modules/DicomUI/include/QmitkDicomExternalDataWidget.h @@ -1,118 +1,118 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QmitkDicomExternalDataWidget_h #define QmitkDicomExternalDataWidget_h #include "ui_QmitkDicomExternalDataWidgetControls.h" #include // include ctk #include #include // include QT #include #include #include #include #include #include #include class ctkFileDialog; /** * \brief QmitkDicomExternalDataWidget is a QWidget providing functionality for dicom import. * * \sa QmitkFunctionality * \ingroup Functionalities */ class MITKDICOMUI_EXPORT QmitkDicomExternalDataWidget : public QWidget { // this is needed for all Qt objects that should have a Qt meta-object // (everything that derives from QObject and wants to have signal/slots) Q_OBJECT public: static const std::string Widget_ID; /** * \brief QmitkDicomExternalDataWidget(QWidget *parent) constructor. * * \param parent is a pointer to the parent widget */ QmitkDicomExternalDataWidget(QWidget *parent); /** * \brief QmitkDicomExternalDataWidget destructor. */ - virtual ~QmitkDicomExternalDataWidget(); + ~QmitkDicomExternalDataWidget() override; /** * \brief CreateQtPartControl(QWidget *parent) sets the view objects from ui_QmitkDicomExternalDataWidgetControls.h. * * \param parent is a pointer to the parent widget */ virtual void CreateQtPartControl(QWidget *parent); /** * \brief Initializes the widget. This method has to be called before widget can start. */ void Initialize(); signals: /// @brief emitted when import into database is finished. void SignalStartDicomImport(const QStringList &); /// @brief emitted when view button is clicked. void SignalDicomToDataManager(QHash); public slots: /// @brief Called when download button was clicked. void OnDownloadButtonClicked(); /// @brief Called when view button was clicked. void OnViewButtonClicked(); /// @brief Called when adding a dicom directory. Starts a thread adding the directory. void OnStartDicomImport(const QString &); void OnSeriesSelectionChanged(const QStringList &s); protected: /// \brief Get the list of filepath from current selected index in TreeView. All file paths referring to the index /// will be returned. QStringList GetFileNamesFromIndex(); /// \brief SetupImportDialog Sets up import dialog. void SetupImportDialog(); void SetupProgressDialog(); ctkDICOMDatabase *m_ExternalDatabase; ctkDICOMIndexer *m_ExternalIndexer; ctkFileDialog *m_ImportDialog; QProgressDialog *m_ProgressDialog; QString m_LastImportDirectory; Ui::QmitkDicomExternalDataWidgetControls *m_Controls; }; #endif // _QmitkDicomExternalDataWidget_H_INCLUDED diff --git a/Modules/DicomUI/include/QmitkDicomLocalStorageWidget.h b/Modules/DicomUI/include/QmitkDicomLocalStorageWidget.h index 475944297c..4cc5d29286 100644 --- a/Modules/DicomUI/include/QmitkDicomLocalStorageWidget.h +++ b/Modules/DicomUI/include/QmitkDicomLocalStorageWidget.h @@ -1,121 +1,121 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QmitkDicomLocalStorageWidget_h #define QmitkDicomLocalStorageWidget_h // #include #include "ui_QmitkDicomLocalStorageWidgetControls.h" #include // include ctk #include #include #include // include QT #include #include #include #include #include class QProgressDialog; class QLabel; /** * \brief QmitkDicomLocalStorageWidget is a QWidget providing functionality for dicom storage and import. * * \sa QmitkFunctionality * \ingroup Functionalities */ class MITKDICOMUI_EXPORT QmitkDicomLocalStorageWidget : public QWidget { // this is needed for all Qt objects that should have a Qt meta-object // (everything that derives from QObject and wants to have signal/slots) Q_OBJECT public: static const std::string Widget_ID; /** * \brief QmitkDicomLocalStorageWidget(QWidget *parent) constructor. * * \param parent is a pointer to the parent widget */ QmitkDicomLocalStorageWidget(QWidget *parent); /** * \brief QmitkDicomExternalDataWidget destructor. */ - virtual ~QmitkDicomLocalStorageWidget(); + ~QmitkDicomLocalStorageWidget() override; /** * \brief CreateQtPartControl(QWidget *parent) sets the view objects from ui_QmitkDicomExternalDataWidgetControls.h. * * \param parent is a pointer to the parent widget */ virtual void CreateQtPartControl(QWidget *parent); /** * \brief SetDatabaseDirectory sets database directory. * * \param newDatabaseDirectory contains path to new database directoy. */ void SetDatabaseDirectory(QString newDatabaseDirectory); signals: /// @brief emitted when import into database is finished. void SignalFinishedImport(); /** * @brief emitted when view button is clicked. * @param QHash containing dicom UIDs properties. */ void SignalDicomToDataManager(QHash); /// \brief emitted if cancel button is pressed. void SignalCancelImport(); public slots: /// @brief Called when view button was clicked. void OnViewButtonClicked(); /// @brief Called delete button was clicked. void OnDeleteButtonClicked(); /// @brief Called when adding a dicom directory. Starts a thread adding the directory. void OnStartDicomImport(const QString &dicomData); /// @brief Called when adding a list of dicom files. Starts a thread adding the dicom files. void OnStartDicomImport(const QStringList &dicomData); /// @brief Called when the selection in the series table has changed void OnSeriesSelectionChanged(const QStringList &); protected: void SetDatabase(QString databaseFile); bool DeletePatients(); bool DeleteStudies(); bool DeleteSeries(); ctkDICOMDatabase *m_LocalDatabase; ctkDICOMIndexer *m_LocalIndexer; Ui::QmitkDicomLocalStorageWidgetControls *m_Controls; }; #endif // _QmitkDicomLocalStorageWidget_H_INCLUDED diff --git a/Modules/DiffusionImaging/Connectomics/Testing/mitkCorrelationCalculatorTest.cpp b/Modules/DiffusionImaging/Connectomics/Testing/mitkCorrelationCalculatorTest.cpp index a99c39ab3d..5994cc9922 100644 --- a/Modules/DiffusionImaging/Connectomics/Testing/mitkCorrelationCalculatorTest.cpp +++ b/Modules/DiffusionImaging/Connectomics/Testing/mitkCorrelationCalculatorTest.cpp @@ -1,294 +1,294 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ // Testing #include "mitkTestingMacros.h" #include "mitkTestFixture.h" // std includes #include // MITK includes #include "mitkCorrelationCalculator.h" #include #include #include #include // VTK includes #include class mitkCorrelationCalculatorTestSuite : public mitk::TestFixture { CPPUNIT_TEST_SUITE(mitkCorrelationCalculatorTestSuite); /// \todo Fix VTK memory leaks. Bug 18097. vtkDebugLeaks::SetExitError(0); MITK_TEST(CalculateWholeCorrelation); MITK_TEST(CalculateParcelCorrelation); CPPUNIT_TEST_SUITE_END(); private: mitk::Image::Pointer m_ParcellationImage; mitk::Image::Pointer m_TimeSeriesImage; public: /** * @brief Setup Always call this method before each Test-case to ensure correct and new intialization of the used members for a new test case. (If the members are not used in a test, the method does not need to be called). */ - void setUp() + void setUp() override { // The setup is somewhat cumbersome, due to the fact, that the mitk-itk conversion // functions do not play nicely with 4D images //create test images itk::Image::Pointer timeSeriesTestImage = itk::Image::New(); itk::Image::RegionType timeSeriesTestRegion; itk::Image::IndexType timeSeriesTestIndex; itk::Image::SizeType timeSeriesTestSize; timeSeriesTestIndex[0] = 0; timeSeriesTestIndex[1] = 0; timeSeriesTestIndex[2] = 0; timeSeriesTestIndex[3] = 0; timeSeriesTestSize[0] = 3; timeSeriesTestSize[1] = 3; timeSeriesTestSize[2] = 3; timeSeriesTestSize[3] = 10; timeSeriesTestRegion.SetIndex(timeSeriesTestIndex); timeSeriesTestRegion.SetSize(timeSeriesTestSize); timeSeriesTestImage->SetRegions(timeSeriesTestRegion); timeSeriesTestImage->Allocate(); timeSeriesTestImage->FillBuffer(0); timeSeriesTestImage->Update(); itk::Image::Pointer parcellationTestImage = itk::Image::New(); itk::Image::RegionType parcellationTestRegion; itk::Image::IndexType parcellationTestIndex; itk::Image::SizeType parcellationTestSize; parcellationTestIndex[0] = 0; parcellationTestIndex[1] = 0; parcellationTestIndex[2] = 0; parcellationTestSize[0] = 3; parcellationTestSize[1] = 3; parcellationTestSize[2] = 3; parcellationTestRegion.SetIndex(parcellationTestIndex); parcellationTestRegion.SetSize(parcellationTestSize); parcellationTestImage->SetRegions(parcellationTestRegion); parcellationTestImage->Allocate(); //Fill test images with values mitk::Image::Pointer tsTestImage = mitk::Image::New(); mitk::GrabItkImageMemory( timeSeriesTestImage, tsTestImage.GetPointer() ); mitk::Image::Pointer pTestImage = mitk::Image::New(); mitk::GrabItkImageMemory( parcellationTestImage, pTestImage.GetPointer()); //divide parcellation image into 3 different parcels for( int loop(0); loop < 27; ++loop) { itk::Image::IndexType parcellationIndex; parcellationIndex[2] = (loop / 9); parcellationIndex[1] = (loop / 3) % 3; parcellationIndex[0] = loop % 3; if(loop < 9) { parcellationTestImage->SetPixel(parcellationIndex, 1); } else if( loop < 15 || (loop > 17 && loop < 21) ) { parcellationTestImage->SetPixel(parcellationIndex, 2); } else { parcellationTestImage->SetPixel(parcellationIndex, 3); } } mitk::ImagePixelWriteAccessor writeAccess( tsTestImage ); //fill time series image with similar time series in each parcel for( int loop(0); loop < 270; ++loop) { itk::Image::IndexType timeSeriesIndex; timeSeriesIndex[3] = (loop / 27); timeSeriesIndex[2] = (loop / 9) % 3; timeSeriesIndex[1] = (loop / 3) % 3; timeSeriesIndex[0] = loop % 3; itk::Image::IndexType parcellationIndex; parcellationIndex[2] = (loop / 9) % 3; parcellationIndex[1] = (loop / 3) % 3; parcellationIndex[0] = loop % 3; if( mitk::Equal(parcellationTestImage->GetPixel(parcellationIndex), 1) ) { writeAccess.SetPixelByIndex(timeSeriesIndex, 1 + loop); } else if( mitk::Equal(parcellationTestImage->GetPixel(parcellationIndex), 2) ) { writeAccess.SetPixelByIndex(timeSeriesIndex, 1 + (loop % 13 - loop % 11) ); } else { writeAccess.SetPixelByIndex(timeSeriesIndex, 1 + ( loop - loop % 2) ); } } //end create test images m_ParcellationImage = pTestImage; m_TimeSeriesImage = tsTestImage; } - void tearDown() + void tearDown() override { m_ParcellationImage = nullptr; m_TimeSeriesImage = nullptr; } void CalculateWholeCorrelation() { mitk::CorrelationCalculator::Pointer correlationCalculator = mitk::CorrelationCalculator::New(); correlationCalculator->SetTimeSeriesImage( m_TimeSeriesImage ); correlationCalculator->DoWholeCorrelation(); const vnl_matrix< double >* cM = correlationCalculator->GetCorrelationMatrix(); bool equal(true); // instead of checking the entire 27 x 27 matrix // just check 3 values and assume if they are equal entire // matrix is likely to be equal if( std::abs((*cM)[0][0] - 1) > 0.00001 ) { equal = false; } if( std::abs((*cM)[2][10] - 0.00828941) > 0.00001 ) { equal = false; } if( std::abs((*cM)[14][8] - 0.636613) > 0.00001 ) { equal = false; } CPPUNIT_ASSERT_MESSAGE( "Comparing created and reference correlation matrix sample points.", equal ); } void CalculateParcelCorrelation() { mitk::CorrelationCalculator::Pointer correlationCalculator = mitk::CorrelationCalculator::New(); correlationCalculator->SetTimeSeriesImage( m_TimeSeriesImage ); correlationCalculator->SetParcellationImage( m_ParcellationImage ); correlationCalculator->DoParcelCorrelation(); const vnl_matrix< double >* cM = correlationCalculator->GetCorrelationMatrix(); bool equal(true); // diagonal should be 1 if( std::abs((*cM)[0][0] - 1) > 0.00001 ) { equal = false; } if( std::abs((*cM)[1][1] - 1) > 0.00001 ) { equal = false; } if( std::abs((*cM)[2][2] - 1) > 0.00001 ) { equal = false; } // parcel 0 and parcel 1 should correlate with -0.431111 if( std::abs((*cM)[1][0] - -0.431111) > 0.00001 ) { equal = false; } if( std::abs((*cM)[0][1] - -0.431111) > 0.00001 ) { equal = false; } // parcel 0 and parcel 2 should correlate with 1 if( std::abs((*cM)[0][2] - 1) > 0.00001 ) { equal = false; } if( std::abs((*cM)[2][0] - 1) > 0.00001 ) { equal = false; } // parcel 1 and parcel 2 should correlate with -0.430522 if( std::abs((*cM)[1][2] - -0.430522) > 0.00001 ) { equal = false; } if( std::abs((*cM)[2][1] - -0.430522) > 0.00001 ) { equal = false; } CPPUNIT_ASSERT_MESSAGE( "Comparing created and reference correlation matrix.", equal ); mitk::ConnectomicsNetwork::Pointer network = correlationCalculator->GetConnectomicsNetwork(); mitk::ConnectomicsNetwork::Pointer refNetwork = mitk::ConnectomicsNetwork::New(); mitk::ConnectomicsNetwork::VertexDescriptorType x = refNetwork->AddVertex( 1 ); mitk::ConnectomicsNetwork::VertexDescriptorType y = refNetwork->AddVertex( 2 ); mitk::ConnectomicsNetwork::VertexDescriptorType z = refNetwork->AddVertex( 3 ); refNetwork->AddEdge(x,y); refNetwork->AddEdge(x,z); refNetwork->AddEdge(y,z); CPPUNIT_ASSERT_MESSAGE( "Comparing created and reference network.", mitk::Equal( network.GetPointer(), refNetwork, mitk::eps, true) ); // check sample parcels for other methods correlationCalculator->DoParcelCorrelation( mitk::CorrelationCalculator::UseAverageCorrelation ); cM = correlationCalculator->GetCorrelationMatrix(); // parcel 0 and parcel 1 should correlate with -0.0643023 equal = true; if( std::abs((*cM)[1][0] - -0.0643023) > 0.00001 ) { equal = false; } // parcel 0 and parcel 2 should correlate with 0.99998 if( std::abs((*cM)[2][0] - 0.99998) > 0.00001 ) { equal = false; } CPPUNIT_ASSERT_MESSAGE( "Comparing sample parcel correlation for average correlation.", equal ); correlationCalculator->DoParcelCorrelation( mitk::CorrelationCalculator::UseMaximumCorrelation ); cM = correlationCalculator->GetCorrelationMatrix(); // parcel 0 and parcel 1 should correlate with 0.636613 equal = true; if( std::abs((*cM)[1][0] - 0.636613) > 0.00001 ) { equal = false; } // parcel 0 and parcel 2 should correlate with 0.99998 if( std::abs((*cM)[2][0] - 0.99998) > 0.00001 ) { equal = false; } CPPUNIT_ASSERT_MESSAGE( "Comparing sample parcel correlation for maximum correlation.", equal ); } }; MITK_TEST_SUITE_REGISTRATION(mitkCorrelationCalculator) diff --git a/Modules/DiffusionImaging/DiffusionCore/src/IODataStructures/Properties/mitkBValueMapPropertySerializer.cpp b/Modules/DiffusionImaging/DiffusionCore/src/IODataStructures/Properties/mitkBValueMapPropertySerializer.cpp index b35e47a093..fe9d8dd741 100644 --- a/Modules/DiffusionImaging/DiffusionCore/src/IODataStructures/Properties/mitkBValueMapPropertySerializer.cpp +++ b/Modules/DiffusionImaging/DiffusionCore/src/IODataStructures/Properties/mitkBValueMapPropertySerializer.cpp @@ -1,131 +1,131 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef mitkBValueMapPropertySerializer_h_included #define mitkBValueMapPropertySerializer_h_included #include "mitkBasePropertySerializer.h" #include "mitkBValueMapProperty.h" #include namespace mitk { class MITKDIFFUSIONCORE_EXPORT BValueMapPropertySerializer : public BasePropertySerializer { protected: void split(const std::string &s, char delim, std::vector &elems) { std::stringstream ss(s); std::string item; while (std::getline(ss, item, delim)) { elems.push_back(std::atoi(item.c_str())); } } std::vector split(const std::string &s, char delim) { std::vector elems; split(s, delim, elems); return elems; } public: mitkClassMacro( BValueMapPropertySerializer, BasePropertySerializer ) itkFactorylessNewMacro(Self) itkCloneMacro(Self) - virtual TiXmlElement* Serialize() override + TiXmlElement* Serialize() override { if (const BValueMapProperty* prop = dynamic_cast(m_Property.GetPointer())) { BValueMapProperty::BValueMap map = prop->GetBValueMap(); if(map.empty()) return nullptr; BValueMapProperty::BValueMap::const_iterator it = map.begin(); BValueMapProperty::BValueMap::const_iterator end = map.end(); auto element = new TiXmlElement("bvaluemap"); while (it != end) { auto child = new TiXmlElement("entry"); { std::stringstream ss; ss << it->first; child->SetAttribute("key", ss.str()); } { std::stringstream ss; for(unsigned int i = 0 ; i < it->second.size(); i++) { ss << it->second[i] << ","; } child->SetAttribute("value", ss.str()); } element->InsertEndChild(*child); ++it; } return element; } else return nullptr; } - virtual BaseProperty::Pointer Deserialize(TiXmlElement* element) override + BaseProperty::Pointer Deserialize(TiXmlElement* element) override { if (!element) return nullptr; BValueMapProperty::BValueMap map; TiXmlElement* entry = element->FirstChildElement( "entry" )->ToElement(); while(entry != nullptr){ std::string key, value; entry->QueryStringAttribute("key",&key); entry->QueryStringAttribute("value",&value); std::vector indices = split(value.c_str(), ','); map[std::atoi(key.c_str())] = indices; entry = entry->NextSiblingElement( "entry" ); } return BValueMapProperty::New(map).GetPointer(); } protected: BValueMapPropertySerializer(){} - virtual ~BValueMapPropertySerializer() {} + ~BValueMapPropertySerializer() override {} }; } // namespace // important to put this into the GLOBAL namespace (because it starts with 'namespace mitk') MITK_REGISTER_SERIALIZER(BValueMapPropertySerializer) #endif diff --git a/Modules/DiffusionImaging/DiffusionCore/src/IODataStructures/Properties/mitkGradientDirectionsPropertySerializer.cpp b/Modules/DiffusionImaging/DiffusionCore/src/IODataStructures/Properties/mitkGradientDirectionsPropertySerializer.cpp index baab368393..320b76cd4f 100644 --- a/Modules/DiffusionImaging/DiffusionCore/src/IODataStructures/Properties/mitkGradientDirectionsPropertySerializer.cpp +++ b/Modules/DiffusionImaging/DiffusionCore/src/IODataStructures/Properties/mitkGradientDirectionsPropertySerializer.cpp @@ -1,106 +1,106 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef mitkGradientDirectionPropertySerializer_h_included #define mitkGradientDirectionPropertySerializer_h_included #include "mitkBasePropertySerializer.h" #include "mitkGradientDirectionsProperty.h" #include "MitkDiffusionCoreExports.h" namespace mitk { class MITKDIFFUSIONCORE_EXPORT GradientDirectionsPropertySerializer : public BasePropertySerializer { public: mitkClassMacro( GradientDirectionsPropertySerializer, BasePropertySerializer ) itkFactorylessNewMacro(Self) itkCloneMacro(Self) - virtual TiXmlElement* Serialize() override + TiXmlElement* Serialize() override { if (const GradientDirectionsProperty* prop = dynamic_cast(m_Property.GetPointer())) { typedef mitk::GradientDirectionsProperty::GradientDirectionsContainerType GradientDirectionsContainerType; GradientDirectionsContainerType::Pointer gdc = prop->GetGradientDirectionsContainer().GetPointer(); if(gdc.IsNull() || gdc->Size() == 0) return nullptr; GradientDirectionsContainerType::Iterator it = gdc->Begin(); GradientDirectionsContainerType::Iterator end = gdc->End(); auto element = new TiXmlElement("gradientdirections"); while (it != end) { auto child = new TiXmlElement("entry"); std::stringstream ss; ss << it.Value(); child->SetAttribute("value", ss.str()); element->InsertEndChild(*child); ++it; } return element; } else return nullptr; } - virtual BaseProperty::Pointer Deserialize(TiXmlElement* element) override + BaseProperty::Pointer Deserialize(TiXmlElement* element) override { if (!element) return nullptr; mitk::GradientDirectionsProperty::GradientDirectionsContainerType::Pointer gdc; gdc = mitk::GradientDirectionsProperty::GradientDirectionsContainerType::New(); TiXmlElement* entry = element->FirstChildElement( "entry" )->ToElement(); while(entry != nullptr){ std::stringstream ss; std::string value; entry->QueryStringAttribute("value",&value); ss << value; vnl_vector_fixed vector; vector.read_ascii(ss); gdc->push_back(vector); entry = entry->NextSiblingElement( "entry" ); } return GradientDirectionsProperty::New(gdc).GetPointer(); } protected: GradientDirectionsPropertySerializer() {} - virtual ~GradientDirectionsPropertySerializer() {} + ~GradientDirectionsPropertySerializer() override {} }; } // namespace // important to put this into the GLOBAL namespace (because it starts with 'namespace mitk') MITK_REGISTER_SERIALIZER(GradientDirectionsPropertySerializer) #endif diff --git a/Modules/DiffusionImaging/DiffusionCore/src/IODataStructures/Properties/mitkMeasurementFramePropertySerializer.cpp b/Modules/DiffusionImaging/DiffusionCore/src/IODataStructures/Properties/mitkMeasurementFramePropertySerializer.cpp index 7f1e101aeb..937ba5013c 100644 --- a/Modules/DiffusionImaging/DiffusionCore/src/IODataStructures/Properties/mitkMeasurementFramePropertySerializer.cpp +++ b/Modules/DiffusionImaging/DiffusionCore/src/IODataStructures/Properties/mitkMeasurementFramePropertySerializer.cpp @@ -1,89 +1,89 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef mitkMeasurementFramePropertySerializer_h_included #define mitkMeasurementFramePropertySerializer_h_included #include "mitkBasePropertySerializer.h" #include "mitkMeasurementFrameProperty.h" #include namespace mitk { class MITKDIFFUSIONCORE_EXPORT MeasurementFramePropertySerializer : public BasePropertySerializer { public: mitkClassMacro( MeasurementFramePropertySerializer, BasePropertySerializer ) itkFactorylessNewMacro(Self) itkCloneMacro(Self) - virtual TiXmlElement* Serialize() override + TiXmlElement* Serialize() override { if (const MeasurementFrameProperty* prop = dynamic_cast(m_Property.GetPointer())) { typedef mitk::MeasurementFrameProperty::MeasurementFrameType MeasurementFrameType; const MeasurementFrameType & mft = prop->GetMeasurementFrame(); if(mft.is_zero()) return nullptr; auto element = new TiXmlElement("measurementframe"); auto child = new TiXmlElement("entry"); std::stringstream ss; ss << mft; child->SetAttribute("value", ss.str()); element->InsertEndChild(*child); return element; } else return nullptr; } - virtual BaseProperty::Pointer Deserialize(TiXmlElement* element) override + BaseProperty::Pointer Deserialize(TiXmlElement* element) override { if (!element) return nullptr; TiXmlElement* entry = element->FirstChildElement( "entry" )->ToElement(); std::stringstream ss; std::string value; entry->QueryStringAttribute("value",&value); ss << value; MeasurementFrameProperty::MeasurementFrameType matrix; matrix.read_ascii(ss); return MeasurementFrameProperty::New(matrix).GetPointer(); } protected: MeasurementFramePropertySerializer() {} - virtual ~MeasurementFramePropertySerializer() {} + ~MeasurementFramePropertySerializer() override {} }; } // namespace // important to put this into the GLOBAL namespace (because it starts with 'namespace mitk') MITK_REGISTER_SERIALIZER(MeasurementFramePropertySerializer) #endif diff --git a/Modules/DiffusionImaging/DiffusionIO/mitkFiberBundleMapper2D.cpp b/Modules/DiffusionImaging/DiffusionIO/mitkFiberBundleMapper2D.cpp index f6dcea7777..521dae66a5 100644 --- a/Modules/DiffusionImaging/DiffusionIO/mitkFiberBundleMapper2D.cpp +++ b/Modules/DiffusionImaging/DiffusionIO/mitkFiberBundleMapper2D.cpp @@ -1,276 +1,276 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "mitkFiberBundleMapper2D.h" #include "mitkBaseRenderer.h" #include "mitkDataNode.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include class vtkShaderCallback : public vtkCommand { public: static vtkShaderCallback *New() { return new vtkShaderCallback; } mitk::BaseRenderer *renderer; mitk::DataNode *node; - virtual void Execute(vtkObject *, unsigned long, void*cbo) + void Execute(vtkObject *, unsigned long, void*cbo) override { vtkOpenGLHelper *cellBO = reinterpret_cast(cbo); float fiberOpacity; bool fiberFading = false; float fiberThickness = 0.0; node->GetOpacity(fiberOpacity, nullptr); node->GetFloatProperty("Fiber2DSliceThickness", fiberThickness); node->GetBoolProperty("Fiber2DfadeEFX", fiberFading); cellBO->Program->SetUniformf("fiberOpacity", fiberOpacity); cellBO->Program->SetUniformi("fiberFadingON", fiberFading); cellBO->Program->SetUniformf("fiberThickness", fiberThickness); if (this->renderer) { //get information about current position of views mitk::SliceNavigationController::Pointer sliceContr = renderer->GetSliceNavigationController(); mitk::PlaneGeometry::ConstPointer planeGeo = sliceContr->GetCurrentPlaneGeometry(); //generate according cutting planes based on the view position float planeNormal[3]; planeNormal[0] = planeGeo->GetNormal()[0]; planeNormal[1] = planeGeo->GetNormal()[1]; planeNormal[2] = planeGeo->GetNormal()[2]; float tmp1 = planeGeo->GetOrigin()[0] * planeNormal[0]; float tmp2 = planeGeo->GetOrigin()[1] * planeNormal[1]; float tmp3 = planeGeo->GetOrigin()[2] * planeNormal[2]; float thickness = tmp1 + tmp2 + tmp3; //attention, correct normalvector float* a = new float[4]; for (int i = 0; i < 3; ++i) a[i] = planeNormal[i]; a[3] = thickness; cellBO->Program->SetUniform4f("slicingPlane", a); } } vtkShaderCallback() { this->renderer = 0; } }; mitk::FiberBundleMapper2D::FiberBundleMapper2D() : m_LineWidth(1) { m_lut = vtkLookupTable::New(); m_lut->Build(); } mitk::FiberBundleMapper2D::~FiberBundleMapper2D() { } mitk::FiberBundle* mitk::FiberBundleMapper2D::GetInput() { return dynamic_cast< mitk::FiberBundle * > ( GetDataNode()->GetData() ); } void mitk::FiberBundleMapper2D::Update(mitk::BaseRenderer * renderer) { bool visible = true; GetDataNode()->GetVisibility(visible, renderer, "visible"); if ( !visible ) return; // Calculate time step of the input data for the specified renderer (integer value) // this method is implemented in mitkMapper this->CalculateTimeStep( renderer ); //check if updates occured in the node or on the display FBXLocalStorage *localStorage = m_LocalStorageHandler.GetLocalStorage(renderer); //set renderer independent shader properties const DataNode::Pointer node = this->GetDataNode(); float thickness = 2.0; if(!this->GetDataNode()->GetPropertyValue("Fiber2DSliceThickness",thickness)) MITK_INFO << "FIBER2D SLICE THICKNESS PROPERTY ERROR"; bool fiberfading = false; if(!this->GetDataNode()->GetPropertyValue("Fiber2DfadeEFX",fiberfading)) MITK_INFO << "FIBER2D SLICE FADE EFX PROPERTY ERROR"; mitk::FiberBundle* fiberBundle = this->GetInput(); if (fiberBundle==nullptr) return; int lineWidth = 0; node->GetIntProperty("LineWidth", lineWidth); if (m_LineWidth!=lineWidth) { m_LineWidth = lineWidth; fiberBundle->RequestUpdate2D(); } if ( localStorage->m_LastUpdateTimeGetCurrentWorldPlaneGeometryUpdateTime() || localStorage->m_LastUpdateTimeGetUpdateTime2D() ) { this->UpdateShaderParameter(renderer); this->GenerateDataForRenderer( renderer ); } } void mitk::FiberBundleMapper2D::UpdateShaderParameter(mitk::BaseRenderer *) { // see new vtkShaderCallback } // vtkActors and Mappers are feeded here void mitk::FiberBundleMapper2D::GenerateDataForRenderer(mitk::BaseRenderer *renderer) { mitk::FiberBundle* fiberBundle = this->GetInput(); //the handler of local storage gets feeded in this method with requested data for related renderwindow FBXLocalStorage *localStorage = m_LocalStorageHandler.GetLocalStorage(renderer); mitk::DataNode* node = this->GetDataNode(); if (node == nullptr) return; vtkSmartPointer fiberPolyData = fiberBundle->GetFiberPolyData(); if (fiberPolyData == nullptr) return; fiberPolyData->GetPointData()->AddArray(fiberBundle->GetFiberColors()); localStorage->m_FiberMapper->ScalarVisibilityOn(); localStorage->m_FiberMapper->SetScalarModeToUsePointFieldData(); localStorage->m_FiberMapper->SetLookupTable(m_lut); //apply the properties after the slice was set localStorage->m_PointActor->GetProperty()->SetOpacity(0.999); localStorage->m_FiberMapper->SelectColorArray("FIBER_COLORS"); localStorage->m_FiberMapper->SetInputData(fiberPolyData); localStorage->m_FiberMapper->SetVertexShaderCode( "//VTK::System::Dec\n" "attribute vec4 vertexMC;\n" "//VTK::Normal::Dec\n" "uniform mat4 MCDCMatrix;\n" "//VTK::Color::Dec\n" "varying vec4 positionWorld;\n" "varying vec4 colorVertex;\n" "void main(void)\n" "{\n" " colorVertex = scalarColor;\n" " positionWorld = vertexMC;\n" " gl_Position = MCDCMatrix * vertexMC;\n" "}\n" ); localStorage->m_FiberMapper->SetFragmentShaderCode( "//VTK::System::Dec\n" // always start with this line "//VTK::Output::Dec\n" // always have this line in your FS "uniform vec4 slicingPlane;\n" "uniform float fiberThickness;\n" "uniform int fiberFadingON;\n" "uniform float fiberOpacity;\n" "varying vec4 positionWorld;\n" "varying vec4 colorVertex;\n" "void main(void)\n" "{\n" " float r1 = dot(positionWorld.xyz, slicingPlane.xyz) - slicingPlane.w;\n" " if (abs(r1) >= fiberThickness)\n" " discard;\n" " if (fiberFadingON != 0)\n" " {\n" " float x = (r1 + fiberThickness) / (fiberThickness*2.0);\n" " x = 1.0 - x;\n" " gl_FragColor = vec4(colorVertex.xyz*x, fiberOpacity);\n" " }\n" " else{\n" " gl_FragColor = vec4(colorVertex.xyz,fiberOpacity);\n" " }\n" "}\n" ); vtkSmartPointer myCallback = vtkSmartPointer::New(); myCallback->renderer = renderer; myCallback->node = this->GetDataNode(); localStorage->m_FiberMapper->AddObserver(vtkCommand::UpdateShaderEvent,myCallback); localStorage->m_PointActor->SetMapper(localStorage->m_FiberMapper); localStorage->m_PointActor->GetProperty()->ShadingOn(); localStorage->m_PointActor->GetProperty()->SetLineWidth(m_LineWidth); // We have been modified => save this for next Update() localStorage->m_LastUpdateTime.Modified(); } vtkProp* mitk::FiberBundleMapper2D::GetVtkProp(mitk::BaseRenderer *renderer) { this->Update(renderer); return m_LocalStorageHandler.GetLocalStorage(renderer)->m_PointActor; } void mitk::FiberBundleMapper2D::SetDefaultProperties(mitk::DataNode* node, mitk::BaseRenderer* renderer, bool overwrite) { Superclass::SetDefaultProperties(node, renderer, overwrite); // node->SetProperty("shader",mitk::ShaderProperty::New("mitkShaderFiberClipping")); //add other parameters to propertylist node->AddProperty( "Fiber2DSliceThickness", mitk::FloatProperty::New(1.0f), renderer, overwrite ); node->AddProperty( "Fiber2DfadeEFX", mitk::BoolProperty::New(true), renderer, overwrite ); node->AddProperty( "color", mitk::ColorProperty::New(1.0,1.0,1.0), renderer, overwrite); } mitk::FiberBundleMapper2D::FBXLocalStorage::FBXLocalStorage() { m_PointActor = vtkSmartPointer::New(); m_FiberMapper = vtkSmartPointer::New(); } diff --git a/Modules/DiffusionImaging/DiffusionIO/mitkFiberBundleMapper3D.cpp b/Modules/DiffusionImaging/DiffusionIO/mitkFiberBundleMapper3D.cpp index cde800a462..7401c66929 100644 --- a/Modules/DiffusionImaging/DiffusionIO/mitkFiberBundleMapper3D.cpp +++ b/Modules/DiffusionImaging/DiffusionIO/mitkFiberBundleMapper3D.cpp @@ -1,411 +1,411 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "mitkFiberBundleMapper3D.h" #include #include #include #include #include #include #include #include #include #include #include #include #include class vtkShaderCallback3D : public vtkCommand { public: static vtkShaderCallback3D *New() { return new vtkShaderCallback3D; } mitk::BaseRenderer *renderer; mitk::DataNode *node; - virtual void Execute(vtkObject *, unsigned long, void*cbo) + void Execute(vtkObject *, unsigned long, void*cbo) override { vtkOpenGLHelper *cellBO = reinterpret_cast(cbo); float fiberOpacity; node->GetOpacity(fiberOpacity, nullptr); cellBO->Program->SetUniformf("fiberOpacity", fiberOpacity); if (this->renderer) { mitk::Vector3D plane_vec; node->GetPropertyValue("Fiber3DClippingPlane",plane_vec); float distance = plane_vec.GetNorm(); plane_vec.Normalize(); bool flip; node->GetBoolProperty("Fiber3DClippingPlaneFlip",flip); if (flip) { plane_vec *= -1; distance *= -1; } node->GetBoolProperty("Fiber3DClippingPlaneSecondFlip",flip); if (flip) { plane_vec *= -1; distance *= -1; } float* a = new float[4]; for (int i = 0; i < 3; ++i) a[i] = plane_vec[i]; a[3] = distance; cellBO->Program->SetUniform4f("slicingPlane", a); float v = 1; node->GetFloatProperty("light.ambient", v); cellBO->Program->SetUniformf("ambient", v); node->GetFloatProperty("light.diffuse", v); cellBO->Program->SetUniformf("diffuse", v); node->GetFloatProperty("light.specular", v); cellBO->Program->SetUniformf("intensity", v); node->GetFloatProperty("light.intensity", v); cellBO->Program->SetUniformf("intensity", v); bool enable_light = false; node->GetBoolProperty("light.enable_light", enable_light); cellBO->Program->SetUniformi("enable_light", enable_light); } } vtkShaderCallback3D() { this->renderer = 0; } }; mitk::FiberBundleMapper3D::FiberBundleMapper3D() : m_TubeRadius(0.0) , m_TubeSides(15) , m_LineWidth(1) { m_lut = vtkLookupTable::New(); m_lut->Build(); } mitk::FiberBundleMapper3D::~FiberBundleMapper3D() { } const mitk::FiberBundle* mitk::FiberBundleMapper3D::GetInput() { return static_cast ( GetDataNode()->GetData() ); } /* This method is called once the mapper gets new input, for UI rotation or changes in colorcoding this method is NOT called */ void mitk::FiberBundleMapper3D::InternalGenerateData(mitk::BaseRenderer *renderer) { m_FiberPolyData->GetPointData()->AddArray(m_FiberBundle->GetFiberColors()); float tmpopa; this->GetDataNode()->GetOpacity(tmpopa, nullptr); FBXLocalStorage3D *localStorage = m_LocalStorageHandler.GetLocalStorage(renderer); if (m_TubeRadius>0.0) { vtkSmartPointer tubeFilter = vtkSmartPointer::New(); tubeFilter->SetInputData(m_FiberPolyData); tubeFilter->SetNumberOfSides(m_TubeSides); tubeFilter->SetRadius(m_TubeRadius); tubeFilter->Update(); m_FiberPolyData = tubeFilter->GetOutput(); } else if (m_RibbonWidth>0.0) { vtkSmartPointer tubeFilter = vtkSmartPointer::New(); tubeFilter->SetInputData(m_FiberPolyData); tubeFilter->SetWidth(m_RibbonWidth); tubeFilter->Update(); m_FiberPolyData = tubeFilter->GetOutput(); } if (tmpopa<1) { vtkSmartPointer depthSort = vtkSmartPointer::New(); depthSort->SetInputData( m_FiberPolyData ); depthSort->SetCamera( renderer->GetVtkRenderer()->GetActiveCamera() ); depthSort->SetDirectionToBackToFront(); depthSort->Update(); localStorage->m_FiberMapper->SetInputConnection(depthSort->GetOutputPort()); } else { localStorage->m_FiberMapper->SetInputData(m_FiberPolyData); } if (m_Lighting) { float floatProp = 1.0; GetDataNode()->GetFloatProperty("light.ambient", floatProp); localStorage->m_FiberActor->GetProperty()->SetAmbient(floatProp); GetDataNode()->GetFloatProperty("light.diffuse", floatProp); localStorage->m_FiberActor->GetProperty()->SetDiffuse(floatProp); GetDataNode()->GetFloatProperty("light.specular", floatProp); localStorage->m_FiberActor->GetProperty()->SetSpecular(floatProp); GetDataNode()->GetFloatProperty("light.specularpower", floatProp); localStorage->m_FiberActor->GetProperty()->SetSpecularPower( floatProp ); mitk::ColorProperty* ambientC = dynamic_cast(GetDataNode()->GetProperty("light.ambientcolor")); mitk::ColorProperty* diffuseC = dynamic_cast(GetDataNode()->GetProperty("light.diffusecolor")); mitk::ColorProperty* specularC = dynamic_cast(GetDataNode()->GetProperty("light.specularcolor")); localStorage->m_FiberActor->GetProperty()->SetAmbientColor( ambientC->GetColor()[0], ambientC->GetColor()[1], ambientC->GetColor()[2] ); localStorage->m_FiberActor->GetProperty()->SetDiffuseColor( diffuseC->GetColor()[0], diffuseC->GetColor()[1], diffuseC->GetColor()[2] ); localStorage->m_FiberActor->GetProperty()->SetSpecularColor( specularC->GetColor()[0], specularC->GetColor()[1], specularC->GetColor()[2] ); localStorage->m_FiberActor->GetProperty()->SetLighting(true); } else { localStorage->m_FiberActor->GetProperty()->SetLighting(false); } localStorage->m_FiberMapper->SelectColorArray("FIBER_COLORS"); localStorage->m_FiberMapper->ScalarVisibilityOn(); localStorage->m_FiberMapper->SetScalarModeToUsePointFieldData(); localStorage->m_FiberActor->SetMapper(localStorage->m_FiberMapper); localStorage->m_FiberMapper->SetLookupTable(m_lut); // set Opacity localStorage->m_FiberActor->GetProperty()->SetOpacity((double) tmpopa); localStorage->m_FiberActor->GetProperty()->SetLineWidth(m_LineWidth); localStorage->m_FiberAssembly->AddPart(localStorage->m_FiberActor); localStorage->m_FiberMapper->SetVertexShaderCode( "//VTK::System::Dec\n" "attribute vec4 vertexMC;\n" "//VTK::Normal::Dec\n" "uniform mat4 MCDCMatrix;\n" "uniform mat4 MCVCMatrix;\n" "//VTK::Color::Dec\n" "attribute vec3 normalMC;\n" "uniform mat3 normalMatrix;\n" "varying vec4 positionWorld;\n" "varying vec4 colorVertex;\n" "varying vec3 N;\n" "varying vec4 v;\n" "void main(void)\n" "{\n" " colorVertex = scalarColor;\n" " positionWorld = vertexMC;\n" " v = MCVCMatrix * vertexMC;\n" " mat4 glNormalMatrix = transpose(inverse(MCVCMatrix));\n" " N = normalize(normalMatrix * normalMC);\n" " gl_Position = MCDCMatrix * vertexMC;\n" "}\n" ); localStorage->m_FiberMapper->SetFragmentShaderCode( "//VTK::System::Dec\n" // always start with this line "//VTK::Output::Dec\n" // always have this line in your FS "uniform vec4 slicingPlane;\n" "uniform float fiberOpacity;\n" "uniform float ambient;\n" "uniform float diffuse;\n" "uniform float specular;\n" "uniform float intensity;\n" "uniform int enable_light;\n" "varying vec4 positionWorld;\n" "varying vec4 colorVertex;\n" "varying vec3 N;\n" "varying vec4 v;\n" "void main(void)\n" "{\n" " float r1 = dot(positionWorld.xyz, slicingPlane.xyz) - slicingPlane.w;\n" " if ( r1 > 0 )\n" " discard;\n" " if (enable_light!=0)\n" " {\n" " vec3 L = normalize(-v.xyz);\n" // "normalize(gl_LightSource[0].position.xyz - v.xyz);\n" " vec3 E = normalize(-v.xyz); // we are in Eye Coordinates, so EyePos is (0,0,0)\n" " vec3 R = normalize(-reflect(L,N));\n" //calculate Diffuse Term: " float Idiff = diffuse * max(dot(N,L), 0.0);\n" " Idiff = clamp(Idiff, 0.0, 1.0);\n" // calculate Specular Term: " float Ispec = specular * pow(max(dot(R,E),0.0),0.3);\n" " Ispec = clamp(Ispec, 0.0, 1.0);\n" " gl_FragColor = vec4(colorVertex.xyz, fiberOpacity)*(1-intensity) + vec4(colorVertex.xyz * (ambient + Idiff + Ispec) * intensity, fiberOpacity);\n" " }\n" " else\n" " {\n" " gl_FragColor = vec4(colorVertex.xyz, fiberOpacity);\n" " }\n" "}\n" ); vtkSmartPointer myCallback = vtkSmartPointer::New(); myCallback->renderer = renderer; myCallback->node = this->GetDataNode(); localStorage->m_FiberMapper->AddObserver(vtkCommand::UpdateShaderEvent,myCallback); localStorage->m_LastUpdateTime.Modified(); } void mitk::FiberBundleMapper3D::GenerateDataForRenderer( mitk::BaseRenderer *renderer ) { bool visible = true; GetDataNode()->GetVisibility(visible, renderer, "visible"); if ( !visible ) return; const DataNode* node = this->GetDataNode(); FBXLocalStorage3D* localStorage = m_LocalStorageHandler.GetLocalStorage(renderer); m_FiberBundle = dynamic_cast(node->GetData()); m_FiberPolyData = m_FiberBundle->GetFiberPolyData(); // this->ApplyShaderProperties(renderer, "shader_3d"); // did any rendering properties change? float tubeRadius = 0; node->GetFloatProperty("shape.tuberadius", tubeRadius); if (m_TubeRadius!=tubeRadius) { m_TubeRadius = tubeRadius; m_FiberBundle->RequestUpdate3D(); } int tubeSides = 0; node->GetIntProperty("shape.tubesides", tubeSides); if (m_TubeSides!=tubeSides) { m_TubeSides = tubeSides; m_FiberBundle->RequestUpdate3D(); } int lineWidth = 0; node->GetIntProperty("shape.linewidth", lineWidth); if (m_LineWidth!=lineWidth) { m_LineWidth = lineWidth; m_FiberBundle->RequestUpdate3D(); } float ribbonWidth = 0; node->GetFloatProperty("shape.ribbonwidth", ribbonWidth); if (m_RibbonWidth!=ribbonWidth) { m_RibbonWidth = ribbonWidth; m_FiberBundle->RequestUpdate3D(); } bool lighting = false; node->GetBoolProperty("light.enable", lighting); if (m_Lighting!=lighting) { m_Lighting = lighting; m_FiberBundle->RequestUpdate3D(); } if (localStorage->m_LastUpdateTime>=m_FiberBundle->GetUpdateTime3D()) return; // Calculate time step of the input data for the specified renderer (integer value) // this method is implemented in mitkMapper this->CalculateTimeStep( renderer ); this->InternalGenerateData(renderer); } void mitk::FiberBundleMapper3D::UpdateShaderParameter(mitk::BaseRenderer * ) { // see new vtkShaderCallback3D } void mitk::FiberBundleMapper3D::SetDefaultProperties(mitk::DataNode* node, mitk::BaseRenderer* renderer, bool overwrite) { Superclass::SetDefaultProperties(node, renderer, overwrite); mitk::Vector3D plane_vec; plane_vec.Fill(0.0); node->AddProperty( "Fiber3DClippingPlane", mitk::Vector3DProperty::New( plane_vec ), renderer, overwrite ); node->AddProperty( "Fiber3DClippingPlaneId", mitk::IntProperty::New( 0 ), renderer, overwrite ); node->AddProperty( "Fiber3DClippingPlaneFlip", mitk::BoolProperty::New( false ), renderer, overwrite ); node->AddProperty( "Fiber3DClippingPlaneSecondFlip", mitk::BoolProperty::New( false ), renderer, overwrite ); node->AddProperty( "opacity", mitk::FloatProperty::New( 1.0 ), renderer, overwrite); node->AddProperty( "color", mitk::ColorProperty::New(1.0,1.0,1.0), renderer, overwrite); node->AddProperty( "pickable", mitk::BoolProperty::New( true ), renderer, overwrite); node->AddProperty( "shape.linewidth", mitk::IntProperty::New( true ), renderer, overwrite ); node->AddProperty( "shape.tuberadius",mitk::FloatProperty::New( 0.0 ), renderer, overwrite); node->AddProperty( "shape.tubesides",mitk::IntProperty::New( 15 ), renderer, overwrite); node->AddProperty( "shape.ribbonwidth", mitk::FloatProperty::New( 0.0 ), renderer, overwrite); node->AddProperty( "light.intensity", mitk::FloatProperty::New( 0.6 ), renderer, overwrite); node->AddProperty( "light.enable_light", mitk::BoolProperty::New( false ), renderer, overwrite); node->AddProperty( "light.ambient", mitk::FloatProperty::New( 0.05 ), renderer, overwrite); node->AddProperty( "light.diffuse", mitk::FloatProperty::New( 1.0 ), renderer, overwrite); node->AddProperty( "light.specular", mitk::FloatProperty::New( 0.0 ), renderer, overwrite); node->AddProperty( "light.specularpower", mitk::FloatProperty::New( 1.0 ), renderer, overwrite); node->AddProperty( "light.ambientcolor", mitk::ColorProperty::New(1,1,1), renderer, overwrite); node->AddProperty( "light.diffusecolor", mitk::ColorProperty::New(1,1,1), renderer, overwrite); node->AddProperty( "light.specularcolor", mitk::ColorProperty::New(1,1,1), renderer, overwrite); } vtkProp* mitk::FiberBundleMapper3D::GetVtkProp(mitk::BaseRenderer *renderer) { return m_LocalStorageHandler.GetLocalStorage(renderer)->m_FiberAssembly; } void mitk::FiberBundleMapper3D::SetVtkMapperImmediateModeRendering(vtkMapper *) { } mitk::FiberBundleMapper3D::FBXLocalStorage3D::FBXLocalStorage3D() { m_FiberActor = vtkSmartPointer::New(); m_FiberMapper = vtkSmartPointer::New(); m_FiberAssembly = vtkSmartPointer::New(); } diff --git a/Modules/DiffusionImaging/DiffusionIO/mitkPeakImageMapper2D.cpp b/Modules/DiffusionImaging/DiffusionIO/mitkPeakImageMapper2D.cpp index d8209d1276..f12d2b0feb 100644 --- a/Modules/DiffusionImaging/DiffusionIO/mitkPeakImageMapper2D.cpp +++ b/Modules/DiffusionImaging/DiffusionIO/mitkPeakImageMapper2D.cpp @@ -1,239 +1,239 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "mitkPeakImageMapper2D.h" #include "mitkBaseRenderer.h" #include "mitkDataNode.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include class vtkPeakShaderCallback : public vtkCommand { public: static vtkPeakShaderCallback *New() { return new vtkPeakShaderCallback; } mitk::BaseRenderer *renderer; mitk::DataNode *node; - virtual void Execute(vtkObject *, unsigned long, void*cbo) + void Execute(vtkObject *, unsigned long, void*cbo) override { vtkOpenGLHelper *cellBO = reinterpret_cast(cbo); mitk::Image* image = dynamic_cast(node->GetData()); mitk::Vector3D spacing = image->GetGeometry()->GetSpacing(); float minSpacing = 1; if(spacing[0]GetOpacity(peakOpacity, nullptr); cellBO->Program->SetUniformf("peakOpacity", peakOpacity); cellBO->Program->SetUniformf("clippingPlaneThickness", minSpacing/2); if (this->renderer) { //get information about current position of views mitk::SliceNavigationController::Pointer sliceContr = renderer->GetSliceNavigationController(); mitk::PlaneGeometry::ConstPointer planeGeo = sliceContr->GetCurrentPlaneGeometry(); //generate according cutting planes based on the view position float planeNormal[3]; planeNormal[0] = planeGeo->GetNormal()[0]; planeNormal[1] = planeGeo->GetNormal()[1]; planeNormal[2] = planeGeo->GetNormal()[2]; float tmp1 = planeGeo->GetOrigin()[0] * planeNormal[0]; float tmp2 = planeGeo->GetOrigin()[1] * planeNormal[1]; float tmp3 = planeGeo->GetOrigin()[2] * planeNormal[2]; float thickness = tmp1 + tmp2 + tmp3; //attention, correct normalvector float* a = new float[4]; for (int i = 0; i < 3; ++i) a[i] = planeNormal[i]; a[3] = thickness; cellBO->Program->SetUniform4f("slicingPlane", a); } } vtkPeakShaderCallback() { this->renderer = 0; } }; mitk::PeakImageMapper2D::PeakImageMapper2D() { m_lut = vtkLookupTable::New(); m_lut->Build(); } mitk::PeakImageMapper2D::~PeakImageMapper2D() { } mitk::PeakImage* mitk::PeakImageMapper2D::GetInput() { return dynamic_cast< mitk::PeakImage * > ( GetDataNode()->GetData() ); } void mitk::PeakImageMapper2D::UpdateVtkTransform(mitk::BaseRenderer *) { // don't apply transform since the peak polydata is already in world coordinates. return; } void mitk::PeakImageMapper2D::Update(mitk::BaseRenderer * renderer) { mitk::DataNode* node = this->GetDataNode(); if (node == nullptr) return; bool visible = true; node->GetVisibility(visible, renderer, "visible"); if ( !visible ) return; this->GenerateDataForRenderer( renderer ); } void mitk::PeakImageMapper2D::UpdateShaderParameter(mitk::BaseRenderer *) { // see new vtkPeakShaderCallback } // vtkActors and Mappers are feeded here void mitk::PeakImageMapper2D::GenerateDataForRenderer(mitk::BaseRenderer *renderer) { mitk::PeakImage* peakImage = this->GetInput(); //the handler of local storage gets feeded in this method with requested data for related renderwindow FBXLocalStorage *localStorage = m_LocalStorageHandler.GetLocalStorage(renderer); vtkSmartPointer polyData = peakImage->GetPolyData(); if (polyData == nullptr) return; localStorage->m_Mapper->ScalarVisibilityOn(); localStorage->m_Mapper->SetScalarModeToUsePointFieldData(); localStorage->m_Mapper->SetLookupTable(m_lut); //apply the properties after the slice was set // localStorage->m_PointActor->GetProperty()->SetOpacity(0.999); localStorage->m_Mapper->SelectColorArray("FIBER_COLORS"); localStorage->m_Mapper->SetInputData(polyData); localStorage->m_Mapper->SetVertexShaderCode( "//VTK::System::Dec\n" "attribute vec4 vertexMC;\n" "//VTK::Normal::Dec\n" "uniform mat4 MCDCMatrix;\n" "//VTK::Color::Dec\n" "varying vec4 positionWorld;\n" "varying vec4 colorVertex;\n" "void main(void)\n" "{\n" " colorVertex = scalarColor;\n" " positionWorld = vertexMC;\n" " gl_Position = MCDCMatrix * vertexMC;\n" "}\n" ); localStorage->m_Mapper->SetFragmentShaderCode( "//VTK::System::Dec\n" // always start with this line "//VTK::Output::Dec\n" // always have this line in your FS "uniform vec4 slicingPlane;\n" "uniform float clippingPlaneThickness;\n" "uniform float peakOpacity;\n" "varying vec4 positionWorld;\n" "varying vec4 colorVertex;\n" "void main(void)\n" "{\n" " float r1 = dot(positionWorld.xyz, slicingPlane.xyz) - slicingPlane.w;\n" " if (abs(r1) >= clippingPlaneThickness)\n" " discard;\n" " gl_FragColor = vec4(colorVertex.xyz,peakOpacity);\n" "}\n" ); vtkSmartPointer myCallback = vtkSmartPointer::New(); myCallback->renderer = renderer; myCallback->node = this->GetDataNode(); localStorage->m_Mapper->AddObserver(vtkCommand::UpdateShaderEvent,myCallback); localStorage->m_PointActor->SetMapper(localStorage->m_Mapper); localStorage->m_PointActor->GetProperty()->ShadingOn(); float linewidth = 1.0; this->GetDataNode()->GetFloatProperty("shape.linewidth",linewidth); localStorage->m_PointActor->GetProperty()->SetLineWidth(linewidth); // We have been modified => save this for next Update() localStorage->m_LastUpdateTime.Modified(); } vtkProp* mitk::PeakImageMapper2D::GetVtkProp(mitk::BaseRenderer *renderer) { this->Update(renderer); return m_LocalStorageHandler.GetLocalStorage(renderer)->m_PointActor; } void mitk::PeakImageMapper2D::SetDefaultProperties(mitk::DataNode* node, mitk::BaseRenderer* renderer, bool overwrite) { Superclass::SetDefaultProperties(node, renderer, overwrite); //add other parameters to propertylist node->AddProperty( "color", mitk::ColorProperty::New(1.0,1.0,1.0), renderer, overwrite); node->AddProperty( "shape.linewidth", mitk::FloatProperty::New(1.0), renderer, overwrite); } mitk::PeakImageMapper2D::FBXLocalStorage::FBXLocalStorage() { m_PointActor = vtkSmartPointer::New(); m_Mapper = vtkSmartPointer::New(); } diff --git a/Modules/IGT/Testing/mitkNavigationToolStorageDeserializerTest.cpp b/Modules/IGT/Testing/mitkNavigationToolStorageDeserializerTest.cpp index 0bf0102e1a..c46e77fb3e 100644 --- a/Modules/IGT/Testing/mitkNavigationToolStorageDeserializerTest.cpp +++ b/Modules/IGT/Testing/mitkNavigationToolStorageDeserializerTest.cpp @@ -1,133 +1,133 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ //testing headers #include #include //headers of IGT classes releated to the tested class #include #include #include class mitkNavigationToolStorageDeserializerTestSuite : public mitk::TestFixture { CPPUNIT_TEST_SUITE(mitkNavigationToolStorageDeserializerTestSuite); MITK_TEST(TestInstantiationDeserializer); MITK_TEST(TestReadSimpleToolStorage); MITK_TEST(TestReadComplexToolStorage); MITK_TEST(TestReadNotExistingStorage); MITK_TEST(TestReadStorageWithUnknownFiletype); MITK_TEST(TestReadZipFileWithNoToolstorage); MITK_TEST(TestDeserializerForExceptions); CPPUNIT_TEST_SUITE_END(); private: /** Members used inside the different test methods. All members are initialized via setUp().*/ mitk::NavigationToolStorageDeserializer::Pointer m_Deserializer; mitk::DataStorage::Pointer m_DataStorage; public: /**@brief Setup Always call this method before each Test-case to ensure correct and new intialization of the used members for a new test case. (If the members are not used in a test, the method does not need to be called).*/ - void setUp() + void setUp() override { m_DataStorage = dynamic_cast(mitk::StandaloneDataStorage::New().GetPointer()); //needed for deserializer! m_Deserializer = mitk::NavigationToolStorageDeserializer::New(m_DataStorage); } - void tearDown() + void tearDown() override { m_DataStorage = nullptr; m_Deserializer = nullptr; } void TestInstantiationDeserializer() { mitk::DataStorage::Pointer tempStorage = dynamic_cast(mitk::StandaloneDataStorage::New().GetPointer()); //needed for deserializer! mitk::NavigationToolStorageDeserializer::Pointer testDeserializer = mitk::NavigationToolStorageDeserializer::New(tempStorage); CPPUNIT_ASSERT_MESSAGE("Testing instantiation of NavigationToolStorageDeserializer",testDeserializer.IsNotNull()); } void TestReadSimpleToolStorage() { std::string testDataPath = GetTestDataFilePath("IGT-Data/SimpleIGTStorage.storage"); mitk::NavigationToolStorage::Pointer readStorage = m_Deserializer->Deserialize(testDataPath); CPPUNIT_ASSERT_MESSAGE("Testing deserialization of simple tool storage",readStorage.IsNotNull()); CPPUNIT_ASSERT_MESSAGE(" ..Testing number of tools in storage",readStorage->GetToolCount()==3); //TODO: why is the order of tools changed is save/load process?? bool foundtool1 = false; bool foundtool2 = false; bool foundtool3 = false; for(int i=0; i<3; i++) { if ((readStorage->GetTool(i)->GetIdentifier()=="001")) foundtool1 = true; else if ((readStorage->GetTool(i)->GetIdentifier()=="002")) foundtool2 = true; else if ((readStorage->GetTool(i)->GetIdentifier()=="003")) foundtool3 = true; } CPPUNIT_ASSERT_MESSAGE(" ..Testing if tool 1 was loaded successfully",foundtool1); CPPUNIT_ASSERT_MESSAGE(" ..Testing if tool 2 was loaded successfully",foundtool2); CPPUNIT_ASSERT_MESSAGE(" ..Testing if tool 3 was loaded successfully",foundtool3); } void TestReadComplexToolStorage() { std::string testDataPath = GetTestDataFilePath("IGT-Data/ComplexIGTStorage.storage"); mitk::NavigationToolStorage::Pointer readStorage = m_Deserializer->Deserialize(testDataPath); CPPUNIT_ASSERT_MESSAGE("Testing deserialization of complex tool storage",readStorage.IsNotNull()); CPPUNIT_ASSERT_MESSAGE(" ..Testing number of tools in storage",readStorage->GetToolCount()==2); } void TestReadNotExistingStorage() { CPPUNIT_ASSERT_THROW_MESSAGE("Testing if exception is thrown if a non existing storage is given for deserialization.", m_Deserializer->Deserialize("noStorage.tfl"), mitk::IGTException); } void TestReadStorageWithUnknownFiletype() { std::string testDataPath = GetTestDataFilePath("IGT-Data/ClaronTool.stl"); CPPUNIT_ASSERT_THROW_MESSAGE("Testing if exception is thrown if a wrong file type is given for deserialization.", m_Deserializer->Deserialize(testDataPath), mitk::IGTException); } void TestReadZipFileWithNoToolstorage() { std::string testDataPath = GetTestDataFilePath("IGT-Data/Empty.zip"); CPPUNIT_ASSERT_THROW_MESSAGE("Testing if exception is thrown if a empty zip file is given for deserialization.", m_Deserializer->Deserialize(testDataPath), mitk::IGTException); } //new tests for exception throwing of NavigationToolStorageDeserializer void TestDeserializerForExceptions() { CPPUNIT_ASSERT_THROW_MESSAGE("Testing deserializer with invalid filename.", m_Deserializer->Deserialize("InvalidName"), mitk::IGTException); std::string testDataPath = GetTestDataFilePath("IGT-Data/Empty2.zip"); CPPUNIT_ASSERT_THROW_MESSAGE("Testing deserializer with invalid filename.", m_Deserializer->Deserialize(testDataPath), mitk::IGTException); } }; MITK_TEST_SUITE_REGISTRATION(mitkNavigationToolStorageDeserializer) diff --git a/Modules/IGT/Testing/mitkNavigationToolStorageSerializerAndDeserializerIntegrationTest.cpp b/Modules/IGT/Testing/mitkNavigationToolStorageSerializerAndDeserializerIntegrationTest.cpp index 8c4eb9a046..62fbc0fd9e 100644 --- a/Modules/IGT/Testing/mitkNavigationToolStorageSerializerAndDeserializerIntegrationTest.cpp +++ b/Modules/IGT/Testing/mitkNavigationToolStorageSerializerAndDeserializerIntegrationTest.cpp @@ -1,139 +1,139 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ //testing headers #include #include #include #include //some general mitk headers #include #include #include //headers of IGT classes releated to the tested class #include #include #include #include #include #include //POCO headers for file handling #include #include #include class mitkNavigationToolStorageSerializerAndDeserializerIntegrationTestSuite : public mitk::TestFixture { CPPUNIT_TEST_SUITE(mitkNavigationToolStorageSerializerAndDeserializerIntegrationTestSuite); MITK_TEST(TestInstantiationSerializer); MITK_TEST(TestInstantiationDeserializer); MITK_TEST(TestWriteAndReadSimpleToolStorageWithToolLandmarks); CPPUNIT_TEST_SUITE_END(); private: /** Members used inside the different test methods. All members are initialized via setUp().*/ mitk::NavigationToolStorageSerializer::Pointer m_Serializer; mitk::NavigationToolStorageDeserializer::Pointer m_Deserializer; std::string m_FileName1; public: /**@brief Setup Always call this method before each Test-case to ensure correct and new intialization of the used members for a new test case. (If the members are not used in a test, the method does not need to be called).*/ - void setUp() + void setUp() override { try { m_FileName1 = mitk::IOUtil::CreateTemporaryFile(); std::ofstream file; file.open(m_FileName1.c_str()); if (!file.good()) {MITK_ERROR <<"Could not create a valid file during setUp() method.";} file.close(); } catch (std::exception& e) { MITK_ERROR << "File access Exception: " << e.what(); MITK_ERROR <<"Could not create filename during setUp() method."; } m_Serializer = mitk::NavigationToolStorageSerializer::New(); mitk::DataStorage::Pointer DataStorage = dynamic_cast(mitk::StandaloneDataStorage::New().GetPointer()); //needed for deserializer! m_Deserializer = mitk::NavigationToolStorageDeserializer::New(DataStorage); } - void tearDown() + void tearDown() override { m_Serializer = nullptr; m_Deserializer = nullptr; try { std::remove(m_FileName1.c_str()); } catch(...) { MITK_ERROR << "Warning: Error occured when deleting test file!"; } } void TestInstantiationSerializer() { // let's create objects of our classes mitk::NavigationToolStorageSerializer::Pointer testSerializer = mitk::NavigationToolStorageSerializer::New(); CPPUNIT_ASSERT_MESSAGE("Testing instantiation of NavigationToolStorageSerializer",testSerializer.IsNotNull()); } void TestInstantiationDeserializer() { mitk::DataStorage::Pointer tempStorage = dynamic_cast(mitk::StandaloneDataStorage::New().GetPointer()); //needed for deserializer! mitk::NavigationToolStorageDeserializer::Pointer testDeserializer = mitk::NavigationToolStorageDeserializer::New(tempStorage); CPPUNIT_ASSERT_MESSAGE("Testing instantiation of NavigationToolStorageDeserializer",testDeserializer.IsNotNull()); } void TestWriteAndReadSimpleToolStorageWithToolLandmarks() { //create Tool Storage mitk::NavigationToolStorage::Pointer storage = mitk::NavigationToolStorageTestHelper::CreateTestData_StorageWithOneTool(); //test serialization bool success = m_Serializer->Serialize(m_FileName1,storage); CPPUNIT_ASSERT_MESSAGE("Testing serialization of tool storage with tool registrations",success); //test deserialization of the same file mitk::NavigationToolStorage::Pointer readStorage = m_Deserializer->Deserialize(m_FileName1); CPPUNIT_ASSERT_MESSAGE("Testing deserialization of tool storage with tool registrations",readStorage.IsNotNull()); CPPUNIT_ASSERT_MESSAGE(" ..Testing number of tools in storage",readStorage->GetToolCount()==1); mitk::PointSet::Pointer readRegLandmarks = readStorage->GetTool(0)->GetToolRegistrationLandmarks(); mitk::PointSet::Pointer readCalLandmarks = readStorage->GetTool(0)->GetToolCalibrationLandmarks(); CPPUNIT_ASSERT_MESSAGE("..Testing if tool registration landmarks have been stored and loaded correctly.",((readRegLandmarks->GetPoint(5)[0] == 4)&&(readRegLandmarks->GetPoint(5)[1] == 5)&&(readRegLandmarks->GetPoint(5)[2] == 6))); CPPUNIT_ASSERT_MESSAGE("..Testing if tool calibration landmarks have been stored and loaded correctly.",((readCalLandmarks->GetPoint(0)[0] == 1)&&(readCalLandmarks->GetPoint(0)[1] == 2)&&(readCalLandmarks->GetPoint(0)[2] == 3))); mitk::Point3D readToolTipPos = readStorage->GetTool(0)->GetToolTipPosition(); mitk::Quaternion readToolTipRot = readStorage->GetTool(0)->GetToolTipOrientation(); CPPUNIT_ASSERT_MESSAGE("..Testing if tool tip position has been stored and loaded correctly.", ((float(readToolTipPos[0]) == float(1.3423))&& (float(readToolTipPos[1]) == float(2.323))&& (float(readToolTipPos[2]) == float(4.332)))); CPPUNIT_ASSERT_MESSAGE("..Testing if tool tip orientation has been stored and loaded correctly.", ((float(readToolTipRot.x()) == float(0.1))&& (float(readToolTipRot.y()) == float(0.2))&& (float(readToolTipRot.z()) == float(0.3))&& (float(readToolTipRot.r()) == float(0.4)))); } }; MITK_TEST_SUITE_REGISTRATION(mitkNavigationToolStorageSerializerAndDeserializerIntegration) diff --git a/Modules/IGT/Testing/mitkNavigationToolStorageSerializerTest.cpp b/Modules/IGT/Testing/mitkNavigationToolStorageSerializerTest.cpp index 49c2a0fb31..27b981c4fa 100644 --- a/Modules/IGT/Testing/mitkNavigationToolStorageSerializerTest.cpp +++ b/Modules/IGT/Testing/mitkNavigationToolStorageSerializerTest.cpp @@ -1,141 +1,141 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ //testing headers #include #include #include #include #include //headers of IGT classes releated to the tested class #include #include class mitkNavigationToolStorageSerializerTestSuite : public mitk::TestFixture { CPPUNIT_TEST_SUITE(mitkNavigationToolStorageSerializerTestSuite); MITK_TEST(TestInstantiationSerializer); MITK_TEST(TestWriteSimpleToolStorage); MITK_TEST(TestWriteComplexToolStorage); MITK_TEST(TestWriteStorageToInvalidFile); MITK_TEST(TestWriteEmptyToolStorage); MITK_TEST(TestSerializerForExceptions); CPPUNIT_TEST_SUITE_END(); private: /** Members used inside the different test methods. All members are initialized via setUp().*/ std::string m_FileName1; mitk::NavigationToolStorageSerializer::Pointer m_Serializer; public: /**@brief Setup Always call this method before each Test-case to ensure correct and new intialization of the used members for a new test case. (If the members are not used in a test, the method does not need to be called).*/ - void setUp() + void setUp() override { try { m_FileName1 = mitk::IOUtil::CreateTemporaryFile("NavigationToolStorageSerializerTestTmp_XXXXXX.IGTToolStorage",mitk::IOUtil::GetProgramPath()); std::ofstream file; file.open(m_FileName1.c_str()); if (!file.good()) {MITK_ERROR <<"Could not create a valid file during setUp() method.";} file.close(); } catch (std::exception& e) { MITK_ERROR << "File access Exception: " << e.what(); MITK_ERROR <<"Could not create filename during setUp() method."; } m_Serializer = mitk::NavigationToolStorageSerializer::New(); } - void tearDown() + void tearDown() override { m_Serializer = nullptr; try { std::remove(m_FileName1.c_str()); } catch(...) { MITK_ERROR << "Warning: Error occured when deleting test file!"; } } void TestInstantiationSerializer() { // let's create objects of our classes mitk::NavigationToolStorageSerializer::Pointer testSerializer = mitk::NavigationToolStorageSerializer::New(); CPPUNIT_ASSERT_MESSAGE("Testing instantiation of NavigationToolStorageSerializer",testSerializer.IsNotNull()); } void TestWriteSimpleToolStorage() { //create Tool Storage mitk::NavigationToolStorage::Pointer myStorage = mitk::NavigationToolStorageTestHelper::CreateTestData_SimpleStorage(); //test serialization bool success = m_Serializer->Serialize(m_FileName1,myStorage); CPPUNIT_ASSERT_MESSAGE("Testing serialization of simple tool storage",success); } void TestWriteComplexToolStorage() { //create navigation tool storage mitk::NavigationToolStorage::Pointer myStorage = mitk::NavigationToolStorageTestHelper::CreateTestData_ComplexStorage(GetTestDataFilePath("ClaronTool"),GetTestDataFilePath("IGT-Data/ClaronTool.stl"),GetTestDataFilePath("IGT-Data/EMTool.stl")); //test serialization bool success = m_Serializer->Serialize(m_FileName1,myStorage); CPPUNIT_ASSERT_MESSAGE("Testing serialization of complex tool storage",success); } void TestWriteStorageToInvalidFile() { //create Tool Storage mitk::NavigationToolStorage::Pointer myStorage = mitk::NavigationToolStorageTestHelper::CreateTestData_SimpleStorage(); //create invalid filename #ifdef WIN32 std::string filename = "C:\342INVALIDFILE<>.storage"; //invalid filename for windows #else std::string filename = "/dsfdsf:$ďż˝$342INVALIDFILE.storage"; //invalid filename for linux #endif //test serialization (should throw exception) CPPUNIT_ASSERT_THROW_MESSAGE("Test serialization with simple storage and invalid filename, an exception is expected.",m_Serializer->Serialize(filename,myStorage),mitk::IGTException); } void TestWriteEmptyToolStorage() { //create Tool Storage mitk::NavigationToolStorage::Pointer myStorage = mitk::NavigationToolStorage::New(); //test serialization bool success = m_Serializer->Serialize(m_FileName1,myStorage); CPPUNIT_ASSERT_MESSAGE("Testing serialization of simple tool storage",success); } void TestSerializerForExceptions() { mitk::NavigationToolStorage::Pointer myStorage = mitk::NavigationToolStorage::New(); //create an invalid filename std::string filename = std::string( MITK_TEST_OUTPUT_DIR )+Poco::Path::separator()+""; //now try to serialize an check if an exception is thrown CPPUNIT_ASSERT_THROW_MESSAGE("Test serialization with empty storage and invalid filename, an exception is expected.",m_Serializer->Serialize(filename,myStorage),mitk::IGTException); } }; MITK_TEST_SUITE_REGISTRATION(mitkNavigationToolStorageSerializer) diff --git a/Modules/IGT/Testing/mitkOpenIGTLinkTrackingDeviceTest.cpp b/Modules/IGT/Testing/mitkOpenIGTLinkTrackingDeviceTest.cpp index 1c5f5a3247..27f00ce755 100644 --- a/Modules/IGT/Testing/mitkOpenIGTLinkTrackingDeviceTest.cpp +++ b/Modules/IGT/Testing/mitkOpenIGTLinkTrackingDeviceTest.cpp @@ -1,87 +1,87 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ //testing headers #include #include //headers of IGT classes releated to the tested class #include //sleep headers #include #include class mitkOpenIGTLinkTrackingDeviceTestSuite : public mitk::TestFixture { CPPUNIT_TEST_SUITE(mitkOpenIGTLinkTrackingDeviceTestSuite); MITK_TEST(TestInstantiation); MITK_TEST(TestSetConnectionParameters); MITK_TEST(TestDiscoverToolMethod); CPPUNIT_TEST_SUITE_END(); private: /** Members used inside the different test methods. All members are initialized via setUp().*/ mitk::OpenIGTLinkTrackingDevice::Pointer m_OpenIGTLinkTrackingDevice; public: /**@brief Setup Always call this method before each Test-case to ensure correct and new intialization of the used members for a new test case. (If the members are not used in a test, the method does not need to be called).*/ - void setUp() + void setUp() override { m_OpenIGTLinkTrackingDevice = mitk::OpenIGTLinkTrackingDevice::New(); } - void tearDown() + void tearDown() override { } void TestInstantiation() { // let's create objects of our classes mitk::OpenIGTLinkTrackingDevice::Pointer testDevice = mitk::OpenIGTLinkTrackingDevice::New(); CPPUNIT_ASSERT_MESSAGE("Testing instantiation of OpenIGTLinkTrackingDevice",testDevice.IsNotNull()); } void TestSetConnectionParameters() { m_OpenIGTLinkTrackingDevice->SetHostname("localhost"); m_OpenIGTLinkTrackingDevice->SetPortNumber(10); CPPUNIT_ASSERT_MESSAGE("Testing method SetHostname() ...", m_OpenIGTLinkTrackingDevice->GetHostname()=="localhost"); CPPUNIT_ASSERT_MESSAGE("Testing method SetPort() ...", m_OpenIGTLinkTrackingDevice->GetPortNumber()==10); } void TestDiscoverToolMethod() { CPPUNIT_ASSERT_MESSAGE("Testing DiscoverTools() without initialization. (Warnings are expected)", m_OpenIGTLinkTrackingDevice->DiscoverTools()==false); m_OpenIGTLinkTrackingDevice->SetPortNumber(10); CPPUNIT_ASSERT_MESSAGE("Testing DiscoverTools() with initialization, but without existing server. (Warnings are expected)", m_OpenIGTLinkTrackingDevice->DiscoverTools()==false); m_OpenIGTLinkTrackingDevice->SetHostname("193.174.50.103"); m_OpenIGTLinkTrackingDevice->SetPortNumber(18944); m_OpenIGTLinkTrackingDevice->DiscoverTools(20000); m_OpenIGTLinkTrackingDevice->OpenConnection(); m_OpenIGTLinkTrackingDevice->StartTracking(); std::this_thread::sleep_for(std::chrono::seconds(20)); m_OpenIGTLinkTrackingDevice->StopTracking(); m_OpenIGTLinkTrackingDevice->CloseConnection(); } }; MITK_TEST_SUITE_REGISTRATION(mitkOpenIGTLinkTrackingDevice) diff --git a/Modules/IGT/Testing/mitkTrackingDeviceTest.cpp b/Modules/IGT/Testing/mitkTrackingDeviceTest.cpp index b82289df0d..88774d2641 100644 --- a/Modules/IGT/Testing/mitkTrackingDeviceTest.cpp +++ b/Modules/IGT/Testing/mitkTrackingDeviceTest.cpp @@ -1,116 +1,116 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "mitkTrackingDevice.h" #include "mitkTestingMacros.h" #include "mitkTrackingTool.h" #include "mitkTrackingTypes.h" #include "mitkCommon.h" #include #include #include #include #include #include #include #include "mitkTrackingDeviceTypeCollection.h" #include "mitkUnspecifiedTrackingTypeInformation.h" //All Tracking devices, which should be avaiable by default #include "mitkNDIAuroraTypeInformation.h" #include "mitkNDIPolarisTypeInformation.h" #include "mitkVirtualTrackerTypeInformation.h" #include "mitkMicronTrackerTypeInformation.h" #include "mitkNPOptitrackTrackingTypeInformation.h" #include "mitkOpenIGTLinkTypeInformation.h" /** * Create new class and derive it from TrackingDevice */ class TrackingDeviceTestClass : public mitk::TrackingDevice { public: mitkClassMacro(TrackingDeviceTestClass, mitk::TrackingDevice); itkFactorylessNewMacro(Self) itkCloneMacro(Self) - virtual bool OpenConnection() override{return true;}; - virtual bool CloseConnection() override{return true;}; - virtual bool StartTracking() override{this->SetState(Tracking); this->m_TrackingFinishedMutex->Unlock(); return true;}; - virtual mitk::TrackingTool* GetTool(unsigned int /*toolNumber*/) const override {return nullptr;}; - virtual unsigned int GetToolCount() const override {return 1;}; + bool OpenConnection() override{return true;}; + bool CloseConnection() override{return true;}; + bool StartTracking() override{this->SetState(Tracking); this->m_TrackingFinishedMutex->Unlock(); return true;}; + mitk::TrackingTool* GetTool(unsigned int /*toolNumber*/) const override {return nullptr;}; + unsigned int GetToolCount() const override {return 1;}; }; /** * This function is testing the Class TrackingDevice. For most tests we would need the MicronTracker hardware, so only a few * simple tests, which can run without the hardware are implemented yet (2009, January, 23rd). As soon as there is a working * concept to test the tracking classes which are very close to the hardware on all systems more tests are needed here. */ int mitkTrackingDeviceTest(int /* argc */, char* /*argv*/[]) { MITK_TEST_BEGIN("TrackingDevice"); mitk::TrackingDeviceTypeCollection deviceTypeCollection; deviceTypeCollection.RegisterTrackingDeviceType(new mitk::NDIAuroraTypeInformation()); deviceTypeCollection.RegisterAsMicroservice(); deviceTypeCollection.RegisterTrackingDeviceType(new mitk::VirtualTrackerTypeInformation()); deviceTypeCollection.RegisterTrackingDeviceType(new mitk::NDIPolarisTypeInformation()); deviceTypeCollection.RegisterTrackingDeviceType(new mitk::MicronTrackerTypeInformation()); // Test instantiation of TrackingDevice TrackingDeviceTestClass::Pointer trackingDeviceTestClass = TrackingDeviceTestClass::New(); MITK_TEST_CONDITION(trackingDeviceTestClass.IsNotNull(),"Test instatiation"); // Test method GetState() MITK_TEST_CONDITION(trackingDeviceTestClass->GetState()==mitk::TrackingDevice::Setup,"Mode should be initialized to SETUP"); // Test method SetType() MITK_TEST_CONDITION(trackingDeviceTestClass->GetType()==mitk::UnspecifiedTrackingTypeInformation::GetTrackingDeviceName(),"Type should be initialized to 'not specified'"); trackingDeviceTestClass->SetType(mitk::NDIAuroraTypeInformation::GetTrackingDeviceName()); MITK_TEST_CONDITION(trackingDeviceTestClass->GetType() == mitk::NDIAuroraTypeInformation::GetTrackingDeviceName(), "Type should be NDIAurora, as it has just been set"); trackingDeviceTestClass->SetType(mitk::NDIPolarisTypeInformation::GetTrackingDeviceName()); MITK_TEST_CONDITION(trackingDeviceTestClass->GetType() == mitk::NDIPolarisTypeInformation::GetTrackingDeviceName(), "Type should be NDIPolaris, as it has just been set"); trackingDeviceTestClass->SetType(mitk::MicronTrackerTypeInformation::GetTrackingDeviceName()); MITK_TEST_CONDITION(trackingDeviceTestClass->GetType() == mitk::MicronTrackerTypeInformation::GetTrackingDeviceName(), "Type should be ClaronMicron, as it has just been set"); trackingDeviceTestClass->SetType(mitk::VirtualTrackerTypeInformation::GetTrackingDeviceName()); MITK_TEST_CONDITION(trackingDeviceTestClass->GetType() == mitk::VirtualTrackerTypeInformation::GetTrackingDeviceName(), "Type should be VirtualTracker, as it has just been set"); // Test method StopTracking() trackingDeviceTestClass->StartTracking(); trackingDeviceTestClass->StopTracking(); MITK_TEST_CONDITION(trackingDeviceTestClass->GetState()== mitk::TrackingDevice::Ready,"Type should be NDIAurora, as it has just been set"); MITK_TEST_CONDITION(deviceTypeCollection.GetTrackingDeviceTypeInformation(mitk::VirtualTrackerTypeInformation::GetTrackingDeviceName())->GetTrackingDeviceName() == mitk::VirtualTrackerTypeInformation::GetTrackingDeviceName(), "Test GetTrackingDeviceTypeInformation"); MITK_TEST_CONDITION(deviceTypeCollection.GetTrackingDeviceTypeInformation(mitk::VirtualTrackerTypeInformation::GetTrackingDeviceName())->m_TrackingDeviceData[0].Model == "Virtual Tracker", "Test GetTrackingDeviceTypeInformation"); std::vector names = deviceTypeCollection.GetTrackingDeviceTypeNames(); MITK_TEST_CONDITION(names[0] == mitk::NDIAuroraTypeInformation::GetTrackingDeviceName(), "Test collection name list"); MITK_TEST_CONDITION(names[1] == mitk::VirtualTrackerTypeInformation::GetTrackingDeviceName(), "Test collection name list"); MITK_TEST_CONDITION(names[2] == mitk::NDIPolarisTypeInformation::GetTrackingDeviceName(), "Test collection name list"); MITK_TEST_CONDITION(names[3] == mitk::MicronTrackerTypeInformation::GetTrackingDeviceName(), "Test collection name list"); MITK_TEST_END(); } diff --git a/Modules/IGT/Testing/mitkTrackingToolTest.cpp b/Modules/IGT/Testing/mitkTrackingToolTest.cpp index e5499014d6..38657eee1e 100644 --- a/Modules/IGT/Testing/mitkTrackingToolTest.cpp +++ b/Modules/IGT/Testing/mitkTrackingToolTest.cpp @@ -1,66 +1,66 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "mitkTestingMacros.h" #include "mitkTrackingTool.h" #include "mitkTrackingTypes.h" #include "mitkCommon.h" #include #include /** * Create new class and derive it from TrackingDevice */ class TrackingToolTestClass : public mitk::TrackingTool { public: mitkClassMacro(TrackingToolTestClass, mitk::TrackingTool); itkFactorylessNewMacro(Self) itkCloneMacro(Self) - virtual void GetPosition(mitk::Point3D & /*position*/) const override {}; - virtual void GetOrientation(mitk::Quaternion& /*orientation*/) const override {}; - virtual void SetToolTip(mitk::Point3D /*toolTipPosition*/, mitk::Quaternion /*orientation*/, mitk::ScalarType /*eps*/) override {}; - virtual bool Enable() override {return true;} - virtual bool Disable() override {return true;} - virtual bool IsEnabled() const override {return true;} - virtual bool IsDataValid() const override {return true;} - virtual float GetTrackingError() const override {return 0.0;} + void GetPosition(mitk::Point3D & /*position*/) const override {}; + void GetOrientation(mitk::Quaternion& /*orientation*/) const override {}; + void SetToolTip(mitk::Point3D /*toolTipPosition*/, mitk::Quaternion /*orientation*/, mitk::ScalarType /*eps*/) override {}; + bool Enable() override {return true;} + bool Disable() override {return true;} + bool IsEnabled() const override {return true;} + bool IsDataValid() const override {return true;} + float GetTrackingError() const override {return 0.0;} }; /** * This function is testing the Class TrackingDevice. For most tests we would need the MicronTracker hardware, so only a few * simple tests, which can run without the hardware are implemented yet (2009, January, 23rd). As soon as there is a working * concept to test the tracking classes which are very close to the hardware on all systems more tests are needed here. */ int mitkTrackingToolTest(int /* argc */, char* /*argv*/[]) { MITK_TEST_BEGIN("TrackingTool"); // Test instantiation of TrackingTool TrackingToolTestClass::Pointer trackingToolTestClass = TrackingToolTestClass::New(); MITK_TEST_CONDITION(trackingToolTestClass.IsNotNull(),"Test instatiation"); // Test method GetToolName() MITK_TEST_CONDITION(!strcmp(trackingToolTestClass->GetToolName(),""),"Tool name should be empty"); // Test method GetErrorMessage() MITK_TEST_CONDITION(!strcmp(trackingToolTestClass->GetErrorMessage(),""),"Error message should be empty"); MITK_TEST_END(); } diff --git a/Modules/IGT/Testing/mitkVirtualTrackingDeviceTest.cpp b/Modules/IGT/Testing/mitkVirtualTrackingDeviceTest.cpp index 6ead54d13e..182e8e2dc3 100644 --- a/Modules/IGT/Testing/mitkVirtualTrackingDeviceTest.cpp +++ b/Modules/IGT/Testing/mitkVirtualTrackingDeviceTest.cpp @@ -1,191 +1,191 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ //Testing #include "mitkTestingMacros.h" #include "mitkTestFixture.h" //Std includes #include //MITK includes #include "mitkVirtualTrackingDevice.h" #include "mitkVirtualTrackingDevice.h" #include "mitkTrackingTool.h" //ITK includes #include "itksys/SystemTools.hxx" class mitkVirtualTrackingDeviceTestSuite : public mitk::TestFixture { CPPUNIT_TEST_SUITE(mitkVirtualTrackingDeviceTestSuite); MITK_TEST(NewVirtualTrackingDevice_IsCreated); MITK_TEST(StartTracking_NotReady_False); MITK_TEST(StopTracking); MITK_TEST(StartTracking_Ready_True); MITK_TEST(StartTrackingAfterConnectionClosed_False); MITK_TEST(GetToolCount_NoToolAdded); MITK_TEST(GetToolCount_SeveralToolsAdded); MITK_TEST(GetTool); MITK_TEST(SettingAndGettingCorrectBounds); MITK_TEST(SetToolSpeed_InvalidSpeed_Error); MITK_TEST(SetToolSpeed_InvalidToolNumber_Error); MITK_TEST(GetSplineCordLength_ValidToolIndex); MITK_TEST(GetSplineCordLength_InvaldiToolIndex_Error); MITK_TEST(StartTracking_NewPositionsProduced); MITK_TEST(SetParamsForGaussianNoise_GetCorrrectParams); CPPUNIT_TEST_SUITE_END(); private: mitk::VirtualTrackingDevice::Pointer m_TestTracker; public: - void setUp() + void setUp() override { m_TestTracker = mitk::VirtualTrackingDevice::New(); } - void tearDown() + void tearDown() override { m_TestTracker->CloseConnection(); } void NewVirtualTrackingDevice_IsCreated() { CPPUNIT_ASSERT_EQUAL(mitk::TrackingDevice::Setup, m_TestTracker->GetState()); } void StartTracking_NotReady_False() { CPPUNIT_ASSERT_EQUAL(false, m_TestTracker->StartTracking()); } void StopTracking() { CPPUNIT_ASSERT(m_TestTracker->StopTracking()); } void StartTracking_Ready_True() { m_TestTracker->OpenConnection(); CPPUNIT_ASSERT(m_TestTracker->StartTracking()); } void StartTrackingAfterConnectionClosed_False() { m_TestTracker->OpenConnection(); m_TestTracker->CloseConnection(); CPPUNIT_ASSERT_EQUAL(false, m_TestTracker->StartTracking()); } void GetToolCount_NoToolAdded() { unsigned int zero = 0; CPPUNIT_ASSERT_EQUAL(zero, m_TestTracker->GetToolCount()); } void GetToolCount_SeveralToolsAdded() { unsigned int one = 1; unsigned int two = 2; unsigned int three = 3; m_TestTracker->AddTool("Tool1"); CPPUNIT_ASSERT_EQUAL(one, m_TestTracker->GetToolCount()); m_TestTracker->AddTool("Tool2"); CPPUNIT_ASSERT_EQUAL(two, m_TestTracker->GetToolCount()); m_TestTracker->AddTool("Tool3"); CPPUNIT_ASSERT_EQUAL(three, m_TestTracker->GetToolCount()); } void GetTool() { m_TestTracker->AddTool("Tool1"); mitk::TrackingTool::Pointer tool = m_TestTracker->GetTool(0); CPPUNIT_ASSERT_EQUAL(m_TestTracker->GetToolByName("Tool1"), tool.GetPointer()); } void SettingAndGettingCorrectBounds() { mitk::ScalarType bounds[6] = { 0.0, 10.0, 1.0, 20.0, 3.0, 30.0 }; m_TestTracker->SetBounds(bounds); CPPUNIT_ASSERT_EQUAL(bounds[0], m_TestTracker->GetBounds()[0]); CPPUNIT_ASSERT_EQUAL(bounds[1], m_TestTracker->GetBounds()[1]); CPPUNIT_ASSERT_EQUAL(bounds[2], m_TestTracker->GetBounds()[2]); CPPUNIT_ASSERT_EQUAL(bounds[3], m_TestTracker->GetBounds()[3]); CPPUNIT_ASSERT_EQUAL(bounds[4], m_TestTracker->GetBounds()[4]); CPPUNIT_ASSERT_EQUAL(bounds[5], m_TestTracker->GetBounds()[5]); } void SetToolSpeed_InvalidSpeed_Error() { m_TestTracker->AddTool("Tool1"); CPPUNIT_ASSERT_THROW(m_TestTracker->SetToolSpeed(0, -1), std::invalid_argument); } void SetToolSpeed_InvalidToolNumber_Error() { m_TestTracker->AddTool("Tool1"); CPPUNIT_ASSERT_THROW(m_TestTracker->SetToolSpeed(1, 0.1), std::invalid_argument); } void GetSplineCordLength_ValidToolIndex() { m_TestTracker->AddTool("Tool1"); mitk::ScalarType lengthBefore = m_TestTracker->GetSplineChordLength(0); m_TestTracker->OpenConnection(); m_TestTracker->StartTracking(); m_TestTracker->StopTracking(); CPPUNIT_ASSERT_EQUAL(lengthBefore, m_TestTracker->GetSplineChordLength(0)); } void GetSplineCordLength_InvaldiToolIndex_Error() { CPPUNIT_ASSERT_THROW(m_TestTracker->GetSplineChordLength(0), std::invalid_argument); } void StartTracking_NewPositionsProduced() { m_TestTracker->AddTool("Tool1"); mitk::Point3D posBefore; mitk::Point3D posAfter; mitk::TrackingTool::Pointer tool = m_TestTracker->GetToolByName("Tool1"); tool->GetPosition(posBefore); tool->GetPosition(posAfter); CPPUNIT_ASSERT_EQUAL(posBefore, posAfter); m_TestTracker->OpenConnection(); m_TestTracker->StartTracking(); itksys::SystemTools::Delay(500); //wait for tracking thread to start generating positions tool->GetPosition(posAfter); CPPUNIT_ASSERT(posBefore != posAfter); } void SetParamsForGaussianNoise_GetCorrrectParams() { double meanDistribution = 2.5; double deviationDistribution = 1.2; m_TestTracker->SetParamsForGaussianNoise(meanDistribution, deviationDistribution); CPPUNIT_ASSERT_EQUAL(meanDistribution, m_TestTracker->GetMeanDistribution()); CPPUNIT_ASSERT_EQUAL(deviationDistribution, m_TestTracker->GetDeviationDistribution()); } }; MITK_TEST_SUITE_REGISTRATION(mitkVirtualTrackingDevice) diff --git a/Modules/IGTUI/Qmitk/QmitkAbstractTrackingDeviceWidget.h b/Modules/IGTUI/Qmitk/QmitkAbstractTrackingDeviceWidget.h index 44754bd672..2948a8c06c 100644 --- a/Modules/IGTUI/Qmitk/QmitkAbstractTrackingDeviceWidget.h +++ b/Modules/IGTUI/Qmitk/QmitkAbstractTrackingDeviceWidget.h @@ -1,143 +1,143 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QmitkAbstractTrackingDeviceWidget_H #define QmitkAbstractTrackingDeviceWidget_H #include #include "MitkIGTUIExports.h" #include "mitkTrackingDevice.h" #include #include "QmitkTrackingDeviceConfigurationWidgetConnectionWorker.h" //itk headers /** Documentation: * \brief Abstract class to configure a tracking device. * Inherited widgets should be registered in the Microservice (TrackingDeviceCollectionWidget), * If done so, they will be included in the QmitkTrackingDeviceConfigurationWidget of the Tracking Toolbox. * * - Each implementation of this class must have a method to construct a tracking Device (ConstructTrackingDevice). * - Please create the UI elements in a function like CreateQtPartControl (e.g. see QmitkVitrualTrackerWidget). * - You might want to use own buttons etc., please connect them in a private CreateConnections (e.g. see QmitkVitrualTrackerWidget). * - Due to initialization of qt during autoloading of the IGT module, you constructor should be as slim as possible and only contain a call * of the QmitkAbstractTrackingDeviceWidget constructor and simple variable initialization. * - For the initialization, you must write an Iniltialize() function, which must include a call of InitializeSuperclassWidget() and should contain * calls of your private CreateConnections / CreateQtPartControl (if you implemented these). * - For integration into the TrackingToolbox, a clone function is needed. Here, a new widget should be created, Initialize() needs to be called, * and all settings of your widget should be copied. * * You can Load and Store previous settings of your GUI elements (e.g. see QmitkNDIPolarisWidget). * Also, you can add an output textbox to your widget to display information about your device status. It's optional, see e.g. QmitkNDIAuroraWidget. * Some Devices need the information if drivers are installed on your computer. If this is necessary for your device to avoid crashes, * please override IsDeviceInstalled. The default return value is true otherwise. * * \ingroup IGTUI */ class MITKIGTUI_EXPORT QmitkAbstractTrackingDeviceWidget : public QWidget { Q_OBJECT public: static const std::string VIEW_ID; QmitkAbstractTrackingDeviceWidget(QWidget* parent = 0, Qt::WindowFlags f = 0); - virtual ~QmitkAbstractTrackingDeviceWidget(); + ~QmitkAbstractTrackingDeviceWidget() override; /** * \brief Return pointer to copy of the object. * Internally use of QmitkUSAbstractCustomWidget::Clone() with additionaly * setting an internal flag that the object was really cloned. */ QmitkAbstractTrackingDeviceWidget* CloneForQt(QWidget* parent = 0) const; /** * \brief Subclass must implement this method to return a pointer to a copy of the object. * Please don't forget to call InitializeSuperclassWidget(), CreateQtPartControl and optionally CreateConnections during this function. */ virtual void Initialize() = 0; bool IsInitialized() const { return isInitialized; } signals: void ConnectionTested(bool connected, QString output); protected slots: void TestConnectionFinished(bool connected, QString output); /* @brief This method is called when the user presses the button "test connection". The method will then create a temporary tracking device, * try to open a connection and start tracking. The user can see the result of the connection test on the small output window. */ void TestConnection(); private: /// \brief Creation of the connections. You might implement the same function again in your inherited widget. void CreateConnections(); protected: PERSISTENCE_GET_SERVICE_METHOD_MACRO void InitializeSuperclassWidget(); QmitkTrackingDeviceConfigurationWidgetConnectionWorker* m_TestConnectionWorker; QThread* m_TestConnectionWorkerThread; /** * \brief Subclass must implement this method to return a pointer to a copy of the object. * Please don't forget to call Initialize() during this function and copy all of your settings. */ virtual QmitkAbstractTrackingDeviceWidget* Clone(QWidget* parent = 0) const = 0; public: /** * \brief Optional method to add output to a small screen in the trackingToolbox (see QmitkNDIPolarisWidget) */ virtual void ResetOutput() {} /** * \brief Optional method to add output to a small screen in the trackingToolbox (see QmitkNDIPolarisWidget) */ virtual void AddOutput(std::string) {} virtual mitk::TrackingDevice::Pointer ConstructTrackingDevice() = 0; /** * \brief Optional method to store and load settings of your widget (see QmitkNDIPolarisWidget) */ virtual void StoreUISettings() {} /** * \brief Optional method to store and load settings of your widget (see QmitkNDIPolarisWidget) */ virtual void LoadUISettings() {} /** * \brief Optional method to investigate if drivers etc for your device are installed. * The default value is "true" as most devices don't need this information. * Others however migth crash, and for these you might implement this function (see QmitkMicronTrackerWidget) */ virtual bool IsDeviceInstalled() { return true; } std::string m_ErrorMessage; ///< current problem description private: /** * \warning Don't touch this variable if you don't know what you are doing! */ bool isInitialized; }; #endif diff --git a/Modules/IGTUI/Qmitk/QmitkFiducialRegistrationWidget.h b/Modules/IGTUI/Qmitk/QmitkFiducialRegistrationWidget.h index 71038605c7..a35c84fd94 100644 --- a/Modules/IGTUI/Qmitk/QmitkFiducialRegistrationWidget.h +++ b/Modules/IGTUI/Qmitk/QmitkFiducialRegistrationWidget.h @@ -1,136 +1,136 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef _QmitkFiducialRegistrationWidget_H_INCLUDED #define _QmitkFiducialRegistrationWidget_H_INCLUDED #include "ui_QmitkFiducialRegistrationWidget.h" #include "QmitkStdMultiWidget.h" #include "MitkIGTUIExports.h" #include "mitkNavigationData.h" /*! * \brief IGT Fiducial Registration Widget * * Widget used to set fiducial landmarks in the image and to confirm the corresponding landmarks on the world object (patient/phantom). * * The widget can add tracker fiducials and perform the registration internally. To enable this functionaltity the * methods SetDataStorage(), setTrackerNavigationData() and setImageNode() needs to be called before. * * If Registration should be handled from outside the class the methods SetImageFiducialsNode() and SetTrackerFiducialsNode() * must be called, otherwise the QmitkPointListWidget can not work. If SetDataStorage() is not called the widget does nothing * internally. * * \sa IGT */ class MITKIGTUI_EXPORT QmitkFiducialRegistrationWidget : public QWidget { Q_OBJECT // this is needed for all Qt objects that should have a MOC object (everything that derives from QObject) public: QmitkFiducialRegistrationWidget(QWidget* parent); - virtual ~QmitkFiducialRegistrationWidget(); + ~QmitkFiducialRegistrationWidget() override; /** Adds the image node which is transformed after "register" is clicked. */ void setImageNode(mitk::DataNode::Pointer i); /** Adds the tracker navigation data which is used when "add current instrument position" is clicked. */ void setTrackerNavigationData(mitk::NavigationData::Pointer t); /** Sets the data storage. This is required is the widget shoul add tracker points and perform * registrations internally. When not setting the data storage the widget can still be used * by reacting on the signals and do custom actions outside.*/ void setDataStorage(mitk::DataStorage::Pointer d); /*! \brief enumeration to specify the appearance of the widget. 'FIDUCIALMODE' is likely to be used for (tracking) fiducial based registration purposes 'LANDMARKMODE' can be used for any kind of landmark based registration (source landmarks -> target/reference landmarks) */ enum WidgetAppearanceMode { FIDUCIALMODE, LANDMARKMODE }; /*! \brief set the appearance mode of this widget 'FIDUCIALMODE' adapts the widget for (tracking) fiducial based registration purposes 'LANDMARKMODE' adapts the widget for landmark based registration (source landmarks -> target/reference landmarks) */ void SetWidgetAppearanceMode(WidgetAppearanceMode widgetMode); void SetMultiWidget(QmitkStdMultiWidget* multiWidget); ///< (Deprecated method. Multiwidget is not required any more.) Set the default stdMultiWidget (needed for the PointListwidget) void AddSliceNavigationController(mitk::SliceNavigationController* snc); ///< add the slice navigation controller to be used to move the crosshair to the actual point position void SetImageFiducialsNode(mitk::DataNode::Pointer imageFiducialsNode); ///< specify data tree node for the image fiducials void SetTrackerFiducialsNode(mitk::DataNode::Pointer trackerFiducialsNode); ///< specify data tree node for the tracker fiducials mitk::DataNode::Pointer GetImageFiducialsNode(); ///< returns data tree node for the image fiducials mitk::DataNode::Pointer GetTrackerFiducialsNode(); ///< returns data tree node for the tracker fiducials void SetQualityDisplayText(QString text); ///< sets specific text on the UI (useful to display FRE/TRE...) /*! \brief Specify the name of the source landmarks. Will be used for label and button. Example: sourceLandmarkName="CT" will result in group box title "CT landmarks" and button text "Add CT landmark". */ void SetSourceLandmarkName(QString sourceLandmarkName); /*! \brief Specify the name of the source landmarks. Will be used for label and button. Example: targetLandmarkName="CT" will result in group box title "CT landmarks" and button text "Add CT landmark". */ void SetTargetLandmarkName(QString targetLandmarkName); bool UseICPIsChecked(); ///< returns true if automatic correspondences search is activated else false void HideStaticRegistrationRadioButton(bool on); ///< show or hide "static Fiducial Registration" radio button in the UI void HideContinousRegistrationRadioButton(bool on); ///< show or hide "hybrid continuous Fiducial Registration" radio button in the UI void HideFiducialRegistrationGroupBox(); ///< show or hide "Fiducial Registration method" groupbox in the UI, depending on the visibility of the radio buttons void HideUseICPRegistrationCheckbox(bool on); ///< show or hide "Find fiducial correspondences (needs 6+ fiducial pairs)" check box in the UI void HideImageFiducialButton(bool on); ///< show or hide "Add image fiducial" button in the UI void HideTrackingFiducialButton(bool on); ///< show or hide "Add tracking fiducial" button in the UI void AdjustButtonSpacing(); ///< Rearrange spacing when buttons are turned on or off signals: void AddedTrackingFiducial(); ///< signal if a world instrument position was added to a tracking space fiducial void AddedImageFiducial(); ///< signal if an image position was added to a image space fiducial void PerformFiducialRegistration(); ///< signal if all fiducial were added and registration can be performed void FindFiducialCorrespondences(bool on); ///< signal if automatic correspondences search is toggled protected slots: void DisableEditButtonRegistrationImagePoints(bool);///< Disables the edit button of the widget RegistrationImagePoints if the activated variable is true. void DisableEditButtonRegistrationTrackingPoints(bool);///< Disables the edit button of the widget RegistrationTrackingPoints if the activated variable is true. void AddTrackerPoint(); void Register(); protected: void CreateQtPartControl(QWidget *parent); void CreateConnections(); bool CheckRegistrationInitialization(); Ui::QmitkFiducialRegistrationWidget* m_Controls; ///< gui widget QmitkStdMultiWidget* m_MultiWidget; mitk::DataNode::Pointer m_ImageFiducialsNode; mitk::DataNode::Pointer m_TrackerFiducialsNode; mitk::DataStorage::Pointer m_DataStorage; mitk::NavigationData::Pointer m_TrackerNavigationData; mitk::DataNode::Pointer m_ImageNode; mitk::NavigationData::Pointer m_T_ObjectReg; }; #endif // _QmitkFiducialRegistrationWidget_H_INCLUDED diff --git a/Modules/IGTUI/Qmitk/QmitkIGTConnectionWidget.h b/Modules/IGTUI/Qmitk/QmitkIGTConnectionWidget.h index da950d88dd..bd7f000d28 100644 --- a/Modules/IGTUI/Qmitk/QmitkIGTConnectionWidget.h +++ b/Modules/IGTUI/Qmitk/QmitkIGTConnectionWidget.h @@ -1,113 +1,113 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QmitkIGTConnectionWidget_H #define QmitkIGTConnectionWidget_H #include #include "MitkIGTUIExports.h" #include "ui_QmitkIGTConnectionWidgetControls.h" #include "mitkDataStorage.h" #include "mitkNavigationToolStorage.h" #include "mitkTrackingDevice.h" #include "mitkTrackingDeviceSource.h" //itk headers /** Documentation: * \brief Simple and fast access to a pre-configured TrackingDeviceSource. * * This widget creates a fully configured, connected and started TrackingDeviceSource. * Clicking "Connect" requires to specify a NavigationToolStorage that holds all tools to be used * in the application. Corresponding surfaces are added to the DataStorage that has to be set for * the widget. * * Inputs: DataStorage * Outputs: TrackingDeviceSource, NavigationToolStorage * Signals: TrackingDeviceConnected, TrackingDeviceDisconnected * * \ingroup IGTUI */ class MITKIGTUI_EXPORT QmitkIGTConnectionWidget : public QWidget { Q_OBJECT public: static const std::string VIEW_ID; QmitkIGTConnectionWidget(QWidget* parent = 0, Qt::WindowFlags f = 0); - ~QmitkIGTConnectionWidget(); + ~QmitkIGTConnectionWidget() override; /* @return Returns the preconfigured and connected TrackingDeviceSource ready to use in an IGT pipeline. */ mitk::TrackingDeviceSource::Pointer GetTrackingDeviceSource(); /*! \brief Get the NavigationToolStorage holding all tools with corresponding surface objects */ mitk::NavigationToolStorage::Pointer GetNavigationToolStorage(); /*! \brief set DataStorage that is used to put the navigation tools */ void SetDataStorage(mitk::DataStorage::Pointer dataStorage); signals: /*! \brief signal emitted when TrackingDevice was successfully connected */ void TrackingDeviceConnected(); /*! \brief signal emitted when TrackingDevice was successfully disconnected */ void TrackingDeviceDisconnected(); protected slots: /*! \brief Asks the user to specify a tool file and finally connects the TrackingDeviceSource */ void OnConnect(); protected: /// \brief Creation of the connections virtual void CreateConnections(); virtual void CreateQtPartControl(QWidget *parent); /*! \brief Load NavigationToolStorage from given filename and set according member \param qFilename file location of the NavigationToolStorage \return success of load operation (true if load successful, false otherwise) m_ErrorMessage holds the problem description */ bool LoadToolfile(QString qFilename); /*! \brief Remove the tool nodes currently associated to the tools hold in the NavigationToolStorage from the DataStorage */ void RemoveToolNodes(); Ui::QmitkIGTConnectionWidgetControls* m_Controls; mitk::DataStorage::Pointer m_DataStorage; ///< data storage to put navigation tools mitk::TrackingDevice::Pointer m_TrackingDevice; ///< tracking device currently connected mitk::TrackingDeviceSource::Pointer m_TrackingDeviceSource; ///< holds the preconfigured source of the IGT pipeline which is provided by this widget for further processing mitk::NavigationToolStorage::Pointer m_NavigationToolStorage; ///< holds all navigation tools currently loaded std::string m_ErrorMessage; ///< current problem description }; #endif diff --git a/Modules/IGTUI/Qmitk/QmitkIGTLoggerWidget.h b/Modules/IGTUI/Qmitk/QmitkIGTLoggerWidget.h index 8f42cfcf60..e622ddcb95 100644 --- a/Modules/IGTUI/Qmitk/QmitkIGTLoggerWidget.h +++ b/Modules/IGTUI/Qmitk/QmitkIGTLoggerWidget.h @@ -1,90 +1,90 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QmitkIGTLoggerWidget_H #define QmitkIGTLoggerWidget_H //QT headers #include //mitk headers #include "MitkIGTUIExports.h" #include "mitkNavigationTool.h" #include #include "mitkNavigationDataRecorder.h" //ui header #include "ui_QmitkIGTLoggerWidgetControls.h" /** Documentation: * \brief GUI to access the IGT recorder. * User can specify the file name where the output shall be stored and * how long the recording shall be performed. * * \ingroup IGTUI */ class MITKIGTUI_EXPORT QmitkIGTLoggerWidget : public QWidget { Q_OBJECT public: static const std::string VIEW_ID; QmitkIGTLoggerWidget(QWidget* parent = 0, Qt::WindowFlags f = 0); - ~QmitkIGTLoggerWidget(); + ~QmitkIGTLoggerWidget() override; void SetDataStorage(mitk::DataStorage* dataStorage); void SetRecorder(mitk::NavigationDataRecorder::Pointer recorder); signals: void SignalRecordingStarted(); void SignalRecordingStopped(); protected slots: void OnChangePressed(); void OnStartRecording(bool recording); void OnRecording(); void UpdateRecordingTime(); void StopRecording(); void UpdateOutputFileName(); protected: /// \brief Creation of the connections virtual void CreateConnections(); virtual void CreateQtPartControl(QWidget *parent); void SetDefaultRecordingSettings(); void SetOutputFileName(); Ui::QmitkIGTLoggerWidgetControls* m_Controls; /** @brief holds the DataStorage */ mitk::DataStorage::Pointer m_DataStorage; mitk::NavigationDataRecorder::Pointer m_Recorder; ///< records NDs to a XML file QString m_CmpFilename; QString m_Dir; QTimer* m_RecordingTimer; QString m_MilliSeconds; QString m_Samples; bool m_RecordingActivated; }; #endif diff --git a/Modules/IGTUI/Qmitk/QmitkIGTPlayerWidget.h b/Modules/IGTUI/Qmitk/QmitkIGTPlayerWidget.h index 9437dd0cfe..85094c6585 100644 --- a/Modules/IGTUI/Qmitk/QmitkIGTPlayerWidget.h +++ b/Modules/IGTUI/Qmitk/QmitkIGTPlayerWidget.h @@ -1,250 +1,250 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QmitkIGTPlayerWidget_H #define QmitkIGTPlayerWidget_H //QT headers #include //mitk headers #include "MitkIGTUIExports.h" #include #include #include #include //ui header #include "ui_QmitkIGTPlayerWidgetControls.h" /** Documentation: * \brief GUI to access the IGT Player. * User must specify the file name where the input xml-file is located. The NavigationDatas from the xml-file can be * played in normal mode or in PointSet mode. * * In normal mode the player updates the NavigationDatas every 100ms (can be changed in SetUpdateRate()) and returns * them when GetNavigationDatas() is called. * In PointSet mode the player generates a PointSet with all NavigationDatas from the xml-file. So the playback is * performed on this ND PointSet. * * \ingroup IGTUI */ class MITKIGTUI_EXPORT QmitkIGTPlayerWidget : public QWidget { Q_OBJECT public: static const std::string VIEW_ID; /*! \brief default constructor */ QmitkIGTPlayerWidget(QWidget* parent = 0, Qt::WindowFlags f = 0); /*! \brief default deconstructor */ - ~QmitkIGTPlayerWidget(); + ~QmitkIGTPlayerWidget() override; /*! \brief Sets the real time player for this player widget */ //void SetRealTimePlayer(mitk::NavigationDataPlayer::Pointer player); /*! \brief Sets the sequential player for this player widget */ //void SetSequentialPlayer(mitk::NavigationDataSequentialPlayer::Pointer player); /*! \brief Returns the playing timer of this widget */ QTimer* GetPlayingTimer(); /*! \brief Returns the current playback NavigationDatas from the xml-file */ const std::vector GetNavigationDatas(); /*! \brief Returns a PointSet of the current NavigationDatas for all recorded tools. */ const mitk::PointSet::Pointer GetNavigationDatasPointSet(); /*! \brief Returns a PointType of the current NavigationData for a specific tool with the given index. */ const mitk::PointSet::PointType GetNavigationDataPoint(unsigned int index); /*! \brief Sets the update rate of this widget's playing timer */ void SetUpdateRate(unsigned int msecs); /*! \brief Returns the number of different tools from the current playing stream. * * Retuns 0 if playback file is invalid. */ unsigned int GetNumberOfTools(); /*! \brief Stops the playback */ void StopPlaying(); /*! \brief Sets the given tool names list to the trajectory select combobox. */ void SetTrajectoryNames(const QStringList toolNames); /*! \brief Returns the current resolution value from the resolution spinbox. */ int GetResolution(); /*! \brief Clears all items in the trajectory selection combobox. */ void ClearTrajectorySelectCombobox(); /*! \brief Returns whether spline mode checkbox is selected. */ bool IsTrajectoryInSplineMode(); enum PlaybackMode { ///< playback mode enum RealTimeMode = 1, SequentialMode = 2 }; PlaybackMode GetCurrentPlaybackMode(); signals: /*! \brief This signal is emitted when the player starts the playback. */ void SignalPlayingStarted(); /*! \brief This signal is emitted when the player resumes after a pause. */ void SignalPlayingResumed(); /*! \brief This signal is emitted when the player stops. */ void SignalPlayingStopped(); /*! \brief This signal is emitted when the player is paused. */ void SignalPlayingPaused(); /*! \brief This signal is emitted when the player reaches the end of the playback. */ void SignalPlayingEnded(); /*! \brief This signal is emitted every time the player updated the NavigationDatas. */ void SignalPlayerUpdated(); /*! \brief This signal is emitted if the input file for the replay was changed. */ void SignalInputFileChanged(); /*! \brief This signal is emitted if the index of the current selected trajectory select combobox item changes. */ void SignalCurrentTrajectoryChanged(int index); /*! \brief This signal is emitted if the spline mode checkbox is toggled or untoggled. */ void SignalSplineModeToggled(bool toggled); protected slots: /*! \brief Starts or pauses the playback */ void OnPlayButtonClicked(bool toggled); /*! \brief Updates the playback data */ void OnPlaying(); /*! \brief Stops the playback */ void OnStopPlaying(); /*! \brief Opens file open dialog for searching the input file */ void OnOpenFileButtonPressed(); /*! \brief Stops the playback */ void OnGoToEnd(); /*! \brief Stops the playback and resets the player to the beginning */ void OnGoToBegin(); /*! \brief Switches widget between realtime and sequential mode */ void OnSequencialModeToggled(bool toggled); /*! \brief Pauses playback when slider is pressed by user */ void OnSliderPressed(); /*! \brief Moves player position to the position selected with the slider */ void OnSliderReleased(); protected: /// \brief Creation of the connections virtual void CreateConnections(); /*! \brief Checks if an imput file with the set filename exists */ bool CheckInputFileValid(); /*! \brief Sets all LCD numbers to 0 */ void ResetLCDNumbers(); mitk::NavigationDataPlayer::Pointer m_RealTimePlayer; ///< plays NDs from a XML file mitk::NavigationDataSequentialPlayer::Pointer m_SequentialPlayer; mitk::NavigationData::TimeStampType m_StartTime; ///< start time of playback needed for time display unsigned int m_CurrentSequentialPointNumber; ///< current point number Ui::QmitkIGTPlayerWidgetControls* m_Controls; QString m_CmpFilename; ///< filename of the input file QTimer* m_PlayingTimer; ///< update timer }; #endif diff --git a/Modules/IGTUI/Qmitk/QmitkInteractiveTransformationWidget.h b/Modules/IGTUI/Qmitk/QmitkInteractiveTransformationWidget.h index a8959444a6..f4a93e5f95 100644 --- a/Modules/IGTUI/Qmitk/QmitkInteractiveTransformationWidget.h +++ b/Modules/IGTUI/Qmitk/QmitkInteractiveTransformationWidget.h @@ -1,94 +1,94 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QmitkInteractiveTransformationWidget_H #define QmitkInteractiveTransformationWidget_H //QT headers #include //Mitk headers #include "MitkIGTUIExports.h" #include "mitkVector.h" #include "mitkGeometry3D.h" //ui header #include "ui_QmitkInteractiveTransformationWidgetControls.h" /** Documentation: * \brief An object of this class offers an UI to create a widget to access the advance tool creation options. * * * \ingroup IGTUI */ class MITKIGTUI_EXPORT QmitkInteractiveTransformationWidget : public QWidget { Q_OBJECT public: static const std::string VIEW_ID; QmitkInteractiveTransformationWidget(QWidget* parent = nullptr, Qt::WindowFlags f = nullptr); - ~QmitkInteractiveTransformationWidget(); + ~QmitkInteractiveTransformationWidget() override; /** Sets the geometry which will be modified by this widget. Default values may be * provided by the second variable. These values will be applied to the geometry * in the beginning and the UI will also hold these values. */ void SetGeometry(mitk::BaseGeometry::Pointer geometry, mitk::BaseGeometry::Pointer defaultValues = nullptr); mitk::BaseGeometry::Pointer GetGeometry(); protected slots: void OnZTranslationValueChanged( int v ); void OnYTranslationValueChanged( int v ); void OnXTranslationValueChanged( int v ); void OnZRotationValueChanged( int v ); void OnYRotationValueChanged( int v ); void OnXRotationValueChanged( int v ); void OnResetGeometry(); void OnApplyManipulatedToolTip(); signals: void ApplyManipulatedToolTip(); protected: virtual void CreateConnections(); virtual void CreateQtPartControl(QWidget *parent); void SetSliderX(int v); void SetSliderY(int v); void SetSliderZ(int v); /*! \brief Method performs the translation. \params translateVector New translation to be combine with geometry. */ void Translate( mitk::Vector3D translateVector); /*! \brief Method performs the rotation. \params rotateVector New rotation to be combined with geometry. */ void Rotate(mitk::Vector3D rotateVector); // Member variables Ui::QmitkInteractiveTransformationWidgetControls* m_Controls; mitk::BaseGeometry::Pointer m_Geometry; ///< \brief Initial geometry that is manipulated mitk::BaseGeometry::Pointer m_ResetGeometry; ///< \brief Lifeline to reset to the initial geometry mitk::Vector3D m_TranslationVector; ///< \brief Accumulated translation vector mitk::Vector3D m_RotateSliderPos; ///< \brief Accumulated rotation vector (holds degree around x,y,z direction) }; #endif // QmitkInteractiveTransformationWidget_H diff --git a/Modules/IGTUI/Qmitk/QmitkMicronTrackerWidget.h b/Modules/IGTUI/Qmitk/QmitkMicronTrackerWidget.h index 6f304182f1..1eabead4e2 100644 --- a/Modules/IGTUI/Qmitk/QmitkMicronTrackerWidget.h +++ b/Modules/IGTUI/Qmitk/QmitkMicronTrackerWidget.h @@ -1,71 +1,71 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QmitkMicronTrackerWidget_H #define QmitkMicronTrackerWidget_H #include "ui_QmitkMicronTrackerWidget.h" #include "QmitkAbstractTrackingDeviceWidget.h" /** Documentation: * \brief Implementation of a configuration widget for Micron Tracking Devices. * * \ingroup IGTUI */ class MITKIGTUI_EXPORT QmitkMicronTrackerWidget : public QmitkAbstractTrackingDeviceWidget { Q_OBJECT // this is needed for all Qt objects that should have a MOC object (everything that derives from QObject) public: static const std::string VIEW_ID; QmitkMicronTrackerWidget(QWidget* parent = 0, Qt::WindowFlags f = 0); - ~QmitkMicronTrackerWidget(); + ~QmitkMicronTrackerWidget() override; - virtual void Initialize(); + void Initialize() override; signals: protected slots : /* @brief Opens a file dialog. The users sets the calibration file which location is then stored in the member m_MTCalibrationFile.*/ void SetMTCalibrationFileClicked(); private: /// \brief Creation of the connections void CreateConnections(); void CreateQtPartControl(QWidget *parent); protected: - virtual QmitkMicronTrackerWidget* Clone(QWidget* parent) const; + QmitkMicronTrackerWidget* Clone(QWidget* parent) const override; std::string m_MTCalibrationFile; Ui::QmitkMicronTrackerWidget* m_Controls; public: - virtual void ResetOutput(); - virtual void AddOutput(std::string s); - virtual mitk::TrackingDevice::Pointer ConstructTrackingDevice(); + void ResetOutput() override; + void AddOutput(std::string s) override; + mitk::TrackingDevice::Pointer ConstructTrackingDevice() override; - virtual void StoreUISettings(); - virtual void LoadUISettings(); - virtual bool IsDeviceInstalled(); + void StoreUISettings() override; + void LoadUISettings() override; + bool IsDeviceInstalled() override; }; #endif diff --git a/Modules/IGTUI/Qmitk/QmitkNDIAbstractDeviceWidget.h b/Modules/IGTUI/Qmitk/QmitkNDIAbstractDeviceWidget.h index dd3c1532c1..28fb67a9af 100644 --- a/Modules/IGTUI/Qmitk/QmitkNDIAbstractDeviceWidget.h +++ b/Modules/IGTUI/Qmitk/QmitkNDIAbstractDeviceWidget.h @@ -1,70 +1,70 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QmitkNDIAbstractDeviceWidget_H #define QmitkNDIAbstractDeviceWidget_H #include "MitkIGTUIExports.h" #include "QmitkAbstractTrackingDeviceWidget.h" #include "QmitkTrackingDeviceConfigurationWidgetScanPortsWorker.h" /** Documentation: * \brief Abstract class of a configuration widget for NDI Devices. * For implementations see NDIAuroraWidget or NDIPolarisWidget. * * \ingroup IGTUI */ class MITKIGTUI_EXPORT QmitkNDIAbstractDeviceWidget : public QmitkAbstractTrackingDeviceWidget { Q_OBJECT // this is needed for all Qt objects that should have a MOC object (everything that derives from QObject) public: static const std::string VIEW_ID; QmitkNDIAbstractDeviceWidget(QWidget* parent = 0, Qt::WindowFlags f = 0); - ~QmitkNDIAbstractDeviceWidget(); + ~QmitkNDIAbstractDeviceWidget() override; - virtual void Initialize() = 0; + void Initialize() override = 0; - virtual void AddOutput(std::string s) = 0; + void AddOutput(std::string s) override = 0; signals: void PortsScanned(int Port, QString result, int PortType); protected slots: /* @brief Scans the serial ports automatically for a connected tracking device. If the method finds a device * it selects the right type and sets the corresponding port in the widget. */ void AutoScanPorts(); /** This slot is called when the port scanning is finished. */ void AutoScanPortsFinished(int Port, QString result, int PortType); private: /// \brief Creation of the connections void CreateConnections(); protected: void InitializeNDIWidget(); QmitkTrackingDeviceConfigurationWidgetScanPortsWorker* m_ScanPortsWorker; QThread* m_ScanPortsWorkerThread; virtual void SetPortValueToGUI(int portValue) = 0; virtual void SetPortTypeToGUI(int portType) = 0; }; #endif diff --git a/Modules/IGTUI/Qmitk/QmitkNDIAuroraWidget.h b/Modules/IGTUI/Qmitk/QmitkNDIAuroraWidget.h index f3fd1bea10..5d4b0951c6 100644 --- a/Modules/IGTUI/Qmitk/QmitkNDIAuroraWidget.h +++ b/Modules/IGTUI/Qmitk/QmitkNDIAuroraWidget.h @@ -1,62 +1,62 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QmitkNDIAuroraWidget_H #define QmitkNDIAuroraWidget_H #include "ui_QmitkNDIAuroraWidget.h" #include "QmitkNDIAbstractDeviceWidget.h" /** Documentation: * \brief Implementation of a configuration widget for NDI Aurora Devices. * * \ingroup IGTUI */ class MITKIGTUI_EXPORT QmitkNDIAuroraWidget : public QmitkNDIAbstractDeviceWidget { Q_OBJECT // this is needed for all Qt objects that should have a MOC object (everything that derives from QObject) public: static const std::string VIEW_ID; QmitkNDIAuroraWidget(QWidget* parent = 0, Qt::WindowFlags f = 0); - ~QmitkNDIAuroraWidget(); + ~QmitkNDIAuroraWidget() override; - virtual void Initialize(); + void Initialize() override; private: /// \brief Creation of the connections void CreateConnections(); void CreateQtPartControl(QWidget *parent); protected: - virtual void ResetOutput(); - virtual void AddOutput(std::string s); - virtual mitk::TrackingDevice::Pointer ConstructTrackingDevice(); + void ResetOutput() override; + void AddOutput(std::string s) override; + mitk::TrackingDevice::Pointer ConstructTrackingDevice() override; - virtual void StoreUISettings(); - virtual void LoadUISettings(); + void StoreUISettings() override; + void LoadUISettings() override; - virtual void SetPortValueToGUI(int portValue); - virtual void SetPortTypeToGUI(int portType); + void SetPortValueToGUI(int portValue) override; + void SetPortTypeToGUI(int portType) override; - virtual QmitkNDIAuroraWidget* Clone(QWidget* parent) const; + QmitkNDIAuroraWidget* Clone(QWidget* parent) const override; Ui::QmitkNDIAuroraWidget* m_Controls; }; #endif diff --git a/Modules/IGTUI/Qmitk/QmitkNDIConfigurationWidget.h b/Modules/IGTUI/Qmitk/QmitkNDIConfigurationWidget.h index 36fa02e6c5..b4d9013424 100644 --- a/Modules/IGTUI/Qmitk/QmitkNDIConfigurationWidget.h +++ b/Modules/IGTUI/Qmitk/QmitkNDIConfigurationWidget.h @@ -1,136 +1,136 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef _QmitkNDIConfigurationWidget_H_INCLUDED #define _QmitkNDIConfigurationWidget_H_INCLUDED #include "ui_QmitkNDIConfigurationWidget.h" #include "mitkNDITrackingDevice.h" #include "mitkTrackingDeviceSource.h" #include "QStringList" #include "MitkIGTUIExports.h" #include "mitkNodePredicateBase.h" #include "mitkNavigationTool.h" class QmitkNDIToolDelegate; namespace mitk { class DataStorage; }; /**@deprecated This widget is deprecated. The features (1) connection to NDI tracking devices and * (2) handling of navigation tools are available in the pluging org.mitk.gui.qt.igttracking * in a current version. The new concept to access the tracking devices is to use microservices. * This can be achieved very simple by using the QmitkNavigationDataSourceSelectionWidget. You * can find an example in the IGT tutorial step 2 / org.mitk.gui.qt.igtexamples (view TrackingLab). * *\ingroup IGTUI */ class MITKIGTUI_EXPORT QmitkNDIConfigurationWidget : public QWidget { Q_OBJECT // this is needed for all Qt objects that should have a MOC object (everything that derives from QObject) public: QmitkNDIConfigurationWidget(QWidget* parent); - virtual ~QmitkNDIConfigurationWidget(); + ~QmitkNDIConfigurationWidget() override; DEPRECATED(std::string GetDeviceName() const); DEPRECATED(mitk::NDITrackingDevice* GetTracker() const); DEPRECATED(mitk::DataStorage* GetDataStorage() const); DEPRECATED(mitk::NodePredicateBase* GetPredicate() const); DEPRECATED(const QStringList& GetToolTypes() const); DEPRECATED(void SetToolTypes(const QStringList& types)); ///< set types list for type editor combobox DEPRECATED(void SetDataStorage(mitk::DataStorage* ds)); ///< set datastorage for organ node editor DEPRECATED(void SetPredicate(mitk::NodePredicateBase::Pointer p)); ///< set predicate for organ node editor DEPRECATED(void SetTagPropertyName(const std::string& name)); ///< set name of the property that is used to tag selected nodes DEPRECATED(void SetTagProperty(mitk::BaseProperty::Pointer prop)); ///< set the property that is used to tag selected nodes DEPRECATED(const QString GetToolType(unsigned int index) const); DEPRECATED(const QString GetToolName(unsigned int index) const); QMap GetToolAndTypes() const; DEPRECATED(QList GetToolsByToolType(QString toolType) const); DEPRECATED(mitk::DataNode* GetNode(unsigned int index) const); signals: void ToolsAdded(QStringList tools); void ToolsChanged(); void Connected(); void Disconnected(); void RepresentationChanged( int row , mitk::Surface::Pointer surface ); // returns the row number of the clicked tableitem for changing tool representation void SignalToolNameChanged(int id, QString name); void SignalSavedTool(int id, QString surfaceFilename); void SignalLoadTool(int id, mitk::DataNode::Pointer dn); public slots: void SetDeviceName(const char* dev); ///< set the device name (e.g. "COM1", "/dev/ttyS0") that will be used to connect to the tracking device void ShowToolRepresentationColumn(); ///< show or hide the tooltable column "Tool Representation". This SLOT should be called after SIGNAL "Connected" is emitted void EnableAddToolsButton(bool enable); ///< enables or disables the Add Tools button void EnableDiscoverNewToolsButton(bool enable); ; ///< enables or disables the Discover new Tools button protected slots: void OnConnect(); void OnDisconnect(); void OnDiscoverTools(); void OnDiscoverDevices(); void OnAddPassiveTool(); void UpdateTrackerFromToolTable(const QModelIndex & topLeft, const QModelIndex & /*bottomRight*/); void OnTableItemClicked(const QModelIndex & topLeft); ///< for clicking on tooltable items void OnDisoverDevicesBtnInfo(); void OnTableCellChanged(int row, int column); void OnSaveTool(); void OnLoadTool(); protected: typedef QMap PortDeviceMap; // key is port name (e.g. "COM1", "/dev/ttyS0"), value will be filled with the type of tracking device at this port /**Documentation * \brief scans the ports provided as key in the portsAndDevices and fills the respective value of portsAndDevices with the tracking device type at that port * * * \param[in] portsAndDevices keys are used to query serial ports * \param[out] portsAndDevices values of the existing keys will be filled with the tracking device type */ void ScanPortsForNDITrackingDevices(PortDeviceMap& portsAndDevices); mitk::TrackingDeviceType ScanPort(QString port); mitk::NavigationTool::Pointer GenerateNavigationTool(mitk::TrackingTool* tool); QStringList GetToolNamesList(); ///< returns a string list with the names of all tools of the current tracking device void CreateTracker(); ///< creates new NDITrackingDevice object void SetupTracker(); ///< sets the parameters from the gui to the tracking device object QString GetStatusText(); ///< construct a status text depending on the current state of the tracking device object void UpdateWidgets(); void UpdateToolTable(); ///< read all tools from the tracking device object and display them in the gui virtual void CreateQtPartControl(QWidget *parent); virtual void CreateConnections(); ///< \brief Creation of the connections of main and control widget void HidePolarisOptionsGroupbox( bool on ); ///< show or hide polaris options in the UI void HideAuroraOptionsGroupbox( bool on ); ///< show or hide aurora options in the UI Ui::QmitkNDIConfigurationWidget* m_Controls; ///< gui widgets mitk::NDITrackingDevice::Pointer m_Tracker; ///< tracking device object mitk::TrackingDeviceSource::Pointer m_Source; QmitkNDIToolDelegate* m_Delegate; QString m_SROMCellDefaultText; QString m_RepresentatonCellDefaultText; mitk::Surface::Pointer LoadSurfaceFromSTLFile(QString surfaceFilename); }; #endif // _QmitkNDIConfigurationWidget_H_INCLUDED diff --git a/Modules/IGTUI/Qmitk/QmitkNDIPolarisWidget.h b/Modules/IGTUI/Qmitk/QmitkNDIPolarisWidget.h index d201e84349..891308aa1b 100644 --- a/Modules/IGTUI/Qmitk/QmitkNDIPolarisWidget.h +++ b/Modules/IGTUI/Qmitk/QmitkNDIPolarisWidget.h @@ -1,71 +1,71 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QmitkNDIPolarisWidget_H #define QmitkNDIPolarisWidget_H #include "ui_QmitkNDIPolarisWidget.h" #include "QmitkNDIAbstractDeviceWidget.h" /** Documentation: * \brief Implementation of a configuration widget for NDI Polaris Devices. * * \ingroup IGTUI */ class MITKIGTUI_EXPORT QmitkNDIPolarisWidget : public QmitkNDIAbstractDeviceWidget { Q_OBJECT // this is needed for all Qt objects that should have a MOC object (everything that derives from QObject) public: static const std::string VIEW_ID; QmitkNDIPolarisWidget(QWidget* parent = 0, Qt::WindowFlags f = 0); - ~QmitkNDIPolarisWidget(); + ~QmitkNDIPolarisWidget() override; - virtual void Initialize(); + void Initialize() override; signals: protected slots : private: /// \brief Creation of the connections void CreateConnections(); void CreateQtPartControl(QWidget *parent); protected: /** @return Returns the frame rate set in the m_frameRatePolaris ComboBox */ mitk::IlluminationActivationRate GetPolarisFrameRate(); Ui::QmitkNDIPolarisWidget* m_Controls; - virtual void SetPortValueToGUI(int portValue); - virtual void SetPortTypeToGUI(int portType); + void SetPortValueToGUI(int portValue) override; + void SetPortTypeToGUI(int portType) override; - virtual QmitkNDIPolarisWidget* Clone(QWidget* parent) const; + QmitkNDIPolarisWidget* Clone(QWidget* parent) const override; public: - virtual void ResetOutput(); - virtual void AddOutput(std::string s); - virtual mitk::TrackingDevice::Pointer ConstructTrackingDevice(); + void ResetOutput() override; + void AddOutput(std::string s) override; + mitk::TrackingDevice::Pointer ConstructTrackingDevice() override; - virtual void StoreUISettings(); - virtual void LoadUISettings(); + void StoreUISettings() override; + void LoadUISettings() override; }; #endif diff --git a/Modules/IGTUI/Qmitk/QmitkNPOptitrackWidget.h b/Modules/IGTUI/Qmitk/QmitkNPOptitrackWidget.h index 54d8c17088..409c2cde51 100644 --- a/Modules/IGTUI/Qmitk/QmitkNPOptitrackWidget.h +++ b/Modules/IGTUI/Qmitk/QmitkNPOptitrackWidget.h @@ -1,68 +1,68 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QmitkNPOptitrackWidget_H #define QmitkNPOptitrackWidget_H #include "ui_QmitkNPOptitrackWidget.h" #include "QmitkAbstractTrackingDeviceWidget.h" /** Documentation: * \brief Implementation of a configuration widget for NP Optitrack Tracking Devices. * * \ingroup IGTUI */ class MITKIGTUI_EXPORT QmitkNPOptitrackWidget : public QmitkAbstractTrackingDeviceWidget { Q_OBJECT // this is needed for all Qt objects that should have a MOC object (everything that derives from QObject) public: static const std::string VIEW_ID; QmitkNPOptitrackWidget(QWidget* parent = 0, Qt::WindowFlags f = 0); - ~QmitkNPOptitrackWidget(); + ~QmitkNPOptitrackWidget() override; - virtual void Initialize(); + void Initialize() override; signals: protected slots : /* @brief Opens a file dialog. The users sets the calibration file which location is then stored in the member m_OptitrackCalibrationFile.*/ void SetOptitrackCalibrationFileClicked(); private: /// \brief Creation of the connections void CreateConnections(); void CreateQtPartControl(QWidget *parent); protected: - virtual QmitkNPOptitrackWidget* Clone(QWidget* parent) const; + QmitkNPOptitrackWidget* Clone(QWidget* parent) const override; std::string m_OptitrackCalibrationFile; Ui::QmitkNPOptitrackWidget* m_Controls; public: - virtual void ResetOutput(); - virtual void AddOutput(std::string s); - virtual mitk::TrackingDevice::Pointer ConstructTrackingDevice(); + void ResetOutput() override; + void AddOutput(std::string s) override; + mitk::TrackingDevice::Pointer ConstructTrackingDevice() override; - virtual bool IsDeviceInstalled(); + bool IsDeviceInstalled() override; }; #endif diff --git a/Modules/IGTUI/Qmitk/QmitkNavigationDataPlayerControlWidget.h b/Modules/IGTUI/Qmitk/QmitkNavigationDataPlayerControlWidget.h index 7a8c5ba505..8cbff718cc 100644 --- a/Modules/IGTUI/Qmitk/QmitkNavigationDataPlayerControlWidget.h +++ b/Modules/IGTUI/Qmitk/QmitkNavigationDataPlayerControlWidget.h @@ -1,62 +1,62 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QMITKNAVIGATIONDATAPLAYERCONTROLWIDGET_H #define QMITKNAVIGATIONDATAPLAYERCONTROLWIDGET_H #include #include "mitkNavigationDataPlayer.h" #include "MitkIGTUIExports.h" class QTimer; namespace Ui { class QmitkNavigationDataPlayerControlWidget; } class MITKIGTUI_EXPORT QmitkNavigationDataPlayerControlWidget : public QWidget { Q_OBJECT signals: void SignalUpdate(); void SignalEndReached(); public slots: void OnStop(); void OnPlayPause(); void OnRestart(); protected slots: void OnUpdate(); public: explicit QmitkNavigationDataPlayerControlWidget(QWidget *parent = 0); - ~QmitkNavigationDataPlayerControlWidget(); + ~QmitkNavigationDataPlayerControlWidget() override; void SetPlayer(mitk::NavigationDataPlayer::Pointer player); private: void ResetPlayerDisplay(); mitk::NavigationDataPlayer::Pointer m_Player; QTimer* m_UpdateTimer; Ui::QmitkNavigationDataPlayerControlWidget *ui; }; #endif // QMITKNAVIGATIONDATAPLAYERCONTROLWIDGET_H diff --git a/Modules/IGTUI/Qmitk/QmitkNavigationDataSequentialPlayerControlWidget.h b/Modules/IGTUI/Qmitk/QmitkNavigationDataSequentialPlayerControlWidget.h index e9d6b42743..6e4660187d 100644 --- a/Modules/IGTUI/Qmitk/QmitkNavigationDataSequentialPlayerControlWidget.h +++ b/Modules/IGTUI/Qmitk/QmitkNavigationDataSequentialPlayerControlWidget.h @@ -1,64 +1,64 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QMITKNAVIGATIONDATASEQUENTIALPLAYERCONTROLWIDGET_H #define QMITKNAVIGATIONDATASEQUENTIALPLAYERCONTROLWIDGET_H #include #include "mitkNavigationDataSequentialPlayer.h" #include "MitkIGTUIExports.h" class QTimer; namespace Ui { class QmitkNavigationDataSequentialPlayerControlWidget; } class MITKIGTUI_EXPORT QmitkNavigationDataSequentialPlayerControlWidget : public QWidget { Q_OBJECT signals: void SignalUpdate(); void SignalEndReached(); public slots: void OnStop(); void OnPlayPause(); void OnRestart(); protected slots: void OnUpdate(); void OnUpdateIntervalChanged(int); public: explicit QmitkNavigationDataSequentialPlayerControlWidget(QWidget *parent = 0); - ~QmitkNavigationDataSequentialPlayerControlWidget(); + ~QmitkNavigationDataSequentialPlayerControlWidget() override; void SetPlayer(mitk::NavigationDataSequentialPlayer::Pointer player); protected: void UpdatePlayerDisplay(); private: mitk::NavigationDataSequentialPlayer::Pointer m_Player; QTimer* m_UpdateTimer; Ui::QmitkNavigationDataSequentialPlayerControlWidget *ui; }; #endif // QMITKNAVIGATIONDATASEQUENTIALPLAYERCONTROLWIDGET_H diff --git a/Modules/IGTUI/Qmitk/QmitkNavigationDataSourceSelectionWidget.h b/Modules/IGTUI/Qmitk/QmitkNavigationDataSourceSelectionWidget.h index 9c6090b0d3..69464b1197 100644 --- a/Modules/IGTUI/Qmitk/QmitkNavigationDataSourceSelectionWidget.h +++ b/Modules/IGTUI/Qmitk/QmitkNavigationDataSourceSelectionWidget.h @@ -1,101 +1,101 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QmitkNavigationDataSourceSelectionWidget_H #define QmitkNavigationDataSourceSelectionWidget_H //QT headers #include //mitk headers #include "MitkIGTUIExports.h" #include #include #include //ui header #include "ui_QmitkNavigationDataSourceSelectionWidgetControls.h" /** Documentation: * \brief This widget allows the user to select a NavigationDataSource. Tools of this Source are also shown and the user can select one of these tools. * \ingroup IGTUI */ class MITKIGTUI_EXPORT QmitkNavigationDataSourceSelectionWidget : public QWidget { Q_OBJECT public: static const std::string VIEW_ID; QmitkNavigationDataSourceSelectionWidget(QWidget* parent = 0, Qt::WindowFlags f = 0); - ~QmitkNavigationDataSourceSelectionWidget(); + ~QmitkNavigationDataSourceSelectionWidget() override; /** @return Returns the currently selected NavigationDataSource. Returns null if no source is selected at the moment. */ mitk::NavigationDataSource::Pointer GetSelectedNavigationDataSource(); /** @return Returns the ID of the currently selected tool. You can get the corresponding NavigationData when calling GetOutput(id) * on the source object. Returns -1 if there is no tool selected. */ int GetSelectedToolID(); /** @return Returns the NavigationTool of the current selected tool if a NavigationToolStorage is available. Returns nullptr if * there is no storage available or if no tool is selected. */ mitk::NavigationTool::Pointer GetSelectedNavigationTool(); /** @return Returns the NavigationToolStorage of the currently selected NavigationDataSource. Returns nullptr if there is no * source selected or if the source has no NavigationToolStorage assigned. */ mitk::NavigationToolStorage::Pointer GetNavigationToolStorageOfSource(); signals: /** @brief This signal is emitted when a new navigation data source is selected. * @param n Holds the new selected navigation data source. Is null if the old source is deselected and no new source is selected. */ void NavigationDataSourceSelected(mitk::NavigationDataSource::Pointer n); /** @brief This signal is emitted when a new navigation data tool is selected. * @param n Holds the new selected navigation tool. Is null if the old source is deselected and no new source is selected. */ void NavigationToolSelected(mitk::NavigationTool::Pointer n); protected slots: void NavigationDataSourceSelected(us::ServiceReferenceU s); void NavigationToolSelected(int selection); protected: /// \brief Creation of the connections virtual void CreateConnections(); virtual void CreateQtPartControl(QWidget *parent); Ui::QmitkNavigationDataSourceSelectionWidgetControls* m_Controls; mitk::NavigationToolStorage::Pointer m_CurrentStorage; mitk::NavigationDataSource::Pointer m_CurrentSource; }; #endif diff --git a/Modules/IGTUI/Qmitk/QmitkNavigationToolCreationAdvancedWidget.h b/Modules/IGTUI/Qmitk/QmitkNavigationToolCreationAdvancedWidget.h index bedca1815e..d770553b75 100644 --- a/Modules/IGTUI/Qmitk/QmitkNavigationToolCreationAdvancedWidget.h +++ b/Modules/IGTUI/Qmitk/QmitkNavigationToolCreationAdvancedWidget.h @@ -1,109 +1,109 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QmitkNavigationToolCreationAdvancedWidget_H #define QmitkNavigationToolCreationAdvancedWidget_H //QT headers #include //Mitk headers #include "MitkIGTUIExports.h" #include "mitkDataStorage.h" #include "mitkSurface.h" // Qmitk headers #include "QmitkInteractiveTransformationWidget.h" //ui header #include "ui_QmitkNavigationToolCreationAdvancedWidgetControls.h" /** Documentation: * \brief An object of this class offers an UI to modify a tooltip of an IGT navigation tool. * * The user can modify translation and orientation of the tooltip. The current tooltip * might be provided as default data, then the widget starts with the given values for * translation and orientation. * * As long as the UI is open, there will also be a (temporary) preview data node, so * the user can see the effect of his manipulations. * * Please call the method SetDataStorage to initialize the UI with the data storage * of the current application. * * \ingroup IGTUI */ class MITKIGTUI_EXPORT QmitkNavigationToolCreationAdvancedWidget : public QDialog { Q_OBJECT public: static const std::string VIEW_ID; QmitkNavigationToolCreationAdvancedWidget(QWidget* parent = 0, Qt::WindowFlags f = 0); - ~QmitkNavigationToolCreationAdvancedWidget(); + ~QmitkNavigationToolCreationAdvancedWidget() override; /** Initializes the view with the a data storage. This data storage is needed for the * preview node during tooltip manipulation. */ void SetDataStorage(mitk::DataStorage::Pointer dataStorage); /** Sets the current tooltip surface, also for preview purposes (the preview node * will be a clone of this surface). If there is no surface, a simple cone can be used. * Please set cone to true in this case. */ void SetToolTipSurface(bool cone, mitk::DataNode::Pointer node = nullptr); /** Sets a default tooltip transform, which will shown in the beginning. * If the windows is already open, the transform will be set to default * immediately. */ void SetDefaultTooltip(mitk::AffineTransform3D::Pointer defaultToolTip); /** @return Returns the manipulated tip transform. Returns an identity transform if * nothing was manipulated. */ mitk::AffineTransform3D::Pointer GetManipulatedToolTip(); /** Reinitializes the view, e.g. after it was closed. */ void ReInitialize(); signals: void DialogCloseRequested(); void RetrieveDataForManualToolTipManipulation(); protected slots: void OnClose(); void OnApplyManipulatedToolTip(); protected: virtual void CreateConnections(); virtual void CreateQtPartControl(QWidget *parent); void RetrieveAndInitializeDataForTooltipManipulation(); // Member variables Ui::QmitkNavigationToolCreationAdvancedWidgetControls* m_Controls; mitk::AffineTransform3D::Pointer m_DefaultToolTip; mitk::DataStorage::Pointer m_DataStorage; mitk::Surface::Pointer m_ToolTipSurface; mitk::Surface::Pointer m_ManipulatedToolTip; ///< manipulated surface object, which holds the tooltip as geometry std::string m_SurfaceNodeName; }; #endif // QmitkNavigationToolCreationAdvancedWidget_H diff --git a/Modules/IGTUI/Qmitk/QmitkNavigationToolCreationWidget.h b/Modules/IGTUI/Qmitk/QmitkNavigationToolCreationWidget.h index c4a060910d..8be1dfc25b 100644 --- a/Modules/IGTUI/Qmitk/QmitkNavigationToolCreationWidget.h +++ b/Modules/IGTUI/Qmitk/QmitkNavigationToolCreationWidget.h @@ -1,132 +1,132 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QmitkNavigationToolCreationWidget_H #define QmitkNavigationToolCreationWidget_H //QT headers #include //mitk headers #include "MitkIGTUIExports.h" #include #include #include //Microservices #include #include #include #include // Qmitk headers #include "QmitkNavigationToolCreationAdvancedWidget.h" //ui header #include "ui_QmitkNavigationToolCreationWidget.h" /** Documentation: * \brief An object of this class offers an UI to create or modify NavigationTools. * * Be sure to call the initialize method before you start the widget * otherwise some errors might occure. * * \ingroup IGTUI */ class MITKIGTUI_EXPORT QmitkNavigationToolCreationWidget : public QWidget { Q_OBJECT public: static const std::string VIEW_ID; /** @brief Initializes the widget. * @param dataStorage The data storage is needed to offer the possibility to choose surfaces from the data storage for tool visualization. * @param supposedIdentifier This Identifier is supposed for the user. It is needed because every identifier in a navigation tool storage must be unique and we don't know the others. */ void Initialize(mitk::DataStorage* dataStorage, const std::string &supposedIdentifier, const std::string &supposedName = "NewTool"); /** @brief Sets the default tracking device type. You may also define if it is changeable or not.*/ void SetTrackingDeviceType(mitk::TrackingDeviceType type, bool changeable = true); /** @brief Sets the default data of all input fields. The default data is used from the default tool which is given as parameter. */ void SetDefaultData(mitk::NavigationTool::Pointer DefaultTool); QmitkNavigationToolCreationWidget(QWidget* parent = 0, Qt::WindowFlags f = 0); - ~QmitkNavigationToolCreationWidget(); + ~QmitkNavigationToolCreationWidget() override; /** @return Returns the created tool. Returns nullptr if no tool was created yet. */ mitk::NavigationTool::Pointer GetCreatedTool(); signals: /** @brief This signal is emitted if the user finished the creation of the tool. */ void NavigationToolFinished(); /** @brief This signal is emitted if the user canceled the creation of the tool. */ void Canceled(); protected slots: void OnCancel(); void OnFinished(); void OnLoadSurface(); void OnLoadCalibrationFile(); void OnShowAdvancedOptions(bool state); void OnProcessDialogCloseRequest(); void OnRetrieveDataForManualTooltipManipulation(); void OnSurfaceUseOtherToggled(bool checked); protected: /// \brief Creation of the connections virtual void CreateConnections(); virtual void CreateQtPartControl(QWidget *parent); Ui::QmitkNavigationToolCreationWidgetControls* m_Controls; QmitkNavigationToolCreationAdvancedWidget* m_AdvancedWidget; /** @brief holds the DataStorage */ mitk::DataStorage* m_DataStorage; /** @brief this pointer holds the tool which is created */ mitk::NavigationTool::Pointer m_CreatedTool; //############## private help methods ####################### /** Shows a message box with the given message s. */ void MessageBox(std::string s); /** Hold the data nodes which are needed for the landmark widgets. */ mitk::DataNode::Pointer m_calLandmarkNode, m_regLandmarkNode; /** Set the tool landmark lists in the UI.*/ void FillUIToolLandmarkLists(mitk::PointSet::Pointer calLandmarks, mitk::PointSet::Pointer regLandmarks); /** Returns the tool landmark lists from the UI. * @param[out] calLandmarks Returns a pointer to the calibration landmarks point set. * @param[out] regLandmarks Returns a pointer to the registration landmarks point set. */ void GetUIToolLandmarksLists(mitk::PointSet::Pointer& calLandmarks, mitk::PointSet::Pointer& regLandmarks); /** Initializes the tool landmark lists in the UI. */ void InitializeUIToolLandmarkLists(); void RefreshTrackingDeviceCollection(); }; #endif diff --git a/Modules/IGTUI/Qmitk/QmitkNavigationToolManagementWidget.h b/Modules/IGTUI/Qmitk/QmitkNavigationToolManagementWidget.h index afe0874bcb..c8bef65e8a 100644 --- a/Modules/IGTUI/Qmitk/QmitkNavigationToolManagementWidget.h +++ b/Modules/IGTUI/Qmitk/QmitkNavigationToolManagementWidget.h @@ -1,112 +1,112 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QMITKNAVIGATIONTOOLMANAGEMENTWIDGET_H #define QMITKNAVIGATIONTOOLMANAGEMENTWIDGET_H //QT headers #include //mitk headers #include "MitkIGTUIExports.h" #include "mitkNavigationTool.h" #include //ui header #include "ui_QmitkNavigationToolManagementWidgetControls.h" /** Documentation: * \brief An object of this class offers an UI to manage NavigationTools and * NavigationToolStorages. This means a user may create, save and load * single NavigationTools and/or NavigationToolStorages with this widget. * * Be sure to call the Initialize-methode before you start the widget * otherwise some errors might occure. * * \ingroup IGTUI */ class MITKIGTUI_EXPORT QmitkNavigationToolManagementWidget : public QWidget { Q_OBJECT public: static const std::string VIEW_ID; /** Initializes the widget. Has to be called before any action, otherwise errors might occur. */ void Initialize(mitk::DataStorage* dataStorage); /** Loads a storage to the widget. The old storage storage is dropped, so be careful, if the * storage is not saved somewhere else it might be lost. You might want to ask the user if he * wants to save the storage to the harddisk before calling this method. * @param storageToLoad This storage will be loaded and might be modified by the user. */ void LoadStorage(mitk::NavigationToolStorage::Pointer storageToLoad); QmitkNavigationToolManagementWidget(QWidget* parent = 0, Qt::WindowFlags f = 0); - ~QmitkNavigationToolManagementWidget(); + ~QmitkNavigationToolManagementWidget() override; signals: /** This signal is emmited if a new storage was added by the widget itself, e.g. because * a storage was loaded from the harddisk. * @param newStorage Holds the new storage which was added. * @param storageName Name of the new storage (e.g. filename) */ void NewStorageAdded(mitk::NavigationToolStorage::Pointer newStorage, std::string storageName); protected slots: //main widget page: void OnAddTool(); void OnDeleteTool(); void OnEditTool(); void OnLoadTool(); void OnSaveTool(); void OnMoveToolUp(); void OnMoveToolDown(); void OnLoadStorage(); void OnSaveStorage(); void OnCreateStorage(); //widget page "add tool": void OnAddToolCancel(); void OnAddToolSave(); protected: /// \brief Creation of the connections virtual void CreateConnections(); virtual void CreateQtPartControl(QWidget *parent); Ui::QmitkNavigationToolManagementWidgetControls* m_Controls; /** @brief holds the DataStorage */ mitk::DataStorage* m_DataStorage; /** @brief holds the NavigationToolStorage we are working with. */ mitk::NavigationToolStorage::Pointer m_NavigationToolStorage; /** @brief shows if we are in edit mode, if not we create new navigation tool objects. */ bool m_edit; //############## private help methods ####################### void MessageBox(std::string s); void UpdateToolTable(); void DisableStorageControls(); void EnableStorageControls(); }; #endif diff --git a/Modules/IGTUI/Qmitk/QmitkNavigationToolStorageSelectionWidget.h b/Modules/IGTUI/Qmitk/QmitkNavigationToolStorageSelectionWidget.h index ca5ed02adb..2bd96adfbd 100644 --- a/Modules/IGTUI/Qmitk/QmitkNavigationToolStorageSelectionWidget.h +++ b/Modules/IGTUI/Qmitk/QmitkNavigationToolStorageSelectionWidget.h @@ -1,82 +1,82 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QmitkNavigationToolStorageSelectionWidget_H #define QmitkNavigationToolStorageSelectionWidget_H //QT headers #include //mitk headers #include "MitkIGTUIExports.h" #include #include #include //ui header #include "ui_QmitkNavigationToolStorageSelectionWidgetControls.h" /** Documentation: * \brief This widget allows the user to select a navigation tool storage. * * The widget lists all navigation tool storages which are available * as microservice via the module context. * * A signal is emmited whenever the tool selection changes. * * \ingroup IGTUI */ class MITKIGTUI_EXPORT QmitkNavigationToolStorageSelectionWidget : public QWidget { Q_OBJECT public: static const std::string VIEW_ID; QmitkNavigationToolStorageSelectionWidget(QWidget* parent = 0, Qt::WindowFlags f = 0); - ~QmitkNavigationToolStorageSelectionWidget(); + ~QmitkNavigationToolStorageSelectionWidget() override; /** @return Returns the currently selected NavigationToolStorage. Returns null if no storage is selected at the moment. */ mitk::NavigationToolStorage::Pointer GetSelectedNavigationToolStorage(); signals: /** @brief This signal is emitted when a new navigation tool storage is selected. * @param storage Holds the new selected navigation tool storage. Is null if the old storage is deselected and no new storage is selected. */ void NavigationToolStorageSelected(mitk::NavigationToolStorage::Pointer storage); protected slots: void NavigationToolStorageSelected(us::ServiceReferenceU s); protected: /// \brief Creation of the connections virtual void CreateConnections(); virtual void CreateQtPartControl(QWidget *parent); Ui::QmitkNavigationToolStorageSelectionWidgetControls* m_Controls; mitk::NavigationToolStorage::Pointer m_CurrentStorage; }; #endif diff --git a/Modules/IGTUI/Qmitk/QmitkOpenIGTLinkWidget.h b/Modules/IGTUI/Qmitk/QmitkOpenIGTLinkWidget.h index a0ebfbb3e5..0f170762c8 100644 --- a/Modules/IGTUI/Qmitk/QmitkOpenIGTLinkWidget.h +++ b/Modules/IGTUI/Qmitk/QmitkOpenIGTLinkWidget.h @@ -1,54 +1,54 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QmitkOpenIGTLinkWidget_H #define QmitkOpenIGTLinkWidget_H #include "ui_QmitkOpenIGTLinkWidget.h" #include "QmitkAbstractTrackingDeviceWidget.h" /** Documentation: * \brief Implementation of a configuration widget to use an Open IGT Link connection to track any device. * * \ingroup IGTUI */ class MITKIGTUI_EXPORT QmitkOpenIGTLinkWidget : public QmitkAbstractTrackingDeviceWidget { Q_OBJECT // this is needed for all Qt objects that should have a MOC object (everything that derives from QObject) public: static const std::string VIEW_ID; QmitkOpenIGTLinkWidget(QWidget* parent = 0, Qt::WindowFlags f = 0); - ~QmitkOpenIGTLinkWidget(); + ~QmitkOpenIGTLinkWidget() override; - virtual void Initialize(); + void Initialize() override; signals: protected slots : private: void CreateQtPartControl(QWidget *parent); protected: - virtual QmitkOpenIGTLinkWidget* Clone(QWidget* parent) const; + QmitkOpenIGTLinkWidget* Clone(QWidget* parent) const override; Ui::QmitkOpenIGTLinkWidget* m_Controls; public: - virtual mitk::TrackingDevice::Pointer ConstructTrackingDevice(); + mitk::TrackingDevice::Pointer ConstructTrackingDevice() override; }; #endif diff --git a/Modules/IGTUI/Qmitk/QmitkToolDistanceWidget.h b/Modules/IGTUI/Qmitk/QmitkToolDistanceWidget.h index 7f1f6310a7..103a6504e3 100644 --- a/Modules/IGTUI/Qmitk/QmitkToolDistanceWidget.h +++ b/Modules/IGTUI/Qmitk/QmitkToolDistanceWidget.h @@ -1,89 +1,89 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef _QmitkToolDistanceWidget_H_INCLUDED #define _QmitkToolDistanceWidget_H_INCLUDED #include "ui_QmitkToolDistanceWidgetControls.h" #include "MitkIGTUIExports.h" #include #include #include /*! \brief QmitkToolDistanceWidget Widget for setting up and controlling an update timer in an IGT-Pipeline. */ class MITKIGTUI_EXPORT QmitkToolDistanceWidget : public QWidget { Q_OBJECT // this is needed for all Qt objects that should have a MOC object (everything that derives from QObject) public: typedef QVector > DistanceLabelType; /*! \brief default constructor */ QmitkToolDistanceWidget( QWidget* parent ); /*! \brief default destructor */ - virtual ~QmitkToolDistanceWidget(); + ~QmitkToolDistanceWidget() override; /*! \brief This method displays the matrix with the distances between the tracking source's outputs in a QGridLayout. */ void ShowDistanceValues(itk::ProcessObject::DataObjectPointerArray & outputs); /*! \brief This method creates the initial distances matrix and labels it with the connected tool names. */ void CreateToolDistanceMatrix(itk::ProcessObject::DataObjectPointerArray & outputs); /*! \brief This method clears the whole tool distances matrix */ void ClearDistanceMatrix(); public slots: /*! \brief This method set's all distance entries in the matrix to "---". Can be used e.g. if tracking is stopped. */ void SetDistanceLabelValuesInvalid(); protected: void CreateConnections(); void CreateQtPartControl( QWidget *parent ); Ui::QmitkToolDistanceWidgetControls* m_Controls; ///< gui widgets private: /*! \brief Double vector for all between tool distances labels. */ DistanceLabelType* m_DistanceLabels; }; #endif // _QmitkToolDistanceWidget_H_INCLUDED diff --git a/Modules/IGTUI/Qmitk/QmitkToolSelectionWidget.h b/Modules/IGTUI/Qmitk/QmitkToolSelectionWidget.h index f466463daf..4f6cf7e251 100644 --- a/Modules/IGTUI/Qmitk/QmitkToolSelectionWidget.h +++ b/Modules/IGTUI/Qmitk/QmitkToolSelectionWidget.h @@ -1,133 +1,133 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef _QmitkToolSelectionWidget_H_INCLUDED #define _QmitkToolSelectionWidget_H_INCLUDED #include "ui_QmitkToolSelectionWidgetControls.h" #include "MitkIGTUIExports.h" #include /*! \brief QmitkToolSelectionWidget Widget for tool selection in an IGT Plugin. Provides a combobx which can be filled with the tool names ( SetToolNames() or AddToolName() ) of a tracking source and a checkbox whose text can be set with AddCheckBoxText(). Toggeling of the checkbox should be used to activate or inactivate a specific action for the selected tool in the IGT Plugin. */ class MITKIGTUI_EXPORT QmitkToolSelectionWidget : public QWidget { Q_OBJECT // this is needed for all Qt objects that should have a MOC object (everything that derives from QObject) public: /*! \brief default constructor */ QmitkToolSelectionWidget( QWidget* parent ); /*! \brief default destructor */ - virtual ~QmitkToolSelectionWidget(); + ~QmitkToolSelectionWidget() override; /*! \brief This method returns the current selected index from the tool combobox. */ int GetCurrentSelectedIndex(); /*! \brief This method sets the list with names of the available tools to the combobox. This method should be used after the initilization of the tracking source. For correct use make sure that the tool names are in the same order as the tools from the tracking source. */ void SetToolNames( const QStringList& toolNames ); /*! \brief This method adds a single tool name at the end of the tool combobox. This method should be used after a tool has been added manually to the tracking source. */ void AddToolName( const QString& toolName); /*! \brief This method changes the tool name in the combobox at the given position. */ void ChangeToolName( int index, const QString& toolName ); /*! \brief This method removes a single tool name from the combobox by name. */ void RemoveToolName( const QString& toolName ); /*! \brief This method removes a single tool name from the combobox by index. */ void RemoveToolName( int index ); /*! \brief This method clears all tool names from the combobox. */ void ClearToolNames(); /*! \brief This method sets the text of the use tool checkbox. */ void SetCheckboxtText( const QString& text); /*! \brief This method returns whether the use tool checkbox is checked or not. */ bool IsSelectedToolActivated(); signals: /*! \brief This signal is emitted when the checkbox is toggled. It provides the current selected tool id and whether it has been selected or deselected. */ void SignalUseTool(int index, bool use); /*! \brief This signal is emitted when a different tool is selected in the combo box. */ void SignalSelectedToolChanged(int index); public slots: /*! \brief Enables this widget. */ void EnableWidget(); /*! \brief Disables this widget. */ void DisableWidget(); protected slots: /*! \brief Slot which emits the SingalUseTool() after providing it with the tool id. */ void CheckBoxToggled(bool checked); protected: /*! \brief Creates this widget's signal slot connections. */ void CreateConnections(); void CreateQtPartControl( QWidget *parent ); Ui::QmitkToolSelectionWidgetControls* m_Controls; ///< gui widgets }; #endif // _QmitkToolSelectionWidget_H_INCLUDED diff --git a/Modules/IGTUI/Qmitk/QmitkToolTrackingStatusWidget.h b/Modules/IGTUI/Qmitk/QmitkToolTrackingStatusWidget.h index c21e4a88f1..cee8cb6aef 100644 --- a/Modules/IGTUI/Qmitk/QmitkToolTrackingStatusWidget.h +++ b/Modules/IGTUI/Qmitk/QmitkToolTrackingStatusWidget.h @@ -1,141 +1,141 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef _QmitkToolTrackingStatusWidget_H_INCLUDED #define _QmitkToolTrackingStatusWidget_H_INCLUDED #include "ui_QmitkToolTrackingStatusWidgetControls.h" #include "MitkIGTUIExports.h" #include #include #include #include #include /*! \brief QmitkToolTrackingStatusWidget Widget for setting up and controlling an update timer in an IGT-Pipeline. */ class MITKIGTUI_EXPORT QmitkToolTrackingStatusWidget : public QWidget { Q_OBJECT // this is needed for all Qt objects that should have a MOC object (everything that derives from QObject) public: typedef std::vector< mitk::NavigationData::Pointer > NavigationDataPointerArray; enum Style { GridLowerStyle, VerticalUpperStyle }; /*! \brief default constructor */ QmitkToolTrackingStatusWidget( QWidget* parent ); /*! \brief default destructor */ - virtual ~QmitkToolTrackingStatusWidget(); + ~QmitkToolTrackingStatusWidget() override; /*! \brief Sets up the labels in this widget's QGridLayout for showing the track status of the tracking tools */ void ShowStatusLabels(); /*! \brief Sets the ND for this widget */ void SetNavigationDatas(std::vector* navDatas); /*! \brief Adds the NavigationData to the existing ones. */ void AddNavigationData(mitk::NavigationData::Pointer nd); /*! \brief Changes background color of status labels (green or red) to show if actual navigation data of each tool is valid. * Depending on usage of SetShowPosition(bool) or SetShowQuaternions(bool) the position coordinates and quaternion values of each tool are shown. * The number of decimal places is set with the parameters posPrecision and quatPrecision. */ void Refresh(int posPrecision = 2, int quatPrecision = 2); /*! \brief Removes all status labels. */ void RemoveStatusLabels(); /** @brief Enables / disables if the tool positions are shown. Default is off.*/ void SetShowPositions(bool enable); /** @brief Enables / disables if the tool quaternions are shown. Default is off.*/ void SetShowQuaternions(bool enable); /** @brief Sets the text alignment of the tool labels. Default is center. Example: Use Qt::AlignLeft for left alignment. */ void SetTextAlignment(Qt::AlignmentFlag alignment); /** @brief Sets the alignment style of this widget: * GridLowerStyle: Tool labels are at the lower side of the widget in grid alignment * VerticalUpperStyle: Tool labels are at the upper side in a vertical alignment (default) */ void SetStyle(QmitkToolTrackingStatusWidget::Style newStyle); /** @brief Shows tool labels for the tools in the tool storage. This method can be called BEFORE connecting the navigation data to * make a preview of the tools. */ void PreShowTools(mitk::NavigationToolStorage::Pointer toolStorage); void OnServiceEvent(const us::ServiceEvent event); protected: void CreateConnections(); void CreateQtPartControl( QWidget *parent ); Ui::QmitkToolTrackingStatusWidgetControls* m_Controls; ///< gui widgets private: /*! \brief Vector for all tool tracking status labels. */ QVector< QLabel* >* m_StatusLabels; std::vector* m_NavigationDatas; bool m_NavDatasNewFlag; bool m_ShowPositions; bool m_ShowQuaternions; Qt::AlignmentFlag m_Alignment; QmitkToolTrackingStatusWidget::Style m_Style; mitk::NavigationToolStorage::Pointer m_previewToolStorage; ///>Tool Storage which is used for preview when tracking is not active... void RemoveGuiLabels(); /** @brief Adds an empty label which tells the user that currently no tool is availiable. */ void AddEmptyLabel(); us::ModuleContext* m_Context; }; #endif // _QmitkToolTrackingStatusWidget_H_INCLUDED diff --git a/Modules/IGTUI/Qmitk/QmitkTrackingDeviceConfigurationWidget.h b/Modules/IGTUI/Qmitk/QmitkTrackingDeviceConfigurationWidget.h index b8b8f8a747..a833054112 100644 --- a/Modules/IGTUI/Qmitk/QmitkTrackingDeviceConfigurationWidget.h +++ b/Modules/IGTUI/Qmitk/QmitkTrackingDeviceConfigurationWidget.h @@ -1,108 +1,108 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QMITKTRACKINGDEVICECONFIGURATIONWIDGET_H #define QMITKTRACKINGDEVICECONFIGURATIONWIDGET_H #include #include #include "MitkIGTUIExports.h" #include "ui_QmitkTrackingDeviceConfigurationWidgetControls.h" #include "mitkTrackingDeviceTypeCollection.h" #include "mitkTrackingDeviceWidgetCollection.h" /** Documentation: * \brief An object of this class offers an UI to configurate * a tracking device. If the user finished the configuration process and * a fully configurated tracking device is availiabe the object emits a * signal "TrackingDeviceConfigurationFinished()". You can then get the * tracking device by calling the method GetTrackingDevice(). * * Once the tracking device is configurated there are two ways to reset * the UI to allow the user for configuring a new device. The method Reset() * can be called and there is also a button "reset" which can be pressed by * the user. In both cases a signal "TrackingDeviceConfigurationReseted()" * is emitted and you may wait for a new configurated tracking device. * * * \ingroup IGTUI */ class MITKIGTUI_EXPORT QmitkTrackingDeviceConfigurationWidget : public QWidget { Q_OBJECT public: static const std::string VIEW_ID; QmitkTrackingDeviceConfigurationWidget(QWidget* parent = 0, Qt::WindowFlags f = 0); - ~QmitkTrackingDeviceConfigurationWidget(); + ~QmitkTrackingDeviceConfigurationWidget() override; /* @return Returns the current configurated tracking device. If the user didn't finished the * configuration process or if there is an error during configuration nullptr is returned. */ mitk::TrackingDevice::Pointer GetTrackingDevice(); signals: /* @brief This signal is sent if the tracking device was changed. */ void TrackingDeviceSelectionChanged(); protected: /// \brief Creation of the connections virtual void CreateConnections(); virtual void CreateQtPartControl(QWidget *parent); Ui::QmitkTrackingDeviceConfigurationWidgetControls* m_Controls; mitk::TrackingDevice::Pointer m_TrackingDevice; // key is port name (e.g. "COM1", "/dev/ttyS0"), value will be filled with the type of tracking device at this port typedef QMap PortDeviceMap; //######################### internal help methods ####################################### void ResetOutput(); void AddOutput(std::string s); mitk::TrackingDevice::Pointer ConstructTrackingDevice(); void StoreUISettings(); void LoadUISettings(); /* @brief This method is called when the user clicks on "Refresh Selection" (m_RefreshTrackingDeviceCollection). It then sets the correct widget for the selected tracking device.*/ void RefreshTrackingDeviceCollection(); protected slots: /* @brief This method is called when the user changes the selection of the trackingdevice (m_trackingDeviceChooser). It then sets the correct widget for the selected tracking device.*/ void TrackingDeviceChanged(); private: PERSISTENCE_GET_SERVICE_METHOD_MACRO std::string GetCurrentDeviceName(void) const; QmitkAbstractTrackingDeviceWidget* GetWidget(const std::string& deviceName) const; /** * @brief Mapping of device type identifier and index of the configuration widget in QStackedWidget. */ std::map m_DeviceToWidgetIndexMap; }; #endif diff --git a/Modules/IGTUI/Qmitk/QmitkTrackingDeviceConfigurationWidgetConnectionWorker.h b/Modules/IGTUI/Qmitk/QmitkTrackingDeviceConfigurationWidgetConnectionWorker.h index 0d17931138..800d00b10a 100644 --- a/Modules/IGTUI/Qmitk/QmitkTrackingDeviceConfigurationWidgetConnectionWorker.h +++ b/Modules/IGTUI/Qmitk/QmitkTrackingDeviceConfigurationWidgetConnectionWorker.h @@ -1,51 +1,51 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QmitkTrackingDeviceConfigurationWidgetConnectionWorker_H #define QmitkTrackingDeviceConfigurationWidgetConnectionWorker_H #include #include "mitkTrackingDevice.h" #include "MitkIGTUIExports.h" // ################################################################################################### //############ PRIVATE WORKER CLASSES FOR THREADS ################################################### //################################################################################################### /** * Worker thread class for test connection. */ class MITKIGTUI_EXPORT QmitkTrackingDeviceConfigurationWidgetConnectionWorker : public QObject { Q_OBJECT; public: QmitkTrackingDeviceConfigurationWidgetConnectionWorker(){}; - ~QmitkTrackingDeviceConfigurationWidgetConnectionWorker(){}; + ~QmitkTrackingDeviceConfigurationWidgetConnectionWorker() override{}; void SetTrackingDevice(mitk::TrackingDevice::Pointer t); public slots: void TestConnectionThreadFunc(); signals: void ConnectionTested(bool connected, QString output); protected: mitk::TrackingDevice::Pointer m_TrackingDevice; }; #endif diff --git a/Modules/IGTUI/Qmitk/QmitkTrackingDeviceConfigurationWidgetScanPortsWorker.h b/Modules/IGTUI/Qmitk/QmitkTrackingDeviceConfigurationWidgetScanPortsWorker.h index 8209eb94d3..25741159c3 100644 --- a/Modules/IGTUI/Qmitk/QmitkTrackingDeviceConfigurationWidgetScanPortsWorker.h +++ b/Modules/IGTUI/Qmitk/QmitkTrackingDeviceConfigurationWidgetScanPortsWorker.h @@ -1,54 +1,54 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QmitkTrackingDeviceConfigurationWidgetScanPortsWorker_H #define QmitkTrackingDeviceConfigurationWidgetScanPortsWorker_H #include #include "mitkTrackingDevice.h" #include "MitkIGTUIExports.h" /** * Worker thread class for scan ports. */ class MITKIGTUI_EXPORT QmitkTrackingDeviceConfigurationWidgetScanPortsWorker : public QObject { Q_OBJECT; public: QmitkTrackingDeviceConfigurationWidgetScanPortsWorker(){}; - ~QmitkTrackingDeviceConfigurationWidgetScanPortsWorker(){}; + ~QmitkTrackingDeviceConfigurationWidgetScanPortsWorker() override{}; public slots: void ScanPortsThreadFunc(); signals: /** * @param Port Returns the port, returns -1 if no device was found. * @param PortType Returns the port type (0=usb,1=tty), returns -1 if the port type is not specified, e.g, in case of Windows. */ void PortsScanned(int Port, QString result, int PortType); protected: /** @brief Scans the given port for a NDI tracking device. * @return Returns the type of the device if one was found. Returns TrackingSystemInvalid if none was found. */ mitk::TrackingDeviceType ScanPort(QString port); }; #endif diff --git a/Modules/IGTUI/Qmitk/QmitkTrackingDeviceWidget.h b/Modules/IGTUI/Qmitk/QmitkTrackingDeviceWidget.h index 0ae67c66b2..06c0740f4a 100644 --- a/Modules/IGTUI/Qmitk/QmitkTrackingDeviceWidget.h +++ b/Modules/IGTUI/Qmitk/QmitkTrackingDeviceWidget.h @@ -1,33 +1,33 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QMITKTRACKINGDEVICEWIDGET_H #define QMITKTRACKINGDEVICEWIDGET_H #include #include "MitkIGTUIExports.h" class MITKIGTUI_EXPORT QmitkTrackingDeviceWidget : public QWidget //MITKIGTUI_EXPORT { Q_OBJECT public: QmitkTrackingDeviceWidget(QWidget* parent = nullptr, Qt::WindowFlags f = nullptr); - ~QmitkTrackingDeviceWidget(); + ~QmitkTrackingDeviceWidget() override; }; #endif diff --git a/Modules/IGTUI/Qmitk/QmitkTrackingSourcesCheckBoxPanelWidget.h b/Modules/IGTUI/Qmitk/QmitkTrackingSourcesCheckBoxPanelWidget.h index 5701d93ef9..6fdc98c910 100644 --- a/Modules/IGTUI/Qmitk/QmitkTrackingSourcesCheckBoxPanelWidget.h +++ b/Modules/IGTUI/Qmitk/QmitkTrackingSourcesCheckBoxPanelWidget.h @@ -1,160 +1,160 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef _QmitkTrackingSourcesCheckBoxPanelWidget_H_INCLUDED #define _QmitkTrackingSourcesCheckBoxPanelWidget_H_INCLUDED #include "ui_QmitkTrackingSourcesCheckBoxPanelWidgetControls.h" #include "MitkIGTUIExports.h" #include #include /*! \brief QmitkTrackingSourcesCheckBoxPanelWidget Widget for setting up and controlling an update timer in an IGT-Pipeline. */ class MITKIGTUI_EXPORT QmitkTrackingSourcesCheckBoxPanelWidget : public QWidget { Q_OBJECT // this is needed for all Qt objects that should have a MOC object (everything that derives from QObject) public: typedef std::vector< QCheckBox* > TrackingSourcesCheckboxes; /// vector with checkboxes for all set NDs /*! \brief default constructor */ QmitkTrackingSourcesCheckBoxPanelWidget( QWidget* parent ); /*! \brief default destructor */ - virtual ~QmitkTrackingSourcesCheckBoxPanelWidget(); + ~QmitkTrackingSourcesCheckBoxPanelWidget() override; /*! \brief Shows the checkboxes */ void ShowSourceCheckboxes(); /*! \brief Sets the ND for this widget */ void SetNavigationDatas(std::vector* navDatas); /*! \brief Adds a ND. */ void AddNavigationData(mitk::NavigationData::Pointer nd); /** \brief Sets this widget's info text. */ void SetInfoText(QString text); /** \brief Sets this widget's action perform button text. */ void SetActionPerformButtonText(QString text); /** \brief Sets whether the action perform button is checkable or not. */ void SetActionPerformButtonCheckable(bool checkable); /** \brief Hides or shows the action perfom button. */ void HideActionPerformButton(bool hide); /** \brief Returns the selected tracking sources IDs. */ const std::vector* GetSelectedTrackingSourcesIDs(); /** \brief Selects all checkboxes in this widget. */ void SelectAll(); /** \brief Deselects all checkboxes in this widget. */ void DeselectAll(); /** \brief Selets the checkbox at the given position. */ void SelectCheckbox(unsigned int idx); /** \brief Deselects the checkbox at the given position */ void DeselectCheckbox(unsigned int idx); /** \brief Enables or disabless the checkboxes in this widget. */ void EnableCheckboxes(bool enable); /** \brief Clears the vector that holds the selected IDs */ void ClearSelectedIDs(); /** \brief Returns whether this widgets "perform action" button is checked */ bool IsActionButtonChecked(); signals: void Selected(int id); /// when a checkbox is selected void Deselected(int id); /// when a checkbox is deselected void PerformAction(); /// when action perfom button is pressed void StopAction(); /// when action perform button is released void Action(); /// when action perfom button is clicked public slots: void ClearPanel(); /// clearing checkboxes from panel protected slots: void OnCheckboxClicked(bool checked); void OnPerformActionClicked(bool toggled); void OnPerformActionClicked(); protected: void CreateConnections(); void CreateQtPartControl( QWidget *parent ); Ui::QmitkTrackingSourcesCheckBoxPanelWidgetControls* m_Controls; ///< gui widgets private: TrackingSourcesCheckboxes* m_SourceCheckboxes; std::vector* m_NavigationDatas; std::vector* m_SelectedIds; }; #endif // _QmitkTrackingSourcesCheckBoxPanelWidget_H_INCLUDED diff --git a/Modules/IGTUI/Qmitk/QmitkUpdateTimerWidget.h b/Modules/IGTUI/Qmitk/QmitkUpdateTimerWidget.h index 4951ec1024..cf0dc04b53 100644 --- a/Modules/IGTUI/Qmitk/QmitkUpdateTimerWidget.h +++ b/Modules/IGTUI/Qmitk/QmitkUpdateTimerWidget.h @@ -1,145 +1,145 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef _QmitkUpdateTimerWidget_H_INCLUDED #define _QmitkUpdateTimerWidget_H_INCLUDED #include "ui_QmitkUpdateTimerWidgetControls.h" #include "MitkIGTUIExports.h" /*! \brief QmitkUpdateTimerWidget Widget for setting up and controlling an update timer in an IGT-Pipeline. */ class MITKIGTUI_EXPORT QmitkUpdateTimerWidget : public QWidget { Q_OBJECT // this is needed for all Qt objects that should have a MOC object (everything that derives from QObject) public: enum WidgetButtons { StartButton, StopButton }; /*! \brief default constructor */ QmitkUpdateTimerWidget( QWidget* parent ); /*! \brief default destructor */ - virtual ~QmitkUpdateTimerWidget(); + ~QmitkUpdateTimerWidget() override; /*! \brief This method returns the timer's timeout interval in msec. */ unsigned int GetTimerInterval(); /*! \brief This method sets the timer's timeout interval in msec. */ void SetTimerInterval( unsigned int msec ); /*! \brief This method starts the timer if it is not already active. */ void StartTimer(); /*! \brief This method stops the timer if it is active at the moment. */ void StopTimer(); /*! \brief This method returns this object's timer. */ QTimer* GetUpdateTimer(); /*! \brief This method sets the given QString for the purpose of this update timer e.g. if "Navigation" is given, the start and stop button will be labeled "Start Navigation" and "Stop Navigation". Furthermore the purpose description is used for the timer status label: "Navigation started ... " in this case. */ void SetPurposeLabelText( QString text ); /*! \brief This method hides the framerate settings spinbox and her labels in the view. */ void HideFramerateSettings( bool hidden ); /*! \brief This method sets the icon for a specific button of the widget. */ void SetIcon( WidgetButtons button, const QIcon& icon ); signals: void Started(); void Stopped(); public slots: void EnableWidget(); void DisableWidget(); protected slots: /*! \brief This method is called when the start button is pressed. It starts the timer using StartTimer(). */ void OnStartTimer(); /*! \brief This method is called when the stop button is pressed. It stops the timer using StopTimer(). */ void OnStopTimer(); /*! \brief This method is called when the value in the spinbox is changed. It updates the timer interval using SetTimerInterval( ). */ void OnChangeTimerInterval( int interval ); protected: void CreateConnections(); void CreateQtPartControl( QWidget *parent ); Ui::QmitkUpdateTimerWidgetControls* m_Controls; ///< gui widgets private: /*! \brief This object's update timer realized by a QTimer */ QTimer* m_UpdateTimer; /*! \brief This method is used to set up the update rate spinbox, min and max range are set and also the step size */ void SetupUpdateRateSB( int min, int max, int step ); /*! \brief This method is used to set the actual framerate (in Hz) as the framerate label text */ void SetFrameRateLabel(); }; #endif // _QmitkUpdateTimerWidget_H_INCLUDED diff --git a/Modules/IGTUI/Qmitk/QmitkVirtualTrackerWidget.h b/Modules/IGTUI/Qmitk/QmitkVirtualTrackerWidget.h index a713d917dc..d1cb353dfd 100644 --- a/Modules/IGTUI/Qmitk/QmitkVirtualTrackerWidget.h +++ b/Modules/IGTUI/Qmitk/QmitkVirtualTrackerWidget.h @@ -1,61 +1,61 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QmitkVirtualTrackerWidget_H #define QmitkVirtualTrackerWidget_H #include "ui_QmitkVirtualTrackerWidget.h" #include "QmitkAbstractTrackingDeviceWidget.h" /** Documentation: * \brief Implementation of a configuration widget for a Vitrual Tracking Device. * * \ingroup IGTUI */ class MITKIGTUI_EXPORT QmitkVirtualTrackerWidget : public QmitkAbstractTrackingDeviceWidget { Q_OBJECT // this is needed for all Qt objects that should have a MOC object (everything that derives from QObject) public: static const std::string VIEW_ID; QmitkVirtualTrackerWidget(QWidget* parent = 0, Qt::WindowFlags f = 0); - ~QmitkVirtualTrackerWidget(); + ~QmitkVirtualTrackerWidget() override; - virtual void Initialize(); + void Initialize() override; signals: protected slots : /* @brief Enables or disables the Gaussian Noise for the VirtualTrackingDevice dependent on the State of the according Checkbox */ void EnableGaussianNoise(); private: /// \brief Creation of the connections void CreateConnections(); void CreateQtPartControl(QWidget *parent); protected: - virtual QmitkVirtualTrackerWidget* Clone(QWidget* parent) const; + QmitkVirtualTrackerWidget* Clone(QWidget* parent) const override; Ui::QmitkVirtualTrackerWidget* m_Controls; public: - virtual mitk::TrackingDevice::Pointer ConstructTrackingDevice(); + mitk::TrackingDevice::Pointer ConstructTrackingDevice() override; }; #endif diff --git a/Modules/MatchPointRegistration/autoload/IO/mitkMatchPointActivator.cpp b/Modules/MatchPointRegistration/autoload/IO/mitkMatchPointActivator.cpp index 50452899b3..e77775995d 100644 --- a/Modules/MatchPointRegistration/autoload/IO/mitkMatchPointActivator.cpp +++ b/Modules/MatchPointRegistration/autoload/IO/mitkMatchPointActivator.cpp @@ -1,48 +1,48 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "mitkMAPRegistrationWrapperIO.h" #include #include namespace mitk { /* * This is the module activator for the "MatchPoint" module. */ class MatchPointActivator : public us::ModuleActivator { public: - void Load(us::ModuleContext* ) + void Load(us::ModuleContext* ) override { m_MAPRegistrationWrapperIO = new MAPRegistrationWrapperIO(); } - void Unload(us::ModuleContext* ) + void Unload(us::ModuleContext* ) override { delete m_MAPRegistrationWrapperIO; } private: mitk::MAPRegistrationWrapperIO* m_MAPRegistrationWrapperIO; }; } US_EXPORT_MODULE_ACTIVATOR(mitk::MatchPointActivator) diff --git a/Modules/MatchPointRegistrationUI/Qmitk/QmitkAlgorithmListModel.h b/Modules/MatchPointRegistrationUI/Qmitk/QmitkAlgorithmListModel.h index 263f1d9ca1..8c755c14ab 100644 --- a/Modules/MatchPointRegistrationUI/Qmitk/QmitkAlgorithmListModel.h +++ b/Modules/MatchPointRegistrationUI/Qmitk/QmitkAlgorithmListModel.h @@ -1,55 +1,55 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QmitkAlgorithmListModel_h #define QmitkAlgorithmListModel_h #include #include // MITK #include "MitkMatchPointRegistrationUIExports.h" // MatchPoint #include /*! \class QmitkAlgorithmListModel Model that takes a list of MatchPoint algorithm dll handles and represents it as model in context of the QT view-model-concept. \warning This class is not yet documented. Use "git blame" and ask the author to provide basic documentation. */ class MITKMATCHPOINTREGISTRATIONUI_EXPORT QmitkAlgorithmListModel : public QAbstractTableModel { Q_OBJECT public: QmitkAlgorithmListModel(QObject *parent = nullptr); - virtual ~QmitkAlgorithmListModel(){}; + ~QmitkAlgorithmListModel() override{}; void SetAlgorithms(::map::deployment::DLLDirectoryBrowser::DLLInfoListType algList); - virtual Qt::ItemFlags flags(const QModelIndex &index) const; - virtual QVariant data(const QModelIndex &index, int role) const; - virtual QVariant headerData(int section, Qt::Orientation orientation, int role) const; - virtual int rowCount(const QModelIndex &parent = QModelIndex()) const; - virtual int columnCount(const QModelIndex &parent = QModelIndex()) const; + Qt::ItemFlags flags(const QModelIndex &index) const override; + QVariant data(const QModelIndex &index, int role) const override; + QVariant headerData(int section, Qt::Orientation orientation, int role) const override; + int rowCount(const QModelIndex &parent = QModelIndex()) const override; + int columnCount(const QModelIndex &parent = QModelIndex()) const override; private: ::map::deployment::DLLDirectoryBrowser::DLLInfoListType m_AlgList; }; #endif // mitkQmitkAlgorithmListModel_h diff --git a/Modules/MatchPointRegistrationUI/Qmitk/QmitkFramesRegistrationJob.h b/Modules/MatchPointRegistrationUI/Qmitk/QmitkFramesRegistrationJob.h index 3721cdaae8..fbb38a26b2 100644 --- a/Modules/MatchPointRegistrationUI/Qmitk/QmitkFramesRegistrationJob.h +++ b/Modules/MatchPointRegistrationUI/Qmitk/QmitkFramesRegistrationJob.h @@ -1,104 +1,104 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef __QMITK_FRAMES_REGISTRATION_JOB_H #define __QMITK_FRAMES_REGISTRATION_JOB_H // QT #include #include // ITK #include // MITK #include #include #include // MatchPoint #include #include #include #include #include // Map4CTK #include "mitkUIDHelper.h" #include #include /** Simple helper job class that could be used to process a frame registration in a paralell thread. * This is e.g. used be plugins to keep the GUI responsive while doing a frame registration*/ class MITKMATCHPOINTREGISTRATIONUI_EXPORT QmitkFramesRegistrationJob : public QObject, public QRunnable, public QmitkMappingJobSettings { // this is needed for all Qt objects that should have a Qt meta-object // (everything that derives from QObject and wants to have signal/slots) Q_OBJECT public: QmitkFramesRegistrationJob(map::algorithm::RegistrationAlgorithmBase *pAlgorithm); - ~QmitkFramesRegistrationJob(); + ~QmitkFramesRegistrationJob() override; - void run(); + void run() override; signals: void Finished(); void Error(QString err); void ResultIsAvailable(mitk::Image::Pointer spResult, const QmitkFramesRegistrationJob *pJob); void AlgorithmIterated(QString info, bool hasIterationCount, unsigned long currentIteration); void LevelChanged(QString info, bool hasLevelCount, unsigned long currentLevel); void AlgorithmStatusChanged(QString info); void AlgorithmInfo(QString info); void FrameProcessed(double progress); void FrameRegistered(double progress); void FrameMapped(double progress); public: // Inputs mitk::BaseData::ConstPointer m_spTargetData; mitk::Image::ConstPointer m_spTargetMask; // job settings mitk::TimeFramesRegistrationHelper::IgnoreListType m_IgnoreList; mitk::NodeUIDType m_TargetDataUID; mitk::NodeUIDType m_TargetMaskDataUID; const map::algorithm::RegistrationAlgorithmBase *GetLoadedAlgorithm() const; private: typedef map::algorithm::facet::IterativeAlgorithmInterface IIterativeAlgorithm; typedef map::algorithm::facet::MultiResRegistrationAlgorithmInterface IMultiResAlgorithm; mitk::Image::Pointer m_spMappedImageNode; ::itk::MemberCommand::Pointer m_spCommand; unsigned long m_ObserverID; map::algorithm::RegistrationAlgorithmBase::Pointer m_spLoadedAlgorithm; mitk::TimeFramesRegistrationHelper::Pointer m_helper; // Helper functions const mitk::Image *GetTargetDataAsImage() const; void OnMapAlgorithmEvent(::itk::Object *, const itk::EventObject &event); }; #endif diff --git a/Modules/MatchPointRegistrationUI/Qmitk/QmitkMAPAlgorithmModel.h b/Modules/MatchPointRegistrationUI/Qmitk/QmitkMAPAlgorithmModel.h index 8d005dc04b..f99b34d818 100644 --- a/Modules/MatchPointRegistrationUI/Qmitk/QmitkMAPAlgorithmModel.h +++ b/Modules/MatchPointRegistrationUI/Qmitk/QmitkMAPAlgorithmModel.h @@ -1,76 +1,76 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QmitkMAPAlgorithmModel_h #define QmitkMAPAlgorithmModel_h #include #include // MITK #include "MitkMatchPointRegistrationUIExports.h" // MatchPoint #include #include /*! \class QmitkMAPAlgorithmModel Helper class that implements a model to handle the MetaProperty interface of a MatchPoint algorithm in contect of the QT view-model-concept. A algorithm can be set as data source for the model. The model retrieves all information through the MetaPropertyInterface. Changes in the view will be propagated by the model into the algorithm. \remarks The model only keep a simple pointer to the MetaPropertyInterface of the algorithm. You have to ensure to reset the algorithm if the pointer goes invalid. \warning This class is not yet documented. Use "git blame" and ask the author to provide basic documentation. */ class MITKMATCHPOINTREGISTRATIONUI_EXPORT QmitkMAPAlgorithmModel : public QAbstractTableModel { Q_OBJECT public: QmitkMAPAlgorithmModel(QObject *parent = nullptr); - virtual ~QmitkMAPAlgorithmModel(){}; + ~QmitkMAPAlgorithmModel() override{}; void SetAlgorithm(map::algorithm::RegistrationAlgorithmBase *pAlgorithm); void SetAlgorithm(map::algorithm::facet::MetaPropertyAlgorithmInterface *pMetaInterface); - virtual Qt::ItemFlags flags(const QModelIndex &index) const; - virtual QVariant data(const QModelIndex &index, int role) const; - virtual QVariant headerData(int section, Qt::Orientation orientation, int role) const; - virtual int rowCount(const QModelIndex &parent = QModelIndex()) const; - virtual int columnCount(const QModelIndex &parent = QModelIndex()) const; - virtual bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole); + Qt::ItemFlags flags(const QModelIndex &index) const override; + QVariant data(const QModelIndex &index, int role) const override; + QVariant headerData(int section, Qt::Orientation orientation, int role) const override; + int rowCount(const QModelIndex &parent = QModelIndex()) const override; + int columnCount(const QModelIndex &parent = QModelIndex()) const override; + bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override; private: void UpdateMetaProperties() const; /** Method uses m_pMetaInterface to retrieve the MetaProperty and unwraps it into an * suitable QVariant depending on the passed QT role. If the MetaProperty type is not supported, the QVariant is * invalid. */ QVariant GetPropertyValue(const map::algorithm::MetaPropertyInfo *pInfo, int role) const; template bool CheckCastAndSetProp(const map::algorithm::MetaPropertyInfo *pInfo, const QVariant &value); bool SetPropertyValue(const map::algorithm::MetaPropertyInfo *pInfo, const QVariant &value); map::algorithm::facet::MetaPropertyAlgorithmInterface *m_pMetaInterface; mutable map::algorithm::facet::MetaPropertyAlgorithmInterface::MetaPropertyVectorType m_MetaProperties; }; #endif diff --git a/Modules/MatchPointRegistrationUI/Qmitk/QmitkMapPropertyDelegate.h b/Modules/MatchPointRegistrationUI/Qmitk/QmitkMapPropertyDelegate.h index 1c0ca5d8d5..3c740cfcf0 100644 --- a/Modules/MatchPointRegistrationUI/Qmitk/QmitkMapPropertyDelegate.h +++ b/Modules/MatchPointRegistrationUI/Qmitk/QmitkMapPropertyDelegate.h @@ -1,82 +1,82 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QmitkPropertyDelegate_h #define QmitkPropertyDelegate_h /// Toolkit includes. #include "mitkBaseProperty.h" #include // MITK #include "MitkMatchPointRegistrationUIExports.h" /// Forward declarations. /// /// \class QmitkPropertyDelegate /// \brief An item delegate for rendering and editing mitk::Properties in a QTableView. /// /// \see QmitkPropertiesTableModel class MITKMATCHPOINTREGISTRATIONUI_EXPORT QmitkMapPropertyDelegate : public QStyledItemDelegate { Q_OBJECT public: /// /// Creates a new PropertyDelegate. /// QmitkMapPropertyDelegate(QObject *parent = 0); /// /// Renders a specific property (overwritten from QItemDelegate) /// - void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const; + void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override; /// /// Create an editor for a specific property (overwritten from QItemDelegate) /// - QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const; + QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const override; /// /// Create an editor for a specific property (overwritten from QItemDelegate) /// - void setEditorData(QWidget *editor, const QModelIndex &index) const; + void setEditorData(QWidget *editor, const QModelIndex &index) const override; /// /// When the user accepts input this func commits the data to the model (overwritten from QItemDelegate) /// - void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const; + void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const override; /// /// \brief Fit an editor to some geometry (overwritten from QItemDelegate) /// - void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const; + void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const override; protected: - bool eventFilter(QObject *o, QEvent *e); + bool eventFilter(QObject *o, QEvent *e) override; private slots: /// /// Invoked when the user accepts editor input, that is when he does not pushes ESC. /// void commitAndCloseEditor(); void showColorDialog(); void ComboBoxCurrentIndexChanged(int index); void SpinBoxValueChanged(const QString &value); }; #endif /* QMITKPROPERTIESTABLEMODEL_H_ */ diff --git a/Modules/MatchPointRegistrationUI/Qmitk/QmitkMappingJob.h b/Modules/MatchPointRegistrationUI/Qmitk/QmitkMappingJob.h index 8aa51baea5..e1e974370c 100644 --- a/Modules/MatchPointRegistrationUI/Qmitk/QmitkMappingJob.h +++ b/Modules/MatchPointRegistrationUI/Qmitk/QmitkMappingJob.h @@ -1,105 +1,105 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef __QMITK_MAPPING_JOB_H #define __QMITK_MAPPING_JOB_H // QT #include #include // ITK #include "itkCommand.h" // MatchPoint #include // MITK #include #include #include #include #include struct MITKMATCHPOINTREGISTRATIONUI_EXPORT QmitkMappingJobSettings { public: /**Job name*/ std::string m_MappedName; /**Indicates of mapper should try to refine geometry (true) or map the data (false)*/ bool m_doGeometryRefinement; /**Indicates if the mapper should allow undefined pixels (true) or mapping should fail (false)*/ bool m_allowUndefPixels; /** Value of undefined pixels. Only relevant if m_allowUndefPixels is true. */ double m_paddingValue; /**Indicates if the mapper should allow pixels that are not covered by the registration (true) or mapping should fail * (false)*/ bool m_allowUnregPixels; /** Value of unreged pixels. Only relevant if m_allowUnregPixels is true. */ double m_errorValue; /** Type of interpolator. Only relevant for images and if m_doGeometryRefinement is false. */ mitk::ImageMappingInterpolator::Type m_InterpolatorType; /** Display name of the interpolator*/ std::string m_InterpolatorLabel; QmitkMappingJobSettings(); }; class MITKMATCHPOINTREGISTRATIONUI_EXPORT QmitkMappingJob : public QObject, public QRunnable, public QmitkMappingJobSettings { // this is needed for all Qt objects that should have a Qt meta-object // (everything that derives from QObject and wants to have signal/slots) Q_OBJECT public: QmitkMappingJob(); - ~QmitkMappingJob(); + ~QmitkMappingJob() override; - void run(); + void run() override; signals: void Error(QString err); /**Signal is emitted to return the mapped data itself. Use it if you are only interested in the mapped data*/ void MapResultIsAvailable(mitk::BaseData::Pointer spMappedData, const QmitkMappingJob *job); void AlgorithmInfo(QString info); public: // Inputs mitk::DataNode::Pointer m_spRegNode; mitk::BaseData::ConstPointer m_spInputData; mitk::NodeUIDType m_InputDataUID; mitk::BaseGeometry::Pointer m_spRefGeometry; const map::core::RegistrationBase *GetRegistration() const; protected: // mapped data. mitk::BaseData::Pointer m_spMappedData; ::itk::MemberCommand::Pointer m_spCommand; unsigned long m_ObserverID; // Helper functions const mitk::Image *GetInputDataAsImage() const; const mitk::PointSet *GetInputDataAsPointSet() const; void OnMapAlgorithmEvent(::itk::Object *, const itk::EventObject &event); }; #endif diff --git a/Modules/MatchPointRegistrationUI/Qmitk/QmitkRegistrationJob.h b/Modules/MatchPointRegistrationUI/Qmitk/QmitkRegistrationJob.h index cfbf51d556..bcb45285d9 100644 --- a/Modules/MatchPointRegistrationUI/Qmitk/QmitkRegistrationJob.h +++ b/Modules/MatchPointRegistrationUI/Qmitk/QmitkRegistrationJob.h @@ -1,105 +1,105 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef __QMITK_REGISTRATION_JOB_H #define __QMITK_REGISTRATION_JOB_H // QT #include #include // ITK #include // MITK #include "mitkUIDHelper.h" #include #include #include // MatchPoint #include #include #include #include #include #include class MITKMATCHPOINTREGISTRATIONUI_EXPORT QmitkRegistrationJob : public QObject, public QRunnable { // this is needed for all Qt objects that should have a Qt meta-object // (everything that derives from QObject and wants to have signal/slots) Q_OBJECT public: QmitkRegistrationJob(::map::algorithm::RegistrationAlgorithmBase *pAlgorithm); - ~QmitkRegistrationJob(); + ~QmitkRegistrationJob() override; - void run(); + void run() override; signals: void Finished(); void Error(QString err); void RegResultIsAvailable(mitk::MAPRegistrationWrapper::Pointer spResultRegistration, const QmitkRegistrationJob *pJob); void AlgorithmIterated(QString info, bool hasIterationCount, unsigned long currentIteration); void LevelChanged(QString info, bool hasLevelCount, unsigned long currentLevel); void AlgorithmStatusChanged(QString info); void AlgorithmInfo(QString info); public: // Inputs mitk::BaseData::ConstPointer m_spTargetData; mitk::BaseData::ConstPointer m_spMovingData; mitk::Image::ConstPointer m_spTargetMask; mitk::Image::ConstPointer m_spMovingMask; // job settings bool m_MapEntity; bool m_StoreReg; bool m_ErrorOccured; std::string m_JobName; mitk::NodeUIDType m_TargetDataUID; mitk::NodeUIDType m_MovingDataUID; mitk::NodeUIDType m_TargetMaskDataUID; mitk::NodeUIDType m_MovingMaskDataUID; const ::map::algorithm::RegistrationAlgorithmBase *GetLoadedAlgorithm() const; protected: typedef ::map::algorithm::facet::IterativeAlgorithmInterface IIterativeAlgorithm; typedef ::map::algorithm::facet::MultiResRegistrationAlgorithmInterface IMultiResAlgorithm; // Result registration. ::map::core::RegistrationBase::Pointer m_spResultRegistration; mitk::DataNode::Pointer m_spRegNode; // mapped image. May be null if m_MapEntity is false. mitk::DataNode::Pointer m_spMappedImageNode; ::itk::MemberCommand::Pointer m_spCommand; unsigned long m_ObserverID; ::map::algorithm::RegistrationAlgorithmBase::Pointer m_spLoadedAlgorithm; // Helper functions const mitk::Image *GetTargetDataAsImage() const; const mitk::Image *GetMovingDataAsImage() const; void OnMapAlgorithmEvent(::itk::Object *, const itk::EventObject &event); }; #endif diff --git a/Modules/OpenIGTLinkUI/Qmitk/QmitkIGTLDeviceCommandWidget.h b/Modules/OpenIGTLinkUI/Qmitk/QmitkIGTLDeviceCommandWidget.h index c4cb93c233..bc0c5b26a0 100644 --- a/Modules/OpenIGTLinkUI/Qmitk/QmitkIGTLDeviceCommandWidget.h +++ b/Modules/OpenIGTLinkUI/Qmitk/QmitkIGTLDeviceCommandWidget.h @@ -1,139 +1,139 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QMITKIGTLDeviceCommandWIDGET_H #define QMITKIGTLDeviceCommandWIDGET_H //QT headers #include #include //mitk headers #include "MitkOpenIGTLinkUIExports.h" #include "mitkIGTLDeviceSource.h" #include "mitkIGTLClient.h" #include "mitkDataStorage.h" //itk #include //ui header #include "ui_QmitkIGTLDeviceCommandWidgetControls.h" /** Documentation: * \brief An object of this class offers an UI to send OpenIGTLink commands. * * * \ingroup OpenIGTLinkUI */ class MITKOPENIGTLINKUI_EXPORT QmitkIGTLDeviceCommandWidget : public QWidget { Q_OBJECT public: static const std::string VIEW_ID; /** * \brief Initializes the widget with the given device. * * The old device is * dropped, so be careful, if the source is not saved somewhere else it might * be lost. You might want to ask the user if he wants to save the changes * before calling this method. * \param device The widget will be initialized corresponding to the state of * this device. */ void Initialize(mitk::IGTLDevice::Pointer device); QmitkIGTLDeviceCommandWidget(QWidget* parent = 0, Qt::WindowFlags f = 0); - ~QmitkIGTLDeviceCommandWidget(); + ~QmitkIGTLDeviceCommandWidget() override; protected slots: void OnCommandChanged(const QString& curCommand); void OnSendCommand(); ///** //* \brief Is called when the current device received a message //*/ //void OnMessageReceived(); ///** //* \brief Is called when the current device received a command //*/ //void OnCommandReceived(); /** * \brief Is called when the current device lost a connection to one of its * sockets */ void OnLostConnection(); /** * \brief Is called when the current device connected to another device */ void OnNewConnection(); /** * \brief Adapts the GUI to the state of the device */ void AdaptGUIToState(); signals: /** * \brief used for thread seperation, the worker thread must not call AdaptGUIToState directly * QT signals are thread safe and seperate the threads */ void AdaptGUIToStateSignal(); protected: /** * \brief Calls AdaptGUIToState() */ void OnDeviceStateChanged(); /// \brief Fills the commands combo box with available commands void FillCommandsComboBox(); /// \brief Creation of the connections virtual void CreateConnections(); virtual void CreateQtPartControl(QWidget *parent); Ui::QmitkIGTLDeviceCommandWidgetControls* m_Controls; /** @brief holds the OpenIGTLink device */ mitk::IGTLDevice::Pointer m_IGTLDevice; igtl::MessageBase::Pointer m_CurrentCommand; /** @brief flag to indicate if the IGTL device is a client or a server */ bool m_IsClient; unsigned long m_MessageReceivedObserverTag; unsigned long m_CommandReceivedObserverTag; unsigned long m_LostConnectionObserverTag; unsigned long m_NewConnectionObserverTag; unsigned long m_StateModifiedObserverTag; //############## private help methods ####################### void DisableSourceControls(); void EnableSourceControls(); }; #endif diff --git a/Modules/OpenIGTLinkUI/Qmitk/QmitkIGTLDeviceSetupConnectionWidget.h b/Modules/OpenIGTLinkUI/Qmitk/QmitkIGTLDeviceSetupConnectionWidget.h index d04fe109fb..dab9020c04 100644 --- a/Modules/OpenIGTLinkUI/Qmitk/QmitkIGTLDeviceSetupConnectionWidget.h +++ b/Modules/OpenIGTLinkUI/Qmitk/QmitkIGTLDeviceSetupConnectionWidget.h @@ -1,180 +1,180 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QmitkIGTLDeviceSetupConnectionWidget_H #define QmitkIGTLDeviceSetupConnectionWidget_H //QT headers #include #include //mitk headers #include "MitkOpenIGTLinkUIExports.h" #include "mitkIGTLDeviceSource.h" #include "mitkIGTLClient.h" #include "mitkDataStorage.h" //itk #include //ui header #include "ui_QmitkIGTLDeviceSetupConnectionWidgetControls.h" /** Documentation: * \brief An object of this class offers an UI to setup the connection of an * OpenIGTLink device. * * * \ingroup OpenIGTLinkUI */ class MITKOPENIGTLINKUI_EXPORT QmitkIGTLDeviceSetupConnectionWidget : public QWidget { Q_OBJECT public: static const std::string VIEW_ID; /** * \brief Initializes the widget with the given device. * * The old device is * dropped, so be careful, if the source is not saved somewhere else it might * be lost. You might want to ask the user if he wants to save the changes * before calling this method. * \param device The widget will be initialized corresponding to the state of * this device. */ void Initialize(mitk::IGTLDevice::Pointer device); QmitkIGTLDeviceSetupConnectionWidget(QWidget* parent = 0, Qt::WindowFlags f = 0); - ~QmitkIGTLDeviceSetupConnectionWidget(); + ~QmitkIGTLDeviceSetupConnectionWidget() override; // /** // * \brief Is called when the current device received a message // */ // void OnMessageReceived(itk::Object* caller, const itk::EventObject&); // /** // * \brief Is called when the current device received a command // */ // void OnCommandReceived(itk::Object* caller, const itk::EventObject&); /** * \brief Is called when the current device lost a connection to one of its * sockets */ void OnLostConnection(); /** * \brief Is called when the current device connected to another device */ void OnNewConnection(); /** * \brief Is called when the current device received a message */ void OnMessageReceived(); /** * \brief Is called when the current device received a message */ void OnMessageSent(); /** * \brief Is called when the current device received a command */ void OnCommandReceived(); protected slots: void OnConnect(); void OnPortChanged(); void OnHostnameChanged(); void OnUpdateFPSLabel(); /** * \brief Enables/Disables the buffering of incoming messages */ void OnBufferIncomingMessages(int state); /** * \brief Enables/Disables the buffering of outgoing messages * * This can be necessary when the data is faster produced then sent */ void OnBufferOutgoingMessages(int state); /** * \brief Adapts the GUI to the state of the device */ void AdaptGUIToState(); signals: /** * \brief used for thread seperation, the worker thread must not call AdaptGUIToState directly. * QT signals are thread safe and seperate the threads */ void AdaptGUIToStateSignal(); protected: /** * \brief Calls AdaptGUIToState() */ void OnDeviceStateChanged(); /** \brief Creation of the connections */ virtual void CreateConnections(); virtual void CreateQtPartControl(QWidget *parent); Ui::QmitkIGTLDeviceSetupConnectionWidgetControls* m_Controls; /** @brief holds the OpenIGTLink device */ mitk::IGTLDevice::Pointer m_IGTLDevice; /** @brief flag to indicate if the IGTL device is a client or a server */ bool m_IsClient; unsigned long m_MessageSentObserverTag; unsigned long m_MessageReceivedObserverTag; unsigned long m_CommandReceivedObserverTag; unsigned long m_LostConnectionObserverTag; unsigned long m_NewConnectionObserverTag; unsigned long m_StateModifiedObserverTag; /** @brief the number of received frames (messages) since the last fps calculation update * * This counter is incremented every time a message is received. When the timer * m_FPSCalculationTimer is fired it is reset to 0 and the number is used to calculate the FPS */ unsigned int m_NumReceivedFramesSinceLastUpdate; /** @brief the number of sent frames (messages) since the last fps calculation update * * This counter is incremented every time a message is sent. When the timer * m_FPSCalculationTimer is fired it is reset to 0 and the number is used to calculate the FPS */ unsigned int m_NumSentFramesSinceLastUpdate; /** @brief the timer used to calculate the frames per second */ QTimer m_FPSCalculationTimer; //############## private help methods ####################### void DisableSourceControls(); // void EnableSourceControls(); void RemoveObserver(); }; #endif diff --git a/Modules/OpenIGTLinkUI/Qmitk/QmitkIGTLDeviceSourceManagementWidget.h b/Modules/OpenIGTLinkUI/Qmitk/QmitkIGTLDeviceSourceManagementWidget.h index 58e33efa81..ef6cb2cd23 100644 --- a/Modules/OpenIGTLinkUI/Qmitk/QmitkIGTLDeviceSourceManagementWidget.h +++ b/Modules/OpenIGTLinkUI/Qmitk/QmitkIGTLDeviceSourceManagementWidget.h @@ -1,132 +1,132 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QMITKIGTLDeviceSourceMANAGEMENTWIDGET_H #define QMITKIGTLDeviceSourceMANAGEMENTWIDGET_H //QT headers #include #include //mitk headers #include "MitkOpenIGTLinkUIExports.h" #include "mitkIGTLDeviceSource.h" #include "mitkIGTLClient.h" #include "mitkDataStorage.h" //itk #include //ui header #include "ui_QmitkIGTLDeviceSourceManagementWidgetControls.h" /** Documentation: * \brief An object of this class offers an UI to manage OpenIGTLink Device * Sources and OpenIGTLink Devices. * * * \ingroup OpenIGTLinkUI */ class MITKOPENIGTLINKUI_EXPORT QmitkIGTLDeviceSourceManagementWidget : public QWidget { Q_OBJECT public: static const std::string VIEW_ID; /** Loads a source to the widget. The old source is dropped, so be careful, * if the source is not saved somewhere else it might be lost. You might * want to ask the user if he wants to save the changes before calling this * method. * @param sourceToLoad This source will be loaded and might be modified * by the user. */ void LoadSource(mitk::IGTLDeviceSource::Pointer sourceToLoad); QmitkIGTLDeviceSourceManagementWidget(QWidget* parent = 0, Qt::WindowFlags f = 0); - ~QmitkIGTLDeviceSourceManagementWidget(); + ~QmitkIGTLDeviceSourceManagementWidget() override; protected slots: void OnSendMessage(); /** * \brief Is called when the current device received a message */ void OnMessageReceived(); /** * \brief Is called when the current device received a command */ void OnCommandReceived(); /** * \brief Is called when the current device lost a connection to one of its * sockets */ void OnLostConnection(); /** * \brief Is called when the current device connected to another device */ void OnNewConnection(); /** * \brief Adapts the GUI to the state of the device */ void AdaptGUIToState(); signals: /** * \brief used for thread seperation, the worker thread must not call AdaptGUIToState directly * QT signals are thread safe and seperate the threads */ void AdaptGUIToStateSignal(); protected: /** * \brief Calls AdaptGUIToState() */ void OnDeviceStateChanged(); /// \brief Fills the commands combo box with available commands void FillCommandsComboBox(); /// \brief Creation of the connections virtual void CreateConnections(); virtual void CreateQtPartControl(QWidget *parent); Ui::QmitkIGTLDeviceSourceManagementWidgetControls* m_Controls; /** @brief holds the OpenIGTLink device */ mitk::IGTLDevice::Pointer m_IGTLDevice; /** @brief holds the IGTLDeviceSource we are working with. */ mitk::IGTLDeviceSource::Pointer m_IGTLDeviceSource; /** @brief flag to indicate if the IGTL device is a client or a server */ bool m_IsClient; unsigned long m_MessageReceivedObserverTag; unsigned long m_CommandReceivedObserverTag; unsigned long m_LostConnectionObserverTag; unsigned long m_NewConnectionObserverTag; unsigned long m_StateModifiedObserverTag; //############## private help methods ####################### void DisableSourceControls(); }; #endif diff --git a/Modules/OpenIGTLinkUI/Qmitk/QmitkIGTLDeviceSourceSelectionWidget.h b/Modules/OpenIGTLinkUI/Qmitk/QmitkIGTLDeviceSourceSelectionWidget.h index 7947da098b..39798535a3 100644 --- a/Modules/OpenIGTLinkUI/Qmitk/QmitkIGTLDeviceSourceSelectionWidget.h +++ b/Modules/OpenIGTLinkUI/Qmitk/QmitkIGTLDeviceSourceSelectionWidget.h @@ -1,84 +1,84 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QmitkIGTLDeviceSourceSelectionWidget_H #define QmitkIGTLDeviceSourceSelectionWidget_H //QT headers #include //mitk headers #include "MitkOpenIGTLinkUIExports.h" #include "mitkIGTLDeviceSource.h" //#include //#include #include //ui header #include "ui_QmitkIGTLDeviceSourceSelectionWidgetControls.h" /** Documentation: * \brief This widget allows the user to select a OpenIGTLink device source. * * The widget lists all OpenIGTLink device sources which are available * as microservice via the module context. * * A signal is emmited whenever the device selection changes. * * \ingroup OpenIGTLinkUI */ class MITKOPENIGTLINKUI_EXPORT QmitkIGTLDeviceSourceSelectionWidget : public QWidget { Q_OBJECT public: static const std::string VIEW_ID; QmitkIGTLDeviceSourceSelectionWidget(QWidget* parent = 0, Qt::WindowFlags f = 0); - ~QmitkIGTLDeviceSourceSelectionWidget(); + ~QmitkIGTLDeviceSourceSelectionWidget() override; /** @return Returns the currently selected OpenIGTLink device source. * Returns null if no source is selected at the moment. */ mitk::IGTLDeviceSource::Pointer GetSelectedIGTLDeviceSource(); signals: /** @brief This signal is emitted when a new OpenIGTLink device source is * selected. * @param source Holds the new selected OpenIGTLink device source. Is null * if the old source is deselected and no new source is selected. */ void IGTLDeviceSourceSelected(mitk::IGTLDeviceSource::Pointer source); protected slots: void IGTLDeviceSourceSelected(us::ServiceReferenceU s); protected: /// \brief Creation of the connections virtual void CreateConnections(); virtual void CreateQtPartControl(QWidget *parent); Ui::QmitkIGTLDeviceSourceSelectionWidgetControls* m_Controls; mitk::IGTLDeviceSource::Pointer m_CurrentIGTLDeviceSource; }; #endif diff --git a/Modules/OpenIGTLinkUI/Qmitk/QmitkIGTLMessageSourceSelectionWidget.h b/Modules/OpenIGTLinkUI/Qmitk/QmitkIGTLMessageSourceSelectionWidget.h index 96231b70cf..6ad1080bc2 100644 --- a/Modules/OpenIGTLinkUI/Qmitk/QmitkIGTLMessageSourceSelectionWidget.h +++ b/Modules/OpenIGTLinkUI/Qmitk/QmitkIGTLMessageSourceSelectionWidget.h @@ -1,87 +1,87 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QmitkIGTLMessageSourceSelectionWidget_H #define QmitkIGTLMessageSourceSelectionWidget_H //QT headers #include //mitk headers #include "MitkOpenIGTLinkUIExports.h" #include "mitkIGTLMessageSource.h" //us #include //ui header #include "ui_QmitkIGTLMessageSourceSelectionWidgetControls.h" /** Documentation: * \brief This widget allows the user to select a OpenIGTLink message source. * * The widget lists all OpenIGTLink message sources which are available * as microservice via the module context. * * A signal is emmited whenever the selection changes. * * \ingroup OpenIGTLinkUI */ class MITKOPENIGTLINKUI_EXPORT QmitkIGTLMessageSourceSelectionWidget : public QWidget { Q_OBJECT public: static const std::string VIEW_ID; QmitkIGTLMessageSourceSelectionWidget(QWidget* parent = 0, Qt::WindowFlags f = 0); - ~QmitkIGTLMessageSourceSelectionWidget(); + ~QmitkIGTLMessageSourceSelectionWidget() override; /** @return Returns the currently selected OpenIGTLink message source. * Returns null if no source is selected at the moment. */ mitk::IGTLMessageSource::Pointer GetSelectedIGTLMessageSource(); signals: /** @brief This signal is emitted when a new OpenIGTLink message source is * selected. * @param source Holds the new selected OpenIGTLink device source. Is null * if the old source is deselected and no new source is selected. */ void IGTLMessageSourceSelected(mitk::IGTLMessageSource::Pointer source); protected slots: void IGTLMessageSourceSelected(us::ServiceReferenceU s); protected: /// \brief Creation of the connections virtual void CreateConnections(); virtual void CreateQtPartControl(QWidget *parent); Ui::QmitkIGTLMessageSourceSelectionWidgetControls* m_Controls; mitk::IGTLMessageSource::Pointer m_CurrentIGTLMessageSource; }; #endif diff --git a/Modules/OpenIGTLinkUI/Qmitk/QmitkIGTLStreamingConnector.h b/Modules/OpenIGTLinkUI/Qmitk/QmitkIGTLStreamingConnector.h index 95a4023aa3..5a65ab4a12 100644 --- a/Modules/OpenIGTLinkUI/Qmitk/QmitkIGTLStreamingConnector.h +++ b/Modules/OpenIGTLinkUI/Qmitk/QmitkIGTLStreamingConnector.h @@ -1,87 +1,87 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QMITKIGTLSTREAMINGCONNECTOR_H #define QMITKIGTLSTREAMINGCONNECTOR_H //QT headers #include //mitk headers #include "MitkOpenIGTLinkUIExports.h" #include "mitkIGTLMessageSource.h" #include "mitkIGTLMessageProvider.h" /** Documentation: * \brief This class is used to stream messages from a IGTL message source * into the sending queue of a message provider. * * The data from the queue will be send to the requesting device. * * This class is just needed because of the qtimer functionality. Check also * the MessageProvider for more information. * * \ingroup OpenIGTLinkUI */ class MITKOPENIGTLINKUI_EXPORT QmitkIGTLStreamingConnector : public QObject { Q_OBJECT public: static const std::string VIEW_ID; QmitkIGTLStreamingConnector(QObject* parent = 0); - ~QmitkIGTLStreamingConnector(); + ~QmitkIGTLStreamingConnector() override; /** @brief Sets the message source that is the end of the pipeline and the * message provider which will send the message */ void Initialize(mitk::IGTLMessageSource::Pointer msgSource, mitk::IGTLMessageProvider::Pointer msgProvider); protected slots: /** @brief checks the fps of the message source, if it is unequal 0 the * streaming is started. */ void OnCheckFPS(); /** @brief updates the message source and sends the latest output to the * provider */ void OnUpdateSource(); protected: /** @brief holds the message source that has to stream its data */ mitk::IGTLMessageSource::Pointer m_IGTLMessageSource; /** @brief holds the message provider that will send the stream data from the * source */ mitk::IGTLMessageProvider::Pointer m_IGTLMessageProvider; /** @brief the timer that is configured depending on the fps, if it is * fired the pipeline is updated and the IGTLMessage added to the sending * queue */ QTimer m_StreamingTimer; /** @brief Everytime this timer is fired the fps of the message source are * checked and the streaming is started or stopped */ QTimer m_CheckFPSTimer; static const unsigned int MILISECONDS_BETWEEN_FPS_CHECK; }; #endif diff --git a/Modules/OpenIGTLinkUI/Qmitk/QmitkIGTLStreamingManagementWidget.h b/Modules/OpenIGTLinkUI/Qmitk/QmitkIGTLStreamingManagementWidget.h index 8e37b4d313..eca0abe04a 100644 --- a/Modules/OpenIGTLinkUI/Qmitk/QmitkIGTLStreamingManagementWidget.h +++ b/Modules/OpenIGTLinkUI/Qmitk/QmitkIGTLStreamingManagementWidget.h @@ -1,171 +1,171 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QMITKIGTLStreamingMANAGEMENTWIDGET_H #define QMITKIGTLStreamingMANAGEMENTWIDGET_H //QT headers #include #include //mitk headers #include "MitkOpenIGTLinkUIExports.h" #include "mitkIGTLMessageProvider.h" #include "mitkIGTLClient.h" #include "mitkDataStorage.h" //itk #include //ui header #include "ui_QmitkIGTLStreamingManagementWidgetControls.h" /** Documentation: * \brief An object of this class offers an UI to manage the streaming of * message sources. * * * \ingroup OpenIGTLinkUI */ class MITKOPENIGTLINKUI_EXPORT QmitkIGTLStreamingManagementWidget : public QWidget { Q_OBJECT public: static const std::string VIEW_ID; /** Loads a provider to the widget. The old source is dropped, so be careful, * if the source is not saved somewhere else it might be lost. You might * want to ask the user if he wants to save the changes before calling this * method. * @param provider This provider will be loaded and might be modified * by the user. */ void LoadSource(mitk::IGTLMessageProvider::Pointer provider); QmitkIGTLStreamingManagementWidget(QWidget* parent = 0, Qt::WindowFlags f = 0); - ~QmitkIGTLStreamingManagementWidget(); + ~QmitkIGTLStreamingManagementWidget() override; protected slots: void OnStartStreaming(); void OnStopStreaming(); void OnStreamingTimerTimeout(); /** \brief Is called when a new source is selected. * @param source the newly selected source */ void SourceSelected(mitk::IGTLMessageSource::Pointer source); /** * \brief Adapts the GUI to the state of the device */ void AdaptGUIToState(); /** * \brief selects the current source and adapts the GUI according to the selection */ void SelectSourceAndAdaptGUI(); signals: /** * \brief used for thread seperation, the worker thread must not call AdaptGUIToState directly. * QT signals are thread safe and seperate the threads */ void AdaptGUIToStateSignal(); /** * \brief used for thread seperation, the worker thread must not call SelectSourceAndAdaptGUI * directly. * QT signals are thread safe and seperate the threads */ void SelectSourceAndAdaptGUISignal(); protected: /** * \brief Is called when the current device received a message */ void OnMessageReceived(); /** * \brief Is called when the current device received a command */ void OnCommandReceived(); /** * \brief Is called when the current device lost a connection to one of its * sockets */ void OnLostConnection(); /** * \brief Is called when the current device connected to another device */ void OnNewConnection(); /** * \brief Is called when provider requests the start of the streaming timer */ void OnStartStreamingTimer(); /** * \brief Is called when provider requests the stop of the streaming timer */ void OnStopStreamingTimer(); /** * \brief Calls AdaptGUIToState() */ void OnDeviceStateChanged(); /// \brief Fills the commands combo box with available commands void FillCommandsComboBox(); /// \brief Creation of the connections virtual void CreateConnections(); virtual void CreateQtPartControl(QWidget *parent); Ui::QmitkIGTLStreamingManagementWidgetControls* m_Controls; /** @brief holds the OpenIGTLink device */ mitk::IGTLDevice::Pointer m_IGTLDevice; /** @brief holds the IGTL Message Provider that will send the stream */ mitk::IGTLMessageProvider::Pointer m_IGTLMsgProvider; /** @brief holds the IGTLDeviceSource we are working with. */ mitk::IGTLMessageSource::Pointer m_IGTLMsgSource; /** @brief flag to indicate if the IGTL device is a client or a server */ bool m_IsClient; /** @brief the streaming timer that periodically calls the update method of the provider */ QTimer m_StreamingTimer; unsigned long m_MessageReceivedObserverTag; unsigned long m_CommandReceivedObserverTag; unsigned long m_LostConnectionObserverTag; unsigned long m_NewConnectionObserverTag; unsigned long m_StateModifiedObserverTag; unsigned long m_StartStreamingTimerObserverTag; unsigned long m_StopStreamingTimerObserverTag; //############## private help methods ####################### void DisableSourceControls(); void RemoveObserver(); }; #endif diff --git a/Modules/Python/autoload/PythonService/mitkPythonActivator.cpp b/Modules/Python/autoload/PythonService/mitkPythonActivator.cpp index a0254b6a17..7d770d44d2 100644 --- a/Modules/Python/autoload/PythonService/mitkPythonActivator.cpp +++ b/Modules/Python/autoload/PythonService/mitkPythonActivator.cpp @@ -1,67 +1,67 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef mitkPythonActivator_h #define mitkPythonActivator_h // Microservices #include #include "usModuleContext.h" #include "mitkPythonService.h" #include namespace mitk { /// /// installs the PythonService /// runs all initial commands (setting env paths etc) /// class PythonActivator : public us::ModuleActivator { public: - void Load(us::ModuleContext* context) + void Load(us::ModuleContext* context) override { MITK_DEBUG << "PythonActivator::Load"; // Registering PythonService as MicroService m_PythonService = itk::SmartPointer(new PythonService()); us::ServiceProperties _PythonServiceProps; _PythonServiceProps["Name"] = std::string("PythonService"); m_PythonServiceRegistration = context->RegisterService(m_PythonService.GetPointer(), _PythonServiceProps); } - void Unload(us::ModuleContext*) + void Unload(us::ModuleContext*) override { MITK_DEBUG("PythonActivator") << "PythonActivator::Unload"; MITK_DEBUG("PythonActivator") << "m_PythonService GetReferenceCount " << m_PythonService->GetReferenceCount(); m_PythonServiceRegistration.Unregister(); m_PythonService->Delete(); MITK_DEBUG("PythonActivator") << "m_PythonService GetReferenceCount " << m_PythonService->GetReferenceCount(); } - virtual ~PythonActivator() + ~PythonActivator() override { } private: itk::SmartPointer m_PythonService; us::ServiceRegistration m_PythonServiceRegistration; }; } US_EXPORT_MODULE_ACTIVATOR(mitk::PythonActivator) #endif diff --git a/Modules/QtOverlays/QmitkOverlay.h b/Modules/QtOverlays/QmitkOverlay.h index 3a21ac5b52..265b4680f8 100644 --- a/Modules/QtOverlays/QmitkOverlay.h +++ b/Modules/QtOverlays/QmitkOverlay.h @@ -1,125 +1,125 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef MITKOVERLAY_H_HEADER_INCLUDED_C10DC4EB #define MITKOVERLAY_H_HEADER_INCLUDED_C10DC4EB // MITK #include "mitkCommon.h" #include "mitkPropertyList.h" // Qt #include #include /** \brief Abstract base class for all overlay-objects in MITK This class is the basis for all classes representing objects that can be visualized as overlays in MITK. It encapsulates an ID, as well as a display-position and a layer. The ID is used to access mitkProperties in a PropertyList that holds information that is needed for the visualization, e.g. text for TextOverlays or scaleFactor for ScalarBarOverlays ... The display-position encodes where on the screen the overlay will be positioned at (see and USE the constants defined by DisplayPosition): \verbatim 0 - 1 - 2 | | | 3 - - 4 | | | 5 - 6 - 7 \endverbatim The layer is needed if several overlays shall be put in the same position. In this case the layer defines the order in which the objects are layouted. \ingroup Qmitk */ class MITKQTOVERLAYS_EXPORT QmitkOverlay : public QObject { Q_OBJECT public: /** \brief enumeration of all possible display positions */ enum DisplayPosition { top_Left = 0, top_Center = 1, top_Right = 2, middle_Left = 3, middle_Right = 4, bottom_Left = 5, bottom_Center = 6, bottom_Right = 7 }; /** * @brief Constructor with string ID **/ QmitkOverlay(const char *id); /** * @brief Default Destructor **/ - virtual ~QmitkOverlay(); + ~QmitkOverlay() override; /** \brief setter for the display-position */ virtual void SetPosition(DisplayPosition); /** \brief getter for the display-position */ virtual DisplayPosition GetPosition(); /** \brief setter for the layer */ virtual void SetLayer(unsigned int); /** \brief getter for the layer */ virtual unsigned int GetLayer(); /** * \brief abstract method to internally setup the overlay */ virtual void GenerateData(mitk::PropertyList::Pointer /*pl*/){}; /** * \brief returns the internally handled QWidget */ virtual QWidget *GetWidget(); virtual QSize GetNeededSize() = 0; protected: /** \brief Add drop shadow effect via QGraphicsEffect */ void AddDropShadow(QWidget *widget); /** \brief ID of the overlay */ const char *m_Id; /** \brief position of the overlay */ DisplayPosition m_Position; /** \brief layer of the overlay */ unsigned int m_Layer; /** \brief internal QWidget representing the overlay */ QWidget *m_Widget; bool m_WidgetIsCustom; }; #endif /* MITKOVERLAY_H_HEADER_INCLUDED_C10DC4EB */ diff --git a/Modules/QtOverlays/QmitkOverlayController.h b/Modules/QtOverlays/QmitkOverlayController.h index eeab2c2197..68dfc8cfe8 100644 --- a/Modules/QtOverlays/QmitkOverlayController.h +++ b/Modules/QtOverlays/QmitkOverlayController.h @@ -1,160 +1,160 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef MITKOVERLAYCONTROLLER_H_HEADER_INCLUDED_C1E77191 #define MITKOVERLAYCONTROLLER_H_HEADER_INCLUDED_C1E77191 // MITK-Stuff #include "QmitkOverlay.h" #include "mitkCommon.h" #include "mitkPropertyList.h" #include #include #include class QmitkRenderWindow; /** \class QmitkOverlayController * \brief controller that manages the positioning and stacking of QmitkOverlays * * This controller manages all QmitkOverlays of one QmitkRenderWindow. * * When constructed, it creates one QWidget for each possible display-position and sets the * appropriate attributes and layouts. * * It is possible to add new Overlays using AddOverlay( QmitkOverlay ). * This overlay will be added to the correct Widget according to its destined position (stored in QmitkOverlay). * If this widget already holds an overlay, the layer-property is taken into account. If no layer has been set, * the overlay will be appended at the end. * * It is possible to set the visibility of all overlays at a time using SetOverlayVisibility(bool). * * RenderWindow specific properties can be set using the internal mitk::PropertyList. This propertyList and the * 'default' propertyList of the RenderingManager will be concatenated before the overlay is set up. * If one property exists in both propertyLists, the one in the QmitkOverlayController will be used! * * \sa QmitkOverlay * \sa QmitkRenderWindow * \ingroup Qmitk */ class MITKQTOVERLAYS_EXPORT QmitkOverlayController : public QObject { Q_OBJECT public: /** * \brief constructor with mandatory QmitkRenderWindow and optional mitk::PropertyList */ QmitkOverlayController(QmitkRenderWindow *rw, mitk::PropertyList *pl = nullptr); - virtual ~QmitkOverlayController(); + ~QmitkOverlayController() override; /** * \brief adds an instance of QmitkOverlay to the RenderWindow * * This method adds the given QmitkOverlay as a sub-widget to the registered RenderWindow. * It will be added to the correct position in the RenderWindow as it's defined by the overlays * position-variable. The layer-property will only be considered if necessary. */ void AddOverlay(QmitkOverlay *); void RemoveOverlay(QmitkOverlay *); void RemoveAllOverlays(); /** * \brief setting the visibility of all overlays */ void SetOverlayVisibility(bool visible); /** * \brief getter for the RenderWindow-specific PropertyList */ mitk::PropertyList *GetPropertyList(); /** * \brief setter for the RenderWindow-specific PropertyList */ void SetPropertyList(mitk::PropertyList *); public slots: /** * \brief adjusts the position of all overlays to the position of the RenderWindow * * This method updates the position of all Widgets according to the position of the RenderWindow * and the extend of the overlays. */ void AdjustAllOverlayPosition(); void AdjustOverlayPosition(QmitkOverlay::DisplayPosition displayPosition); void UpdateAllOverlays(); void UpdateOverlayData(QmitkOverlay *overlay); protected: /** * \brief setting up the widgets that will hold all overlays * * This method sets up the 8 QWidgets that will later hold all QmitkOverlays. * This includes the correct setting of layouts, alignments and the widget * attributes necessary to achieve a translucent background and correct rendering * on all platforms. */ void InitializeOverlayLayout(); /** * \brief re-aligning the overlays - not implemented yet */ virtual void AlignOverlays(); /** * \brief initializes one QWidget - internally used by InitializeOverlayLayout() */ void InitializeWidget(QmitkOverlay::DisplayPosition pos); void RestackOverlays(QmitkOverlay::DisplayPosition pos); QSize GetMinimumSizeForWidget(QmitkOverlay::DisplayPosition displayPosition); typedef std::map OverlayPositionMap; typedef std::vector OverlayVector; /** * \brief all QmitkOverlays that are currently added */ OverlayVector m_AllOverlays; /** * \brief all possible positions and the QWidgets representing the corresponding QmitkOverlays */ OverlayPositionMap m_PositionedOverlays; /** * \brief RenderWindow that all Overlays will be added to */ QmitkRenderWindow *m_RenderWindow; /** * \brief PropertyList for RenderWindow-specific properties */ mitk::PropertyList::Pointer m_PropertyList; }; #endif /* MITKOVERLAYCONTROLLER_H_HEADER_INCLUDED_C1E77191 */ diff --git a/Modules/QtOverlays/QmitkScalarBar.h b/Modules/QtOverlays/QmitkScalarBar.h index fc2f8bea1a..7a26b9077f 100644 --- a/Modules/QtOverlays/QmitkScalarBar.h +++ b/Modules/QtOverlays/QmitkScalarBar.h @@ -1,77 +1,77 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef MITKSCALARBAR_H_HEADER_INCLUDED_C10DC4EB #define MITKSCALARBAR_H_HEADER_INCLUDED_C10DC4EB #include #include #include #include class MITKQTOVERLAYS_EXPORT QmitkScalarBar : public QWidget { Q_OBJECT public: enum alignment { vertical = 0, horizontal = 1 }; /** * @brief Default Constructor **/ QmitkScalarBar(QWidget *parent = nullptr); /** * @brief Default Destructor **/ - virtual ~QmitkScalarBar(); + ~QmitkScalarBar() override; virtual void SetScaleFactor(double scale); virtual void SetAlignment(alignment align); void SetPen(const QPen &pen); void SetNumberOfSubdivisions(unsigned int subs); unsigned int GetNumberOfSubdivisions(); protected: void paintEvent(QPaintEvent *event) override; void SetupGeometry(alignment align); void CleanUpLines(); // void moveEvent(QMoveEvent*); alignment m_Alignment; double m_ScaleFactor; QLine *m_MainLine; std::vector m_SubDivisionLines; QPen m_Pen; unsigned int m_NumberOfSubDivisions; }; #endif /* MITKSCALARBAR_H_HEADER_INCLUDED_C10DC4EB */ diff --git a/Modules/QtOverlays/QmitkScalarBarOverlay.h b/Modules/QtOverlays/QmitkScalarBarOverlay.h index 13ee5b21d0..ac576774f2 100644 --- a/Modules/QtOverlays/QmitkScalarBarOverlay.h +++ b/Modules/QtOverlays/QmitkScalarBarOverlay.h @@ -1,85 +1,85 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef MITKSCALARBAROVERLAY_H_HEADER_INCLUDED_C10DC4EB #define MITKSCALARBAROVERLAY_H_HEADER_INCLUDED_C10DC4EB #include // MITK-Stuff #include "QmitkOverlay.h" #include "mitkCommon.h" #include "mitkPropertyList.h" #include /** \class QmitkScalarBarOverlay * \brief object representing a text that is drawn as an overlay * * \ingroup Qmitk */ class MITKQTOVERLAYS_EXPORT QmitkScalarBarOverlay : public QmitkOverlay { Q_OBJECT public: /** * @brief Default Constructor **/ QmitkScalarBarOverlay(const char *id); /** * @brief Default Destructor **/ - virtual ~QmitkScalarBarOverlay(); + ~QmitkScalarBarOverlay() override; /** * \brief Setup the QLabel with overlay specific information * * First, this method sets text-overlay specific properties as described in the class docu above. * Secondly, the actual text of the label is set. * * \WARNING No error will be issued if the property containing the text is not found, the TextOverlay * will show an empty string! */ - virtual void GenerateData(mitk::PropertyList::Pointer) override; + void GenerateData(mitk::PropertyList::Pointer) override; QSize GetNeededSize() override; protected: /** * \brief internal helper class to determine text-properties * * This method is only used internally to apply the text specific properties that can be set * using a mitk::PropertyList. If a property cannot be found, a default value is used. * * The values of these properties are then attributed to the label using QFont and QPalette. */ void GetProperties(mitk::PropertyList::Pointer); void SetupCallback(mitk::BaseProperty::Pointer prop); void SetScaleFactor(); /** \brief QWidget internally representing the TextOverlay */ QmitkScalarBar *m_ScalarBar; mitk::BaseProperty::Pointer m_ObservedProperty; mitk::PropertyList::Pointer m_PropertyList; unsigned long m_ObserverTag; }; #endif /* MITKSCALARBAROVERLAY_H_HEADER_INCLUDED_C10DC4EB */ diff --git a/Modules/QtPython/QmitkCtkPythonShell.h b/Modules/QtPython/QmitkCtkPythonShell.h index beabdce287..94e66d482d 100644 --- a/Modules/QtPython/QmitkCtkPythonShell.h +++ b/Modules/QtPython/QmitkCtkPythonShell.h @@ -1,60 +1,60 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QmitkCtkPythonShell_h #define QmitkCtkPythonShell_h #include #include #include /// /// forward declarations /// struct QmitkCtkPythonShellData; class ctkAbstractPythonManager; class QDragEnterEvent; class QDropEvent; class QMimeData; /// /// Reimplements the ctkPythonConsole with drag and drop functionality for text /// Furthermore it calls NotifyObserver() on the IPythonService to inform listeners /// class MITKQTPYTHON_EXPORT QmitkCtkPythonShell : public ctkPythonConsole { Q_OBJECT public: QmitkCtkPythonShell(QWidget* parent = 0); - ~QmitkCtkPythonShell(); + ~QmitkCtkPythonShell() override; public slots: void Paste( const QString& command ); protected: - void dragEnterEvent(QDragEnterEvent *event); - void dropEvent(QDropEvent *event); + void dragEnterEvent(QDragEnterEvent *event) override; + void dropEvent(QDropEvent *event) override; bool canInsertFromMimeData( const QMimeData *source ) const; - void executeCommand(const QString& command); + void executeCommand(const QString& command) override; private: QmitkCtkPythonShellData* d; }; #endif // QmitkCtkPythonShell_h diff --git a/Modules/QtPython/QmitkPythonScriptEditorHighlighter.h b/Modules/QtPython/QmitkPythonScriptEditorHighlighter.h index 96171f8f0b..6b56b65735 100644 --- a/Modules/QtPython/QmitkPythonScriptEditorHighlighter.h +++ b/Modules/QtPython/QmitkPythonScriptEditorHighlighter.h @@ -1,40 +1,40 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QmitkPythonScriptEditorHighlighter_h #define QmitkPythonScriptEditorHighlighter_h #include #include /// /// A script highlighter for Python Scripts class MITKQTPYTHON_EXPORT QmitkPythonScriptEditorHighlighter : public QSyntaxHighlighter { Q_OBJECT public: QmitkPythonScriptEditorHighlighter(QTextDocument *parent); - virtual ~QmitkPythonScriptEditorHighlighter(); + ~QmitkPythonScriptEditorHighlighter() override; protected: - void highlightBlock(const QString &text); + void highlightBlock(const QString &text) override; void highlightComments(const QString &text); private: }; #endif // QmitkPythonScriptEditorHighlighter_h diff --git a/Modules/QtPython/QmitkPythonSnippets.h b/Modules/QtPython/QmitkPythonSnippets.h index d38ac4bd5f..976df8fc7d 100644 --- a/Modules/QtPython/QmitkPythonSnippets.h +++ b/Modules/QtPython/QmitkPythonSnippets.h @@ -1,105 +1,105 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef _QmitkPythonSnippets_H #define _QmitkPythonSnippets_H #include #include #include struct QmitkPythonSnippetsData; /// /// a widget that holds snippets and serializes the snippets to a certain places class MITKQTPYTHON_EXPORT QmitkPythonSnippets: public QWidget { Q_OBJECT public: static const QString DEFAULT_SNIPPET_FILE; static const QString SNIPPETS_ROOT_XML_ELEMENT_NAME; static const QString SNIPPETS_XML_ELEMENT_NAME; /// /// typedef for string map typedef QMap QStringMap; /// /// build ui here /// the snippets will be loaded from _AutoSaveFileName if not empty and readable /// otherwise the default snippets will be loaded QmitkPythonSnippets( const QString& _AutoSaveFileName="", QWidget* parent=0 ); /// /// delete d pointer - virtual ~QmitkPythonSnippets(); + ~QmitkPythonSnippets() override; /// /// read string map from xml file static bool LoadStringMap( const QString& filename, QStringMap& oldMap ); signals: /// /// this class whishes to paste sth command void PasteCommandRequested(const QString& command); protected slots: /// /// emits PasteCommandRequested signal void on_PasteSnippet_triggered( bool checked = false ); /// /// ask for name as long as it exists, call update() void on_RenameSnippet_triggered( bool checked = false ); /// /// ask for name, create snippet, call update() void on_AddSnippet_triggered( bool checked = false ); /// /// remove the current snippet, call update() void on_RemoveSnippet_triggered( bool checked = false ); /// /// call LoadStringMap with d->m_DefaultSnippetsAutoSaveFileName void on_RestoreDefaultSnippets_triggered( bool checked = false ); /// /// update action state (enable/disable), update text box void on_Name_currentIndexChanged( int i ); /// /// save changed snippet void on_Content_textChanged(); /// /// ask for file, save snippets void on_SaveSnippets_triggered( bool checked = false ); /// /// ask for file, load snippets (do not replace) void on_LoadSnippets_triggered( bool checked = false ); protected: /// /// write string map to xml file void SaveStringMap( const QString& filename, const QStringMap& map ) const; /// /// creates a name which does not exist in the list QString CreateUniqueName(const QString &name) const; /// /// update combo box /// if name is passed, the according element will be selected void Update(const QString &name = ""); private: /// /// d pointer declaration (holds members) QmitkPythonSnippetsData* d; }; #endif // _QmitkPythonSnippets_H_INCLUDED diff --git a/Modules/QtPython/QmitkPythonTextEditor.h b/Modules/QtPython/QmitkPythonTextEditor.h index 04bcfb8fe1..1cd44d02a6 100644 --- a/Modules/QtPython/QmitkPythonTextEditor.h +++ b/Modules/QtPython/QmitkPythonTextEditor.h @@ -1,53 +1,53 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QMITKPYTHONTEXTEDITOR_H_ #define QMITKPYTHONTEXTEDITOR_H_ #include #include #include #include struct QmitkPythonTextEditorData; /// /// this is a python text editor with syntax highlightning class MITKQTPYTHON_EXPORT QmitkPythonTextEditor : public QWidget { Q_OBJECT public: QmitkPythonTextEditor(QWidget *parent = 0); - virtual ~QmitkPythonTextEditor(); + ~QmitkPythonTextEditor() override; public slots: void Paste(const QString& command); protected slots: void on_SaveScript_triggered(bool checked=false); void on_LoadScript_triggered(bool checked=false); void on_RunScript_triggered(bool checked=false); protected: - void dragEnterEvent(QDragEnterEvent *event); - void dropEvent(QDropEvent *event); + void dragEnterEvent(QDragEnterEvent *event) override; + void dropEvent(QDropEvent *event) override; //bool canInsertFromMimeData( const QMimeData *source ) const; QString ReadFile(const QString &filename); private: QmitkPythonTextEditorData* d; }; #endif diff --git a/Modules/QtPython/QmitkPythonVariableStackTableModel.h b/Modules/QtPython/QmitkPythonVariableStackTableModel.h index 06b90bb1b6..03f0379a52 100755 --- a/Modules/QtPython/QmitkPythonVariableStackTableModel.h +++ b/Modules/QtPython/QmitkPythonVariableStackTableModel.h @@ -1,63 +1,63 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QmitkPythonVariableStackTableModel_h #define QmitkPythonVariableStackTableModel_h #include #include #include #include "mitkIPythonService.h" #include #include /// /// implements a table model to show the variables of the Python "__main__" dictionary /// furthermore implements dragging and dropping of datanodes (conversion from and to python) /// class MITKQTPYTHON_EXPORT QmitkPythonVariableStackTableModel : public QAbstractTableModel, public mitk::PythonCommandObserver { Q_OBJECT public: static const QString MITK_IMAGE_VAR_NAME; static const QString MITK_SURFACE_VAR_NAME; QmitkPythonVariableStackTableModel(QObject *parent = 0); - virtual ~QmitkPythonVariableStackTableModel(); - - int rowCount(const QModelIndex &parent = QModelIndex()) const; - int columnCount(const QModelIndex &parent = QModelIndex()) const; - QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; - Qt::ItemFlags flags( const QModelIndex& index ) const; - virtual QVariant headerData(int section, Qt::Orientation orientation, - int role) const; - - QStringList mimeTypes() const; - bool dropMimeData ( const QMimeData *, Qt::DropAction, int, int, const QModelIndex & ); - Qt::DropActions supportedDropActions() const; + ~QmitkPythonVariableStackTableModel() override; + + int rowCount(const QModelIndex &parent = QModelIndex()) const override; + int columnCount(const QModelIndex &parent = QModelIndex()) const override; + QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; + Qt::ItemFlags flags( const QModelIndex& index ) const override; + QVariant headerData(int section, Qt::Orientation orientation, + int role) const override; + + QStringList mimeTypes() const override; + bool dropMimeData ( const QMimeData *, Qt::DropAction, int, int, const QModelIndex & ) override; + Qt::DropActions supportedDropActions() const override; //Qt::DropActions supportedDragActions() const; - void CommandExecuted(const std::string& pythonCommand); + void CommandExecuted(const std::string& pythonCommand) override; std::vector GetVariableStack() const; private: std::vector m_VariableStack; mitk::IPythonService* m_PythonService; us::ServiceReference m_PythonServiceRef; }; #endif // QmitkPythonVariableStackTableModel_h diff --git a/Modules/QtPython/QmitkPythonVariableStackTableView.h b/Modules/QtPython/QmitkPythonVariableStackTableView.h index 7523cd8f66..018abeef54 100755 --- a/Modules/QtPython/QmitkPythonVariableStackTableView.h +++ b/Modules/QtPython/QmitkPythonVariableStackTableView.h @@ -1,50 +1,50 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QmitkPythonVariableStackTableView_h #define QmitkPythonVariableStackTableView_h #include #include #include "QmitkPythonVariableStackTableModel.h" #include #include /// /// implements the table view for the variable stack /// purpose of this class: 1. Setup the view correctly, 2. Implement the double click to write back results /// to the datastorage /// class MITKQTPYTHON_EXPORT QmitkPythonVariableStackTableView : public QTableView { Q_OBJECT public: QmitkPythonVariableStackTableView(QWidget *parent = 0); - virtual ~QmitkPythonVariableStackTableView(); + ~QmitkPythonVariableStackTableView() override; void SetDataStorage(mitk::DataStorage* _DataStorage); protected slots: void OnVariableStackDoubleClicked(const QModelIndex &index); private: QmitkPythonVariableStackTableModel* m_TableModel; mitk::DataStorage::Pointer m_DataStorage; mitk::IPythonService* m_PythonService; }; #endif // QmitkPythonVariableStackTableView_h diff --git a/Modules/QtWidgets/include/QmitkDataStorageComboBox.h b/Modules/QtWidgets/include/QmitkDataStorageComboBox.h index 087855b0d2..1dd4cbc7a9 100644 --- a/Modules/QtWidgets/include/QmitkDataStorageComboBox.h +++ b/Modules/QtWidgets/include/QmitkDataStorageComboBox.h @@ -1,243 +1,243 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QmitkDataStorageComboBox_h #define QmitkDataStorageComboBox_h #include // Own Includes #include "mitkDataNode.h" #include "mitkDataStorage.h" #include "mitkNodePredicateBase.h" #include "mitkWeakPointer.h" // Toolkit Includes #include #include // Forward Declartions /// /// \ingroup QmitkModule /// \class QmitkDataStorageComboBox /// \author Michael Mueller /// \version 4.0 /// \date 2009-02-09 /// \ingroup Widgets /// \brief Displays all or a subset (defined by a predicate) of nodes of the Data Storage. /// /// Dont forget that this class inherits from QComboBox and you can therefore use the whole API of QComboBox. /// class MITKQTWIDGETS_EXPORT QmitkDataStorageComboBox : public QComboBox { //#CLASS-MACROS,FRIENDS Q_OBJECT //#CTORS/DTOR public: /// /// \brief Ctor for an empty combobox. Use setDataStorage and setPredicate afterwards. /// QmitkDataStorageComboBox(QWidget *parent = nullptr, bool _AutoSelectNewNodes = false); /// /// \brief Ctor for constructing QmitkDataStorageComboBox with given DataStorageComboBox and given _Predicate. /// QmitkDataStorageComboBox(mitk::DataStorage *_DataStorage, const mitk::NodePredicateBase *_Predicate, QWidget *parent = nullptr, bool _AutoSelectNewNodes = false); /// /// \brief Standard Dtor. Nothing to do here. /// - ~QmitkDataStorageComboBox(); + ~QmitkDataStorageComboBox() override; /// /// \brief Seaches for a given node and returns a valid index or -1 if the node was not found. /// virtual int Find(const mitk::DataNode *_DataNode) const; //#PUBLIC GETTER public: /// /// \brief Get the DataStorage this ComboBox listens to. /// mitk::DataStorage::Pointer GetDataStorage() const; /// /// \brief Return the predicate (may be nullptr) that is responsible for the _DataNode selection of this ComboBox. /// const mitk::NodePredicateBase::ConstPointer GetPredicate() const; /// /// \brief Returns the _DataNode at Index index or 0 if the index is out of bounds. /// virtual mitk::DataNode::Pointer GetNode(int index) const; /// /// \brief Returns the selected _DataNode or 0 if there is none. /// virtual mitk::DataNode::Pointer GetSelectedNode() const; /// /// \brief Returns all nodes that are stored in this combobox. /// mitk::DataStorage::SetOfObjects::ConstPointer GetNodes() const; /// /// Returns the AutoSelectNewItems. /// \see SetAutoSelectNewItems /// virtual bool GetAutoSelectNewItems(); //#PUBLIC SETTER public: /// /// \brief Set the DataStorage this ComboBox should listen to. /// /// If DataStorage is 0 nothing will be shown. If DataStorage is re-set the combobox will be resetted. void SetDataStorage(mitk::DataStorage *dataStorage); /// /// \brief Set the predicate for this ComboBox. (QmitkDataStorageComboBox is now owner of the predicate) /// /// If predicate is nullptr all nodes will be selected. If predicate changes the whole combobox will be resetted. void SetPredicate(const mitk::NodePredicateBase *_Predicate); /// /// Adds a node to the ComboBox. Gets called everytime a DataStorage Add Event was thrown. /// virtual void AddNode(const mitk::DataNode *_DataNode); /// /// Removes a node from the ComboBox at a specified index (if the index exists). Gets called when a DataStorage Remove /// Event was thrown. /// virtual void RemoveNode(int index); /// /// Removes a node from the ComboBox. Gets called when a DataStorage Remove Event was thrown. /// virtual void RemoveNode(const mitk::DataNode *_DataNode); /// /// Set a _DataNode in the ComboBox at the specified index (if the index exists). /// Internally the method just calls RemoveNode(unsigned int) /// virtual void SetNode(int index, const mitk::DataNode *_DataNode); /// /// Replaces a _DataNode in the combobox by an _OtherDataNode. /// Internally the method just calls SetNode(unsigned int, mitk::DataNode*) /// virtual void SetNode(const mitk::DataNode *_DataNode, const mitk::DataNode *_OtherDataNode); /// /// Sets AutoSelectNewItems flag. If set to true new Nodes will be automatically selected. Default is false. /// virtual void SetAutoSelectNewItems(bool _AutoSelectNewItems); /// /// \brief Called when a node is deleted or the name property of the node was modified. Calls RemoveNode or SetNode /// then. /// virtual void OnDataNodeDeleteOrModified(const itk::Object *caller, const itk::EventObject &event); signals: /// /// \brief Throw a signal when the _DataNode selection changed. /// void OnSelectionChanged(const mitk::DataNode *); //#PROTECTED GETTER protected: /// /// \brief Checks if the given index is within the range of the m_Nodes vector. /// bool HasIndex(unsigned int index) const; //#PROTECTED SETTER protected slots: /// /// \brief Slot for signal when the user selects another item. /// void OnCurrentIndexChanged(int); //#PUBLIC SETTER public slots: /// /// \brief Slot for signal when user wants to set a node as current selected node. /// void SetSelectedNode(mitk::DataNode::Pointer item); protected: /// /// \brief Inserts a new node at the given index. If the index does not exist, the _DataNode is simply appended to the /// combobox. /// /// This function is used by AddNode() and SetNode() because they just to the same: /// 1. If node is replaced (that is when index exists), /// the itk::Event observer will be removed /// 2. Check Node against Predicate /// 3. Register for itk::Events on the node /// 4. Insert Node and show in combobox virtual void InsertNode(int index, const mitk::DataNode *_DataNode); /// /// \brief Init-function this class with the given dataStorage and _Predicate. This function is called by all ctors. /// void Init(); /// /// \brief Reset function whenever datastorage or predicate changes. /// virtual void Reset(); protected: //#PROTECTED MEMBER VARS /// /// Pointer to the DataStorage from which the nodes are selected (remember: in BlueBerry there /// might be more than one DataStorage). /// mitk::WeakPointer m_DataStorage; /// /// \brief Holds the predicate that is responsible for the _DataNode selection of this ComboBox. /// If the predicate is 0, every _DataNode will be selected. /// mitk::NodePredicateBase::ConstPointer m_Predicate; /// /// Holds all selected Nodes. Dont hold smart pointer as we are in a GUI class. /// std::vector m_Nodes; /// /// \brief Holds the tags of the node-modified observers. (must be updated everytime m_Nodes changes) /// std::vector m_NodesModifiedObserverTags; /// /// \brief Holds the tags of the node-modified observers. (must be updated everytime m_Nodes changes) /// std::vector m_NodesDeleteObserverTags; /// /// \brief Maps a a specific node to (Name-)property. This is needed because we have to find the assiociated node /// whenever the name property of a node changed. /// std::map m_PropertyToNode; /// /// \brief Event function guard. Each function which is called by an event mechanism /// first checks if this is true in order to avoid endless loops. bool m_BlockEvents; /// /// \brief If set to "true" new Nodes will be automatically selected. bool m_AutoSelectNewNodes; }; #endif // QmitkDataStorageComboBox_h diff --git a/Modules/QtWidgets/include/QmitkDataStorageComboBoxWithSelectNone.h b/Modules/QtWidgets/include/QmitkDataStorageComboBoxWithSelectNone.h index fccb4eafdd..a80673b07a 100644 --- a/Modules/QtWidgets/include/QmitkDataStorageComboBoxWithSelectNone.h +++ b/Modules/QtWidgets/include/QmitkDataStorageComboBoxWithSelectNone.h @@ -1,151 +1,151 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) University College London (UCL). All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QmitkDataStorageComboBoxWithSelectNone_h #define QmitkDataStorageComboBoxWithSelectNone_h #include #include "QmitkDataStorageComboBox.h" #include "QmitkCustomVariants.h" #include "mitkDataNode.h" /** * \class QmitkDataStorageComboBoxWithSelectNone * \brief Displays all or a subset (defined by a predicate) of nodes of the Data Storage, * and additionally, index 0 is always "please select", indicating no selection, and will * hence always return a nullptr mitk::DataNode* if asked for the node at index 0. * * \author Matt Clarkson (m.clarkson@ucl.ac.uk) * \ingroup org_mitk_gui_qt_cmdlinemodules_internal * \sa QmitkDataStorageComboBox */ class MITKQTWIDGETS_EXPORT QmitkDataStorageComboBoxWithSelectNone : public QmitkDataStorageComboBox { Q_OBJECT Q_PROPERTY(mitkDataNodePtr SelectedNode READ GetSelectedNode WRITE SetSelectedNode) Q_PROPERTY(QString currentValue READ currentValue WRITE setCurrentValue) public: /** * \brief Calls base class constructor. * \see QmitkDataStorageComboBox */ QmitkDataStorageComboBoxWithSelectNone(QWidget* parent = nullptr, bool autoSelectNewNodes=false); /** * \brief Calls base class constructor. * \see QmitkDataStorageComboBox */ QmitkDataStorageComboBoxWithSelectNone( mitk::DataStorage* _DataStorage, const mitk::NodePredicateBase* predicate, QWidget* parent = nullptr, bool autoSelectNewNodes=false); /** * \brief Nothing to do. * \see QmitkDataStorageComboBox */ - ~QmitkDataStorageComboBoxWithSelectNone(); + ~QmitkDataStorageComboBoxWithSelectNone() override; /** * \brief Stores the string that will be present on index 0, currently equal to "please select". */ static const QString ZERO_ENTRY_STRING; /** * \brief Searches for a given node, returning the index if found. * \param dataNode an mitk::DataNode, can be nullptr. * \return int -1 if not found, and compared to base class, will add 1 onto the retrieved index. */ - virtual int Find( const mitk::DataNode* dataNode ) const override; + int Find( const mitk::DataNode* dataNode ) const override; /** * \brief Retrieves the node at a given index, where if index is zero, will always return nullptr. * \param index An integer between 0 and n = number of nodes. * \return mitk::DataNode::Pointer nullptr or a data node pointer. */ - virtual mitk::DataNode::Pointer GetNode(int index) const override; + mitk::DataNode::Pointer GetNode(int index) const override; /** * \brief Returns the selected DataNode or nullptr if there is none, or the current index is zero. */ - virtual mitk::DataNode::Pointer GetSelectedNode() const override; + mitk::DataNode::Pointer GetSelectedNode() const override; /** * \brief Sets the combo box to the index that contains the specified node, or 0 if the node cannot be found. */ virtual void SetSelectedNode(const mitk::DataNode::Pointer& node); using QmitkDataStorageComboBox::RemoveNode; /** * \brief Removes a node from the ComboBox at a specified index (if the index exists). * Gets called when a DataStorage Remove Event was thrown. */ - virtual void RemoveNode(int index) override; + void RemoveNode(int index) override; using QmitkDataStorageComboBox::SetNode; /** * \brief Set a DataNode in the ComboBox at the specified index (if the index exists). * Internally the method just calls InsertNode(unsigned int) */ - virtual void SetNode(int index, const mitk::DataNode* dataNode) override; + void SetNode(int index, const mitk::DataNode* dataNode) override; /** * \brief Get the current file path. */ virtual QString currentValue() const; /** * \brief Set the current file path. */ virtual void setCurrentValue(const QString& path); /** * \brief Set the string that will be present on index 0. */ void SetZeroEntryText(const QString& zeroEntryString); protected: /** * \brief Checks if the given index is within range. */ bool HasIndex(unsigned int index) const; /** * \brief Inserts a new node at the given index, unless index is 0, which is silently ignored. */ - virtual void InsertNode(int index, const mitk::DataNode* dataNode) override; + void InsertNode(int index, const mitk::DataNode* dataNode) override; /** * \brief Reset function whenever datastorage or predicate changes. */ - virtual void Reset() override; + void Reset() override; private: /** * \brief This should store the current file path of the current image. * * * The reason is so that we can store and retrieve a temporary file name. */ QString m_CurrentPath; }; #endif // QmitkDataStorageComboBoxWithSelectNone_h diff --git a/Modules/QtWidgets/include/QmitkDataStorageTableModel.h b/Modules/QtWidgets/include/QmitkDataStorageTableModel.h index 92bd8aaba2..1538ee59fe 100644 --- a/Modules/QtWidgets/include/QmitkDataStorageTableModel.h +++ b/Modules/QtWidgets/include/QmitkDataStorageTableModel.h @@ -1,227 +1,227 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QmitkDataStorageTableModel_h #define QmitkDataStorageTableModel_h #include /// Own includes. #include "mitkBaseProperty.h" #include "mitkDataStorage.h" #include "mitkNodePredicateBase.h" #include "mitkWeakPointer.h" /// Toolkit includes. #include /// Forward declarations. /// /// \ingroup QmitkModule /// \class QmitkDataStorageTableModel /// /// \brief A table model for a set of DataNodes defined by a predicate. /// \TODO make columns interchangeable, select which properties to show as columns /// class MITKQTWIDGETS_EXPORT QmitkDataStorageTableModel : public QAbstractTableModel { Q_OBJECT //#Ctors/Dtor public: /// /// Constructs a new QmitkDataStorageTableModel and sets a predicate that defines /// this list. /// \see setPredicate() /// QmitkDataStorageTableModel(mitk::DataStorage::Pointer _DataStorage, mitk::NodePredicateBase *_Predicate = nullptr, QObject *parent = nullptr); /// /// Standard dtor. Delete predicate, disconnect from DataStorage. /// - virtual ~QmitkDataStorageTableModel(); + ~QmitkDataStorageTableModel() override; //# Public GETTER public: /// /// Get the DataStorage. /// const mitk::DataStorage::Pointer GetDataStorage() const; /// /// Get the predicate. /// mitk::NodePredicateBase::Pointer GetPredicate() const; /// /// Get node at a specific model index. Another way to implement this, is /// by introducing a new role like "DateTreeNode" and capture /// that in the data function. /// mitk::DataNode::Pointer GetNode(const QModelIndex &index) const; /// /// Overridden from QAbstractTableModel. Returns the header data at section /// for given orientation and role. /// - virtual QVariant headerData(int section, Qt::Orientation orientation, int role) const override; + QVariant headerData(int section, Qt::Orientation orientation, int role) const override; /// /// Overridden from QAbstractTableModel. Returns what can be done /// with an item. /// - virtual Qt::ItemFlags flags(const QModelIndex &index) const override; + Qt::ItemFlags flags(const QModelIndex &index) const override; /// /// Overridden from QAbstractTableModel. Returns the node count. /// - virtual int rowCount(const QModelIndex &parent) const override; + int rowCount(const QModelIndex &parent) const override; /// /// Overridden from QAbstractTableModel. Returns the number of features (columns) to display. /// - virtual int columnCount(const QModelIndex &parent) const override; + int columnCount(const QModelIndex &parent) const override; /// /// Overridden from QAbstractTableModel. Returns the data at index for given role. /// - virtual QVariant data(const QModelIndex &index, int role) const override; + QVariant data(const QModelIndex &index, int role) const override; //# Public SETTERS public: /// /// Sets the DataStorage. /// void SetDataStorage(mitk::DataStorage::Pointer _DataStorage); /// /// Sets the predicate. QmitkDataStorageTableModel is owner of the predicate! /// void SetPredicate(mitk::NodePredicateBase *_Predicate); /// /// Adds a node to this model. /// There are two constraints for nodes in this model: /// 1. If a predicate is set (not null) the node will be checked against it. /// 2. The node has to have a data object (no one wants to see empty nodes). /// Also adds event listeners to the node. /// virtual void AddNode(const mitk::DataNode *node); /// /// Removes a node from this model. Also removes any event listener from the node. /// virtual void RemoveNode(const mitk::DataNode *node); /// /// Returns a copy of the node-vector that is shown by this model /// virtual std::vector GetNodeSet() const; /// /// \brief Called when a single property was changed. /// The function searches through the list of nodes in this model for the changed /// property. If the property was found a dataChanged signal is emitted forcing /// all observing views to request the data again. /// virtual void PropertyModified(const itk::Object *caller, const itk::EventObject &event); /// /// Overridden from QAbstractTableModel. Sets data at index for given role. /// bool setData(const QModelIndex &index, const QVariant &value, int role) override; /// /// \brief Reimplemented sort function from QAbstractTableModel to enable sorting on the table. /// void sort(int column, Qt::SortOrder order = Qt::AscendingOrder) override; //#PROTECTED INNER CLASSES protected: /// /// \struct DataNodeCompareFunction /// \brief A struct that inherits from std::binary_function. You can use it in std::sort algorithm for sorting the /// node list elements. /// struct DataNodeCompareFunction : public std::binary_function { /// /// \brief Specifies field of the property with which it will be sorted. /// enum CompareCriteria { CompareByName = 0, CompareByClassName, CompareByVisibility }; /// /// \brief Specifies Ascending/descending ordering. /// enum CompareOperator { Less = 0, Greater }; /// /// \brief Creates a PropertyDataSetCompareFunction. A CompareCriteria and a CompareOperator must be given. /// DataNodeCompareFunction(CompareCriteria _CompareCriteria = CompareByName, CompareOperator _CompareOperator = Less); /// /// \brief The reimplemented compare function. /// bool operator()(const mitk::DataNode::Pointer &_Left, const mitk::DataNode::Pointer &_Right) const; protected: CompareCriteria m_CompareCriteria; CompareOperator m_CompareOperator; }; //#Protected SETTER protected: /// /// Called when DataStorage or Predicate changed. Resets whole model and reads all nodes /// in again. /// virtual void Reset(); //#Protected MEMBER VARIABLES protected: /// /// Pointer to the DataStorage from which the nodes are selected (remember: in BlueBerry there /// might be more than one DataStorage). /// Store it in a weak pointer. This is a GUI class which should not hold a strong reference /// to any non-GUI Object. /// mitk::WeakPointer m_DataStorage; /// /// Holds the predicate that defines this SubSet of Nodes. If m_Predicate /// is nullptr all Nodes will be selected. /// mitk::NodePredicateBase::Pointer m_Predicate; /// /// Holds all selected Nodes. /// std::vector m_NodeSet; /// /// \brief Maps a property to an observer tag. /// std::map m_NamePropertyModifiedObserverTags; /// /// \brief Maps a property to an observer tag. /// std::map m_VisiblePropertyModifiedObserverTags; /// /// Saves if this model is currently working on events to prevent endless event loops. /// bool m_BlockEvents; /// /// \brief The property is true when the property list is sorted in descending order. /// bool m_SortDescending; }; #endif diff --git a/Modules/QtWidgets/include/QmitkFileReaderOptionsDialog.h b/Modules/QtWidgets/include/QmitkFileReaderOptionsDialog.h index 043f66a468..e3c316b3af 100644 --- a/Modules/QtWidgets/include/QmitkFileReaderOptionsDialog.h +++ b/Modules/QtWidgets/include/QmitkFileReaderOptionsDialog.h @@ -1,49 +1,49 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QMITKFILEREADEROPTIONSDIALOG_H #define QMITKFILEREADEROPTIONSDIALOG_H #include "mitkIOUtil.h" #include namespace Ui { class QmitkFileReaderOptionsDialog; } class QmitkFileReaderWriterOptionsWidget; class QmitkFileReaderOptionsDialog : public QDialog { Q_OBJECT public: explicit QmitkFileReaderOptionsDialog(mitk::IOUtil::LoadInfo &loadInfo, QWidget *parent = 0); - ~QmitkFileReaderOptionsDialog(); + ~QmitkFileReaderOptionsDialog() override; bool ReuseOptions() const; - virtual void accept() override; + void accept() override; private: Ui::QmitkFileReaderOptionsDialog *ui; mitk::IOUtil::LoadInfo &m_LoadInfo; std::vector m_ReaderItems; }; #endif // QMITKFILEREADEROPTIONSDIALOG_H diff --git a/Modules/QtWidgets/include/QmitkFileWriterOptionsDialog.h b/Modules/QtWidgets/include/QmitkFileWriterOptionsDialog.h index bc0e217530..3c2beaa9fe 100644 --- a/Modules/QtWidgets/include/QmitkFileWriterOptionsDialog.h +++ b/Modules/QtWidgets/include/QmitkFileWriterOptionsDialog.h @@ -1,49 +1,49 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QMITKFILEWRITEROPTIONSDIALOG_H #define QMITKFILEWRITEROPTIONSDIALOG_H #include #include namespace Ui { class QmitkFileWriterOptionsDialog; } class QmitkFileReaderWriterOptionsWidget; class QmitkFileWriterOptionsDialog : public QDialog { Q_OBJECT public: explicit QmitkFileWriterOptionsDialog(mitk::IOUtil::SaveInfo &saveInfo, QWidget *parent = 0); - ~QmitkFileWriterOptionsDialog(); + ~QmitkFileWriterOptionsDialog() override; bool ReuseOptions() const; - virtual void accept() override; + void accept() override; private: Ui::QmitkFileWriterOptionsDialog *ui; mitk::IOUtil::SaveInfo &m_SaveInfo; std::vector m_WriterItems; }; #endif // QMITKFILEREADEROPTIONSDIALOG_H diff --git a/Modules/QtWidgets/include/QmitkLevelWindowPresetDefinitionDialog.h b/Modules/QtWidgets/include/QmitkLevelWindowPresetDefinitionDialog.h index 73c1b822f2..30282e0254 100644 --- a/Modules/QtWidgets/include/QmitkLevelWindowPresetDefinitionDialog.h +++ b/Modules/QtWidgets/include/QmitkLevelWindowPresetDefinitionDialog.h @@ -1,105 +1,105 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QMITKLEVELWINDOWPRESETDEFINITIONDIALOG_H_ #define QMITKLEVELWINDOWPRESETDEFINITIONDIALOG_H_ #include #include "ui_QmitkLevelWindowPresetDefinition.h" #include #include #include #include /// \ingroup QmitkModule class MITKQTWIDGETS_EXPORT QmitkLevelWindowPresetDefinitionDialog : public QDialog, public Ui::QmitkLevelWindowPresetDefinition { Q_OBJECT public: QmitkLevelWindowPresetDefinitionDialog(QWidget *parent = nullptr, Qt::WindowFlags f = nullptr); - ~QmitkLevelWindowPresetDefinitionDialog(); + ~QmitkLevelWindowPresetDefinitionDialog() override; void setPresets(std::map &level, std::map &window, QString initLevel, QString initWindow); std::map getLevelPresets(); std::map getWindowPresets(); protected slots: void addPreset(); void removePreset(); void changePreset(); void ListViewSelectionChanged(const QItemSelection &, const QItemSelection &); void sortPresets(int index); protected: class PresetTableModel : public QAbstractTableModel { public: struct Entry { std::string name; double level; double window; Entry(const std::string &n, double l, double w) : name(n), level(l), window(w) {} }; PresetTableModel(std::map &levels, std::map &windows, QObject *parent = nullptr); int rowCount(const QModelIndex &) const override; int columnCount(const QModelIndex &) const override; QVariant data(const QModelIndex &index, int) const override; QVariant headerData(int section, Qt::Orientation orientation, int) const override; void addPreset(std::string &name, double level, double window); void removePreset(const QModelIndex &); void changePreset(int row, std::string &name, double level, double window); void getLevels(std::map &levels); void getWindows(std::map &windows); bool contains(std::string &name); Entry getPreset(const QModelIndex &) const; private: std::vector m_Entries; }; void resizeEvent(QResizeEvent *event) override; void showEvent(QShowEvent *event) override; void resizeColumns(); PresetTableModel *m_TableModel; QSortFilterProxyModel m_SortModel; }; #endif /*QMITKLEVELWINDOWPRESETDEFINITIONDIALOG_H_*/ diff --git a/Modules/QtWidgets/include/QmitkLevelWindowWidgetContextMenu.h b/Modules/QtWidgets/include/QmitkLevelWindowWidgetContextMenu.h index 40814dc8c4..6c1a5af5f0 100644 --- a/Modules/QtWidgets/include/QmitkLevelWindowWidgetContextMenu.h +++ b/Modules/QtWidgets/include/QmitkLevelWindowWidgetContextMenu.h @@ -1,121 +1,121 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QMITKLEVELWINDOWWIDGETCONTEXTMENU_H #define QMITKLEVELWINDOWWIDGETCONTEXTMENU_H #include #include #include #include /** * \ingroup QmitkModule * \brief Provides a contextmenu for Level/Window functionality. * * Either creates * a new contextmenu with standard functions or adds Level/Window standard * functions to an predefined contextmenu. */ class MITKQTWIDGETS_EXPORT QmitkLevelWindowWidgetContextMenu : public QWidget { Q_OBJECT public: /// constructor QmitkLevelWindowWidgetContextMenu(QWidget *parent, Qt::WindowFlags f = nullptr); - virtual ~QmitkLevelWindowWidgetContextMenu(); + ~QmitkLevelWindowWidgetContextMenu() override; /*! * data structure which reads and writes presets defined in a XML-file */ mitk::LevelWindowPreset *m_LevelWindowPreset; /*! * data structure which stores the values manipulated * by a QmitkLevelWindowWidgetContextMenu */ mitk::LevelWindow m_LevelWindow; /// submenu with all presets for contextmenu QMenu *m_PresetSubmenu; /// submenu with all images for contextmenu QMenu *m_ImageSubmenu; /// pointer to the object which manages all Level/Window changes on images and holds the LevelWindowProperty /// of the current image mitk::LevelWindowManager *m_Manager; /// map to hold all image-properties, one can get the image which is selected in the contextmenu /// with the QAction representing the image for the contextmenu std::map m_Images; /*! * returns the contextmenu with standard functions for Level/Window * * input is a prefilled contextmenu to which standard functions will be added */ void getContextMenu(QMenu *contextmenu); /// returns the contextmenu with standard functions for Level/Window void getContextMenu(); /// lets this object know about the LevelWindowManager to get all images and tell about changes void setLevelWindowManager(mitk::LevelWindowManager *levelWindowManager); protected: /// ID of preset selected in contextmenu QAction *m_PresetAction; /// ID of image selected in contextmenu QAction *m_ImageAction; protected slots: /// sets level and window value of the current image to the values defined for the selected preset void setPreset(QAction *presetAction); /// calls the mitkLevelWindow SetAuto method with guessByCentralSlice false, so that the greyvalues from whole image /// will be considered void useOptimizedLevelWindow(); /// calls the mitkLevelWindow SetToImageRange method, so that the greyvalues from whole image will be used void useAllGreyvaluesFromImage(); /// sets the level window slider to be fixed void setFixed(); /// adds a new Preset for presets-contextmenu void addPreset(); /// resets the current images Level/Window to its default values void setDefaultLevelWindow(); /// resets the current images scalerange to its default values void setDefaultScaleRange(); /// changes the current images scalerange void changeScaleRange(); /// sets the selected image or the topmost layer image to the new current image void setImage(QAction *imageAction); /// sets the window to its maximum Size to fit the scalerange void setMaximumWindow(); }; #endif diff --git a/Modules/QtWidgets/include/QmitkLineEditLevelWindowWidget.h b/Modules/QtWidgets/include/QmitkLineEditLevelWindowWidget.h index 424e0b25b2..429238a86c 100644 --- a/Modules/QtWidgets/include/QmitkLineEditLevelWindowWidget.h +++ b/Modules/QtWidgets/include/QmitkLineEditLevelWindowWidget.h @@ -1,97 +1,97 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QMITKLINEEDITLEVELWINDOWWIDGET #define QMITKLINEEDITLEVELWINDOWWIDGET #include #include #include class QmitkLevelWindowWidgetContextMenu; class QLineEdit; /** * \ingroup QmitkModule * \brief Provides a widget with two lineedit fields, one to change the * window value of the current image and one to change the level value of * the current image. */ class MITKQTWIDGETS_EXPORT QmitkLineEditLevelWindowWidget : public QWidget { Q_OBJECT public: /// constructor QmitkLineEditLevelWindowWidget(QWidget *parent = nullptr, Qt::WindowFlags f = nullptr); /// destructor - ~QmitkLineEditLevelWindowWidget(); + ~QmitkLineEditLevelWindowWidget() override; /// inputfield for level value QLineEdit *m_LevelInput; /// inputfield for window value QLineEdit *m_WindowInput; /*! * data structure which stores the values manipulated * by a QmitkLineEditLevelWindowWidget */ mitk::LevelWindow m_LevelWindow; /// manager who is responsible to collect and deliver changes on Level/Window mitk::LevelWindowManager::Pointer m_Manager; /// sets the manager who is responsible to collect and deliver changes on Level/Window void setLevelWindowManager(mitk::LevelWindowManager *levelWindowManager); /// sets the DataStorage which holds all image-nodes void SetDataStorage(mitk::DataStorage *ds); /// returns the manager who is responsible to collect and deliver changes on Level/Window mitk::LevelWindowManager *GetManager(); private: /// creates the contextmenu for this widget from class QmitkLevelWindowWidgetContextMenu void contextMenuEvent(QContextMenuEvent *) override; /// change notifications from the mitkLevelWindowManager void OnPropertyModified(const itk::EventObject &e); public slots: /// called when return is pressed in levelinput field void SetLevelValue(); /// called when return is pressed in windowinput field void SetWindowValue(); // validator to accept only possible values for Level/Window in lineedits // void setValidator(); protected: unsigned long m_ObserverTag; bool m_IsObserverTagSet; /*! * data structure which creates the contextmenu for QmitkLineEditLevelWindowWidget */ QmitkLevelWindowWidgetContextMenu *m_Contextmenu; }; #endif // QMITKLINEEDITLEVELWINDOWWIDGET diff --git a/Modules/QtWidgets/include/QmitkMemoryUsageIndicatorView.h b/Modules/QtWidgets/include/QmitkMemoryUsageIndicatorView.h index 6087bbbd11..91eb84563d 100644 --- a/Modules/QtWidgets/include/QmitkMemoryUsageIndicatorView.h +++ b/Modules/QtWidgets/include/QmitkMemoryUsageIndicatorView.h @@ -1,52 +1,52 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QMITKMEMORYUSAGEINDICATORVIEW_WIDGET #define QMITKMEMORYUSAGEINDICATORVIEW_WIDGET #include #include "ui_QmitkMemoryUsageIndicator.h" #include #include /// \ingroup QmitkModule class MITKQTWIDGETS_EXPORT QmitkMemoryUsageIndicatorView : public QWidget, public Ui::QmitkMemoryUsageIndicator { Q_OBJECT public: /// constructor QmitkMemoryUsageIndicatorView(QWidget *parent = nullptr, Qt::WindowFlags f = nullptr); /// destructor - ~QmitkMemoryUsageIndicatorView(); + ~QmitkMemoryUsageIndicatorView() override; protected slots: void UpdateMemoryUsage(); protected: std::string FormatMemorySize(size_t size); std::string FormatPercentage(double val); std::string GetMemoryDescription(size_t processSize, float percentage); QPixmap m_LEDGreen; QPixmap m_LEDYellow; QPixmap m_LEDOrange; QPixmap m_LEDRed; char m_PreviousState; }; #endif // QMITKMEMORYUSAGEINDICATORVIEW_WIDGET diff --git a/Modules/QtWidgets/include/QmitkMouseModeSwitcher.h b/Modules/QtWidgets/include/QmitkMouseModeSwitcher.h index 6a0825bb41..a444f12477 100644 --- a/Modules/QtWidgets/include/QmitkMouseModeSwitcher.h +++ b/Modules/QtWidgets/include/QmitkMouseModeSwitcher.h @@ -1,89 +1,89 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QmitkMouseModeSwitcher_h #define QmitkMouseModeSwitcher_h #include "MitkQtWidgetsExports.h" #include "mitkMouseModeSwitcher.h" #include #include /** * \ingroup QmitkModule * \brief Qt toolbar representing mitk::MouseModeSwitcher. * * Provides buttons for the interaction modes defined in mitk::MouseModeSwitcher * and communicates with this non-graphical class. * * Can be used in a GUI to provide a mouse mode selector to the user. */ class MITKQTWIDGETS_EXPORT QmitkMouseModeSwitcher : public QToolBar { Q_OBJECT public: QmitkMouseModeSwitcher(QWidget *parent = 0); - virtual ~QmitkMouseModeSwitcher(); + ~QmitkMouseModeSwitcher() override; typedef mitk::MouseModeSwitcher::MouseMode MouseMode; public slots: /** \brief Connect to non-GUI class. When a button is pressed, given mitk::MouseModeSwitcher is informed to adapt interactors. \todo QmitkMouseModeSwitcher could be enhanced to actively observe mitk::MouseModeSwitcher and change available actions or visibility appropriately. */ void setMouseModeSwitcher(mitk::MouseModeSwitcher *); signals: /** \brief Mode activated. This signal is needed for other GUI element to react appropriately. Sadly this is needed to provide "normal" functionality of QmitkStdMultiWidget, because this must enable/disable automatic reaction of SliceNavigationControllers to mouse clicks - depending on which mode is active. */ void MouseModeSelected(mitk::MouseModeSwitcher::MouseMode id); // TODO change int to enum of MouseModeSwitcher protected slots: void modeSelectedByUser(); void addButton(MouseMode id, const QString &toolName, const QIcon &icon, bool on = false); // TODO change int to enum of MouseModeSwitcher protected: void OnMouseModeChanged(const itk::EventObject &); QActionGroup *m_ActionGroup; mitk::MouseModeSwitcher *m_MouseModeSwitcher; unsigned long m_ObserverTag; bool m_InObservationReaction; }; #endif diff --git a/Modules/QtWidgets/include/QmitkNodeDescriptor.h b/Modules/QtWidgets/include/QmitkNodeDescriptor.h index c9d4fc953e..cba03a1d5b 100644 --- a/Modules/QtWidgets/include/QmitkNodeDescriptor.h +++ b/Modules/QtWidgets/include/QmitkNodeDescriptor.h @@ -1,105 +1,105 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QmitkNodeDescriptor_h #define QmitkNodeDescriptor_h #include #include "mitkDataNode.h" #include #include #include #include #include #include #include /** * \ingroup QmitkModule * \brief QmitkNodeQmitkNodeDescriptor is Decorator class for * the mitk::DataNode which enhances certain mitk::DataNode by additional * infos needed by the GUI (Icon, ...) * * Moreover, QmitkNodeQmitkNodeDescriptor stores a Menu for actions that can be taken * for a certain DataNode, e.g. for DataNodes containing images this menu * can be filled with Image Filter Actions, etc. * * \sa QmitkDataNodeQmitkNodeDescriptorManager */ class MITKQTWIDGETS_EXPORT QmitkNodeDescriptor : public QObject { Q_OBJECT public: /// /// Creates a new QmitkNodeQmitkNodeDescriptor /// QmitkNodeDescriptor(const QString &_ClassName, const QString &_PathToIcon, mitk::NodePredicateBase *_Predicate, QObject *parent); /// /// Deletes all actions /// - virtual ~QmitkNodeDescriptor(); + ~QmitkNodeDescriptor() override; /// /// Returns a name for this class of DataNodes (e.g. "Image", "Image Mask", etc.) /// virtual QString GetNameOfClass() const; /// /// Returns an Icon for this class of DataNodes /// virtual QIcon GetIcon() const; /// /// Returns an Icon for this class of DataNodes /// virtual QAction *GetSeparator() const; /// /// Check if this class describes the given node /// virtual bool CheckNode(const mitk::DataNode *node) const; /// /// Create and return an action with this descriptor as owner /// virtual void AddAction(QAction *action, bool isBatchAction = true); /// /// Remove and delete (!) an action /// virtual void RemoveAction(QAction *_Action); /// /// Get all actions associated with this class of nodes /// virtual QList GetActions() const; /// /// Get all actions for this descriptor class that can be executed on multiple nodes /// (no priot knowledge abpout the node is required) /// virtual QList GetBatchActions() const; public slots: /// Called when an action was destroyed void ActionDestroyed(QObject *obj = nullptr); protected: QString m_ClassName; QString m_PathToIcon; mitk::NodePredicateBase::Pointer m_Predicate; QList m_Actions; QList m_BatchActions; QAction *m_Separator; }; #endif // QmitkNodeDescriptor_h diff --git a/Modules/QtWidgets/include/QmitkNodeDescriptorManager.h b/Modules/QtWidgets/include/QmitkNodeDescriptorManager.h index e613bd98ac..924be1623b 100644 --- a/Modules/QtWidgets/include/QmitkNodeDescriptorManager.h +++ b/Modules/QtWidgets/include/QmitkNodeDescriptorManager.h @@ -1,117 +1,117 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QmitkNodeDescriptorManager_h #define QmitkNodeDescriptorManager_h #include #include "QmitkNodeDescriptor.h" /** * \ingroup QmitkModule * \brief QmitkNodeDescriptorManager manages a set of QmitkNodeDescriptors * * \sa QmitkNodeDescriptor */ class MITKQTWIDGETS_EXPORT QmitkNodeDescriptorManager : public QObject { Q_OBJECT public: /// /// \return the solely instance of QmitkNodeDescriptorManager /// static QmitkNodeDescriptorManager *GetInstance(); /// /// Initializes the QmitkNodeDescriptorManager. /// Adds a few standard Descriptors. /// This Descriptors are added: /// - A QmitkNodeDescriptor for the class of "Image" DataNodes /// - A QmitkNodeDescriptor for the class of "Image Mask" DataNodes /// - A QmitkNodeDescriptor for the class of "Surface" DataNodes /// - A QmitkNodeDescriptor for the class of "PointSet" DataNodes /// virtual void Initialize(); /// /// Adds a new descriptor to the manager. The manager takes the ownership. /// void AddDescriptor(QmitkNodeDescriptor *_Descriptor); /// /// Removes and deletes a descriptor from the manager /// void RemoveDescriptor(QmitkNodeDescriptor *_Descriptor); /// /// Get the last descriptor in the descriptors list that matches the given node. /// *Attention*: More specialized Descriptors should therefore be appended at /// the end of the list, e.g. first add "Image", then add "Image Mask" /// /// \return a QmitkNodeDescriptor for the given node or a QmitkNodeDescriptor describing unknown nodes (never 0) /// \sa AddDescriptor() /// QmitkNodeDescriptor *GetDescriptor(const mitk::DataNode *_Node) const; /// /// Get the last QmitkNodeDescriptor for the given class name /// /// \return a QmitkNodeDescriptor for the given class name or 0 if there is no QmitkNodeDescriptor for _ClassName /// QmitkNodeDescriptor *GetDescriptor(const QString &_ClassName) const; /// /// \return The UnknownDataNodeDescriptor, which is the default Descriptor for all Nodes. /// QmitkNodeDescriptor *GetUnknownDataNodeDescriptor() const; /// /// Returns a list of all actions that are associated with the given node. /// If there are more than one Descriptors for this node all actions /// will be merged together. /// E.g. all actions from the "unknown" DataNodes will be added to /// this list. Generic Actions like Save, Load, etc. are stored there. /// QList GetActions(const mitk::DataNode *_Node) const; /// /// \return a list of actions associated with the given nodes /// QList GetActions(const QList &_Nodes) const; /// /// Deletes all Descriptors in the list /// - virtual ~QmitkNodeDescriptorManager(); + ~QmitkNodeDescriptorManager() override; protected: /// /// Creates the m_UnknownDataNodeDescriptor /// Calls Initialize /// QmitkNodeDescriptorManager(); protected: /// /// This is the standard QmitkNodeDescriptor matching every node /// QmitkNodeDescriptor *m_UnknownDataNodeDescriptor; /// /// Holds all user defined descriptors /// QList m_NodeDescriptors; }; #endif // QmitkNodeDescriptorManager_h diff --git a/Modules/QtWidgets/include/QmitkProgressBar.h b/Modules/QtWidgets/include/QmitkProgressBar.h index b43f270d2c..8232f32928 100644 --- a/Modules/QtWidgets/include/QmitkProgressBar.h +++ b/Modules/QtWidgets/include/QmitkProgressBar.h @@ -1,81 +1,81 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QMITKPROGRESSBAR_H #define QMITKPROGRESSBAR_H #include #include #include /** * \ingroup QmitkModule * \brief QT-Toolkit/GUI dependent class that provides the QT's ProgressBar * * All mitk-classes will call this class for output: * mitk::ProgressBar::GetInstance(); */ class MITKQTWIDGETS_EXPORT QmitkProgressBar : public QProgressBar, public mitk::ProgressBarImplementation { Q_OBJECT public: //##Documentation //##@brief Constructor; //## holds param instance internally and connects this to the mitkProgressBar QmitkProgressBar(QWidget *parent = nullptr, const char *name = nullptr); //##Documentation //##@brief Destructor - virtual ~QmitkProgressBar(); + ~QmitkProgressBar() override; //##Documentation //## @brief Sets whether the current progress value is displayed. - virtual void SetPercentageVisible(bool visible) override; + void SetPercentageVisible(bool visible) override; //##Documentation //## @brief Adds steps to totalSteps. - virtual void AddStepsToDo(unsigned int steps) override; + void AddStepsToDo(unsigned int steps) override; //##Documentation //## @brief Sets the current amount of progress to current progress + steps. //## @param: steps the number of steps done since last Progress(int steps) call. - virtual void Progress(unsigned int steps) override; + void Progress(unsigned int steps) override; signals: void SignalAddStepsToDo(unsigned int steps); void SignalProgress(unsigned int steps); void SignalSetPercentageVisible(bool visible); protected slots: virtual void SlotAddStepsToDo(unsigned int steps); virtual void SlotProgress(unsigned int steps); virtual void SlotSetPercentageVisible(bool visible); private: //##Documentation //## @brief Reset the progress bar. The progress bar "rewinds" and shows no progress. void Reset() override; unsigned int m_TotalSteps; unsigned int m_Progress; }; #endif /* define QMITKPROGRESSBAR_H */ diff --git a/Modules/QtWidgets/include/QmitkPropertiesTableEditor.h b/Modules/QtWidgets/include/QmitkPropertiesTableEditor.h index 08d09766c9..a34fc93b6b 100644 --- a/Modules/QtWidgets/include/QmitkPropertiesTableEditor.h +++ b/Modules/QtWidgets/include/QmitkPropertiesTableEditor.h @@ -1,90 +1,90 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QmitkPropertiesTableEditor_h #define QmitkPropertiesTableEditor_h #include /// Own includes. #include "mitkDataNode.h" /// Toolkit includes. #include /// Forward declarations. class QmitkPropertiesTableModel; class QTableView; class QLineEdit; /** * \ingroup QmitkModule * \brief Combines a QTableView along with a QmitkPropertiesTableModel to a reusable * Property Editor component. * * \see QmitkPropertyDelegate */ class MITKQTWIDGETS_EXPORT QmitkPropertiesTableEditor : public QWidget { Q_OBJECT public: /// /// Constructs a new QmitkDataStorageTableModel /// and sets the DataNode for this TableModel. QmitkPropertiesTableEditor(QWidget *parent = 0, Qt::WindowFlags f = 0, mitk::DataNode::Pointer _Node = 0); /// /// Standard dtor. Nothing to do here. - virtual ~QmitkPropertiesTableEditor(); + ~QmitkPropertiesTableEditor() override; /// /// Convenience method. Sets the property list in the model. /// void SetPropertyList(mitk::PropertyList::Pointer _List); /// /// Get the model. /// QmitkPropertiesTableModel *getModel() const; QTableView *getTable() const; protected slots: void PropertyFilterKeyWordTextChanged(const QString &text); protected: /// /// Initialise empty GUI. /// virtual void init(); /// /// The table view that renders the property list. /// QTableView *m_NodePropertiesTableView; /// /// A text field in which the user can enter a filter keyword for the properties. Only properties containing with this /// keyword /// will be selected. /// QLineEdit *m_TxtPropertyFilterKeyWord; /// /// The property list table model. /// QmitkPropertiesTableModel *m_Model; }; #endif /* QMITKPROPERTIESTABLEMODEL_H_ */ diff --git a/Modules/QtWidgets/include/QmitkPropertyItemDelegate.h b/Modules/QtWidgets/include/QmitkPropertyItemDelegate.h index 14e1689c07..f55ec505bf 100644 --- a/Modules/QtWidgets/include/QmitkPropertyItemDelegate.h +++ b/Modules/QtWidgets/include/QmitkPropertyItemDelegate.h @@ -1,97 +1,97 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QmitkPropertyItemDelegate_h #define QmitkPropertyItemDelegate_h #include #include #include #include #include class QComboBox; class QLineEdit; class QToolButton; class QResizeEvent; class QmitkColorWidget : public QWidget { Q_OBJECT public: explicit QmitkColorWidget(QWidget *parent = nullptr); - ~QmitkColorWidget(); + ~QmitkColorWidget() override; QColor GetColor() const; void SetColor(QColor color); signals: void ColorPicked(); private slots: void OnButtonClicked(); void OnLineEditEditingFinished(); private: QColor m_Color; QLineEdit *m_LineEdit; QToolButton *m_Button; }; class QmitkComboBoxListView : public QListView { Q_OBJECT public: explicit QmitkComboBoxListView(QComboBox *comboBox = nullptr); - ~QmitkComboBoxListView(); + ~QmitkComboBoxListView() override; protected: void paintEvent(QPaintEvent *event) override; void resizeEvent(QResizeEvent *event) override; QStyleOptionViewItem viewOptions() const override; private: QComboBox *m_ComboBox; }; class MITKQTWIDGETS_EXPORT QmitkPropertyItemDelegate : public QStyledItemDelegate { Q_OBJECT public: explicit QmitkPropertyItemDelegate(QObject *parent = nullptr); - ~QmitkPropertyItemDelegate(); + ~QmitkPropertyItemDelegate() override; QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const override; void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override; void setEditorData(QWidget *editor, const QModelIndex &index) const override; void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const override; void SetPropertyList(mitk::PropertyList *propertyList); private slots: void OnComboBoxCurrentIndexChanged(int index); void OnSpinBoxEditingFinished(); void OnColorPicked(); private: std::string GetPropertyName(const QModelIndex &index) const; mitk::WeakPointer m_PropertyList; }; #endif diff --git a/Modules/QtWidgets/include/QmitkPropertyItemModel.h b/Modules/QtWidgets/include/QmitkPropertyItemModel.h index cad26e11bf..803048e442 100644 --- a/Modules/QtWidgets/include/QmitkPropertyItemModel.h +++ b/Modules/QtWidgets/include/QmitkPropertyItemModel.h @@ -1,88 +1,88 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QmitkPropertyItemModel_h #define QmitkPropertyItemModel_h #include #include #include #include class QmitkPropertyItem; namespace berry { struct IBerryPreferences; } namespace mitk { class IPropertyAliases; class IPropertyFilters; enum { PropertyRole = Qt::UserRole + 1 }; } class MITKQTWIDGETS_EXPORT QmitkPropertyItemModel : public QAbstractItemModel { Q_OBJECT public: explicit QmitkPropertyItemModel(QObject *parent = nullptr); - ~QmitkPropertyItemModel(); + ~QmitkPropertyItemModel() override; int columnCount(const QModelIndex &parent = QModelIndex()) const override; QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; Qt::ItemFlags flags(const QModelIndex &index) const override; mitk::PropertyList *GetPropertyList() const; QVariant headerData(int section, Qt::Orientation orientation, int role) const override; QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override; void OnPreferencesChanged(); QModelIndex parent(const QModelIndex &child) const override; int rowCount(const QModelIndex &parent = QModelIndex()) const override; bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override; void SetPropertyList(mitk::PropertyList *propertyList, const QString &className = ""); void Update(); void SetShowAliases(const bool showAliases) { this->m_ShowAliases = showAliases; } bool GetShowAliases() const { return this->m_ShowAliases; } void SetFilterProperties(const bool filterProperties) { this->m_FilterProperties = filterProperties; } bool GetFilterProperties() const { return this->m_FilterProperties; } private: void CreateRootItem(); QModelIndex FindProperty(const mitk::BaseProperty *property); void OnPropertyListModified(const itk::Object *propertyList); void OnPropertyListDeleted(const itk::Object *propertyList); void OnPropertyDeleted(const itk::Object *property, const itk::EventObject &event); void OnPropertyModified(const itk::Object *property, const itk::EventObject &event); void SetNewPropertyList(mitk::PropertyList *propertyList); bool m_ShowAliases; bool m_FilterProperties; mitk::IPropertyAliases *m_PropertyAliases; mitk::IPropertyFilters *m_PropertyFilters; mitk::WeakPointer m_PropertyList; QString m_ClassName; std::unique_ptr m_RootItem; std::map m_PropertyDeletedTags; std::map m_PropertyModifiedTags; }; #endif diff --git a/Modules/QtWidgets/include/QmitkRenderWindow.h b/Modules/QtWidgets/include/QmitkRenderWindow.h index 52406c7123..31af9e698d 100644 --- a/Modules/QtWidgets/include/QmitkRenderWindow.h +++ b/Modules/QtWidgets/include/QmitkRenderWindow.h @@ -1,167 +1,167 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QMITKRENDERWINDOW_H_HEADER_INCLUDED_C1C40D66 #define QMITKRENDERWINDOW_H_HEADER_INCLUDED_C1C40D66 #include "mitkRenderWindowBase.h" #include "QVTKWidget.h" #include "QmitkRenderWindowMenu.h" #include #include #include "mitkBaseRenderer.h" #include "mitkInteractionEventConst.h" class QmitkStdMultiWidget; class QDragEnterEvent; class QDropEvent; class QInputEvent; /** * \ingroup QmitkModule * \brief MITK implementation of the QVTKWidget */ class MITKQTWIDGETS_EXPORT QmitkRenderWindow : public QVTKWidget, public mitk::RenderWindowBase { Q_OBJECT public: QmitkRenderWindow( QWidget *parent = 0, QString name = "unnamed renderwindow", mitk::VtkPropRenderer *renderer = nullptr, mitk::RenderingManager *renderingManager = nullptr, mitk::BaseRenderer::RenderingMode::Type renderingMode = mitk::BaseRenderer::RenderingMode::Standard); - virtual ~QmitkRenderWindow(); + ~QmitkRenderWindow() override; /** * \brief Whether Qt events should be passed to parent (default: true) * * With introduction of the QVTKWidget the behaviour regarding Qt events changed. * QVTKWidget "accepts" Qt events like mouse clicks (i.e. set an "accepted" flag). * When this flag is set, Qt fininshed handling of this event -- otherwise it is * reached through to the widget's parent. * * This reaching through to the parent was implicitly required by QmitkMaterialWidget / QmitkMaterialShowCase. *QmitkStdMultiWidget * The default behaviour of QmitkRenderWindow is now to clear the "accepted" flag * of Qt events after they were handled by QVTKWidget. This way parents can also * handle events. * * If you don't want this behaviour, call SetResendQtEvents(true) on your render window. */ virtual void SetResendQtEvents(bool resend); // Set Layout Index to define the Layout Type void SetLayoutIndex(unsigned int layoutIndex); // Get Layout Index to define the Layout Type unsigned int GetLayoutIndex(); // MenuWidget need to update the Layout Design List when Layout had changed void LayoutDesignListChanged(int layoutDesignIndex); void HideRenderWindowMenu(); // Activate or Deactivate MenuWidget. void ActivateMenuWidget(bool state, QmitkStdMultiWidget *stdMultiWidget = 0); bool GetActivateMenuWidgetFlag() { return m_MenuWidgetActivated; } // Get it from the QVTKWidget parent - virtual vtkRenderWindow *GetVtkRenderWindow() override { return GetRenderWindow(); } - virtual vtkRenderWindowInteractor *GetVtkRenderWindowInteractor() override { return nullptr; } + vtkRenderWindow *GetVtkRenderWindow() override { return GetRenderWindow(); } + vtkRenderWindowInteractor *GetVtkRenderWindowInteractor() override { return nullptr; } void FullScreenMode(bool state); protected: // overloaded move handler - virtual void moveEvent(QMoveEvent *event) override; + void moveEvent(QMoveEvent *event) override; // overloaded show handler void showEvent(QShowEvent *event) override; // overloaded paint handler - virtual void paintEvent(QPaintEvent *event) override; + void paintEvent(QPaintEvent *event) override; // overloaded mouse press handler - virtual void mousePressEvent(QMouseEvent *event) override; + void mousePressEvent(QMouseEvent *event) override; // overloaded mouse double-click handler - virtual void mouseDoubleClickEvent(QMouseEvent *event) override; + void mouseDoubleClickEvent(QMouseEvent *event) override; // overloaded mouse move handler - virtual void mouseMoveEvent(QMouseEvent *event) override; + void mouseMoveEvent(QMouseEvent *event) override; // overloaded mouse release handler - virtual void mouseReleaseEvent(QMouseEvent *event) override; + void mouseReleaseEvent(QMouseEvent *event) override; // overloaded key press handler - virtual void keyPressEvent(QKeyEvent *event) override; + void keyPressEvent(QKeyEvent *event) override; // overloaded enter handler - virtual void enterEvent(QEvent *) override; + void enterEvent(QEvent *) override; // overloaded leave handler - virtual void leaveEvent(QEvent *) override; + void leaveEvent(QEvent *) override; /// \brief Simply says we accept the event type. - virtual void dragEnterEvent(QDragEnterEvent *event) override; + void dragEnterEvent(QDragEnterEvent *event) override; /// \brief If the dropped type is application/x-mitk-datanodes we process the request by converting to mitk::DataNode /// pointers and emitting the NodesDropped signal. - virtual void dropEvent(QDropEvent *event) override; + void dropEvent(QDropEvent *event) override; #ifndef QT_NO_WHEELEVENT // overload wheel mouse event - virtual void wheelEvent(QWheelEvent *) override; + void wheelEvent(QWheelEvent *) override; #endif void AdjustRenderWindowMenuVisibility(const QPoint &pos); signals: void ResetView(); // \brief int parameters are enum from QmitkStdMultiWidget void ChangeCrosshairRotationMode(int); void SignalLayoutDesignChanged(int layoutDesignIndex); void moved(); /// \brief Emits a signal to say that this window has had the following nodes dropped on it. void NodesDropped(QmitkRenderWindow *thisWindow, std::vector nodes); protected slots: void OnChangeLayoutDesign(int layoutDesignIndex); void OnWidgetPlaneModeChanged(int); void DeferredHideMenu(); private: // Helper Functions to Convert Qt-Events to Mitk-Events mitk::Point2D GetMousePosition(QMouseEvent *me) const; mitk::Point2D GetMousePosition(QWheelEvent *we) const; mitk::InteractionEvent::MouseButtons GetEventButton(QMouseEvent *me) const; mitk::InteractionEvent::MouseButtons GetButtonState(QMouseEvent *me) const; mitk::InteractionEvent::ModifierKeys GetModifiers(QInputEvent *me) const; mitk::InteractionEvent::MouseButtons GetButtonState(QWheelEvent *we) const; std::string GetKeyLetter(QKeyEvent *ke) const; int GetDelta(QWheelEvent *we) const; bool m_ResendQtEvents; QmitkRenderWindowMenu *m_MenuWidget; bool m_MenuWidgetActivated; unsigned int m_LayoutIndex; }; #endif diff --git a/Modules/QtWidgets/include/QmitkRenderWindowMenu.h b/Modules/QtWidgets/include/QmitkRenderWindowMenu.h index 03b075c799..7d2ea6a1cd 100644 --- a/Modules/QtWidgets/include/QmitkRenderWindowMenu.h +++ b/Modules/QtWidgets/include/QmitkRenderWindowMenu.h @@ -1,339 +1,339 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QmitkRenderWindowMenu_h #define QmitkRenderWindowMenu_h #if defined(_WIN32) || defined(__APPLE__) #define QMITK_USE_EXTERNAL_RENDERWINDOW_MENU #endif #include "mitkBaseRenderer.h" #include #include #include #include #include #include #include #include #include class QmitkStdMultiWidget; /** * \ingroup QmitkModule * \brief The QmitkRenderWindowMenu is a popup Widget which shows * up when the mouse curser enter a QmitkRenderWindow. * The Menu Widget is located in the right top corner of each * RenderWindow. It includes different settings. For example * the layout design can be changed with the setting button. Switching * between full-screen mode and layout design can be done * with the full-screen button. Splitting the Widget horizontal or * vertical as well closing the Widget is not implemented yet. * The popup Widget can be deactivated with ActivateMenuWidget(false) in * QmitkRenderWindow. * * \sa QmitkRenderWindow * \sa QmitkStdMultiWidget * */ class MITKQTWIDGETS_EXPORT QmitkRenderWindowMenu : public QWidget { Q_OBJECT public: QmitkRenderWindowMenu(QWidget *parent = 0, Qt::WindowFlags f = 0, mitk::BaseRenderer *b = 0, QmitkStdMultiWidget *mw = 0); - virtual ~QmitkRenderWindowMenu(); + ~QmitkRenderWindowMenu() override; /*! Return visibility of settings menu. The menu is connected with m_SettingsButton and includes layout direction (axial, coronal .. ) and layout design (standard layout, 2D images top, 3D bottom ... ). */ bool GetSettingsMenuVisibilty() { if (m_Settings == nullptr) return false; else return m_Settings->isVisible(); } /*! Set layout index. Defines layout direction (axial, coronal, sagital or threeD) of the parent. */ void SetLayoutIndex(unsigned int layoutIndex); /*! Return layout direction of parent (axial, coronal, sagital or threeD) */ unsigned int GetLayoutIndex() { return m_Layout; } /*! Update list of layout design (standard layout, 2D images top, 3D bottom ..). Set action of current layout design to disable and all other to enable. */ void UpdateLayoutDesignList(int layoutDesignIndex); /*! Move menu widget to correct position (right upper corner). E.g. it is necessary when the full-screen mode is activated.*/ #ifdef QMITK_USE_EXTERNAL_RENDERWINDOW_MENU void MoveWidgetToCorrectPos(float opacity); #else void MoveWidgetToCorrectPos(float /*opacity*/); #endif void ChangeFullScreenMode(bool state); void NotifyNewWidgetPlanesMode(int mode); protected: /*! Create menu widget. The menu contains five QPushButtons (hori-split, verti-split, full-screen, settings and close button) and their signal/slot connection for handling. */ void CreateMenuWidget(); /*! Create settings menu which contains layout direction and the different layout designs. */ void CreateSettingsWidget(); /*! Reimplemented from QWidget. The paint event is a request to repaint all or part of a widget.*/ - void paintEvent(QPaintEvent *event); + void paintEvent(QPaintEvent *event) override; /*! Update list of layout direction (axial, coronal, sagital or threeD). Set action of currect layout direction to disable and all other to enable. Normaly the user can switch here between the different layout direction, but this is not supported yet. */ void UpdateLayoutList(); /*! Change Icon of full-screen button depending on full-screen mode. */ void ChangeFullScreenIcon(); int currentCrosshairRotationMode; public slots: void SetCrossHairVisibility(bool state); signals: void ResetView(); // == "global reinit" // \brief int parameters are enum from QmitkStdMultiWidget void ChangeCrosshairRotationMode(int); /*! emit signal, when layout design changed by the setting menu.*/ void SignalChangeLayoutDesign(int layoutDesign); public slots: void DeferredHideMenu(); void DeferredShowMenu(); void smoothHide(); protected slots: /// /// this function is continously called by a timer /// to do the auto rotation /// void AutoRotateNextStep(); /// /// this function is invoked when the auto-rotate action /// is clicked /// void OnAutoRotationActionTriggered(); void enterEvent(QEvent * /*e*/) override; void leaveEvent(QEvent * /*e*/) override; void OnTSNumChanged(int); void OnCrosshairRotationModeSelected(QAction *); /*! slot for activating/deactivating the full-screen mode. The slot is connected to the clicked() event of m_FullScreenButton. Activating the full-screen maximize the current widget, deactivating restore If layout design changed by the settings menu, the full-Screen mode is automatically switch to false. */ void OnFullScreenButton(bool checked); /*! Slot for opening setting menu. The slot is connected to the clicked() event of m_SettingsButton. The settings menu includes differen layout directions (axial, coronal, saggital and 3D) as well all layout design (standard layout, 2D images top, 3D bottom ..)*/ void OnSettingsButton(bool checked); /*! Slot for changing layout design to standard layout. The slot is connected to the triggered() signal of * m_DefaultLayoutAction. */ void OnChangeLayoutToDefault(bool); /*! Slot for changing layout design to 2D images top, 3D bottom layout. The slot is connected to the triggered() * signal of m_2DImagesUpLayoutAction. */ void OnChangeLayoutTo2DImagesUp(bool); /*! Slot for changing layout design to 2D images left, 3D right layout. The slot is connected to the triggered() * signal of m_2DImagesLeftLayoutAction. */ void OnChangeLayoutTo2DImagesLeft(bool); /*! Slot for changing layout to Big 3D layout. The slot is connected to the triggered() signal of m_Big3DLayoutAction. */ void OnChangeLayoutToBig3D(bool); /*! Slot for changing layout design to Axial plane layout. The slot is connected to the triggered() signal of * m_Widget1LayoutAction. */ void OnChangeLayoutToWidget1(bool); /*! Slot for changing layout design to Sagittal plane layout. The slot is connected to the triggered() signal of * m_Widget2LayoutAction. */ void OnChangeLayoutToWidget2(bool); /*! Slot for changing layout design to Coronal plane layout. The slot is connected to the triggered() signal of * m_Widget3LayoutAction. */ void OnChangeLayoutToWidget3(bool); /*! Slot for changing layout design to Coronal top, 3D bottom layout. The slot is connected to the triggered() signal * of m_RowWidget3And4LayoutAction. */ void OnChangeLayoutToRowWidget3And4(bool); /*! Slot for changing layout design to Coronal left, 3D right layout. The slot is connected to the triggered() signal * of m_ColumnWidget3And4LayoutAction. */ void OnChangeLayoutToColumnWidget3And4(bool); /*! Slot for changing layout design to Sagittal top, Coronal n 3D bottom layout. The slot is connected to the * triggered() signal of m_SmallUpperWidget2Big3and4LayoutAction. */ void OnChangeLayoutToSmallUpperWidget2Big3and4(bool); /*! Slot for changing layout design to Axial n Sagittal left, 3D right layout. The slot is connected to the * triggered() signal of m_2x2Dand3DWidgetLayoutAction. */ void OnChangeLayoutTo2x2Dand3DWidget(bool); /*! Slot for changing layout design to Axial n 3D left, Sagittal right layout. The slot is connected to the * triggered() signal of m_Left2Dand3DRight2DLayoutAction. */ void OnChangeLayoutToLeft2Dand3DRight2D(bool); void OnCrossHairMenuAboutToShow(); public: /*! enum for layout direction*/ enum { AXIAL, SAGITTAL, CORONAL, THREE_D }; /*! enum for layout design */ enum { LAYOUT_DEFAULT, LAYOUT_2DIMAGEUP, LAYOUT_2DIMAGELEFT, LAYOUT_BIG3D, LAYOUT_AXIAL, LAYOUT_SAGITTAL, LAYOUT_CORONAL, LAYOUT_2X2DAND3DWIDGET, LAYOUT_ROWWIDGET3AND4, LAYOUT_COLUMNWIDGET3AND4, LAYOUT_ROWWIDGETSMALL3ANDBIG4, // not in use in this class, but we need it here to synchronize with the // SdtMultiWidget. LAYOUT_SMALLUPPERWIDGET2BIGAND4, LAYOUT_LEFT2DAND3DRIGHT2D }; void ShowMenu(); void HideMenu(); protected: QToolButton *m_CrosshairModeButton; // QAction* m_ShowHideCrosshairVisibilityAction; /*! QPushButton for activating/deactivating full-screen mode*/ QToolButton *m_FullScreenButton; /*! QPushButton for open the settings menu*/ QToolButton *m_SettingsButton; /*! QAction for Default layout design */ QAction *m_DefaultLayoutAction; /*! QAction for 2D images up layout design */ QAction *m_2DImagesUpLayoutAction; /*! QAction for 2D images left layout design */ QAction *m_2DImagesLeftLayoutAction; /*! QAction for big 3D layout design */ QAction *m_Big3DLayoutAction; /*! QAction for big axial layout design */ QAction *m_Widget1LayoutAction; /*! QAction for big saggital layout design */ QAction *m_Widget2LayoutAction; /*! QAction for big coronal layout design */ QAction *m_Widget3LayoutAction; /*! QAction for coronal top, 3D bottom layout design */ QAction *m_RowWidget3And4LayoutAction; /*! QAction for coronal left, 3D right layout design */ QAction *m_ColumnWidget3And4LayoutAction; /*! QAction for sagittal top, coronal n 3D bottom layout design */ QAction *m_SmallUpperWidget2Big3and4LayoutAction; /*! QAction for axial n sagittal left, 3D right layout design */ QAction *m_2x2Dand3DWidgetLayoutAction; /*! QAction for axial n 3D left, sagittal right layout design*/ QAction *m_Left2Dand3DRight2DLayoutAction; QLabel *m_TSLabel; /*! QMenu containg all layout direction and layout design settings.*/ QMenu *m_Settings; QMenu *m_CrosshairMenu; /*! Index of layout direction. 0: axial; 1: saggital; 2: coronal; 3: threeD */ unsigned int m_Layout; /*! Index of layout design. 0: LAYOUT_DEFAULT; 1: LAYOUT_2DIMAGEUP; 2: LAYOUT_2DIMAGELEFT; 3: LAYOUT_BIG3D 4: LAYOUT_AXIAL; 5: LAYOUT_SAGITTAL; 6: LAYOUT_CORONAL; 7: LAYOUT_2X2DAND3DWIDGET; 8: LAYOUT_ROWWIDGET3AND4; 9: LAYOUT_COLUMNWIDGET3AND4; 10: LAYOUT_ROWWIDGETSMALL3ANDBIG4; 11: LAYOUT_SMALLUPPERWIDGET2BIGAND4; 12: LAYOUT_LEFT2DAND3DRIGHT2D */ unsigned int m_LayoutDesign; /*! Store index of old layout design. It is used e.g. for the full-screen mode, when deactivating the mode the former * layout design will restore.*/ unsigned int m_OldLayoutDesign; /*! Flag if full-screen mode is activated or deactivated. */ bool m_FullScreenMode; bool m_Entered; private: mitk::BaseRenderer::Pointer m_Renderer; QmitkStdMultiWidget *m_MultiWidget; /// /// a timer for the auto rotate action /// QTimer m_AutoRotationTimer; QTimer m_HideTimer; QWidget *m_Parent; }; #endif // QmitkRenderWindowMenu_H diff --git a/Modules/QtWidgets/include/QmitkRenderingManager.h b/Modules/QtWidgets/include/QmitkRenderingManager.h index ddfbba389d..55974ab58b 100644 --- a/Modules/QtWidgets/include/QmitkRenderingManager.h +++ b/Modules/QtWidgets/include/QmitkRenderingManager.h @@ -1,85 +1,85 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QMITKRENDERINGMANAGER_H_HEADER_INCLUDED_C135A197 #define QMITKRENDERINGMANAGER_H_HEADER_INCLUDED_C135A197 #include #include "mitkRenderingManager.h" #include #include class QmitkRenderingManagerInternal; class QmitkRenderingManagerFactory; /** * \ingroup QmitkModule * \brief Qt specific implementation of mitk::RenderingManager. * * This implementation defines a QmitkRenderingRequestEvent to realize the * rendering request process. The event must be handled by the Qmitk * interface to Qt (QmitkRenderWindow). * * Note: it may be necessary to remove all pending RenderingRequestEvents * from the system's event processing pipeline during system shutdown to * make sure that dangling events do not lead to unexpected behavior. * */ class MITKQTWIDGETS_EXPORT QmitkRenderingManager : public QObject, public mitk::RenderingManager { Q_OBJECT public: mitkClassMacro(QmitkRenderingManager, mitk::RenderingManager); - virtual ~QmitkRenderingManager(); + ~QmitkRenderingManager() override; - virtual void DoMonitorRendering() override; - virtual void DoFinishAbortRendering() override; + void DoMonitorRendering() override; + void DoFinishAbortRendering() override; - virtual bool event(QEvent *event) override; + bool event(QEvent *event) override; protected: itkFactorylessNewMacro(Self); QmitkRenderingManager(); - virtual void GenerateRenderingRequestEvent() override; + void GenerateRenderingRequestEvent() override; - virtual void StartOrResetTimer() override; + void StartOrResetTimer() override; int pendingTimerCallbacks; protected slots: void TimerCallback(); private: friend class QmitkRenderingManagerFactory; }; class QmitkRenderingRequestEvent : public QEvent { public: enum Type { RenderingRequest = QEvent::MaxUser - 1024 }; QmitkRenderingRequestEvent() : QEvent((QEvent::Type)RenderingRequest){}; }; #endif /* MITKRenderingManager_H_HEADER_INCLUDED_C135A197 */ diff --git a/Modules/QtWidgets/include/QmitkServiceListWidget.h b/Modules/QtWidgets/include/QmitkServiceListWidget.h index 14b25d6157..c3212a9beb 100644 --- a/Modules/QtWidgets/include/QmitkServiceListWidget.h +++ b/Modules/QtWidgets/include/QmitkServiceListWidget.h @@ -1,292 +1,292 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef _QmitkServiceListWidget_H_INCLUDED #define _QmitkServiceListWidget_H_INCLUDED #include "MitkQtWidgetsExports.h" #include "ui_QmitkServiceListWidgetControls.h" #include // QT headers #include #include // Microservices #include "mitkServiceInterface.h" #include "usModuleContext.h" #include "usServiceEvent.h" #include "usServiceReference.h" /** * \ingroup QmitkModule * * \brief This widget provides abstraction for the handling of MicroServices. * * Place one in your Plugin and set it to look for a certain interface. * One can also specify a filter and / or a property to use for captioning of * the services. It also offers functionality to signal * ServiceEvents and to return the actual classes, so only a minimum of * interaction with the MicroserviceInterface is required. * To get started, just put it in your Plugin or Widget, call the Initialize * Method and optionally connect it's signals. * As QT limits templating possibilities, events only throw ServiceReferences. * You can manually dereference them using TranslateServiceReference() */ class MITKQTWIDGETS_EXPORT QmitkServiceListWidget : public QWidget { // this is needed for all Qt objects that should have a MOC object (everything that derives from QObject) Q_OBJECT private: us::ModuleContext *m_Context; /** \brief a filter to further narrow down the list of results*/ std::string m_Filter; /** \brief The name of the ServiceInterface that this class should list */ std::string m_Interface; /** \brief The name of the ServiceProperty that will be displayed in the list to represent the service */ std::string m_NamingProperty; /** \brief Determines if the first entry of the list should be selected automatically if no entry was selected before * (default false). */ bool m_AutomaticallySelectFirstEntry; public: static const std::string VIEW_ID; QmitkServiceListWidget(QWidget *p = 0, Qt::WindowFlags f1 = 0); - virtual ~QmitkServiceListWidget(); + ~QmitkServiceListWidget() override; /** \brief Set if the first entry of the list should be selected automatically if no entry was selected before. */ void SetAutomaticallySelectFirstEntry(bool automaticallySelectFirstEntry); /** \brief This method is part of the widget an needs not to be called separately. */ virtual void CreateQtPartControl(QWidget *parent); /** \brief This method is part of the widget an needs not to be called separately. (Creation of the connections of * main and control widget.)*/ virtual void CreateConnections(); /** * \brief Will return true, if a service is currently selected and false otherwise. * * Call this before requesting service references to avoid invalid ServiceReferences. */ bool GetIsServiceSelected(); /** * \brief Returns the currently selected Service as a ServiceReference. * * If no Service is selected, the result will probably be a bad pointer. call GetIsServiceSelected() * beforehand to avoid this */ us::ServiceReferenceU GetSelectedServiceReference(); /** * @return Returns all service references that are displayed in this widget. */ std::vector GetAllServiceReferences(); /** * \brief Use this function to return the all listed services as a class directly. * * Make sure you pass the appropriate type, or else this call will fail. * Usually, you will pass the class itself, not the SmartPointer, but the function returns a pointer. */ template std::vector GetAllServices() { // if (this->m_Controls->m_ServiceList->currentRow()==-1) return nullptr; std::vector refs = GetAllServiceReferences(); std::vector result; for (std::size_t i = 0; i < refs.size(); i++) { result.push_back(m_Context->GetService(us::ServiceReference(refs[i]))); } return result; } /** * \brief Use this function to return the currently selected service as a class directly. * * Make sure you pass the appropriate type, or else this call will fail. * Usually, you will pass the class itself, not the SmartPointer, but the function returns a pointer. Example: * \verbatim mitk::USDevice::Pointer device = GetSelectedService(); \endverbatim * @return Returns the current selected device. Returns nullptr if no device is selected. */ template T *GetSelectedService() { if (this->m_Controls->m_ServiceList->currentRow() == -1) return nullptr; us::ServiceReferenceU ref = GetServiceForListItem(this->m_Controls->m_ServiceList->currentItem()); return (m_Context->GetService(us::ServiceReference(ref))); } /** * \brief Initializes the Widget with essential parameters. * * The string filter is an LDAP parsable String, compare mitk::ModuleContext for examples on filtering. * Pass class T to tell the widget which class it should filter for - only services of this class will be listed. * NamingProperty is a property that will be used to caption the Items in the list. If no filter is supplied, all * matching interfaces are shown. If no namingProperty is supplied, the interfaceName will be used to caption Items in the list. * For example, this Initialization will filter for all USDevices that are set to active. The USDevice's model will be used to display it in the list: * \verbatim std::string filter = "(&(" + us::ServiceConstants::OBJECTCLASS() + "=" + "org.mitk.services.UltrasoundDevice)(IsActive=true))"; m_Controls.m_ActiveVideoDevices->Initialize(mitk::USDevice::GetPropertyKeys().US_PROPKEY_NAME ,filter); * \endverbatim */ template void Initialize(const std::string &namingProperty = static_cast(""), const std::string &filter = static_cast("")) { std::string interfaceName(us_service_interface_iid()); m_Interface = interfaceName; InitPrivate(namingProperty, filter); } /** * \brief Translates a serviceReference to a class of the given type. * * Use this to translate the signal's parameters. To adhere to the MicroService contract, * only ServiceReferences stemming from the same widget should be used as parameters for this method. * \verbatim mitk::USDevice::Pointer device = TranslateReference(myDeviceReference); \endverbatim */ template T *TranslateReference(const us::ServiceReferenceU &reference) { return m_Context->GetService(us::ServiceReference(reference)); } /** *\brief This Function listens to ServiceRegistry changes and updates the list of services accordingly. * * The user of this widget does not need to call this method, it is instead used to recieve events from the module *registry. */ void OnServiceEvent(const us::ServiceEvent event); signals: /** *\brief Emitted when a new Service matching the filter is being registered. * * Be careful if you use a filter: * If a device does not match the filter when registering, but modifies it's properties later to match the filter, * then the first signal you will see this device in will be ServiceModified. */ void ServiceRegistered(us::ServiceReferenceU); /** *\brief Emitted directly before a Service matching the filter is being unregistered. */ void ServiceUnregistering(us::ServiceReferenceU); /** *\brief Emitted when a Service matching the filter changes it's properties, or when a service that formerly not *matched the filter * changed it's properties and now matches the filter. */ void ServiceModified(us::ServiceReferenceU); /** *\brief Emitted when a Service matching the filter changes it's properties, * * and the new properties make it fall trough the filter. This effectively means that * the widget will not track the service anymore. Usually, the Service should still be useable though */ void ServiceModifiedEndMatch(us::ServiceReferenceU); /** *\brief Emitted if the user selects a Service from the list. * * If no service is selected, an invalid serviceReference is returned. The user can easily check for this. * if (serviceReference) will evaluate to false, if the reference is invalid and true if valid. */ void ServiceSelectionChanged(us::ServiceReferenceU); public slots: protected slots: /** \brief Called, when the selection in the list of Services changes. */ void OnServiceSelectionChanged(); protected: Ui::QmitkServiceListWidgetControls *m_Controls; ///< member holding the UI elements of this widget /** * \brief Internal structure used to link ServiceReferences to their QListWidgetItems */ struct ServiceListLink { us::ServiceReferenceU service; QListWidgetItem *item; }; /** * \brief Finishes initialization after Initialize has been called. * * This function assumes that m_Interface is set correctly (Which Initialize does). */ void InitPrivate(const std::string &namingProperty, const std::string &filter); /** * \brief Contains a list of currently active services and their entires in the list. This is wiped with every * ServiceRegistryEvent. */ std::vector m_ListContent; /** * \brief Constructs a ListItem from the given service, displays it, and locally stores the service. */ QListWidgetItem *AddServiceToList(const us::ServiceReferenceU &serviceRef); /** * \brief Removes the given service from the list and cleans up. Returns true if successful, false if service was not * found. */ bool RemoveServiceFromList(const us::ServiceReferenceU &serviceRef); /** * \brief Changes list entry of given service to match the changed service properties. * \return true if successful, false if service was not found */ bool ChangeServiceOnList(const us::ServiceReferenceU &serviceRef); /** * \brief Returns the serviceReference corresponding to the given ListEntry or an invalid one if none was found (will * evaluate to false in bool expressions). */ us::ServiceReferenceU GetServiceForListItem(QListWidgetItem *item); /** * \brief Returns a list of ServiceReferences matching the filter criteria by querying the service registry. */ std::vector GetAllRegisteredServices(); /** * \brief Gets string from the naming property of the service. * \return caption string for given us::ServiceReferenceU */ QString CreateCaptionForService(const us::ServiceReferenceU &serviceRef); }; #endif // _QmitkServiceListWidget_H_INCLUDED diff --git a/Modules/QtWidgets/include/QmitkSliderLevelWindowWidget.h b/Modules/QtWidgets/include/QmitkSliderLevelWindowWidget.h index 021fd819ca..32b14887ab 100644 --- a/Modules/QtWidgets/include/QmitkSliderLevelWindowWidget.h +++ b/Modules/QtWidgets/include/QmitkSliderLevelWindowWidget.h @@ -1,193 +1,193 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QMITKSLIDERLEVELWINDOW_WIDGET #define QMITKSLIDERLEVELWINDOW_WIDGET #include #include #include class QmitkLevelWindowWidgetContextMenu; /** * \ingroup QmitkModule * * \brief Provides a widget with a slider to change the level and * window value of the current image. * * This documentation actually refers to the QmitkLevelWindowWidget * and is only put in this class due to technical issues (should be * moved later). * * The QmitkLevelWindowWidget is a kind of container for a * QmitkSliderLevelWindowWidget (this is the cyan bar above the text * input fields) and a QmitkLineEditLevelWindowWidget (with two text * input fields). It holds a reference to a mitk::LevelWindowManager * variable, which keeps the LevelWindowProperty of the currently * selected image. Level/Window is manipulated by the text inputs and * the Slider to adjust brightness/contrast of a single image. All * changes on the slider or in the text input fields affect the current * image by giving new values to LevelWindowManager. LevelWindowManager * then sends a signal to tell other listeners about changes. * * Which image is changed is determined by mitkLevelWindowManager. If * m_AutoTopMost is true, always the topmost image in data tree (layer * property) is affected by changes. The image which is affected by * changes can also be changed by QmitkLevelWindowWidgetContextMenu, * the context menu for QmitkSliderLevelWindowWidget and * QmitkLineEditLevelWindowWidget. There you have the possibility to * set a certain image or always the topmost image in the data tree * (layer property) to be affected by changes. * * The internal mitk::LevelWindow variable contains a range that is * valid for a given image. It should not be possible to move the * level/window parameters outside this range. The range can be changed * and reset to its default values by QmitkLevelWindowWidgetContextMenu, * the context menu for QmitkSliderLevelWindowWidget and * QmitkLineEditLevelWindowWidget. * * Now for the behaviour of the text inputs: The upper one contains the * value of the level (brightness), the lower one shows the window (contrast). * * The behaviour of the cyan bar is more obvious: the scale in the * background shows the valid range. The cyan bar in front displays the * currently selected level/window setting. You can change the level by * dragging the bar with the left mouse button or clicking somewhere inside * the scalerange with the left mouse button. The window is changed by * moving the mouse on the upper or lower bound of the bar until the cursor * becomes an vertical double-arrowed symbol. Then you can change the * windowsize by clicking the left mouse button and move the mouse upwards * or downwards. The bar becomes greater upwards as well as downwards. If * you want to change the size of the window in only one direction you * have to press the CTRL-key while doing the same as mentioned above. * This information is also presented by a tooltip text when moving the * mouse on the upper or lower bound of the bar. */ class MITKQTWIDGETS_EXPORT QmitkSliderLevelWindowWidget : public QWidget { Q_OBJECT public: /// constructor QmitkSliderLevelWindowWidget(QWidget *parent = nullptr, Qt::WindowFlags f = nullptr); /// destructor - ~QmitkSliderLevelWindowWidget(); + ~QmitkSliderLevelWindowWidget() override; /*! * data structure which stores the values manipulated * by a QmitkSliderLevelWindowWidget */ mitk::LevelWindow m_LevelWindow; /// manager who is responsible to collect and deliver changes on Level/Window mitk::LevelWindowManager::Pointer m_Manager; /// sets the manager who is responsible to collect and deliver changes on Level/Window void setLevelWindowManager(mitk::LevelWindowManager *levelWindowManager); /// sets the DataStorage which holds all image-nodes void setDataStorage(mitk::DataStorage *ds); /// returns the manager who is responsible to collect and deliver changes on Level/Window mitk::LevelWindowManager *GetManager(); private: /// creates the contextmenu for this widget from class QmitkLevelWindowWidgetContextMenu void contextMenuEvent(QContextMenuEvent *) override; /// change notifications from the mitkLevelWindowManager void OnPropertyModified(const itk::EventObject &e); protected: /// recalculate the size and position of the slider bar virtual void update(); /*! * helper for drawing the component */ QRect m_Rect; /*! * helper for drawing the component */ QPoint m_StartPos; bool m_Resize; bool m_Bottom; bool m_MouseDown; bool m_Leftbutton; bool m_CtrlPressed; int m_MoveHeight; bool m_ScaleVisible; QRect m_LowerBound; QRect m_UpperBound; unsigned long m_ObserverTag; bool m_IsObserverTagSet; QFont m_Font; /*! * data structure which creates the contextmenu for QmitkLineEditLevelWindowWidget */ QmitkLevelWindowWidgetContextMenu *m_Contextmenu; /*! * repaint the slider and the scale */ void paintEvent(QPaintEvent *e) override; /*! * method implements the component behaviour * * checks if cursor is on upper or lower bound of slider bar and changes cursor symbol * * checks if left mouse button is pressed and if CTRL is pressed and changes sliderbar in movedirection accordingly */ void mouseMoveEvent(QMouseEvent *mouseEvent) override; void enterEvent(QEvent *event) override; /*! * registers events when a mousebutton is pressed * * if leftbutton is pressed m_Leftbutton is set to true * * also checks if CTRL is pressed and sets the bool variable m_CtrlPressed */ void mousePressEvent(QMouseEvent *mouseEvent) override; /*! * sets the variable m_MouseDown to false */ void mouseReleaseEvent(QMouseEvent *mouseEvent) override; /*! * causes an update of the sliderbar when resizing the window */ - void virtual resizeEvent(QResizeEvent *event) override; + void resizeEvent(QResizeEvent *event) override; protected slots: /// hides the scale if "Hide Scale" is selected in contextmenu void hideScale(); /// shows the scale if "Show Scale" is selected in contextmenu void showScale(); }; #endif // QMITKSLIDERLEVELWINDOW_WIDGET diff --git a/Modules/QtWidgets/include/QmitkStdMultiWidget.h b/Modules/QtWidgets/include/QmitkStdMultiWidget.h index 90bdfbc7b6..5eba7fb047 100644 --- a/Modules/QtWidgets/include/QmitkStdMultiWidget.h +++ b/Modules/QtWidgets/include/QmitkStdMultiWidget.h @@ -1,433 +1,433 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QmitkStdMultiWidget_h #define QmitkStdMultiWidget_h #include "MitkQtWidgetsExports.h" #include #include #include #include #include #include #include #include #include class QHBoxLayout; class QVBoxLayout; class QGridLayout; class QSpacerItem; class QmitkLevelWindowWidget; class QmitkRenderWindow; class vtkCornerAnnotation; class vtkMitkRectangleProp; namespace mitk { class RenderingManager; } /// \ingroup QmitkModule class MITKQTWIDGETS_EXPORT QmitkStdMultiWidget : public QWidget { Q_OBJECT public: QmitkStdMultiWidget( QWidget *parent = 0, Qt::WindowFlags f = 0, mitk::RenderingManager *renderingManager = 0, mitk::BaseRenderer::RenderingMode::Type renderingMode = mitk::BaseRenderer::RenderingMode::Standard, const QString &name = "stdmulti"); - virtual ~QmitkStdMultiWidget(); + ~QmitkStdMultiWidget() override; mitk::SliceNavigationController *GetTimeNavigationController(); void RequestUpdate(); void ForceImmediateUpdate(); mitk::MouseModeSwitcher *GetMouseModeSwitcher(); QmitkRenderWindow *GetRenderWindow1() const; QmitkRenderWindow *GetRenderWindow2() const; QmitkRenderWindow *GetRenderWindow3() const; QmitkRenderWindow *GetRenderWindow4() const; const mitk::Point3D GetCrossPosition() const; void EnablePositionTracking(); void DisablePositionTracking(); int GetLayout() const; bool GetGradientBackgroundFlag() const; /*! \brief Access node of widget plane 1 \return DataNode holding widget plane 1 */ mitk::DataNode::Pointer GetWidgetPlane1(); /*! \brief Access node of widget plane 2 \return DataNode holding widget plane 2 */ mitk::DataNode::Pointer GetWidgetPlane2(); /*! \brief Access node of widget plane 3 \return DataNode holding widget plane 3 */ mitk::DataNode::Pointer GetWidgetPlane3(); /*! \brief Convenience method to access node of widget planes \param id number of widget plane to be returned \return DataNode holding widget plane 3 */ mitk::DataNode::Pointer GetWidgetPlane(int id); bool IsColoredRectanglesEnabled() const; bool IsDepartmentLogoEnabled() const; void InitializeWidget(); /// called when the StdMultiWidget is closed to remove the 3 widget planes and the helper node from the DataStorage void RemovePlanesFromDataStorage(); void AddPlanesToDataStorage(); void SetDataStorage(mitk::DataStorage *ds); /** \brief Listener to the CrosshairPositionEvent Ensures the CrosshairPositionEvent is handled only once and at the end of the Qt-Event loop */ void HandleCrosshairPositionEvent(); /// activate Menu Widget. true: activated, false: deactivated void ActivateMenuWidget(bool state); bool IsMenuWidgetEnabled() const; void SetCornerAnnotationVisibility(bool visibility); bool IsCornerAnnotationVisible(void) const; protected: void UpdateAllWidgets(); void HideAllWidgetToolbars(); mitk::DataNode::Pointer GetTopLayerNode(mitk::DataStorage::SetOfObjects::ConstPointer nodes); public slots: /// Receives the signal from HandleCrosshairPositionEvent, executes the StatusBar update void HandleCrosshairPositionEventDelayed(); void changeLayoutTo2DImagesUp(); void changeLayoutTo2DImagesLeft(); void changeLayoutToDefault(); void changeLayoutToBig3D(); void changeLayoutToWidget1(); void changeLayoutToWidget2(); void changeLayoutToWidget3(); void changeLayoutToRowWidget3And4(); void changeLayoutToColumnWidget3And4(); void changeLayoutToRowWidgetSmall3andBig4(); void changeLayoutToSmallUpperWidget2Big3and4(); void changeLayoutTo2x2Dand3DWidget(); void changeLayoutToLeft2Dand3DRight2D(); /** Changes the layout to one 2D window up and a 3D window down. * The 2D window can be defined by its id (1-3). If MITK default * settings were not changed, 1 is axial, 2 is sagittal and 3 is coronal. */ void changeLayoutTo2DUpAnd3DDown(unsigned int id2Dwindow = 2); void Fit(); void InitPositionTracking(); void AddDisplayPlaneSubTree(); void EnableStandardLevelWindow(); void DisableStandardLevelWindow(); bool InitializeStandardViews(const mitk::Geometry3D *geometry); void wheelEvent(QWheelEvent *e) override; void mousePressEvent(QMouseEvent *e) override; void moveEvent(QMoveEvent *e) override; void EnsureDisplayContainsPoint(mitk::BaseRenderer *renderer, const mitk::Point3D &p); void MoveCrossToPosition(const mitk::Point3D &newPosition); // void EnableNavigationControllerEventListening(); // void DisableNavigationControllerEventListening(); void EnableGradientBackground(); void DisableGradientBackground(); void EnableDepartmentLogo(); void DisableDepartmentLogo(); void EnableColoredRectangles(); void DisableColoredRectangles(); void SetWidgetPlaneVisibility(const char *widgetName, bool visible, mitk::BaseRenderer *renderer = nullptr); void SetWidgetPlanesVisibility(bool visible, mitk::BaseRenderer *renderer = nullptr); void SetWidgetPlanesLocked(bool locked); void SetWidgetPlanesRotationLocked(bool locked); void SetWidgetPlanesRotationLinked(bool link); void SetWidgetPlaneMode(int mode); void SetGradientBackgroundColors(const mitk::Color &upper, const mitk::Color &lower); void SetDepartmentLogo(const char *path); void SetWidgetPlaneModeToSlicing(bool activate); void SetWidgetPlaneModeToRotation(bool activate); void SetWidgetPlaneModeToSwivel(bool activate); void OnLayoutDesignChanged(int layoutDesignIndex); void ResetCrosshair(); signals: void LeftMouseClicked(mitk::Point3D pointValue); void WheelMoved(QWheelEvent *); void WidgetPlanesRotationLinked(bool); void WidgetPlanesRotationEnabled(bool); void ViewsInitialized(); void WidgetPlaneModeSlicing(bool); void WidgetPlaneModeRotation(bool); void WidgetPlaneModeSwivel(bool); void WidgetPlaneModeChange(int); void WidgetNotifyNewCrossHairMode(int); void Moved(); public: /** Define RenderWindow (public)*/ QmitkRenderWindow *mitkWidget1; QmitkRenderWindow *mitkWidget2; QmitkRenderWindow *mitkWidget3; QmitkRenderWindow *mitkWidget4; QmitkLevelWindowWidget *levelWindowWidget; /********************************/ enum { PLANE_MODE_SLICING = 0, PLANE_MODE_ROTATION, PLANE_MODE_SWIVEL }; enum { LAYOUT_DEFAULT = 0, LAYOUT_2D_IMAGES_UP, LAYOUT_2D_IMAGES_LEFT, LAYOUT_BIG_3D, LAYOUT_WIDGET1, LAYOUT_WIDGET2, LAYOUT_WIDGET3, LAYOUT_2X_2D_AND_3D_WIDGET, LAYOUT_ROW_WIDGET_3_AND_4, LAYOUT_COLUMN_WIDGET_3_AND_4, LAYOUT_ROW_WIDGET_SMALL3_AND_BIG4, LAYOUT_SMALL_UPPER_WIDGET2_BIG3_AND4, LAYOUT_2D_AND_3D_LEFT_2D_RIGHT_WIDGET, LAYOUT_2D_UP_AND_3D_DOWN }; enum { AXIAL, SAGITTAL, CORONAL, THREE_D }; /** * @brief SetCornerAnnotation Create a corner annotation for a widget. * @param text The text of the annotation. * @param color The color. * @param widgetNumber The widget (0-3). */ void SetDecorationProperties(std::string text, mitk::Color color, int widgetNumber); /** * @brief GetRenderWindow convinience method to get a widget. * @param number of the widget (0-3) * @return The renderwindow widget. */ QmitkRenderWindow *GetRenderWindow(unsigned int number); /** * @brief SetGradientBackgroundColorForRenderWindow background for a widget. * * If two different input colors are, a gradient background is generated. * * @param upper Upper color of the gradient background. * @param lower Lower color of the gradient background. * @param widgetNumber The widget (0-3). */ void SetGradientBackgroundColorForRenderWindow(const mitk::Color &upper, const mitk::Color &lower, unsigned int widgetNumber); /** * @brief GetDecorationColorForWidget Get the color for annotation, crosshair and rectangle. * @param widgetNumber Number of the renderwindow (0-3). * @return Color in mitk format. */ mitk::Color GetDecorationColor(unsigned int widgetNumber); /** * @brief SetDecorationColor Set the color of the decoration of the 4 widgets. * * This is used to color the frame of the renderwindow and the corner annatation. * For the first 3 widgets, this color is a property of the helper object nodes * which contain the respective plane geometry. For widget 4, this is a member, * since there is no data node for this widget. */ void SetDecorationColor(unsigned int widgetNumber, mitk::Color color); /** * @brief GetCornerAnnotationText Getter for corner annotation text. * @param widgetNumber the widget number (0-3). * @return The text in the corner annotation. */ std::string GetCornerAnnotationText(unsigned int widgetNumber); /** * @brief GetGradientColors Getter for gradientbackground colors. * @param widgetNumber the widget number (0-3). * @return A pair of colors. First: upper, second: lower. */ std::pair GetGradientColors(unsigned int widgetNumber); protected: QHBoxLayout *QmitkStdMultiWidgetLayout; int m_Layout; int m_PlaneMode; mitk::RenderingManager *m_RenderingManager; mitk::LogoAnnotation::Pointer m_LogoRendering; bool m_GradientBackgroundFlag; mitk::MouseModeSwitcher::Pointer m_MouseModeSwitcher; mitk::SliceNavigationController *m_TimeNavigationController; mitk::DataStorage::Pointer m_DataStorage; /** * @brief m_PlaneNode1 the 3 helper objects which contain the plane geometry. */ mitk::DataNode::Pointer m_PlaneNode1; mitk::DataNode::Pointer m_PlaneNode2; mitk::DataNode::Pointer m_PlaneNode3; /** * @brief m_ParentNodeForGeometryPlanes This helper object is added to the datastorage * and contains the 3 planes for displaying the image geometry (crosshair and 3D planes). */ mitk::DataNode::Pointer m_ParentNodeForGeometryPlanes; /** * @brief m_DecorationColorWidget4 color for annotation and rectangle of widget 4. * * For other widgets1-3, the color is a property of the respective data node. * There is no node for widget 4, hence, we need an extra member. */ mitk::Color m_DecorationColorWidget4; /** * @brief m_GradientBackgroundColors Contains the colors of the gradient background. * */ std::pair m_GradientBackgroundColors[4]; QSplitter *m_MainSplit; QSplitter *m_LayoutSplit; QSplitter *m_SubSplit1; QSplitter *m_SubSplit2; QWidget *mitkWidget1Container; QWidget *mitkWidget2Container; QWidget *mitkWidget3Container; QWidget *mitkWidget4Container; vtkSmartPointer m_CornerAnnotations[4]; vtkSmartPointer m_RectangleProps[4]; bool m_PendingCrosshairPositionEvent; bool m_CrosshairNavigationEnabled; /** * @brief CreateCornerAnnotation helper method to create a corner annotation. * @param text of the annotation. * @param color of the annotation. * @return the complete CornerAnnotation. */ vtkSmartPointer CreateCornerAnnotation(std::string text, mitk::Color color); /** * @brief FillGradientBackgroundWithBlack Internal helper method to initialize the * gradient background colors with black. */ void FillGradientBackgroundWithBlack(); }; #endif /*QmitkStdMultiWidget_h*/ diff --git a/Modules/QtWidgets/src/QmitkIOUtil.cpp b/Modules/QtWidgets/src/QmitkIOUtil.cpp index addec7b86a..f1605cb962 100644 --- a/Modules/QtWidgets/src/QmitkIOUtil.cpp +++ b/Modules/QtWidgets/src/QmitkIOUtil.cpp @@ -1,540 +1,540 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "QmitkIOUtil.h" #include "mitkCoreServices.h" #include "mitkCustomMimeType.h" #include "mitkFileReaderRegistry.h" #include "mitkFileWriterRegistry.h" #include "mitkIMimeTypeProvider.h" #include "mitkMimeType.h" #include #include #include "QmitkFileReaderOptionsDialog.h" #include "QmitkFileWriterOptionsDialog.h" // QT #include #include #include #include // ITK #include #include struct QmitkIOUtil::Impl { struct ReaderOptionsDialogFunctor : public ReaderOptionsFunctorBase { - virtual bool operator()(LoadInfo &loadInfo) const override + bool operator()(LoadInfo &loadInfo) const override { QmitkFileReaderOptionsDialog dialog(loadInfo); if (dialog.exec() == QDialog::Accepted) { return !dialog.ReuseOptions(); } else { loadInfo.m_Cancel = true; return true; } } }; struct WriterOptionsDialogFunctor : public WriterOptionsFunctorBase { - virtual bool operator()(SaveInfo &saveInfo) const override + bool operator()(SaveInfo &saveInfo) const override { QmitkFileWriterOptionsDialog dialog(saveInfo); if (dialog.exec() == QDialog::Accepted) { return !dialog.ReuseOptions(); } else { saveInfo.m_Cancel = true; return true; } } }; }; struct MimeTypeComparison : public std::unary_function { MimeTypeComparison(const std::string &mimeTypeName) : m_Name(mimeTypeName) {} bool operator()(const mitk::MimeType &mimeType) const { return mimeType.GetName() == m_Name; } const std::string m_Name; }; QString QmitkIOUtil::GetFileOpenFilterString() { QString filters; mitk::CoreServicePointer mimeTypeProvider(mitk::CoreServices::GetMimeTypeProvider()); std::vector categories = mimeTypeProvider->GetCategories(); for (std::vector::iterator cat = categories.begin(); cat != categories.end(); ++cat) { QSet filterExtensions; std::vector mimeTypes = mimeTypeProvider->GetMimeTypesForCategory(*cat); for (std::vector::iterator mt = mimeTypes.begin(); mt != mimeTypes.end(); ++mt) { std::vector extensions = mt->GetExtensions(); for (std::vector::iterator ext = extensions.begin(); ext != extensions.end(); ++ext) { filterExtensions << QString::fromStdString(*ext); } } QString filter = QString::fromStdString(*cat) + " ("; foreach (const QString &extension, filterExtensions) { filter += "*." + extension + " "; } filter = filter.replace(filter.size() - 1, 1, ')'); filters += ";;" + filter; } filters.prepend("All (*)"); return filters; } QList QmitkIOUtil::Load(const QStringList &paths, QWidget *parent) { std::vector loadInfos; foreach (const QString &file, paths) { loadInfos.push_back(LoadInfo(file.toLocal8Bit().constData())); } Impl::ReaderOptionsDialogFunctor optionsCallback; std::string errMsg = Load(loadInfos, nullptr, nullptr, &optionsCallback); if (!errMsg.empty()) { QMessageBox::warning(parent, "Error reading files", QString::fromStdString(errMsg)); mitkThrow() << errMsg; } QList qResult; for (std::vector::const_iterator iter = loadInfos.begin(), iterEnd = loadInfos.end(); iter != iterEnd; ++iter) { for (const auto &elem : iter->m_Output) { qResult << elem; } } return qResult; } mitk::DataStorage::SetOfObjects::Pointer QmitkIOUtil::Load(const QStringList &paths, mitk::DataStorage &storage, QWidget *parent) { std::vector loadInfos; foreach (const QString &file, paths) { loadInfos.push_back(LoadInfo(file.toLocal8Bit().constData())); } mitk::DataStorage::SetOfObjects::Pointer nodeResult = mitk::DataStorage::SetOfObjects::New(); Impl::ReaderOptionsDialogFunctor optionsCallback; std::string errMsg = Load(loadInfos, nodeResult, &storage, &optionsCallback); if (!errMsg.empty()) { QMessageBox::warning(parent, "Error reading files", QString::fromStdString(errMsg)); } return nodeResult; } QList QmitkIOUtil::Load(const QString &path, QWidget *parent) { QStringList paths; paths << path; return Load(paths, parent); } mitk::DataStorage::SetOfObjects::Pointer QmitkIOUtil::Load(const QString &path, mitk::DataStorage &storage, QWidget *parent) { QStringList paths; paths << path; return Load(paths, storage, parent); } QString QmitkIOUtil::Save(const mitk::BaseData *data, const QString &defaultBaseName, const QString &defaultPath, QWidget *parent) { std::vector dataVector; dataVector.push_back(data); QStringList defaultBaseNames; defaultBaseNames.push_back(defaultBaseName); return Save(dataVector, defaultBaseNames, defaultPath, parent).back(); } QStringList QmitkIOUtil::Save(const std::vector &data, const QStringList &defaultBaseNames, const QString &defaultPath, QWidget *parent) { QStringList fileNames; QString currentPath = defaultPath; std::vector saveInfos; int counter = 0; for (std::vector::const_iterator dataIter = data.begin(), dataIterEnd = data.end(); dataIter != dataIterEnd; ++dataIter, ++counter) { SaveInfo saveInfo(*dataIter, mitk::MimeType(), std::string()); SaveFilter filters(saveInfo); // If there is only the "__all__" filter string, it means there is no writer for this base data if (filters.Size() < 2) { QMessageBox::warning( parent, "Saving not possible", QString("No writer available for type \"%1\"").arg(QString::fromStdString((*dataIter)->GetNameOfClass()))); continue; } // Construct a default path and file name QString filterString = filters.ToString(); QString selectedFilter = filters.GetDefaultFilter(); QString fileName = currentPath; QString dialogTitle = "Save " + QString::fromStdString((*dataIter)->GetNameOfClass()); if (counter < defaultBaseNames.size()) { dialogTitle += " \"" + defaultBaseNames[counter] + "\""; fileName += QDir::separator() + defaultBaseNames[counter]; // We do not append an extension to the file name by default. The extension // is chosen by the user by either selecting a filter or writing the // extension in the file name himself (in the file save dialog). /* QString defaultExt = filters.GetDefaultExtension(); if (!defaultExt.isEmpty()) { fileName += "." + defaultExt; } */ } // Ask the user for a file name QString nextName = QFileDialog::getSaveFileName(parent, dialogTitle, fileName, filterString, &selectedFilter); if (nextName.isEmpty()) { // We stop asking for further file names, but we still save the // data where the user already confirmed the save dialog. break; } fileName = nextName; std::string stdFileName = fileName.toLocal8Bit().constData(); QFileInfo fileInfo(fileName); currentPath = fileInfo.absolutePath(); QString suffix = fileInfo.completeSuffix(); mitk::MimeType filterMimeType = filters.GetMimeTypeForFilter(selectedFilter); mitk::MimeType selectedMimeType; if (fileInfo.exists() && !fileInfo.isFile()) { QMessageBox::warning(parent, "Saving not possible", QString("The path \"%1\" is not a file").arg(fileName)); continue; } // Theoretically, the user could have entered an extension that does not match the selected filter // The extension then has prioritry over the filter // Check if one of the available mime-types match the filename std::vector filterMimeTypes = filters.GetMimeTypes(); for (std::vector::const_iterator mimeTypeIter = filterMimeTypes.begin(), mimeTypeIterEnd = filterMimeTypes.end(); mimeTypeIter != mimeTypeIterEnd; ++mimeTypeIter) { if (mimeTypeIter->MatchesExtension(stdFileName)) { selectedMimeType = *mimeTypeIter; break; } } if (!selectedMimeType.IsValid()) { // The file name either does not contain an extension or the // extension is unknown. // If the file already exists, we stop here because we are unable // to (over)write the file without adding a custom suffix. If the file // does not exist, we add the default extension from the currently // selected filter. If the "All" filter was selected, we only add the // default extensions if the file name itself does not already contain // an extension. if (!fileInfo.exists()) { if (filterMimeType == SaveFilter::ALL_MIMETYPE()) { if (suffix.isEmpty()) { // Use the highest ranked mime-type from the list selectedMimeType = filters.GetDefaultMimeType(); } } else { selectedMimeType = filterMimeType; } if (selectedMimeType.IsValid()) { suffix = QString::fromStdString(selectedMimeType.GetExtensions().front()); fileName += "." + suffix; stdFileName = fileName.toLocal8Bit().constData(); // We changed the file name (added a suffix) so ask in case // the file aready exists. fileInfo = QFileInfo(fileName); if (fileInfo.exists()) { if (!fileInfo.isFile()) { QMessageBox::warning( parent, "Saving not possible", QString("The path \"%1\" is not a file").arg(fileName)); continue; } if (QMessageBox::question( parent, "Replace File", QString("A file named \"%1\" already exists. Do you want to replace it?").arg(fileName)) == QMessageBox::No) { continue; } } } } } if (!selectedMimeType.IsValid()) { // The extension/filename is not valid (no mime-type found), bail out QMessageBox::warning( parent, "Saving not possible", QString("No mime-type available which can handle \"%1\".").arg(fileName)); continue; } if (!QFileInfo(fileInfo.absolutePath()).isWritable()) { QMessageBox::warning(parent, "Saving not possible", QString("The path \"%1\" is not writable").arg(fileName)); continue; } fileNames.push_back(fileName); saveInfo.m_Path = stdFileName; saveInfo.m_MimeType = selectedMimeType; // pre-select the best writer for the chosen mime-type saveInfo.m_WriterSelector.Select(selectedMimeType.GetName()); saveInfos.push_back(saveInfo); } if (!saveInfos.empty()) { Impl::WriterOptionsDialogFunctor optionsCallback; std::string errMsg = Save(saveInfos, &optionsCallback); if (!errMsg.empty()) { QMessageBox::warning(parent, "Error writing files", QString::fromStdString(errMsg)); mitkThrow() << errMsg; } } return fileNames; } void QmitkIOUtil::SaveBaseDataWithDialog(mitk::BaseData *data, std::string fileName, QWidget * /*parent*/) { Save(data, fileName); } void QmitkIOUtil::SaveSurfaceWithDialog(mitk::Surface::Pointer surface, std::string fileName, QWidget * /*parent*/) { Save(surface, fileName); } void QmitkIOUtil::SaveImageWithDialog(mitk::Image::Pointer image, std::string fileName, QWidget * /*parent*/) { Save(image, fileName); } void QmitkIOUtil::SavePointSetWithDialog(mitk::PointSet::Pointer pointset, std::string fileName, QWidget * /*parent*/) { Save(pointset, fileName); } struct QmitkIOUtil::SaveFilter::Impl { Impl(const mitk::IOUtil::SaveInfo &saveInfo) : m_SaveInfo(saveInfo) { // Add an artifical filter for "All" m_MimeTypes.push_back(ALL_MIMETYPE()); m_FilterStrings.push_back("All (*.*)"); // Get all writers and their mime types for the given base data type // (this is sorted already) std::vector mimeTypes = saveInfo.m_WriterSelector.GetMimeTypes(); for (std::vector::const_reverse_iterator iter = mimeTypes.rbegin(), iterEnd = mimeTypes.rend(); iter != iterEnd; ++iter) { QList filterExtensions; mitk::MimeType mimeType = *iter; std::vector extensions = mimeType.GetExtensions(); for (auto &extension : extensions) { filterExtensions << QString::fromStdString(extension); } if (m_DefaultExtension.isEmpty()) { m_DefaultExtension = QString::fromStdString(extensions.front()); } QString filter = QString::fromStdString(mimeType.GetComment()) + " ("; foreach (const QString &extension, filterExtensions) { filter += "*." + extension + " "; } filter = filter.replace(filter.size() - 1, 1, ')'); m_MimeTypes.push_back(mimeType); m_FilterStrings.push_back(filter); } } const mitk::IOUtil::SaveInfo m_SaveInfo; std::vector m_MimeTypes; QStringList m_FilterStrings; QString m_DefaultExtension; }; mitk::MimeType QmitkIOUtil::SaveFilter::ALL_MIMETYPE() { static mitk::CustomMimeType allMimeType(std::string("__all__")); return mitk::MimeType(allMimeType, -1, -1); } QmitkIOUtil::SaveFilter::SaveFilter(const QmitkIOUtil::SaveFilter &other) : d(new Impl(*other.d)) { } QmitkIOUtil::SaveFilter::SaveFilter(const SaveInfo &saveInfo) : d(new Impl(saveInfo)) { } QmitkIOUtil::SaveFilter &QmitkIOUtil::SaveFilter::operator=(const QmitkIOUtil::SaveFilter &other) { d.reset(new Impl(*other.d)); return *this; } std::vector QmitkIOUtil::SaveFilter::GetMimeTypes() const { return d->m_MimeTypes; } QString QmitkIOUtil::SaveFilter::GetFilterForMimeType(const std::string &mimeType) const { std::vector::const_iterator iter = std::find_if(d->m_MimeTypes.begin(), d->m_MimeTypes.end(), MimeTypeComparison(mimeType)); if (iter == d->m_MimeTypes.end()) { return QString(); } int index = static_cast(iter - d->m_MimeTypes.begin()); if (index < 0 || index >= d->m_FilterStrings.size()) { return QString(); } return d->m_FilterStrings[index]; } mitk::MimeType QmitkIOUtil::SaveFilter::GetMimeTypeForFilter(const QString &filter) const { int index = d->m_FilterStrings.indexOf(filter); if (index < 0) { return mitk::MimeType(); } return d->m_MimeTypes[index]; } QString QmitkIOUtil::SaveFilter::GetDefaultFilter() const { if (d->m_FilterStrings.size() > 1) { return d->m_FilterStrings.at(1); } else if (d->m_FilterStrings.size() > 0) { return d->m_FilterStrings.front(); } return QString(); } QString QmitkIOUtil::SaveFilter::GetDefaultExtension() const { return d->m_DefaultExtension; } mitk::MimeType QmitkIOUtil::SaveFilter::GetDefaultMimeType() const { if (d->m_MimeTypes.size() > 1) { return d->m_MimeTypes.at(1); } else if (d->m_MimeTypes.size() > 0) { return d->m_MimeTypes.front(); } return mitk::MimeType(); } QString QmitkIOUtil::SaveFilter::ToString() const { return d->m_FilterStrings.join(";;"); } int QmitkIOUtil::SaveFilter::Size() const { return d->m_FilterStrings.size(); } bool QmitkIOUtil::SaveFilter::IsEmpty() const { return d->m_FilterStrings.isEmpty(); } bool QmitkIOUtil::SaveFilter::ContainsMimeType(const std::string &mimeType) { return std::find_if(d->m_MimeTypes.begin(), d->m_MimeTypes.end(), MimeTypeComparison(mimeType)) != d->m_MimeTypes.end(); } diff --git a/Modules/QtWidgetsExt/include/QmitkAboutDialog.h b/Modules/QtWidgetsExt/include/QmitkAboutDialog.h index b28a0de264..d73ebdb0dd 100644 --- a/Modules/QtWidgetsExt/include/QmitkAboutDialog.h +++ b/Modules/QtWidgetsExt/include/QmitkAboutDialog.h @@ -1,46 +1,46 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QmitkAboutDialog_h #define QmitkAboutDialog_h #include "MitkQtWidgetsExtExports.h" #include class MITKQTWIDGETSEXT_EXPORT QmitkAboutDialog : public QDialog { Q_OBJECT public: QmitkAboutDialog(QWidget *parent = nullptr, Qt::WindowFlags f = Qt::CustomizeWindowHint | Qt::WindowCloseButtonHint); - virtual ~QmitkAboutDialog(); + ~QmitkAboutDialog() override; QString GetAboutText() const; QString GetCaptionText() const; QString GetRevisionText() const; void SetAboutText(const QString &text); void SetCaptionText(const QString &text); void SetRevisionText(const QString &text); protected slots: void ShowModules(); private: Ui::QmitkAboutDialog m_GUI; }; #endif diff --git a/Modules/QtWidgetsExt/include/QmitkBasePropertyView.h b/Modules/QtWidgetsExt/include/QmitkBasePropertyView.h index c4d721b798..cfc6d346a4 100644 --- a/Modules/QtWidgetsExt/include/QmitkBasePropertyView.h +++ b/Modules/QtWidgetsExt/include/QmitkBasePropertyView.h @@ -1,40 +1,40 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QMITK_BASEPROPERTYVIEW_H_INCLUDED #define QMITK_BASEPROPERTYVIEW_H_INCLUDED #include "MitkQtWidgetsExtExports.h" #include #include #include /// @ingroup Widgets class MITKQTWIDGETSEXT_EXPORT QmitkBasePropertyView : public QLabel, public mitk::PropertyView { Q_OBJECT public: QmitkBasePropertyView(const mitk::BaseProperty *, QWidget *parent); - virtual ~QmitkBasePropertyView(); + ~QmitkBasePropertyView() override; protected: - virtual void PropertyChanged() override; - virtual void PropertyRemoved() override; + void PropertyChanged() override; + void PropertyRemoved() override; private: }; #endif diff --git a/Modules/QtWidgetsExt/include/QmitkBoolPropertyWidget.h b/Modules/QtWidgetsExt/include/QmitkBoolPropertyWidget.h index 60dfcf5645..138c5aa134 100644 --- a/Modules/QtWidgetsExt/include/QmitkBoolPropertyWidget.h +++ b/Modules/QtWidgetsExt/include/QmitkBoolPropertyWidget.h @@ -1,45 +1,45 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QMITK_BOOLPROPERTYVIEW_H_INCLUDED #define QMITK_BOOLPROPERTYVIEW_H_INCLUDED #include "MitkQtWidgetsExtExports.h" #include #include class _BoolPropertyWidgetImpl; /// @ingroup Widgets class MITKQTWIDGETSEXT_EXPORT QmitkBoolPropertyWidget : public QCheckBox { Q_OBJECT public: QmitkBoolPropertyWidget(QWidget *parent = nullptr); QmitkBoolPropertyWidget(const QString &text, QWidget *parent = nullptr); - virtual ~QmitkBoolPropertyWidget(); + ~QmitkBoolPropertyWidget() override; void SetProperty(mitk::BoolProperty *property); protected slots: void onToggle(bool on); protected: _BoolPropertyWidgetImpl *m_PropEditorImpl; }; #endif diff --git a/Modules/QtWidgetsExt/include/QmitkBoundingObjectWidget.h b/Modules/QtWidgetsExt/include/QmitkBoundingObjectWidget.h index b85ab815e4..5899010d98 100644 --- a/Modules/QtWidgetsExt/include/QmitkBoundingObjectWidget.h +++ b/Modules/QtWidgetsExt/include/QmitkBoundingObjectWidget.h @@ -1,89 +1,89 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef _QMITKBOUNDINGOBJECTWIDGET_H_INCLUDED #define _QMITKBOUNDINGOBJECTWIDGET_H_INCLUDED // includes #include "MitkQtWidgetsExtExports.h" #include #include #include #include #include #include #include #include class MITKQTWIDGETSEXT_EXPORT QmitkBoundingObjectWidget : public QWidget { Q_OBJECT public: QmitkBoundingObjectWidget(QWidget *parent = 0, Qt::WindowFlags f = 0); - ~QmitkBoundingObjectWidget(); + ~QmitkBoundingObjectWidget() override; void SetDataStorage(mitk::DataStorage *dataStorage); mitk::DataStorage *GetDataStorage(); mitk::BoundingObject::Pointer GetSelectedBoundingObject(); mitk::DataNode::Pointer GetSelectedBoundingObjectNode(); mitk::DataNode::Pointer GetAllBoundingObjects(); void setEnabled(bool flag); void OnBoundingObjectModified(const itk::EventObject &e); void RemoveAllItems(); signals: // signal when bo has changed void BoundingObjectsChanged(); protected slots: void CreateBoundingObject(int type); void OnDelButtonClicked(); void SelectionChanged(); void OnItemDoubleClicked(QTreeWidgetItem *item, int col); void OnItemDataChanged(QTreeWidgetItem *item, int col); protected: void AddItem(mitk::DataNode *node); void RemoveItem(); mitk::DataStorage *m_DataStorage; QTreeWidget *m_TreeWidget; QComboBox *m_addComboBox; QPushButton *m_DelButton; QPushButton *m_SaveButton; QPushButton *m_LoadButton; QTreeWidgetItem *m_lastSelectedItem; unsigned long m_lastAffineObserver; typedef std::map ItemNodeMapType; ItemNodeMapType m_ItemNodeMap; unsigned int m_BoundingObjectCounter; enum BoundingObjectType { CUBOID, CONE, ELLIPSOID, CYLINDER, }; }; #endif diff --git a/Modules/QtWidgetsExt/include/QmitkCallbackFromGUIThread.h b/Modules/QtWidgetsExt/include/QmitkCallbackFromGUIThread.h index f1b12d5b19..f149380854 100644 --- a/Modules/QtWidgetsExt/include/QmitkCallbackFromGUIThread.h +++ b/Modules/QtWidgetsExt/include/QmitkCallbackFromGUIThread.h @@ -1,46 +1,46 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QMITK_CALLBACK_WITHIN_GUI_TREAD_H_INCLUDGEWQ #define QMITK_CALLBACK_WITHIN_GUI_TREAD_H_INCLUDGEWQ #include "MitkQtWidgetsExtExports.h" #include "mitkCallbackFromGUIThread.h" #include /*! \brief Qt specific implementation of mitk::CallbackFromGUIThreadImplementation */ class MITKQTWIDGETSEXT_EXPORT QmitkCallbackFromGUIThread : public QObject, public mitk::CallbackFromGUIThreadImplementation { Q_OBJECT public: /// Change the current application cursor - virtual void CallThisFromGUIThread(itk::Command *, itk::EventObject *) override; + void CallThisFromGUIThread(itk::Command *, itk::EventObject *) override; QmitkCallbackFromGUIThread(); - virtual ~QmitkCallbackFromGUIThread(); + ~QmitkCallbackFromGUIThread() override; - virtual bool event(QEvent *e) override; + bool event(QEvent *e) override; protected: private: }; #endif diff --git a/Modules/QtWidgetsExt/include/QmitkColorPropertyEditor.h b/Modules/QtWidgetsExt/include/QmitkColorPropertyEditor.h index 348574c08d..f15bc9df52 100644 --- a/Modules/QtWidgetsExt/include/QmitkColorPropertyEditor.h +++ b/Modules/QtWidgetsExt/include/QmitkColorPropertyEditor.h @@ -1,94 +1,94 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QMITK_COLORPROPERTYEDITOR_H_INCLUDED #define QMITK_COLORPROPERTYEDITOR_H_INCLUDED #include "MitkQtWidgetsExtExports.h" #include "QmitkColorPropertyView.h" #include #include class QListBox; /// @ingroup Widgets class MITKQTWIDGETSEXT_EXPORT QmitkPopupColorChooser : public QFrame { Q_OBJECT public: QmitkPopupColorChooser(QWidget *parent = nullptr, unsigned int steps = 16, unsigned int size = 150); - virtual ~QmitkPopupColorChooser(); + ~QmitkPopupColorChooser() override; void setSteps(int); virtual void popup(QWidget *parent, const QPoint &point, const mitk::Color * = nullptr); /// Call to popup this widget. parent determines popup position signals: void colorSelected(QColor); protected: - virtual void keyReleaseEvent(QKeyEvent *) override; + void keyReleaseEvent(QKeyEvent *) override; - virtual void mouseMoveEvent(QMouseEvent *) override; - virtual void mouseReleaseEvent(QMouseEvent *) override; - virtual void closeEvent(QCloseEvent *) override; + void mouseMoveEvent(QMouseEvent *) override; + void mouseReleaseEvent(QMouseEvent *) override; + void closeEvent(QCloseEvent *) override; - virtual void paintEvent(QPaintEvent *) override; + void paintEvent(QPaintEvent *) override; void drawGradient(QPainter *p); private: QWidget *m_popupParent; QWidget *my_parent; unsigned int m_Steps; unsigned int m_Steps2; unsigned int m_HStep; unsigned int m_SStep; unsigned int m_VStep; int m_H; int m_S; int m_V; QColor m_OriginalColor; }; /// @ingroup Widgets class MITKQTWIDGETSEXT_EXPORT QmitkColorPropertyEditor : public QmitkColorPropertyView { Q_OBJECT public: QmitkColorPropertyEditor(const mitk::ColorProperty *, QWidget *parent); - virtual ~QmitkColorPropertyEditor(); + ~QmitkColorPropertyEditor() override; protected: - virtual void mousePressEvent(QMouseEvent *) override; - virtual void mouseReleaseEvent(QMouseEvent *) override; + void mousePressEvent(QMouseEvent *) override; + void mouseReleaseEvent(QMouseEvent *) override; static QmitkPopupColorChooser *colorChooser; static int colorChooserRefCount; protected slots: void onColorSelected(QColor); private: }; #endif diff --git a/Modules/QtWidgetsExt/include/QmitkColorPropertyView.h b/Modules/QtWidgetsExt/include/QmitkColorPropertyView.h index 2cb2db03ec..ee57368489 100644 --- a/Modules/QtWidgetsExt/include/QmitkColorPropertyView.h +++ b/Modules/QtWidgetsExt/include/QmitkColorPropertyView.h @@ -1,44 +1,44 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QMITK_COLORPROPERTYVIEW_H_INCLUDED #define QMITK_COLORPROPERTYVIEW_H_INCLUDED #include "MitkQtWidgetsExtExports.h" #include #include #include /// @ingroup Widgets class MITKQTWIDGETSEXT_EXPORT QmitkColorPropertyView : public QLabel, public mitk::PropertyView { Q_OBJECT public: QmitkColorPropertyView(const mitk::ColorProperty *, QWidget *parent); - virtual ~QmitkColorPropertyView(); + ~QmitkColorPropertyView() override; protected: - virtual void PropertyChanged() override; - virtual void PropertyRemoved() override; + void PropertyChanged() override; + void PropertyRemoved() override; void DisplayColor(); const mitk::ColorProperty *m_ColorProperty; QPalette m_WidgetPalette; }; #endif diff --git a/Modules/QtWidgetsExt/include/QmitkColorTransferFunctionCanvas.h b/Modules/QtWidgetsExt/include/QmitkColorTransferFunctionCanvas.h index 2e50d59b6e..2c93615435 100755 --- a/Modules/QtWidgetsExt/include/QmitkColorTransferFunctionCanvas.h +++ b/Modules/QtWidgetsExt/include/QmitkColorTransferFunctionCanvas.h @@ -1,98 +1,98 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QMITKCOLORTRANSFERFUNCTIONCANVAS_H_INCLUDED #define QMITKCOLORTRANSFERFUNCTIONCANVAS_H_INCLUDED #include "MitkQtWidgetsExtExports.h" #include "QmitkTransferFunctionCanvas.h" #include class MITKQTWIDGETSEXT_EXPORT QmitkColorTransferFunctionCanvas : public QmitkTransferFunctionCanvas { Q_OBJECT public: QmitkColorTransferFunctionCanvas(QWidget *parent = nullptr, Qt::WindowFlags f = nullptr); - virtual void paintEvent(QPaintEvent *e) override; + void paintEvent(QPaintEvent *e) override; int GetNearHandle(int x, int y, unsigned int maxSquaredDistance = 32) override; void SetTitle(const QString &title); void SetColorTransferFunction(vtkColorTransferFunction *colorTransferFunction) { this->m_ColorTransferFunction = colorTransferFunction; this->SetMin(colorTransferFunction->GetRange()[0]); this->SetMax(colorTransferFunction->GetRange()[1]); setEnabled(true); update(); } int AddFunctionPoint(double x, double) override { return m_ColorTransferFunction->AddRGBPoint(x, m_ColorTransferFunction->GetRedValue(x), m_ColorTransferFunction->GetGreenValue(x), m_ColorTransferFunction->GetBlueValue(x)); } void RemoveFunctionPoint(double x) override { int old_size = GetFunctionSize(); m_ColorTransferFunction->RemovePoint(x); if (GetFunctionSize() + 1 != old_size) { std::cout << "old/new size" << old_size << "/" << GetFunctionSize() << std::endl; std::cout << "called with x=" << x << std::endl; } } double GetFunctionX(int index) override { return m_ColorTransferFunction->GetDataPointer()[index * 4]; } int GetFunctionSize() override { return m_ColorTransferFunction->GetSize(); } void DoubleClickOnHandle(int handle) override; void MoveFunctionPoint(int index, std::pair pos) override; void AddRGB(double x, double r, double g, double b); double GetFunctionMax() { return m_ColorTransferFunction->GetRange()[1]; } double GetFunctionMin() { return m_ColorTransferFunction->GetRange()[0]; } double GetFunctionRange() { double range; if ((m_ColorTransferFunction->GetRange()[0]) == 0) { range = m_ColorTransferFunction->GetRange()[1]; return range; } else { range = (m_ColorTransferFunction->GetRange()[1]) - (m_ColorTransferFunction->GetRange()[0]); return range; } } void RemoveAllFunctionPoints() { m_ColorTransferFunction->AddRGBSegment(this->GetFunctionMin(), 1, 0, 0, this->GetFunctionMax(), 1, 1, 0); } double GetFunctionY(int) override { return 0.0; } protected: vtkColorTransferFunction *m_ColorTransferFunction; QString m_Title; }; #endif diff --git a/Modules/QtWidgetsExt/include/QmitkEditPointDialog.h b/Modules/QtWidgetsExt/include/QmitkEditPointDialog.h index 22f3f4fbe8..33588ebddf 100644 --- a/Modules/QtWidgetsExt/include/QmitkEditPointDialog.h +++ b/Modules/QtWidgetsExt/include/QmitkEditPointDialog.h @@ -1,48 +1,48 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QmitkEditPointDialog_h #define QmitkEditPointDialog_h #include "MitkQtWidgetsExtExports.h" #include #include struct QmitkEditPointDialogData; /*! * \brief A dialog for editing points directly (coordinates) via TextEdits * */ class MITKQTWIDGETSEXT_EXPORT QmitkEditPointDialog : public QDialog { Q_OBJECT public: QmitkEditPointDialog(QWidget *parent = nullptr, Qt::WindowFlags f = nullptr); - virtual ~QmitkEditPointDialog(); + ~QmitkEditPointDialog() override; void SetPoint(mitk::PointSet *_PointSet, mitk::PointSet::PointIdentifier _PointId, int timestep = 0); protected slots: void OnOkButtonClicked(bool); protected: QmitkEditPointDialogData *d; }; #endif diff --git a/Modules/QtWidgetsExt/include/QmitkEnumerationPropertyWidget.h b/Modules/QtWidgetsExt/include/QmitkEnumerationPropertyWidget.h index 7294b4af21..a03fb70ac1 100644 --- a/Modules/QtWidgetsExt/include/QmitkEnumerationPropertyWidget.h +++ b/Modules/QtWidgetsExt/include/QmitkEnumerationPropertyWidget.h @@ -1,51 +1,51 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QMITK_ENUMERATIONPROPERTYWIDGET_H_INCLUDED #define QMITK_ENUMERATIONPROPERTYWIDGET_H_INCLUDED #include "MitkQtWidgetsExtExports.h" #include #include namespace mitk { class EnumerationProperty; } class _EnumPropEditorImpl; /// @ingroup Widgets class MITKQTWIDGETSEXT_EXPORT QmitkEnumerationPropertyWidget : public QComboBox { Q_OBJECT public: QmitkEnumerationPropertyWidget(QWidget *parent = nullptr); - ~QmitkEnumerationPropertyWidget(); + ~QmitkEnumerationPropertyWidget() override; void SetProperty(mitk::EnumerationProperty *property); protected slots: void OnIndexChanged(int index); protected: _EnumPropEditorImpl *propView; }; #endif diff --git a/Modules/QtWidgetsExt/include/QmitkFFmpegWriter.h b/Modules/QtWidgetsExt/include/QmitkFFmpegWriter.h index 9cf2d28929..34f531f64f 100644 --- a/Modules/QtWidgetsExt/include/QmitkFFmpegWriter.h +++ b/Modules/QtWidgetsExt/include/QmitkFFmpegWriter.h @@ -1,64 +1,64 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QmitkFFmpegWriter_h #define QmitkFFmpegWriter_h #include #include #include "MitkQtWidgetsExtExports.h" class MITKQTWIDGETSEXT_EXPORT QmitkFFmpegWriter : public QObject { Q_OBJECT public: explicit QmitkFFmpegWriter(QObject *parent = nullptr); - ~QmitkFFmpegWriter(); + ~QmitkFFmpegWriter() override; QString GetFFmpegPath() const; void SetFFmpegPath(const QString &path); QSize GetSize() const; void SetSize(const QSize &size); void SetSize(int width, int height); int GetFramerate() const; void SetFramerate(int framerate); QString GetOutputPath() const; void SetOutputPath(const QString &path); void Start(); bool IsRunning() const; void WriteFrame(const unsigned char *frame); void Stop(); private slots: void OnProcessError(QProcess::ProcessError error); void OnProcessFinished(int exitCode, QProcess::ExitStatus exitStatus); private: QProcess *m_Process; QString m_FFmpegPath; QSize m_Size; int m_Framerate; QString m_OutputPath; bool m_IsRunning; }; #endif diff --git a/Modules/QtWidgetsExt/include/QmitkGnuplotWidget.h b/Modules/QtWidgetsExt/include/QmitkGnuplotWidget.h index 2406816580..e05ec284c2 100644 --- a/Modules/QtWidgetsExt/include/QmitkGnuplotWidget.h +++ b/Modules/QtWidgetsExt/include/QmitkGnuplotWidget.h @@ -1,78 +1,78 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QmitkGnuplotWidget_h #define QmitkGnuplotWidget_h #include #include #include #include #include class QAction; class QMenu; namespace Ui { class QmitkGnuplotWidget; } class MITKQTWIDGETSEXT_EXPORT QmitkGnuplotWidget : public QWidget { Q_OBJECT public: explicit QmitkGnuplotWidget(QWidget *parent = nullptr); - ~QmitkGnuplotWidget(); + ~QmitkGnuplotWidget() override; QString GetGnuplotPath() const; void SetGnuplotPath(const QString &path); QStringList GetCommands() const; void SetCommands(const QStringList &commands); void Update(); QSize sizeHint() const override; protected: void contextMenuEvent(QContextMenuEvent *event) override; void resizeEvent(QResizeEvent *event) override; private slots: void OnProcessStateChanged(QProcess::ProcessState state); void OnProcessError(QProcess::ProcessError error); void OnProcessFinished(int exitCode, QProcess::ExitStatus exitStatus); void OnCopyPlot(); void OnCopyScript(); private: void CreateContextMenu(); QString CreateSetTermCommand() const; QScopedPointer m_Ui; QMenu *m_ContextMenu; QAction *m_CopyPlotAction; QAction *m_CopyScriptAction; QProcess *m_Process; QString m_GnuplotPath; QStringList m_Commands; itk::TimeStamp m_ModifiedTime; itk::TimeStamp m_UpdateTime; }; #endif diff --git a/Modules/QtWidgetsExt/include/QmitkHotkeyLineEdit.h b/Modules/QtWidgetsExt/include/QmitkHotkeyLineEdit.h index 95d9db3691..fc27f4cfdb 100644 --- a/Modules/QtWidgetsExt/include/QmitkHotkeyLineEdit.h +++ b/Modules/QtWidgetsExt/include/QmitkHotkeyLineEdit.h @@ -1,52 +1,52 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QMITKHOTKEYLINEEDIT_H_ #define QMITKHOTKEYLINEEDIT_H_ #include #include #include "MitkQtWidgetsExtExports.h" class MITKQTWIDGETSEXT_EXPORT QmitkHotkeyLineEdit : public QLineEdit { Q_OBJECT public: static const std::string TOOLTIP; QmitkHotkeyLineEdit(QWidget *parent = nullptr); QmitkHotkeyLineEdit(const QKeySequence &_QKeySequence, QWidget *parent = nullptr); QmitkHotkeyLineEdit(const QString &_QString, QWidget *parent = nullptr); virtual void SetKeySequence(const QKeySequence &_QKeySequence); virtual void SetKeySequence(const QString &_QKeySequenceAsString); virtual QKeySequence GetKeySequence(); virtual QString GetKeySequenceAsString(); bool Matches(QKeyEvent *event); protected slots: void LineEditTextChanged(const QString &); protected: - virtual void keyPressEvent(QKeyEvent *event) override; + void keyPressEvent(QKeyEvent *event) override; void Init(); protected: QKeySequence m_KeySequence; }; #endif diff --git a/Modules/QtWidgetsExt/include/QmitkNumberPropertyEditor.h b/Modules/QtWidgetsExt/include/QmitkNumberPropertyEditor.h index 083dc25e46..b47b5ec4ef 100644 --- a/Modules/QtWidgetsExt/include/QmitkNumberPropertyEditor.h +++ b/Modules/QtWidgetsExt/include/QmitkNumberPropertyEditor.h @@ -1,87 +1,87 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QMITK_NUMBERPROPERTYEDITOR_H_INCLUDED #define QMITK_NUMBERPROPERTYEDITOR_H_INCLUDED #include "MitkQtWidgetsExtExports.h" #include #include #include /// @ingroup Widgets class MITKQTWIDGETSEXT_EXPORT QmitkNumberPropertyEditor : public QSpinBox, public mitk::PropertyEditor { Q_OBJECT Q_PROPERTY(short decimalPlaces READ getDecimalPlaces WRITE setDecimalPlaces) Q_PROPERTY(bool showPercent READ getShowPercent WRITE setShowPercent) Q_PROPERTY(int minValue READ minValue WRITE setMinValue) Q_PROPERTY(int maxValue READ maxValue WRITE setMaxValue) public: QmitkNumberPropertyEditor(mitk::IntProperty *, QWidget *parent); QmitkNumberPropertyEditor(mitk::FloatProperty *, QWidget *parent); QmitkNumberPropertyEditor(mitk::DoubleProperty *, QWidget *parent); - virtual ~QmitkNumberPropertyEditor(); + ~QmitkNumberPropertyEditor() override; short getDecimalPlaces() const; void setDecimalPlaces(short); bool getShowPercent() const; void setShowPercent(bool); int minValue() const; void setMinValue(int); int maxValue() const; void setMaxValue(int); double doubleValue() const; void setDoubleValue(double); protected: void initialize(); - virtual QString textFromValue(int) const override; - virtual int valueFromText(const QString &) const override; + QString textFromValue(int) const override; + int valueFromText(const QString &) const override; - virtual void PropertyChanged() override; - virtual void PropertyRemoved() override; + void PropertyChanged() override; + void PropertyRemoved() override; void DisplayNumber(); union { mitk::GenericProperty *m_IntProperty; mitk::GenericProperty *m_FloatProperty; mitk::GenericProperty *m_DoubleProperty; }; const int m_DataType; short m_DecimalPlaces; // how many decimal places are shown double m_FactorPropertyToSpinbox; // internal conversion factor. neccessary because spinbox ranges work only with ints double m_FactorSpinboxToDisplay; // internal conversion factor. neccessary because spinbox ranges work only with ints bool m_ShowPercents; // whether values are given in percent (0.5 -> 50%) protected slots: void onValueChanged(int); private: void adjustFactors(short, bool); bool m_SelfChangeLock; }; #endif diff --git a/Modules/QtWidgetsExt/include/QmitkNumberPropertySlider.h b/Modules/QtWidgetsExt/include/QmitkNumberPropertySlider.h index 24b51b66cc..8561c6fe4a 100644 --- a/Modules/QtWidgetsExt/include/QmitkNumberPropertySlider.h +++ b/Modules/QtWidgetsExt/include/QmitkNumberPropertySlider.h @@ -1,71 +1,71 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QmitkNumberPropertySliderhincludecd #define QmitkNumberPropertySliderhincludecd #include "MitkQtWidgetsExtExports.h" #include #include namespace mitk { class IntProperty; class FloatProperty; class DoubleProperty; } /// @ingroup Widgets class MITKQTWIDGETSEXT_EXPORT QmitkNumberPropertySlider : public QSlider { Q_OBJECT Q_PROPERTY(short decimalPlaces READ getDecimalPlaces WRITE setDecimalPlaces) Q_PROPERTY(bool showPercent READ getShowPercent WRITE setShowPercent) Q_PROPERTY(int minValue READ minValue WRITE setMinValue) Q_PROPERTY(int maxValue READ maxValue WRITE setMaxValue) public: QmitkNumberPropertySlider(QWidget *parent = nullptr); - virtual ~QmitkNumberPropertySlider(); + ~QmitkNumberPropertySlider() override; void SetProperty(mitk::IntProperty *property); void SetProperty(mitk::FloatProperty *property); void SetProperty(mitk::DoubleProperty *property); short getDecimalPlaces() const; void setDecimalPlaces(short); bool getShowPercent() const; void setShowPercent(bool); int minValue() const; void setMinValue(int); int maxValue() const; void setMaxValue(int); double doubleValue() const; void setDoubleValue(double); protected slots: void onValueChanged(int); private: class Impl; std::unique_ptr d; }; #endif diff --git a/Modules/QtWidgetsExt/include/QmitkNumberPropertyView.h b/Modules/QtWidgetsExt/include/QmitkNumberPropertyView.h index f380a75c49..5b9cabe342 100644 --- a/Modules/QtWidgetsExt/include/QmitkNumberPropertyView.h +++ b/Modules/QtWidgetsExt/include/QmitkNumberPropertyView.h @@ -1,69 +1,69 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QMITK_NUMBERPROPERTYVIEW_H_INCLUDED #define QMITK_NUMBERPROPERTYVIEW_H_INCLUDED #include "MitkQtWidgetsExtExports.h" #include #include #include /// @ingroup Widgets class MITKQTWIDGETSEXT_EXPORT QmitkNumberPropertyView : public QLabel, public mitk::PropertyView { Q_OBJECT Q_PROPERTY(short decimalPlaces READ decimalPlaces WRITE setDecimalPlaces) Q_PROPERTY(QString suffix READ suffix WRITE setSuffix) Q_PROPERTY(bool showPercent READ showPercent WRITE setShowPercent) public: QmitkNumberPropertyView(const mitk::IntProperty *, QWidget *parent); QmitkNumberPropertyView(const mitk::FloatProperty *, QWidget *parent); QmitkNumberPropertyView(const mitk::DoubleProperty *, QWidget *parent); - virtual ~QmitkNumberPropertyView(); + ~QmitkNumberPropertyView() override; short decimalPlaces() const; void setDecimalPlaces(short); QString suffix() const; void setSuffix(const QString &); bool showPercent() const; void setShowPercent(bool); protected: void initialize(); - virtual void PropertyChanged() override; - virtual void PropertyRemoved() override; + void PropertyChanged() override; + void PropertyRemoved() override; void DisplayNumber(); union { const mitk::GenericProperty *m_IntProperty; const mitk::GenericProperty *m_FloatProperty; const mitk::GenericProperty *m_DoubleProperty; }; const int m_DataType; short m_DecimalPlaces; /// -1 indicates "no limit to decimal places" QString m_Suffix; double m_DisplayFactor; }; #endif diff --git a/Modules/QtWidgetsExt/include/QmitkPiecewiseFunctionCanvas.h b/Modules/QtWidgetsExt/include/QmitkPiecewiseFunctionCanvas.h index 04aab7fe65..476e9e292e 100755 --- a/Modules/QtWidgetsExt/include/QmitkPiecewiseFunctionCanvas.h +++ b/Modules/QtWidgetsExt/include/QmitkPiecewiseFunctionCanvas.h @@ -1,103 +1,103 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QMITKPIECEWISEFUNCTIONCANVAS_H_INCLUDED #define QMITKPIECEWISEFUNCTIONCANVAS_H_INCLUDED #include "MitkQtWidgetsExtExports.h" #include "QmitkTransferFunctionCanvas.h" #include class MITKQTWIDGETSEXT_EXPORT QmitkPiecewiseFunctionCanvas : public QmitkTransferFunctionCanvas { Q_OBJECT public: QmitkPiecewiseFunctionCanvas(QWidget *parent = nullptr, Qt::WindowFlags f = nullptr); - virtual void paintEvent(QPaintEvent *e) override; + void paintEvent(QPaintEvent *e) override; void SetTitle(const QString &title); int GetNearHandle(int x, int y, unsigned int maxSquaredDistance = 32) override; void SetPiecewiseFunction(vtkPiecewiseFunction *piecewiseFunction) { this->m_PiecewiseFunction = piecewiseFunction; this->SetMin(m_PiecewiseFunction->GetRange()[0]); this->SetMax(m_PiecewiseFunction->GetRange()[1]); setEnabled(true); update(); } int AddFunctionPoint(double x, double val) override { return m_PiecewiseFunction->AddPoint(x, val); } void RemoveFunctionPoint(double x) override { int old_size = GetFunctionSize(); m_PiecewiseFunction->RemovePoint(x); if (GetFunctionSize() + 1 != old_size) { std::cout << "old/new size" << old_size << "/" << GetFunctionSize() << std::endl; std::cout << "called with x=" << x << std::endl; } } double GetFunctionX(int index) override { return m_PiecewiseFunction->GetDataPointer()[index * 2]; } double GetFunctionY(int index) override { return m_PiecewiseFunction->GetValue(m_PiecewiseFunction->GetDataPointer()[index * 2]); } int GetFunctionSize() override { return m_PiecewiseFunction->GetSize(); } void DoubleClickOnHandle(int) override {} void MoveFunctionPoint(int index, std::pair pos) override; double GetFunctionMax() { return m_PiecewiseFunction->GetRange()[1]; } double GetFunctionMin() { return m_PiecewiseFunction->GetRange()[0]; } double GetFunctionRange() { double range; if ((m_PiecewiseFunction->GetRange()[0]) < 0) { range = (m_PiecewiseFunction->GetRange()[1]) - (m_PiecewiseFunction->GetRange()[0]); return range; } else { range = m_PiecewiseFunction->GetRange()[1]; return range; } } void RemoveAllFunctionPoints() { m_PiecewiseFunction->AddSegment(this->GetFunctionMin(), 0, this->GetFunctionMax(), 1); m_PiecewiseFunction->AddPoint(0.0, 0.0); } void ResetGO() { // Gradient Opacity m_PiecewiseFunction->AddSegment(this->GetFunctionMin(), 0, 0, 1); m_PiecewiseFunction->AddSegment(0, 1, ((this->GetFunctionRange()) * 0.125), 1); m_PiecewiseFunction->AddSegment(((this->GetFunctionRange()) * 0.125), 1, ((this->GetFunctionRange()) * 0.2), 1); m_PiecewiseFunction->AddSegment(((this->GetFunctionRange()) * 0.2), 1, ((this->GetFunctionRange()) * 0.25), 1); } protected: vtkPiecewiseFunction *m_PiecewiseFunction; QString m_Title; }; #endif diff --git a/Modules/QtWidgetsExt/include/QmitkPlotWidget.h b/Modules/QtWidgetsExt/include/QmitkPlotWidget.h index 03ce11cdb6..4ffc87f782 100644 --- a/Modules/QtWidgetsExt/include/QmitkPlotWidget.h +++ b/Modules/QtWidgetsExt/include/QmitkPlotWidget.h @@ -1,301 +1,301 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef _QmitkPlotWidget_H_ #define _QmitkPlotWidget_H_ #include "MitkQtWidgetsExtExports.h" #include "mitkCommon.h" #include #include #include #include #include #include #include #include /** * Provides a convenient interface for plotting curves using qwt. * Designed for qwt version 5.2.1. * Can be used with a QmitkPlotDialog, which provides a "Close" button. * @see QmitkPlotDialog * * To plot data do the following: * 1. Create two QmitkPlotWidget::DataVector Objects and fill them * with corresponding x/y values. DataVectors are simple stl-vectors * of type std::vector. Please note that the xValues * vector and the yValues vector MUST have the same size. * 2. Instantiate the widget for example like that: * QmitkPlotWidget* widget = new QmitkPlotWidget( this, "widget" ); * widget->SetAxisTitle( QwtPlot::xBottom, "My x asis [mm]" ); * widget->SetAxisTitle( QwtPlot::yLeft, "My y axis [mm]" ); * int curveId = widget->InsertCurve( "My sophisticated data" ); * widget->SetCurveData( curveId, xValues, yValues ); * widget->SetCurvePen( curveId, QPen( red ) ); * widget->SetCurveTitle( curveId, "My curve description" ); * widget->Replot(); * 3. You can modify the behavior of the plot by directly referencing * the QwtPlot instance using the method GetPlot(). * @see QwtPlot */ class MITKQTWIDGETSEXT_EXPORT QmitkPlotWidget : public QWidget { private: Q_OBJECT public: /** * represents the data type used for scalar values stored * in data arrays. This type is provided by qwt and may not * be changed. */ typedef double ScalarType; /** * This type may be used to store a set of scalar values * representing either x or y coordinates of the data * points that should be rendered. */ typedef std::vector DataVector; /** * convenience type used to store pairs representing x/y coordinates * that should be rendered as a curve by the plot widget */ typedef std::vector> XYDataVector; /** * Standard qt constructor */ QmitkPlotWidget(QWidget *parent = nullptr, const char *title = nullptr, const char *name = nullptr, Qt::WindowFlags f = nullptr); /** * Virtual destructor */ - virtual ~QmitkPlotWidget(); + ~QmitkPlotWidget() override; /** * Returns the instance of the plot-widget. This may be used * to modify any detail of the appearance of the plot. */ QwtPlot *GetPlot(); /** * Set the title using (formatted) QwtText object */ void SetPlotTitle(const QwtText &qwt_title); /** * Set plain text title, using default formatting */ void SetPlotTitle(const char *title); /** * Inserts a new curve into the plot-window. * @param title the name of the curve * @returns the id of the curve. Use this id to * refer to the curve, if you want to modify or add data. */ unsigned int InsertCurve(const char *title, QColor color = QColor(Qt::black)); /** * Sets the title of the given axis. For the set of available axes * @see QwtPlot::Axis. * @param axis the axis for which the description should be set. * @param title the name of the axis. */ void SetAxisTitle(int axis, const char *title); /** * Sets the data for a previously added curve. Data is provided as two vectors of double. * The first vector represents the x coordinates, the second vector represents the y coordinates. * @param curveId the id of the curve for which data should be added. * @param xValues the x coordinates of the points that define the curve * @param yValues the y coordinates of the points that define the curve * @returns whether data was added successfully or not */ bool SetCurveData(unsigned int curveId, const DataVector &xValues, const DataVector &yValues); /** * @brief Sets the data with errors for a previously added curve. * * @param curveId the id of the curve for which data should be added. * @param xValues the x coordinates of the points that define the curve * @param yValues the y coordinates of the points that define the curve * @param yLowerError the magnitude (>0) of the error in the lesser direction of y * @param yUpperError the magnitude (>0) of the error in the larger direction of y * @returns whether data was added successfully or not */ bool SetCurveData(unsigned int curveId, const DataVector &xValues, const DataVector &yValues, const DataVector &yLowerError, const DataVector &yUpperError); /** * @brief Sets the data with errors for a previously added curve. * * @param curveId the id of the curve for which data should be added. * @param xValues the x coordinates of the points that define the curve * @param yValues the y coordinates of the points that define the curve * @param xLowerError the magnitude (>0) of the error in the lesser direction of x * @param xUpperError the magnitude (>0) of the error in the larger direction of x * @param yLowerError the magnitude (>0) of the error in the lesser direction of y * @param yUpperError the magnitude (>0) of the error in the larger direction of y * @returns whether data was added successfully or not */ bool SetCurveData(unsigned int curveId, const DataVector &xValues, const DataVector &yValues, const DataVector &xLowerError, const DataVector &xUpperError, const DataVector &yLowerError, const DataVector &yUpperError); /** * Sets the data for a previously added curve. Data is provided as a vectors of pairs. * The pairs represent x/y coordinates of the points that define the curve. * @param curveId the id of the curve for which data should be added. * @param data the coordinates of the points that define the curve * @returns whether data was added successfully or not */ bool SetCurveData(unsigned int curveId, const XYDataVector &data); /** * Defines how a curve should be drawn. For drawing a curve, a QPen is used. * @param curveId the id of the curve for which appearance should be changed * @param pen a QPen (@see QPen) defining the line style */ void SetCurvePen(unsigned int curveId, const QPen &pen); /** * Assign a brush, which defines the fill pattern of shapes drawn by a QPainter. * In case of brush.style() != QBrush::NoBrush and * style() != QwtPlotCurve::Sticks * the area between the curve and the baseline will be filled. * In case !brush.color().isValid() the area will be filled by pen.color(). * The fill algorithm simply connects the first and the last curve point to the * baseline. So the curve data has to be sorted (ascending or descending). * @param curveId the id of the curve for which appearance should be changed * @param brush a QBrush (@see QBrush) defining the line style */ void SetCurveBrush(unsigned int curveId, const QBrush &brush); /** * Sets the style how the line is drawn for the curve; like, plain line, * or with the data points marked with a symbol; * @param: style A QwtPlotCurve::CurveStyle */ void SetCurveStyle(unsigned int curveId, const QwtPlotCurve::CurveStyle style); /** * Sets the style data points are drawn for the curve; like, a line, * or dots; * @param: symbol A QwtSymbol */ void SetCurveSymbol(unsigned int curveId, QwtSymbol *symbol); void SetCurveAntialiasingOn(unsigned int curveId); void SetCurveAntialiasingOff(unsigned int curveId); /** * Sets the title of the given curve. The title will be shown in the legend of * the QwtPlot. * @param curveId the id of the curve for which the title should be set * @param title the description of the curve that will be shown in the legend. */ void SetCurveTitle(unsigned int curveId, const char *title); /** * Defines how a curves errors should be drawn. For drawing a QPen is used. * @param curveId the id of the curve for which error appearance should be changed * @param pen a QPen (@see QPen) defining the line style */ void SetErrorPen(unsigned int curveId, const QPen &pen); /** * Defines the style of errors, symbols or as a curve. * @param curveId the id of the curve for which error appearance should be changed * @param drawSmybols true - draw symbols, false - draw curve */ void SetErrorStyleSymbols(unsigned int curveId, bool drawSmybols); /** * Sets the legend of the plot * */ void SetLegend(QwtLegend *legend, QwtPlot::LegendPosition pos = QwtPlot::RightLegend, double ratio = -1); /** * Set a curve's legend attribute * @param curveId the id of the curve * @param attribute the öegend attribute to be set */ void SetLegendAttribute(unsigned int curveId, const QwtPlotCurve::LegendAttribute &attribute); /** * Triggers a replot of the curve. Replot should be called once after * setting new data. */ void Replot(); /** * Resets the plot into an empty state */ void Clear(); protected: /** * Converts the given values into a raw double* array. * A new array is allocated via new and must be deleted[] by the caller. */ double *ConvertToRawArray(const DataVector &values); /** * Converts the given values into a raw double* array. * A new array is allocated via new and must be deleted[] by the caller. * @param values the x/y values to convert to an array * @param component defines if the x values (0) or the y values(1) should * be converted. Other values than 0 and 1 will not be accepted. */ double *ConvertToRawArray(const XYDataVector &values, unsigned int component); /** * Adds an error interval curve. * * All errors should be absolutes. The magnitude will be used. * * @param curveId Which curve should the error curve be added to * @param xValues Vector of x values an error bar belongs to * @param values The original data value * @param lessError Error in the negative direction (value - lessError) * @param moreError Error in the positive direction (value + lessError) * @param isXError Should the error bars be drawn horizontally */ bool AddErrorIntervalCurve(unsigned int curveId, const DataVector &lessError, const DataVector &moreError, bool isXError); QwtPlot *m_Plot; std::vector> m_PlotCurveVector; }; #endif diff --git a/Modules/QtWidgetsExt/include/QmitkPointListModel.h b/Modules/QtWidgetsExt/include/QmitkPointListModel.h index 2be895bd5f..0644e8956c 100644 --- a/Modules/QtWidgetsExt/include/QmitkPointListModel.h +++ b/Modules/QtWidgetsExt/include/QmitkPointListModel.h @@ -1,129 +1,129 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QMITK_POINTLIST_MODEL_H_INCLUDED #define QMITK_POINTLIST_MODEL_H_INCLUDED #include "MitkQtWidgetsExtExports.h" #include #include "mitkDataNode.h" #include "mitkPointSet.h" class MITKQTWIDGETSEXT_EXPORT QmitkPointListModel : public QAbstractListModel { Q_OBJECT public: QmitkPointListModel(mitk::DataNode * = nullptr, int t = 0, QObject *parent = 0); - ~QmitkPointListModel(); + ~QmitkPointListModel() override; Qt::ItemFlags flags(const QModelIndex &) const override; /// interface of QAbstractListModel int rowCount(const QModelIndex &parent = QModelIndex()) const override; /// interface of QAbstractListModel QVariant data(const QModelIndex &index, int role) const override; /// interface of QAbstractListModel QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override; /// which point set to work on void SetPointSetNode(mitk::DataNode *pointSetNode); /// which point set to work on mitk::PointSet *GetPointSet() const; // which point set to work on mitk::DataNode *GetPointSetNode() const; /// which time step to display/model void SetTimeStep(int t); /// which time step to display/model int GetTimeStep() const; /// itk observer for point set "modified" events void OnPointSetChanged(const itk::EventObject &e); /// itk observer for point set "delete" events void OnPointSetDeleted(const itk::EventObject &e); /** * \brief get point and point ID that correspond to a given QModelIndex * * The mitk::PointSet uses a map to store points in an ID<-->Point relation. * The IDs are not neccesarily continuously numbered, therefore, we can not * directly use the QModelIndex as point ID. This method returns the point and * the corresponding point id for a given QModelIndex. The point and the point ID * are returned in the outgoing parameters p and id. If a valid point and ID were * found, the method returns true, otherwise it returns false * \param[in] QModelIndex &index the index for which a point is requested. The row() part of the index is used to find a corresponding point * \param[out] mitk::Point3D& p If a valid point is found, it will be stored in the p parameter * \param[out] mitk::PointSet::PointIdentifier& id If a valid point is found, the corresponding ID will be stored in id * \return Returns true, if a valid point was found, false otherwise */ bool GetPointForModelIndex(const QModelIndex &index, mitk::PointSet::PointType &p, mitk::PointSet::PointIdentifier &id) const; /**Documentation * \brief returns a QModelIndex for a given point ID * * The mitk::PointSet uses a map to store points in an ID<-->Point relation. * The IDs are not neccesarily continuously numbered, therefore, we can not * directly use the point ID as a QModelIndex. This method returns a QModelIndex * for a given point ID in the outgoing parameter index. * \param[in] mitk::PointSet::PointIdentifier id The point ID for which the QModelIndex will be created * \param[out] QModelIndex& index if a point with the ID id was found, index will contain a corresponding QModelIndex * for that point * \return returns true, if a valid QModelIndex was created, false otherwise */ bool GetModelIndexForPointID(mitk::PointSet::PointIdentifier id, QModelIndex &index) const; public slots: void MoveSelectedPointUp(); void MoveSelectedPointDown(); void RemoveSelectedPoint(); signals: /// emitted, when views should update their selection status /// (because mouse interactions in render windows can change /// the selection status of points) void SignalUpdateSelection(); protected: /// internally observe different point set void ObserveNewPointSet(mitk::DataNode *pointSetNode); // initially checks if there is a PointSet as data in the DataNode. // returns PointSet if so and nullptr if other data is set to node mitk::PointSet *CheckForPointSetInNode(mitk::DataNode *node) const; protected: mitk::DataNode *m_PointSetNode; unsigned int m_PointSetModifiedObserverTag; unsigned int m_PointSetDeletedObserverTag; int m_TimeStep; }; #endif diff --git a/Modules/QtWidgetsExt/include/QmitkPointListView.h b/Modules/QtWidgetsExt/include/QmitkPointListView.h index a3ba79ed79..9210842248 100644 --- a/Modules/QtWidgetsExt/include/QmitkPointListView.h +++ b/Modules/QtWidgetsExt/include/QmitkPointListView.h @@ -1,131 +1,131 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QMITK_POINTLIST_VIEW_H_INCLUDED #define QMITK_POINTLIST_VIEW_H_INCLUDED #include "MitkQtWidgetsExtExports.h" #include "QmitkPointListModel.h" #include #include #include class QmitkStdMultiWidget; /*! * \brief GUI widget for handling mitk::PointSet * * Displays all the points in a mitk::PointSet graphically. * Reacts automatically to changes in the PointSet's selection status. * Updates PointSet's selection status when this list's selection changes. * * If a QmitkStdMultiWidget is assigned via SetMultiWidget(), the * crosshair of the QmitkStdMultiWidget is moved to the currently selected * point. * */ class MITKQTWIDGETSEXT_EXPORT QmitkPointListView : public QListView { Q_OBJECT public: QmitkPointListView(QWidget *parent = 0); - ~QmitkPointListView(); + ~QmitkPointListView() override; /// assign a point set for observation void SetPointSetNode(mitk::DataNode *pointSetNode); /// which point set to work on const mitk::PointSet *GetPointSet() const; /** * \brief If Multiwidget is set, the crosshair is automatically centering to the selected point * As an alternative, if you dont have a multiwidget, you can call SetSnc1, SetSnc2, SetSnc3 to set the * SliceNavigationControllers directly to enable the focussing feature. */ void SetMultiWidget(QmitkStdMultiWidget *multiWidget); QmitkStdMultiWidget *GetMultiWidget() const; ///< return the QmitkStdMultiWidget that is used for updating render window crosshair void SetTimesStep(int i); ///< which time step to display/model /** * @brief Add a mitk::SliceNavigationController instance. * @param snc The mitk::SliceNavigationController instance. * * This method adds \c snc to the set of slice navigation controllers which are * used to navigate to the selected point. */ void AddSliceNavigationController(mitk::SliceNavigationController *snc); /** * @brief Remove a mitk::SliceNavigationController instance. * @param snc The mitk::SliceNavigationController instance. * * This method removes \c snc from the set of slice navigation controllers which are * used to navigate to the selected point. */ void RemoveSliceNavigationController(mitk::SliceNavigationController *snc); signals: void SignalPointSelectionChanged(); ///< this signal is emmitted, if the selection of a point in the pointset is changed protected slots: /// Filtering double click event for editing point coordinates via a dialog void OnPointDoubleClicked(const QModelIndex &index); /// called when the point set data structure changes void OnPointSetSelectionChanged(); /// called when the selection of the view widget changes void OnListViewSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected); /// fade the shown timestep out void fadeTimeStepOut(); /// open ContextMenu void ctxMenu(const QPoint &pos); /// Turn TimeStep Fading On/Off void SetFading(bool onOff); /// Delete all points in the list void ClearPointList(); /// delete all points in the list in the current timestep void ClearPointListTS(); protected: void keyPressEvent(QKeyEvent *e) override; ///< react to F2, F3 and DEL keys void wheelEvent(QWheelEvent *event) override; ///< change timestep of the current pointset by mouse wheel void fadeTimeStepIn(); ///< fade a label with the currently shown timestep in std::set m_Sncs; QmitkPointListModel *m_PointListModel; bool m_SelfCall; bool m_showFading; /// used to position the planes on a selected point QmitkStdMultiWidget *m_MultiWidget; QLabel *m_TimeStepFaderLabel; }; #endif diff --git a/Modules/QtWidgetsExt/include/QmitkPointListViewWidget.h b/Modules/QtWidgetsExt/include/QmitkPointListViewWidget.h index b0429f5994..ce923201d5 100644 --- a/Modules/QtWidgetsExt/include/QmitkPointListViewWidget.h +++ b/Modules/QtWidgetsExt/include/QmitkPointListViewWidget.h @@ -1,100 +1,100 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QmitkPointListViewWidget_h #define QmitkPointListViewWidget_h #include "MitkQtWidgetsExtExports.h" #include #include #include class QmitkStdMultiWidget; /*! * \brief GUI widget for handling mitk::PointSet * * Displays all the points in a mitk::PointSet graphically. * Reacts automatically to changes in the PointSet's selection status. * Updates PointSet's selection status when this list's selection changes. * * If a QmitkStdMultiWidget is assigned via SetMultiWidget(), the * crosshair of the QmitkStdMultiWidget is moved to the currently selected * point. * */ class MITKQTWIDGETSEXT_EXPORT QmitkPointListViewWidget : public QListWidget { Q_OBJECT signals: void PointSelectionChanged(); ///< this signal is emmitted, if the selection of a point in the pointset is changed public: QmitkPointListViewWidget(QWidget *parent = 0); - ~QmitkPointListViewWidget(); + ~QmitkPointListViewWidget() override; /// assign a point set for observation void SetPointSet(mitk::PointSet *pointSet); /// which point set to work on const mitk::PointSet *GetPointSet() const; void SetMultiWidget( QmitkStdMultiWidget *multiWidget); ///< assign a QmitkStdMultiWidget for updating render window crosshair QmitkStdMultiWidget *GetMultiWidget() const; ///< return the QmitkStdMultiWidget that is used for updating render window crosshair /// which time step to display/model void SetTimeStep(int t); /// which time step to display/model int GetTimeStep() const; /// observer for point set "modified" events void OnPointSetChanged(const itk::Object * /*obj*/); /// observer for point set "delete" events void OnPointSetDeleted(const itk::Object * /*obj*/); protected slots: /// /// Filtering double click event for editing point coordinates via a dialog /// void OnItemDoubleClicked(QListWidgetItem *item); /// called when the selection of the view widget changes void OnCurrentRowChanged(int /*currentRow*/); protected: void keyPressEvent(QKeyEvent *e) override; ///< react to F2, F3 and DEL keys void MoveSelectedPointUp(); void MoveSelectedPointDown(); void RemoveSelectedPoint(); void Update(bool currentRowChanged = false); protected: mitk::WeakPointer m_PointSet; int m_TimeStep; bool m_SelfCall; /// used to position the planes on a selected point QmitkStdMultiWidget *m_MultiWidget; }; #endif diff --git a/Modules/QtWidgetsExt/include/QmitkPointListWidget.h b/Modules/QtWidgetsExt/include/QmitkPointListWidget.h index ad1a4e23c4..a7136b489f 100644 --- a/Modules/QtWidgetsExt/include/QmitkPointListWidget.h +++ b/Modules/QtWidgetsExt/include/QmitkPointListWidget.h @@ -1,150 +1,150 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QmitkPointListWidget_H #define QmitkPointListWidget_H #include "MitkQtWidgetsExtExports.h" #include #include #include #include #include #include #include /*! * \brief Widget for regular operations on point sets * * Displays a list of point coordinates and a couple of * buttons which * * \li enable point set interaction * \li clear all points from a set * \li load points from file * \li save points to file * * The user/application module of this widget needs to * assign a mitk::PointSet object to this widget. The user * also has to decide whether it wants to put the point set * into (a) DataStorage. This widget will not add/remove * point sets to DataStorage. * * If the render window crosshair should be moved to the * currently selected point, the widget user has to provide * a QmitkStdMultiWidget object. */ class MITKQTWIDGETSEXT_EXPORT QmitkPointListWidget : public QWidget { Q_OBJECT public: QmitkPointListWidget(QWidget *parent = 0, int orientation = 0); - ~QmitkPointListWidget(); + ~QmitkPointListWidget() override; void SetupConnections(); /** * @brief Add a mitk::SliceNavigationController instance. * @param snc The mitk::SliceNavigationController instance. * * This method adds \c snc to the set of slice navigation controllers which are * used to navigate to the selected point. */ void AddSliceNavigationController(mitk::SliceNavigationController *snc); /** * @brief Remove a mitk::SliceNavigationController instance. * @param snc The mitk::SliceNavigationController instance. * * This method removes \c snc from the set of slice navigation controllers which are * used to navigate to the selected point. */ void RemoveSliceNavigationController(mitk::SliceNavigationController *snc); /** @brief assign a point set (contained in a node of DataStorage) for observation */ void SetPointSet(mitk::PointSet *newPs); mitk::PointSet *GetPointSet(); /** @brief assign a point set (contained in a node of DataStorage) for observation */ void SetPointSetNode(mitk::DataNode *newNode); mitk::DataNode *GetPointSetNode(); /** @brief assign a QmitkStdMultiWidget for updating render window crosshair */ void SetMultiWidget(QmitkStdMultiWidget *multiWidget); /** @brief itk observer for node "delete" events */ void OnNodeDeleted(const itk::EventObject &e); /** @brief Unselects the edit button if it is selected. */ void UnselectEditButton(); public slots: void DeactivateInteractor(bool deactivate); void EnableEditButton(bool enabled); signals: /** @brief signal to inform about the state of the EditPointSetButton, whether an interactor for setting points is * active or not */ void EditPointSets(bool active); /// signal to inform that the selection of a point in the pointset has changed void PointSelectionChanged(); /// signal to inform about cleared or loaded point sets void PointListChanged(); protected slots: void OnBtnSavePoints(); void OnBtnLoadPoints(); void RemoveSelectedPoint(); void MoveSelectedPointDown(); void MoveSelectedPointUp(); void OnBtnAddPoint(bool checked); void OnBtnAddPointManually(); /*! \brief pass through signal from PointListView that point selection has changed */ void OnPointSelectionChanged(); void OnListDoubleClick(); protected: void SetupUi(); void ObserveNewNode(mitk::DataNode *node); QmitkPointListView *m_PointListView; mitk::DataNode::Pointer m_PointSetNode; int m_Orientation; QPushButton *m_MovePointUpBtn; QPushButton *m_MovePointDownBtn; QPushButton *m_RemovePointBtn; QPushButton *m_SavePointsBtn; QPushButton *m_LoadPointsBtn; QPushButton *m_ToggleAddPoint; QPushButton *m_AddPoint; mitk::DataInteractor::Pointer m_DataInteractor; int m_TimeStep; bool m_EditAllowed; unsigned long m_NodeObserverTag; }; #endif diff --git a/Modules/QtWidgetsExt/include/QmitkPrimitiveMovieNavigatorWidget.h b/Modules/QtWidgetsExt/include/QmitkPrimitiveMovieNavigatorWidget.h index 4cb9dd5f8b..1239f3d530 100755 --- a/Modules/QtWidgetsExt/include/QmitkPrimitiveMovieNavigatorWidget.h +++ b/Modules/QtWidgetsExt/include/QmitkPrimitiveMovieNavigatorWidget.h @@ -1,54 +1,54 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QMITKPRIMITIVEMOVIENAVIGATORWIDGET_H_ #define QMITKPRIMITIVEMOVIENAVIGATORWIDGET_H_ #include "MitkQtWidgetsExtExports.h" #include #include #include class MITKQTWIDGETSEXT_EXPORT QmitkPrimitiveMovieNavigatorWidget : public QWidget { Q_OBJECT public: QmitkPrimitiveMovieNavigatorWidget(QWidget *parent = nullptr, Qt::WindowFlags fl = nullptr); - ~QmitkPrimitiveMovieNavigatorWidget(); + ~QmitkPrimitiveMovieNavigatorWidget() override; virtual int getTimerInterval(); public slots: virtual void Refetch(); virtual void SetStepper(mitk::Stepper *stepper); virtual void goButton_clicked(); virtual void stopButton_clicked(); virtual void spinBoxValueChanged(int value); virtual void setTimerInterval(int timerIntervalInMS); protected: Ui::QmitkPrimitiveMovieNavigator m_Controls; mitk::Stepper::Pointer m_Stepper; bool m_InRefetch; QTimer *m_Timer; int m_TimerIntervalInMS; private slots: virtual void next(); }; #endif diff --git a/Modules/QtWidgetsExt/include/QmitkSelectableGLWidget.h b/Modules/QtWidgetsExt/include/QmitkSelectableGLWidget.h index 11cdad2f83..a672dd5dd6 100644 --- a/Modules/QtWidgetsExt/include/QmitkSelectableGLWidget.h +++ b/Modules/QtWidgetsExt/include/QmitkSelectableGLWidget.h @@ -1,55 +1,55 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QMITKSELECTABLEGLWIDGET_H #define QMITKSELECTABLEGLWIDGET_H #include "mitkCameraRotationController.h" #include "mitkCommon.h" #include "mitkSliceNavigationController.h" #include "mitkVtkPropRenderer.h" #include "ui_QmitkSelectableGLWidget.h" #include #include #include class QmitkRenderWindow; class MITKQTWIDGETSEXT_EXPORT QmitkSelectableGLWidget : public QWidget { Q_OBJECT public: QmitkSelectableGLWidget(QWidget *parent = 0); - ~QmitkSelectableGLWidget(); + ~QmitkSelectableGLWidget() override; mitk::VtkPropRenderer *GetRenderer(); QmitkRenderWindow *GetRenderWindow() const; mitk::SliceNavigationController *GetSliceNavigationController() const; mitk::CameraRotationController *GetCameraRotationController() const; mitk::BaseController *GetController() const; protected: void wheelEvent(QWheelEvent *e) override; QmitkRenderWindow *m_RenderWindow; mitk::VtkPropRenderer::Pointer m_Renderer; private: Ui::QmitkSelectableGLWidget *m_Ui; }; #endif diff --git a/Modules/QtWidgetsExt/include/QmitkStandardViews.h b/Modules/QtWidgetsExt/include/QmitkStandardViews.h index 6d26e1635f..9bfe4a7e89 100644 --- a/Modules/QtWidgetsExt/include/QmitkStandardViews.h +++ b/Modules/QtWidgetsExt/include/QmitkStandardViews.h @@ -1,55 +1,55 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QmitkStandardViews_h_included #define QmitkStandardViews_h_included #include "MitkQtWidgetsExtExports.h" #include "mitkCameraController.h" #include "mitkCommon.h" #include class QClickableLabel; class vtkRenderWindow; class MITKQTWIDGETSEXT_EXPORT QmitkStandardViews : public QWidget { Q_OBJECT public: QmitkStandardViews(QWidget *parent = 0, Qt::WindowFlags f = 0); - virtual ~QmitkStandardViews(); + ~QmitkStandardViews() override; void SetCameraController(mitk::CameraController *controller); void SetCameraControllerFromRenderWindow(vtkRenderWindow *window); signals: void StandardViewDefined(mitk::CameraController::StandardView view); protected slots: void hotspotClicked(const QString &s); protected: QClickableLabel *m_ClickablePicture; mitk::CameraController::Pointer m_CameraController; }; #endif diff --git a/Modules/QtWidgetsExt/include/QmitkStepperAdapter.h b/Modules/QtWidgetsExt/include/QmitkStepperAdapter.h index f427f9c4ec..7c331b21ca 100644 --- a/Modules/QtWidgetsExt/include/QmitkStepperAdapter.h +++ b/Modules/QtWidgetsExt/include/QmitkStepperAdapter.h @@ -1,78 +1,78 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QMITKSTEPPERADAPTER_H_HEADER_INCLUDED_C1E77191 #define QMITKSTEPPERADAPTER_H_HEADER_INCLUDED_C1E77191 #include "MitkQtWidgetsExtExports.h" #include "itkCommand.h" #include "itkObject.h" #include "mitkStepper.h" #include "qobject.h" //##Documentation //## @brief Helper class to connect Qt-based navigators to instances of Stepper //## //## The constructor has to be provided with the \a Navigator //## that wants to use the \a Stepper. The \a Navigator has to define the //## slots \a Refetch() and \a SetStepper(mitk::Stepper *). \a SetStepper will be //## called only once to pass the \a Stepper to the \a Navigator. When the values of //## the \a Stepper changes, \a Refetch() will be called. The \a Navigator can than //## ask the \a Stepper for its new values. //## \warning The \a Navigator has to be aware that it might have caused the changes //## of the \a Stepper itself. So take care that no infinite recursion is created! //## @ingroup NavigationControl class MITKQTWIDGETSEXT_EXPORT QmitkStepperAdapter : public QObject { Q_OBJECT public: QmitkStepperAdapter(QObject *navigator, mitk::Stepper *stepper, const char *name); - virtual ~QmitkStepperAdapter(); + ~QmitkStepperAdapter() override; void SetStepper(mitk::Stepper *stepper) { this->SendStepper(stepper); this->Refetch(); } class MITKQTWIDGETSEXT_EXPORT ItkEventListener : public itk::Command { public: mitkClassMacroItkParent(ItkEventListener, itk::Command); ItkEventListener(QmitkStepperAdapter *receiver) : m_Receiver(receiver){ }; - virtual void Execute(itk::Object *, const itk::EventObject &) override { emit m_Receiver->Refetch(); }; - virtual void Execute(const itk::Object *, const itk::EventObject &) override { emit m_Receiver->Refetch(); }; + void Execute(itk::Object *, const itk::EventObject &) override { emit m_Receiver->Refetch(); }; + void Execute(const itk::Object *, const itk::EventObject &) override { emit m_Receiver->Refetch(); }; protected: QmitkStepperAdapter *m_Receiver; }; signals: void signal_dummy(); void Refetch(); void SendStepper(mitk::Stepper *); protected: mitk::Stepper::Pointer m_Stepper; long m_ObserverTag; friend class QmitkStepperAdapter::ItkEventListener; ItkEventListener::Pointer m_ItkEventListener; }; #endif diff --git a/Modules/QtWidgetsExt/include/QmitkStringPropertyEditor.h b/Modules/QtWidgetsExt/include/QmitkStringPropertyEditor.h index 64987f861e..5cd9dd0f24 100644 --- a/Modules/QtWidgetsExt/include/QmitkStringPropertyEditor.h +++ b/Modules/QtWidgetsExt/include/QmitkStringPropertyEditor.h @@ -1,46 +1,46 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QMITK_STRINGPROPERTYEDITOR_H_INCLUDED #define QMITK_STRINGPROPERTYEDITOR_H_INCLUDED #include "MitkQtWidgetsExtExports.h" #include #include #include /// @ingroup Widgets class MITKQTWIDGETSEXT_EXPORT QmitkStringPropertyEditor : public QLineEdit, public mitk::PropertyEditor { Q_OBJECT public: QmitkStringPropertyEditor(mitk::StringProperty *, QWidget *parent); - virtual ~QmitkStringPropertyEditor(); + ~QmitkStringPropertyEditor() override; protected: - virtual void PropertyChanged() override; - virtual void PropertyRemoved() override; + void PropertyChanged() override; + void PropertyRemoved() override; mitk::StringProperty *m_StringProperty; protected slots: void onTextChanged(const QString &); private: }; #endif diff --git a/Modules/QtWidgetsExt/include/QmitkStringPropertyOnDemandEdit.h b/Modules/QtWidgetsExt/include/QmitkStringPropertyOnDemandEdit.h index 6ec03d7fa1..be78c0553c 100644 --- a/Modules/QtWidgetsExt/include/QmitkStringPropertyOnDemandEdit.h +++ b/Modules/QtWidgetsExt/include/QmitkStringPropertyOnDemandEdit.h @@ -1,61 +1,61 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QMITK_STRINGPROPERTYONDEMANDDEDITOR_H_INCLUDED #define QMITK_STRINGPROPERTYONDEMANDDEDITOR_H_INCLUDED #include "MitkQtWidgetsExtExports.h" #include #include #include #include class MITKQTWIDGETSEXT_EXPORT QClickableLabel2 : public QLabel { Q_OBJECT signals: void clicked(); public: QClickableLabel2(QWidget *parent, Qt::WindowFlags f = nullptr) : QLabel(parent, f) {} - virtual void mouseReleaseEvent(QMouseEvent *) override { emit clicked(); } + void mouseReleaseEvent(QMouseEvent *) override { emit clicked(); } }; /// @ingroup Widgets class MITKQTWIDGETSEXT_EXPORT QmitkStringPropertyOnDemandEdit : public QFrame, public mitk::PropertyEditor { Q_OBJECT public: QmitkStringPropertyOnDemandEdit(mitk::StringProperty *, QWidget *parent); - virtual ~QmitkStringPropertyOnDemandEdit(); + ~QmitkStringPropertyOnDemandEdit() override; protected: - virtual void PropertyChanged() override; - virtual void PropertyRemoved() override; + void PropertyChanged() override; + void PropertyRemoved() override; mitk::StringProperty *m_StringProperty; QHBoxLayout *m_layout; QLabel *m_label; QClickableLabel2 *m_toolbutton; protected slots: void onToolButtonClicked(); }; #endif diff --git a/Modules/QtWidgetsExt/include/QmitkStringPropertyView.h b/Modules/QtWidgetsExt/include/QmitkStringPropertyView.h index 01851d78fb..ec87682cea 100644 --- a/Modules/QtWidgetsExt/include/QmitkStringPropertyView.h +++ b/Modules/QtWidgetsExt/include/QmitkStringPropertyView.h @@ -1,40 +1,40 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QMITK_STRINGPROPERTYVIEW_H_INCLUDED #define QMITK_STRINGPROPERTYVIEW_H_INCLUDED #include "MitkQtWidgetsExtExports.h" #include #include #include /// @ingroup Widgets class MITKQTWIDGETSEXT_EXPORT QmitkStringPropertyView : public QLabel, public mitk::PropertyView { Q_OBJECT public: QmitkStringPropertyView(const mitk::StringProperty *, QWidget *parent); - virtual ~QmitkStringPropertyView(); + ~QmitkStringPropertyView() override; protected: - virtual void PropertyChanged() override; - virtual void PropertyRemoved() override; + void PropertyChanged() override; + void PropertyRemoved() override; const mitk::StringProperty *m_StringProperty; }; #endif diff --git a/Modules/QtWidgetsExt/include/QmitkTransferFunctionCanvas.h b/Modules/QtWidgetsExt/include/QmitkTransferFunctionCanvas.h index 1fae56fe2e..8969ae058f 100755 --- a/Modules/QtWidgetsExt/include/QmitkTransferFunctionCanvas.h +++ b/Modules/QtWidgetsExt/include/QmitkTransferFunctionCanvas.h @@ -1,135 +1,135 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QMITKTRANSFERFUNCTIONCANVAS_H_INCLUDED #define QMITKTRANSFERFUNCTIONCANVAS_H_INCLUDED #include "MitkQtWidgetsExtExports.h" #include #include #include #include class MITKQTWIDGETSEXT_EXPORT QmitkTransferFunctionCanvas : public QWidget { Q_OBJECT public: QmitkTransferFunctionCanvas(QWidget *parent = nullptr, Qt::WindowFlags f = nullptr); mitk::SimpleHistogram *GetHistogram() { return m_Histogram; } void SetHistogram(mitk::SimpleHistogram *histogram) { m_Histogram = histogram; } double GetMin() { return m_Min; } void SetMin(double min) { this->m_Min = min; SetLower(min); } double GetMax() { return m_Max; } void SetMax(double max) { this->m_Max = max; SetUpper(max); } double GetLower() { return m_Lower; } void SetLower(double lower) { this->m_Lower = lower; } double GetUpper() { return m_Upper; } void SetUpper(double upper) { this->m_Upper = upper; } void mousePressEvent(QMouseEvent *mouseEvent) override; - virtual void paintEvent(QPaintEvent *e) override; + void paintEvent(QPaintEvent *e) override; virtual void DoubleClickOnHandle(int handle) = 0; void mouseMoveEvent(QMouseEvent *mouseEvent) override; void mouseReleaseEvent(QMouseEvent *mouseEvent) override; void mouseDoubleClickEvent(QMouseEvent *mouseEvent) override; void PaintHistogram(QPainter &p); virtual int GetNearHandle(int x, int y, unsigned int maxSquaredDistance = 32) = 0; virtual int AddFunctionPoint(double x, double val) = 0; virtual void RemoveFunctionPoint(double x) = 0; virtual void MoveFunctionPoint(int index, std::pair pos) = 0; virtual double GetFunctionX(int index) = 0; virtual double GetFunctionY(int index) = 0; virtual int GetFunctionSize() = 0; int m_GrabbedHandle; double m_Lower, m_Upper, m_Min, m_Max; std::pair FunctionToCanvas(std::pair); std::pair CanvasToFunction(std::pair); mitk::SimpleHistogram *m_Histogram; void keyPressEvent(QKeyEvent *e) override; void SetImmediateUpdate(bool state); std::pair ValidateCoord(std::pair x) { double max = m_Histogram->GetMax(); double min = m_Histogram->GetMin(); if (x.first < min) x.first = min; if (x.first > max) x.first = max; if (x.second < 0) x.second = 0; if (x.second > 1) x.second = 1; return x; } void SetX(float x) { if (m_GrabbedHandle != -1) { this->MoveFunctionPoint(m_GrabbedHandle, ValidateCoord(std::make_pair(x, GetFunctionY(m_GrabbedHandle)))); update(); mitk::RenderingManager::GetInstance()->RequestUpdateAll(); } } void SetY(float y) { if (m_GrabbedHandle != -1) { this->MoveFunctionPoint(m_GrabbedHandle, ValidateCoord(std::make_pair(GetFunctionX(m_GrabbedHandle), y))); update(); mitk::RenderingManager::GetInstance()->RequestUpdateAll(); } } void SetQLineEdits(QLineEdit *xEdit, QLineEdit *yEdit) { m_XEdit = xEdit; m_YEdit = yEdit; m_LineEditAvailable = true; } protected: bool m_ImmediateUpdate; float m_Range; bool m_LineEditAvailable; QLineEdit *m_XEdit; QLineEdit *m_YEdit; }; #endif diff --git a/Modules/QtWidgetsExt/include/QmitkTransferFunctionGeneratorWidget.h b/Modules/QtWidgetsExt/include/QmitkTransferFunctionGeneratorWidget.h index 55c5c6fca7..ff42f5d3d3 100644 --- a/Modules/QtWidgetsExt/include/QmitkTransferFunctionGeneratorWidget.h +++ b/Modules/QtWidgetsExt/include/QmitkTransferFunctionGeneratorWidget.h @@ -1,84 +1,84 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QMITKTRANSFERFUNCTIONGENERATORWIDGET_H #define QMITKTRANSFERFUNCTIONGENERATORWIDGET_H #include "MitkQtWidgetsExtExports.h" #include "ui_QmitkTransferFunctionGeneratorWidget.h" #include #include #include #include class MITKQTWIDGETSEXT_EXPORT QmitkTransferFunctionGeneratorWidget : public QWidget, public Ui::QmitkTransferFunctionGeneratorWidget { Q_OBJECT public: QmitkTransferFunctionGeneratorWidget(QWidget *parent = nullptr, Qt::WindowFlags f = nullptr); - ~QmitkTransferFunctionGeneratorWidget(); + ~QmitkTransferFunctionGeneratorWidget() override; void SetDataNode(mitk::DataNode *node); int AddPreset(const QString &presetName); void SetPresetsTabEnabled(bool enable); void SetThresholdTabEnabled(bool enable); void SetBellTabEnabled(bool enable); public slots: void OnSavePreset(); void OnLoadPreset(); void OnDeltaLevelWindow(int dx, int dy); void OnDeltaThreshold(int dx, int dy); signals: void SignalTransferFunctionModeChanged(int); void SignalUpdateCanvas(); protected slots: void OnPreset(int mode); protected: mitk::TransferFunctionProperty::Pointer tfpToChange; double histoMinimum; double histoMaximum; double thPos; double thDelta; double deltaScale; double deltaMax; double deltaMin; const mitk::Image::HistogramType *histoGramm; QString presetFileName; double ScaleDelta(int d) const; }; #endif diff --git a/Modules/QtWidgetsExt/include/QmitkUGCombinedRepresentationPropertyWidget.h b/Modules/QtWidgetsExt/include/QmitkUGCombinedRepresentationPropertyWidget.h index 4100b88e0b..7c4e87e3dd 100644 --- a/Modules/QtWidgetsExt/include/QmitkUGCombinedRepresentationPropertyWidget.h +++ b/Modules/QtWidgetsExt/include/QmitkUGCombinedRepresentationPropertyWidget.h @@ -1,71 +1,71 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QMITKUGCOMBINEDREPRESENTATIONPROPERTYWIDGET_H #define QMITKUGCOMBINEDREPRESENTATIONPROPERTYWIDGET_H #include "MitkQtWidgetsExtExports.h" #include namespace mitk { class GridVolumeMapperProperty; class GridRepresentationProperty; class BoolProperty; } class _UGCombinedEnumPropEditor; class _UGCombinedBoolPropEditor; /// @ingroup Widgets class MITKQTWIDGETSEXT_EXPORT QmitkUGCombinedRepresentationPropertyWidget : public QComboBox { Q_OBJECT public: QmitkUGCombinedRepresentationPropertyWidget(QWidget *parent = nullptr); - ~QmitkUGCombinedRepresentationPropertyWidget(); + ~QmitkUGCombinedRepresentationPropertyWidget() override; void SetProperty(mitk::GridRepresentationProperty *gridRepresentation, mitk::GridVolumeMapperProperty *volumeMapper, mitk::BoolProperty *volumeProp); protected slots: void OnIndexChanged(int index); protected: friend class _UGCombinedEnumPropEditor; friend class _UGCombinedBoolPropEditor; void SetGridRepresentationId(int enumId); void SetGridVolumeId(int enumId); void IsVolumeChanged(bool volume); _UGCombinedEnumPropEditor *gridRepPropEditor; _UGCombinedEnumPropEditor *volumeMapperPropEditor; _UGCombinedBoolPropEditor *volumePropEditor; int m_GridRepIndex; int m_GridVolIndex; int m_FirstVolumeRepId; QHash m_MapRepEnumToIndex; QHash m_MapVolEnumToIndex; }; #endif diff --git a/Modules/QtWidgetsExt/include/QmitkVideoBackground.h b/Modules/QtWidgetsExt/include/QmitkVideoBackground.h index 217f328697..62193875e5 100644 --- a/Modules/QtWidgetsExt/include/QmitkVideoBackground.h +++ b/Modules/QtWidgetsExt/include/QmitkVideoBackground.h @@ -1,207 +1,207 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef _Qmitk_Video_Background_h_ #define _Qmitk_Video_Background_h_ // MITK #include "MitkQtWidgetsExtExports.h" #include "mitkVideoSource.h" // Qt #include class QTimer; // vtk class vtkRenderer; class vtkRenderWindow; class vtkImageActor; class vtkImageImport; class vtkActor2D; class vtkVideoSizeCallback; class vtkObject; /** * Displays a 3-channel (!) video data in the background * of one or more vtkRenderWindow(s). * The video is provided by a mitkVideoSource / GetVideoTexture(). * Caution: As the texture data is not being copied, the user is responsible for a valid * pointer to the data. Also the image dimensions needs to be set correctly before enabling the * background. */ class MITKQTWIDGETSEXT_EXPORT QmitkVideoBackground : public QObject { Q_OBJECT public: /// /// default ctor, TimerDelay is 40 by default /// you must SetVideoSource() and AddRenderWindow() afterwards /// explicit QmitkVideoBackground(QObject *parent = nullptr); /// /// constructs a video background with the given video source /// no parent is set here, dont forget to delete the object or /// call setParent() /// TimerDelay = refresh rate of video in ms (25 ms = 40 Hz). /// you must call AddRenderWindow() afterwards /// explicit QmitkVideoBackground(mitk::VideoSource *v, int TimerDelay = 25); /// /// disables all video backgrounds /// - virtual ~QmitkVideoBackground(); + ~QmitkVideoBackground() override; /// /// \brief add a RenderWindow in which the video is displayed. /// -> must be initialized before enabling the background. /// if the renderwindow was previously inserted it will get /// re-inserted (restarted videobackground) /// *ATTENTION*: to size the renderwindow correctly GetImageWidth() of the video /// source will be called and if *no size is returned: FetchFrame() /// on the video source will be called to get the first frame and /// the corresponding size* /// void AddRenderWindow(vtkRenderWindow *renderWindow); /// /// \brief removes a renderwindow = disables video background there /// void RemoveRenderWindow(vtkRenderWindow *renderWindow); /// /// \return true if "renderWindow" is currently connected to the video /// background or not /// bool IsRenderWindowIncluded(vtkRenderWindow *renderWindow); /// /// \brief sets the update rate of the video in milli seconds, by default 25. /// void SetTimerDelay(int ms); /// /// visualizes the video. Requires image dimensions and an active videosource to be set. /// void Enable(); /// /// \brief disables visualization of the video. /// void Disable(); /// /// \brief Checks, if the Video background is currently enabled (visible). /// bool IsEnabled(); /// /// Returns the videosource attached to this background /// mitk::VideoSource *GetVideoSource(); /// /// Returns the timer delay /// int GetTimerDelay(); /// /// pauses the playback (stops the update timer) /// void Pause(); /// /// resumes the playback (restarts the update timer) /// void Resume(); /// /// sets a *new* video source (if previously enabled, this will stop /// the video background if it was previously enabled /// void SetVideoSource(mitk::VideoSource *videoSource); /// /// receive renderwindow delete events /// static void OnRenderWindowDelete(vtkObject *, unsigned long eid, void *clientdata, void * /*calldata*/); /// /// receive VideoSource delete event /// void OnVideoSourceDelete(const itk::Object *caller, const itk::EventObject &event); public slots: /// /// update all video backgrounds. (called by the timer or manually /// by the user) /// void UpdateVideo(); signals: /// /// emitted after all video backgrounds are filled with the new /// video frame /// void NewFrameAvailable(mitk::VideoSource *); void EndOfVideoSourceReached(mitk::VideoSource *); protected: /// /// class for holding all vtk dependencies /// needed to do background image rendering /// struct VideoBackgroundVectorInfo { vtkRenderWindow *renWin; vtkRenderer *videoRenderer; vtkImageActor *videoActor; vtkImageImport *videoImport; unsigned long renderWindowObserverTag; }; /// /// removes the renderwindow and also removes the observer if the flag is set /// void RemoveRenderWindow(vtkRenderWindow *renderWindow, bool removeObserver); /// /// reset all video backgrounds /// void ResetVideoBackground(); /// /// inits all renderwindows with default values, called before video rendering is started /// void Modified(); /// /// the class has to store a list of renderwindows /// typedef std::vector RenderWindowVectorInfoType; protected: /// /// a list of renderwindows and associated renderers and actors and imageimporters /// RenderWindowVectorInfoType m_renderWindowVectorInfo; /// /// calls updatevideo repeateadly for framegrabbing /// QTimer *m_QTimer; /// /// must implement GetVideoTexture() correctly (must return an OpenGL texture) /// mitk::VideoSource *m_VideoSource; /// /// the observer tag for the video source /// unsigned long m_VideoSourceObserverTag; }; #endif diff --git a/Modules/QtWidgetsExt/include/qclickablelabel.h b/Modules/QtWidgetsExt/include/qclickablelabel.h index 81866d0590..61905357e6 100644 --- a/Modules/QtWidgetsExt/include/qclickablelabel.h +++ b/Modules/QtWidgetsExt/include/qclickablelabel.h @@ -1,72 +1,72 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef qclickablelabelhincluded #define qclickablelabelhincluded #include "MitkQtWidgetsExtExports.h" #include #include #include #include "mitkCommon.h" /** \brief A QLabel with multiple hotspots, that can be clicked Specially useful in connection with a pixmap. Stretched images should be avoided, because the hotspots will not be adjusted in any way. */ class MITKQTWIDGETSEXT_EXPORT QClickableLabel : public QLabel { Q_OBJECT public: QClickableLabel(QWidget *parent, Qt::WindowFlags f = nullptr); QClickableLabel(const QString &text, QWidget *parent, Qt::WindowFlags f = nullptr); - virtual ~QClickableLabel(); + ~QClickableLabel() override; void AddHotspot(const QString &name, const QRect position); void RemoveHotspot(const QString &name); void RemoveHotspot(unsigned int hotspotIndex); void RemoveAllHotspots(); signals: void mousePressed(const QString &hotspotName); void mousePressed(unsigned int hotspotIndex); void mouseReleased(const QString &hotspotName); void mouseReleased(unsigned int hotspotIndex); protected: - virtual void mousePressEvent(QMouseEvent *e) override; - virtual void mouseReleaseEvent(QMouseEvent *e) override; + void mousePressEvent(QMouseEvent *e) override; + void mouseReleaseEvent(QMouseEvent *e) override; /// returns index == m_Hotspots.size() if nothing is hit unsigned int matchingRect(const QPoint &p); typedef std::vector RectVectorType; RectVectorType m_Hotspots; typedef std::map NameToIndexMapType; typedef std::map IndexToNameMapType; NameToIndexMapType m_HotspotIndexForName; IndexToNameMapType m_HotspotNameForIndex; }; #endif diff --git a/Modules/QtWidgetsExt/src/QmitkBoolPropertyWidget.cpp b/Modules/QtWidgetsExt/src/QmitkBoolPropertyWidget.cpp index 8cddeb98a9..b34be32af0 100644 --- a/Modules/QtWidgetsExt/src/QmitkBoolPropertyWidget.cpp +++ b/Modules/QtWidgetsExt/src/QmitkBoolPropertyWidget.cpp @@ -1,106 +1,106 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "QmitkBoolPropertyWidget.h" #include class _BoolPropertyWidgetImpl : public mitk::PropertyEditor { public: _BoolPropertyWidgetImpl(mitk::BoolProperty *property, QCheckBox *checkBox) : PropertyEditor(property), m_BoolProperty(property), m_CheckBox(checkBox) { } - virtual void PropertyChanged() override + void PropertyChanged() override { if (m_Property) m_CheckBox->setChecked(m_BoolProperty->GetValue()); } - virtual void PropertyRemoved() override + void PropertyRemoved() override { m_Property = nullptr; m_BoolProperty = nullptr; // display "no certain value" m_CheckBox->blockSignals(true); m_CheckBox->setTristate(true); m_CheckBox->setCheckState(Qt::PartiallyChecked); m_CheckBox->setEnabled(false); m_CheckBox->blockSignals(false); } void ValueChanged(bool value) { this->BeginModifyProperty(); // deregister from events m_BoolProperty->SetValue(value); this->EndModifyProperty(); // again register for events } protected: mitk::BoolProperty *m_BoolProperty; QCheckBox *m_CheckBox; }; QmitkBoolPropertyWidget::QmitkBoolPropertyWidget(QWidget *parent) : QCheckBox(parent), m_PropEditorImpl(nullptr) { setEnabled(false); connect(this, SIGNAL(toggled(bool)), this, SLOT(onToggle(bool))); } QmitkBoolPropertyWidget::QmitkBoolPropertyWidget(const QString &text, QWidget *parent) : QCheckBox(text, parent), m_PropEditorImpl(nullptr) { setEnabled(false); connect(this, SIGNAL(toggled(bool)), this, SLOT(onToggle(bool))); } QmitkBoolPropertyWidget::~QmitkBoolPropertyWidget() { delete m_PropEditorImpl; } void QmitkBoolPropertyWidget::SetProperty(mitk::BoolProperty *property) { if (m_PropEditorImpl) { delete m_PropEditorImpl; m_PropEditorImpl = nullptr; } if (!property) { setTristate(true); setCheckState(Qt::PartiallyChecked); setEnabled(false); return; } setEnabled(true); m_PropEditorImpl = new _BoolPropertyWidgetImpl(property, this); m_PropEditorImpl->PropertyChanged(); } void QmitkBoolPropertyWidget::onToggle(bool on) { if (m_PropEditorImpl) { m_PropEditorImpl->ValueChanged(on); } } diff --git a/Modules/QtWidgetsExt/src/QmitkCallbackFromGUIThread.cpp b/Modules/QtWidgetsExt/src/QmitkCallbackFromGUIThread.cpp index f5a84638a3..c4979d961f 100644 --- a/Modules/QtWidgetsExt/src/QmitkCallbackFromGUIThread.cpp +++ b/Modules/QtWidgetsExt/src/QmitkCallbackFromGUIThread.cpp @@ -1,74 +1,74 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "QmitkCallbackFromGUIThread.h" #include #include /// This kind of object is posted into the Qt event queue in order to call some method from the GUI thread class QmitkCallbackEvent : public QEvent { public: QmitkCallbackEvent(itk::Command *cmd, itk::EventObject *e) : QEvent(QEvent::User), m_Command(cmd), m_Event(e) {} - ~QmitkCallbackEvent() { delete m_Event; } + ~QmitkCallbackEvent() override { delete m_Event; } itk::Command *command() { return m_Command; } itk::EventObject *itkevent() { return m_Event; } protected: itk::Command::Pointer m_Command; itk::EventObject *m_Event; }; QmitkCallbackFromGUIThread::QmitkCallbackFromGUIThread() { mitk::CallbackFromGUIThread::RegisterImplementation(this); } QmitkCallbackFromGUIThread::~QmitkCallbackFromGUIThread() { } void QmitkCallbackFromGUIThread::CallThisFromGUIThread(itk::Command *cmd, itk::EventObject *e) { QApplication::instance()->postEvent(this, new QmitkCallbackEvent(cmd, e)); } bool QmitkCallbackFromGUIThread::event(QEvent *e) { QmitkCallbackEvent *event(dynamic_cast(e)); if (!event) return false; itk::Command *cmd(event->command()); if (cmd) { if (event->itkevent()) { cmd->Execute((const itk::Object *)nullptr, // no itk::Object here *(event->itkevent())); } else { const itk::NoEvent dummyEvent; cmd->Execute((const itk::Object *)nullptr, // no itk::Object here dummyEvent); } } return true; } diff --git a/Modules/QtWidgetsExt/src/QmitkEnumerationPropertyWidget.cpp b/Modules/QtWidgetsExt/src/QmitkEnumerationPropertyWidget.cpp index 258ad9f452..b3637528df 100644 --- a/Modules/QtWidgetsExt/src/QmitkEnumerationPropertyWidget.cpp +++ b/Modules/QtWidgetsExt/src/QmitkEnumerationPropertyWidget.cpp @@ -1,110 +1,110 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "QmitkEnumerationPropertyWidget.h" #include #include class _EnumPropEditorImpl : public mitk::PropertyEditor { public: _EnumPropEditorImpl(mitk::EnumerationProperty *property, QComboBox *combo, const QHash &enumIdToItemIndex) : PropertyEditor(property), m_EnumerationProperty(property), m_ComboBox(combo), m_EnumIdToItemIndex(enumIdToItemIndex) { } - ~_EnumPropEditorImpl() { m_EnumerationProperty = nullptr; } + ~_EnumPropEditorImpl() override { m_EnumerationProperty = nullptr; } void IndexChanged(int enumId) { this->BeginModifyProperty(); m_EnumerationProperty->SetValue(enumId); this->EndModifyProperty(); } - virtual void PropertyChanged() override + void PropertyChanged() override { if (m_EnumerationProperty) { m_ComboBox->setCurrentIndex(m_EnumIdToItemIndex[m_EnumerationProperty->GetValueAsId()]); } } - virtual void PropertyRemoved() override + void PropertyRemoved() override { m_Property = nullptr; m_EnumerationProperty = nullptr; m_ComboBox->setEnabled(false); } protected: mitk::EnumerationProperty *m_EnumerationProperty; QComboBox *m_ComboBox; QHash m_EnumIdToItemIndex; }; QmitkEnumerationPropertyWidget::QmitkEnumerationPropertyWidget(QWidget *parent) : QComboBox(parent), propView(nullptr) { connect(this, SIGNAL(currentIndexChanged(int)), this, SLOT(OnIndexChanged(int))); } QmitkEnumerationPropertyWidget::~QmitkEnumerationPropertyWidget() { delete propView; } void QmitkEnumerationPropertyWidget::SetProperty(mitk::EnumerationProperty *property) { if (propView) { delete propView; propView = nullptr; } this->clear(); if (!property) { return; } this->setEnabled(true); QHash enumIdToItemIndex; const mitk::EnumerationProperty::EnumStringsContainerType &strings = property->GetEnumStrings(); int index = 0; for (auto it = strings.begin(); it != strings.end(); ++it, ++index) { enumIdToItemIndex.insert(it->second, index); this->addItem(QString::fromStdString(it->first), it->second); } propView = new _EnumPropEditorImpl(property, this, enumIdToItemIndex); propView->PropertyChanged(); } void QmitkEnumerationPropertyWidget::OnIndexChanged(int index) { if (propView) { int enumIndex = this->itemData(index, Qt::UserRole).toInt(); propView->IndexChanged(enumIndex); } } diff --git a/Modules/QtWidgetsExt/src/QmitkNumberPropertySlider.cpp b/Modules/QtWidgetsExt/src/QmitkNumberPropertySlider.cpp index 446c869bb5..64c84ebd7d 100644 --- a/Modules/QtWidgetsExt/src/QmitkNumberPropertySlider.cpp +++ b/Modules/QtWidgetsExt/src/QmitkNumberPropertySlider.cpp @@ -1,345 +1,345 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include #include #include #include #define DT_SHORT 1 #define DT_INT 2 #define DT_FLOAT 3 #define DT_DOUBLE 4 #define ROUND(x) (((x) > 0) ? int((x) + 0.5) : int((x)-0.5)) #define ROUND_SHORT(x) (((x) > 0) ? short((x) + 0.5) : short((x)-0.5)) class QmitkNumberPropertySlider::Impl { public: Impl(QmitkNumberPropertySlider *q); void DisplayNumber(); void adjustFactors(short, bool); class Editor : public mitk::PropertyEditor { public: Editor(mitk::IntProperty *, Impl *impl); Editor(mitk::FloatProperty *, Impl *impl); Editor(mitk::DoubleProperty *, Impl *impl); - virtual void PropertyChanged() override; - virtual void PropertyRemoved() override; + void PropertyChanged() override; + void PropertyRemoved() override; void BeginModifyProperty() { mitk::PropertyEditor::BeginModifyProperty(); } void EndModifyProperty() { mitk::PropertyEditor::EndModifyProperty(); } union { mitk::GenericProperty *m_IntProperty; mitk::GenericProperty *m_FloatProperty; mitk::GenericProperty *m_DoubleProperty; }; const int m_DataType; private: Impl *m_Impl; }; std::unique_ptr m_PropEditor; short m_DecimalPlaces; // how many decimal places are shown double m_FactorPropertyToSlider; // internal conversion factor. neccessary because slider ranges work only with ints double m_FactorSliderToDisplay; // internal conversion factor. neccessary because slider ranges work only with ints bool m_ShowPercents; // whether values are given in percent (0.5 -> 50%) bool m_SelfChangeLock; private: void initialize(); QmitkNumberPropertySlider *q; }; QmitkNumberPropertySlider::Impl::Editor::Editor(mitk::IntProperty *property, Impl *impl) : mitk::PropertyEditor(property), m_IntProperty(property), m_DataType(DT_INT), m_Impl(impl) { } QmitkNumberPropertySlider::Impl::Editor::Editor(mitk::FloatProperty *property, Impl *impl) : mitk::PropertyEditor(property), m_FloatProperty(property), m_DataType(DT_FLOAT), m_Impl(impl) { } QmitkNumberPropertySlider::Impl::Editor::Editor(mitk::DoubleProperty *property, Impl *impl) : mitk::PropertyEditor(property), m_DoubleProperty(property), m_DataType(DT_DOUBLE), m_Impl(impl) { } QmitkNumberPropertySlider::~QmitkNumberPropertySlider() { } void QmitkNumberPropertySlider::SetProperty(mitk::IntProperty *property) { if (property == nullptr) { d->m_PropEditor.reset(); this->setEnabled(false); } else { d->m_PropEditor.reset(new Impl::Editor(property, d.get())); d->m_PropEditor->PropertyChanged(); this->setEnabled(true); } } void QmitkNumberPropertySlider::SetProperty(mitk::FloatProperty *property) { if (property == nullptr) { d->m_PropEditor.reset(); this->setEnabled(false); } else { d->m_PropEditor.reset(new Impl::Editor(property, d.get())); d->m_PropEditor->PropertyChanged(); this->setEnabled(true); } } void QmitkNumberPropertySlider::SetProperty(mitk::DoubleProperty *property) { if (property == nullptr) { d->m_PropEditor.reset(); this->setEnabled(false); } else { d->m_PropEditor.reset(new Impl::Editor(property, d.get())); d->m_PropEditor->PropertyChanged(); this->setEnabled(true); } } QmitkNumberPropertySlider::Impl::Impl(QmitkNumberPropertySlider *q) : m_DecimalPlaces(0), m_FactorPropertyToSlider(1.0), m_FactorSliderToDisplay(1.0), m_ShowPercents(false), m_SelfChangeLock(false), q(q) { } QmitkNumberPropertySlider::QmitkNumberPropertySlider(QWidget *parent) : QSlider(parent), d(new Impl(this)) { connect(this, SIGNAL(valueChanged(int)), this, SLOT(onValueChanged(int))); this->setEnabled(false); } void QmitkNumberPropertySlider::Impl::adjustFactors(short newDecimalPlaces, bool newShowPercents) { int oldMax = q->maxValue(); int oldMin = q->minValue(); m_DecimalPlaces = newDecimalPlaces; m_ShowPercents = newShowPercents; m_FactorPropertyToSlider = pow(10.0, m_DecimalPlaces); m_FactorSliderToDisplay = 1.0 / m_FactorPropertyToSlider; if (m_ShowPercents) m_FactorPropertyToSlider *= 100.0; q->setMinimum(oldMin); q->setMaximum(oldMax); } short QmitkNumberPropertySlider::getDecimalPlaces() const { return d->m_DecimalPlaces; } void QmitkNumberPropertySlider::setDecimalPlaces(short places) { if (d->m_PropEditor.get() == nullptr) return; switch (d->m_PropEditor->m_DataType) { case DT_FLOAT: case DT_DOUBLE: { d->adjustFactors(places, d->m_ShowPercents); d->DisplayNumber(); break; } default: break; } } bool QmitkNumberPropertySlider::getShowPercent() const { return d->m_ShowPercents; } void QmitkNumberPropertySlider::setShowPercent(bool showPercent) { if (showPercent == d->m_ShowPercents) return; // nothing to change if (d->m_PropEditor.get() == nullptr) return; switch (d->m_PropEditor->m_DataType) { case DT_FLOAT: case DT_DOUBLE: { d->adjustFactors(d->m_DecimalPlaces, showPercent); break; } default: { break; } } d->DisplayNumber(); } int QmitkNumberPropertySlider::minValue() const { return ROUND(QSlider::minimum() / d->m_FactorPropertyToSlider); } void QmitkNumberPropertySlider::setMinValue(int value) { QSlider::setMinimum(ROUND(value * d->m_FactorPropertyToSlider)); } int QmitkNumberPropertySlider::maxValue() const { return ROUND(QSlider::maximum() / d->m_FactorPropertyToSlider); } void QmitkNumberPropertySlider::setMaxValue(int value) { QSlider::setMaximum(ROUND(value * d->m_FactorPropertyToSlider)); } double QmitkNumberPropertySlider::doubleValue() const { return static_cast((QSlider::value()) / d->m_FactorPropertyToSlider); } void QmitkNumberPropertySlider::setDoubleValue(double value) { QSlider::setValue(ROUND(value * d->m_FactorPropertyToSlider)); } void QmitkNumberPropertySlider::onValueChanged(int value) { if (d->m_PropEditor.get() == nullptr) return; if (d->m_SelfChangeLock) return; // valueChanged is even emitted, when this widget initiates a change to its value // this may be useful some times, but in this use, it would be wrong: // (A) is an editor with 3 decimal places // (B) is an editor with 2 decimal places // User changes A's displayed value to 4.002 // A's onValueChanged gets called, sets the associated Property to 4.002 // B's onPropertyChanged gets called, sets its display to 4.00 // B's onValueChanged gets called and sets the associated Property to 4.00 // A's onPropertyChanged gets called, sets its display to 4.000 d->m_PropEditor->BeginModifyProperty(); double newValue(value / d->m_FactorPropertyToSlider); switch (d->m_PropEditor->m_DataType) { case DT_INT: { d->m_PropEditor->m_IntProperty->SetValue(ROUND(newValue)); break; } case DT_FLOAT: { d->m_PropEditor->m_FloatProperty->SetValue(newValue); break; } case DT_DOUBLE: { d->m_PropEditor->m_DoubleProperty->SetValue(newValue); break; } } mitk::RenderingManager::GetInstance()->RequestUpdateAll(); d->m_PropEditor->EndModifyProperty(); } void QmitkNumberPropertySlider::Impl::Editor::PropertyChanged() { m_Impl->DisplayNumber(); mitk::RenderingManager::GetInstance()->RequestUpdateAll(); } void QmitkNumberPropertySlider::Impl::Editor::PropertyRemoved() { this->m_Property = nullptr; } void QmitkNumberPropertySlider::Impl::DisplayNumber() { if (m_PropEditor.get() == nullptr) return; m_SelfChangeLock = true; switch (m_PropEditor->m_DataType) { case DT_INT: { int i = m_PropEditor->m_IntProperty->GetValue(); q->setValue(i); break; } case DT_FLOAT: { float f = m_PropEditor->m_FloatProperty->GetValue(); q->setDoubleValue(f); break; } case DT_DOUBLE: { double d = m_PropEditor->m_DoubleProperty->GetValue(); q->setDoubleValue(d); break; } default: break; } m_SelfChangeLock = false; } diff --git a/Modules/QtWidgetsExt/src/QmitkUGCombinedRepresentationPropertyWidget.cpp b/Modules/QtWidgetsExt/src/QmitkUGCombinedRepresentationPropertyWidget.cpp index 7d79e3ab78..c41a50ea02 100644 --- a/Modules/QtWidgetsExt/src/QmitkUGCombinedRepresentationPropertyWidget.cpp +++ b/Modules/QtWidgetsExt/src/QmitkUGCombinedRepresentationPropertyWidget.cpp @@ -1,265 +1,265 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "QmitkUGCombinedRepresentationPropertyWidget.h" #include #include #include #include class _UGCombinedBoolPropEditor : public mitk::PropertyEditor { public: _UGCombinedBoolPropEditor(mitk::BoolProperty *boolProp, QmitkUGCombinedRepresentationPropertyWidget *combo) : PropertyEditor(boolProp), m_BoolProperty(boolProp), m_ComboBox(combo) { PropertyChanged(); } - virtual ~_UGCombinedBoolPropEditor() {} + ~_UGCombinedBoolPropEditor() override {} bool IsEnabled() const { return enabled; } void SetEnabled(bool enable) { this->BeginModifyProperty(); m_BoolProperty->SetValue(enable); this->EndModifyProperty(); } protected: - virtual void PropertyChanged() override + void PropertyChanged() override { if (m_BoolProperty) enabled = m_BoolProperty->GetValue(); else enabled = false; m_ComboBox->IsVolumeChanged(enabled); } - virtual void PropertyRemoved() override + void PropertyRemoved() override { m_Property = nullptr; m_BoolProperty = nullptr; enabled = false; } mitk::BoolProperty *m_BoolProperty; QmitkUGCombinedRepresentationPropertyWidget *m_ComboBox; bool enabled; }; class _UGCombinedEnumPropEditor : public mitk::PropertyEditor { public: _UGCombinedEnumPropEditor(mitk::EnumerationProperty *property, QmitkUGCombinedRepresentationPropertyWidget *combo, bool isVolumeProp) : PropertyEditor(property), m_EnumerationProperty(property), m_ComboBox(combo), m_IsVolumeProp(isVolumeProp) { } - ~_UGCombinedEnumPropEditor() { m_EnumerationProperty = nullptr; } + ~_UGCombinedEnumPropEditor() override { m_EnumerationProperty = nullptr; } void IndexChanged(int enumId) { this->BeginModifyProperty(); m_EnumerationProperty->SetValue(enumId); this->EndModifyProperty(); } - virtual void PropertyChanged() override + void PropertyChanged() override { if (m_EnumerationProperty) { if (m_IsVolumeProp) { m_ComboBox->SetGridVolumeId(m_EnumerationProperty->GetValueAsId()); } else { m_ComboBox->SetGridRepresentationId(m_EnumerationProperty->GetValueAsId()); } } } - virtual void PropertyRemoved() override + void PropertyRemoved() override { m_Property = nullptr; m_EnumerationProperty = nullptr; } protected: mitk::EnumerationProperty *m_EnumerationProperty; QmitkUGCombinedRepresentationPropertyWidget *m_ComboBox; QHash m_EnumIdToItemIndex; bool m_IsVolumeProp; }; QmitkUGCombinedRepresentationPropertyWidget::QmitkUGCombinedRepresentationPropertyWidget(QWidget *parent) : QComboBox(parent), gridRepPropEditor(nullptr), volumeMapperPropEditor(nullptr), volumePropEditor(nullptr), m_GridRepIndex(0), m_GridVolIndex(0), m_FirstVolumeRepId(0) { connect(this, SIGNAL(currentIndexChanged(int)), this, SLOT(OnIndexChanged(int))); } QmitkUGCombinedRepresentationPropertyWidget::~QmitkUGCombinedRepresentationPropertyWidget() { delete gridRepPropEditor; delete volumeMapperPropEditor; delete volumePropEditor; } void QmitkUGCombinedRepresentationPropertyWidget::SetProperty(mitk::GridRepresentationProperty *gridRepProp, mitk::GridVolumeMapperProperty *gridVolProp, mitk::BoolProperty *volumeProp) { if (gridRepPropEditor) { delete gridRepPropEditor; gridRepPropEditor = nullptr; } if (volumeMapperPropEditor) { delete volumeMapperPropEditor; volumeMapperPropEditor = nullptr; } if (volumePropEditor) { delete volumePropEditor; volumePropEditor = nullptr; } this->clear(); this->setEnabled(true); m_FirstVolumeRepId = 0; m_MapRepEnumToIndex.clear(); m_MapVolEnumToIndex.clear(); if (!gridRepProp && !gridVolProp) return; int i = 0; if (gridRepProp) { const mitk::EnumerationProperty::EnumStringsContainerType &repStrings = gridRepProp->GetEnumStrings(); for (auto it = repStrings.begin(); it != repStrings.end(); ++it, ++i) { m_MapRepEnumToIndex.insert(it->second, i); this->addItem(QString::fromStdString(it->first), it->second); } m_FirstVolumeRepId = i; } if (gridVolProp) { const mitk::EnumerationProperty::EnumStringsContainerType &volStrings = gridVolProp->GetEnumStrings(); for (auto it = volStrings.begin(); it != volStrings.end(); ++it, ++i) { m_MapVolEnumToIndex.insert(it->second, i); this->addItem(QString("Volume (") + QString::fromStdString(it->first) + ")", it->second); } } if (gridRepProp) { gridRepPropEditor = new _UGCombinedEnumPropEditor(gridRepProp, this, false); } if (gridVolProp) { volumeMapperPropEditor = new _UGCombinedEnumPropEditor(gridVolProp, this, true); } if (volumeProp) { volumePropEditor = new _UGCombinedBoolPropEditor(volumeProp, this); } if (gridRepProp) { this->SetGridRepresentationId(gridRepProp->GetValueAsId()); } if (gridVolProp) { this->SetGridVolumeId(gridVolProp->GetValueAsId()); } } void QmitkUGCombinedRepresentationPropertyWidget::OnIndexChanged(int index) { int enumIndex = this->itemData(index, Qt::UserRole).toInt(); if (index < m_FirstVolumeRepId && gridRepPropEditor) { gridRepPropEditor->IndexChanged(enumIndex); if (volumePropEditor) { volumePropEditor->SetEnabled(false); } } else if (volumeMapperPropEditor) { volumeMapperPropEditor->IndexChanged(enumIndex); if (volumePropEditor) { volumePropEditor->SetEnabled(true); } } } void QmitkUGCombinedRepresentationPropertyWidget::SetGridRepresentationId(int enumId) { m_GridRepIndex = enumId; if (volumePropEditor && volumePropEditor->IsEnabled()) { return; } else { this->setCurrentIndex(m_MapRepEnumToIndex[enumId]); } } void QmitkUGCombinedRepresentationPropertyWidget::SetGridVolumeId(int enumId) { m_GridVolIndex = enumId; if (volumePropEditor && volumePropEditor->IsEnabled()) { this->setCurrentIndex(m_MapVolEnumToIndex[enumId]); } else { return; } } void QmitkUGCombinedRepresentationPropertyWidget::IsVolumeChanged(bool volume) { if (volume) { this->SetGridVolumeId(m_GridVolIndex); } else { this->SetGridRepresentationId(m_GridRepIndex); } } diff --git a/Modules/RDF/Testing/mitkRdfStoreTest.cpp b/Modules/RDF/Testing/mitkRdfStoreTest.cpp index 40b600d699..63c40a6781 100644 --- a/Modules/RDF/Testing/mitkRdfStoreTest.cpp +++ b/Modules/RDF/Testing/mitkRdfStoreTest.cpp @@ -1,159 +1,159 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "mitkTestingMacros.h" #include #include #include "mitkRdfStore.h" #include #include class mitkRdfStoreTestSuite : public mitk::TestFixture { CPPUNIT_TEST_SUITE(mitkRdfStoreTestSuite); // List of Tests MITK_TEST(TestAddPrefix); MITK_TEST(TestAddTriple); MITK_TEST(TestRemoveTriple); MITK_TEST(TestQueryTriple); MITK_TEST(TestSaveStore); MITK_TEST(TestImportStore); MITK_TEST(ExecuteBooleanQuery_PatternHasSolution_ReturnsTrue); MITK_TEST(ExecuteBooleanQuery_PatternDoesNotHaveSolution_ReturnsFalse); MITK_TEST(ExecuteBooleanQuery_MalformedBooleanQuery_ThrowsException); MITK_TEST(ExecuteBooleanQuery_NonBooleanQuery_ThrowsException); CPPUNIT_TEST_SUITE_END(); private: mitk::RdfStore store; mitk::RdfTriple triple; public: - void setUp() + void setUp() override { store.SetBaseUri(mitk::RdfUri("http://mitk.org/wiki/MITK/data/instances.rdf#")); store.AddPrefix("dcterms", mitk::RdfUri("http://purl.org/dc/terms/")); store.AddPrefix("mitk", mitk::RdfUri("http://mitk.org/wiki/MITK/data/BaseOntology.rdf#")); triple = mitk::RdfTriple(mitk::RdfNode(mitk::RdfUri("http://mitk.org/wiki/MITK/data/instances.rdf#i0012")), mitk::RdfNode(mitk::RdfUri("dcterms:title")), mitk::RdfNode("TestImage")); } - void tearDown() + void tearDown() override { store.CleanUp(); } // Test functions void TestAddPrefix() { mitk::RdfUri fma = mitk::RdfUri("http://www.bioontology.org/projects/ontologies/fma/"); store.AddPrefix("fma", fma); std::map testMap = store.GetPrefixes(); CPPUNIT_ASSERT(testMap.find("fma") != testMap.end()); } void TestAddTriple() { store.Add(triple); CPPUNIT_ASSERT(store.Contains(triple)); } void TestRemoveTriple() { store.Add(triple); store.Remove(triple); CPPUNIT_ASSERT(!store.Contains(triple)); } void TestQueryTriple() { store.Add(triple); std::string query = "SELECT ?x WHERE { ?x ?z ?y . }"; mitk::RdfStore::ResultMap queryResult = store.ExecuteTupleQuery(query); std::list list = queryResult["x"]; CPPUNIT_ASSERT(triple.GetTripleSubject() == list.back()); } void TestSaveStore() { store.Add(triple); std::ofstream tmpStream; const std::string tmpFileName = mitk::IOUtil::CreateTemporaryFile(tmpStream); store.Save(tmpFileName); std::ifstream in(tmpFileName); std::string s((std::istreambuf_iterator(in)), std::istreambuf_iterator()); in.close(); MITK_INFO << s; tmpStream.close(); std::size_t found = s.find(":i0012"); CPPUNIT_ASSERT(found!=std::string::npos); } void TestImportStore() { std::ofstream tmpStream; const std::string tmpFileName = mitk::IOUtil::CreateTemporaryFile(tmpStream); const std::string strRDF = "@base . @prefix rdf: . @prefix : <> . @prefix dcterms: . @prefix mitk: . @prefix owl: . @prefix rdfs: . @prefix xsd: . :i0012 'TestImage' ."; tmpStream << strRDF; tmpStream.close(); store.Import("file:"+tmpFileName); CPPUNIT_ASSERT(store.Contains(triple)); } void ExecuteBooleanQuery_PatternHasSolution_ReturnsTrue(void) { store.Add(triple); const std::string query = "ASK { 'TestImage' }"; CPPUNIT_ASSERT_EQUAL(true, store.ExecuteBooleanQuery(query)); } void ExecuteBooleanQuery_PatternDoesNotHaveSolution_ReturnsFalse(void) { const std::string query = "ASK { 'TestImage' }"; CPPUNIT_ASSERT_EQUAL(false, store.ExecuteBooleanQuery(query)); } void ExecuteBooleanQuery_MalformedBooleanQuery_ThrowsException(void) { const std::string query = "ASK { TestImage }"; CPPUNIT_ASSERT_THROW(store.ExecuteBooleanQuery(query), mitk::Exception); } void ExecuteBooleanQuery_NonBooleanQuery_ThrowsException(void) { const std::string query = "SELECT ?x ?y ?z WHERE { ?x ?y ?z }"; CPPUNIT_ASSERT_THROW(store.ExecuteBooleanQuery(query), mitk::Exception); } }; MITK_TEST_SUITE_REGISTRATION(mitkRdfStore) diff --git a/Modules/RDF/Testing/mitkRdfTripleTest.cpp b/Modules/RDF/Testing/mitkRdfTripleTest.cpp index 75f70deca2..ee92ec3ec1 100644 --- a/Modules/RDF/Testing/mitkRdfTripleTest.cpp +++ b/Modules/RDF/Testing/mitkRdfTripleTest.cpp @@ -1,120 +1,120 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "mitkTestingMacros.h" #include #include #include "mitkRdfTriple.h" class mitkRdfTripleTestSuite : public mitk::TestFixture { CPPUNIT_TEST_SUITE(mitkRdfTripleTestSuite); // List of Tests MITK_TEST(TestEmptyTriple); MITK_TEST(TestObjectTriple); MITK_TEST(TestDataTriple); MITK_TEST(TestSubjectOfTriple); MITK_TEST(TestPredicateOfTriple); MITK_TEST(TestObjectOfTripleAsObject); MITK_TEST(TestObjectOfTripleAsData); CPPUNIT_TEST_SUITE_END(); private: mitk::RdfTriple emptyTriple; mitk::RdfUri seg; mitk::RdfUri title; public: - void setUp() + void setUp() override { emptyTriple = mitk::RdfTriple(); title = mitk::RdfUri("dcterms:title"); seg = mitk::RdfUri("http://mitk.org/wiki/MITK/data/instance.rdf#s0001"); } - void tearDown() + void tearDown() override { } // Test functions void TestEmptyTriple() { mitk::RdfTriple anotherTriple = mitk::RdfTriple( mitk::RdfNode(), mitk::RdfNode(), mitk::RdfNode()); CPPUNIT_ASSERT(emptyTriple == anotherTriple); } void TestObjectTriple() { mitk::RdfUri src = mitk::RdfUri("dcterms:source"); mitk::RdfUri image = mitk::RdfUri("http://mitk.org/wiki/MITK/data/instance.rdf#i0012"); mitk::RdfTriple objectTriple = mitk::RdfTriple( mitk::RdfNode(seg), mitk::RdfNode(src), mitk::RdfNode(image)); emptyTriple.SetTripleSubject(seg); emptyTriple.SetTriplePredicate(src); emptyTriple.SetTripleObject(mitk::RdfNode(image)); CPPUNIT_ASSERT(emptyTriple == objectTriple); } void TestDataTriple() { mitk::RdfTriple dataTriple = mitk::RdfTriple( mitk::RdfNode(seg), mitk::RdfNode(title), "TestLiver"); emptyTriple.SetTripleSubject(seg); emptyTriple.SetTriplePredicate(title); emptyTriple.SetTripleObject("TestLiver"); CPPUNIT_ASSERT(emptyTriple == dataTriple); } void TestSubjectOfTriple() { mitk::RdfTriple triple = mitk::RdfTriple( mitk::RdfNode(seg), mitk::RdfNode(title), "KidneyLeft"); CPPUNIT_ASSERT(triple.GetTripleSubject() == mitk::RdfNode(seg)); } void TestPredicateOfTriple() { mitk::RdfTriple triple = mitk::RdfTriple( mitk::RdfNode(seg), mitk::RdfNode(title), "KidneyRight"); CPPUNIT_ASSERT(triple.GetTriplePredicate() == mitk::RdfNode(title)); } void TestObjectOfTripleAsObject() { mitk::RdfNode image = mitk::RdfNode( mitk::RdfUri("http://mitk.org/wiki/MITK/data/instance.rdf#i0012")); mitk::RdfTriple triple = mitk::RdfTriple( mitk::RdfNode(seg), mitk::RdfNode(mitk::RdfUri("dcterms:source")), image); CPPUNIT_ASSERT(triple.GetTripleObject() == image); } void TestObjectOfTripleAsData() { mitk::RdfTriple triple = mitk::RdfTriple( mitk::RdfNode(seg), mitk::RdfNode(mitk::RdfUri("mitk:volumeInMl")), "450"); CPPUNIT_ASSERT(triple.GetTripleObject() == mitk::RdfNode("450")); } }; MITK_TEST_SUITE_REGISTRATION(mitkRdfTriple) diff --git a/Modules/RDF/Testing/mitkRdfUriTest.cpp b/Modules/RDF/Testing/mitkRdfUriTest.cpp index 206dbaee51..f6f5b80242 100644 --- a/Modules/RDF/Testing/mitkRdfUriTest.cpp +++ b/Modules/RDF/Testing/mitkRdfUriTest.cpp @@ -1,74 +1,74 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "mitkTestingMacros.h" #include #include #include "mitkRdfUri.h" class mitkRdfUriTestSuite : public mitk::TestFixture { CPPUNIT_TEST_SUITE(mitkRdfUriTestSuite); // List of Tests MITK_TEST(TestEmptyUri); MITK_TEST(TestValueOfUri); MITK_TEST(TestSetUri); CPPUNIT_TEST_SUITE_END(); private: mitk::RdfUri m_EmptyUri; std::string m_UriText; mitk::RdfUri m_Uri; public: - void setUp() + void setUp() override { // normal URI m_UriText = "http://mitk.org/wiki/MITK/data/BaseOntology.rdf#"; m_Uri = mitk::RdfUri(m_UriText); } - void tearDown() + void tearDown() override { } // Test functions void TestEmptyUri() { mitk::RdfUri anotherEmptyUri(""); CPPUNIT_ASSERT(m_EmptyUri == anotherEmptyUri); } void TestValueOfUri() { CPPUNIT_ASSERT(m_Uri.ToString().compare(m_UriText) == 0); } void TestSetUri() { mitk::RdfUri newUri; newUri.SetUri(m_UriText); CPPUNIT_ASSERT(newUri == m_Uri); } }; MITK_TEST_SUITE_REGISTRATION(mitkRdfUri) diff --git a/Modules/RTUI/Qmitk/QmitkDoseColorDelegate.h b/Modules/RTUI/Qmitk/QmitkDoseColorDelegate.h index f42463989a..e52caac6c0 100644 --- a/Modules/RTUI/Qmitk/QmitkDoseColorDelegate.h +++ b/Modules/RTUI/Qmitk/QmitkDoseColorDelegate.h @@ -1,44 +1,44 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QmitkDoseColorDelegate_h #define QmitkDoseColorDelegate_h #include #include "MitkRTUIExports.h" /** \class QmitkDoseColorDelegate \brief An item delegate for rendering and editing dose color in a QTableView.*/ class MITKRTUI_EXPORT QmitkDoseColorDelegate : public QStyledItemDelegate { Q_OBJECT public: /// /// Creates a new PropertyDelegate. /// explicit QmitkDoseColorDelegate(QObject *parent = 0); bool editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option, - const QModelIndex &index); + const QModelIndex &index) override; void paint(QPainter *painter, const QStyleOptionViewItem &option, - const QModelIndex &index) const; + const QModelIndex &index) const override; }; #endif diff --git a/Modules/RTUI/Qmitk/QmitkDoseValueDelegate.h b/Modules/RTUI/Qmitk/QmitkDoseValueDelegate.h index 8f7cf66ba5..95a76a4c76 100644 --- a/Modules/RTUI/Qmitk/QmitkDoseValueDelegate.h +++ b/Modules/RTUI/Qmitk/QmitkDoseValueDelegate.h @@ -1,63 +1,63 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QmitkDoseValueDelegate_h #define QmitkDoseValueDelegate_h #include #include "MitkRTUIExports.h" /** \class QmitkDoseValueDelegate \brief An item delegate for rendering and editing dose values. The delegate assumes that the model uses the role Qt::UserRole+1 to indicate if the returned dose value is an absolute (data(Qt::UserRole+1) == true) or an relative dose (data(Qt::UserRole+1) == false).*/ class MITKRTUI_EXPORT QmitkDoseValueDelegate : public QStyledItemDelegate { Q_OBJECT public: /// /// Creates a new PropertyDelegate. /// explicit QmitkDoseValueDelegate(QObject *parent = 0); /// /// Renders a specific property (overwritten from QItemDelegate) /// void paint(QPainter *painter, const QStyleOptionViewItem &option - , const QModelIndex &index) const; + , const QModelIndex &index) const override; /// /// Create an editor for a specific property (overwritten from QItemDelegate) /// QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option - , const QModelIndex &index) const; + , const QModelIndex &index) const override; /// /// Create an editor for a specific property (overwritten from QItemDelegate) /// - void setEditorData(QWidget *editor, const QModelIndex &index) const; + void setEditorData(QWidget *editor, const QModelIndex &index) const override; /// /// When the user accepts input this func commits the data to the model (overwritten from QItemDelegate) /// - void setModelData(QWidget *editor, QAbstractItemModel* model, const QModelIndex &index) const; + void setModelData(QWidget *editor, QAbstractItemModel* model, const QModelIndex &index) const override; }; #endif /* QMITKPROPERTIESTABLEMODEL_H_ */ diff --git a/Modules/RTUI/Qmitk/QmitkDoseVisualStyleDelegate.h b/Modules/RTUI/Qmitk/QmitkDoseVisualStyleDelegate.h index d00fe17f17..790d1b1e33 100644 --- a/Modules/RTUI/Qmitk/QmitkDoseVisualStyleDelegate.h +++ b/Modules/RTUI/Qmitk/QmitkDoseVisualStyleDelegate.h @@ -1,47 +1,47 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QmitkDoseVisualStyleDelegate_h #define QmitkDoseVisualStyleDelegate_h /// Toolkit includes. #include #include "MitkRTUIExports.h" /** \class QmitkDoseVisualStyleDelegate \brief An item delegate for rendering and editing dose visualization options. The delegate is used to handle aspects of a isodose level like visualization of the isodose lines or colorwash display.*/ class MITKRTUI_EXPORT QmitkDoseVisualStyleDelegate : public QStyledItemDelegate { Q_OBJECT public: explicit QmitkDoseVisualStyleDelegate(QObject *parent = 0); void paint(QPainter *painter, const QStyleOptionViewItem &option - , const QModelIndex &index) const; + , const QModelIndex &index) const override; bool editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option, - const QModelIndex &index); + const QModelIndex &index) override; }; #endif diff --git a/Modules/RTUI/Qmitk/QmitkIsoDoseLevelSetModel.h b/Modules/RTUI/Qmitk/QmitkIsoDoseLevelSetModel.h index 78f8a85c1c..bcf516d2ce 100644 --- a/Modules/RTUI/Qmitk/QmitkIsoDoseLevelSetModel.h +++ b/Modules/RTUI/Qmitk/QmitkIsoDoseLevelSetModel.h @@ -1,98 +1,98 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QmitkIsoDoseLevelSetModel_h #define QmitkIsoDoseLevelSetModel_h #include #include "mitkIsoDoseLevelCollections.h" #include "MitkRTUIExports.h" /*! \class QmitkIsoDoseLevelSetModel Model that handles a iso dose level set and allows viewing and editing of its contents. Please see special delegates (QmitkDoseColorDelegate, QmitkDoseValueDelegate, QmitkDoseVisualStyleDelegate) to handle visualization and editing in views that work on this model. \warning This class is not yet documented. Use "git blame" and ask the author to provide basic documentation. */ class MITKRTUI_EXPORT QmitkIsoDoseLevelSetModel : public QAbstractTableModel { Q_OBJECT public: explicit QmitkIsoDoseLevelSetModel(QObject *parent = nullptr); - virtual ~QmitkIsoDoseLevelSetModel() {}; + ~QmitkIsoDoseLevelSetModel() override {}; /** Sets the data handled by the model and resets the modified flag*/ void setIsoDoseLevelSet(mitk::IsoDoseLevelSet *pSet); - virtual Qt::ItemFlags flags(const QModelIndex &index) const; - virtual QVariant data(const QModelIndex &index, int role) const; - virtual QVariant headerData(int section, Qt::Orientation orientation, int role) const; - virtual int rowCount(const QModelIndex &parent = QModelIndex()) const; - virtual int columnCount(const QModelIndex &parent = QModelIndex()) const; - virtual bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole); + Qt::ItemFlags flags(const QModelIndex &index) const override; + QVariant data(const QModelIndex &index, int role) const override; + QVariant headerData(int section, Qt::Orientation orientation, int role) const override; + int rowCount(const QModelIndex &parent = QModelIndex()) const override; + int columnCount(const QModelIndex &parent = QModelIndex()) const override; + bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override; bool getShowAbsoluteDose() const; mitk::DoseValueAbs getReferenceDose() const; bool getVisibilityEditOnly() const; void switchVisibilityIsoLines(bool activate); void switchVisibilityColorWash(bool activate); void invertVisibilityIsoLines(); void invertVisibilityColorWash(); void swapVisibility(); void addLevel(); void deleteLevel(const QModelIndex &index); /**Indicates if the content of the model was modified since the data was set via setIsoDoseLevelSet()*/ bool isModified(); public Q_SLOTS: /** * \brief Slot that can be used to set the prescribed dose. */ void setReferenceDose(double newReferenceDose); /** * \brief Slot that can be used to adjust whether the dose should be displayed in absolute or relative units. */ void setShowAbsoluteDose(bool showAbsoluteDose); /** * \brief Slat that can be used to adjust wether the model allows to edit only visibilities (no dose value or color) */ void setVisibilityEditOnly(bool onlyVisibility); private: mitk::IsoDoseLevelSet::Pointer m_DoseSet; bool m_showAbsoluteDose; bool m_visibilityEditOnly; mitk::DoseValueAbs m_referenceDose; /** Indicates if the data of the model was modified, since the model was set. */ bool m_modified; }; #endif // QmitkIsoDoseLevelSetModel_h diff --git a/Modules/RenderWindowManager/include/QmitkRenderWindowDataModel.h b/Modules/RenderWindowManager/include/QmitkRenderWindowDataModel.h index ae9a9562dc..b96a518bc2 100644 --- a/Modules/RenderWindowManager/include/QmitkRenderWindowDataModel.h +++ b/Modules/RenderWindowManager/include/QmitkRenderWindowDataModel.h @@ -1,69 +1,69 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QMITKRENDERWINDOWDATAMODEL_H #define QMITKRENDERWINDOWDATAMODEL_H // render window manager module #include "MitkRenderWindowManagerExports.h" #include "mitkRenderWindowLayerUtilities.h" //mitk core #include #include // qt #include /* * @brief This class extends the 'QAbstractTableModel' to meet the specific requirements of the QmitkRenderWindowDataModel. */ class MITKRENDERWINDOWMANAGER_EXPORT QmitkRenderWindowDataModel : public QAbstractTableModel { Q_OBJECT public: QmitkRenderWindowDataModel(QObject* parent = nullptr); - ~QmitkRenderWindowDataModel(); + ~QmitkRenderWindowDataModel() override; ////////////////////////////////////////////////////////////////////////// /// overridden functions from QAbstractItemModel ////////////////////////////////////////////////////////////////////////// - virtual Qt::ItemFlags flags(const QModelIndex &index) const override; - virtual QVariant data(const QModelIndex &index, int role) const override; - virtual QVariant headerData(int section, Qt::Orientation orientation, int role) const override; - virtual int rowCount(const QModelIndex &parent = QModelIndex()) const override; - virtual int columnCount(const QModelIndex &parent = QModelIndex()) const override; - virtual bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override; + Qt::ItemFlags flags(const QModelIndex &index) const override; + QVariant data(const QModelIndex &index, int role) const override; + QVariant headerData(int section, Qt::Orientation orientation, int role) const override; + int rowCount(const QModelIndex &parent = QModelIndex()) const override; + int columnCount(const QModelIndex &parent = QModelIndex()) const override; + bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override; ////////////////////////////////////////////////////////////////////////// /// end override ///////////////////////////////////////////////////////////////////////// void SetDataStorage(mitk::DataStorage::Pointer dataStorage); void SetCurrentRenderer(std::string rendererName); mitk::BaseRenderer* GetCurrentRenderer() const { return m_BaseRenderer.GetPointer(); } void DataChanged(const mitk::DataNode* dataNode); private: mitk::DataStorage::Pointer m_DataStorage; mitk::BaseRenderer::Pointer m_BaseRenderer; RenderWindowLayerUtilities::LayerStack m_TempLayerStack; }; #endif // QMITKRENDERWINDOWDATAMODEL_H diff --git a/Modules/SegmentationUI/Qmitk/QmitkAdaptiveRegionGrowingToolGUI.h b/Modules/SegmentationUI/Qmitk/QmitkAdaptiveRegionGrowingToolGUI.h index e8c7be64d8..c2d3c91edd 100644 --- a/Modules/SegmentationUI/Qmitk/QmitkAdaptiveRegionGrowingToolGUI.h +++ b/Modules/SegmentationUI/Qmitk/QmitkAdaptiveRegionGrowingToolGUI.h @@ -1,232 +1,232 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QMITK_QmitkAdaptiveRegionGrowingToolGUI_H #define QMITK_QmitkAdaptiveRegionGrowingToolGUI_H #include "itkImage.h" #include "mitkDataStorage.h" #include "mitkGeometry3D.h" #include "mitkPointSet.h" #include "qwidget.h" #include "ui_QmitkAdaptiveRegionGrowingToolGUIControls.h" #include #include "QmitkToolGUI.h" #include "mitkAdaptiveRegionGrowingTool.h" class QmitkStdMultiWidget; class DataNode; class QmitkAdaptiveRegionGrowingToolGUIControls; /*! * * \brief QmitkAdaptiveRegionGrowingToolGUI * * Adaptive Region Growing View class of the segmentation. * */ class MITKSEGMENTATIONUI_EXPORT QmitkAdaptiveRegionGrowingToolGUI : public QmitkToolGUI { Q_OBJECT public: /** * @brief mitkClassMacro */ mitkClassMacro(QmitkAdaptiveRegionGrowingToolGUI, QmitkToolGUI); itkFactorylessNewMacro(Self) itkCloneMacro(Self) QmitkAdaptiveRegionGrowingToolGUI(QWidget *parent = 0); /** \brief Method to create the connections for the component. This Method is obligatory even if no connections is * needed*/ virtual void CreateConnections(); ///** \brief Method to set the default data storage.*/ virtual void SetDataStorage(mitk::DataStorage *dataStorage); /** * @brief Method to set the used multiwidget. * @param multiWidget */ void SetMultiWidget(QmitkStdMultiWidget *multiWidget); /** * @brief Method to set the name of a data node. * @param labledSegmentation Name of the labeled segmentation * @param binaryImage Name of the binary image * @param surface Name of the surface */ void SetDataNodeNames(std::string labledSegmentation, std::string binaryImage, /*std::string vesselTree,*/ std::string surface, std::string maskedSegmentation); /** * @brief Method to enable/disable controls for region growing * * This method checks if a seed point is set and a segmentation exists. * @param enable/disable controls */ void EnableControls(bool enable); /** * @brief Method to set the input image node * @param data node */ void SetInputImageNode(mitk::DataNode *node); void Deactivated(); void Activated(); /** * @brief The created GUI from the .ui-File. This Attribute is obligatory */ Ui::QmitkAdaptiveRegionGrowingToolGUIControls m_Controls; protected slots: /** * @brief Method to start the segmentation * * This method is called, when the "Start Segmentation" button is clicked. */ void RunSegmentation(); /** * @brief Method to change the level window * * This method is called, when the level window slider is changed via the slider in the control widget * @param new value */ void ChangeLevelWindow(double newValue); /** * @brief Method to increase the preview slider * * This method is called, when the + button is clicked and increases the value by 1 */ void IncreaseSlider(); /** * @brief Method to decrease the preview slider * * This method is called, when the - button is clicked and decreases the value by 1 */ void DecreaseSlider(); /** * @brief Method to confirm the preview segmentation * * This method is called, when the "Confirm Segmentation" button is clicked. */ void ConfirmSegmentation(); /** * @brief Method to switch the volume rendering on/off * @param on/off */ void UseVolumeRendering(bool on); /** * @brief Method to set the lower threshold * * This method is called, when the minimum threshold slider has changed * @param lower threshold */ void SetLowerThresholdValue(double lowerThreshold); /** * @brief Method to set upper threshold * * This Method is called, when the maximum threshold slider has changed * @param upper threshold */ void SetUpperThresholdValue(double upperThreshold); /** * @brief Method to determine which tool to activate * * This method listens to the tool manager and activates this tool if requested otherwise disables this view */ void OnNewToolAssociated(mitk::Tool *); protected: mitk::AdaptiveRegionGrowingTool::Pointer m_RegionGrow3DTool; /** \brief Destructor. */ - virtual ~QmitkAdaptiveRegionGrowingToolGUI(); + ~QmitkAdaptiveRegionGrowingToolGUI() override; // Pointer to the main widget to be able to reach the renderer QmitkStdMultiWidget *m_MultiWidget; mitk::DataStorage *m_DataStorage; mitk::DataNode::Pointer m_InputImageNode; /** * @brief Method to calculate parameter settings, when a seed point is set */ void OnPointAdded(); private: std::string m_NAMEFORORGIMAGE; std::string m_NAMEFORLABLEDSEGMENTATIONIMAGE; std::string m_NAMEFORBINARYIMAGE; std::string m_NAMEFORSURFACE; std::string m_NAMEFORMASKEDSEGMENTATION; mitk::ScalarType m_LOWERTHRESHOLD; // Hounsfield value mitk::ScalarType m_UPPERTHRESHOLD; // Hounsfield value mitk::ScalarType m_SeedPointValueMean; void RemoveHelperNodes(); int m_DetectedLeakagePoint; bool m_CurrentRGDirectionIsUpwards; // defines fixed threshold (true = LOWERTHRESHOLD fixed, false = UPPERTHRESHOLD // fixed) int m_SeedpointValue; bool m_SliderInitialized; bool m_UseVolumeRendering; bool m_UpdateSuggestedThreshold; float m_SuggestedThValue; long m_PointSetAddObserverTag; long m_PointSetMoveObserverTag; template void StartRegionGrowing(itk::Image *itkImage, mitk::BaseGeometry *imageGeometry, mitk::PointSet::PointType seedPoint); template void ITKThresholding(itk::Image *inputImage); void InitializeLevelWindow(); void EnableVolumeRendering(bool enable); void UpdateVolumeRenderingThreshold(int thValue); }; #endif diff --git a/Modules/SegmentationUI/Qmitk/QmitkBinaryThresholdToolGUI.h b/Modules/SegmentationUI/Qmitk/QmitkBinaryThresholdToolGUI.h index 22bbd678ee..77de0527ec 100644 --- a/Modules/SegmentationUI/Qmitk/QmitkBinaryThresholdToolGUI.h +++ b/Modules/SegmentationUI/Qmitk/QmitkBinaryThresholdToolGUI.h @@ -1,98 +1,98 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QmitkBinaryThresholdToolGUI_h_Included #define QmitkBinaryThresholdToolGUI_h_Included #include "QmitkToolGUI.h" #include "mitkBinaryThresholdTool.h" #include #include class QSlider; /** \ingroup org_mitk_gui_qt_interactivesegmentation_internal \brief GUI for mitk::BinaryThresholdTool. This GUI shows a slider to change the tool's threshold and an OK button to accept a preview for actual thresholding. There is only a slider for INT values in QT. So, if the working image has a float/double pixeltype, we need to convert the original float intensity into a respective int value for the slider. The slider range is then between 0 and 99. If the pixeltype is INT, then we do not need any conversion. Last contributor: $Author$ */ class MITKSEGMENTATIONUI_EXPORT QmitkBinaryThresholdToolGUI : public QmitkToolGUI { Q_OBJECT public: mitkClassMacro(QmitkBinaryThresholdToolGUI, QmitkToolGUI); itkFactorylessNewMacro(Self) itkCloneMacro(Self) void OnThresholdingIntervalBordersChanged(double lower, double upper, bool isFloat); void OnThresholdingValueChanged(double current); signals: /// \brief Emitted when threshold Accepted void thresholdAccepted(); /// \brief Emitted when threshold Canceled void thresholdCanceled(); public slots: protected slots: void OnNewToolAssociated(mitk::Tool *); void OnAcceptThresholdPreview(); /// \brief Called when Spinner value has changed. Consider: Spinner contains DOUBLE values void OnSpinnerValueChanged(); /// \brief Called when Slider value has changed. Consider: Slider contains INT values void OnSliderValueChanged(int value); protected: QmitkBinaryThresholdToolGUI(); - virtual ~QmitkBinaryThresholdToolGUI(); + ~QmitkBinaryThresholdToolGUI() override; /// \brief When Slider (int value) has changed, we need to convert it to a respective double value for the spinner double SliderIntToDouble(int val); /// \brief When Spinner (double value) has changed, we need to convert it to a respective int value for the slider int DoubleToSliderInt(double val); QSlider *m_Slider; QDoubleSpinBox *m_Spinner; /// \brief is image float or int? bool m_isFloat; double m_RangeMin; double m_RangeMax; double m_Range; /// \brief helper bool values to find out, which of the GUI elements has been touched by the user. bool m_ChangingSlider, m_ChangingSpinner; mitk::BinaryThresholdTool::Pointer m_BinaryThresholdTool; }; #endif diff --git a/Modules/SegmentationUI/Qmitk/QmitkBinaryThresholdULToolGUI.h b/Modules/SegmentationUI/Qmitk/QmitkBinaryThresholdULToolGUI.h index 6cbdad4793..2fcffac0a8 100644 --- a/Modules/SegmentationUI/Qmitk/QmitkBinaryThresholdULToolGUI.h +++ b/Modules/SegmentationUI/Qmitk/QmitkBinaryThresholdULToolGUI.h @@ -1,65 +1,65 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QmitkBinaryThresholdULToolGUI_h_Included #define QmitkBinaryThresholdULToolGUI_h_Included #include "QmitkToolGUI.h" #include "ctkRangeWidget.h" #include "mitkBinaryThresholdULTool.h" #include /** \ingroup org_mitk_gui_qt_interactivesegmentation_internal \brief GUI for mitk::BinaryThresholdTool. This GUI shows a slider to change the tool's threshold and an OK button to accept a preview for actual thresholding. Last contributor: $Author$ */ class MITKSEGMENTATIONUI_EXPORT QmitkBinaryThresholdULToolGUI : public QmitkToolGUI { Q_OBJECT public: mitkClassMacro(QmitkBinaryThresholdULToolGUI, QmitkToolGUI); itkFactorylessNewMacro(Self) itkCloneMacro(Self) void OnThresholdingIntervalBordersChanged(double lower, double upper, bool isFloat); void OnThresholdingValuesChanged(mitk::ScalarType lower, mitk::ScalarType upper); signals: public slots: protected slots: void OnNewToolAssociated(mitk::Tool *); void OnAcceptThresholdPreview(); void OnThresholdsChanged(double min, double max); protected: QmitkBinaryThresholdULToolGUI(); - virtual ~QmitkBinaryThresholdULToolGUI(); + ~QmitkBinaryThresholdULToolGUI() override; ctkRangeWidget *m_DoubleThresholdSlider; mitk::BinaryThresholdULTool::Pointer m_BinaryThresholdULTool; }; #endif diff --git a/Modules/SegmentationUI/Qmitk/QmitkCalculateGrayValueStatisticsToolGUI.h b/Modules/SegmentationUI/Qmitk/QmitkCalculateGrayValueStatisticsToolGUI.h index cffcc1cd65..9ba1500776 100644 --- a/Modules/SegmentationUI/Qmitk/QmitkCalculateGrayValueStatisticsToolGUI.h +++ b/Modules/SegmentationUI/Qmitk/QmitkCalculateGrayValueStatisticsToolGUI.h @@ -1,61 +1,61 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QmitkCalculateGrayValueStatisticsToolGUI_h_Included #define QmitkCalculateGrayValueStatisticsToolGUI_h_Included #include "QmitkToolGUI.h" #include #include "mitkCalculateGrayValueStatisticsTool.h" /** \ingroup org_mitk_gui_qt_interactivesegmentation_internal \brief GUI for mitk::CalculateGrayValueStatisticsTool. Shows nothing. Only when the corresponding tool send a message that statistics are ready, this class pops up a window showing the results. Last contributor: $Author$ */ class MITKSEGMENTATIONUI_EXPORT QmitkCalculateGrayValueStatisticsToolGUI : public QmitkToolGUI { Q_OBJECT public: mitkClassMacro(QmitkCalculateGrayValueStatisticsToolGUI, QmitkToolGUI); itkFactorylessNewMacro(Self) itkCloneMacro(Self) /// Reacts to signals from mitk::CalculateGrayValueStatisticsTool void OnCalculationsDone(); signals: public slots: protected slots: /// Connected to signal from QmitkToolGUI. We remember the current tool here void OnNewToolAssociated(mitk::Tool *); protected: QmitkCalculateGrayValueStatisticsToolGUI(); - virtual ~QmitkCalculateGrayValueStatisticsToolGUI(); + ~QmitkCalculateGrayValueStatisticsToolGUI() override; mitk::CalculateGrayValueStatisticsTool::Pointer m_CalculateGrayValueStatisticsTool; }; #endif diff --git a/Modules/SegmentationUI/Qmitk/QmitkConfirmSegmentationDialog.h b/Modules/SegmentationUI/Qmitk/QmitkConfirmSegmentationDialog.h index 8a0896e5fe..7c8ffe4f3c 100644 --- a/Modules/SegmentationUI/Qmitk/QmitkConfirmSegmentationDialog.h +++ b/Modules/SegmentationUI/Qmitk/QmitkConfirmSegmentationDialog.h @@ -1,40 +1,40 @@ #ifndef QMITKCONFIRMSEGMENTATIONDIALOG_H #define QMITKCONFIRMSEGMENTATIONDIALOG_H #include namespace Ui { class QmitkConfirmSegmentationDialog; } class QmitkConfirmSegmentationDialog : public QDialog { Q_OBJECT public: explicit QmitkConfirmSegmentationDialog(QWidget *parent = nullptr); - ~QmitkConfirmSegmentationDialog(); + ~QmitkConfirmSegmentationDialog() override; void SetSegmentationName(QString name); enum { OVERWRITE_SEGMENTATION, CREATE_NEW_SEGMENTATION, CANCEL_SEGMENTATION }; protected slots: void OnOverwriteExistingSegmentation(); void OnCreateNewSegmentation(); void OnCancelSegmentation(); private: Ui::QmitkConfirmSegmentationDialog *m_Controls; }; #endif // QMITKCONFIRMSEGMENTATIONDIALOG_H diff --git a/Modules/SegmentationUI/Qmitk/QmitkCopyToClipBoardDialog.h b/Modules/SegmentationUI/Qmitk/QmitkCopyToClipBoardDialog.h index ad7eaa3112..46e29f0a54 100644 --- a/Modules/SegmentationUI/Qmitk/QmitkCopyToClipBoardDialog.h +++ b/Modules/SegmentationUI/Qmitk/QmitkCopyToClipBoardDialog.h @@ -1,45 +1,45 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QmitkCopyToClipBoardDialog_h_Included #define QmitkCopyToClipBoardDialog_h_Included #include #include #include /** \brief Displays read-only QTextEdit. For output of any kind of information that might be copied into other applications. */ class MITKSEGMENTATIONUI_EXPORT QmitkCopyToClipBoardDialog : public QDialog { Q_OBJECT public: QmitkCopyToClipBoardDialog(const QString &text, QWidget *parent = nullptr, const char *name = nullptr); - virtual ~QmitkCopyToClipBoardDialog(); + ~QmitkCopyToClipBoardDialog() override; signals: public slots: protected slots: protected: }; #endif diff --git a/Modules/SegmentationUI/Qmitk/QmitkDrawPaintbrushToolGUI.h b/Modules/SegmentationUI/Qmitk/QmitkDrawPaintbrushToolGUI.h index a7bb433a47..cade54d645 100644 --- a/Modules/SegmentationUI/Qmitk/QmitkDrawPaintbrushToolGUI.h +++ b/Modules/SegmentationUI/Qmitk/QmitkDrawPaintbrushToolGUI.h @@ -1,52 +1,52 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QmitkDrawPaintbrushToolGUI_h_Included #define QmitkDrawPaintbrushToolGUI_h_Included #include "QmitkPaintbrushToolGUI.h" #include /** \ingroup org_mitk_gui_qt_interactivesegmentation_internal \brief GUI for mitk::PaintbrushTool. This GUI shows a slider to change the tool's threshold and an OK button to accept a preview for actual thresholding. Last contributor: $Author$ */ class MITKSEGMENTATIONUI_EXPORT QmitkDrawPaintbrushToolGUI : public QmitkPaintbrushToolGUI { Q_OBJECT public: mitkClassMacro(QmitkDrawPaintbrushToolGUI, QmitkPaintbrushToolGUI); itkFactorylessNewMacro(Self) itkCloneMacro(Self) - virtual ~QmitkDrawPaintbrushToolGUI(); + ~QmitkDrawPaintbrushToolGUI() override; signals: public slots: protected slots: protected: QmitkDrawPaintbrushToolGUI(); }; #endif diff --git a/Modules/SegmentationUI/Qmitk/QmitkErasePaintbrushToolGUI.h b/Modules/SegmentationUI/Qmitk/QmitkErasePaintbrushToolGUI.h index a4b58b26dc..7129f2332b 100644 --- a/Modules/SegmentationUI/Qmitk/QmitkErasePaintbrushToolGUI.h +++ b/Modules/SegmentationUI/Qmitk/QmitkErasePaintbrushToolGUI.h @@ -1,52 +1,52 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QmitkErasePaintbrushToolGUI_h_Included #define QmitkErasePaintbrushToolGUI_h_Included #include "QmitkPaintbrushToolGUI.h" #include /** \ingroup org_mitk_gui_qt_interactivesegmentation_internal \brief GUI for mitk::PaintbrushTool. This GUI shows a slider to change the tool's threshold and an OK button to accept a preview for actual thresholding. Last contributor: $Author$ */ class MITKSEGMENTATIONUI_EXPORT QmitkErasePaintbrushToolGUI : public QmitkPaintbrushToolGUI { Q_OBJECT public: mitkClassMacro(QmitkErasePaintbrushToolGUI, QmitkPaintbrushToolGUI); itkFactorylessNewMacro(Self) itkCloneMacro(Self) signals : public slots : protected slots : protected : QmitkErasePaintbrushToolGUI(); - virtual ~QmitkErasePaintbrushToolGUI(); + ~QmitkErasePaintbrushToolGUI() override; }; #endif diff --git a/Modules/SegmentationUI/Qmitk/QmitkFastMarchingTool3DGUI.h b/Modules/SegmentationUI/Qmitk/QmitkFastMarchingTool3DGUI.h index 0ebb7fc5ad..e277be1b80 100644 --- a/Modules/SegmentationUI/Qmitk/QmitkFastMarchingTool3DGUI.h +++ b/Modules/SegmentationUI/Qmitk/QmitkFastMarchingTool3DGUI.h @@ -1,87 +1,87 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QmitkFastMarchingTool3DGUI_h_Included #define QmitkFastMarchingTool3DGUI_h_Included #include "QmitkToolGUI.h" #include "mitkFastMarchingTool3D.h" #include class ctkSliderWidget; class ctkRangeWidget; class QPushButton; #include "QmitkStepperAdapter.h" /** \ingroup org_mitk_gui_qt_interactivesegmentation_internal \brief GUI for mitk::FastMarchingTool. \sa mitk::FastMarchingTool */ class MITKSEGMENTATIONUI_EXPORT QmitkFastMarchingTool3DGUI : public QmitkToolGUI { Q_OBJECT public: mitkClassMacro(QmitkFastMarchingTool3DGUI, QmitkToolGUI); itkFactorylessNewMacro(Self) itkCloneMacro(Self) void OnThresholdChanged(int current); protected slots: void OnNewToolAssociated(mitk::Tool *); void OnThresholdChanged(double, double); void OnAlphaChanged(double); void OnBetaChanged(double); void OnSigmaChanged(double); void OnStoppingValueChanged(double); void OnConfirmSegmentation(); void Refetch(); void SetStepper(mitk::Stepper *); void OnClearSeeds(); protected: QmitkFastMarchingTool3DGUI(); - virtual ~QmitkFastMarchingTool3DGUI(); + ~QmitkFastMarchingTool3DGUI() override; void BusyStateChanged(bool) override; void Update(); ctkRangeWidget *m_slwThreshold; ctkSliderWidget *m_slStoppingValue; ctkSliderWidget *m_slSigma; ctkSliderWidget *m_slAlpha; ctkSliderWidget *m_slBeta; QPushButton *m_btConfirm; QPushButton *m_btClearSeeds; mitk::FastMarchingTool3D::Pointer m_FastMarchingTool; bool m_TimeIsConnected; mitk::Stepper::Pointer m_TimeStepper; void OnFastMarchingToolReady(); private: void EnableWidgets(bool); }; #endif diff --git a/Modules/SegmentationUI/Qmitk/QmitkFastMarchingToolGUI.h b/Modules/SegmentationUI/Qmitk/QmitkFastMarchingToolGUI.h index f6faf0ff39..178a0d5745 100644 --- a/Modules/SegmentationUI/Qmitk/QmitkFastMarchingToolGUI.h +++ b/Modules/SegmentationUI/Qmitk/QmitkFastMarchingToolGUI.h @@ -1,87 +1,87 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QmitkFastMarchingToolGUI_h_Included #define QmitkFastMarchingToolGUI_h_Included #include "QmitkToolGUI.h" #include "mitkFastMarchingTool.h" #include class ctkSliderWidget; class ctkRangeWidget; class QPushButton; #include "QmitkStepperAdapter.h" /** \ingroup org_mitk_gui_qt_interactivesegmentation_internal \brief GUI for mitk::FastMarchingTool. \sa mitk::FastMarchingTool */ class MITKSEGMENTATIONUI_EXPORT QmitkFastMarchingToolGUI : public QmitkToolGUI { Q_OBJECT public: mitkClassMacro(QmitkFastMarchingToolGUI, QmitkToolGUI); itkFactorylessNewMacro(Self) itkCloneMacro(Self) void OnThresholdChanged(int current); protected slots: void OnNewToolAssociated(mitk::Tool *); void OnThresholdChanged(double, double); void OnAlphaChanged(double); void OnBetaChanged(double); void OnSigmaChanged(double); void OnStoppingValueChanged(double); void OnConfirmSegmentation(); void Refetch(); void SetStepper(mitk::Stepper *); void OnClearSeeds(); protected: QmitkFastMarchingToolGUI(); - virtual ~QmitkFastMarchingToolGUI(); + ~QmitkFastMarchingToolGUI() override; void Update(); void BusyStateChanged(bool) override; ctkRangeWidget *m_slwThreshold; ctkSliderWidget *m_slStoppingValue; ctkSliderWidget *m_slSigma; ctkSliderWidget *m_slAlpha; ctkSliderWidget *m_slBeta; QPushButton *m_btConfirm; QPushButton *m_btClearSeeds; mitk::FastMarchingTool::Pointer m_FastMarchingTool; bool m_TimeIsConnected; mitk::Stepper::Pointer m_TimeStepper; void OnFastMarchingToolReady(); private: void EnableWidgets(bool); }; #endif diff --git a/Modules/SegmentationUI/Qmitk/QmitkLabelSetWidget.h b/Modules/SegmentationUI/Qmitk/QmitkLabelSetWidget.h index 295947c04d..3a818da621 100644 --- a/Modules/SegmentationUI/Qmitk/QmitkLabelSetWidget.h +++ b/Modules/SegmentationUI/Qmitk/QmitkLabelSetWidget.h @@ -1,175 +1,175 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QmitkLabelSetWidget_h #define QmitkLabelSetWidget_h #include "MitkSegmentationUIExports.h" #include "mitkColorSequenceRainbow.h" #include "mitkLabel.h" #include "mitkNumericTypes.h" #include class QmitkDataStorageComboBox; class QCompleter; namespace mitk { class LabelSetImage; class LabelSet; class Label; class DataStorage; class ToolManager; class DataNode; } class MITKSEGMENTATIONUI_EXPORT QmitkLabelSetWidget : public QWidget { Q_OBJECT public: explicit QmitkLabelSetWidget(QWidget *parent = nullptr); - ~QmitkLabelSetWidget(); + ~QmitkLabelSetWidget() override; void SetDataStorage(mitk::DataStorage *storage); void SetOrganColors(const QStringList &organColors); void UpdateControls(); virtual void setEnabled(bool enabled); QStringList &GetLabelStringList(); signals: /// \brief Send a signal when it was requested to go to a label. void goToLabel(const mitk::Point3D &); void resetView(); public slots: /** * @brief Updates the current labels in the label set widget table. For each label (widget item) the 'UpdateTableWidgetItem' is called. * * Updating means setting the color box of the table, setting the column with and fill it with the label name. * Furthermore the two push buttons for locking and showing/hiding the layer are checked/unchecked. * This functions only changes the appearance of the table widget and no render window update is necessary. */ void UpdateAllTableWidgetItems(); /** * @brief Resets the current labels in the label set widget table. For each label a widget item is inserted into the table. * * Resetting means removing all rows of the widget table and inserting new rows (labels) from the active label set (= layer) of the current working node. * The currently active label is selected and 'Number of labels' is set. * As this function is typically used after one label has been removed or the reference node has been changed (e.g.) the render windows have to be updated. */ void ResetAllTableWidgetItems(); void SelectLabelByPixelValue(mitk::Label::PixelType pixelValue); private slots: // LabelSet dependent void OnOpacityChanged(int); void OnUnlockAllLabels(bool); void OnLockAllLabels(bool); void OnSetAllLabelsVisible(bool); void OnSetAllLabelsInvisible(bool); void OnSetOnlyActiveLabelVisible(bool); void OnRandomColor(bool); void OnRemoveLabel(bool); void OnRemoveLabels(bool); void OnRenameLabel(bool); void OnLockedButtonClicked(); void OnVisibleButtonClicked(); void OnColorButtonClicked(); void OnItemClicked(QTableWidgetItem *item); void OnItemDoubleClicked(QTableWidgetItem *item); void OnTableViewContextMenuRequested(const QPoint &); void InsertTableWidgetItem(mitk::Label *label); void UpdateTableWidgetItem(QTableWidgetItem *item); // reaction to "returnPressed" signal from ... void OnSearchLabel(); // reaction to the button "Change Label" void OnActiveLabelChanged(int pixelValue); // LabelSetImage Dependet void OnCreateDetailedSurface(bool); void OnCreateSmoothedSurface(bool); // reaction to the signal "createMask" from QmitkLabelSetTableWidget void OnCreateMask(bool); void OnCreateMasks(bool); // reaction to the signal "createCroppedMask" from QmitkLabelSetTableWidget void OnCreateCroppedMask(bool); void OnCombineAndCreateMask(bool); void OnCombineAndCreateSurface(bool); void OnEraseLabel(bool); void OnEraseLabels(bool); // reaction to signal "mergeLabel" from QmitkLabelSetTableWidget void OnMergeLabel(bool); void OnMergeLabels(bool); // reaction to the button "Import Segmentation" void OnImportSegmentation(); // reaction to the button "Import Labeled Image" void OnImportLabeledImage(); // reaction to signal "labelListModified" from QmitkLabelSetTableWidget void OnLabelListModified(const QStringList &list); // reaction to the signal "toggleOutline" from QmitkLabelSetTableWidget void OnToggleOutline(bool); private: enum TableColumns { NAME_COL = 0, LOCKED_COL, COLOR_COL, VISIBLE_COL }; void WaitCursorOn(); void WaitCursorOff(); void RestoreOverrideCursor(); void OnThreadedCalculationDone(); void InitializeTableWidget(); int GetPixelValueOfSelectedItem(); mitk::LabelSetImage *GetWorkingImage(); mitk::DataNode *GetWorkingNode(); Ui::QmitkLabelSetWidgetControls m_Controls; mitk::ColorSequenceRainbow m_ColorSequenceRainbow; mitk::DataStorage *m_DataStorage; QCompleter *m_Completer; mitk::ToolManager *m_ToolManager; QStringList m_OrganColors; QStringList m_LabelStringList; }; #endif diff --git a/Modules/SegmentationUI/Qmitk/QmitkLiveWireTool2DGUI.h b/Modules/SegmentationUI/Qmitk/QmitkLiveWireTool2DGUI.h index d8427bf346..b64ddcea88 100644 --- a/Modules/SegmentationUI/Qmitk/QmitkLiveWireTool2DGUI.h +++ b/Modules/SegmentationUI/Qmitk/QmitkLiveWireTool2DGUI.h @@ -1,67 +1,67 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QmitkLiveWireTool2DGUI_h_Included #define QmitkLiveWireTool2DGUI_h_Included #include "QmitkToolGUI.h" #include "mitkLiveWireTool2D.h" #include "ui_QmitkLiveWireTool2DGUIControls.h" #include class QSlider; class QLabel; class QFrame; class QPushButton; #include #include "QmitkStepperAdapter.h" class QmitkLiveWireTool2DGUIControls; /** \ingroup org_mitk_gui_qt_interactivesegmentation_internal \brief GUI for mitk::LiveWireTool. \sa mitk::LiveWireTool2D */ class MITKSEGMENTATIONUI_EXPORT QmitkLiveWireTool2DGUI : public QmitkToolGUI { Q_OBJECT public: mitkClassMacro(QmitkLiveWireTool2DGUI, QmitkToolGUI); itkFactorylessNewMacro(Self) itkCloneMacro(Self) protected slots : void OnNewToolAssociated(mitk::Tool *); void OnConfirmSegmentation(); void OnClearSegmentation(); void OnShowInformation(bool on); protected: QmitkLiveWireTool2DGUI(); - virtual ~QmitkLiveWireTool2DGUI(); + ~QmitkLiveWireTool2DGUI() override; Ui::QmitkLiveWireTool2DGUIControls m_Controls; mitk::LiveWireTool2D::Pointer m_LiveWireTool; }; #endif diff --git a/Modules/SegmentationUI/Qmitk/QmitkMaskStampWidget.h b/Modules/SegmentationUI/Qmitk/QmitkMaskStampWidget.h index 36ca830f65..ad74b170fd 100644 --- a/Modules/SegmentationUI/Qmitk/QmitkMaskStampWidget.h +++ b/Modules/SegmentationUI/Qmitk/QmitkMaskStampWidget.h @@ -1,63 +1,63 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QmitkMaskStampWidget_h_Included #define QmitkMaskStampWidget_h_Included #include "MitkSegmentationUIExports.h" #include "mitkDataNode.h" #include #include "ui_QmitkMaskStampWidgetGUIControls.h" namespace mitk { class ToolManager; } /** \brief GUI for mask stamp functionality \ingroup ToolManagerEtAl \ingroup Widgets */ class MITKSEGMENTATIONUI_EXPORT QmitkMaskStampWidget : public QWidget { Q_OBJECT public: QmitkMaskStampWidget(QWidget *parent = 0, const char *name = 0); - virtual ~QmitkMaskStampWidget(); + ~QmitkMaskStampWidget() override; void SetDataStorage(mitk::DataStorage *storage); protected slots: void OnShowInformation(bool); void OnStamp(); private: mitk::ToolManager *m_ToolManager; mitk::DataStorage *m_DataStorage; Ui::QmitkMaskStampWidgetGUIControls m_Controls; }; #endif diff --git a/Modules/SegmentationUI/Qmitk/QmitkNewSegmentationDialog.h b/Modules/SegmentationUI/Qmitk/QmitkNewSegmentationDialog.h index 7b5837adda..49100310cc 100644 --- a/Modules/SegmentationUI/Qmitk/QmitkNewSegmentationDialog.h +++ b/Modules/SegmentationUI/Qmitk/QmitkNewSegmentationDialog.h @@ -1,99 +1,99 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QmitkNewSegmentationDialog_h_Included #define QmitkNewSegmentationDialog_h_Included #include "mitkColorProperty.h" #include #include #include class QLabel; class QLineEdit; class Q3ListBox; class QPushButton; #include /** \brief Dialog for QmitkInteractiveSegmentation. \ingroup ToolManagerEtAl \ingroup Widgets This dialog is used to ask a user about the type of a newly created segmentation and a name for it. \warning Will not create a new organ type in the OrganTypeProperty. Client has to do that. */ class MITKSEGMENTATIONUI_EXPORT QmitkNewSegmentationDialog : public QDialog { Q_OBJECT public: QmitkNewSegmentationDialog(QWidget *parent = nullptr); - virtual ~QmitkNewSegmentationDialog(); + ~QmitkNewSegmentationDialog() override; const QString GetSegmentationName(); mitk::Color GetColor(); const char *GetOrganType(); void SetSegmentationName(const QString &segmentationName); void SetColor(const mitk::Color &color); void SetSuggestionList(QStringList organColorList); signals: public slots: void setPrompt(const QString &prompt); protected slots: void onAcceptClicked(); void onNewOrganNameChanged(const QString &); void onColorBtnClicked(); void onColorChange(const QString &completedWord); protected: QLabel *lblPrompt; Q3ListBox *lstOrgans; QLineEdit *lineEditName; QPushButton *btnColor; QPushButton *btnOk; QLineEdit *edtNewOrgan; QString selectedOrgan; bool newOrganEntry; QColor m_Color; QCompleter *completer; QString m_SegmentationName; QStringList organList; QList colorList; }; #endif diff --git a/Modules/SegmentationUI/Qmitk/QmitkOtsuTool3DGUI.h b/Modules/SegmentationUI/Qmitk/QmitkOtsuTool3DGUI.h index 79a0bbdd39..33ae866d00 100644 --- a/Modules/SegmentationUI/Qmitk/QmitkOtsuTool3DGUI.h +++ b/Modules/SegmentationUI/Qmitk/QmitkOtsuTool3DGUI.h @@ -1,86 +1,86 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QmitkOtsuTool3DGUI_h_Included #define QmitkOtsuTool3DGUI_h_Included #include "QmitkToolGUI.h" #include "mitkOtsuTool3D.h" #include "ui_QmitkOtsuToolWidgetControls.h" #include #include #include class QSpinBox; class QLabel; /** \ingroup org_mitk_gui_qt_interactivesegmentation_internal \brief GUI for mitk::. \sa mitk:: This GUI shows ... Last contributor: $Author$ */ class MITKSEGMENTATIONUI_EXPORT QmitkOtsuTool3DGUI : public QmitkToolGUI { Q_OBJECT public: mitkClassMacro(QmitkOtsuTool3DGUI, QmitkToolGUI); itkFactorylessNewMacro(Self) itkCloneMacro(Self) signals : public slots : protected slots : void OnNewToolAssociated(mitk::Tool *); void OnSpinboxValueAccept(); void OnSegmentationRegionAccept(); void OnRegionSelectionChanged(); void OnRegionSpinboxChanged(int); void OnVolumePreviewChecked(int); private slots: void OnAdvancedSettingsButtonToggled(bool toggled); protected: QmitkOtsuTool3DGUI(); - virtual ~QmitkOtsuTool3DGUI(); + ~QmitkOtsuTool3DGUI() override; mitk::OtsuTool3D::Pointer m_OtsuTool3DTool; Ui_QmitkOtsuToolWidgetControls m_Controls; int m_NumberOfRegions; bool m_UseValleyEmphasis; int m_NumberOfBins; QList m_SelectedItems; }; #endif diff --git a/Modules/SegmentationUI/Qmitk/QmitkPaintbrushToolGUI.h b/Modules/SegmentationUI/Qmitk/QmitkPaintbrushToolGUI.h index e488042f43..93f8824a30 100644 --- a/Modules/SegmentationUI/Qmitk/QmitkPaintbrushToolGUI.h +++ b/Modules/SegmentationUI/Qmitk/QmitkPaintbrushToolGUI.h @@ -1,69 +1,69 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QmitkPaintbrushToolGUI_h_Included #define QmitkPaintbrushToolGUI_h_Included #include "QmitkToolGUI.h" #include "mitkPaintbrushTool.h" #include class QSlider; class QLabel; class QFrame; /** \ingroup org_mitk_gui_qt_interactivesegmentation_internal \brief GUI for mitk::PaintbrushTool. \sa mitk::PaintbrushTool This GUI shows a slider to change the pen's size. Last contributor: $Author$ */ class MITKSEGMENTATIONUI_EXPORT QmitkPaintbrushToolGUI : public QmitkToolGUI { Q_OBJECT public: mitkClassMacro(QmitkPaintbrushToolGUI, QmitkToolGUI); void OnSizeChanged(int current); signals: public slots: protected slots: void OnNewToolAssociated(mitk::Tool *); void OnSliderValueChanged(int value); void VisualizePaintbrushSize(int size); protected: QmitkPaintbrushToolGUI(); - virtual ~QmitkPaintbrushToolGUI(); + ~QmitkPaintbrushToolGUI() override; QSlider *m_Slider; QLabel *m_SizeLabel; QFrame *m_Frame; mitk::PaintbrushTool::Pointer m_PaintbrushTool; }; #endif diff --git a/Modules/SegmentationUI/Qmitk/QmitkPickingToolGUI.h b/Modules/SegmentationUI/Qmitk/QmitkPickingToolGUI.h index 09c244b75c..8a3be14cd3 100644 --- a/Modules/SegmentationUI/Qmitk/QmitkPickingToolGUI.h +++ b/Modules/SegmentationUI/Qmitk/QmitkPickingToolGUI.h @@ -1,63 +1,63 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QmitkPickingToolGUI_h_Included #define QmitkPickingToolGUI_h_Included #include "QmitkToolGUI.h" #include "mitkPickingTool.h" #include "ui_QmitkPickingToolGUIControls.h" #include class QSlider; class QLabel; class QFrame; class QPushButton; #include #include "QmitkStepperAdapter.h" class QmitkPickingToolGUIControls; /** \ingroup org_mitk_gui_qt_interactivesegmentation_internal \brief GUI for mitk::LiveWireTool. \sa mitk::PickingTool */ class MITKSEGMENTATIONUI_EXPORT QmitkPickingToolGUI : public QmitkToolGUI { Q_OBJECT public: mitkClassMacro(QmitkPickingToolGUI, QmitkToolGUI); itkFactorylessNewMacro(Self) itkCloneMacro(Self) protected slots : void OnNewToolAssociated(mitk::Tool *); void OnConfirmSegmentation(); protected: QmitkPickingToolGUI(); - virtual ~QmitkPickingToolGUI(); + ~QmitkPickingToolGUI() override; Ui::QmitkPickingToolGUIControls m_Controls; mitk::PickingTool::Pointer m_PickingTool; }; #endif diff --git a/Modules/SegmentationUI/Qmitk/QmitkPixelManipulationToolGUI.h b/Modules/SegmentationUI/Qmitk/QmitkPixelManipulationToolGUI.h index 422d4e9a9e..31e58373f3 100644 --- a/Modules/SegmentationUI/Qmitk/QmitkPixelManipulationToolGUI.h +++ b/Modules/SegmentationUI/Qmitk/QmitkPixelManipulationToolGUI.h @@ -1,50 +1,50 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QMITKPIXELMANIPULATIONTOOLGUI_H #define QMITKPIXELMANIPULATIONTOOLGUI_H #include "QmitkDataStorageComboBox.h" #include "QmitkToolGUI.h" #include "mitkPixelManipulationTool.h" #include #include class QmitkPixelManipulationToolGUI : public QmitkToolGUI { Q_OBJECT public: mitkClassMacro(QmitkPixelManipulationToolGUI, QmitkToolGUI); itkFactorylessNewMacro(Self) itkCloneMacro(Self) protected slots : void OnNewToolAssociated(mitk::Tool *); void OnSliderValueChanged(int); void OnSpinBoxChanged(); void OnOkButtonClicked(); void SetFixedValueOn(bool); void SetFixedValueOff(bool); protected: QmitkPixelManipulationToolGUI(); - virtual ~QmitkPixelManipulationToolGUI(); + ~QmitkPixelManipulationToolGUI() override; mitk::PixelManipulationTool::Pointer m_PixelManipulationTool; QSlider *m_Slider; QSpinBox *m_Spinner; }; // class #endif diff --git a/Modules/SegmentationUI/Qmitk/QmitkSearchLabelDialog.h b/Modules/SegmentationUI/Qmitk/QmitkSearchLabelDialog.h index c8937be89d..cff0212bf4 100644 --- a/Modules/SegmentationUI/Qmitk/QmitkSearchLabelDialog.h +++ b/Modules/SegmentationUI/Qmitk/QmitkSearchLabelDialog.h @@ -1,63 +1,63 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QmitkSearchLabelDialog_h_Included #define QmitkSearchLabelDialog_h_Included #include "MitkSegmentationUIExports.h" #include #include #include class MITKSEGMENTATIONUI_EXPORT QmitkSearchLabelDialog : public QDialog { Q_OBJECT public: QmitkSearchLabelDialog(QWidget *parent = 0, Qt::WindowFlags f = 0); - virtual ~QmitkSearchLabelDialog(); + ~QmitkSearchLabelDialog() override; int GetLabelSetWidgetTableIndex(); QString GetLabelSetWidgetTableCompleteWord(); void SetLabelSuggestionList(QStringList stringList); signals: void goToLabel(int); public slots: protected slots: void OnLabelCompleterChanged(const QString &completedWord); protected: Ui::QmitkSearchLabelDialogGUI *m_Controls; QCompleter *m_Completer; QStringList m_LabelList; int m_LabelIndex; QString m_CompleteWord; }; #endif diff --git a/Modules/SegmentationUI/Qmitk/QmitkSliceBasedInterpolatorWidget.h b/Modules/SegmentationUI/Qmitk/QmitkSliceBasedInterpolatorWidget.h index 9cdf12dd8d..9180ca1e07 100644 --- a/Modules/SegmentationUI/Qmitk/QmitkSliceBasedInterpolatorWidget.h +++ b/Modules/SegmentationUI/Qmitk/QmitkSliceBasedInterpolatorWidget.h @@ -1,202 +1,202 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QmitkSliceBasedInterpolatorWidget_h_Included #define QmitkSliceBasedInterpolatorWidget_h_Included #include "MitkSegmentationUIExports.h" #include "mitkDataStorage.h" #include "mitkSliceBasedInterpolationController.h" #include #include #include "ui_QmitkSliceBasedInterpolatorWidgetGUIControls.h" namespace mitk { class PlaneGeometry; class SliceNavigationController; class LabelSetImage; class ToolManager; class DiffSliceOperation; } /** \brief GUI for slices interpolation. \ingroup ToolManagerEtAl \ingroup Widgets \sa QmitkInteractiveSegmentation \sa mitk::SegmentationInterpolation There is a separate page describing the general design of QmitkInteractiveSegmentation: \ref QmitkInteractiveSegmentationTechnicalPage While mitk::SegmentationInterpolation does the bookkeeping of interpolation (keeping track of which slices contain how much segmentation) and the algorithmic work, QmitkSliceBasedInterpolatorWidget is responsible to watch the GUI, to notice, which slice is currently visible. It triggers generation of interpolation suggestions and also triggers acception of suggestions. \todo show/hide feedback on demand Last contributor: $Author: maleike $ */ class MITKSEGMENTATIONUI_EXPORT QmitkSliceBasedInterpolatorWidget : public QWidget { Q_OBJECT public: QmitkSliceBasedInterpolatorWidget(QWidget *parent = 0, const char *name = 0); - virtual ~QmitkSliceBasedInterpolatorWidget(); + ~QmitkSliceBasedInterpolatorWidget() override; void SetDataStorage(mitk::DataStorage &storage); /** Sets the slice navigation controllers for getting slice changed events from the views. */ void SetSliceNavigationControllers(const QList &controllers); void OnToolManagerWorkingDataModified(); void OnTimeChanged(itk::Object *sender, const itk::EventObject &); void OnSliceChanged(itk::Object *sender, const itk::EventObject &); void OnSliceNavigationControllerDeleted(const itk::Object *sender, const itk::EventObject &); /** Just public because it is called by itk::Commands. You should not need to call this. */ void OnSliceInterpolationInfoChanged(const itk::EventObject &); Ui::QmitkSliceBasedInterpolatorWidgetGUIControls m_Controls; signals: void signalSliceBasedInterpolationEnabled(bool); public slots: /** \brief Reaction to "Start/Stop" button click */ void OnToggleWidgetActivation(bool); protected slots: /** \brief Reaction to "Accept Current Slice" button click. */ void OnAcceptInterpolationClicked(); /* \brief Reaction to "Accept All Slices" button click. Opens popup to ask about which orientation should be interpolated */ void OnAcceptAllInterpolationsClicked(); /* \brief Called from popup menu of OnAcceptAllInterpolationsClicked() Will trigger interpolation for all slices in given orientation */ void OnAcceptAllPopupActivated(QAction *action); protected: typedef std::map ActionToSliceDimensionMapType; const ActionToSliceDimensionMapType CreateActionToSliceDimension(); ActionToSliceDimensionMapType m_ActionToSliceDimensionMap; void AcceptAllInterpolations(mitk::SliceNavigationController *slicer); void WaitCursorOn(); void WaitCursorOff(); void RestoreOverrideCursor(); /** Gets the working slice based on the given plane geometry and last saved interaction \param planeGeometry a plane geometry */ mitk::Image::Pointer GetWorkingSlice(const mitk::PlaneGeometry *planeGeometry); /** Retrieves the currently selected PlaneGeometry from a SlicedGeometry3D that is generated by a SliceNavigationController and calls Interpolate to further process this PlaneGeometry into an interpolation. \param e is a actually a mitk::SliceNavigationController::GeometrySliceEvent, sent by a SliceNavigationController \param slice the SliceNavigationController */ void TranslateAndInterpolateChangedSlice(const itk::EventObject &e, mitk::SliceNavigationController *slicer); /** Given a PlaneGeometry, this method figures out which slice of the first working image (of the associated ToolManager) should be interpolated. The actual work is then done by our SegmentationInterpolation object. */ void Interpolate(mitk::PlaneGeometry *plane, unsigned int timeStep, mitk::SliceNavigationController *slicer); /** Called internally to update the interpolation suggestion. Finds out about the focused render window and requests an interpolation. */ void UpdateVisibleSuggestion(); private: mitk::SliceBasedInterpolationController::Pointer m_SliceInterpolatorController; mitk::ToolManager *m_ToolManager; bool m_Activated; template void WritePreviewOnWorkingImage(itk::Image *target, const mitk::Image *source, int overwritevalue); QHash m_ControllerToTimeObserverTag; QHash m_ControllerToSliceObserverTag; QHash m_ControllerToDeleteObserverTag; unsigned int m_InterpolationInfoChangedObserverTag; mitk::DiffSliceOperation *m_doOperation; mitk::DiffSliceOperation *m_undoOperation; mitk::DataNode::Pointer m_PreviewNode; mitk::Image::Pointer m_PreviewImage; mitk::LabelSetImage::Pointer m_WorkingImage; QHash m_TimeStep; mitk::DataStorage::Pointer m_DataStorage; mitk::SliceNavigationController *m_LastSNC; unsigned int m_LastSliceIndex; }; #endif diff --git a/Modules/SegmentationUI/Qmitk/QmitkSlicesInterpolator.h b/Modules/SegmentationUI/Qmitk/QmitkSlicesInterpolator.h index fec5cecd27..da981f7762 100644 --- a/Modules/SegmentationUI/Qmitk/QmitkSlicesInterpolator.h +++ b/Modules/SegmentationUI/Qmitk/QmitkSlicesInterpolator.h @@ -1,299 +1,299 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QmitkSlicesInterpolator_h_Included #define QmitkSlicesInterpolator_h_Included #include "mitkDataNode.h" #include "mitkDataStorage.h" #include "mitkSegmentationInterpolationController.h" #include "mitkSliceNavigationController.h" #include "mitkSurfaceInterpolationController.h" #include "mitkToolManager.h" #include "mitkWeakPointer.h" #include #include "mitkFeatureBasedEdgeDetectionFilter.h" #include "mitkPointCloudScoringFilter.h" #include #include #include #include #include #include #include #include "mitkVtkRepresentationProperty.h" #include "vtkProperty.h" // For running 3D interpolation in background #include #include #include #include namespace mitk { class PlaneGeometry; class SliceNavigationController; } class QPushButton; /** \brief GUI for slices interpolation. \ingroup ToolManagerEtAl \ingroup Widgets \sa QmitkInteractiveSegmentation \sa mitk::SegmentationInterpolation There is a separate page describing the general design of QmitkInteractiveSegmentation: \ref QmitkInteractiveSegmentationTechnicalPage While mitk::SegmentationInterpolation does the bookkeeping of interpolation (keeping track of which slices contain how much segmentation) and the algorithmic work, QmitkSlicesInterpolator is responsible to watch the GUI, to notice, which slice is currently visible. It triggers generation of interpolation suggestions and also triggers acception of suggestions. \todo show/hide feedback on demand Last contributor: $Author: maleike $ */ class MITKSEGMENTATIONUI_EXPORT QmitkSlicesInterpolator : public QWidget { Q_OBJECT public: QmitkSlicesInterpolator(QWidget *parent = 0, const char *name = 0); /** To be called once before real use. */ void Initialize(mitk::ToolManager *toolManager, const QList &controllers); void Uninitialize(); - virtual ~QmitkSlicesInterpolator(); + ~QmitkSlicesInterpolator() override; void SetDataStorage(mitk::DataStorage::Pointer storage); mitk::DataStorage *GetDataStorage(); /** Just public because it is called by itk::Commands. You should not need to call this. */ void OnToolManagerWorkingDataModified(); /** Just public because it is called by itk::Commands. You should not need to call this. */ void OnToolManagerReferenceDataModified(); void OnTimeChanged(itk::Object *sender, const itk::EventObject &); void OnSliceChanged(itk::Object *sender, const itk::EventObject &); void OnSliceNavigationControllerDeleted(const itk::Object *sender, const itk::EventObject &); /** Just public because it is called by itk::Commands. You should not need to call this. */ void OnInterpolationInfoChanged(const itk::EventObject &); /** Just public because it is called by itk::Commands. You should not need to call this. */ void OnSurfaceInterpolationInfoChanged(const itk::EventObject &); /** * @brief Set the visibility of the 3d interpolation */ void Show3DInterpolationResult(bool); signals: void SignalRememberContourPositions(bool); void SignalShowMarkerNodes(bool); public slots: virtual void setEnabled(bool); /** Call this from the outside to enable/disable interpolation */ void EnableInterpolation(bool); void Enable3DInterpolation(bool); /** Call this from the outside to accept all interpolations */ void FinishInterpolation(mitk::SliceNavigationController *slicer = nullptr); protected slots: /** Reaction to button clicks. */ void OnAcceptInterpolationClicked(); /* Opens popup to ask about which orientation should be interpolated */ void OnAcceptAllInterpolationsClicked(); /* Reaction to button clicks */ void OnAccept3DInterpolationClicked(); void OnReinit3DInterpolation(); void OnSuggestPlaneClicked(); /* * Will trigger interpolation for all slices in given orientation (called from popup menu of * OnAcceptAllInterpolationsClicked) */ void OnAcceptAllPopupActivated(QAction *action); /** Called on activation/deactivation */ void OnInterpolationActivated(bool); void On3DInterpolationActivated(bool); void OnInterpolationMethodChanged(int index); // Enhancement for 3D interpolation void On2DInterpolationEnabled(bool); void On3DInterpolationEnabled(bool); void OnInterpolationDisabled(bool); void OnShowMarkers(bool); void Run3DInterpolation(); void RunPlaneSuggestion(); void OnSurfaceInterpolationFinished(); void StartUpdateInterpolationTimer(); void StopUpdateInterpolationTimer(); void ChangeSurfaceColor(); protected: const std::map createActionToSliceDimension(); std::map ACTION_TO_SLICEDIMENSION; void AcceptAllInterpolations(mitk::SliceNavigationController *slicer); /** Retrieves the currently selected PlaneGeometry from a SlicedGeometry3D that is generated by a SliceNavigationController and calls Interpolate to further process this PlaneGeometry into an interpolation. \param e is a actually a mitk::SliceNavigationController::GeometrySliceEvent, sent by a SliceNavigationController \param slice the SliceNavigationController */ bool TranslateAndInterpolateChangedSlice(const itk::EventObject &e, mitk::SliceNavigationController *slicer); /** Given a PlaneGeometry, this method figures out which slice of the first working image (of the associated ToolManager) should be interpolated. The actual work is then done by our SegmentationInterpolation object. */ void Interpolate(mitk::PlaneGeometry *plane, unsigned int timeStep, mitk::SliceNavigationController *slicer); // void InterpolateSurface(); /** Called internally to update the interpolation suggestion. Finds out about the focused render window and requests an interpolation. */ void UpdateVisibleSuggestion(); void SetCurrentContourListID(); private: void HideAllInterpolationControls(); void Show2DInterpolationControls(bool show); void Show3DInterpolationControls(bool show); void CheckSupportedImageDimension(); void WaitForFutures(); void NodeRemoved(const mitk::DataNode* node); mitk::SegmentationInterpolationController::Pointer m_Interpolator; mitk::SurfaceInterpolationController::Pointer m_SurfaceInterpolator; mitk::FeatureBasedEdgeDetectionFilter::Pointer m_EdgeDetector; mitk::PointCloudScoringFilter::Pointer m_PointScorer; mitk::ToolManager::Pointer m_ToolManager; bool m_Initialized; QHash m_ControllerToTimeObserverTag; QHash m_ControllerToSliceObserverTag; QHash m_ControllerToDeleteObserverTag; unsigned int InterpolationInfoChangedObserverTag; unsigned int SurfaceInterpolationInfoChangedObserverTag; QGroupBox *m_GroupBoxEnableExclusiveInterpolationMode; QComboBox *m_CmbInterpolation; QPushButton *m_BtnApply2D; QPushButton *m_BtnApplyForAllSlices2D; QPushButton *m_BtnApply3D; QPushButton *m_BtnSuggestPlane; QCheckBox *m_ChkShowPositionNodes; QPushButton *m_BtnReinit3DInterpolation; mitk::DataNode::Pointer m_FeedbackNode; mitk::DataNode::Pointer m_InterpolatedSurfaceNode; mitk::DataNode::Pointer m_3DContourNode; mitk::Image *m_Segmentation; mitk::SliceNavigationController *m_LastSNC; unsigned int m_LastSliceIndex; QHash m_TimeStep; bool m_2DInterpolationEnabled; bool m_3DInterpolationEnabled; // unsigned int m_CurrentListID; mitk::DataStorage::Pointer m_DataStorage; QFuture m_Future; QFutureWatcher m_Watcher; QTimer *m_Timer; QFuture m_PlaneFuture; QFutureWatcher m_PlaneWatcher; bool m_FirstRun; }; #endif diff --git a/Modules/SegmentationUI/Qmitk/QmitkSurfaceBasedInterpolatorWidget.h b/Modules/SegmentationUI/Qmitk/QmitkSurfaceBasedInterpolatorWidget.h index 89e8e78b71..f82cc13314 100644 --- a/Modules/SegmentationUI/Qmitk/QmitkSurfaceBasedInterpolatorWidget.h +++ b/Modules/SegmentationUI/Qmitk/QmitkSurfaceBasedInterpolatorWidget.h @@ -1,126 +1,126 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QmitkSurfaceBasedInterpolatorWidgetWidget_h_Included #define QmitkSurfaceBasedInterpolatorWidgetWidget_h_Included #include "MitkSegmentationUIExports.h" #include "mitkDataNode.h" #include "mitkDataStorage.h" #include "mitkLabelSetImage.h" #include "mitkSurfaceBasedInterpolationController.h" #include #include // For running 3D interpolation in background #include #include #include #include #include "ui_QmitkSurfaceBasedInterpolatorWidgetGUIControls.h" namespace mitk { class ToolManager; } /** \brief GUI for surface-based interpolation. \ingroup ToolManagerEtAl \ingroup Widgets \sa QmitkInteractiveSegmentation \sa mitk::SurfaceBasedInterpolationController There is a separate page describing the general design of QmitkInteractiveSegmentation: \ref QmitkInteractiveSegmentationTechnicalPage QmitkSurfaceBasedInterpolatorWidgetController is responsible to watch the GUI, to notice, which slice is currently visible. It triggers generation of interpolation suggestions and also triggers acception of suggestions. */ class MITKSEGMENTATIONUI_EXPORT QmitkSurfaceBasedInterpolatorWidget : public QWidget { Q_OBJECT public: QmitkSurfaceBasedInterpolatorWidget(QWidget *parent = 0, const char *name = 0); - virtual ~QmitkSurfaceBasedInterpolatorWidget(); + ~QmitkSurfaceBasedInterpolatorWidget() override; void SetDataStorage(mitk::DataStorage &storage); void OnToolManagerWorkingDataModified(); /** Just public because it is called by itk::Commands. You should not need to call this. */ void OnSurfaceInterpolationInfoChanged(const itk::EventObject &); /** * @brief Set the visibility of the interpolation */ void ShowInterpolationResult(bool); Ui::QmitkSurfaceBasedInterpolatorWidgetGUIControls m_Controls; public slots: /** \brief Reaction to "Start/Stop" button click */ void OnToggleWidgetActivation(bool); protected slots: void OnAcceptInterpolationClicked(); void OnSurfaceInterpolationFinished(); void OnRunInterpolation(); void OnShowMarkers(bool); void StartUpdateInterpolationTimer(); void StopUpdateInterpolationTimer(); void ChangeSurfaceColor(); private: mitk::SurfaceBasedInterpolationController::Pointer m_SurfaceBasedInterpolatorController; mitk::ToolManager *m_ToolManager; bool m_Activated; unsigned int m_SurfaceInterpolationInfoChangedObserverTag; mitk::DataNode::Pointer m_InterpolatedSurfaceNode; mitk::DataNode::Pointer m_3DContourNode; mitk::DataStorage::Pointer m_DataStorage; mitk::LabelSetImage::Pointer m_WorkingImage; QFuture m_Future; QFutureWatcher m_Watcher; QTimer *m_Timer; }; #endif diff --git a/Modules/SegmentationUI/Qmitk/QmitkSurfaceStampWidget.h b/Modules/SegmentationUI/Qmitk/QmitkSurfaceStampWidget.h index 264b75dd2e..d301e6518a 100644 --- a/Modules/SegmentationUI/Qmitk/QmitkSurfaceStampWidget.h +++ b/Modules/SegmentationUI/Qmitk/QmitkSurfaceStampWidget.h @@ -1,62 +1,62 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QmitkSurfaceStampWidget_h_Included #define QmitkSurfaceStampWidget_h_Included #include "MitkSegmentationUIExports.h" #include #include "ui_QmitkSurfaceStampWidgetGUIControls.h" namespace mitk { class ToolManager; } /** \brief GUI for surface-based interpolation. \ingroup ToolManagerEtAl \ingroup Widgets */ class MITKSEGMENTATIONUI_EXPORT QmitkSurfaceStampWidget : public QWidget { Q_OBJECT public: QmitkSurfaceStampWidget(QWidget *parent = 0, const char *name = 0); - virtual ~QmitkSurfaceStampWidget(); + ~QmitkSurfaceStampWidget() override; void SetDataStorage(mitk::DataStorage *storage); protected slots: void OnShowInformation(bool); void OnStamp(); private: mitk::ToolManager *m_ToolManager; mitk::DataStorage *m_DataStorage; Ui::QmitkSurfaceStampWidgetGUIControls m_Controls; }; #endif diff --git a/Modules/SegmentationUI/Qmitk/QmitkToolGUI.h b/Modules/SegmentationUI/Qmitk/QmitkToolGUI.h index 0ceec055bb..f0ec2a871e 100644 --- a/Modules/SegmentationUI/Qmitk/QmitkToolGUI.h +++ b/Modules/SegmentationUI/Qmitk/QmitkToolGUI.h @@ -1,66 +1,66 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QmitkToolGUI_h_Included #define QmitkToolGUI_h_Included #include #include #include "mitkCommon.h" #include "mitkTool.h" /** \brief Base class for GUIs belonging to mitk::Tool classes. \ingroup org_mitk_gui_qt_interactivesegmentation Created through ITK object factory. TODO May be changed to a toolkit specific way later? Last contributor: $Author$ */ class MITKSEGMENTATIONUI_EXPORT QmitkToolGUI : public QWidget, public itk::Object { Q_OBJECT public: mitkClassMacroItkParent(QmitkToolGUI, itk::Object); void SetTool(mitk::Tool *tool); // just make sure ITK won't take care of anything (especially not destruction) - virtual void Register() const override; - virtual void UnRegister() const ITK_NOEXCEPT ITK_OVERRIDE; - virtual void SetReferenceCount(int) override; + void Register() const override; + void UnRegister() const ITK_NOEXCEPT ITK_OVERRIDE; + void SetReferenceCount(int) override; - virtual ~QmitkToolGUI(); + ~QmitkToolGUI() override; signals: void NewToolAssociated(mitk::Tool *); public slots: protected slots: protected: mitk::Tool::Pointer m_Tool; virtual void BusyStateChanged(bool){}; }; #endif diff --git a/Modules/SegmentationUI/Qmitk/QmitkToolGUIArea.h b/Modules/SegmentationUI/Qmitk/QmitkToolGUIArea.h index 9601f36c35..e57d759dcc 100644 --- a/Modules/SegmentationUI/Qmitk/QmitkToolGUIArea.h +++ b/Modules/SegmentationUI/Qmitk/QmitkToolGUIArea.h @@ -1,50 +1,50 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QmitkToolGUIArea_h_Included #define QmitkToolGUIArea_h_Included #include "mitkCommon.h" #include #include /** \brief Dummy class for putting into a GUI (mainly using Qt Designer). This class is nothing more than a QWidget. It is good for use with QmitkToolSelectionBox as a place to display GUIs for active tools. Last contributor: $Author$ */ class MITKSEGMENTATIONUI_EXPORT QmitkToolGUIArea : public QWidget { Q_OBJECT public: QmitkToolGUIArea(QWidget *parent = nullptr, Qt::WindowFlags f = nullptr); - virtual ~QmitkToolGUIArea(); + ~QmitkToolGUIArea() override; signals: public slots: protected slots: protected: }; #endif diff --git a/Modules/SegmentationUI/Qmitk/QmitkToolReferenceDataSelectionBox.h b/Modules/SegmentationUI/Qmitk/QmitkToolReferenceDataSelectionBox.h index 24609535c6..d4dc0bfbcb 100644 --- a/Modules/SegmentationUI/Qmitk/QmitkToolReferenceDataSelectionBox.h +++ b/Modules/SegmentationUI/Qmitk/QmitkToolReferenceDataSelectionBox.h @@ -1,130 +1,130 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QmitkToolReferenceDataSelectionBox_h_Included #define QmitkToolReferenceDataSelectionBox_h_Included #include "mitkDataStorage.h" #include "mitkToolManager.h" #include #include #include class QmitkDataStorageComboBox; /** \brief Display the data selection of a ToolManager. \sa mitk::ToolManager \sa mitk::DataStorage \ingroup ToolManagerEtAl \ingroup Widgets There is a separate page describing the general design of QmitkInteractiveSegmentation: \ref QmitkInteractiveSegmentationTechnicalPage Shows the reference data of a ToolManager in a segmentation setting. The reference image can be selected from a combobox, where all images of the scene are listed. $Author: maleike $ */ class MITKSEGMENTATIONUI_EXPORT QmitkToolReferenceDataSelectionBox : public QWidget { Q_OBJECT public: /** * \brief What kind of items should be displayed. * * Every mitk::Tool holds a NodePredicateBase object, telling the kind of data that this * tool will successfully work with. There are two ways that this list box deals with * these predicates. * * DEFAULT is: list data if ANY one of the displayed tools' predicate matches. * Other option: list data if ALL one of the displayed tools' predicate matches */ enum DisplayMode { ListDataIfAllToolsMatch, ListDataIfAnyToolMatches }; QmitkToolReferenceDataSelectionBox(QWidget *parent = 0); - virtual ~QmitkToolReferenceDataSelectionBox(); + ~QmitkToolReferenceDataSelectionBox() override; mitk::DataStorage *GetDataStorage(); void SetDataStorage(mitk::DataStorage &storage); /// initialization with a data storage object void Initialize(mitk::DataStorage *); void UpdateDataDisplay(); mitk::ToolManager *GetToolManager(); void SetToolManager(mitk::ToolManager &); // no nullptr pointer allowed here, a manager is required void OnToolManagerReferenceDataModified(); /** * \brief No brief description. * * Should be called to restrict the number of tools that are * evaluated to build up the list. Default is to ask all tools for their predicate, by * setting the 'groups' string this can be restricted to certain groups of tools * or single tools. */ void SetToolGroupsForFiltering(const std::string &groups); /** * \brief How the list contents is determined. * * See also documentation of DisplayMode. * * \sa DisplayMode */ void SetDisplayMode(DisplayMode mode); signals: void ReferenceNodeSelected(const mitk::DataNode *); protected slots: void OnReferenceDataSelected(const mitk::DataNode *node); void EnsureOnlyReferenceImageIsVisibile(); protected: mitk::DataStorage::SetOfObjects::ConstPointer GetAllPossibleReferenceImages(); mitk::NodePredicateBase::ConstPointer GetAllPossibleReferenceImagesPredicate(); mitk::ToolManager::Pointer m_ToolManager; QmitkDataStorageComboBox *m_ReferenceDataSelectionBox; bool m_SelfCall; DisplayMode m_DisplayMode; std::string m_ToolGroupsForFiltering; QVBoxLayout *m_Layout; }; #endif diff --git a/Modules/SegmentationUI/Qmitk/QmitkToolRoiDataSelectionBox.h b/Modules/SegmentationUI/Qmitk/QmitkToolRoiDataSelectionBox.h index 393a0ba11d..25bc544431 100644 --- a/Modules/SegmentationUI/Qmitk/QmitkToolRoiDataSelectionBox.h +++ b/Modules/SegmentationUI/Qmitk/QmitkToolRoiDataSelectionBox.h @@ -1,78 +1,78 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QMITK_TOOLROIDATASELECTIONBOX_H #define QMITK_TOOLROIDATASELECTIONBOX_H #include "QmitkBoundingObjectWidget.h" #include "mitkToolManager.h" #include #include /** \brief Widget for defining a ROI inside the Interactive Segmentation Framwork \ingroup ToolManagerEtAl \ingroup Widgets Allows to define a Region of interest (ROI) either by existing segmentations or by bounding objects. Selection is possible via a combobox, listing all available segmentations. Item "bounding objects" activates the \ref QmitkBoundingObjectWidget. */ class MITKSEGMENTATIONUI_EXPORT QmitkToolRoiDataSelectionBox : public QWidget { Q_OBJECT public: QmitkToolRoiDataSelectionBox(QWidget *parent = 0, mitk::DataStorage *storage = 0); - virtual ~QmitkToolRoiDataSelectionBox(); + ~QmitkToolRoiDataSelectionBox() override; mitk::DataStorage *GetDataStorage(); void SetDataStorage(mitk::DataStorage &storage); mitk::ToolManager *GetToolManager(); void SetToolManager(mitk::ToolManager &manager); void OnToolManagerRoiDataModified(); void DataStorageChanged(const mitk::DataNode *node); mitk::ToolManager::DataVectorType GetSelection(); void UpdateComboBoxData(); void setEnabled(bool); signals: void RoiDataSelected(const mitk::DataNode *node); protected slots: void OnRoiDataSelectionChanged(const QString &name); void OnRoiDataSelectionChanged(); protected: QmitkBoundingObjectWidget *m_boundingObjectWidget; QComboBox *m_segmentationComboBox; mitk::ToolManager::Pointer m_ToolManager; bool m_SelfCall; mitk::DataNode::Pointer m_lastSelection; QString m_lastSelectedName; }; #endif diff --git a/Modules/SegmentationUI/Qmitk/QmitkToolSelectionBox.h b/Modules/SegmentationUI/Qmitk/QmitkToolSelectionBox.h index fdbd31d7ac..23c804e5d2 100755 --- a/Modules/SegmentationUI/Qmitk/QmitkToolSelectionBox.h +++ b/Modules/SegmentationUI/Qmitk/QmitkToolSelectionBox.h @@ -1,154 +1,154 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QmitkToolSelectionBox_h_Included #define QmitkToolSelectionBox_h_Included #include "QmitkToolGUIArea.h" #include #include "mitkToolManager.h" #include #include #include #include class QmitkToolGUI; /** \brief Display the tool selection state of a mitk::ToolManager \sa mitk::ToolManager \ingroup org_mitk_gui_qt_interactivesegmentation \ingroup ToolManagerEtAl There is a separate page describing the general design of QmitkInteractiveSegmentation: \ref QmitkInteractiveSegmentationTechnicalPage This widget graphically displays the active tool of a mitk::ToolManager as a set of toggle buttons. Each button show the identification of a Tool (icon and name). When a button's toggle state is "down", the tool is activated. When a different button is clicked, the active tool is switched. When you click an already active button, the associated tool is deactivated with no replacement, which means that no tool is active then. When this widget is enabled/disabled it (normally) also enables/disables the tools. There could be cases where two QmitkToolSelectionBox widgets are associated to the same ToolManager, but if this happens, please look deeply into the code. Last contributor: $Author: maleike $ */ class MITKSEGMENTATIONUI_EXPORT QmitkToolSelectionBox : public QWidget //! { Q_OBJECT public: enum EnabledMode { EnabledWithReferenceAndWorkingDataVisible, EnabledWithReferenceData, EnabledWithWorkingData, AlwaysEnabled }; QmitkToolSelectionBox(QWidget *parent = 0, mitk::DataStorage *storage = 0); - virtual ~QmitkToolSelectionBox(); + ~QmitkToolSelectionBox() override; mitk::ToolManager *GetToolManager(); void SetToolManager(mitk::ToolManager &); // no nullptr pointer allowed here, a manager is required void setTitle(const QString &title); /** You may specify a list of tool "groups" that should be displayed in this widget. Every Tool can report its group as a string. This method will try to find the tool's group inside the supplied string \param toolGroups. If there is a match, the tool is displayed. Effectively, you can provide a human readable list like "default, lymphnodevolumetry, oldERISstuff". */ void SetDisplayedToolGroups(const std::string &toolGroups = 0); void OnToolManagerToolModified(); void OnToolManagerReferenceDataModified(); void OnToolManagerWorkingDataModified(); void OnToolGUIProcessEventsMessage(); void OnToolErrorMessage(std::string s); void OnGeneralToolMessage(std::string s); void RecreateButtons(); signals: /// Whenever a tool is activated. id is the index of the active tool. Counting starts at 0, -1 indicates "no tool /// selected" /// This signal is also emitted, when the whole QmitkToolSelectionBox get disabled. Then it will claim /// ToolSelected(-1) /// When it is enabled again, there will be another ToolSelected event with the tool that is currently selected void ToolSelected(int id); public slots: virtual void setEnabled(bool); virtual void SetEnabledMode(EnabledMode mode); virtual void SetLayoutColumns(int); virtual void SetShowNames(bool); virtual void SetGenerateAccelerators(bool); virtual void SetToolGUIArea(QWidget *parentWidget); protected slots: void toolButtonClicked(int id); void SetGUIEnabledAccordingToToolManagerState(); protected: void showEvent(QShowEvent *) override; void hideEvent(QHideEvent *) override; void SetOrUnsetButtonForActiveTool(); mitk::ToolManager::Pointer m_ToolManager; bool m_SelfCall; std::string m_DisplayedGroups; /// stores relationship between button IDs of the Qt widget and tool IDs of ToolManager std::map m_ButtonIDForToolID; /// stores relationship between button IDs of the Qt widget and tool IDs of ToolManager std::map m_ToolIDForButtonID; int m_LayoutColumns; bool m_ShowNames; bool m_GenerateAccelerators; QWidget *m_ToolGUIWidget; QmitkToolGUI *m_LastToolGUI; // store buttons in this group QButtonGroup *m_ToolButtonGroup; QGridLayout *m_ButtonLayout; EnabledMode m_EnabledMode; }; #endif diff --git a/Modules/SegmentationUI/Qmitk/QmitkToolWorkingDataSelectionBox.h b/Modules/SegmentationUI/Qmitk/QmitkToolWorkingDataSelectionBox.h index aca7c07b77..26f145813b 100644 --- a/Modules/SegmentationUI/Qmitk/QmitkToolWorkingDataSelectionBox.h +++ b/Modules/SegmentationUI/Qmitk/QmitkToolWorkingDataSelectionBox.h @@ -1,145 +1,145 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QmitkToolWorkingDataSelectionListBox_h_Included #define QmitkToolWorkingDataSelectionListBox_h_Included // mmueller #include #include #include "mitkProperties.h" #include "mitkToolManager.h" /** \brief Display the data selection of a ToolManager. \sa mitk::ToolManager \sa mitk::DataStorage \ingroup Widgets There is a separate page describing the general design of QmitkInteractiveSegmentation: \ref QmitkInteractiveSegmentationTechnicalPage Shows the working data of a ToolManager in a segmentation setting. By default only the segmentation name is shown. The working images (segmentations) are listed in a QListView, each row telling the color and name of a single segmentation. One or several segmentations can be selected to be the "active" segmentations. $Author: maleike $ */ class MITKSEGMENTATIONUI_EXPORT QmitkToolWorkingDataSelectionBox : public QListWidget { Q_OBJECT public: /** * \brief What kind of items should be displayed. * * Every mitk::Tool holds a NodePredicateBase object, telling the kind of data that this * tool will successfully work with. There are two ways that this list box deals with * these predicates. * * DEFAULT is: list data if ANY one of the displayed tools' predicate matches. * Other option: list data if ALL one of the displayed tools' predicate matches */ enum DisplayMode { ListDataIfAllToolsMatch, ListDataIfAnyToolMatches }; QmitkToolWorkingDataSelectionBox(QWidget *parent = 0); - virtual ~QmitkToolWorkingDataSelectionBox(); + ~QmitkToolWorkingDataSelectionBox() override; mitk::DataStorage *GetDataStorage(); void SetDataStorage(mitk::DataStorage &storage); /** \brief Can be called to trigger an update of the list contents. */ void UpdateDataDisplay(); /** \brief Returns the associated mitk::ToolManager. */ mitk::ToolManager *GetToolManager(); /** \brief Tell this object to listen to another ToolManager. */ void SetToolManager(mitk::ToolManager &); // no nullptr pointer allowed here, a manager is required /** * \brief A list of all displayed DataNode objects. * This method might be convenient for program modules that want to display * additional information about these nodes, like a total volume of all segmentations, etc. */ mitk::ToolManager::DataVectorType GetAllNodes(bool onlyDerivedFromOriginal = true); /** * \brief A list of all selected DataNode objects. * This method might be convenient for program modules that want to display * additional information about these nodes, like a total volume of all segmentations, etc. */ mitk::ToolManager::DataVectorType GetSelectedNodes(); /** * \brief Like GetSelectedNodes(), but will only return one object. * Will only return what QListView gives as selected object (documentation says nothing is returned if list is in * Single selection mode). */ mitk::DataNode *GetSelectedNode(); /** * \brief Callback function, no need to call it. * This is used to observe and react to changes in the mitk::ToolManager object. */ void OnToolManagerWorkingDataModified(); /** * \brief Callback function, no need to call it. * This is used to observe and react to changes in the mitk::ToolManager object. */ void OnToolManagerReferenceDataModified(); signals: void WorkingNodeSelected(const mitk::DataNode *); protected slots: void OnWorkingDataSelectionChanged(); protected: typedef std::map ItemNodeMapType; mitk::ToolManager::Pointer m_ToolManager; ItemNodeMapType m_Node; bool m_SelfCall; mitk::DataNode *m_LastSelectedReferenceData; std::string m_ToolGroupsForFiltering; bool m_DisplayOnlyDerivedNodes; }; #endif diff --git a/Modules/SegmentationUI/Qmitk/QmitkWatershedToolGUI.h b/Modules/SegmentationUI/Qmitk/QmitkWatershedToolGUI.h index b40ef57b1a..477cf29e39 100644 --- a/Modules/SegmentationUI/Qmitk/QmitkWatershedToolGUI.h +++ b/Modules/SegmentationUI/Qmitk/QmitkWatershedToolGUI.h @@ -1,75 +1,75 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QmitkWatershedToolGUI_h_Included #define QmitkWatershedToolGUI_h_Included #include "QmitkToolGUI.h" #include "mitkWatershedTool.h" #include class QSlider; class QLabel; class QFrame; /** \ingroup org_mitk_gui_qt_interactivesegmentation_internal \brief GUI for mitk::WatershedTool. \sa mitk::WatershedTool This GUI shows two sliders to change the watershed parameters. It executes the watershed algorithm by clicking on the button. */ class MITKSEGMENTATIONUI_EXPORT QmitkWatershedToolGUI : public QmitkToolGUI { Q_OBJECT public: mitkClassMacro(QmitkWatershedToolGUI, QmitkToolGUI); itkFactorylessNewMacro(Self) itkCloneMacro(Self) protected slots : void OnNewToolAssociated(mitk::Tool *); /** \brief Passes the chosen threshold value directly to the watershed tool */ void OnSliderValueThresholdChanged(int value); /** \brief Passes the chosen level value directly to the watershed tool */ void OnSliderValueLevelChanged(int value); /** \brief Starts segmentation algorithm in the watershed tool */ void OnCreateSegmentation(); protected: QmitkWatershedToolGUI(); - virtual ~QmitkWatershedToolGUI(); + ~QmitkWatershedToolGUI() override; QSlider *m_SliderThreshold; QSlider *m_SliderLevel; /** \brief Label showing the current threshold value. */ QLabel *m_ThresholdLabel; /** \brief Label showing the current level value. */ QLabel *m_LevelLabel; /** \brief Label showing additional informations. */ QLabel *m_InformationLabel; QFrame *m_Frame; mitk::WatershedTool::Pointer m_WatershedTool; }; #endif diff --git a/Modules/TumorInvasionAnalysis/test/mitkClassificationTest.cpp b/Modules/TumorInvasionAnalysis/test/mitkClassificationTest.cpp index 0625f7054f..b0a498b96d 100644 --- a/Modules/TumorInvasionAnalysis/test/mitkClassificationTest.cpp +++ b/Modules/TumorInvasionAnalysis/test/mitkClassificationTest.cpp @@ -1,109 +1,109 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifdef _MSC_VER # pragma warning(disable : 4996) #endif #include "mitkTestFixture.h" #include "mitkTestingMacros.h" #include "mitkCompareImageDataFilter.h" #include "mitkIOUtil.h" #include "mitkDataCollection.h" #include "mitkTumorInvasionClassification.h" #include "mitkDiffusionCollectionReader.h" #include "mitkDiffusionCollectionWriter.h" #include /** * @brief mitkClassificationTestSuite * * Tests mitkDecisionForest, mitkClassifyProgression, mitkDataCollection, mitkDiffusionCollectionReader * \warn Reference is compared to results computed based on random forests, which might be a source of random test fails * such sporadic fails do represent total fails, as the result is no longer consitently under the provided margin. * */ class mitkClassificationTestSuite : public mitk::TestFixture { CPPUNIT_TEST_SUITE(mitkClassificationTestSuite); MITK_TEST(TestClassification); CPPUNIT_TEST_SUITE_END(); public: /** * @brief Setup - Always call this method before each Test-case to ensure correct and new intialization of the used * members for a new test case. (If the members are not used in a test, the method does not need to be called). */ - void setUp() {} - void tearDown() {} + void setUp() override {} + void tearDown() override {} void TestClassification() { size_t forestSize = 10; size_t treeDepth = 2; std::string train = GetTestDataFilePath("DiffusionImaging/ProgressionAnalysis/Classification/Train.xml"); std::string eval = GetTestDataFilePath("DiffusionImaging/ProgressionAnalysis/Classification/Test.xml"); std::vector modalities; modalities.push_back("MOD0"); modalities.push_back("MOD1"); mitk::DiffusionCollectionReader colReader; mitk::DataCollection::Pointer collection = colReader.LoadCollection(train); colReader.Clear(); // read evaluation collection mitk::DataCollection::Pointer evaluation = colReader.LoadCollection(eval); mitk::TumorInvasionClassification progression; progression.SetClassRatio(1); progression.SetTrainMargin(4, 0); progression.SetMaskID("MASK"); progression.SelectTrainingSamples(collection); progression.LearnProgressionFeatures(collection, modalities, forestSize, treeDepth); progression.PredictInvasion(evaluation, modalities); mitk::Image::Pointer refImage = dynamic_cast(mitk::IOUtil::Load( GetTestDataFilePath("DiffusionImaging/ProgressionAnalysis/Classification/TESTING_RESULT.nrrd"))[0].GetPointer()); mitk::DataCollection *patCol = dynamic_cast(evaluation->GetData(0).GetPointer()); mitk::DataCollection *subCol = dynamic_cast(patCol->GetData(0).GetPointer()); mitk::Image::Pointer resultImage = subCol->GetMitkImage("RESULT"); // Test result against fixed reference. // Require more than 90% to be correct. // 10% margin due to // 1) unsure classification in transitional regions and // 2) stochastic training procedure // Total number of voxels 2400 -> 10% err -> 240 voxels margin mitk::CompareImageDataFilter::Pointer compareFilter = mitk::CompareImageDataFilter::New(); compareFilter->SetInput(0, refImage.GetPointer()); compareFilter->SetInput(1, resultImage); compareFilter->SetTolerance(.1); compareFilter->Update(); MITK_TEST_CONDITION_REQUIRED(compareFilter->GetResult(240), "Compare prediction results to reference image.") } }; MITK_TEST_SUITE_REGISTRATION(mitkClassification) diff --git a/Modules/XNAT/include/QmitkSelectXnatUploadDestinationDialog.h b/Modules/XNAT/include/QmitkSelectXnatUploadDestinationDialog.h index e3e2d2de98..907417f372 100644 --- a/Modules/XNAT/include/QmitkSelectXnatUploadDestinationDialog.h +++ b/Modules/XNAT/include/QmitkSelectXnatUploadDestinationDialog.h @@ -1,47 +1,47 @@ #ifndef QMITKSELECTXNATUPLOADDESTINATIONDIALOG_H #define QMITKSELECTXNATUPLOADDESTINATIONDIALOG_H #include #include namespace Ui { class QmitkSelectXnatUploadDestinationDialog; } class ctkXnatObject; class ctkXnatSession; class QModelIndex; class QmitkXnatTreeModel; class MITKXNAT_EXPORT QmitkSelectXnatUploadDestinationDialog : public QDialog { Q_OBJECT public: explicit QmitkSelectXnatUploadDestinationDialog(ctkXnatSession *session, const QStringList &, QWidget *parent = 0); - ~QmitkSelectXnatUploadDestinationDialog(); + ~QmitkSelectXnatUploadDestinationDialog() override; ctkXnatObject *GetUploadDestination(); void SetXnatResourceFolderUrl(const QString &url); protected slots: void OnUpload(); void OnSelectResource(bool selectResource); void OnSelectFromTreeView(bool selectFromTreeView); void OnResourceEntered(const QString &resourceEntered); void OnResourceSelected(const QString &resource); void OnXnatNodeSelected(const QModelIndex &); void OnCancel(); private: QmitkXnatTreeModel *m_TreeModel; QString m_Url; QString m_ResourceName; bool m_CreateNewFolder; Ui::QmitkSelectXnatUploadDestinationDialog *ui; }; #endif // QMITKSELECTXNATUPLOADDESTINATIONDIALOG_H diff --git a/Modules/XNAT/include/QmitkXnatCreateObjectDialog.h b/Modules/XNAT/include/QmitkXnatCreateObjectDialog.h index de1d3062bb..f4600e35d2 100644 --- a/Modules/XNAT/include/QmitkXnatCreateObjectDialog.h +++ b/Modules/XNAT/include/QmitkXnatCreateObjectDialog.h @@ -1,57 +1,57 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QMITKXNATCREATEOBJECTDIALOG_H #define QMITKXNATCREATEOBJECTDIALOG_H #include // Qt #include #include class ctkXnatObject; class MITKXNAT_EXPORT QmitkXnatCreateObjectDialog : public QDialog { Q_OBJECT public: enum SpecificType { // PROJECT, SUBJECT, EXPERIMENT }; QmitkXnatCreateObjectDialog(SpecificType type, QWidget *parent = 0); - virtual ~QmitkXnatCreateObjectDialog(); + ~QmitkXnatCreateObjectDialog() override; // Returns a specific xnat object like SpecificType ctkXnatObject *GetXnatObject(); protected slots: void OnAcceptClicked(); void OnCancelClicked(); private: SpecificType m_Type; ctkXnatObject *m_Object; QWidget *m_Widget; }; #endif // QMITKXNATCREATEOBJECTDIALOG_H diff --git a/Modules/XNAT/include/QmitkXnatExperimentWidget.h b/Modules/XNAT/include/QmitkXnatExperimentWidget.h index 146476d49b..2a78a216c7 100644 --- a/Modules/XNAT/include/QmitkXnatExperimentWidget.h +++ b/Modules/XNAT/include/QmitkXnatExperimentWidget.h @@ -1,57 +1,57 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological rmatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QMITKXNATEXPERIMENTWIDGET_H #define QMITKXNATEXPERIMENTWIDGET_H // XNATUI #include #include // Qt #include // CTK XNAT Core class ctkXnatExperiment; class MITKXNAT_EXPORT QmitkXnatExperimentWidget : public QWidget { Q_OBJECT public: enum Mode { INFO, CREATE }; QmitkXnatExperimentWidget(QWidget *parent = nullptr); QmitkXnatExperimentWidget(Mode mode, QWidget *parent = nullptr); - ~QmitkXnatExperimentWidget(); + ~QmitkXnatExperimentWidget() override; void SetExperiment(ctkXnatExperiment *experiment); ctkXnatExperiment *GetExperiment() const; protected: Ui::QmitkXnatExperimentWidgetControls m_Controls; private: void Init(); Mode m_Mode; ctkXnatExperiment *m_Experiment; }; #endif // QMITKXNATEXPERIMENTWIDGET_H diff --git a/Modules/XNAT/include/QmitkXnatProjectWidget.h b/Modules/XNAT/include/QmitkXnatProjectWidget.h index 0bed2fe2e2..d9022ecb21 100644 --- a/Modules/XNAT/include/QmitkXnatProjectWidget.h +++ b/Modules/XNAT/include/QmitkXnatProjectWidget.h @@ -1,57 +1,57 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological rmatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QMITKXNATPROJECTWIDGET_H #define QMITKXNATPROJECTWIDGET_H // XNATUI #include #include // Qt #include // CTK XNAT Core class ctkXnatProject; class MITKXNAT_EXPORT QmitkXnatProjectWidget : public QWidget { Q_OBJECT public: enum Mode { INFO, CREATE }; QmitkXnatProjectWidget(QWidget *parent = nullptr); QmitkXnatProjectWidget(Mode mode, QWidget *parent = nullptr); - ~QmitkXnatProjectWidget(); + ~QmitkXnatProjectWidget() override; void SetProject(ctkXnatProject *project); ctkXnatProject *GetProject() const; protected: Ui::QmitkXnatProjectWidgetControls m_Controls; private: void Init(); Mode m_Mode; ctkXnatProject *m_Project; }; #endif // QMITKXNATPROJECTWIDGET_H diff --git a/Modules/XNAT/include/QmitkXnatSubjectWidget.h b/Modules/XNAT/include/QmitkXnatSubjectWidget.h index c1f74a7755..fd96133220 100644 --- a/Modules/XNAT/include/QmitkXnatSubjectWidget.h +++ b/Modules/XNAT/include/QmitkXnatSubjectWidget.h @@ -1,56 +1,56 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QMITKXNATSUBJECTWIDGET_H #define QMITKXNATSUBJECTWIDGET_H #include #include // Qt #include // CTK XNAT Core class ctkXnatSubject; class MITKXNAT_EXPORT QmitkXnatSubjectWidget : public QWidget { Q_OBJECT public: enum Mode { INFO, CREATE }; QmitkXnatSubjectWidget(QWidget *parent = nullptr); QmitkXnatSubjectWidget(Mode mode, QWidget *parent = nullptr); - ~QmitkXnatSubjectWidget(); + ~QmitkXnatSubjectWidget() override; void SetSubject(ctkXnatSubject *subject); ctkXnatSubject *GetSubject() const; protected: Ui::QmitkXnatSubjectWidgetControls m_Controls; private: void Init(); Mode m_Mode; ctkXnatSubject *m_Subject; }; #endif // QMITKXNATSUBJECTWIDGET_H diff --git a/Modules/XNAT/include/QmitkXnatTreeModel.h b/Modules/XNAT/include/QmitkXnatTreeModel.h index 55f451d9aa..ca49dc14e7 100644 --- a/Modules/XNAT/include/QmitkXnatTreeModel.h +++ b/Modules/XNAT/include/QmitkXnatTreeModel.h @@ -1,63 +1,63 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QMITKXNATTREEMODEL_H #define QMITKXNATTREEMODEL_H // CTK includes #include // MITK includes #include "MitkXNATExports.h" namespace mitk { class DataNode; } class MITKXNAT_EXPORT QmitkXnatTreeModel : public ctkXnatTreeModel { Q_OBJECT public: QmitkXnatTreeModel(); - virtual QVariant data(const QModelIndex &index, int role) const; + QVariant data(const QModelIndex &index, int role) const override; - virtual bool dropMimeData( - const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent); + bool dropMimeData( + const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override; using QAbstractItemModel::supportedDropActions; virtual Qt::DropActions supportedDropActions(); - virtual Qt::ItemFlags flags(const QModelIndex &index) const; + Qt::ItemFlags flags(const QModelIndex &index) const override; ctkXnatObject *GetXnatObjectFromUrl(const QString &); void fetchMore(const QModelIndex &index) override; QModelIndexList match( const QModelIndex &start, int role, const QVariant &value, int hits, Qt::MatchFlags flags) const override; signals: void Error(const QModelIndex &idx); void ResourceDropped(const QList &, ctkXnatObject *, const QModelIndex &); private: ctkXnatObject *InternalGetXnatObjectFromUrl(const QString &xnatObjectType, const QString &url, ctkXnatObject *parent); }; #endif // QMITKXNATTREEMODEL_H diff --git a/Modules/XNAT/include/QmitkXnatUploadFromDataStorageDialog.h b/Modules/XNAT/include/QmitkXnatUploadFromDataStorageDialog.h index a56450e4ef..7e1f1f5f6e 100644 --- a/Modules/XNAT/include/QmitkXnatUploadFromDataStorageDialog.h +++ b/Modules/XNAT/include/QmitkXnatUploadFromDataStorageDialog.h @@ -1,45 +1,45 @@ #ifndef QMITKXNATUPLOADFROMDATASTORAGEDIALOG_H #define QMITKXNATUPLOADFROMDATASTORAGEDIALOG_H #include #include "MitkXNATExports.h" #include namespace Ui { class QmitkXnatUploadFromDataStorageDialog; } namespace mitk { class DataStorage; } class MITKXNAT_EXPORT QmitkXnatUploadFromDataStorageDialog : public QDialog { Q_OBJECT public: explicit QmitkXnatUploadFromDataStorageDialog(QWidget *parent = 0); - ~QmitkXnatUploadFromDataStorageDialog(); + ~QmitkXnatUploadFromDataStorageDialog() override; void SetDataStorage(mitk::DataStorage *ds); mitk::DataNode::Pointer GetSelectedNode(); protected slots: void OnUpload(); void OnUploadSceneChecked(); void OnCancel(); void OnMITKProjectFileNameEntered(const QString &text); void OnDataSelected(const mitk::DataNode *); private: Ui::QmitkXnatUploadFromDataStorageDialog *ui; mitk::DataNode::Pointer m_SelectedNode; }; #endif // QMITKXNATUPLOADFROMDATASTORAGEDIALOG_H diff --git a/Modules/XNAT/include/mitkXnatSessionTracker.h b/Modules/XNAT/include/mitkXnatSessionTracker.h index fda9e26126..3132de565a 100644 --- a/Modules/XNAT/include/mitkXnatSessionTracker.h +++ b/Modules/XNAT/include/mitkXnatSessionTracker.h @@ -1,54 +1,54 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef MITKXNATSESSIONTRACKER_H #define MITKXNATSESSIONTRACKER_H #include "usServiceTracker.h" #include "MitkXNATExports.h" #include "mitkXnatSession.h" namespace mitk { class MITKXNAT_EXPORT XnatSessionTracker : public QObject, public us::ServiceTracker { Q_OBJECT public: XnatSessionTracker(us::ModuleContext *context); signals: void Opened(ctkXnatSession *); void AboutToBeClosed(ctkXnatSession *); private: typedef us::ServiceTracker Superclass; us::ModuleContext *m_Context; - virtual TrackedType AddingService(const ServiceReferenceType &reference) override; - virtual void RemovedService(const ServiceReferenceType &reference, TrackedType tracked) override; + TrackedType AddingService(const ServiceReferenceType &reference) override; + void RemovedService(const ServiceReferenceType &reference, TrackedType tracked) override; private slots: void SessionOpened(); void SessionAboutToBeClosed(); }; } // end of namespace mitk #endif // MITKXNATSESSIONTRACKER_H diff --git a/Plugins/org.blueberry.core.runtime/src/dynamichelpers/berryExtensionTracker.cpp b/Plugins/org.blueberry.core.runtime/src/dynamichelpers/berryExtensionTracker.cpp index e3927457f0..945de316cf 100644 --- a/Plugins/org.blueberry.core.runtime/src/dynamichelpers/berryExtensionTracker.cpp +++ b/Plugins/org.blueberry.core.runtime/src/dynamichelpers/berryExtensionTracker.cpp @@ -1,334 +1,334 @@ /*=================================================================== BlueBerry Platform Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "berryExtensionTracker.h" #include #include #include #include #include #include #include #include #include "internal/berrySimpleExtensionPointFilter.h" #include #include #include #include namespace berry { struct ExtensionTracker::Impl { struct HandlerWrapper; ExtensionTracker* const q; QHash > extensionToStrongObjects; QHash > extensionToWeakObjects; //ListenerList handlers; QHash handlerToWrapper; QMutex mutex; bool closed; IExtensionRegistry* registry; // the registry that this tacker works with Impl(ExtensionTracker* q, IExtensionRegistry* theRegistry) : q(q) , closed(false) , registry(theRegistry) {} }; struct ExtensionTracker::Impl::HandlerWrapper : public IRegistryEventListener { ExtensionTracker* const q; IExtensionChangeHandler* const handler; HandlerWrapper(ExtensionTracker* q, IExtensionChangeHandler* handler) : q(q) , handler(handler) {} bool operator==(const HandlerWrapper& target) const { return handler == target.handler; } - virtual void Added(const QList& extensions) override + void Added(const QList& extensions) override { for (int i = 0; i < extensions.size(); ++i) { q->ApplyAdd(handler, extensions[i]); } } - virtual void Removed(const QList& extensions) override + void Removed(const QList& extensions) override { QList > removedObjects; { QMutexLocker lock(&q->d->mutex); for (int i = 0; i < extensions.size(); ++i) { QSet associatedObjects = q->d->extensionToStrongObjects.take(extensions[i]); foreach(const Object::WeakPtr& ptr, q->d->extensionToWeakObjects.take(extensions[i])) { if (!ptr.Expired()) { associatedObjects.insert(ptr.Lock()); } } removedObjects.push_back(associatedObjects.toList()); } } for (int i = 0; i < extensions.size(); ++i) { q->ApplyRemove(handler, extensions[i], removedObjects[i]); } } - virtual void Added(const QList& /*extensionPoints*/) override + void Added(const QList& /*extensionPoints*/) override { // do nothing } - virtual void Removed(const QList& /*extensionPoints*/) override + void Removed(const QList& /*extensionPoints*/) override { // do nothing } }; ExtensionTracker::ExtensionTracker() { this->Init(Platform::GetExtensionRegistry()); } ExtensionTracker::~ExtensionTracker() { } ExtensionTracker::ExtensionTracker(IExtensionRegistry* theRegistry) : d() { this->Init(theRegistry); } void ExtensionTracker::Init(IExtensionRegistry* registry) { d.reset(new Impl(this, registry)); if (registry == nullptr) { //RuntimeLog.log(new Status(IStatus.ERROR, RegistryMessages.OWNER_NAME, 0, RegistryMessages.registry_no_default, null)); BERRY_ERROR << "Extension tracker was unable to obtain BlueBerry extension registry."; d->closed = true; } } void ExtensionTracker::RegisterHandler(IExtensionChangeHandler* handler, const IExtensionPointFilter& filter) { QMutexLocker lock(&d->mutex); if (d->closed) return; auto iter = d->handlerToWrapper.insert(handler, new Impl::HandlerWrapper(this, handler)); d->registry->AddListener(iter.value(), filter); } void ExtensionTracker::RegisterHandler(IExtensionChangeHandler* handler, const QString& extensionPointId) { this->RegisterHandler(handler, extensionPointId.isEmpty() ? IExtensionPointFilter(nullptr) : IExtensionPointFilter(new SimpleExtensionPointFilter(extensionPointId))); } void ExtensionTracker::UnregisterHandler(IExtensionChangeHandler* handler) { QMutexLocker lock(&d->mutex); if (d->closed) return; IRegistryEventListener* listener = d->handlerToWrapper.take(handler); d->registry->RemoveListener(listener); delete listener; } void ExtensionTracker::RegisterObject(const SmartPointer& element, const SmartPointer& object, IExtensionTracker::ReferenceType referenceType) { if (element.IsNull() || object.IsNull()) return; QMutexLocker lock(&d->mutex); if (d->closed) return; if (referenceType == REF_STRONG) { d->extensionToStrongObjects[element].insert(object); } else if (referenceType == REF_WEAK) { d->extensionToWeakObjects[element].insert(Object::WeakPtr(object)); } } QList > ExtensionTracker::GetObjects(const IExtension::Pointer& element) const { QSet objectSet; QMutexLocker lock(&d->mutex); if (d->closed) return objectSet.toList(); auto iter = d->extensionToStrongObjects.find(element); if (iter != d->extensionToStrongObjects.end()) { objectSet.unite(iter.value()); } auto iter2 = d->extensionToWeakObjects.find(element); if (iter2 != d->extensionToWeakObjects.end()) { foreach(const Object::WeakPtr& ptr, iter2.value()) { if (!ptr.Expired()) objectSet.insert(ptr.Lock()); } } return objectSet.toList(); } void ExtensionTracker::Close() { QMutexLocker lock(&d->mutex); if (d->closed) return; foreach(Impl::HandlerWrapper* wrapper, d->handlerToWrapper.values()) { d->registry->RemoveListener(wrapper); delete wrapper; } d->extensionToStrongObjects.clear(); d->extensionToWeakObjects.clear(); d->handlerToWrapper.clear(); d->closed = true; } void ExtensionTracker::UnregisterObject(const SmartPointer& extension, const SmartPointer& object) { QMutexLocker lock(&d->mutex); if (d->closed) return; auto iter = d->extensionToStrongObjects.find(extension); if (iter != d->extensionToStrongObjects.end()) { iter.value().remove(object); } auto iter2 = d->extensionToWeakObjects.find(extension); if (iter2 != d->extensionToWeakObjects.end()) { iter2.value().remove(Object::WeakPtr(object)); } } QList > ExtensionTracker::UnregisterObject(const SmartPointer& extension) { QSet objectSet; QMutexLocker lock(&d->mutex); if (d->closed) return objectSet.toList(); auto iter = d->extensionToStrongObjects.find(extension); if (iter != d->extensionToStrongObjects.end()) { objectSet.unite(iter.value()); d->extensionToStrongObjects.erase(iter); } auto iter2 = d->extensionToWeakObjects.find(extension); if (iter2 != d->extensionToWeakObjects.end()) { foreach(const Object::WeakPtr& ptr, iter2.value()) { if (!ptr.Expired()) objectSet.insert(ptr.Lock()); } d->extensionToWeakObjects.erase(iter2); } return objectSet.toList(); } IExtensionPointFilter ExtensionTracker::CreateExtensionPointFilter(const SmartPointer& xpt) { struct F : IExtensionPointFilter::Concept { const IExtensionPoint::Pointer m_Xpt; F(const IExtensionPoint::Pointer& xp) : m_Xpt(xp) {} bool Matches(const IExtensionPoint* target) const override { return m_Xpt == target; } }; return IExtensionPointFilter(new F(xpt)); } IExtensionPointFilter ExtensionTracker::CreateExtensionPointFilter(const QList >& xpts) { struct F : IExtensionPointFilter::Concept { const QList m_Xpts; F(const QList& xps) : m_Xpts(xps) {} bool Matches(const IExtensionPoint* target) const override { for (int i = 0; i < m_Xpts.size(); i++) { if (m_Xpts[i] == target) { return true; } } return false; } }; return IExtensionPointFilter(new F(xpts)); } IExtensionPointFilter ExtensionTracker::CreateNamespaceFilter(const QString& id) { struct F : IExtensionPointFilter::Concept { const QString m_Id; F(const QString& id) : m_Id(id) {} bool Matches(const IExtensionPoint* target) const override { return m_Id == target->GetNamespaceIdentifier(); } }; return IExtensionPointFilter(new F(id)); } void ExtensionTracker::ApplyAdd(IExtensionChangeHandler* handler, const SmartPointer& extension) { handler->AddExtension(this, extension); } void ExtensionTracker::ApplyRemove(IExtensionChangeHandler* handler, const SmartPointer& removedExtension, const QList& removedObjects) { handler->RemoveExtension(removedExtension, removedObjects); } } diff --git a/Plugins/org.blueberry.ui.qt.help/src/internal/berryHelpPluginActivator.cpp b/Plugins/org.blueberry.ui.qt.help/src/internal/berryHelpPluginActivator.cpp index 7934590340..78827a8428 100644 --- a/Plugins/org.blueberry.ui.qt.help/src/internal/berryHelpPluginActivator.cpp +++ b/Plugins/org.blueberry.ui.qt.help/src/internal/berryHelpPluginActivator.cpp @@ -1,478 +1,478 @@ /*=================================================================== BlueBerry Platform Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "berryHelpPluginActivator.h" #include "berryHelpContentView.h" #include "berryHelpIndexView.h" #include "berryHelpSearchView.h" #include "berryHelpEditor.h" #include "berryHelpEditorInput.h" #include "berryHelpEditorInputFactory.h" #include "berryHelpPerspective.h" #include "berryQHelpEngineConfiguration.h" #include "berryQHelpEngineWrapper.h" #include #include #include #include namespace berry { class HelpPerspectiveListener : public IPerspectiveListener { public: Events::Types GetPerspectiveEventTypes() const override; using IPerspectiveListener::PerspectiveChanged; void PerspectiveOpened(const SmartPointer& page, const IPerspectiveDescriptor::Pointer& perspective) override; void PerspectiveChanged(const SmartPointer& page, const IPerspectiveDescriptor::Pointer& perspective, const QString &changeId) override; }; class HelpWindowListener : public IWindowListener { public: HelpWindowListener(); - ~HelpWindowListener(); + ~HelpWindowListener() override; void WindowClosed(const IWorkbenchWindow::Pointer& window) override; void WindowOpened(const IWorkbenchWindow::Pointer& window) override; private: // We use the same perspective listener for every window QScopedPointer perspListener; }; HelpPluginActivator* HelpPluginActivator::instance = nullptr; HelpPluginActivator::HelpPluginActivator() : pluginListener(nullptr) { this->instance = this; } HelpPluginActivator::~HelpPluginActivator() { instance = nullptr; } void HelpPluginActivator::start(ctkPluginContext* context) { BERRY_REGISTER_EXTENSION_CLASS(berry::HelpContentView, context) BERRY_REGISTER_EXTENSION_CLASS(berry::HelpIndexView, context) BERRY_REGISTER_EXTENSION_CLASS(berry::HelpSearchView, context) BERRY_REGISTER_EXTENSION_CLASS(berry::HelpEditor, context) BERRY_REGISTER_EXTENSION_CLASS(berry::HelpEditorInputFactory, context) BERRY_REGISTER_EXTENSION_CLASS(berry::HelpPerspective, context) QFileInfo qhcInfo = context->getDataFile("qthelpcollection.qhc"); helpEngine.reset(new QHelpEngineWrapper(qhcInfo.absoluteFilePath())); if (!helpEngine->setupData()) { BERRY_ERROR << "QHelpEngine set-up failed: " << helpEngine->error().toStdString(); return; } helpEngineConfiguration.reset(new QHelpEngineConfiguration(context, *helpEngine.data())); delete pluginListener; pluginListener = new QCHPluginListener(context, helpEngine.data()); context->connectPluginListener(pluginListener, SLOT(pluginChanged(ctkPluginEvent))); // register all QCH files from all the currently installed plugins pluginListener->processPlugins(); helpEngine->initialDocSetupDone(); // Register a wnd listener which registers a perspective listener for each // new window. The perspective listener opens the help home page in the window // if no other help page is opened yet. wndListener.reset(new HelpWindowListener()); PlatformUI::GetWorkbench()->AddWindowListener(wndListener.data()); // Register an event handler for CONTEXTHELP_REQUESTED events helpContextHandler.reset(new HelpContextHandler); ctkDictionary helpHandlerProps; helpHandlerProps.insert(ctkEventConstants::EVENT_TOPIC, "org/blueberry/ui/help/CONTEXTHELP_REQUESTED"); context->registerService(helpContextHandler.data(), helpHandlerProps); } void HelpPluginActivator::stop(ctkPluginContext* /*context*/) { delete pluginListener; pluginListener = nullptr; if (PlatformUI::IsWorkbenchRunning()) { PlatformUI::GetWorkbench()->RemoveWindowListener(wndListener.data()); } wndListener.reset(); helpEngineConfiguration.reset(); helpEngine.reset(); } HelpPluginActivator *HelpPluginActivator::getInstance() { return instance; } QHelpEngineWrapper& HelpPluginActivator::getQHelpEngine() { return *helpEngine; } void HelpPluginActivator::linkActivated(IWorkbenchPage::Pointer page, const QUrl &link) { IEditorInput::Pointer input(new HelpEditorInput(link)); // see if an editor with the same input is already open IEditorPart::Pointer reuseEditor = page->FindEditor(input); if (reuseEditor) { // just activate it page->Activate(reuseEditor); } else { // reuse the currently active editor, if it is a HelpEditor reuseEditor = page->GetActiveEditor(); if (reuseEditor.IsNotNull() && page->GetReference(reuseEditor)->GetId() == HelpEditor::EDITOR_ID) { page->ReuseEditor(reuseEditor.Cast(), input); page->Activate(reuseEditor); } else { // get the last used HelpEditor instance QList editors = page->FindEditors(IEditorInput::Pointer(nullptr), HelpEditor::EDITOR_ID, IWorkbenchPage::MATCH_ID); if (editors.empty()) { // no HelpEditor is currently open, create a new one page->OpenEditor(input, HelpEditor::EDITOR_ID); } else { // reuse an existing editor reuseEditor = editors.front()->GetEditor(false); page->ReuseEditor(reuseEditor.Cast(), input); page->Activate(reuseEditor); } } } } QCHPluginListener::QCHPluginListener(ctkPluginContext* context, QHelpEngine* helpEngine) : delayRegistration(true), context(context), helpEngine(helpEngine) {} void QCHPluginListener::processPlugins() { QMutexLocker lock(&mutex); processPlugins_unlocked(); } void QCHPluginListener::pluginChanged(const ctkPluginEvent& event) { QMutexLocker lock(&mutex); if (delayRegistration) { this->processPlugins_unlocked(); return; } /* Only should listen for RESOLVED and UNRESOLVED events. * * When a plugin is updated the Framework will publish an UNRESOLVED and * then a RESOLVED event which should cause the plugin to be removed * and then added back into the registry. * * When a plugin is uninstalled the Framework should publish an UNRESOLVED * event and then an UNINSTALLED event so the plugin will have been removed * by the UNRESOLVED event before the UNINSTALLED event is published. */ QSharedPointer plugin = event.getPlugin(); switch (event.getType()) { case ctkPluginEvent::RESOLVED : addPlugin(plugin); break; case ctkPluginEvent::UNRESOLVED : removePlugin(plugin); break; default: break; } } void QCHPluginListener::processPlugins_unlocked() { if (!delayRegistration) return; foreach (QSharedPointer plugin, context->getPlugins()) { if (isPluginResolved(plugin)) addPlugin(plugin); else removePlugin(plugin); } delayRegistration = false; } bool QCHPluginListener::isPluginResolved(QSharedPointer plugin) { return (plugin->getState() & (ctkPlugin::RESOLVED | ctkPlugin::ACTIVE | ctkPlugin::STARTING | ctkPlugin::STOPPING)) != 0; } void QCHPluginListener::removePlugin(QSharedPointer plugin) { // bail out if system plugin if (plugin->getPluginId() == 0) return; QFileInfo qchDirInfo = context->getDataFile("qch_files/" + QString::number(plugin->getPluginId())); if (qchDirInfo.exists()) { QDir qchDir(qchDirInfo.absoluteFilePath()); QStringList qchEntries = qchDir.entryList(QStringList("*.qch")); QStringList qchFiles; foreach(QString qchEntry, qchEntries) { qchFiles << qchDir.absoluteFilePath(qchEntry); } // unregister the cached qch files foreach(QString qchFile, qchFiles) { QString namespaceName = QHelpEngineCore::namespaceName(qchFile); if (namespaceName.isEmpty()) { BERRY_ERROR << "Could not get the namespace for qch file " << qchFile.toStdString(); continue; } else { if (!helpEngine->unregisterDocumentation(namespaceName)) { BERRY_ERROR << "Unregistering qch namespace " << namespaceName.toStdString() << " failed: " << helpEngine->error().toStdString(); } } } // clean the directory foreach(QString qchEntry, qchEntries) { qchDir.remove(qchEntry); } } } void QCHPluginListener::addPlugin(QSharedPointer plugin) { // bail out if system plugin if (plugin->getPluginId() == 0) return; QFileInfo qchDirInfo = context->getDataFile("qch_files/" + QString::number(plugin->getPluginId())); QUrl location(plugin->getLocation()); QFileInfo pluginFileInfo(location.toLocalFile()); if (!qchDirInfo.exists() || qchDirInfo.lastModified() < pluginFileInfo.lastModified()) { removePlugin(plugin); if (!qchDirInfo.exists()) { QDir().mkpath(qchDirInfo.absoluteFilePath()); } QStringList localQCHFiles; QStringList resourceList = plugin->findResources("/", "*.qch", true); foreach(QString resource, resourceList) { QByteArray content = plugin->getResource(resource); QFile localFile(qchDirInfo.absoluteFilePath() + "/" + resource.section('/', -1)); localFile.open(QIODevice::WriteOnly); localFile.write(content); localFile.close(); if (localFile.error() != QFile::NoError) { BERRY_WARN << "Error writing " << localFile.fileName().toStdString() << ": " << localFile.errorString().toStdString(); } else { localQCHFiles << localFile.fileName(); } } foreach(QString qchFile, localQCHFiles) { if (!helpEngine->registerDocumentation(qchFile)) { BERRY_ERROR << "Registering qch file " << qchFile.toStdString() << " failed: " << helpEngine->error().toStdString(); } } } } IPerspectiveListener::Events::Types HelpPerspectiveListener::GetPerspectiveEventTypes() const { return Events::OPENED | Events::CHANGED; } void HelpPerspectiveListener::PerspectiveOpened(const SmartPointer& page, const IPerspectiveDescriptor::Pointer& perspective) { // if no help editor is opened, open one showing the home page if (perspective->GetId() == HelpPerspective::ID && page->FindEditors(IEditorInput::Pointer(nullptr), HelpEditor::EDITOR_ID, IWorkbenchPage::MATCH_ID).empty()) { IEditorInput::Pointer input(new HelpEditorInput()); page->OpenEditor(input, HelpEditor::EDITOR_ID); } } void HelpPerspectiveListener::PerspectiveChanged(const SmartPointer& page, const IPerspectiveDescriptor::Pointer& perspective, const QString &changeId) { if (perspective->GetId() == HelpPerspective::ID && changeId == IWorkbenchPage::CHANGE_RESET) { PerspectiveOpened(page, perspective); } } HelpWindowListener::HelpWindowListener() : perspListener(new HelpPerspectiveListener()) { // Register perspective listener for already opened windows typedef QList WndVec; WndVec windows = PlatformUI::GetWorkbench()->GetWorkbenchWindows(); for (WndVec::iterator i = windows.begin(); i != windows.end(); ++i) { (*i)->AddPerspectiveListener(perspListener.data()); } } HelpWindowListener::~HelpWindowListener() { if (!PlatformUI::IsWorkbenchRunning()) return; typedef QList WndVec; WndVec windows = PlatformUI::GetWorkbench()->GetWorkbenchWindows(); for (WndVec::iterator i = windows.begin(); i != windows.end(); ++i) { (*i)->RemovePerspectiveListener(perspListener.data()); } } void HelpWindowListener::WindowClosed(const IWorkbenchWindow::Pointer& window) { window->RemovePerspectiveListener(perspListener.data()); } void HelpWindowListener::WindowOpened(const IWorkbenchWindow::Pointer& window) { window->AddPerspectiveListener(perspListener.data()); } void HelpContextHandler::handleEvent(const ctkEvent &event) { struct _runner : public Poco::Runnable { _runner(const ctkEvent& ev) : ev(ev) {} void run() override { QUrl helpUrl; if (ev.containsProperty("url")) { helpUrl = QUrl(ev.getProperty("url").toString()); } else { helpUrl = contextUrl(); } HelpPluginActivator::linkActivated(PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow()->GetActivePage(), helpUrl); delete this; } QUrl contextUrl() const { berry::IWorkbench* currentWorkbench = berry::PlatformUI::GetWorkbench(); if (currentWorkbench) { berry::IWorkbenchWindow::Pointer currentWorkbenchWindow = currentWorkbench->GetActiveWorkbenchWindow(); if (currentWorkbenchWindow) { berry::IWorkbenchPage::Pointer currentPage = currentWorkbenchWindow->GetActivePage(); if (currentPage) { berry::IWorkbenchPart::Pointer currentPart = currentPage->GetActivePart(); if (currentPart) { QString pluginID = currentPart->GetSite()->GetPluginId(); QString viewID = currentPart->GetSite()->GetId(); QString loc = "qthelp://" + pluginID + "/bundle/%1.html"; QHelpEngineWrapper& helpEngine = HelpPluginActivator::getInstance()->getQHelpEngine(); // Get view help page if available QUrl contextUrl(loc.arg(viewID.replace(".", "_"))); QUrl url = helpEngine.findFile(contextUrl); if (url.isValid()) return url; else { BERRY_INFO << "Context help url invalid: " << contextUrl.toString().toStdString(); } // If no view help exists get plugin help if available QUrl pluginContextUrl(loc.arg(pluginID.replace(".", "_"))); url = helpEngine.findFile(pluginContextUrl); if (url.isValid()) return url; // Try to get the index.html file of the plug-in contributing the // currently active part. QUrl pluginIndexUrl(loc.arg("index")); url = helpEngine.findFile(pluginIndexUrl); if (url != pluginIndexUrl) { // Use the default page instead of another index.html // (merged via the virtual folder property). url = QUrl(); } return url; } } } } return QUrl(); } ctkEvent ev; }; // sync with GUI thread Display::GetDefault()->AsyncExec(new _runner(event)); } } diff --git a/Plugins/org.blueberry.ui.qt.help/src/internal/berryHelpWebView.cpp b/Plugins/org.blueberry.ui.qt.help/src/internal/berryHelpWebView.cpp index ff375079a9..8e8085887d 100644 --- a/Plugins/org.blueberry.ui.qt.help/src/internal/berryHelpWebView.cpp +++ b/Plugins/org.blueberry.ui.qt.help/src/internal/berryHelpWebView.cpp @@ -1,454 +1,454 @@ /*=================================================================== BlueBerry Platform Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "berryHelpWebView.h" #include "berryHelpPluginActivator.h" #include "berryHelpEditor.h" #include "berryHelpEditorInput.h" #include "berryQHelpEngineWrapper.h" #include #include #include #include #include #include #include #include #include #include #include namespace berry { struct ExtensionMap { const char *extension; const char *mimeType; } extensionMap[] = { { ".bmp", "image/bmp" }, { ".css", "text/css" }, { ".gif", "image/gif" }, { ".html", "text/html" }, { ".htm", "text/html" }, { ".ico", "image/x-icon" }, { ".jpeg", "image/jpeg" }, { ".jpg", "image/jpeg" }, { ".js", "application/x-javascript" }, { ".mng", "video/x-mng" }, { ".pbm", "image/x-portable-bitmap" }, { ".pgm", "image/x-portable-graymap" }, { ".pdf", "application/pdf" }, { ".png", "image/png" }, { ".ppm", "image/x-portable-pixmap" }, { ".rss", "application/rss+xml" }, { ".svg", "image/svg+xml" }, { ".svgz", "image/svg+xml" }, { ".text", "text/plain" }, { ".tif", "image/tiff" }, { ".tiff", "image/tiff" }, { ".txt", "text/plain" }, { ".xbm", "image/x-xbitmap" }, { ".xml", "text/xml" }, { ".xpm", "image/x-xpm" }, { ".xsl", "text/xsl" }, { ".xhtml", "application/xhtml+xml" }, { ".wml", "text/vnd.wap.wml" }, { ".wmlc", "application/vnd.wap.wmlc" }, { "about:blank", nullptr }, { nullptr, nullptr } }; class HelpDeviceReply final : public QIODevice { public: HelpDeviceReply(const QUrl& request, const QByteArray& fileData); - ~HelpDeviceReply(); + ~HelpDeviceReply() override; qint64 bytesAvailable() const override; void close() override; private: qint64 readData(char* data, qint64 maxlen) override; qint64 writeData(const char* data, qint64 maxlen) override; QByteArray m_Data; const qint64 m_OrigLen; }; HelpDeviceReply::HelpDeviceReply(const QUrl&, const QByteArray& fileData) : m_Data(fileData), m_OrigLen(fileData.length()) { this->setOpenMode(QIODevice::ReadOnly); QTimer::singleShot(0, this, &QIODevice::readyRead); QTimer::singleShot(0, this, &QIODevice::readChannelFinished); } HelpDeviceReply::~HelpDeviceReply() { } qint64 HelpDeviceReply::bytesAvailable() const { return m_Data.length() + QIODevice::bytesAvailable(); } void HelpDeviceReply::close() { QIODevice::close(); this->deleteLater(); } qint64 HelpDeviceReply::readData(char* data, qint64 maxlen) { qint64 len = qMin(qint64(m_Data.length()), maxlen); if (len) { memcpy(data, m_Data.constData(), len); m_Data.remove(0, len); } return len; } qint64 HelpDeviceReply::writeData(const char*, qint64) { return 0; } class HelpUrlSchemeHandler final : public QWebEngineUrlSchemeHandler { public: explicit HelpUrlSchemeHandler(QObject* parent = nullptr); - ~HelpUrlSchemeHandler(); + ~HelpUrlSchemeHandler() override; void requestStarted(QWebEngineUrlRequestJob* job) override; }; HelpUrlSchemeHandler::HelpUrlSchemeHandler(QObject* parent) : QWebEngineUrlSchemeHandler(parent) { } HelpUrlSchemeHandler::~HelpUrlSchemeHandler() { } enum class ResolveUrlResult { Error, Redirect, Data }; ResolveUrlResult ResolveUrl(const QUrl& url, QUrl& redirectedUrl, QByteArray& data) { auto& helpEngine = HelpPluginActivator::getInstance()->getQHelpEngine(); const auto targetUrl = helpEngine.findFile(url); if (!targetUrl.isValid()) return ResolveUrlResult::Error; if (targetUrl != url) { redirectedUrl = targetUrl; return ResolveUrlResult::Redirect; } data = helpEngine.fileData(targetUrl); return ResolveUrlResult::Data; } void HelpUrlSchemeHandler::requestStarted(QWebEngineUrlRequestJob* job) { QUrl url = job->requestUrl(); QUrl redirectedUrl; QByteArray data; switch (ResolveUrl(url, redirectedUrl, data)) { case ResolveUrlResult::Data: job->reply( HelpWebView::mimeFromUrl(url).toLatin1(), new HelpDeviceReply(url, data)); break; case ResolveUrlResult::Redirect: job->redirect(redirectedUrl); break; case ResolveUrlResult::Error: job->reply( QByteArrayLiteral("text/html"), new HelpDeviceReply(url, HelpWebView::m_PageNotFoundMessage.arg(url.toString()).toUtf8())); break; } } const QString HelpWebView::m_PageNotFoundMessage = QCoreApplication::translate("org.blueberry.ui.qt.help", "Context Help


No help page found for identifier


'%1'" "

"); const QString HelpWebView::m_MissingContextMessage = QCoreApplication::translate("org.blueberry.ui.qt.help", "Context Help


Unknown context..

 

Please click inside a view and hit F1 again!

"); class HelpPage final : public QWebEnginePage { public: explicit HelpPage(QObject* parent = nullptr); - ~HelpPage(); + ~HelpPage() override; private: bool acceptNavigationRequest(const QUrl& url, NavigationType type, bool isMainFrame) override; }; HelpPage::HelpPage(QObject* parent) : QWebEnginePage(parent) { } HelpPage::~HelpPage() { } bool HelpPage::acceptNavigationRequest(const QUrl& url, NavigationType, bool) { if (url.scheme().contains("http")) { QDesktopServices::openUrl(url); return false; } return true; } HelpWebView::HelpWebView(IEditorSite::Pointer, QWidget *parent, qreal zoom) : QWebEngineView(parent), m_LoadFinished(false), m_HelpEngine(HelpPluginActivator::getInstance()->getQHelpEngine()), m_HelpSchemeHandler(new HelpUrlSchemeHandler(this)) { QWebEngineProfile::defaultProfile()->installUrlSchemeHandler("qthelp", m_HelpSchemeHandler); auto helpPage = new HelpPage(this); this->setPage(helpPage); this->setAcceptDrops(false); auto action = pageAction(QWebEnginePage::OpenLinkInNewWindow); action->setText("Open Link in New Tab"); if (parent == nullptr) action->setVisible(false); this->pageAction(QWebEnginePage::DownloadLinkToDisk)->setVisible(false); this->pageAction(QWebEnginePage::DownloadImageToDisk)->setVisible(false); connect(pageAction(QWebEnginePage::Copy), SIGNAL(changed()), this, SLOT(actionChanged())); connect(pageAction(QWebEnginePage::Back), SIGNAL(changed()), this, SLOT(actionChanged())); connect(pageAction(QWebEnginePage::Forward), SIGNAL(changed()), this, SLOT(actionChanged())); connect(page(), SIGNAL(linkHovered(QString)), this, SIGNAL(highlighted(QString))); connect(this, SIGNAL(urlChanged(QUrl)), this, SIGNAL(sourceChanged(QUrl))); connect(this, SIGNAL(loadStarted()), this, SLOT(setLoadStarted())); connect(this, SIGNAL(loadFinished(bool)), this, SLOT(setLoadFinished(bool))); this->setFont(this->viewerFont()); this->setZoomFactor(zoom == 0.0 ? 1.0 : zoom); } HelpWebView::~HelpWebView() { } QFont HelpWebView::viewerFont() const { QWebEngineSettings *webSettings = QWebEngineSettings::globalSettings(); return QFont(webSettings->fontFamily(QWebEngineSettings::StandardFont), webSettings->fontSize(QWebEngineSettings::DefaultFontSize)); } void HelpWebView::setViewerFont(const QFont &font) { QWebEngineSettings *webSettings = settings(); webSettings->setFontFamily(QWebEngineSettings::StandardFont, font.family()); webSettings->setFontSize(QWebEngineSettings::DefaultFontSize, font.pointSize()); } void HelpWebView::scaleUp() { setZoomFactor(zoomFactor() + 0.1); } void HelpWebView::scaleDown() { setZoomFactor(qMax(0.0, zoomFactor() - 0.1)); } void HelpWebView::resetScale() { setZoomFactor(1.0); } bool HelpWebView::handleForwardBackwardMouseButtons(QMouseEvent *e) { if (e->button() == Qt::XButton1) { triggerPageAction(QWebEnginePage::Back); return true; } if (e->button() == Qt::XButton2) { triggerPageAction(QWebEnginePage::Forward); return true; } return false; } void HelpWebView::setSource(const QUrl &url) { if (url.toString().trimmed().isEmpty()) { setHtml(m_MissingContextMessage); } else if (m_HelpEngine.findFile(url).isValid()) { load(url); } else { setHtml(m_PageNotFoundMessage.arg(url.toString())); } } void HelpWebView::wheelEvent(QWheelEvent *e) { if (e->modifiers()& Qt::ControlModifier) { e->accept(); e->delta() > 0 ? scaleUp() : scaleDown(); } else { QWebEngineView::wheelEvent(e); } } void HelpWebView::actionChanged() { QAction *a = qobject_cast(sender()); if (a == pageAction(QWebEnginePage::Copy)) emit copyAvailable(a->isEnabled()); else if (a == pageAction(QWebEnginePage::Back)) emit backwardAvailable(a->isEnabled()); else if (a == pageAction(QWebEnginePage::Forward)) emit forwardAvailable(a->isEnabled()); } void HelpWebView::setLoadStarted() { m_LoadFinished = false; } void HelpWebView::setLoadFinished(bool ok) { m_LoadFinished = ok; emit sourceChanged(url()); } QString HelpWebView::mimeFromUrl(const QUrl &url) { const QString &path = url.path(); const int index = path.lastIndexOf(QLatin1Char('.')); const QByteArray &ext = path.mid(index).toUtf8().toLower(); const ExtensionMap *e = extensionMap; while (e->extension) { if (ext == e->extension) return QLatin1String(e->mimeType); ++e; } return QLatin1String(""); } bool HelpWebView::canOpenPage(const QString &url) { return !mimeFromUrl(url).isEmpty(); } bool HelpWebView::isLocalUrl(const QUrl &url) { const QString &scheme = url.scheme(); return scheme.isEmpty() || scheme == QLatin1String("file") || scheme == QLatin1String("qrc") || scheme == QLatin1String("data") || scheme == QLatin1String("qthelp") || scheme == QLatin1String("about"); } bool HelpWebView::launchWithExternalApp(const QUrl &url) { if (isLocalUrl(url)) { const QHelpEngine& helpEngine = HelpPluginActivator::getInstance()->getQHelpEngine(); const QUrl &resolvedUrl = helpEngine.findFile(url); if (!resolvedUrl.isValid()) return false; const QString& path = resolvedUrl.path(); if (!canOpenPage(path)) { QTemporaryFile tmpTmpFile; if (!tmpTmpFile.open()) return false; const QString &extension = QFileInfo(path).completeSuffix(); QFile actualTmpFile(tmpTmpFile.fileName() % QLatin1String(".") % extension); if (!actualTmpFile.open(QIODevice::ReadWrite | QIODevice::Truncate)) return false; actualTmpFile.write(helpEngine.fileData(resolvedUrl)); actualTmpFile.close(); return QDesktopServices::openUrl(QUrl(actualTmpFile.fileName())); } } else if (url.scheme() == QLatin1String("http")) { return QDesktopServices::openUrl(url); } return false; } void HelpWebView::home() { setSource(m_HelpEngine.homePage()); } } diff --git a/Plugins/org.blueberry.ui.qt/src/internal/berryWorkbenchMenuService.cpp b/Plugins/org.blueberry.ui.qt/src/internal/berryWorkbenchMenuService.cpp index 62786ccae5..f3b2f27143 100644 --- a/Plugins/org.blueberry.ui.qt/src/internal/berryWorkbenchMenuService.cpp +++ b/Plugins/org.blueberry.ui.qt/src/internal/berryWorkbenchMenuService.cpp @@ -1,1063 +1,1063 @@ /*=================================================================== BlueBerry Platform Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "berryWorkbenchMenuService.h" #include #include #include #include #include #include #include #include #include #include #include "berryAbstractGroupMarker.h" #include "berryAbstractMenuAdditionCacheEntry.h" #include "berryAlwaysEnabledExpression.h" #include "berryContributionItem.h" #include "berryContributionRoot.h" #include "berryMenuManager.h" #include "berryWorkbenchPlugin.h" #include "berryWorkbenchWindow.h" #include namespace berry { const QString WorkbenchMenuService::INDEX_AFTER_ADDITIONS_QK = "after"; const QString WorkbenchMenuService::INDEX_AFTER_ADDITIONS_QV = "additions"; const QString WorkbenchMenuService::PROP_VISIBLE = "visible"; /** * A combined property and activity listener that updates the visibility of * contribution items in the new menu system. */ class ContributionItemUpdater : public IPropertyChangeListener //, public IIdentifierListener { private: const IContributionItem::Pointer item; //IIdentifier identifier; bool lastExpressionResult; WorkbenchMenuService* wms; void UpdateVisibility() { //bool visible = identifier.IsNotNull() ? (identifier->IsEnabled() && lastExpressionResult) // : lastExpressionResult; bool visible = lastExpressionResult; item->SetVisible(visible); IContributionManager* parent = nullptr; if (ContributionItem::Pointer ci = item.Cast()) { parent = ci->GetParent(); } else if (MenuManager::Pointer mm = item.Cast()) { parent = mm->GetParent(); } if (parent != nullptr) { parent->MarkDirty(); wms->managersAwaitingUpdates.insert(parent); } } public: ContributionItemUpdater(WorkbenchMenuService* wms, const IContributionItem::Pointer& item) //, IIdentifier identifier) : item(item), lastExpressionResult(true), wms(wms) { // if (identifier.IsNotNull()) // { // this->identifier = identifier; // this->identifier->AddIdentifierListener(this); // UpdateVisibility(); // force initial visibility to fall in line // // with activity enablement // } } /** * Dispose of this updater */ - ~ContributionItemUpdater() + ~ContributionItemUpdater() override { // if (identifier.IsNotNull()) // identifier->RemoveIdentifierListener(this); } using IPropertyChangeListener::PropertyChange; /* * @see IPropertyChangeListener#PropertyChange(PropertyChangeEvent) */ void PropertyChange(const PropertyChangeEvent::Pointer& event) override { if (event->GetProperty() == WorkbenchMenuService::PROP_VISIBLE) { if (event->GetNewValue().IsNotNull()) { lastExpressionResult = event->GetNewValue(); } else { lastExpressionResult = false; } UpdateVisibility(); } } /* * @see IIdentifierListener#IdentifierChanged(IdentifierEvent) */ // void identifierChanged(IdentifierEvent identifierEvent) // { // UpdateVisibility(); // } }; WorkbenchMenuService::ManagerPopulationRecord::ManagerPopulationRecord() : wms(nullptr), serviceLocatorToUse(nullptr), recurse(false) { } WorkbenchMenuService::ManagerPopulationRecord:: ManagerPopulationRecord(WorkbenchMenuService* wms, IServiceLocator* serviceLocatorToUse, const QSet >& restriction, const QString& uri, bool recurse) : wms(wms), serviceLocatorToUse(serviceLocatorToUse), restriction(restriction), uri(uri), recurse(recurse) { } void WorkbenchMenuService::ManagerPopulationRecord:: AddFactoryContribution(const SmartPointer& factory, const SmartPointer& ciList) { // Remove any existing cache info for this factory RemoveFactoryContribution(factory); // save the new info factoryToItems.insert(factory, ciList); } void WorkbenchMenuService::ManagerPopulationRecord:: RemoveFactoryContribution(const SmartPointer& factory) { ContributionRoot::Pointer items = factoryToItems.take(factory); if (items.IsNotNull()) { wms->ReleaseContributions(items.GetPointer()); } } SmartPointer WorkbenchMenuService::ManagerPopulationRecord:: GetContributions(const SmartPointer& factory) const { if (factoryToItems.contains(factory)) return factoryToItems[factory]; return ContributionRoot::Pointer(nullptr); } void WorkbenchMenuService::ManagerPopulationRecord:: ReleaseContributions() { foreach (ContributionRoot::Pointer items, factoryToItems.values()) { wms->ReleaseContributions(items.GetPointer()); } factoryToItems.clear(); } WorkbenchMenuService::WorkbenchMenuService(IServiceLocator* serviceLocator) : evaluationService(nullptr), serviceLocator(serviceLocator) { //this.menuPersistence = new MenuPersistence(this); evaluationService = serviceLocator->GetService(); evaluationService->AddServiceListener(GetServiceListener()); // IWorkbenchLocationService wls = (IWorkbenchLocationService) serviceLocator // .getService(IWorkbenchLocationService.class); // wls.getWorkbench() // .getActivitySupport().getActivityManager() // .addActivityManagerListener(getActivityManagerListener()); // final IExtensionRegistry registry = Platform.getExtensionRegistry(); // registryChangeListener = new IRegistryChangeListener() { // public void registryChanged(final IRegistryChangeEvent event) { // final Display display = PlatformUI.getWorkbench().getDisplay(); // if (display.isDisposed()) { // return; // } // display.syncExec(new Runnable() { // public void run() { // handleRegistryChanges(event); // } // }); // } // }; // registry.addRegistryChangeListener(registryChangeListener); } WorkbenchMenuService::~WorkbenchMenuService() { this->Dispose(); } void WorkbenchMenuService::Dispose() { //menuPersistence.dispose(); // if (registryChangeListener != null) // { // final IExtensionRegistry registry = Platform.getExtensionRegistry(); // registry.removeRegistryChangeListener(registryChangeListener); // registryChangeListener = null; // } foreach (IEvaluationReference::Pointer ref, evaluationsByItem.values()) { evaluationService->RemoveEvaluationListener(ref); } evaluationsByItem.clear(); managersAwaitingUpdates.clear(); evaluationService->RemoveServiceListener(GetServiceListener()); // if (activityManagerListener != null) // { // IWorkbenchLocationService wls = (IWorkbenchLocationService) serviceLocator // .getService(IWorkbenchLocationService.class); // IWorkbench workbench = wls.getWorkbench(); // if (workbench != null) // { // workbench.getActivitySupport().getActivityManager() // .removeActivityManagerListener(activityManagerListener); // } // } } void WorkbenchMenuService::AddSourceProvider(const SmartPointer& /*provider*/) { // no-op } void WorkbenchMenuService::ReadRegistry() { //menuPersistence.read(); } void WorkbenchMenuService::RemoveSourceProvider(const SmartPointer& /*provider*/) { // no-op } void WorkbenchMenuService::UpdateManagers() { QList managers = managersAwaitingUpdates.toList(); managersAwaitingUpdates.clear(); foreach (IContributionManager* mgr, managers) { mgr->Update(true); // if (ToolBarManager* tbMgr = dynamic_cast(mgr)) // { // if (!UpdateToolBar(tbMgr)) // { // //UpdateTrim((ToolBarManager) mgr); // } // } // else if (MenuManager* mMgr = dynamic_cast(mgr)) { IContributionManager* parent = mMgr->GetParent(); if (parent != nullptr) { parent->Update(true); } } } } WorkbenchMenuService::FactoryListType WorkbenchMenuService::GetAdditionsForURI(const QUrl& uri) { if (uri.isEmpty()) return FactoryListType(); return uriToFactories[GetIdFromURI(uri)]; } void WorkbenchMenuService::AddContributionFactory(const SmartPointer& factory) { if (factory.IsNull() || factory->GetLocation().isNull()) return; QUrl uri(factory->GetLocation()); QString factoryId = GetIdFromURI(uri); FactoryListType& factories = uriToFactories[factoryId]; { // MenuAdditionCacheEntry::Pointer mace = factory.Cast(); // if (mace && mace->HasAdditions()) // { // factories.push_front(factory); // } // else { factories.push_back(factory); } } // OK, now update any managers that use this uri FactoryListType factoryList; factoryList.push_back(factory); foreach (IContributionManager* mgr, GetManagersFor(factoryId)) { const ManagerPopulationRecord& mpr = populatedManagers[mgr]; AddContributionsToManager(mpr.serviceLocatorToUse, mpr.restriction, dynamic_cast(mgr), mpr.uri, mpr.recurse, factoryList); mgr->Update(true); } } void WorkbenchMenuService::RemoveContributionFactory(const SmartPointer& factory) { if (factory.IsNull() || factory->GetLocation().isNull()) return; QUrl uri(factory->GetLocation()); QString factoryId = GetIdFromURI(uri); if (uriToFactories.contains(factoryId)) { FactoryListType& factories = uriToFactories[factoryId]; // // Before we remove the top-level cache we recursively // // remove any sub-caches created by this one // if (MenuAdditionCacheEntry::Pointer mace = factory.Cast()) // { // QList subCaches = mace->GetSubCaches(); // foreach (AbstractMenuAdditionCacheEntry::Pointer amace, subCaches) // { // RemoveContributionFactory(amace); // } // } factories.removeAll(factory); } // OK, now update any managers that use this uri FactoryListType factoryList; factoryList.push_back(factory); foreach (IContributionManager* mgr, GetManagersFor(factoryId)) { RemoveContributionsForFactory(mgr, factory); mgr->Update(true); } } void WorkbenchMenuService::PopulateContributionManager(ContributionManager* mgr, const QString& uri) { PopulateContributionManager(serviceLocator, QSet >(), mgr, uri, true); } void WorkbenchMenuService::PopulateContributionManager(IServiceLocator* serviceLocatorToUse, const QSet >& restriction, ContributionManager* mgr, const QString& uri, bool recurse) { // Track this attempt to populate the menu, remembering all the parameters if (!populatedManagers.contains(mgr)) { populatedManagers.insert(mgr, ManagerPopulationRecord(this, serviceLocatorToUse, restriction, uri, recurse)); } QUrl contributionLocation(uri); FactoryListType factories = GetAdditionsForURI(contributionLocation); AddContributionsToManager(serviceLocatorToUse, restriction, mgr, uri, recurse, factories); } void WorkbenchMenuService::AddContributionsToManager(IServiceLocator* serviceLocatorToUse, const QSet >& restriction, ContributionManager* mgr, const QString& uri, bool recurse, const QList >& factories) { QUrl contributionLocation(uri); QList retryList; QSet itemsAdded; foreach (AbstractContributionFactory::Pointer cache, factories) { if (!ProcessAdditions(serviceLocatorToUse, restriction, mgr, cache, itemsAdded)) { retryList.push_back(cache); } } // OK, iteratively loop through entries whose URI's could not // be resolved until we either run out of entries or the list // doesn't change size (indicating that the remaining entries // can never be resolved). bool done = retryList.isEmpty(); while (!done) { // Clone the retry list and clear it QList curRetry = retryList; int retryCount = retryList.size(); retryList.clear(); // Walk the current list seeing if any entries can now be resolved foreach (AbstractContributionFactory::Pointer cache, curRetry) { if (!ProcessAdditions(serviceLocatorToUse, restriction, mgr, cache, itemsAdded)) { retryList.push_back(cache); } } // We're done if the retryList is now empty (everything done) or // if the list hasn't changed at all (no hope) done = retryList.isEmpty() || (retryList.size() == retryCount); } // Now, recurse through any sub-menus foreach (IContributionItem::Pointer curItem, mgr->GetItems()) { if (ContributionManager::Pointer cm = curItem.Cast()) { QString id = curItem->GetId(); if (!id.isEmpty() && (recurse || itemsAdded.contains(id))) { PopulateContributionManager(serviceLocatorToUse, restriction, cm.GetPointer(), contributionLocation.scheme() + ":" + id, true); } } // else if (IToolBarContributionItem::Pointer tbci = curItem.Cast()) // { // if (!(tbci->GetId().isEmpty()) && (recurse || itemsAdded.contains(tbci->GetId()))) // { // PopulateContributionManager(serviceLocatorToUse, // restriction, dynamic_cast(tbci->GetToolBarManager()), // contributionLocation.scheme() + ":" + tbci->GetId(), true); // } // } } } SmartPointer WorkbenchMenuService::GetCurrentState() const { return evaluationService->GetCurrentState(); } void WorkbenchMenuService::RegisterVisibleWhen(const SmartPointer& item, const SmartPointer& visibleWhen, QSet >& /*restriction*/, const QString& /*identifierID*/) { if (item.IsNull()) { throw std::invalid_argument("item cannot be null"); } if (visibleWhen.IsNull()) { throw std::invalid_argument("visibleWhen expression cannot be null"); } if (evaluationsByItem.contains(item)) { QString id = item->GetId(); WorkbenchPlugin::Log(QString("item is already registered: ") + (id.isEmpty() ? QString("no id") : id)); return; } // TODO activity support // IIdentifier identifier = null; // if (identifierID != null) { // identifier = PlatformUI.getWorkbench().getActivitySupport() // .getActivityManager().getIdentifier(identifierID); // } // ContributionItemUpdater* listener = // new ContributionItemUpdater(item, identifier); // if (visibleWhen != AlwaysEnabledExpression::INSTANCE) // { // IEvaluationReference::Pointer ref = evaluationService->AddEvaluationListener( // visibleWhen, listener, PROP_VISIBLE); // restriction.insert(ref); // evaluationsByItem.insert(item, ref); // } // activityListenersByItem.put(item, listener); } void WorkbenchMenuService::UnregisterVisibleWhen(const SmartPointer& item, QSet >& restriction) { // TODO activity support // ContributionItemUpdater identifierListener = (ContributionItemUpdater) activityListenersByItem // .remove(item); // if (identifierListener != null) { // identifierListener.dispose(); // } IEvaluationReference::Pointer ref = evaluationsByItem.take(item); if (ref.IsNull()) { return; } evaluationService->RemoveEvaluationListener(ref); restriction.remove(ref); } void WorkbenchMenuService::ReleaseContributions(ContributionManager* mgr) { if (mgr == nullptr) return; // Recursively remove any contributions from sub-menus foreach (IContributionItem::Pointer item, mgr->GetItems()) { if (ContributionManager::Pointer cm = item.Cast()) { ReleaseContributions(cm.GetPointer()); } // else if (IToolBarContributionItem::Pointer tbci = item.Cast()) // { // ReleaseContributions(tbci->GetToolBarManager()); // } } // Now remove any cached information if (populatedManagers.contains(mgr)) { populatedManagers[mgr].ReleaseContributions(); populatedManagers.remove(mgr); } managersAwaitingUpdates.remove(mgr); } //void WorkbenchMenuService::HandleDynamicAdditions(const QList >& menuAdditions) //{ // for (Iterator additionsIter = menuAdditions.iterator(); additionsIter.hasNext();) { // AbstractContributionFactory newFactory = null; // final IConfigurationElement menuAddition = (IConfigurationElement) additionsIter.next(); // if (isProgramaticContribution(menuAddition)) // newFactory = new ProxyMenuAdditionCacheEntry( // menuAddition // .getAttribute(IWorkbenchRegistryConstants.TAG_LOCATION_URI), // menuAddition.getNamespaceIdentifier(), menuAddition); // else // newFactory = new MenuAdditionCacheEntry( // this, // menuAddition, // menuAddition // .getAttribute(IWorkbenchRegistryConstants.TAG_LOCATION_URI), // menuAddition.getNamespaceIdentifier()); // if (newFactory != null) // addContributionFactory(newFactory); // } //} //void WorkbenchMenuService::HandleDynamicRemovals(const QList >& menuRemovals) //{ // for (Iterator additionsIter = menuRemovals.iterator(); additionsIter.hasNext();) { // IConfigurationElement ceToRemove = (IConfigurationElement) additionsIter.next(); // AbstractMenuAdditionCacheEntry factoryToRemove = findFactory(ceToRemove); // removeContributionFactory(factoryToRemove); // } //} //void WorkbenchMenuService::HandleRegistryChanges(const SmartPointer& event) //{ // // HACK!! determine if this is an addition or deletion from the first delta // IExtensionDelta[] deltas = event.getExtensionDeltas(); // if (deltas.length == 0) // return; // boolean isAddition = deltas[0].getKind() == IExtensionDelta.ADDED; // // access all the necessary service persistence handlers // HandlerService handlerSvc = (HandlerService) serviceLocator.getService(IHandlerService.class); // HandlerPersistence handlerPersistence = handlerSvc.getHandlerPersistence(); // CommandService cmdSvc = (CommandService) serviceLocator.getService(ICommandService.class); // CommandPersistence cmdPersistence = cmdSvc.getCommandPersistence(); // BindingService bindingSvc = (BindingService) serviceLocator.getService(IBindingService.class); // BindingPersistence bindingPersistence = bindingSvc.getBindingPersistence(); // boolean needsUpdate = false; // // determine order from the type of delta // if (isAddition) { // // additions order: Commands, Handlers, Bindings, Menus // if (cmdPersistence.commandsNeedUpdating(event)) { // cmdPersistence.reRead(); // needsUpdate = true; // } // if (handlerPersistence.handlersNeedUpdating(event)) { // handlerPersistence.reRead(); // needsUpdate = true; // } // if (bindingPersistence.bindingsNeedUpdating(event)) { // bindingPersistence.reRead(); // needsUpdate = true; // } // if (menuPersistence.menusNeedUpdating(event)) { // handleMenuChanges(event); // needsUpdate = true; // } // } // else { // // Removal order: Menus, Bindings, Handlers, Commands // if (menuPersistence.menusNeedUpdating(event)) { // handleMenuChanges(event); // needsUpdate = true; // } // if (bindingPersistence.bindingsNeedUpdating(event)) { // bindingPersistence.reRead(); // needsUpdate = true; // } // if (handlerPersistence.handlersNeedUpdating(event)) { // final IExtensionDelta[] handlerDeltas = event.getExtensionDeltas( // PlatformUI.PLUGIN_ID, IWorkbenchRegistryConstants.PL_HANDLERS); // for (int i = 0; i < handlerDeltas.length; i++) { // IConfigurationElement[] ices = handlerDeltas[i].getExtension().getConfigurationElements(); // HandlerProxy.updateStaleCEs(ices); // } // handlerPersistence.reRead(); // needsUpdate = true; // } // if (cmdPersistence.commandsNeedUpdating(event)) { // cmdPersistence.reRead(); // needsUpdate = true; // } // } // if (needsUpdate) { // ContributionManager[] managers = (ContributionManager[]) populatedManagers // .keySet().toArray( // new ContributionManager[populatedManagers.keySet() // .size()]); // for (int i = 0; i < managers.length; i++) { // ContributionManager mgr = managers[i]; // mgr.update(false); // } // } //} //MenuPersistence* WorkbenchMenuService::GetMenuPersistence() //{ // return menuPersistence; //} void WorkbenchMenuService::PopulateContributionManager(ContributionManager* mgr, const QString& uri, bool recurse) { PopulateContributionManager(serviceLocator, QSet(), mgr, uri, recurse); } void WorkbenchMenuService::RemoveContributionsForFactory(IContributionManager* manager, const SmartPointer& factory) { populatedManagers[manager].RemoveFactoryContribution(factory); // automatically cleans its caches } void WorkbenchMenuService::ReleaseContributions(ContributionRoot* items) { ContributionManager* mgr = items->GetManager(); foreach(IContributionItem::Pointer item, items->GetItems()) { ReleaseItem(item, items->restriction); mgr->Remove(item); } ReleaseCache(items); } void WorkbenchMenuService::PropertyChange(const PropertyChangeEvent::Pointer& event) { if (event->GetProperty() == IEvaluationService::PROP_NOTIFYING) { if (!(event->GetNewValue().Cast()->GetValue())) { // if it's false, the evaluation service has // finished with its latest round of updates this->UpdateManagers(); } } } //SmartPointer WorkbenchMenuService::GetActivityManagerListener() //{ // if (activityManagerListener == null) { // activityManagerListener = new IActivityManagerListener() { // public void activityManagerChanged( // ActivityManagerEvent activityManagerEvent) { // if (activityManagerEvent.haveEnabledActivityIdsChanged()) { // updateManagers(); // called after all identifiers have // // been update - now update the // // managers // } // } // }; // } // return activityManagerListener; //} IPropertyChangeListener* WorkbenchMenuService::GetServiceListener() { return this; } //void WorkbenchMenuService::UpdateTrim(ToolBarManager* mgr) //{ // Control control = mgr.getControl(); // if (control == null || control.isDisposed()) { // return; // } // LayoutUtil.resize(control); //} bool WorkbenchMenuService::UpdateToolBar(ToolBarManager* /*mgr*/) { // QList windows = PlatformUI::GetWorkbench()->GetWorkbenchWindows(); // QList::iterator wend = windows.end(); // for (QList::iterator i = windows.begin(); i != wend; ++i) // { // WorkbenchWindow::Pointer window = i->Cast(); // IToolBarManager* tb = window->GetToolBarManager(); // if (tb != 0) // { // foreach (IContributionItem::Pointer item, tb->GetItems()) // { // if (ToolBarContributionItem::Pointer tbci = item.Cast()) // { // IToolBarManager* tbm = tbci->GetToolBarManager(); // if (mgr == tbm) // { // tb->Update(true); // return true; // } // } // } // } // } return false; } QString WorkbenchMenuService::GetIdFromURI(const QUrl& uri) { return uri.scheme() + ":" + uri.path(); } QList WorkbenchMenuService::GetManagersFor(const QString& factoryId) { QList mgrs; QHashIterator mgrIter(populatedManagers); while(mgrIter.hasNext()) { if (factoryId == mgrIter.value().uri) { mgrs.push_back(mgrIter.key()); } } return mgrs; } bool WorkbenchMenuService::ProcessAdditions(IServiceLocator* serviceLocatorToUse, const QSet >& restriction, ContributionManager* mgr, const AbstractContributionFactory::Pointer& cache, QSet& itemsAdded) { if (!ProcessFactory(mgr, cache)) return true; const int idx = GetInsertionIndex(mgr, cache->GetLocation()); if (idx == -1) return false; // can't process (yet) struct _SafeRunnable : public ISafeRunnable { WorkbenchMenuService* wms; int insertionIndex; IServiceLocator* serviceLocatorToUse; QSet > restriction; ContributionManager* mgr; AbstractContributionFactory::Pointer cache; QSet& itemsAdded; _SafeRunnable(WorkbenchMenuService* wms, int idx, IServiceLocator* serviceLocatorToUse, const QSet >& restriction, ContributionManager* mgr, AbstractContributionFactory::Pointer cache, QSet& itemsAdded) : wms(wms), insertionIndex(idx), serviceLocatorToUse(serviceLocatorToUse), restriction(restriction), mgr(mgr), cache(cache), itemsAdded(itemsAdded) {} void HandleException(const ctkException&) override {} void Run() override { // Get the additions ContributionRoot::Pointer ciList(new ContributionRoot(wms, restriction, mgr, cache.GetPointer())); cache->CreateContributionItems(serviceLocatorToUse, ciList); // If we have any then add them at the correct location if (!ciList->GetItems().isEmpty()) { // Cache the items for future cleanup ManagerPopulationRecord& mpr = wms->populatedManagers[mgr]; ContributionRoot::Pointer contributions = mpr.GetContributions(cache); if (contributions.IsNotNull()) { // Existing contributions in the mgr will be released. // Adjust the insertionIndex foreach (IContributionItem::Pointer item, contributions->GetItems()) { if (item == mgr->Find(item->GetId())) insertionIndex--; } } mpr.AddFactoryContribution(cache, ciList); foreach (IContributionItem::Pointer ici, ciList->GetItems()) { if ((ici.Cast() || //ici.Cast || ici.Cast()) && !(ici->GetId().isEmpty())) { IContributionItem::Pointer foundIci = mgr->Find(ici->GetId()); // really, this is a very specific scenario that // allows merging but, if it is a contribution manager that also // contains items, then we would be throwing stuff away. if (ContributionManager::Pointer cm = foundIci.Cast()) { if (cm->GetSize() > 0) { // IStatus status = new Status( // IStatus.WARNING, // WorkbenchPlugin.PI_WORKBENCH, // "Menu contribution id collision: " // + ici.getId()); // StatusManager.getManager().handle(status); BERRY_WARN << "Menu contribution id collision: " << ici->GetId().toStdString(); } continue; } // else if (IToolBarContributionItem::Pointer tbci = foundIci.Cast()) // { // IToolBarManager* toolBarManager = tbci->GetToolBarManager(); // if (ContributionManager::Pointer tbcm = dynamic_cast(toolBarManager) // && tbcm->GetSize() > 0) // { //// IStatus status = new Status( //// IStatus.WARNING, //// WorkbenchPlugin.PI_WORKBENCH, //// "Toolbar contribution id collision: " //$NON-NLS-1$ //// + ici.getId()); //// StatusManager.getManager().handle(status); // BERRY_WARN << "Toolbar contribution id collision: " << ici->GetId().toStdString(); // } // continue; // } else if (foundIci.Cast()) { continue; } } const int oldSize = mgr->GetSize(); mgr->Insert(insertionIndex, ici); if (!ici->GetId().isEmpty()) { itemsAdded.insert(ici->GetId()); } if (mgr->GetSize() > oldSize) insertionIndex++; } } } }; ISafeRunnable::Pointer run (new _SafeRunnable(this, idx, serviceLocatorToUse, restriction, mgr, cache, itemsAdded)); SafeRunner::Run(run); return true; } bool WorkbenchMenuService::ProcessFactory(ContributionManager* mgr, const AbstractContributionFactory::Pointer& factory) { QUrl uri(factory->GetLocation()); if (MenuUtil::ANY_POPUP == (uri.scheme() + ':' + uri.path())) { // its any popup. check whether manager has additions if (mgr->IndexOf(WorkbenchActionConstants::MB_ADDITIONS) == -1) { // // menu has no additions. Add only if allPopups = true // if (MenuAdditionCacheEntry::Pointer menuEntry = factory.Cast()) // { // return menuEntry->ContributeToAllPopups(); // } } } return true; } void WorkbenchMenuService::ReleaseCache(ContributionRoot* items) { items->Release(); } int WorkbenchMenuService::GetInsertionIndex(ContributionManager* mgr, const QString& location) { QUrl uri(location); QUrlQuery query(uri); QList > queryParts = query.queryItems(); bool indexAfterAdditions = query.queryItemValue(INDEX_AFTER_ADDITIONS_QK) == INDEX_AFTER_ADDITIONS_QV; int additionsIndex = -1; // No Query means 'after=additions' (if there) or // the end of the menu if (queryParts.isEmpty() || indexAfterAdditions) { additionsIndex = mgr->IndexOf(WorkbenchActionConstants::MB_ADDITIONS); if (additionsIndex == -1) additionsIndex = mgr->GetItems().size(); else ++additionsIndex; } else { // Should be in the form "[before|after|endof]=id" if (queryParts.size() > 0 && !(queryParts[0].second.isEmpty())) { QString modifier = queryParts[0].first; QString id = queryParts[0].second; additionsIndex = mgr->IndexOf(id); if (additionsIndex != -1) { if (MenuUtil::QUERY_BEFORE == modifier) { // this is OK, the additionsIndex will either be correct // or -1 (which is a no-op) } else if (MenuUtil::QUERY_AFTER == modifier) { additionsIndex++; } else if (MenuUtil::QUERY_ENDOF == modifier) { // OK, this one is exciting QList items = mgr->GetItems(); for (additionsIndex++; additionsIndex < items.size(); additionsIndex++) { if (items[additionsIndex]->IsGroupMarker()) { break; } } } } } } return additionsIndex; } void WorkbenchMenuService::ReleaseItem(const SmartPointer& item, QSet >& restriction) { UnregisterVisibleWhen(item, restriction); if (ContributionManager::Pointer cm = item.Cast()) { ReleaseContributions(cm.GetPointer()); } // else if (IToolBarContributionItem::Pointer tbci = item.Cast()) // { // ReleaseContributions(dynamic_cast(tbci->GetToolBarManager())); // } } bool WorkbenchMenuService::IsProgramaticContribution(const SmartPointer& menuAddition) const { return !menuAddition->GetAttribute(WorkbenchRegistryConstants::ATT_CLASS).isEmpty(); } SmartPointer WorkbenchMenuService::FindFactory(const SmartPointer& ceToRemove) { QUrl uri = ceToRemove->GetAttribute(WorkbenchRegistryConstants::TAG_LOCATION_URI); FactoryListType factories = GetAdditionsForURI(uri); foreach (AbstractContributionFactory::Pointer factory, GetAdditionsForURI(uri)) { if (AbstractMenuAdditionCacheEntry::Pointer mace = factory.Cast()) { if (mace->GetConfigElement() == ceToRemove) return mace; } } return AbstractMenuAdditionCacheEntry::Pointer(nullptr); } //void WorkbenchMenuService::HandleMenuChanges(const SmartPointer& event) //{ // final IExtensionDelta[] menuDeltas = event.getExtensionDeltas( // PlatformUI.PLUGIN_ID, IWorkbenchRegistryConstants.PL_MENUS); // final List menuAdditions = new ArrayList(); // final List menuRemovals = new ArrayList(); // for (int i = 0; i < menuDeltas.length; i++) { // IConfigurationElement[] ices = menuDeltas[i].getExtension().getConfigurationElements(); // for (int j = 0; j < ices.length; j++) { // if (IWorkbenchRegistryConstants.PL_MENU_CONTRIBUTION.equals(ices[j].getName())) { // if (menuDeltas[i].getKind() == IExtensionDelta.ADDED) // menuAdditions.add(ices[j]); // else // menuRemovals.add(ices[j]); // } // } // } // // Handle additions // if (menuAdditions.size() > 0) { // handleDynamicAdditions(menuAdditions); // } // // Handle Removals // if (menuRemovals.size() > 0) { // handleDynamicRemovals(menuRemovals); // } //} } diff --git a/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/QmitkDiffusionImagingAppWorkbenchAdvisor.cpp b/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/QmitkDiffusionImagingAppWorkbenchAdvisor.cpp index 26dd08c6ca..417146690b 100644 --- a/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/QmitkDiffusionImagingAppWorkbenchAdvisor.cpp +++ b/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/QmitkDiffusionImagingAppWorkbenchAdvisor.cpp @@ -1,99 +1,99 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "QmitkDiffusionImagingAppWorkbenchAdvisor.h" #include "internal/QmitkDiffusionApplicationPlugin.h" #include #include #include #include #include #include #include #include const QString QmitkDiffusionImagingAppWorkbenchAdvisor::WELCOME_PERSPECTIVE_ID = "org.mitk.diffusionimagingapp.perspectives.welcome"; class QmitkDiffusionImagingAppWorkbenchWindowAdvisor : public QmitkExtWorkbenchWindowAdvisor { public: QmitkDiffusionImagingAppWorkbenchWindowAdvisor(berry::WorkbenchAdvisor* wbAdvisor, berry::IWorkbenchWindowConfigurer::Pointer configurer) : QmitkExtWorkbenchWindowAdvisor(wbAdvisor, configurer) { } - void PostWindowOpen() + void PostWindowOpen() override { QmitkExtWorkbenchWindowAdvisor::PostWindowOpen(); berry::IWorkbenchWindowConfigurer::Pointer configurer = GetWindowConfigurer(); configurer->GetWindow()->GetWorkbench()->GetIntroManager()->ShowIntro(configurer->GetWindow(), false); } }; void QmitkDiffusionImagingAppWorkbenchAdvisor::Initialize(berry::IWorkbenchConfigurer::Pointer configurer) { berry::QtWorkbenchAdvisor::Initialize(configurer); configurer->SetSaveAndRestore(true); } berry::WorkbenchWindowAdvisor* QmitkDiffusionImagingAppWorkbenchAdvisor::CreateWorkbenchWindowAdvisor( berry::IWorkbenchWindowConfigurer::Pointer configurer) { QList perspExcludeList; perspExcludeList.push_back( "org.blueberry.uitest.util.EmptyPerspective" ); perspExcludeList.push_back( "org.blueberry.uitest.util.EmptyPerspective2" ); perspExcludeList.push_back("org.blueberry.perspectives.help"); QList viewExcludeList; viewExcludeList.push_back( "org.mitk.views.controlvisualizationpropertiesview" ); viewExcludeList.push_back( "org.mitk.views.modules" ); //QRect rec = QApplication::desktop()->screenGeometry(); //configurer->SetInitialSize(QPoint(rec.width(),rec.height())); QmitkDiffusionImagingAppWorkbenchWindowAdvisor* advisor = new QmitkDiffusionImagingAppWorkbenchWindowAdvisor(this, configurer); advisor->ShowViewMenuItem(true); advisor->ShowNewWindowMenuItem(true); advisor->ShowClosePerspectiveMenuItem(true); advisor->SetPerspectiveExcludeList(perspExcludeList); advisor->SetViewExcludeList(viewExcludeList); advisor->ShowViewToolbar(false); advisor->ShowPerspectiveToolbar(true); advisor->ShowVersionInfo(false); advisor->ShowMitkVersionInfo(false); advisor->ShowMemoryIndicator(false); advisor->SetProductName("MITK Diffusion"); advisor->SetWindowIcon(":/org.mitk.gui.qt.diffusionimagingapp/app-icon.png"); return advisor; } QString QmitkDiffusionImagingAppWorkbenchAdvisor::GetInitialWindowPerspectiveId() { return WELCOME_PERSPECTIVE_ID; } diff --git a/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkDiffusionImagingAppIntroPart.cpp b/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkDiffusionImagingAppIntroPart.cpp index 3aa3ec9d25..5292e05208 100644 --- a/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkDiffusionImagingAppIntroPart.cpp +++ b/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkDiffusionImagingAppIntroPart.cpp @@ -1,202 +1,202 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "QmitkDiffusionImagingAppIntroPart.h" #include "mitkNodePredicateDataType.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "QmitkDiffusionApplicationPlugin.h" #include "mitkDataStorageEditorInput.h" #include #include "mitkProgressBar.h" #include "mitkNodePredicateNot.h" #include "mitkNodePredicateProperty.h" namespace { class QmitkDiffusionWebEnginePage final : public QWebEnginePage { public: explicit QmitkDiffusionWebEnginePage(QmitkDiffusionImagingAppIntroPart* introPart, QObject* parent = nullptr); - ~QmitkDiffusionWebEnginePage(); + ~QmitkDiffusionWebEnginePage() override; private: bool acceptNavigationRequest(const QUrl& url, NavigationType type, bool isMainFrame) override; QmitkDiffusionImagingAppIntroPart* m_IntroPart; }; QmitkDiffusionWebEnginePage::QmitkDiffusionWebEnginePage(QmitkDiffusionImagingAppIntroPart* introPart, QObject* parent) : QWebEnginePage(parent), m_IntroPart(introPart) { } QmitkDiffusionWebEnginePage::~QmitkDiffusionWebEnginePage() { } bool QmitkDiffusionWebEnginePage::acceptNavigationRequest(const QUrl& url, NavigationType, bool) { QString scheme = url.scheme(); if (scheme.contains("mitk")) { if (url.path().isEmpty()) return false; if (url.host().contains("perspectives")) { QString id = url.path().simplified().replace("/", ""); auto introSite = m_IntroPart->GetIntroSite(); auto workbenchWindow = introSite->GetWorkbenchWindow(); auto workbench = workbenchWindow->GetWorkbench(); workbench->ShowPerspective(id, workbenchWindow); auto context = QmitkDiffusionApplicationPlugin::GetDefault()->GetPluginContext(); auto serviceReference = context->getServiceReference(); mitk::IDataStorageService* service = serviceReference ? context->getService(serviceReference) : nullptr; if (service) { berry::IEditorInput::Pointer editorInput(new mitk::DataStorageEditorInput(service->GetActiveDataStorage())); auto page = introSite->GetPage(); auto editors = page->FindEditors(editorInput, "org.mitk.editors.stdmultiwidget", 1); if (!editors.isEmpty()) page->Activate(editors[0]->GetPart(true)); } } } else if (scheme.contains("http")) { QDesktopServices::openUrl(url); } else { return true; } return false; } } QmitkDiffusionImagingAppIntroPart::QmitkDiffusionImagingAppIntroPart() : m_Controls(nullptr) { berry::IPreferences::Pointer workbenchPrefs = QmitkDiffusionApplicationPlugin::GetDefault()->GetPreferencesService()->GetSystemPreferences(); workbenchPrefs->PutBool(berry::WorkbenchPreferenceConstants::SHOW_INTRO, true); workbenchPrefs->Flush(); } QmitkDiffusionImagingAppIntroPart::~QmitkDiffusionImagingAppIntroPart() { // if the workbench is not closing (that means, welcome screen was closed explicitly), set "Show_intro" false if (!this->GetIntroSite()->GetPage()->GetWorkbenchWindow()->GetWorkbench()->IsClosing()) { berry::IPreferences::Pointer workbenchPrefs = QmitkDiffusionApplicationPlugin::GetDefault()->GetPreferencesService()->GetSystemPreferences(); workbenchPrefs->PutBool(berry::WorkbenchPreferenceConstants::SHOW_INTRO, false); workbenchPrefs->Flush(); } else { berry::IPreferences::Pointer workbenchPrefs = QmitkDiffusionApplicationPlugin::GetDefault()->GetPreferencesService()->GetSystemPreferences(); workbenchPrefs->PutBool(berry::WorkbenchPreferenceConstants::SHOW_INTRO, true); workbenchPrefs->Flush(); } // if workbench is not closing (Just welcome screen closing), open last used perspective if (this->GetIntroSite()->GetPage()->GetPerspective()->GetId() == "org.mitk.diffusionimagingapp.perspectives.welcome" && !this->GetIntroSite()->GetPage()->GetWorkbenchWindow()->GetWorkbench()->IsClosing()) { berry::IPerspectiveDescriptor::Pointer perspective = this->GetIntroSite()->GetWorkbenchWindow()->GetWorkbench()->GetPerspectiveRegistry()->FindPerspectiveWithId("org.mitk.perspectives.diffusiondefault"); if (perspective) { this->GetIntroSite()->GetPage()->SetPerspective(perspective); } } } void QmitkDiffusionImagingAppIntroPart::CreateQtPartControl(QWidget* parent) { if (!m_Controls) { // create GUI widgets m_Controls = new Ui::QmitkWelcomeScreenViewControls; m_Controls->setupUi(parent); m_view = new QWebEngineView(parent); auto page = new QmitkDiffusionWebEnginePage(this, parent); m_view->setPage(page); QUrl urlQtResource(QString("qrc:/org.mitk.gui.qt.welcomescreen/mitkdiffusionimagingappwelcomeview.html"), QUrl::TolerantMode ); m_view->load( urlQtResource ); // adds the webview as a widget parent->layout()->addWidget(m_view); this->CreateConnections(); } } void QmitkDiffusionImagingAppIntroPart::CreateConnections() { } void QmitkDiffusionImagingAppIntroPart::StandbyStateChanged(bool) { } void QmitkDiffusionImagingAppIntroPart::SetFocus() { } diff --git a/Plugins/org.mitk.gui.qt.dosevisualization/src/internal/RTDoseVisualizer.cpp b/Plugins/org.mitk.gui.qt.dosevisualization/src/internal/RTDoseVisualizer.cpp index 2ceb10fce7..ae29c058ff 100644 --- a/Plugins/org.mitk.gui.qt.dosevisualization/src/internal/RTDoseVisualizer.cpp +++ b/Plugins/org.mitk.gui.qt.dosevisualization/src/internal/RTDoseVisualizer.cpp @@ -1,825 +1,825 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ // Qt #include #include // Blueberry #include #include // MITK #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include // Qmitk #include "RTDoseVisualizer.h" #include #include #include #include #include #include "QmitkRenderWindow.h" #include "org_mitk_gui_qt_dosevisualization_Activator.h" #include #include "vtkDecimatePro.h" const std::string RTDoseVisualizer::VIEW_ID = "org.mitk.views.rt.dosevisualization"; const std::string RTDoseVisualizer::ISO_LINE_NODE_NAME = "dose iso lines"; namespace mitk { /** @brief Predicate to identify dose nodes. Didn't use NodePredicateeDataProperty, because we want only depend on the property value ('RTDOSE') and not on the property type (e.g. StringProperty or mitkTemperoSpatialStringProperty).*/ class NodePredicateDose : public NodePredicateBase { public: mitkClassMacro(NodePredicateDose, NodePredicateBase); itkNewMacro(NodePredicateDose); - virtual ~NodePredicateDose() + ~NodePredicateDose() override {}; - virtual bool CheckNode(const mitk::DataNode *node) const override + bool CheckNode(const mitk::DataNode *node) const override { if (!node) return false; auto data = node->GetData(); if (!data) { return false; } auto modalityProperty = data->GetProperty(mitk::GeneratePropertyNameForDICOMTag(0x0008, 0x0060).c_str()); if (modalityProperty.IsNull()) { return false; } std::string modality = modalityProperty->GetValueAsString(); return modality == "RTDOSE"; }; protected: NodePredicateDose() {}; }; } // namespace mitk RTDoseVisualizer::RTDoseVisualizer() { m_selectedNode = nullptr; m_selectedPresetName = ""; m_PrescribedDose_Data = 0.0; m_freeIsoValuesCount = 0; m_internalUpdate = false; m_isDoseOrIsoPredicate = mitk::NodePredicateDose::New(); m_isIsoPredicate = mitk::NodePredicateProperty::New("name", mitk::StringProperty::New(ISO_LINE_NODE_NAME)); m_isDosePredicate = mitk::NodePredicateAnd::New(m_isDoseOrIsoPredicate, mitk::NodePredicateNot::New(m_isIsoPredicate)); } RTDoseVisualizer::~RTDoseVisualizer() { mitk::DataStorage::SetOfObjects::ConstPointer isoNodes = this->GetDataStorage()->GetSubset(m_isIsoPredicate); this->GetDataStorage()->Remove(isoNodes); delete m_LevelSetModel; delete m_DoseColorDelegate; delete m_DoseValueDelegate; delete m_DoseVisualDelegate; } void RTDoseVisualizer::SetFocus(){} void RTDoseVisualizer::CreateQtPartControl( QWidget *parent ) { // create GUI widgets from the Qt Designer's .ui file m_Controls.setupUi( parent ); m_LevelSetModel = new QmitkIsoDoseLevelSetModel(this); m_LevelSetModel->setVisibilityEditOnly(true); m_DoseColorDelegate = new QmitkDoseColorDelegate(this); m_DoseValueDelegate = new QmitkDoseValueDelegate(this); m_DoseVisualDelegate = new QmitkDoseVisualStyleDelegate(this); this->UpdateByPreferences(); auto doseNodes = this->GetDataStorage()->GetSubset(this->m_isDosePredicate); auto doseNodeIter = doseNodes->begin(); while (doseNodeIter != doseNodes->end()) { PrepareDoseNode(*doseNodeIter); ++doseNodeIter; } this->ActualizeIsoLevelsForAllDoseDataNodes(); this->ActualizeReferenceDoseForAllDoseDataNodes(); this->ActualizeDisplayStyleForAllDoseDataNodes(); this->m_Controls.isoLevelSetView->setModel(m_LevelSetModel); this->m_Controls.isoLevelSetView->setItemDelegateForColumn(0,m_DoseColorDelegate); this->m_Controls.isoLevelSetView->setItemDelegateForColumn(1,m_DoseValueDelegate); this->m_Controls.isoLevelSetView->setItemDelegateForColumn(2,m_DoseVisualDelegate); this->m_Controls.isoLevelSetView->setItemDelegateForColumn(3,m_DoseVisualDelegate); this->m_Controls.isoLevelSetView->setContextMenuPolicy(Qt::CustomContextMenu); this->m_Controls.btnRemoveFreeValue->setDisabled(true); this->m_Controls.doseBtn->setVisible(false); connect(m_Controls.spinReferenceDose, SIGNAL(valueChanged(double)), this, SLOT(OnReferenceDoseChanged(double))); connect(m_Controls.spinReferenceDose, SIGNAL(valueChanged(double)), m_LevelSetModel, SLOT(setReferenceDose(double))); connect(m_Controls.radioAbsDose, SIGNAL(toggled(bool)), m_LevelSetModel, SLOT(setShowAbsoluteDose(bool))); connect(m_Controls.radioAbsDose, SIGNAL(toggled(bool)), this, SLOT(OnAbsDoseToggled(bool))); connect(m_Controls.btnAddFreeValue, SIGNAL(clicked()), this, SLOT(OnAddFreeValueClicked())); connect(m_Controls.btnRemoveFreeValue, SIGNAL(clicked()), this, SLOT(OnRemoveFreeValueClicked())); connect(m_Controls.checkGlobalVisColorWash, SIGNAL(toggled(bool)), this, SLOT(OnGlobalVisColorWashToggled(bool))); connect(m_Controls.checkGlobalVisIsoLine, SIGNAL(toggled(bool)), this, SLOT(OnGlobalVisIsoLineToggled(bool))); connect(m_Controls.isoLevelSetView, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(OnShowContextMenuIsoSet(const QPoint&))); connect(m_Controls.comboPresets, SIGNAL(currentIndexChanged ( const QString&)), this, SLOT(OnCurrentPresetChanged(const QString&))); connect(m_Controls.btnUsePrescribedDose, SIGNAL(clicked()), this, SLOT(OnUsePrescribedDoseClicked())); connect(m_Controls.isoLevelSetView->model(), SIGNAL( modelReset()), this, SLOT(OnDataChangedInIsoLevelSetView())); ctkServiceReference ref = mitk::org_mitk_gui_qt_dosevisualization_Activator::GetContext()->getServiceReference(); ctkDictionary propsForSlot; if (ref) { ctkEventAdmin* eventAdmin = mitk::org_mitk_gui_qt_dosevisualization_Activator::GetContext()->getService(ref); propsForSlot[ctkEventConstants::EVENT_TOPIC] = mitk::RTCTKEventConstants::TOPIC_ISO_DOSE_LEVEL_PRESETS_CHANGED.c_str(); eventAdmin->subscribeSlot(this, SLOT(OnHandleCTKEventPresetsChanged(ctkEvent)), propsForSlot); propsForSlot[ctkEventConstants::EVENT_TOPIC] = mitk::RTCTKEventConstants::TOPIC_REFERENCE_DOSE_CHANGED.c_str(); eventAdmin->subscribeSlot(this, SLOT(OnHandleCTKEventReferenceDoseChanged(ctkEvent)), propsForSlot); propsForSlot[ctkEventConstants::EVENT_TOPIC] = mitk::RTCTKEventConstants::TOPIC_GLOBAL_VISIBILITY_CHANGED.c_str(); eventAdmin->subscribeSlot(this, SLOT(OnHandleCTKEventGlobalVisChanged(ctkEvent)), propsForSlot); } this->UpdateBySelectedNode(); } void RTDoseVisualizer::OnReferenceDoseChanged(double value) { if (! m_internalUpdate) { mitk::DoseValueAbs referenceDose = 0.0; bool globalSync = mitk::GetReferenceDoseValue(referenceDose); if (globalSync) { mitk::SetReferenceDoseValue(globalSync, value); this->ActualizeReferenceDoseForAllDoseDataNodes(); } else { if (this->m_selectedNode.IsNotNull()) { this->m_selectedNode->SetFloatProperty(mitk::RTConstants::REFERENCE_DOSE_PROPERTY_NAME.c_str(), value); mitk::DataNode::Pointer isoDoseNode = this->GetIsoDoseNode(m_selectedNode); if (isoDoseNode.IsNotNull()) isoDoseNode->SetFloatProperty(mitk::RTConstants::REFERENCE_DOSE_PROPERTY_NAME.c_str(), value); } } if (this->m_selectedNode.IsNotNull()) { this->UpdateColorWashTransferFunction(); mitk::RenderingManager::GetInstance()->RequestUpdateAll(); } } } void RTDoseVisualizer::OnAddFreeValueClicked() { QColor newColor; //Use HSV schema of QColor to calculate a different color depending on the //number of already existing free iso lines. newColor.setHsv((m_freeIsoValuesCount*85)%360,255,255); mitk::IsoDoseLevel::ColorType mColor; mColor[0]=newColor.redF(); mColor[1]=newColor.greenF(); mColor[2]=newColor.blueF(); mitk::IsoDoseLevelVector::Pointer freeIsoDoseVector; mitk::IsoDoseLevelVectorProperty::Pointer propIsoVector; mitk::DataNode::Pointer isoDoseNode = this->GetIsoDoseNode(m_selectedNode); if (isoDoseNode.IsNotNull()) { propIsoVector = dynamic_cast(isoDoseNode->GetProperty(mitk::RTConstants::DOSE_FREE_ISO_VALUES_PROPERTY_NAME.c_str())); freeIsoDoseVector = propIsoVector->GetValue(); if (freeIsoDoseVector.IsNull()) mitk::IsoDoseLevelVector::Pointer freeIsoDoseVector = mitk::IsoDoseLevelVector::New(); mitk::IsoDoseLevel::Pointer newLevel = mitk::IsoDoseLevel::New(0.5, mColor, true, false); freeIsoDoseVector->InsertElement(m_freeIsoValuesCount, newLevel); propIsoVector = mitk::IsoDoseLevelVectorProperty::New(freeIsoDoseVector); isoDoseNode->SetProperty(mitk::RTConstants::DOSE_FREE_ISO_VALUES_PROPERTY_NAME.c_str(), propIsoVector); m_freeIsoValuesCount++; this->m_Controls.btnRemoveFreeValue->setEnabled(true); //Update Widget this->UpdateFreeIsoValues(); //Update Rendering this->ActualizeFreeIsoLine(); } } void RTDoseVisualizer::OnRemoveFreeValueClicked() { int index = this->m_Controls.listFreeValues->currentRow(); if (index > static_cast(m_freeIsoValuesCount) || index < 0) return; mitk::IsoDoseLevelVectorProperty::Pointer propfreeIsoVec; mitk::DataNode::Pointer isoDoseNode = this->GetIsoDoseNode(m_selectedNode); propfreeIsoVec = dynamic_cast(isoDoseNode->GetProperty(mitk::RTConstants::DOSE_FREE_ISO_VALUES_PROPERTY_NAME.c_str())); mitk::IsoDoseLevelVector::Pointer freeIsoDoseLevelVec = propfreeIsoVec->GetValue(); if(freeIsoDoseLevelVec->IndexExists(index)) { //freeIsoDoseLevelVec->DeleteIndex(index); freeIsoDoseLevelVec->erase(freeIsoDoseLevelVec->begin()+index); --m_freeIsoValuesCount; if(m_freeIsoValuesCount == 0) this->m_Controls.btnRemoveFreeValue->setEnabled(true); this->UpdateFreeIsoValues(); this->ActualizeFreeIsoLine(); } } void RTDoseVisualizer::OnUsePrescribedDoseClicked() { m_Controls.spinReferenceDose->setValue(this->m_PrescribedDose_Data); } void RTDoseVisualizer::OnDataChangedInIsoLevelSetView() { //colorwash visibility changed, update the colorwash this->UpdateColorWashTransferFunction(); if(m_selectedNode.IsNotNull()) { //Hack: This is a dirty hack to reinit the isodose contour node. Only if the node (or property) has changed the rendering process register the RequestUpdateAll //Only way to render the isoline by changes without a global reinit mitk::DataNode::Pointer isoDoseNode = this->GetIsoDoseNode(m_selectedNode); if (isoDoseNode.IsNotNull()) isoDoseNode->Modified(); // Reinit if visibility of colorwash or isodoselevel changed mitk::RenderingManager::GetInstance()->RequestUpdateAll(); } } void RTDoseVisualizer::OnShowContextMenuIsoSet(const QPoint& pos) { QPoint globalPos = m_Controls.isoLevelSetView->viewport()->mapToGlobal(pos); QMenu viewMenu; QAction* invertIsoLineAct = viewMenu.addAction("Invert iso line visibility"); QAction* activateIsoLineAct = viewMenu.addAction("Activate all iso lines"); QAction* deactivateIsoLineAct = viewMenu.addAction("Deactivate all iso lines"); viewMenu.addSeparator(); QAction* invertColorWashAct = viewMenu.addAction("Invert color wash visibility"); QAction* activateColorWashAct = viewMenu.addAction("Activate all color wash levels"); QAction* deactivateColorWashAct = viewMenu.addAction("Deactivate all color wash levels"); viewMenu.addSeparator(); QAction* swapAct = viewMenu.addAction("Swap iso line/color wash visibility"); // ... QAction* selectedItem = viewMenu.exec(globalPos); if (selectedItem == invertIsoLineAct) { this->m_LevelSetModel->invertVisibilityIsoLines(); } else if (selectedItem == activateIsoLineAct) { this->m_LevelSetModel->switchVisibilityIsoLines(true); } else if (selectedItem == deactivateIsoLineAct) { this->m_LevelSetModel->switchVisibilityIsoLines(false); } else if (selectedItem == invertColorWashAct) { this->m_LevelSetModel->invertVisibilityColorWash(); } else if (selectedItem == activateColorWashAct) { this->m_LevelSetModel->switchVisibilityColorWash(true); } else if (selectedItem == deactivateColorWashAct) { this->m_LevelSetModel->switchVisibilityColorWash(false); } else if (selectedItem == swapAct) { this->m_LevelSetModel->swapVisibility(); } } void RTDoseVisualizer::UpdateFreeIsoValues() { this->m_Controls.listFreeValues->clear(); mitk::DataNode::Pointer isoDoseNode = this->GetIsoDoseNode(m_selectedNode); if (isoDoseNode.IsNotNull()) { mitk::IsoDoseLevelVectorProperty::Pointer propfreeIsoVec; propfreeIsoVec = dynamic_cast(isoDoseNode->GetProperty(mitk::RTConstants::DOSE_FREE_ISO_VALUES_PROPERTY_NAME.c_str())); mitk::IsoDoseLevelVector::Pointer freeIsoDoseLevelVec = propfreeIsoVec->GetValue(); for (mitk::IsoDoseLevelVector::Iterator pos = freeIsoDoseLevelVec->Begin(); pos != freeIsoDoseLevelVec->End(); ++pos) { QListWidgetItem* item = new QListWidgetItem; item->setSizeHint(QSize(0, 25)); QmitkFreeIsoDoseLevelWidget* widget = new QmitkFreeIsoDoseLevelWidget; float pref; m_selectedNode->GetFloatProperty(mitk::RTConstants::REFERENCE_DOSE_PROPERTY_NAME.c_str(), pref); widget->setIsoDoseLevel(pos.Value()); widget->setReferenceDose(pref); connect(m_Controls.spinReferenceDose, SIGNAL(valueChanged(double)), widget, SLOT(setReferenceDose(double))); connect(widget, SIGNAL(ColorChanged(mitk::IsoDoseLevel*)), this, SLOT(ActualizeFreeIsoLine())); connect(widget, SIGNAL(ValueChanged(mitk::IsoDoseLevel*, mitk::DoseValueRel)), this, SLOT(ActualizeFreeIsoLine())); connect(widget, SIGNAL(VisualizationStyleChanged(mitk::IsoDoseLevel*)), this, SLOT(ActualizeFreeIsoLine())); this->m_Controls.listFreeValues->addItem(item); this->m_Controls.listFreeValues->setItemWidget(item, widget); } } } void RTDoseVisualizer::ActualizeFreeIsoLine() { if(m_selectedNode.IsNotNull()) { //Hack: This is a dirty hack to reinit the isodose contour node. Only if the node (or property) has changed the rendering process register the RequestUpdateAll //Only way to render the isoline by changes without a global reinit mitk::DataNode::Pointer isoDoseNode = this->GetIsoDoseNode(m_selectedNode); if (isoDoseNode.IsNotNull()) isoDoseNode->Modified(); // Reinit if visibility of colorwash or isodoselevel changed mitk::RenderingManager::GetInstance()->RequestUpdateAll(); } } void RTDoseVisualizer::OnAbsDoseToggled(bool showAbs) { if (! m_internalUpdate) { mitk::SetDoseDisplayAbsolute(showAbs); this->ActualizeDisplayStyleForAllDoseDataNodes(); } } void RTDoseVisualizer::OnGlobalVisColorWashToggled(bool showColorWash) { if (m_selectedNode.IsNotNull()) { m_selectedNode->SetBoolProperty(mitk::RTConstants::DOSE_SHOW_COLORWASH_PROPERTY_NAME.c_str(), showColorWash); //The rendering mode could be set in the dose mapper: Refactoring! mitk::RenderingModeProperty::Pointer renderingMode = mitk::RenderingModeProperty::New(); if(showColorWash) renderingMode->SetValue(mitk::RenderingModeProperty::COLORTRANSFERFUNCTION_COLOR); else renderingMode->SetValue(mitk::RenderingModeProperty::LOOKUPTABLE_LEVELWINDOW_COLOR); m_selectedNode->SetProperty("Image Rendering.Mode", renderingMode); mitk::RenderingManager::GetInstance()->RequestUpdateAll(); } } void RTDoseVisualizer::OnGlobalVisIsoLineToggled(bool showIsoLines) { if (m_selectedNode.IsNotNull()) { mitk::DataNode::Pointer isoDoseNode = this->GetIsoDoseNode(m_selectedNode); if (isoDoseNode.IsNotNull()) { isoDoseNode->SetBoolProperty(mitk::RTConstants::DOSE_SHOW_ISOLINES_PROPERTY_NAME.c_str(), showIsoLines); //toggle the visibility of the free isolevel sliders this->m_Controls.listFreeValues->setEnabled(showIsoLines); mitk::RenderingManager::GetInstance()->RequestUpdateAll(); } } } void RTDoseVisualizer::UpdateColorWashTransferFunction() { //Generating the Colorwash vtkSmartPointer transferFunction = vtkSmartPointer::New(); if(m_selectedNode.IsNotNull()) { mitk::IsoDoseLevelSetProperty::Pointer propIsoSet = dynamic_cast(m_selectedNode->GetProperty(mitk::RTConstants::DOSE_ISO_LEVELS_PROPERTY_NAME.c_str())); mitk::IsoDoseLevelSet::Pointer isoDoseLevelSet = propIsoSet->GetValue(); float referenceDose; m_selectedNode->GetFloatProperty(mitk::RTConstants::REFERENCE_DOSE_PROPERTY_NAME.c_str(),referenceDose); mitk::TransferFunction::ControlPoints scalarOpacityPoints; scalarOpacityPoints.push_back( std::make_pair(0, 1 ) ); //Backgroud transferFunction->AddHSVPoint(((isoDoseLevelSet->Begin())->GetDoseValue()*referenceDose)-0.001,0,0,0,1.0,1.0); for(mitk::IsoDoseLevelSet::ConstIterator itIsoDoseLevel = isoDoseLevelSet->Begin(); itIsoDoseLevel != isoDoseLevelSet->End(); ++itIsoDoseLevel) { float *hsv = new float[3]; //used for transfer rgb to hsv vtkSmartPointer cCalc = vtkSmartPointer::New(); if(itIsoDoseLevel->GetVisibleColorWash()) { cCalc->RGBToHSV(itIsoDoseLevel->GetColor()[0],itIsoDoseLevel->GetColor()[1],itIsoDoseLevel->GetColor()[2],&hsv[0],&hsv[1],&hsv[2]); transferFunction->AddHSVPoint(itIsoDoseLevel->GetDoseValue()*referenceDose,hsv[0],hsv[1],hsv[2],1.0,1.0); } else { scalarOpacityPoints.push_back( std::make_pair(itIsoDoseLevel->GetDoseValue()*referenceDose, 1 ) ); } } mitk::TransferFunction::Pointer mitkTransFunc = mitk::TransferFunction::New(); mitk::TransferFunctionProperty::Pointer mitkTransFuncProp = mitk::TransferFunctionProperty::New(); mitkTransFunc->SetColorTransferFunction(transferFunction); mitkTransFunc->SetScalarOpacityPoints(scalarOpacityPoints); mitkTransFuncProp->SetValue(mitkTransFunc); m_selectedNode->SetProperty("Image Rendering.Transfer Function", mitkTransFuncProp); } } /**Simple check if the passed node has dose visualization properties set.*/ bool hasDoseVisProperties(mitk::DataNode::Pointer doseNode) { return doseNode->GetProperty(mitk::RTConstants::REFERENCE_DOSE_PROPERTY_NAME.c_str()) != nullptr; } void RTDoseVisualizer::OnSelectionChanged( berry::IWorkbenchPart::Pointer, const QList&) { QList dataNodes = this->GetDataManagerSelection(); mitk::DataNode* selectedNode = nullptr; if (!dataNodes.empty()) { bool isDoseNode = m_isDosePredicate->CheckNode(dataNodes[0].GetPointer()); if (isDoseNode) { selectedNode = dataNodes[0]; } } if (selectedNode != m_selectedNode.GetPointer()) { m_selectedNode = selectedNode; if (selectedNode) { PrepareDoseNode(m_selectedNode); } } UpdateBySelectedNode(); } void RTDoseVisualizer::PrepareDoseNode( mitk::DataNode* doseNode ) const { mitk::DoseValueAbs dose; mitk::GetReferenceDoseValue(dose); auto presetMap = mitk::LoadPresetsMap(); auto colorPreset = mitk::GeneratIsoLevels_Virtuos(); auto finding = presetMap.find(mitk::GetSelectedPresetName()); if (finding != presetMap.end()) { colorPreset = finding->second; } if (!hasDoseVisProperties(doseNode)) { mitk::ConfigureNodeAsDoseNode(doseNode, colorPreset, dose, true); } mitk::DataNode::Pointer doseOutlineNode = this->GetIsoDoseNode(doseNode); if (doseOutlineNode.IsNull()) { doseOutlineNode = mitk::DataNode::New(); doseOutlineNode->SetData(doseNode->GetData()); doseOutlineNode->SetName(ISO_LINE_NODE_NAME); mitk::ConfigureNodeAsIsoLineNode(doseOutlineNode, colorPreset, dose, true); this->GetDataStorage()->Add(doseOutlineNode, doseNode); } } void RTDoseVisualizer::UpdateBySelectedNode() { m_Controls.groupNodeSpecific->setEnabled(m_selectedNode.IsNotNull()); m_Controls.groupFreeValues->setEnabled(m_selectedNode.IsNotNull()); m_Controls.checkGlobalVisColorWash->setEnabled(m_selectedNode.IsNotNull()); m_Controls.checkGlobalVisIsoLine->setEnabled(m_selectedNode.IsNotNull()); m_Controls.isoLevelSetView->setEnabled(m_selectedNode.IsNotNull()); if(m_selectedNode.IsNull()) { m_Controls.NrOfFractions->setText(QString("N/A. No dose selected")); m_Controls.prescribedDoseSpecific->setText(QString("N/A. No dose selected")); } else { //dose specific information int fracCount = 1; m_selectedNode->GetIntProperty(mitk::RTConstants::DOSE_FRACTION_COUNT_PROPERTY_NAME.c_str(), fracCount); m_Controls.NrOfFractions->setText(QString::number(fracCount)); m_PrescribedDose_Data = 0.0; auto prescibedDoseProperty = m_selectedNode->GetData()->GetProperty(mitk::RTConstants::PRESCRIBED_DOSE_PROPERTY_NAME.c_str()); auto prescribedDoseGenericProperty = dynamic_cast*>(prescibedDoseProperty.GetPointer()); m_PrescribedDose_Data = prescribedDoseGenericProperty->GetValue(); m_Controls.prescribedDoseSpecific->setText(QString::number(m_PrescribedDose_Data)); //free iso lines mitk::DataNode::Pointer isoDoseNode = this->GetIsoDoseNode(m_selectedNode); if (isoDoseNode) { mitk::IsoDoseLevelVectorProperty::Pointer propIsoVector; propIsoVector = dynamic_cast(isoDoseNode->GetProperty(mitk::RTConstants::DOSE_FREE_ISO_VALUES_PROPERTY_NAME.c_str())); if (propIsoVector.IsNull()) { mitk::IsoDoseLevelVector::Pointer freeIsoValues = mitk::IsoDoseLevelVector::New(); propIsoVector = mitk::IsoDoseLevelVectorProperty::New(freeIsoValues); isoDoseNode->SetProperty(mitk::RTConstants::DOSE_FREE_ISO_VALUES_PROPERTY_NAME.c_str(), propIsoVector); } UpdateFreeIsoValues(); //global dose issues //ATM the IsoDoseContours have an own (helper) node which is a child of dose node; Will be fixed with the doseMapper refactoring bool showIsoLine = mitk::GetGlobalIsolineVis(); isoDoseNode->GetBoolProperty(mitk::RTConstants::DOSE_SHOW_ISOLINES_PROPERTY_NAME.c_str(), showIsoLine); m_Controls.checkGlobalVisIsoLine->setChecked(showIsoLine); } bool showColorWash = mitk::GetGlobalColorwashVis(); m_selectedNode->GetBoolProperty(mitk::RTConstants::DOSE_SHOW_COLORWASH_PROPERTY_NAME.c_str(),showColorWash); m_Controls.checkGlobalVisColorWash->setChecked(showColorWash); float referenceDose = 0.0; m_selectedNode->GetFloatProperty(mitk::RTConstants::REFERENCE_DOSE_PROPERTY_NAME.c_str(),referenceDose); m_Controls.spinReferenceDose->setValue(referenceDose); mitk::IsoDoseLevelSetProperty::Pointer propIsoSet = dynamic_cast(m_selectedNode->GetProperty(mitk::RTConstants::DOSE_ISO_LEVELS_PROPERTY_NAME.c_str())); if (propIsoSet) { this->m_LevelSetModel->setIsoDoseLevelSet(propIsoSet->GetValue()); } } } void RTDoseVisualizer::NodeRemoved(const mitk::DataNode* node) { /**@TODO This removal seems to be needed because of the current dose rendering approach (additional sub node for iso dose lines). As soon as we have a better and sound single node rendering mechanism for doses. This method should be removed.*/ bool isdose = m_isDosePredicate->CheckNode(node); if (isdose) { mitk::DataStorage::SetOfObjects::ConstPointer childNodes = this->GetDataStorage()->GetDerivations(node, m_isIsoPredicate); auto iterChildNodes = childNodes->begin(); while (iterChildNodes != childNodes->end()) { this->GetDataStorage()->Remove((*iterChildNodes)); ++iterChildNodes; } } } void RTDoseVisualizer::NodeChanged(const mitk::DataNode *node) { /**@TODO This event seems to be needed because of the current dose rendering approach (additional sub node for iso dose lines). As soon as we have a better and sound single node rendering mechanism for doses. This method should be removed.*/ bool isdose = m_isDosePredicate->CheckNode(node); if(isdose) { bool isvisible = true; if(node->GetBoolProperty("visible", isvisible)) { mitk::DataStorage::SetOfObjects::ConstPointer childNodes = this->GetDataStorage()->GetDerivations(node, m_isIsoPredicate); mitk::DataStorage::SetOfObjects::const_iterator iterChildNodes = childNodes->begin(); while (iterChildNodes != childNodes->end()) { (*iterChildNodes)->SetVisibility(isvisible); ++iterChildNodes; } } } } void RTDoseVisualizer::UpdateByPreferences() { m_Presets = mitk::LoadPresetsMap(); m_internalUpdate = true; m_Controls.comboPresets->clear(); this->m_selectedPresetName = mitk::GetSelectedPresetName(); m_Controls.checkGlobalVisIsoLine->setChecked(mitk::GetGlobalIsolineVis()); m_Controls.checkGlobalVisColorWash->setChecked(mitk::GetGlobalColorwashVis()); if(m_Presets.empty()) return; int index = 0; int selectedIndex = -1; for (mitk::PresetMapType::const_iterator pos = m_Presets.begin(); pos != m_Presets.end(); ++pos, ++index) { m_Controls.comboPresets->addItem(QString(pos->first.c_str())); if (this->m_selectedPresetName == pos->first) { selectedIndex = index; } } if (selectedIndex == -1) { selectedIndex = 0; MITK_WARN << "Error. Iso dose level preset specified in preferences does not exist. Preset name: "<m_selectedPresetName; this->m_selectedPresetName = m_Presets.begin()->first; mitk::SetSelectedPresetName(this->m_selectedPresetName); MITK_INFO << "Changed selected iso dose level preset to first existing preset. New preset name: "<m_selectedPresetName; } m_Controls.comboPresets->setCurrentIndex(selectedIndex); this->m_LevelSetModel->setIsoDoseLevelSet(this->m_Presets[this->m_selectedPresetName]); mitk::DoseValueAbs referenceDose = 0.0; bool globalSync = mitk::GetReferenceDoseValue(referenceDose); if (globalSync || this->m_selectedNode.IsNull()) { m_Controls.spinReferenceDose->setValue(referenceDose); } bool displayAbsoluteDose = mitk::GetDoseDisplayAbsolute(); m_Controls.radioAbsDose->setChecked(displayAbsoluteDose); m_Controls.radioRelDose->setChecked(!displayAbsoluteDose); this->m_LevelSetModel->setShowAbsoluteDose(displayAbsoluteDose); m_internalUpdate = false; } void RTDoseVisualizer::OnCurrentPresetChanged(const QString& presetName) { if (! m_internalUpdate) { mitk::SetSelectedPresetName(presetName.toStdString()); this->UpdateByPreferences(); this->ActualizeIsoLevelsForAllDoseDataNodes(); this->UpdateBySelectedNode(); } } void RTDoseVisualizer::ActualizeIsoLevelsForAllDoseDataNodes() { std::string presetName = mitk::GetSelectedPresetName(); mitk::PresetMapType presetMap = mitk::LoadPresetsMap(); mitk::DataStorage::SetOfObjects::ConstPointer nodes = this->GetDataStorage()->GetSubset(m_isDoseOrIsoPredicate); if(presetMap.empty()) return; mitk::IsoDoseLevelSet* selectedPreset = presetMap[presetName]; if (!selectedPreset) { mitkThrow() << "Error. Cannot actualize iso dose level preset. Selected preset does not exist. Preset name: "<begin(); pos != nodes->end(); ++pos) { mitk::IsoDoseLevelSet::Pointer clonedPreset = selectedPreset->Clone(); mitk::IsoDoseLevelSetProperty::Pointer propIsoSet = mitk::IsoDoseLevelSetProperty::New(clonedPreset); (*pos)->SetProperty(mitk::RTConstants::DOSE_ISO_LEVELS_PROPERTY_NAME.c_str(),propIsoSet); } } void RTDoseVisualizer::ActualizeReferenceDoseForAllDoseDataNodes() { mitk::DoseValueAbs value = 0; bool sync = mitk::GetReferenceDoseValue(value); if (sync) { mitk::DataStorage::SetOfObjects::ConstPointer nodes = this->GetDataStorage()->GetSubset(m_isDoseOrIsoPredicate); for(mitk::DataStorage::SetOfObjects::const_iterator pos = nodes->begin(); pos != nodes->end(); ++pos) { (*pos)->SetFloatProperty(mitk::RTConstants::REFERENCE_DOSE_PROPERTY_NAME.c_str(), value); /**@TODO: ATM the IsoDoseContours have an own (helper) node which is a child of dose node; Will be fixed with the doseMapper refactoring*/ mitk::DataStorage::SetOfObjects::ConstPointer childNodes = this->GetDataStorage()->GetDerivations(*pos); mitk::DataStorage::SetOfObjects::const_iterator iterChildNodes = childNodes->begin(); while (iterChildNodes != childNodes->end()) { (*iterChildNodes)->SetFloatProperty(mitk::RTConstants::REFERENCE_DOSE_PROPERTY_NAME.c_str(), value); ++iterChildNodes; } } } } void RTDoseVisualizer::ActualizeDisplayStyleForAllDoseDataNodes() { /** @TODO Klären ob diese präsentations info global oder auch per node gespeichert wird*/ } void RTDoseVisualizer::OnHandleCTKEventReferenceDoseChanged(const ctkEvent&) { mitk::DoseValueAbs referenceDose = 0.0; mitk::GetReferenceDoseValue(referenceDose); this->m_Controls.spinReferenceDose->setValue(referenceDose); } void RTDoseVisualizer::OnHandleCTKEventGlobalVisChanged(const ctkEvent&) { this->m_Controls.checkGlobalVisIsoLine->setChecked(mitk::GetGlobalIsolineVis()); this->m_Controls.checkGlobalVisColorWash->setChecked(mitk::GetGlobalColorwashVis()); } void RTDoseVisualizer::OnHandleCTKEventPresetsChanged(const ctkEvent&) { std::string currentPresetName = mitk::GetSelectedPresetName(); this->OnCurrentPresetChanged(QString::fromStdString(currentPresetName)); } /**@TODO ATM the IsoDoseContours have an own (helper) node which is a child of dose node; Will be fixed with the doseMapper refactoring*/ mitk::DataNode::Pointer RTDoseVisualizer::GetIsoDoseNode(mitk::DataNode::Pointer doseNode) const { mitk::DataStorage::SetOfObjects::ConstPointer childNodes = this->GetDataStorage()->GetDerivations(doseNode, m_isIsoPredicate); if (childNodes->empty()) { return nullptr; } else { return (*childNodes->begin()); } } diff --git a/Plugins/org.mitk.gui.qt.extapplication/src/internal/QmitkMitkWorkbenchIntroPart.cpp b/Plugins/org.mitk.gui.qt.extapplication/src/internal/QmitkMitkWorkbenchIntroPart.cpp index 566af5834c..73cd26b69d 100644 --- a/Plugins/org.mitk.gui.qt.extapplication/src/internal/QmitkMitkWorkbenchIntroPart.cpp +++ b/Plugins/org.mitk.gui.qt.extapplication/src/internal/QmitkMitkWorkbenchIntroPart.cpp @@ -1,242 +1,242 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "QmitkMitkWorkbenchIntroPart.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "QmitkExtApplicationPlugin.h" #include "mitkDataStorageEditorInput.h" #include #ifdef MITK_USE_Qt5_WebEngine #include #include #include #endif class QmitkMitkWorkbenchIntroPart::Impl { public: Impl() #ifdef MITK_USE_Qt5_WebEngine : View(nullptr) #endif { } ~Impl() { } #ifdef MITK_USE_Qt5_WebEngine QWebEngineView* View; #endif private: Impl(const Impl&); Impl& operator=(const Impl&); }; #ifdef MITK_USE_Qt5_WebEngine namespace { class QmitkWebEnginePage final : public QWebEnginePage { public: explicit QmitkWebEnginePage(QmitkMitkWorkbenchIntroPart* introPart, QObject* parent = nullptr); - ~QmitkWebEnginePage(); + ~QmitkWebEnginePage() override; private: bool acceptNavigationRequest(const QUrl& url, NavigationType type, bool isMainFrame) override; QmitkMitkWorkbenchIntroPart* m_IntroPart; }; QmitkWebEnginePage::QmitkWebEnginePage(QmitkMitkWorkbenchIntroPart* introPart, QObject* parent) : QWebEnginePage(parent), m_IntroPart(introPart) { } QmitkWebEnginePage::~QmitkWebEnginePage() { } bool QmitkWebEnginePage::acceptNavigationRequest(const QUrl& url, NavigationType, bool) { QString scheme = url.scheme(); if (scheme.contains("mitk")) { if (url.path().isEmpty()) return false; if (url.host().contains("perspectives")) { QString id = url.path().simplified().replace("/", ""); auto introSite = m_IntroPart->GetIntroSite(); auto workbenchWindow = introSite->GetWorkbenchWindow(); auto workbench = workbenchWindow->GetWorkbench(); workbench->ShowPerspective(id, workbenchWindow); auto context = QmitkExtApplicationPlugin::GetDefault()->GetPluginContext(); auto serviceReference = context->getServiceReference(); mitk::IDataStorageService* service = serviceReference ? context->getService(serviceReference) : nullptr; if (service) { berry::IEditorInput::Pointer editorInput(new mitk::DataStorageEditorInput(service->GetActiveDataStorage())); auto page = introSite->GetPage(); auto editorPart = page->FindEditor(editorInput); if (editorPart.IsNotNull()) page->Activate(editorPart); } } } else if (scheme.contains("http")) { QDesktopServices::openUrl(url); } else { return true; } return false; } } #endif QmitkMitkWorkbenchIntroPart::QmitkMitkWorkbenchIntroPart() : m_Controls(nullptr), m_Impl(new Impl) { berry::IPreferences::Pointer workbenchPrefs = QmitkExtApplicationPlugin::GetDefault()->GetPreferencesService()->GetSystemPreferences(); #ifdef MITK_USE_Qt5_WebEngine workbenchPrefs->PutBool(berry::WorkbenchPreferenceConstants::SHOW_INTRO, true); #else workbenchPrefs->PutBool(berry::WorkbenchPreferenceConstants::SHOW_INTRO, false); #endif workbenchPrefs->Flush(); } QmitkMitkWorkbenchIntroPart::~QmitkMitkWorkbenchIntroPart() { // if the workbench is not closing (that means, welcome screen was closed explicitly), set "Show_intro" false if (!this->GetIntroSite()->GetPage()->GetWorkbenchWindow()->GetWorkbench()->IsClosing()) { berry::IPreferences::Pointer workbenchPrefs = QmitkExtApplicationPlugin::GetDefault()->GetPreferencesService()->GetSystemPreferences(); workbenchPrefs->PutBool(berry::WorkbenchPreferenceConstants::SHOW_INTRO, false); workbenchPrefs->Flush(); } else { berry::IPreferences::Pointer workbenchPrefs = QmitkExtApplicationPlugin::GetDefault()->GetPreferencesService()->GetSystemPreferences(); #ifdef MITK_USE_Qt5_WebEngine workbenchPrefs->PutBool(berry::WorkbenchPreferenceConstants::SHOW_INTRO, true); #else workbenchPrefs->PutBool(berry::WorkbenchPreferenceConstants::SHOW_INTRO, false); #endif workbenchPrefs->Flush(); } // if workbench is not closing (Just welcome screen closing), open last used perspective if (this->GetIntroSite()->GetPage()->GetPerspective()->GetId() == "org.mitk.mitkworkbench.perspectives.editor" && !this->GetIntroSite()->GetPage()->GetWorkbenchWindow()->GetWorkbench()->IsClosing()) { berry::IPerspectiveDescriptor::Pointer perspective = this->GetIntroSite()->GetWorkbenchWindow()->GetWorkbench()->GetPerspectiveRegistry()->FindPerspectiveWithId("org.mitk.mitkworkbench.perspectives.editor"); if (perspective) { this->GetIntroSite()->GetPage()->SetPerspective(perspective); } } delete m_Impl; } void QmitkMitkWorkbenchIntroPart::CreateQtPartControl(QWidget* parent) { if (!m_Controls) { // create GUI widgets m_Controls = new Ui::QmitkWelcomeScreenViewControls; m_Controls->setupUi(parent); #ifdef MITK_USE_Qt5_WebEngine // create a QWebView as well as a QWebPage and QWebFrame within the QWebview m_Impl->View = new QWebEngineView(parent); auto page = new QmitkWebEnginePage(this, parent); m_Impl->View->setPage(page); QUrl urlQtResource(QString("qrc:/org.mitk.gui.qt.welcomescreen/mitkworkbenchwelcomeview.html"), QUrl::TolerantMode ); m_Impl->View->load( urlQtResource ); // adds the webview as a widget parent->layout()->addWidget(m_Impl->View); #endif this->CreateConnections(); } } void QmitkMitkWorkbenchIntroPart::CreateConnections() { } void QmitkMitkWorkbenchIntroPart::StandbyStateChanged(bool /*standby*/) { } void QmitkMitkWorkbenchIntroPart::SetFocus() { } diff --git a/Plugins/org.mitk.gui.qt.remeshing/src/internal/QmitkRemeshingView.cpp b/Plugins/org.mitk.gui.qt.remeshing/src/internal/QmitkRemeshingView.cpp index 697ddbc62a..c5b67589e8 100644 --- a/Plugins/org.mitk.gui.qt.remeshing/src/internal/QmitkRemeshingView.cpp +++ b/Plugins/org.mitk.gui.qt.remeshing/src/internal/QmitkRemeshingView.cpp @@ -1,156 +1,156 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "QmitkRemeshingView.h" #include #include #include #include #include #include #include #include #include QmitkRemeshingView::QmitkRemeshingView() { } QmitkRemeshingView::~QmitkRemeshingView() { } void QmitkRemeshingView::CreateQtPartControl(QWidget* parent) { m_Controls.setupUi(parent); m_Controls.surfaceComboBox->SetDataStorage(this->GetDataStorage()); m_Controls.surfaceComboBox->SetPredicate(mitk::NodePredicateAnd::New( mitk::TNodePredicateDataType::New(), mitk::NodePredicateNot::New(mitk::NodePredicateProperty::New("helper object")))); connect(m_Controls.surfaceComboBox, SIGNAL(OnSelectionChanged(const mitk::DataNode *)), this, SLOT(OnSelectedSurfaceChanged(const mitk::DataNode *))); connect(m_Controls.densitySlider, SIGNAL(valueChanged(int)), this, SLOT(OnDensityChanged(int))); connect(m_Controls.densitySpinBox, SIGNAL(valueChanged(int)), this, SLOT(OnDensityChanged(int))); connect(m_Controls.remeshPushButton, SIGNAL(clicked()), this, SLOT(OnRemeshButtonClicked())); this->OnSelectedSurfaceChanged(m_Controls.surfaceComboBox->GetSelectedNode()); } void QmitkRemeshingView::OnSelectedSurfaceChanged(const mitk::DataNode *node) { if (node != nullptr) { m_MaxNumberOfVertices = static_cast(static_cast(node->GetData())->GetVtkPolyData()->GetNumberOfPoints()); this->EnableWidgets(true); } else { m_MaxNumberOfVertices = 0; this->EnableWidgets(false); } } void QmitkRemeshingView::OnDensityChanged(int density) { if (density != m_Controls.densitySlider->value()) m_Controls.densitySlider->setValue(density); if (density != m_Controls.densitySpinBox->value()) m_Controls.densitySpinBox->setValue(density); } void QmitkRemeshingView::OnRemeshButtonClicked() { mitk::DataNode::Pointer selectedNode = m_Controls.surfaceComboBox->GetSelectedNode(); mitk::Surface::ConstPointer surface = static_cast(selectedNode->GetData()); int density = m_Controls.densitySpinBox->value(); int numVertices = std::max(100, static_cast(m_MaxNumberOfVertices * (density * 0.01))); double gradation = m_Controls.remeshingComboBox->currentText() == QStringLiteral("Adaptive") ? 1.0 : 0.0; const QString quality = m_Controls.qualityComboBox->currentText(); int subsampling; if (QStringLiteral("High (slow)") == quality) { subsampling = 50; } else if (QStringLiteral("Maximum (very slow)") == quality) { subsampling = 500; } else // The default is "Medium (fast)". { subsampling = 10; } bool boundaryFixing = m_Controls.preserveEdgesCheckBox->isChecked(); mitk::ACVD::RemeshFilter::Pointer remesher = mitk::ACVD::RemeshFilter::New(); remesher->SetInput(surface); remesher->SetTimeStep(0); remesher->SetNumVertices(numVertices); remesher->SetGradation(gradation); remesher->SetSubsampling(subsampling); remesher->SetEdgeSplitting(0.0); remesher->SetOptimizationLevel(1.0); remesher->SetForceManifold(false); remesher->SetBoundaryFixing(boundaryFixing); try { remesher->Update(); } catch(const mitk::Exception& exception) { MITK_ERROR << exception.GetDescription(); return; } mitk::Surface::Pointer remeshedSurface = remesher->GetOutput(); mitk::DataNode::Pointer newNode = mitk::DataNode::New(); newNode->SetName(QString("%1 (%2%)").arg(selectedNode->GetName().c_str()).arg(density).toStdString()); newNode->SetProperty("material.representation", mitk::VtkRepresentationProperty::New(VTK_WIREFRAME)); newNode->SetData(remeshedSurface); this->GetDataStorage()->Add(newNode, selectedNode); } void QmitkRemeshingView::EnableWidgets(bool enable) { m_Controls.surfaceComboBox->setEnabled(enable); m_Controls.densitySlider->setEnabled(enable); m_Controls.densitySpinBox->setEnabled(enable); m_Controls.remeshingComboBox->setEnabled(enable); m_Controls.qualityComboBox->setEnabled(enable); m_Controls.preserveEdgesCheckBox->setEnabled(enable); m_Controls.remeshPushButton->setEnabled(enable); - m_Controls.explanationLabel->setVisible(enable); + m_Controls.gradationLabel->setVisible(enable); } void QmitkRemeshingView::SetFocus() { m_Controls.surfaceComboBox->setFocus(); } diff --git a/Plugins/org.mitk.gui.qt.ugvisualization/src/internal/QmitkUGVisualizationView.cpp b/Plugins/org.mitk.gui.qt.ugvisualization/src/internal/QmitkUGVisualizationView.cpp index ff7d4c359a..60a5ae646c 100644 --- a/Plugins/org.mitk.gui.qt.ugvisualization/src/internal/QmitkUGVisualizationView.cpp +++ b/Plugins/org.mitk.gui.qt.ugvisualization/src/internal/QmitkUGVisualizationView.cpp @@ -1,289 +1,289 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ // Blueberry #include #include // Qmitk #include "QmitkUGVisualizationView.h" #include #include #include #include #include #include #include #include #include class UGVisVolumeObserver : public mitk::PropertyView { public: UGVisVolumeObserver(mitk::BoolProperty* property, QmitkUGVisualizationView* view) : PropertyView(property), m_View(view), m_BoolProperty(property) { } protected: - virtual void PropertyChanged() override + void PropertyChanged() override { m_View->m_VolumeMode = m_BoolProperty->GetValue(); m_View->UpdateEnablement(); } - virtual void PropertyRemoved() override + void PropertyRemoved() override { m_View->m_VolumeMode = false; m_Property = 0; m_BoolProperty = 0; } QmitkUGVisualizationView* m_View; mitk::BoolProperty* m_BoolProperty; }; const std::string QmitkUGVisualizationView::VIEW_ID = "org.mitk.views.ugvisualization"; QmitkUGVisualizationView::QmitkUGVisualizationView() : QmitkAbstractView(), m_Outline2DAction(0), m_Outline2DWidget(0), m_LODAction(0), m_ScalarVisibilityAction(0), m_ScalarVisibilityWidget(0), m_FirstVolumeRepId(-1), m_ShowTFGeneratorWidget(true), m_ShowScalarOpacityWidget(false), m_ShowColorWidget(true), m_ShowGradientOpacityWidget(false), m_ShowTFGeneratorAction(0), m_ShowScalarOpacityAction(0), m_ShowColorAction(0), m_ShowGradientOpacityAction(0), m_VolumeModeObserver(0) { } QmitkUGVisualizationView::~QmitkUGVisualizationView() { delete m_VolumeModeObserver; } void QmitkUGVisualizationView::CreateQtPartControl( QWidget *parent ) { m_Controls.setupUi( parent ); m_Outline2DWidget = new QmitkBoolPropertyWidget("Outline 2D polygons", parent); m_Outline2DAction = new QWidgetAction(this); m_Outline2DAction->setDefaultWidget(m_Outline2DWidget); m_LODAction = new QAction("Enable LOD (Level Of Detail)", this); m_LODAction->setCheckable(true); m_ScalarVisibilityWidget = new QmitkBoolPropertyWidget("Visualize scalars", parent); m_ScalarVisibilityAction = new QWidgetAction(this); m_ScalarVisibilityAction->setDefaultWidget(m_ScalarVisibilityWidget); m_ShowColorAction = new QAction("Show color transfer function", this); m_ShowColorAction->setCheckable(true); m_ShowColorAction->setChecked(m_ShowColorWidget); m_ShowGradientOpacityAction = new QAction("Show gradient opacity function", this); m_ShowGradientOpacityAction->setCheckable(true); m_ShowGradientOpacityAction->setChecked(m_ShowGradientOpacityWidget); m_ShowScalarOpacityAction = new QAction("Show scalar opacity function", this); m_ShowScalarOpacityAction->setCheckable(true); m_ShowScalarOpacityAction->setChecked(m_ShowScalarOpacityWidget); m_ShowTFGeneratorAction = new QAction("Show transfer function generator", this); m_ShowTFGeneratorAction->setCheckable(true); m_ShowTFGeneratorAction->setChecked(m_ShowTFGeneratorWidget); QMenu* menu = new QMenu(parent); menu->addAction(m_ScalarVisibilityAction); menu->addAction(m_Outline2DAction); //menu->addAction(m_LODAction); menu->addSeparator(); menu->addAction(m_ShowTFGeneratorAction); menu->addAction(m_ShowScalarOpacityAction); menu->addAction(m_ShowColorAction); menu->addAction(m_ShowGradientOpacityAction); m_Controls.m_OptionsButton->setMenu(menu); m_Controls.m_TransferFunctionWidget->SetScalarLabel("Scalar value"); // const mitk::EnumerationProperty::EnumStringsContainerType& scalarStrings = scalarProp->GetEnumStrings(); // for (mitk::EnumerationProperty::EnumStringsContainerType::const_iterator it = scalarStrings.begin(); // it != scalarStrings.end(); ++it) // { // MITK_INFO << "ADding: " << it->first; // m_Controls.m_ScalarModeComboBox->addItem(QString::fromStdString(it->first), it->second); // } this->UpdateGUI(); CreateConnections(); } void QmitkUGVisualizationView::CreateConnections() { connect(m_Controls.m_ScalarModeComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(UpdateRenderWindow())); connect(m_Controls.m_RepresentationComboBox, SIGNAL(activated(int)), this, SLOT(UpdateRenderWindow())); connect(m_Outline2DWidget, SIGNAL(toggled(bool)), this, SLOT(UpdateRenderWindow())); connect(m_ScalarVisibilityWidget, SIGNAL(toggled(bool)), this, SLOT(UpdateRenderWindow())); connect(m_Controls.m_TransferFunctionGeneratorWidget, SIGNAL(SignalUpdateCanvas()), m_Controls.m_TransferFunctionWidget, SLOT(OnUpdateCanvas())); connect(m_ShowColorAction, SIGNAL(triggered(bool)), this, SLOT(ShowColorWidget(bool))); connect(m_ShowGradientOpacityAction, SIGNAL(triggered(bool)), this, SLOT(ShowGradientOpacityWidget(bool))); connect(m_ShowScalarOpacityAction, SIGNAL(triggered(bool)), this, SLOT(ShowScalarOpacityWidget(bool))); connect(m_ShowTFGeneratorAction, SIGNAL(triggered(bool)), this, SLOT(ShowTFGeneratorWidget(bool))); } void QmitkUGVisualizationView::SetFocus() { m_Controls.m_OptionsButton->setFocus(); } void QmitkUGVisualizationView::UpdateRenderWindow() { mitk::RenderingManager::GetInstance()->RequestUpdateAll(); } void QmitkUGVisualizationView::ShowTFGeneratorWidget(bool show) { m_ShowTFGeneratorWidget = show; UpdateEnablement(); } void QmitkUGVisualizationView::ShowScalarOpacityWidget(bool show) { m_ShowScalarOpacityWidget = show; UpdateEnablement(); } void QmitkUGVisualizationView::ShowColorWidget(bool show) { m_ShowColorWidget = show; UpdateEnablement(); } void QmitkUGVisualizationView::ShowGradientOpacityWidget(bool show) { m_ShowGradientOpacityWidget = show; UpdateEnablement(); } void QmitkUGVisualizationView::UpdateEnablement() { m_Controls.m_TransferFunctionGeneratorWidget->setVisible(m_ShowTFGeneratorWidget); m_Controls.m_TransferFunctionWidget->ShowScalarOpacityFunction(m_ShowScalarOpacityWidget); m_Controls.m_TransferFunctionWidget->ShowColorFunction(m_ShowColorWidget); m_Controls.m_TransferFunctionWidget->ShowGradientOpacityFunction(m_ShowGradientOpacityWidget); m_Controls.m_TransferFunctionGeneratorWidget->SetThresholdTabEnabled(m_ScalarVisibilityWidget->isChecked()); m_Controls.m_TransferFunctionGeneratorWidget->SetBellTabEnabled(m_ScalarVisibilityWidget->isChecked()); m_Controls.m_TransferFunctionWidget->SetScalarOpacityFunctionEnabled(m_ScalarVisibilityWidget->isChecked()); m_Controls.m_TransferFunctionWidget->SetGradientOpacityFunctionEnabled(m_VolumeMode); } void QmitkUGVisualizationView::UpdateGUI() { bool enable = false; mitk::DataNode* node = 0; auto nodes = this->GetDataManagerSelection(); if (!nodes.empty()) { node = nodes.front(); if (node) { // here we have a valid mitk::DataNode // a node itself is not very useful, we need its data item mitk::BaseData* data = node->GetData(); if (data) { // test if this data item is an unstructured grid enable = dynamic_cast( data ); } } } m_Controls.m_SelectedLabel->setVisible(enable); m_Controls.m_ErrorLabel->setVisible(!enable); m_Controls.m_ContainerWidget->setEnabled(enable); m_Controls.m_OptionsButton->setEnabled(enable); if (enable) { m_VolumeMode = false; node->GetBoolProperty("volumerendering", m_VolumeMode); m_Controls.m_SelectedLabel->setText(QString("Selected UG: ") + node->GetName().c_str()); m_Controls.m_TransferFunctionGeneratorWidget->SetDataNode(node); m_Controls.m_TransferFunctionWidget->SetDataNode(node); mitk::BoolProperty* outlineProp = 0; node->GetProperty(outlineProp, "outline polygons"); m_Outline2DWidget->SetProperty(outlineProp); mitk::BoolProperty* scalarVisProp = 0; node->GetProperty(scalarVisProp, "scalar visibility"); m_ScalarVisibilityWidget->SetProperty(scalarVisProp); mitk::VtkScalarModeProperty* scalarProp = 0; if (node->GetProperty(scalarProp, "scalar mode")) { m_Controls.m_ScalarModeComboBox->SetProperty(scalarProp); } mitk::GridRepresentationProperty* gridRepProp = 0; mitk::GridVolumeMapperProperty* gridVolumeProp = 0; mitk::BoolProperty* volumeProp = 0; node->GetProperty(gridRepProp, "grid representation"); node->GetProperty(gridVolumeProp, "volumerendering.mapper"); node->GetProperty(volumeProp, "volumerendering"); m_Controls.m_RepresentationComboBox->SetProperty(gridRepProp, gridVolumeProp, volumeProp); if (m_VolumeModeObserver) { delete m_VolumeModeObserver; m_VolumeModeObserver = 0; } if (volumeProp) { m_VolumeModeObserver = new UGVisVolumeObserver(volumeProp, this); } } UpdateEnablement(); } void QmitkUGVisualizationView::OnSelectionChanged(berry::IWorkbenchPart::Pointer /*part*/, const QList& /*nodes*/) { UpdateGUI(); }