diff --git a/Plugins/PluginList.cmake b/Plugins/PluginList.cmake index 03bbd9f40f..f27a7559da 100644 --- a/Plugins/PluginList.cmake +++ b/Plugins/PluginList.cmake @@ -1,86 +1,87 @@ # Plug-ins must be ordered according to their dependencies set(MITK_PLUGINS org.blueberry.core.runtime:ON org.blueberry.core.expressions:OFF org.blueberry.core.commands:OFF org.blueberry.core.jobs:OFF org.blueberry.ui.qt:OFF org.blueberry.ui.qt.help:OFF org.blueberry.ui.qt.log:ON org.blueberry.ui.qt.objectinspector:OFF #org.blueberry.test:ON #org.blueberry.uitest:ON #Testing/org.blueberry.core.runtime.tests:ON #Testing/org.blueberry.osgi.tests:ON org.mitk.core.services:ON org.mitk.gui.common:ON org.mitk.planarfigure:ON org.mitk.core.ext:OFF org.mitk.core.jobs:OFF org.mitk.diffusionimaging:OFF org.mitk.simulation:OFF org.mitk.gui.qt.application:ON org.mitk.gui.qt.coreapplication:OFF org.mitk.gui.qt.ext:OFF org.mitk.gui.qt.extapplication:OFF org.mitk.gui.qt.common:ON org.mitk.gui.qt.stdmultiwidgeteditor:ON org.mitk.gui.qt.common.legacy:OFF org.mitk.gui.qt.cmdlinemodules:OFF org.mitk.gui.qt.diffusionimagingapp:OFF org.mitk.gui.qt.datamanager:ON org.mitk.gui.qt.datamanagerlight:OFF org.mitk.gui.qt.properties:ON org.mitk.gui.qt.basicimageprocessing:OFF org.mitk.gui.qt.dicom:OFF org.mitk.gui.qt.dicominspector:OFF org.mitk.gui.qt.diffusionimaging:OFF org.mitk.gui.qt.dosevisualization:OFF org.mitk.gui.qt.geometrytools:OFF org.mitk.gui.qt.igtexamples:OFF org.mitk.gui.qt.igttracking:OFF org.mitk.gui.qt.lasercontrol:OFF org.mitk.gui.qt.openigtlink:OFF org.mitk.gui.qt.imagecropper:OFF org.mitk.gui.qt.imagenavigator:ON org.mitk.gui.qt.viewnavigator:OFF org.mitk.gui.qt.materialeditor:OFF org.mitk.gui.qt.measurementtoolbox:OFF org.mitk.gui.qt.moviemaker:OFF org.mitk.gui.qt.pointsetinteraction:OFF org.mitk.gui.qt.pointsetinteractionmultispectrum:OFF org.mitk.gui.qt.python:OFF org.mitk.gui.qt.registration:OFF org.mitk.gui.qt.remeshing:OFF org.mitk.gui.qt.segmentation:OFF org.mitk.gui.qt.simulation:OFF org.mitk.gui.qt.aicpregistration:OFF org.mitk.gui.qt.toftutorial:OFF org.mitk.gui.qt.tofutil:OFF org.mitk.gui.qt.tubegraph:OFF org.mitk.gui.qt.ugvisualization:OFF org.mitk.gui.qt.ultrasound:OFF org.mitk.gui.qt.volumevisualization:OFF org.mitk.gui.qt.eventrecorder:OFF org.mitk.gui.qt.xnat:OFF org.mitk.gui.qt.igt.app.echotrack:OFF org.mitk.gui.qt.spectrocamrecorder:OFF org.mitk.gui.qt.classificationsegmentation:OFF org.mitk.gui.qt.overlaymanager:OFF org.mitk.gui.qt.multilabelsegmentation:ON org.mitk.matchpoint.core.helper:OFF org.mitk.gui.qt.matchpoint.algorithm.browser:OFF org.mitk.gui.qt.matchpoint.algorithm.control:OFF org.mitk.gui.qt.matchpoint.algorithm.batch:OFF org.mitk.gui.qt.matchpoint.mapper:OFF org.mitk.gui.qt.matchpoint.framereg:OFF org.mitk.gui.qt.matchpoint.visualizer:OFF org.mitk.gui.qt.matchpoint.evaluator:OFF org.mitk.gui.qt.matchpoint.manipulator:OFF + org.mitk.gui.qt.photoacoustics.pausviewer:OFF ) diff --git a/Plugins/org.mitk.gui.qt.pausmultiwidgeteditor/CMakeLists.txt b/Plugins/org.mitk.gui.qt.pausmultiwidgeteditor/CMakeLists.txt new file mode 100644 index 0000000000..fb2efded2a --- /dev/null +++ b/Plugins/org.mitk.gui.qt.pausmultiwidgeteditor/CMakeLists.txt @@ -0,0 +1,7 @@ +project(org_mitk_gui_qt_pausmultiwidgeteditor) + +mitk_create_plugin( + EXPORT_DIRECTIVE ORG_MITK_GUI_QT_PAUSMULTIWIDGETEDITOR + EXPORTED_INCLUDE_SUFFIXES src + MODULE_DEPENDS MitkQtWidgets + ) diff --git a/Plugins/org.mitk.gui.qt.pausmultiwidgeteditor/files.cmake b/Plugins/org.mitk.gui.qt.pausmultiwidgeteditor/files.cmake new file mode 100644 index 0000000000..353d18260e --- /dev/null +++ b/Plugins/org.mitk.gui.qt.pausmultiwidgeteditor/files.cmake @@ -0,0 +1,30 @@ +set(SRC_CPP_FILES + QmitkPAUSMultiWidgetEditor.cpp +) + +set(INTERNAL_CPP_FILES + org_mitk_gui_qt_pausmultiwidgeteditor_Activator.cpp +) + +set(MOC_H_FILES + src/QmitkPAUSMultiWidgetEditor.h + src/internal/org_mitk_gui_qt_pausmultiwidgeteditor_Activator.h +) + +set(CACHED_RESOURCE_FILES + plugin.xml + resources/PAUSMultiWidgetEditor.png +) + +set(QRC_FILES +) + +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.pausmultiwidgeteditor/manifest_headers.cmake b/Plugins/org.mitk.gui.qt.pausmultiwidgeteditor/manifest_headers.cmake new file mode 100644 index 0000000000..6d91642b93 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.pausmultiwidgeteditor/manifest_headers.cmake @@ -0,0 +1,6 @@ +set(Plugin-Name "PAUS MultiWidget Editor") +set(Plugin-Version "1.0.0") +set(Plugin-Vendor "DKFZ, Medical and Biological Informatics") +set(Plugin-ContactAddress "http://www.mitk.org") +set(Require-Plugin org.mitk.gui.qt.ultrasound) + diff --git a/Plugins/org.mitk.gui.qt.pausmultiwidgeteditor/plugin.xml b/Plugins/org.mitk.gui.qt.pausmultiwidgeteditor/plugin.xml new file mode 100644 index 0000000000..be21558d29 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.pausmultiwidgeteditor/plugin.xml @@ -0,0 +1,13 @@ + + + + + + + + diff --git a/Plugins/org.mitk.gui.qt.pausmultiwidgeteditor/resources/PAUSMultiWidgetEditor.png b/Plugins/org.mitk.gui.qt.pausmultiwidgeteditor/resources/PAUSMultiWidgetEditor.png new file mode 100644 index 0000000000..00cf383e5b Binary files /dev/null and b/Plugins/org.mitk.gui.qt.pausmultiwidgeteditor/resources/PAUSMultiWidgetEditor.png differ diff --git a/Plugins/org.mitk.gui.qt.pausmultiwidgeteditor/src/QmitkPAUSMultiWidgetEditor.cpp b/Plugins/org.mitk.gui.qt.pausmultiwidgeteditor/src/QmitkPAUSMultiWidgetEditor.cpp new file mode 100644 index 0000000000..fa7e58146d --- /dev/null +++ b/Plugins/org.mitk.gui.qt.pausmultiwidgeteditor/src/QmitkPAUSMultiWidgetEditor.cpp @@ -0,0 +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. + +===================================================================*/ + +#include "QmitkPAUSMultiWidgetEditor.h" + +#include + + +const QString QmitkPAUSMultiWidgetEditor::EDITOR_ID = "org.mitk.editors.pausmultiwidget"; + +QmitkPAUSMultiWidgetEditor::QmitkPAUSMultiWidgetEditor() +{ +} + +QmitkPAUSMultiWidgetEditor::~QmitkPAUSMultiWidgetEditor() +{ +} + +void QmitkPAUSMultiWidgetEditor::SetFocus() +{ +} + +bool QmitkPAUSMultiWidgetEditor::IsDecorationEnabled(const QString &decoration) const +{ + return false; +} + +void QmitkPAUSMultiWidgetEditor::EnableDecorations(bool enable, const QStringList &decorations) +{ +} + +QStringList QmitkPAUSMultiWidgetEditor::GetDecorations() const +{ + QStringList decorations; + decorations << DECORATION_BORDER; + return decorations; +} + +mitk::Point3D QmitkPAUSMultiWidgetEditor::GetSelectedPosition(const QString & /*id*/) const +{ + mitk::Point3D zeroPosition; + return zeroPosition; +} + +void QmitkPAUSMultiWidgetEditor::SetSelectedPosition(const mitk::Point3D &pos, const QString &/*id*/) +{ +} + +QHash QmitkPAUSMultiWidgetEditor::GetQmitkRenderWindows() const +{ + return m_RenderWindows; +} + +QmitkRenderWindow *QmitkPAUSMultiWidgetEditor::GetActiveQmitkRenderWindow() const +{ + return 0; +} + +QmitkRenderWindow *QmitkPAUSMultiWidgetEditor::GetQmitkRenderWindow(const QString &id) const +{ + return 0; +} + +void QmitkPAUSMultiWidgetEditor::CreateQtPartControl(QWidget* parent) +{ + // if (d->m_StdMultiWidget == 0) + // { + // QHBoxLayout* layout = new QHBoxLayout(parent); + // layout->setContentsMargins(0,0,0,0); + + // if (d->m_MouseModeToolbar == NULL) + // { + // d->m_MouseModeToolbar = new QmitkMouseModeSwitcher(parent); // delete by Qt via parent + // layout->addWidget(d->m_MouseModeToolbar); + // } + + // berry::IPreferences::Pointer prefs = this->GetPreferences(); + + // mitk::BaseRenderer::RenderingMode::Type renderingMode = static_cast(prefs->GetInt( "Rendering Mode" , 0 )); + + // d->m_StdMultiWidget = new QmitkStdMultiWidget(parent,0,0,renderingMode); + // d->m_RenderWindows.insert("axial", d->m_StdMultiWidget->GetRenderWindow1()); + // d->m_RenderWindows.insert("sagittal", d->m_StdMultiWidget->GetRenderWindow2()); + // d->m_RenderWindows.insert("coronal", d->m_StdMultiWidget->GetRenderWindow3()); + // d->m_RenderWindows.insert("3d", d->m_StdMultiWidget->GetRenderWindow4()); + + // d->m_MouseModeToolbar->setMouseModeSwitcher( d->m_StdMultiWidget->GetMouseModeSwitcher() ); + + // layout->addWidget(d->m_StdMultiWidget); + + // mitk::DataStorage::Pointer ds = this->GetDataStorage(); + + // // Tell the multiWidget which (part of) the tree to render + // d->m_StdMultiWidget->SetDataStorage(ds); + + // // Initialize views as axial, sagittal, coronar to all data objects in DataStorage + // // (from top-left to bottom) + // mitk::TimeGeometry::Pointer geo = ds->ComputeBoundingGeometry3D(ds->GetAll()); + // mitk::RenderingManager::GetInstance()->InitializeViews(geo); + + // // Initialize bottom-right view as 3D view + // d->m_StdMultiWidget->GetRenderWindow4()->GetRenderer()->SetMapperID( + // mitk::BaseRenderer::Standard3D ); + + // // Enable standard handler for levelwindow-slider + // d->m_StdMultiWidget->EnableStandardLevelWindow(); + + // // Add the displayed views to the tree to see their positions + // // in 2D and 3D + // d->m_StdMultiWidget->AddDisplayPlaneSubTree(); + + // //d->m_StdMultiWidget->EnableNavigationControllerEventListening(); + + // // Store the initial visibility status of the menu widget. + // d->m_MenuWidgetsEnabled = d->m_StdMultiWidget->IsMenuWidgetEnabled(); + + // this->GetSite()->GetPage()->AddPartListener(d->m_PartListener.data()); + + // berry::IBerryPreferences* berryprefs = dynamic_cast(prefs.GetPointer()); + // InitializePreferences(berryprefs); + // this->OnPreferencesChanged(berryprefs); + + // this->RequestUpdate(); + // } +} + diff --git a/Plugins/org.mitk.gui.qt.pausmultiwidgeteditor/src/QmitkPAUSMultiWidgetEditor.h b/Plugins/org.mitk.gui.qt.pausmultiwidgeteditor/src/QmitkPAUSMultiWidgetEditor.h new file mode 100644 index 0000000000..c87ed75478 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.pausmultiwidgeteditor/src/QmitkPAUSMultiWidgetEditor.h @@ -0,0 +1,91 @@ +/*=================================================================== + +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 QmitkPAUSMultiWidgetEditor_h +#define QmitkPAUSMultiWidgetEditor_h + +#include + +#include + +class ORG_MITK_GUI_QT_PAUSMULTIWIDGETEDITOR QmitkPAUSMultiWidgetEditor + : public QmitkAbstractRenderEditor +{ + Q_OBJECT + +public: + + berryObjectMacro(QmitkPAUSMultiWidgetEditor) + + static const QString EDITOR_ID; + + QmitkPAUSMultiWidgetEditor(); + ~QmitkPAUSMultiWidgetEditor(); + +protected: + + void SetFocus() override; + + // ------------------- mitk::IRenderWindowPart ---------------------- + + /** + * \see mitk::IRenderWindowPart::GetActiveQmitkRenderWindow() + */ + QmitkRenderWindow* GetActiveQmitkRenderWindow() const override; + + /** + * \see mitk::IRenderWindowPart::GetQmitkRenderWindows() + */ + QHash GetQmitkRenderWindows() const override; + + /** + * \see mitk::IRenderWindowPart::GetQmitkRenderWindow(QString) + */ + QmitkRenderWindow* GetQmitkRenderWindow(const QString& id) const override; + + /** + * \see mitk::IRenderWindowPart::GetSelectionPosition() + */ + mitk::Point3D GetSelectedPosition(const QString& id = QString()) const override; + + /** + * \see mitk::IRenderWindowPart::SetSelectedPosition() + */ + void SetSelectedPosition(const mitk::Point3D& pos, const QString& id = QString()) override; + + /** + * \see mitk::IRenderWindowPart::EnableDecorations() + */ + void EnableDecorations(bool enable, const QStringList& decorations = QStringList()) override; + + /** + * \see mitk::IRenderWindowPart::IsDecorationEnabled() + */ + bool IsDecorationEnabled(const QString& decoration) const override; + + /** + * \see mitk::IRenderWindowPart::GetDecorations() + */ + QStringList GetDecorations() const override; + + + QHash m_RenderWindows; + + + void CreateQtPartControl(QWidget* parent) override; + +}; +#endif /*QmitkPAUSMultiWidgetEditor_h*/ diff --git a/Plugins/org.mitk.gui.qt.pausmultiwidgeteditor/src/internal/org_mitk_gui_qt_pausmultiwidgeteditor_Activator.cpp b/Plugins/org.mitk.gui.qt.pausmultiwidgeteditor/src/internal/org_mitk_gui_qt_pausmultiwidgeteditor_Activator.cpp new file mode 100644 index 0000000000..e3b6b2f4fb --- /dev/null +++ b/Plugins/org.mitk.gui.qt.pausmultiwidgeteditor/src/internal/org_mitk_gui_qt_pausmultiwidgeteditor_Activator.cpp @@ -0,0 +1,42 @@ +/*=================================================================== + +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 "org_mitk_gui_qt_pausmultiwidgeteditor_Activator.h" + +#include "../QmitkPAUSMultiWidgetEditor.h" + +ctkPluginContext* org_mitk_gui_qt_pausmultiwidgeteditor_Activator::m_Context = nullptr; + +void +org_mitk_gui_qt_pausmultiwidgeteditor_Activator::start(ctkPluginContext* context) +{ + m_Context = context; + + BERRY_REGISTER_EXTENSION_CLASS(QmitkPAUSMultiWidgetEditor, context) +} + +void +org_mitk_gui_qt_pausmultiwidgeteditor_Activator::stop(ctkPluginContext* context) +{ + Q_UNUSED(context) + + m_Context = nullptr; +} + +ctkPluginContext *org_mitk_gui_qt_pausmultiwidgeteditor_Activator::GetContext() +{ + return m_Context; +} diff --git a/Plugins/org.mitk.gui.qt.pausmultiwidgeteditor/src/internal/org_mitk_gui_qt_pausmultiwidgeteditor_Activator.h b/Plugins/org.mitk.gui.qt.pausmultiwidgeteditor/src/internal/org_mitk_gui_qt_pausmultiwidgeteditor_Activator.h new file mode 100644 index 0000000000..bf0d9d71c1 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.pausmultiwidgeteditor/src/internal/org_mitk_gui_qt_pausmultiwidgeteditor_Activator.h @@ -0,0 +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 org_mitk_gui_qt_pausmultiwidgeteditor_Activator_H_ +#define org_mitk_gui_qt_pausmultiwidgeteditor_Activator_H_ + +#include + +class org_mitk_gui_qt_pausmultiwidgeteditor_Activator : public QObject, public ctkPluginActivator +{ + Q_OBJECT + Q_PLUGIN_METADATA(IID "org_mitk_gui_qt_pausmultiwidgeteditor") + Q_INTERFACES(ctkPluginActivator) + +public: + + void start(ctkPluginContext* context) override; + void stop(ctkPluginContext* context) override; + + static ctkPluginContext* GetContext(); + +private: + + static ctkPluginContext* m_Context; + +}; + +typedef org_mitk_gui_qt_pausmultiwidgeteditor_Activator PluginActivator; + +#endif /* org_mitk_gui_qt_pausmultiwidgeteditor_Activator_H_ */ + diff --git a/Plugins/org.mitk.gui.qt.photoacoustics.pausviewer/CMakeLists.txt b/Plugins/org.mitk.gui.qt.photoacoustics.pausviewer/CMakeLists.txt new file mode 100644 index 0000000000..37b3269ee4 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.photoacoustics.pausviewer/CMakeLists.txt @@ -0,0 +1,9 @@ +# The project name must correspond to the directory name of your plug-in +# and must not contain periods. +project(org_mitk_gui_qt_photoacoustics_pausviewer) + +mitk_create_plugin( + EXPORT_DIRECTIVE PHOTOACOUSTICS_PAUSVIEWER_EXPORTS + EXPORTED_INCLUDE_SUFFIXES src + MODULE_DEPENDS MitkQtWidgets +) diff --git a/Plugins/org.mitk.gui.qt.photoacoustics.pausviewer/files.cmake b/Plugins/org.mitk.gui.qt.photoacoustics.pausviewer/files.cmake new file mode 100644 index 0000000000..d1ea1b0bd4 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.photoacoustics.pausviewer/files.cmake @@ -0,0 +1,26 @@ +set(INTERNAL_CPP_FILES + QmitkPAUSViewerView.cpp + org_mitk_gui_qt_photoacoustics_pausviewer_Activator.cpp +) + +set(UI_FILES + src/internal/QmitkPAUSViewerViewControls.ui +) + +set(MOC_H_FILES + src/internal/QmitkPAUSViewerView.h + src/internal/org_mitk_gui_qt_photoacoustics_pausviewer_Activator.h +) + +set(CACHED_RESOURCE_FILES + resources/PAUSViewer.png + plugin.xml +) + +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}) \ No newline at end of file diff --git a/Plugins/org.mitk.gui.qt.photoacoustics.pausviewer/manifest_headers.cmake b/Plugins/org.mitk.gui.qt.photoacoustics.pausviewer/manifest_headers.cmake new file mode 100644 index 0000000000..b0abe671c4 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.photoacoustics.pausviewer/manifest_headers.cmake @@ -0,0 +1,5 @@ +set(Plugin-Name "PA US Viewer") +set(Plugin-Version "0.9") +set(Plugin-Vendor "DKFZ, Medical and Biological Informatics") +set(Plugin-ContactAddress "http://www.mitk.org") +set(Require-Plugin org.mitk.gui.qt.common) \ No newline at end of file diff --git a/Plugins/org.mitk.gui.qt.photoacoustics.pausviewer/plugin.xml b/Plugins/org.mitk.gui.qt.photoacoustics.pausviewer/plugin.xml new file mode 100644 index 0000000000..f2bda668ae --- /dev/null +++ b/Plugins/org.mitk.gui.qt.photoacoustics.pausviewer/plugin.xml @@ -0,0 +1,11 @@ + + + + + + + + diff --git a/Plugins/org.mitk.gui.qt.photoacoustics.pausviewer/resources/PAUSViewer.png b/Plugins/org.mitk.gui.qt.photoacoustics.pausviewer/resources/PAUSViewer.png new file mode 100644 index 0000000000..7846083408 Binary files /dev/null and b/Plugins/org.mitk.gui.qt.photoacoustics.pausviewer/resources/PAUSViewer.png differ diff --git a/Plugins/org.mitk.gui.qt.photoacoustics.pausviewer/src/internal/QmitkPAUSViewerView.cpp b/Plugins/org.mitk.gui.qt.photoacoustics.pausviewer/src/internal/QmitkPAUSViewerView.cpp new file mode 100644 index 0000000000..67af788781 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.photoacoustics.pausviewer/src/internal/QmitkPAUSViewerView.cpp @@ -0,0 +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. + +===================================================================*/ + +// Blueberry +#include +#include + +#include "QmitkPAUSViewerView.h" + +const std::string QmitkPAUSViewerView::VIEW_ID = "org.mitk.views.photoacoustics.pausviewer"; + +QmitkPAUSViewerView::QmitkPAUSViewerView() +{ +} + +QmitkPAUSViewerView::~QmitkPAUSViewerView() +{ +} + +void QmitkPAUSViewerView::InitWindows() +{ +} + +void QmitkPAUSViewerView::SetFocus() +{ +} + +void QmitkPAUSViewerView::OnSelectionChanged(berry::IWorkbenchPart::Pointer /*source*/, + const QList& nodes) +{ +} + +void QmitkPAUSViewerView::CreateQtPartControl(QWidget *parent) +{ + m_Controls.setupUi(parent); +} \ No newline at end of file diff --git a/Plugins/org.mitk.gui.qt.photoacoustics.pausviewer/src/internal/QmitkPAUSViewerView.h b/Plugins/org.mitk.gui.qt.photoacoustics.pausviewer/src/internal/QmitkPAUSViewerView.h new file mode 100644 index 0000000000..b994cdba12 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.photoacoustics.pausviewer/src/internal/QmitkPAUSViewerView.h @@ -0,0 +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 QMITKPAUSVIEWERVIEW_H_INCLUDED +#define QMITKPAUSVIEWERVIEW_H_INCLUDED + +#include +#include + +#include "ui_QmitkPAUSViewerViewControls.h" + +#include "mitkCommon.h" + +class QmitkPAUSViewerView : public QmitkAbstractView +{ + // 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 VIEW_ID; + + QmitkPAUSViewerView(); + virtual ~QmitkPAUSViewerView(); + + virtual void CreateQtPartControl(QWidget *parent); + void InitWindows(); + +protected: + + virtual void SetFocus() override; + + virtual void OnSelectionChanged(berry::IWorkbenchPart::Pointer source, + const QList& nodes) override; + + Ui::QmitkPAUSViewerViewControls m_Controls; +}; + +#endif // QMITKPAUSVIEWERVIEW_H_INCLUDED + diff --git a/Plugins/org.mitk.gui.qt.photoacoustics.pausviewer/src/internal/QmitkPAUSViewerViewControls.ui b/Plugins/org.mitk.gui.qt.photoacoustics.pausviewer/src/internal/QmitkPAUSViewerViewControls.ui new file mode 100644 index 0000000000..dda546f9e0 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.photoacoustics.pausviewer/src/internal/QmitkPAUSViewerViewControls.ui @@ -0,0 +1,91 @@ + + + QmitkPAUSViewerViewControls + + + + 0 + 0 + 1086 + 744 + + + + + 0 + 0 + + + + QmitkTemplate + + + false + + + + + + + + + 0 + 0 + + + + + + + + + 0 + 0 + + + + + + + + + 75 + true + + + + Ultrasound + + + + + + + + 75 + true + + + + Photoacoustics + + + + + + + + + + + QmitkRenderWindow + QListView +
QmitkRenderWindow.h
+
+
+ + QmitkDataStorageComboBox.h + + + +
diff --git a/Plugins/org.mitk.gui.qt.photoacoustics.pausviewer/src/internal/org_mitk_gui_qt_photoacoustics_pausviewer_Activator.cpp b/Plugins/org.mitk.gui.qt.photoacoustics.pausviewer/src/internal/org_mitk_gui_qt_photoacoustics_pausviewer_Activator.cpp new file mode 100644 index 0000000000..6c6193b374 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.photoacoustics.pausviewer/src/internal/org_mitk_gui_qt_photoacoustics_pausviewer_Activator.cpp @@ -0,0 +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. + +===================================================================*/ + +#include "org_mitk_gui_qt_photoacoustics_pausviewer_Activator.h" +#include "QmitkPAUSViewerView.h" + + +namespace mitk { + + void org_mitk_gui_qt_photoacoustics_pausviewer_Activator::start(ctkPluginContext* context) + { + BERRY_REGISTER_EXTENSION_CLASS(QmitkPAUSViewerView, context) + } + + void org_mitk_gui_qt_photoacoustics_pausviewer_Activator::stop(ctkPluginContext* context) + { + Q_UNUSED(context) + } + +} diff --git a/Plugins/org.mitk.gui.qt.photoacoustics.pausviewer/src/internal/org_mitk_gui_qt_photoacoustics_pausviewer_Activator.h b/Plugins/org.mitk.gui.qt.photoacoustics.pausviewer/src/internal/org_mitk_gui_qt_photoacoustics_pausviewer_Activator.h new file mode 100644 index 0000000000..e91e4d7f07 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.photoacoustics.pausviewer/src/internal/org_mitk_gui_qt_photoacoustics_pausviewer_Activator.h @@ -0,0 +1,39 @@ +/*=================================================================== + +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 _MITKPAUSVIEWERPLUGINACTIVATOR_H +#define _MITKPAUSVIEWERPLUGINACTIVATOR_H + +#include + +namespace mitk { + + class org_mitk_gui_qt_photoacoustics_pausviewer_Activator : + public QObject, public ctkPluginActivator + { + Q_OBJECT + Q_PLUGIN_METADATA(IID "org_mitk_gui_qt_photoacoustics_pausviewer") + Q_INTERFACES(ctkPluginActivator) + + public: + + void start(ctkPluginContext* context) override; + void stop(ctkPluginContext* context) override; + + }; + +} + +#endif // _MITKPAUSVIEWERPLUGINACTIVATOR_H diff --git a/Plugins/org.mitk.gui.qt.ultrasound/src/internal/UltrasoundSupport.cpp b/Plugins/org.mitk.gui.qt.ultrasound/src/internal/UltrasoundSupport.cpp index c108a65cd1..9904cbd530 100644 --- a/Plugins/org.mitk.gui.qt.ultrasound/src/internal/UltrasoundSupport.cpp +++ b/Plugins/org.mitk.gui.qt.ultrasound/src/internal/UltrasoundSupport.cpp @@ -1,735 +1,732 @@ /*=================================================================== 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 //Mitk #include #include #include #include #include #include #include #include #include #include #include "QmitkRegisterClasses.h" #include "QmitkRenderWindow.h" #include "mitkScaleLegendOverlay.h" #include #include // Qmitk #include "UltrasoundSupport.h" // Qt #include #include #include // Ultrasound #include "mitkUSDevice.h" #include "QmitkUSAbstractCustomWidget.h" #include #include #include "usServiceReference.h" #include "internal/org_mitk_gui_qt_ultrasound_Activator.h" +#include "mitkNodePredicateDataType.h" +#include const std::string UltrasoundSupport::VIEW_ID = "org.mitk.views.ultrasoundsupport"; void UltrasoundSupport::SetFocus() { } void UltrasoundSupport::CreateQtPartControl(QWidget *parent) { //initialize timers m_UpdateTimer = new QTimer(this); m_RenderingTimer2d = new QTimer(this); m_RenderingTimer3d = new QTimer(this); // create GUI widgets from the Qt Designer's .ui file m_Controls.setupUi(parent); //load persistence data before connecting slots (so no slots are called in this phase...) LoadUISettings(); //connect signals and slots... connect(m_Controls.m_DeviceManagerWidget, SIGNAL(NewDeviceButtonClicked()), this, SLOT(OnClickedAddNewDevice())); // Change Widget Visibilities connect(m_Controls.m_DeviceManagerWidget, SIGNAL(NewDeviceButtonClicked()), this->m_Controls.m_NewVideoDeviceWidget, SLOT(CreateNewDevice())); // Init NewDeviceWidget connect(m_Controls.m_ActiveVideoDevices, SIGNAL(ServiceSelectionChanged(us::ServiceReferenceU)), this, SLOT(OnChangedActiveDevice())); connect(m_Controls.m_RunImageTimer, SIGNAL(clicked()), this, SLOT(OnChangedActiveDevice())); connect(m_Controls.m_ShowImageStream, SIGNAL(clicked()), this, SLOT(OnChangedActiveDevice())); connect(m_Controls.m_NewVideoDeviceWidget, SIGNAL(Finished()), this, SLOT(OnNewDeviceWidgetDone())); // After NewDeviceWidget finished editing connect(m_Controls.m_FrameRatePipeline, SIGNAL(valueChanged(int)), this, SLOT(OnChangedFramerateLimit())); connect(m_Controls.m_FrameRate2d, SIGNAL(valueChanged(int)), this, SLOT(OnChangedFramerateLimit())); connect(m_Controls.m_FrameRate3d, SIGNAL(valueChanged(int)), this, SLOT(OnChangedFramerateLimit())); connect(m_Controls.m_FreezeButton, SIGNAL(clicked()), this, SLOT(OnClickedFreezeButton())); connect(m_UpdateTimer, SIGNAL(timeout()), this, SLOT(UpdateImage())); connect(m_RenderingTimer2d, SIGNAL(timeout()), this, SLOT(RenderImage2d())); connect(m_RenderingTimer3d, SIGNAL(timeout()), this, SLOT(RenderImage3d())); connect(m_Controls.m_Update2DView, SIGNAL(clicked()), this, SLOT(StartTimers())); connect(m_Controls.m_Update3DView, SIGNAL(clicked()), this, SLOT(StartTimers())); connect(m_Controls.m_DeviceManagerWidget, SIGNAL(EditDeviceButtonClicked(mitk::USDevice::Pointer)), this, SLOT(OnClickedEditDevice())); //Change Widget Visibilities connect(m_Controls.m_DeviceManagerWidget, SIGNAL(EditDeviceButtonClicked(mitk::USDevice::Pointer)), this->m_Controls.m_NewVideoDeviceWidget, SLOT(EditDevice(mitk::USDevice::Pointer))); // Initializations m_Controls.m_NewVideoDeviceWidget->setVisible(false); std::string filter = "(&(" + us::ServiceConstants::OBJECTCLASS() + "=" + "org.mitk.services.UltrasoundDevice)(" + mitk::USDevice::GetPropertyKeys().US_PROPKEY_ISACTIVE + "=true))"; m_Controls.m_ActiveVideoDevices->Initialize( mitk::USDevice::GetPropertyKeys().US_PROPKEY_LABEL, filter); m_Controls.m_ActiveVideoDevices->SetAutomaticallySelectFirstEntry(true); m_FrameCounterPipeline = 0; m_FrameCounter2d = 0; m_FrameCounter3d = 0; m_Controls.tabWidget->setTabEnabled(1, false); CreateWindows(); } - -#include "mitkNodePredicateDataType.h" - void UltrasoundSupport::CreateWindows() { auto renderingManager = mitk::RenderingManager::GetInstance(); m_PARenderWidget = new QmitkSliceWidget(); m_PARenderWidget->SetLevelWindowEnabled(true); m_PARenderWidget->levelWindow->SetDataStorage(m_PADataStorage); m_PARenderWidget->SetDataStorage(m_PADataStorage); m_PARenderWidget->hide(); m_PARenderWidget->m_NavigatorWidget->hide(); m_USRenderWidget = new QmitkSliceWidget(); m_USRenderWidget->SetLevelWindowEnabled(true); m_USRenderWidget->levelWindow->SetDataStorage(m_USDataStorage); m_USRenderWidget->SetDataStorage(m_USDataStorage); m_USRenderWidget->hide(); m_USRenderWidget->m_NavigatorWidget->hide(); } -#include - void UltrasoundSupport::InitNewNode() { m_Node.push_back(nullptr); auto& Node = m_Node.back(); Node = mitk::DataNode::New(); Node->SetName("No Data received yet ..."); //create a dummy image (gray values 0..255) for correct initialization of level window, etc. mitk::Image::Pointer dummyImage = mitk::ImageGenerator::GenerateRandomImage(100, 100, 1, 1, 1, 1, 1, 255, 0); Node->SetData(dummyImage); m_OldGeometry = dynamic_cast(dummyImage->GetGeometry()); UpdateColormaps(); this->GetDataStorage()->Add(Node); if (m_Node.size() > 1) m_USDataStorage->Add(Node); else if (m_Node.size() == 1) m_PADataStorage->Add(Node); } void UltrasoundSupport::DestroyLastNode() { auto& Node = m_Node.back(); this->GetDataStorage()->Remove(Node); if (m_Node.size() > 1) m_USDataStorage->Remove(Node); else if (m_Node.size() == 1) m_PADataStorage->Remove(Node); Node->ReleaseData(); m_Node.pop_back(); UpdateColormaps(); } void UltrasoundSupport::AddOverlays() { mitk::ScaleLegendOverlay::Pointer scaleOverlay = mitk::ScaleLegendOverlay::New(); scaleOverlay->SetLeftAxisVisibility(true); scaleOverlay->SetRightAxisVisibility(false); scaleOverlay->SetRightAxisVisibility(false); scaleOverlay->SetTopAxisVisibility(false); scaleOverlay->SetCornerOffsetFactor(0); m_PAOverlayManager->AddOverlay(scaleOverlay.GetPointer()); m_USOverlayManager->AddOverlay(scaleOverlay.GetPointer()); } void UltrasoundSupport::RemoveOverlays() { m_PAOverlayManager->RemoveAllOverlays(); } void UltrasoundSupport::UpdateColormaps() { //return; // TODO: review the colormap functionality // we update here both the colormaps of the nodes, as well as the // level window for the current dynamic range mitk::LevelWindow levelWindow; if (m_Node.size() > 1) { for (int index = 0; index < m_AmountOfOutputs - 1; ++index) { SetColormap(m_Node.at(index), mitk::LookupTable::LookupTableType::GRAYSCALE); m_Node.at(index)->GetLevelWindow(levelWindow); if (!m_Image->IsEmpty()) levelWindow.SetAuto(m_Image, true, true); m_Node.at(index)->SetLevelWindow(levelWindow); } SetColormap(m_Node.back(), mitk::LookupTable::LookupTableType::GRAYSCALE); m_Node.back()->GetLevelWindow(levelWindow); levelWindow.SetWindowBounds(10, 150, true); m_Node.back()->SetLevelWindow(levelWindow); } else if (m_Node.size() == 1) { SetColormap(m_Node.back(), mitk::LookupTable::LookupTableType::GRAYSCALE); m_Node.back()->GetLevelWindow(levelWindow); if (!m_Image->IsEmpty()) levelWindow.SetAuto(m_Image, true, true); m_Node.back()->SetLevelWindow(levelWindow); } } void UltrasoundSupport::SetColormap(mitk::DataNode::Pointer node, mitk::LookupTable::LookupTableType type) { mitk::LookupTable::Pointer lookupTable = mitk::LookupTable::New(); mitk::LookupTableProperty::Pointer lookupTableProperty = mitk::LookupTableProperty::New(); lookupTable->SetType(type); lookupTableProperty->SetLookupTable(lookupTable); node->SetProperty("LookupTable", lookupTableProperty); mitk::RenderingModeProperty::Pointer renderingMode = dynamic_cast(node->GetProperty("Image Rendering.Mode")); renderingMode->SetValue(mitk::RenderingModeProperty::LOOKUPTABLE_LEVELWINDOW_COLOR); } void UltrasoundSupport::OnClickedAddNewDevice() { m_Controls.m_NewVideoDeviceWidget->setVisible(true); m_Controls.m_DeviceManagerWidget->setVisible(false); m_Controls.m_Headline->setText("Add New Video Device:"); m_Controls.m_WidgetActiveDevices->setVisible(false); } void UltrasoundSupport::OnClickedEditDevice() { m_Controls.m_NewVideoDeviceWidget->setVisible(true); m_Controls.m_DeviceManagerWidget->setVisible(false); m_Controls.m_WidgetActiveDevices->setVisible(false); m_Controls.m_Headline->setText("Edit Video Device:"); } void UltrasoundSupport::UpdateAmountOfOutputs() { // Update the amount of Nodes; there should be one Node for every slide that is set. Note that we must check whether the slices are set, // just using the m_Image->dimension(3) will produce nullpointers on slices of the image that were not set bool isSet = true; m_AmountOfOutputs = 0; while (isSet) { isSet = m_Image->IsSliceSet(m_AmountOfOutputs); if (isSet) ++m_AmountOfOutputs; } // correct the amount of Nodes to display data while (m_Node.size() < m_AmountOfOutputs) { InitNewNode(); } while (m_Node.size() > m_AmountOfOutputs) { DestroyLastNode(); } // correct the amount of image outputs that we feed the nodes with while (m_curOutput.size() < m_AmountOfOutputs) { m_curOutput.push_back(mitk::Image::New()); // initialize the slice images as 2d images with the size of m_Images unsigned int* dimOld = m_Image->GetDimensions(); unsigned int dim[2] = { dimOld[0], dimOld[1] }; m_curOutput.back()->Initialize(m_Image->GetPixelType(), 2, dim); } while (m_curOutput.size() > m_AmountOfOutputs) { m_curOutput.pop_back(); } } void UltrasoundSupport::UpdateImage() { if(m_Controls.m_ShowImageStream->isChecked()) { if (m_PARenderer == nullptr || m_PAOverlayManager == nullptr || m_USRenderer == nullptr || m_USOverlayManager == nullptr) { //setup an overlay manager mitk::OverlayManager::Pointer OverlayManagerInstancePA = mitk::OverlayManager::New(); m_PARenderer = mitk::BaseRenderer::GetInstance(m_PARenderWidget->GetRenderWindow()->GetVtkRenderWindow()); m_PARenderer->SetOverlayManager(OverlayManagerInstancePA); m_PAOverlayManager = m_PARenderer->GetOverlayManager(); mitk::OverlayManager::Pointer OverlayManagerInstanceUS = mitk::OverlayManager::New(); m_USRenderer = mitk::BaseRenderer::GetInstance(m_USRenderWidget->GetRenderWindow()->GetVtkRenderWindow()); m_USRenderer->SetOverlayManager(OverlayManagerInstanceUS); m_USOverlayManager = m_USRenderer->GetOverlayManager(); AddOverlays(); m_PARenderWidget->show(); m_USRenderWidget->show(); } m_Device->Modified(); m_Device->Update(); // Update device m_Image = m_Device->GetOutput(); // get the Image data to display UpdateAmountOfOutputs(); // create as many Nodes and Outputs as there are slices in m_Image if (m_AmountOfOutputs == 0) return; // if there is no image to be displayed, skip the rest of this method for (int index = 0; index < m_AmountOfOutputs; ++index) { if (m_curOutput.at(index)->GetDimension(0) != m_Image->GetDimension(0) || m_curOutput.at(index)->GetDimension(1) != m_Image->GetDimension(1) || m_curOutput.at(index)->GetDimension(2) != m_Image->GetDimension(2) || m_curOutput.at(index)->GetPixelType() != m_Image->GetPixelType()) { unsigned int* dimOld = m_Image->GetDimensions(); unsigned int dim[2] = { dimOld[0], dimOld[1]}; m_curOutput.at(index)->Initialize(m_Image->GetPixelType(), 2, dim); // if we switched image resolution or type the outputs must be reinitialized! } if (!m_Image->IsEmpty()) { mitk::ImageReadAccessor inputReadAccessor(m_Image, m_Image->GetSliceData(m_AmountOfOutputs-index-1,0,0,nullptr,mitk::Image::ReferenceMemory)); // just reference the slices, to get a small performance gain m_curOutput.at(index)->SetSlice(inputReadAccessor.GetData()); m_curOutput.at(index)->GetGeometry()->SetIndexToWorldTransform(m_Image->GetSlicedGeometry()->GetIndexToWorldTransform()); // Update the image Output with seperate slices } if (m_curOutput.at(index)->IsEmpty()) { m_Node.at(index)->SetName("No Data received yet ..."); // create a noise image for correct initialization of level window, etc. mitk::Image::Pointer randomImage = mitk::ImageGenerator::GenerateRandomImage(32, 32, 1, 1, 1, 1, 1, 255, 0); m_Node.at(index)->SetData(randomImage); m_curOutput.at(index)->SetGeometry(randomImage->GetGeometry()); } else { char name[30]; sprintf(name, "US Viewing Stream - Image %d", index); m_Node.at(index)->SetName(name); m_Node.at(index)->SetData(m_curOutput.at(index)); // set the name of the Output } } // if the geometry changed: reinitialize the ultrasound image. we use the m_curOutput.at(0) to readjust the geometry if ((m_OldGeometry.IsNotNull()) && (m_curOutput.at(0)->GetGeometry() != NULL) && (!mitk::Equal(m_OldGeometry.GetPointer(), m_curOutput.at(0)->GetGeometry(), 0.0001, false)) ) { mitk::IRenderWindowPart* renderWindow = this->GetRenderWindowPart(); if ((renderWindow != NULL) && (m_curOutput.at(0)->GetTimeGeometry()->IsValid()) && (m_Controls.m_ShowImageStream->isChecked())) { renderWindow->GetRenderingManager()->InitializeViews( m_curOutput.at(0)->GetGeometry(), mitk::RenderingManager::REQUEST_UPDATE_ALL, true); renderWindow->GetRenderingManager()->RequestUpdateAll(); } m_CurrentImageWidth = m_curOutput.at(0)->GetDimension(0); m_CurrentImageHeight = m_curOutput.at(0)->GetDimension(1); m_OldGeometry = dynamic_cast(m_curOutput.at(0)->GetGeometry()); } } //Update frame counter m_FrameCounterPipeline++; if (m_FrameCounterPipeline >= 10) { // compute framerate of pipeline update int nMilliseconds = m_Clock.restart(); int fps = 10000.0f / (nMilliseconds); m_FPSPipeline = fps; m_FrameCounterPipeline = 0; // display lowest framerate in UI int lowestFPS = m_FPSPipeline; if (m_Controls.m_Update2DView->isChecked() && (m_FPS2d < lowestFPS)) { lowestFPS = m_FPS2d; } if (m_Controls.m_Update3DView->isChecked() && (m_FPS3d < lowestFPS)) { lowestFPS = m_FPS3d; } m_Controls.m_FramerateLabel->setText("Current Framerate: " + QString::number(lowestFPS) + " FPS"); } } void UltrasoundSupport::RenderImage2d() { if (!m_Controls.m_Update2DView->isChecked()) return; //mitk::IRenderWindowPart* renderWindow = this->GetRenderWindowPart(); //renderWindow->GetRenderingManager()->RequestUpdate(mitk::BaseRenderer::GetInstance(mitk::BaseRenderer::GetRenderWindowByName("stdmulti.widget1"))->GetRenderWindow()); // TODO: figure out how to proceed with the standard display auto renderingManager = mitk::RenderingManager::GetInstance(); renderingManager->RequestUpdate(m_PARenderWidget->GetRenderWindow()->GetRenderWindow()); renderingManager->RequestUpdate(m_USRenderWidget->GetRenderWindow()->GetRenderWindow()); //this->RequestRenderWindowUpdate(mitk::RenderingManager::REQUEST_UPDATE_2DWINDOWS); m_FrameCounter2d++; if (m_FrameCounter2d >= 10) { // compute framerate of 2d render window update int nMilliseconds = m_Clock2d.restart(); int fps = 10000.0f / (nMilliseconds); m_FPS2d = fps; m_FrameCounter2d = 0; } } void UltrasoundSupport::RenderImage3d() { if (!m_Controls.m_Update3DView->isChecked()) return; this->RequestRenderWindowUpdate(mitk::RenderingManager::REQUEST_UPDATE_3DWINDOWS); m_FrameCounter3d++; if (m_FrameCounter3d >= 10) { // compute framerate of 2d render window update int nMilliseconds = m_Clock3d.restart(); int fps = 10000.0f / (nMilliseconds); m_FPS3d = fps; m_FrameCounter3d = 0; } } void UltrasoundSupport::OnChangedFramerateLimit() { StopTimers(); int intervalPipeline = (1000 / m_Controls.m_FrameRatePipeline->value()); int interval2D = (1000 / m_Controls.m_FrameRate2d->value()); int interval3D = (1000 / m_Controls.m_FrameRate3d->value()); SetTimerIntervals(intervalPipeline, interval2D, interval3D); StartTimers(); } void UltrasoundSupport::OnClickedFreezeButton() { if (m_Device.IsNull()) { MITK_WARN("UltrasoundSupport") << "Freeze button clicked though no device is selected."; return; } if (m_Device->GetIsFreezed()) { m_Device->SetIsFreezed(false); m_Controls.m_FreezeButton->setText("Freeze"); } else { m_Device->SetIsFreezed(true); m_Controls.m_FreezeButton->setText("Start Viewing Again"); } } void UltrasoundSupport::OnChangedActiveDevice() { //clean up, delete nodes and stop timer StopTimers(); this->RemoveControlWidgets(); for (auto& Node : m_Node) { this->GetDataStorage()->Remove(Node); Node->ReleaseData(); } m_Node.clear(); m_PARenderWidget->hide(); m_USRenderWidget->hide(); //get current device, abort if it is invalid m_Device = m_Controls.m_ActiveVideoDevices->GetSelectedService(); if (m_Device.IsNull()) { m_Controls.tabWidget->setTabEnabled(1, false); return; } //create the widgets for this device and enable the widget tab this->CreateControlWidgets(); m_Controls.tabWidget->setTabEnabled(1, true); //start timer if (m_Controls.m_RunImageTimer->isChecked()) { int intervalPipeline = (1000 / m_Controls.m_FrameRatePipeline->value()); int interval2D = (1000 / m_Controls.m_FrameRate2d->value()); int interval3D = (1000 / m_Controls.m_FrameRate3d->value()); SetTimerIntervals(intervalPipeline, interval2D, interval3D); StartTimers(); m_Controls.m_TimerWidget->setEnabled(true); } else { m_Controls.m_TimerWidget->setEnabled(false); } m_PARenderWidget->show(); m_USRenderWidget->show(); } void UltrasoundSupport::OnNewDeviceWidgetDone() { m_Controls.m_NewVideoDeviceWidget->setVisible(false); m_Controls.m_DeviceManagerWidget->setVisible(true); m_Controls.m_Headline->setText("Ultrasound Devices:"); m_Controls.m_WidgetActiveDevices->setVisible(true); } void UltrasoundSupport::CreateControlWidgets() { m_ControlProbesWidget = new QmitkUSControlsProbesWidget(m_Device->GetControlInterfaceProbes(), m_Controls.m_ToolBoxControlWidgets); m_Controls.probesWidgetContainer->addWidget(m_ControlProbesWidget); // create b mode widget for current device m_ControlBModeWidget = new QmitkUSControlsBModeWidget(m_Device->GetControlInterfaceBMode(), m_Controls.m_ToolBoxControlWidgets); if (m_Device->GetControlInterfaceBMode()) { m_Controls.m_ToolBoxControlWidgets->addItem(m_ControlBModeWidget, "B Mode Controls"); //m_Controls.m_ToolBoxControlWidgets->setItemEnabled(m_Controls.m_ToolBoxControlWidgets->count() - 1, false); } // create doppler widget for current device m_ControlDopplerWidget = new QmitkUSControlsDopplerWidget(m_Device->GetControlInterfaceDoppler(), m_Controls.m_ToolBoxControlWidgets); if (m_Device->GetControlInterfaceDoppler()) { m_Controls.m_ToolBoxControlWidgets->addItem(m_ControlDopplerWidget, "Doppler Controls"); //m_Controls.m_ToolBoxControlWidgets->setItemEnabled(m_Controls.m_ToolBoxControlWidgets->count() - 1, false); } ctkPluginContext* pluginContext = mitk::PluginActivator::GetContext(); if (pluginContext) { std::string filter = "(ork.mitk.services.UltrasoundCustomWidget.deviceClass=" + m_Device->GetDeviceClass() + ")"; QString interfaceName = QString::fromStdString(us_service_interface_iid()); m_CustomWidgetServiceReference = pluginContext->getServiceReferences(interfaceName, QString::fromStdString(filter)); if (m_CustomWidgetServiceReference.size() > 0) { m_ControlCustomWidget = pluginContext->getService (m_CustomWidgetServiceReference.at(0))->CloneForQt(m_Controls.tab2); m_ControlCustomWidget->SetDevice(m_Device); m_Controls.m_ToolBoxControlWidgets->addItem(m_ControlCustomWidget, "Custom Controls"); } else { m_Controls.m_ToolBoxControlWidgets->addItem(new QWidget(m_Controls.m_ToolBoxControlWidgets), "Custom Controls"); m_Controls.m_ToolBoxControlWidgets->setItemEnabled(m_Controls.m_ToolBoxControlWidgets->count() - 1, false); } } // select first enabled control widget for (int n = 0; n < m_Controls.m_ToolBoxControlWidgets->count(); ++n) { if (m_Controls.m_ToolBoxControlWidgets->isItemEnabled(n)) { m_Controls.m_ToolBoxControlWidgets->setCurrentIndex(n); break; } } } void UltrasoundSupport::RemoveControlWidgets() { if (!m_ControlProbesWidget) { return; } //widgets do not exist... nothing to do // remove all control widgets from the tool box widget while (m_Controls.m_ToolBoxControlWidgets->count() > 0) { m_Controls.m_ToolBoxControlWidgets->removeItem(0); } // remove probes widget (which is not part of the tool box widget) m_Controls.probesWidgetContainer->removeWidget(m_ControlProbesWidget); delete m_ControlProbesWidget; m_ControlProbesWidget = 0; delete m_ControlBModeWidget; m_ControlBModeWidget = 0; delete m_ControlDopplerWidget; m_ControlDopplerWidget = 0; // delete custom widget if it is present if (m_ControlCustomWidget) { ctkPluginContext* pluginContext = mitk::PluginActivator::GetContext(); delete m_ControlCustomWidget; m_ControlCustomWidget = 0; if (m_CustomWidgetServiceReference.size() > 0) { pluginContext->ungetService(m_CustomWidgetServiceReference.at(0)); } } } void UltrasoundSupport::OnDeciveServiceEvent(const ctkServiceEvent event) { if (m_Device.IsNull() || event.getType() != us::ServiceEvent::MODIFIED) { return; } ctkServiceReference service = event.getServiceReference(); if (m_Device->GetManufacturer() != service.getProperty(QString::fromStdString(mitk::USDevice::GetPropertyKeys().US_PROPKEY_MANUFACTURER)).toString().toStdString() && m_Device->GetName() != service.getProperty(QString::fromStdString(mitk::USDevice::GetPropertyKeys().US_PROPKEY_NAME)).toString().toStdString()) { return; } if (!m_Device->GetIsActive() && m_UpdateTimer->isActive()) { StopTimers(); } if (m_CurrentDynamicRange != service.getProperty(QString::fromStdString(mitk::USDevice::GetPropertyKeys().US_PROPKEY_BMODE_DYNAMIC_RANGE)).toDouble()) { m_CurrentDynamicRange = service.getProperty(QString::fromStdString(mitk::USDevice::GetPropertyKeys().US_PROPKEY_BMODE_DYNAMIC_RANGE)).toDouble(); // update level window for the current dynamic range mitk::LevelWindow levelWindow; for (auto& Node : m_Node) { Node->GetLevelWindow(levelWindow); levelWindow.SetAuto(m_Image, true, true); levelWindow.SetWindowBounds(55, 125,true); Node->SetLevelWindow(levelWindow); } } } UltrasoundSupport::UltrasoundSupport() : m_ControlCustomWidget(0), m_ControlBModeWidget(0), m_ControlProbesWidget(0), m_ImageAlreadySetToNode(false), m_CurrentImageWidth(0), m_CurrentImageHeight(0), m_AmountOfOutputs(0), m_PARenderer(nullptr), m_PAOverlayManager(nullptr), m_USRenderer(nullptr), m_USOverlayManager(nullptr), m_PADataStorage(mitk::StandaloneDataStorage::New()), m_USDataStorage(mitk::StandaloneDataStorage::New()) { ctkPluginContext* pluginContext = mitk::PluginActivator::GetContext(); if (pluginContext) { // to be notified about service event of an USDevice pluginContext->connectServiceListener(this, "OnDeciveServiceEvent", QString::fromStdString("(" + us::ServiceConstants::OBJECTCLASS() + "=" + us_service_interface_iid() + ")")); } } UltrasoundSupport::~UltrasoundSupport() { try { StopTimers(); // Get all active devicesand deactivate them to prevent freeze std::vector devices = this->m_Controls.m_ActiveVideoDevices->GetAllServices(); for (int i = 0; i < devices.size(); i++) { mitk::USDevice::Pointer device = devices[i]; if (device.IsNotNull() && device->GetIsActive()) { device->Deactivate(); device->Disconnect(); } } StoreUISettings(); } catch (std::exception &e) { MITK_ERROR << "Exception during call of destructor! Message: " << e.what(); } delete m_PARenderWidget; delete m_USRenderWidget; } void UltrasoundSupport::StoreUISettings() { QSettings settings; settings.beginGroup(QString::fromStdString(VIEW_ID)); settings.setValue("DisplayImage", QVariant(m_Controls.m_ShowImageStream->isChecked())); settings.setValue("RunImageTimer", QVariant(m_Controls.m_RunImageTimer->isChecked())); settings.setValue("Update2DView", QVariant(m_Controls.m_Update2DView->isChecked())); settings.setValue("Update3DView", QVariant(m_Controls.m_Update3DView->isChecked())); settings.setValue("UpdateRatePipeline", QVariant(m_Controls.m_FrameRatePipeline->value())); settings.setValue("UpdateRate2d", QVariant(m_Controls.m_FrameRate2d->value())); settings.setValue("UpdateRate3d", QVariant(m_Controls.m_FrameRate3d->value())); settings.endGroup(); } void UltrasoundSupport::LoadUISettings() { QSettings settings; settings.beginGroup(QString::fromStdString(VIEW_ID)); m_Controls.m_ShowImageStream->setChecked(settings.value("DisplayImage", true).toBool()); m_Controls.m_RunImageTimer->setChecked(settings.value("RunImageTimer", true).toBool()); m_Controls.m_Update2DView->setChecked(settings.value("Update2DView", true).toBool()); m_Controls.m_Update3DView->setChecked(settings.value("Update3DView", true).toBool()); m_Controls.m_FrameRatePipeline->setValue(settings.value("UpdateRatePipeline", 50).toInt()); m_Controls.m_FrameRate2d->setValue(settings.value("UpdateRate2d", 20).toInt()); m_Controls.m_FrameRate3d->setValue(settings.value("UpdateRate3d", 5).toInt()); settings.endGroup(); } void UltrasoundSupport::StartTimers() { m_UpdateTimer->start(); if (m_Controls.m_Update2DView->isChecked()) { m_RenderingTimer2d->start(); } if (m_Controls.m_Update3DView->isChecked()) { m_RenderingTimer3d->start(); } } void UltrasoundSupport::StopTimers() { m_UpdateTimer->stop(); m_RenderingTimer2d->stop(); m_RenderingTimer3d->stop(); } void UltrasoundSupport::SetTimerIntervals(int intervalPipeline, int interval2D, int interval3D) { m_UpdateTimer->setInterval(intervalPipeline); m_RenderingTimer2d->setInterval(interval2D); m_RenderingTimer3d->setInterval(interval3D); }