diff --git a/Plugins/org.mitk.gui.qt.mitkworkbench.intro/files.cmake b/Plugins/org.mitk.gui.qt.mitkworkbench.intro/files.cmake index fe593005bc..ce3944d94d 100644 --- a/Plugins/org.mitk.gui.qt.mitkworkbench.intro/files.cmake +++ b/Plugins/org.mitk.gui.qt.mitkworkbench.intro/files.cmake @@ -1,39 +1,42 @@ set(SRC_CPP_FILES ) set(INTERNAL_CPP_FILES QmitkMitkWorkbenchIntroPlugin.cpp QmitkMitkWorkbenchIntroPart.cpp + QmitkMitkWorkbenchIntroPreferencePage.cpp ) set(MOC_H_FILES src/internal/QmitkMitkWorkbenchIntroPlugin.h src/internal/QmitkMitkWorkbenchIntroPart.h + src/internal/QmitkMitkWorkbenchIntroPreferencePage.h ) set(UI_FILES src/internal/QmitkWelcomeScreenViewControls.ui + src/internal/QmitkMitkWorkbenchIntroPreferencePage.ui ) set(CACHED_RESOURCE_FILES # list of resource files which can be used by the plug-in # system without loading the plug-ins shared library, # for example the icon used in the menu and tabs for the # plug-in views in the workbench plugin.xml ) set(QRC_FILES resources/QmitkWelcomeScreenView.qrc ) set(CPP_FILES ) foreach(file ${SRC_CPP_FILES}) set(CPP_FILES ${CPP_FILES} src/${file}) endforeach(file ${SRC_CPP_FILES}) foreach(file ${INTERNAL_CPP_FILES}) set(CPP_FILES ${CPP_FILES} src/internal/${file}) endforeach(file ${INTERNAL_CPP_FILES}) diff --git a/Plugins/org.mitk.gui.qt.mitkworkbench.intro/plugin.xml b/Plugins/org.mitk.gui.qt.mitkworkbench.intro/plugin.xml index dda81a0406..002333fb74 100644 --- a/Plugins/org.mitk.gui.qt.mitkworkbench.intro/plugin.xml +++ b/Plugins/org.mitk.gui.qt.mitkworkbench.intro/plugin.xml @@ -1,12 +1,17 @@ + + + + + diff --git a/Plugins/org.mitk.gui.qt.mitkworkbench.intro/resources/index.html b/Plugins/org.mitk.gui.qt.mitkworkbench.intro/resources/index.html index fd791bbff8..4f2113bf1f 100644 --- a/Plugins/org.mitk.gui.qt.mitkworkbench.intro/resources/index.html +++ b/Plugins/org.mitk.gui.qt.mitkworkbench.intro/resources/index.html @@ -1,84 +1,84 @@ Welcome to the MITK Workbench!

Welcome to the MITK Workbench!

Load and view medical images from all kinds of imaging modalities like X-ray, US, CT, MRI, and many more. Use our tools to efficiently create segmentations, measure anatomical structures, inspect image statistics, or register multiple images to each other.

The MITK Workbench is developed at the ↪ German Cancer Research Center (DKFZ).
It is based on the free open source ↪ Medical Imaging Interaction Toolkit (MITK).

Mouse navigation

Crosshair

Your images are typically shown from three different view directions at once: axial, sagittal, and coronal. Together, the view planes resemble the shape of a three-dimensional crosshair slicing through your image data. Use the mouse to navigate in these views.

Focus

Left mouse button

Use the left mouse button to focus all views on the clicked position.

Zoom

Right mouse button

Press and hold the right mouse button and move the mouse up and down to zoom in and out.

Pan

Middle mouse button

Press and hold the middle mouse button and move the mouse to pan around.

Scroll

Scroll wheel

Use the scroll wheel to scroll through slices along the view's direction.

-
diff --git a/Plugins/org.mitk.gui.qt.mitkworkbench.intro/resources/script.js b/Plugins/org.mitk.gui.qt.mitkworkbench.intro/resources/script.js index a09441a664..45b56caa01 100644 --- a/Plugins/org.mitk.gui.qt.mitkworkbench.intro/resources/script.js +++ b/Plugins/org.mitk.gui.qt.mitkworkbench.intro/resources/script.js @@ -1,10 +1,32 @@ function showNextTip() { var tips = document.querySelectorAll('.tip'); for (let i = 0; i < tips.length; ++i) { if (!tips[i].hasAttribute('hidden')) { tips[i].setAttribute('hidden', ''); tips[(i + 1) % tips.length].removeAttribute('hidden'); break; } } } + +function showRandomTip() { + var tips = document.querySelectorAll('.tip'); + var show = Math.floor(Math.random() * tips.length); + for (let i = 0; i < tips.length; ++i) { + if (i != show) { + tips[i].setAttribute('hidden', ''); + } else { + tips[i].removeAttribute('hidden'); + } + } +} + +function showTips() { + var tips = document.querySelector('.tips'); + tips.removeAttribute('hidden'); +} + +function hideTips() { + var tips = document.querySelector('.tips'); + tips.setAttribute('hidden', ''); +} diff --git a/Plugins/org.mitk.gui.qt.mitkworkbench.intro/src/internal/QmitkMitkWorkbenchIntroPart.cpp b/Plugins/org.mitk.gui.qt.mitkworkbench.intro/src/internal/QmitkMitkWorkbenchIntroPart.cpp index 2d3ecff848..c2fcf07cde 100644 --- a/Plugins/org.mitk.gui.qt.mitkworkbench.intro/src/internal/QmitkMitkWorkbenchIntroPart.cpp +++ b/Plugins/org.mitk.gui.qt.mitkworkbench.intro/src/internal/QmitkMitkWorkbenchIntroPart.cpp @@ -1,220 +1,223 @@ /*============================================================================ The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center (DKFZ) All rights reserved. Use of this source code is governed by a 3-clause BSD license that can be found in the LICENSE file. ============================================================================*/ #include "QmitkMitkWorkbenchIntroPart.h" +#include "QmitkMitkWorkbenchIntroPlugin.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 -#include -#include #include - -#include "QmitkMitkWorkbenchIntroPlugin.h" -#include "mitkDataStorageEditorInput.h" -#include - -#include #include -#include +#include class QmitkMitkWorkbenchIntroPart::Impl { public: Impl() : View(nullptr) { } ~Impl() { } QWebEngineView* View; private: Impl(const Impl&); Impl& operator=(const Impl&); }; namespace { class QmitkWebEnginePage final : public QWebEnginePage { public: explicit QmitkWebEnginePage(QmitkMitkWorkbenchIntroPart* introPart, QObject* parent = nullptr); ~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 = QmitkMitkWorkbenchIntroPlugin::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("https")) { QDesktopServices::openUrl(url); } else { return true; } return false; } } QmitkMitkWorkbenchIntroPart::QmitkMitkWorkbenchIntroPart() : m_Controls(nullptr), m_Impl(new Impl) { berry::IPreferences::Pointer workbenchPrefs = QmitkMitkWorkbenchIntroPlugin::GetDefault()->GetPreferencesService()->GetSystemPreferences(); workbenchPrefs->PutBool(berry::WorkbenchPreferenceConstants::SHOW_INTRO, true); 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 = QmitkMitkWorkbenchIntroPlugin::GetDefault()->GetPreferencesService()->GetSystemPreferences(); workbenchPrefs->PutBool(berry::WorkbenchPreferenceConstants::SHOW_INTRO, false); workbenchPrefs->Flush(); } else { berry::IPreferences::Pointer workbenchPrefs = QmitkMitkWorkbenchIntroPlugin::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.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); // create a QWebView as well as a QWebPage and QWebFrame within the QWebview m_Impl->View = new QWebEngineView(parent); + this->CreateConnections(); + auto page = new QmitkWebEnginePage(this, parent); m_Impl->View->setPage(page); QUrl urlQtResource(QString("qrc:/org.mitk.gui.qt.welcomescreen/index.html"), QUrl::TolerantMode); m_Impl->View->load( urlQtResource ); // adds the webview as a widget parent->layout()->addWidget(m_Impl->View); - - this->CreateConnections(); } } void QmitkMitkWorkbenchIntroPart::CreateConnections() { + connect(m_Impl->View, &QWebEngineView::loadFinished, this, &QmitkMitkWorkbenchIntroPart::OnLoadFinished); } void QmitkMitkWorkbenchIntroPart::StandbyStateChanged(bool /*standby*/) { } void QmitkMitkWorkbenchIntroPart::SetFocus() { } + +void QmitkMitkWorkbenchIntroPart::ReloadPage() +{ + if (m_Impl->View != nullptr) + m_Impl->View->reload(); +} + +void QmitkMitkWorkbenchIntroPart::OnLoadFinished(bool ok) +{ + if (!ok) + return; + + auto prefs = QmitkMitkWorkbenchIntroPlugin::GetDefault()->GetPreferencesService()->GetSystemPreferences()->Node("/org.mitk.qt.extapplicationintro"); + bool showTips = prefs->GetBool("show tips", true); + + if (showTips) + { + m_Impl->View->page()->runJavaScript("showRandomTip(); showTips()"); + } + else + { + m_Impl->View->page()->runJavaScript("hideTips()"); + } +} diff --git a/Plugins/org.mitk.gui.qt.mitkworkbench.intro/src/internal/QmitkMitkWorkbenchIntroPart.h b/Plugins/org.mitk.gui.qt.mitkworkbench.intro/src/internal/QmitkMitkWorkbenchIntroPart.h index df259e5983..4165230a60 100644 --- a/Plugins/org.mitk.gui.qt.mitkworkbench.intro/src/internal/QmitkMitkWorkbenchIntroPart.h +++ b/Plugins/org.mitk.gui.qt.mitkworkbench.intro/src/internal/QmitkMitkWorkbenchIntroPart.h @@ -1,77 +1,75 @@ /*============================================================================ The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center (DKFZ) All rights reserved. Use of this source code is governed by a 3-clause BSD license that can be found in the LICENSE file. ============================================================================*/ #ifndef QMITKWORKBENCHINTROPART_H_ #define QMITKWORKBENCHINTROPART_H_ #include #include #include /** * \ingroup org_mitk_gui_qt_welcomescreen_internal * \brief QmitkMitkWorkbenchIntroPart * The WelcomeView Module is an helpful feature to people new to MITK. The main idea is to provide first * information about the MITK Workbench. * The WelcomeView is realized by making use of the QTWebKit Module. The Qt WebKit module * provides an HTML browser engine that makes it easy to embed web content into native applications, and to enhance * web content with native controls. * For the welcome view of the application the QWebView, QWebPage classes have been used. The shown WelcomeView * html start page is styled by an external css stylesheet. The required resources as well as the html pages are integrated * into the QtResource system. The QT resource system allows the storage of files like html pages, css pages, jpgs etc. * as binaries within the executable. * This minimizes the risk of loosing resource files as well as the risk of getting files deleted. In order to use the Qt * resource system the resource files have to be added to the associated qrt resource file list. * * The foundation is set to design more complex html pages. The Q::WebPage gives options to set a * LinkDelegationPolicy. The used policy defines how links to external or internal resources are handled. To fit our needs * the delegate all links policy is used. This requires all external as well as internal links of the html pages to be handle * explicitly. In order to change mitk working modes (perspectives) a mitk url scheme has been designed. The url scheme * is set to mitk. The url host provides information about what's next to do. In our case, the case of switching to a * particular working mode the host is set to perspectives. The followed path provides information about the perspective id. * (e.g. mitk//::mitk.perspectives/org.mitk.qt.defaultperspective) The the generic design of the mitk url scheme allows to * execute other task depending on the mitk url host. * \sa QmitkWelcomePage Editor */ class QmitkMitkWorkbenchIntroPart : public berry::QtIntroPart { // this is needed for all Qt objects that should have a MOC object (everything that derives from QObject) Q_OBJECT public: QmitkMitkWorkbenchIntroPart(); ~QmitkMitkWorkbenchIntroPart() override; - void CreateQtPartControl(QWidget *parent) override; - void StandbyStateChanged(bool) override; - void SetFocus() override; + void ReloadPage(); - virtual void CreateConnections(); - -protected: +private: + void CreateConnections(); + void OnLoadFinished(bool ok); Ui::QmitkWelcomeScreenViewControls* m_Controls; class Impl; Impl* m_Impl; }; #endif /* QMITKWORKBENCHINTROPART_H_ */ diff --git a/Plugins/org.mitk.gui.qt.mitkworkbench.intro/src/internal/QmitkMitkWorkbenchIntroPlugin.cpp b/Plugins/org.mitk.gui.qt.mitkworkbench.intro/src/internal/QmitkMitkWorkbenchIntroPlugin.cpp index c38924e45c..a0af12b0f1 100644 --- a/Plugins/org.mitk.gui.qt.mitkworkbench.intro/src/internal/QmitkMitkWorkbenchIntroPlugin.cpp +++ b/Plugins/org.mitk.gui.qt.mitkworkbench.intro/src/internal/QmitkMitkWorkbenchIntroPlugin.cpp @@ -1,53 +1,55 @@ /*============================================================================ The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center (DKFZ) All rights reserved. Use of this source code is governed by a 3-clause BSD license that can be found in the LICENSE file. ============================================================================*/ #include "QmitkMitkWorkbenchIntroPlugin.h" #include "QmitkMitkWorkbenchIntroPart.h" +#include "QmitkMitkWorkbenchIntroPreferencePage.h" #include #include #include #include #include #include QmitkMitkWorkbenchIntroPlugin* QmitkMitkWorkbenchIntroPlugin::inst = nullptr; QmitkMitkWorkbenchIntroPlugin::QmitkMitkWorkbenchIntroPlugin() { inst = this; } QmitkMitkWorkbenchIntroPlugin::~QmitkMitkWorkbenchIntroPlugin() { } QmitkMitkWorkbenchIntroPlugin* QmitkMitkWorkbenchIntroPlugin::GetDefault() { return inst; } void QmitkMitkWorkbenchIntroPlugin::start(ctkPluginContext* context) { berry::AbstractUICTKPlugin::start(context); this->context = context; - BERRY_REGISTER_EXTENSION_CLASS(QmitkMitkWorkbenchIntroPart, context); + BERRY_REGISTER_EXTENSION_CLASS(QmitkMitkWorkbenchIntroPart, context) + BERRY_REGISTER_EXTENSION_CLASS(QmitkMitkWorkbenchIntroPreferencePage, context) } ctkPluginContext* QmitkMitkWorkbenchIntroPlugin::GetPluginContext() const { return context; } diff --git a/Plugins/org.mitk.gui.qt.mitkworkbench.intro/src/internal/QmitkMitkWorkbenchIntroPreferencePage.cpp b/Plugins/org.mitk.gui.qt.mitkworkbench.intro/src/internal/QmitkMitkWorkbenchIntroPreferencePage.cpp new file mode 100644 index 0000000000..f1222ec90f --- /dev/null +++ b/Plugins/org.mitk.gui.qt.mitkworkbench.intro/src/internal/QmitkMitkWorkbenchIntroPreferencePage.cpp @@ -0,0 +1,76 @@ +/*============================================================================ + +The Medical Imaging Interaction Toolkit (MITK) + +Copyright (c) German Cancer Research Center (DKFZ) +All rights reserved. + +Use of this source code is governed by a 3-clause BSD license that can be +found in the LICENSE file. + +============================================================================*/ + +#include "QmitkMitkWorkbenchIntroPreferencePage.h" +#include "QmitkMitkWorkbenchIntroPart.h" + +#include +#include +#include + +#include + +QmitkMitkWorkbenchIntroPreferencePage::QmitkMitkWorkbenchIntroPreferencePage() + : m_Ui(new Ui::QmitkMitkWorkbenchIntroPreferencePage), + m_Control(nullptr) +{ +} + +QmitkMitkWorkbenchIntroPreferencePage::~QmitkMitkWorkbenchIntroPreferencePage() +{ +} + +void QmitkMitkWorkbenchIntroPreferencePage::Init(berry::IWorkbench::Pointer) +{ +} + +void QmitkMitkWorkbenchIntroPreferencePage::CreateQtControl(QWidget* parent) +{ + auto* prefService = berry::Platform::GetPreferencesService(); + m_MitkWorkbenchIntroPreferencesNode = prefService->GetSystemPreferences()->Node("/org.mitk.qt.extapplicationintro"); + + m_Control = new QWidget(parent); + m_Ui->setupUi(m_Control); + + this->Update(); +} + +QWidget* QmitkMitkWorkbenchIntroPreferencePage::GetQtControl() const +{ + return m_Control; +} + +bool QmitkMitkWorkbenchIntroPreferencePage::PerformOk() +{ + m_MitkWorkbenchIntroPreferencesNode->PutBool("show tips", m_Ui->showTipsCheckBox->isChecked()); + + auto intro = berry::PlatformUI::GetWorkbench()->GetIntroManager()->GetIntro(); + + if (intro.IsNotNull()) + { + auto* workbenchIntro = dynamic_cast(intro.GetPointer()); + + if (workbenchIntro != nullptr) + workbenchIntro->ReloadPage(); + } + + return true; +} + +void QmitkMitkWorkbenchIntroPreferencePage::PerformCancel() +{ +} + +void QmitkMitkWorkbenchIntroPreferencePage::Update() +{ + m_Ui->showTipsCheckBox->setChecked(m_MitkWorkbenchIntroPreferencesNode->GetBool("show tips", true)); +} diff --git a/Plugins/org.mitk.gui.qt.mitkworkbench.intro/src/internal/QmitkMitkWorkbenchIntroPreferencePage.h b/Plugins/org.mitk.gui.qt.mitkworkbench.intro/src/internal/QmitkMitkWorkbenchIntroPreferencePage.h new file mode 100644 index 0000000000..e41d1e0c89 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.mitkworkbench.intro/src/internal/QmitkMitkWorkbenchIntroPreferencePage.h @@ -0,0 +1,46 @@ +/*============================================================================ + +The Medical Imaging Interaction Toolkit (MITK) + +Copyright (c) German Cancer Research Center (DKFZ) +All rights reserved. + +Use of this source code is governed by a 3-clause BSD license that can be +found in the LICENSE file. + +============================================================================*/ + +#ifndef QmitkMitkWorkbenchIntroPreferencePage_h +#define QmitkMitkWorkbenchIntroPreferencePage_h + +#include + +namespace Ui +{ + class QmitkMitkWorkbenchIntroPreferencePage; +} + +class QmitkMitkWorkbenchIntroPreferencePage : public QObject, public berry::IQtPreferencePage +{ + Q_OBJECT + Q_INTERFACES(berry::IPreferencePage) + +public: + QmitkMitkWorkbenchIntroPreferencePage(); + ~QmitkMitkWorkbenchIntroPreferencePage() override; + + void Init(berry::IWorkbench::Pointer workbench) override; + void CreateQtControl(QWidget* parent) override; + QWidget* GetQtControl() const override; + bool PerformOk() override; + void PerformCancel() override; + void Update() override; + +private: + berry::IPreferences::Pointer m_MitkWorkbenchIntroPreferencesNode; + + Ui::QmitkMitkWorkbenchIntroPreferencePage* m_Ui; + QWidget* m_Control; +}; + +#endif diff --git a/Plugins/org.mitk.gui.qt.mitkworkbench.intro/src/internal/QmitkMitkWorkbenchIntroPreferencePage.ui b/Plugins/org.mitk.gui.qt.mitkworkbench.intro/src/internal/QmitkMitkWorkbenchIntroPreferencePage.ui new file mode 100644 index 0000000000..b56753d42f --- /dev/null +++ b/Plugins/org.mitk.gui.qt.mitkworkbench.intro/src/internal/QmitkMitkWorkbenchIntroPreferencePage.ui @@ -0,0 +1,44 @@ + + + QmitkMitkWorkbenchIntroPreferencePage + + + + 0 + 0 + 400 + 300 + + + + Welcome Page + + + + + + Show tips + + + true + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + +