diff --git a/Plugins/PluginList.cmake b/Plugins/PluginList.cmake index 53935ebd4f..733a067492 100644 --- a/Plugins/PluginList.cmake +++ b/Plugins/PluginList.cmake @@ -1,88 +1,89 @@ # 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:ON org.blueberry.ui.qt.log:ON org.blueberry.ui.qt.objectinspector:OFF 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.gui.qt.application:ON org.mitk.gui.qt.ext:OFF org.mitk.gui.qt.extapplication:OFF org.mitk.gui.qt.mitkworkbench.intro:OFF org.mitk.gui.qt.common:ON org.mitk.gui.qt.stdmultiwidgeteditor:ON org.mitk.gui.qt.mxnmultiwidgeteditor:OFF org.mitk.gui.qt.cmdlinemodules:OFF org.mitk.gui.qt.chartExample:OFF org.mitk.gui.qt.datamanager:ON org.mitk.gui.qt.datamanagerlight:OFF org.mitk.gui.qt.datastorageviewertest:OFF org.mitk.gui.qt.properties:ON + org.mitk.gui.qt.voxelvalue:ON org.mitk.gui.qt.basicimageprocessing:OFF org.mitk.gui.qt.dicombrowser:OFF org.mitk.gui.qt.dicominspector: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.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.remeshing:OFF org.mitk.gui.qt.segmentation:OFF org.mitk.gui.qt.deformableclippingplane:OFF org.mitk.gui.qt.aicpregistration:OFF org.mitk.gui.qt.renderwindowmanager:OFF org.mitk.gui.qt.semanticrelations: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.ultrasoundtrackingnavigation:OFF org.mitk.gui.qt.classificationsegmentation:OFF org.mitk.gui.qt.overlaymanager:OFF org.mitk.gui.qt.igt.app.hummelprotocolmeasurements:OFF 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.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.preprocessing.resampling:OFF org.mitk.gui.qt.radiomics:OFF org.mitk.gui.qt.cest:OFF org.mitk.gui.qt.fit.demo:OFF org.mitk.gui.qt.fit.inspector:OFF org.mitk.gui.qt.fit.genericfitting:OFF org.mitk.gui.qt.pharmacokinetics.mri:OFF org.mitk.gui.qt.pharmacokinetics.pet:OFF org.mitk.gui.qt.pharmacokinetics.simulation:OFF org.mitk.gui.qt.pharmacokinetics.curvedescriptor:OFF org.mitk.gui.qt.pharmacokinetics.concentration.mri:OFF org.mitk.gui.qt.flowapplication:OFF org.mitk.gui.qt.flow.segmentation:OFF ) diff --git a/Plugins/org.mitk.gui.qt.voxelvalue/CMakeLists.txt b/Plugins/org.mitk.gui.qt.voxelvalue/CMakeLists.txt new file mode 100644 index 0000000000..1515886837 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.voxelvalue/CMakeLists.txt @@ -0,0 +1,8 @@ +project(org_mitk_gui_qt_voxelvalue) + +mitk_create_plugin( + EXPORT_DIRECTIVE MITK_QT_VOXELVALUE + EXPORTED_INCLUDE_SUFFIXES src + MODULE_DEPENDS MitkQtWidgetsExt +) + diff --git a/Plugins/org.mitk.gui.qt.voxelvalue/documentation/doxygen/modules.dox b/Plugins/org.mitk.gui.qt.voxelvalue/documentation/doxygen/modules.dox new file mode 100644 index 0000000000..08af3f3c61 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.voxelvalue/documentation/doxygen/modules.dox @@ -0,0 +1,16 @@ +/** + \defgroup org_mitk_gui_qt_voxelvalue org.mitk.gui.qt.voxelvalue + \ingroup MITKPlugins + + \brief This is the voxel value plugin. It shows the value of the selected voxel in images. + +*/ + +/** + \defgroup org_mitk_gui_qt_voxelvalue_internal Internal + \ingroup org_mitk_gui_qt_voxelvalue + + \brief This subcategory includes the internal classes of the org.mitk.gui.qt.voxelvalue plugin. Other + plugins must not rely on these classes. They contain implementation details and their interface + may change at any time. We mean it. +*/ \ No newline at end of file diff --git a/Plugins/org.mitk.gui.qt.voxelvalue/files.cmake b/Plugins/org.mitk.gui.qt.voxelvalue/files.cmake new file mode 100644 index 0000000000..d946cec8ab --- /dev/null +++ b/Plugins/org.mitk.gui.qt.voxelvalue/files.cmake @@ -0,0 +1,30 @@ +set(INTERNAL_CPP_FILES + mitkPluginActivator.cpp + QmitkVoxelValueView.cpp +) + +set(UI_FILES +) + +set(MOC_H_FILES + src/internal/mitkPluginActivator.h + src/internal/QmitkVoxelValueView.h +) + +set(CACHED_RESOURCE_FILES + resources/icon.svg + plugin.xml +) + +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.voxelvalue/manifest_headers.cmake b/Plugins/org.mitk.gui.qt.voxelvalue/manifest_headers.cmake new file mode 100644 index 0000000000..53b63f00e5 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.voxelvalue/manifest_headers.cmake @@ -0,0 +1,5 @@ +set(Plugin-Name "MITK Voxel Value") +set(Plugin-Version "1.0.0") +set(Plugin-Vendor "German Cancer Research Center (DKFZ)") +set(Plugin-ContactAddress "https://www.mitk.org") +set(Require-Plugin org.mitk.gui.qt.common) diff --git a/Plugins/org.mitk.gui.qt.voxelvalue/plugin.xml b/Plugins/org.mitk.gui.qt.voxelvalue/plugin.xml new file mode 100644 index 0000000000..237518af0a --- /dev/null +++ b/Plugins/org.mitk.gui.qt.voxelvalue/plugin.xml @@ -0,0 +1,18 @@ + + + + + + + + Crop images to a given size + + + + + diff --git a/Plugins/org.mitk.gui.qt.voxelvalue/resources/icon.svg b/Plugins/org.mitk.gui.qt.voxelvalue/resources/icon.svg new file mode 100644 index 0000000000..95e7a66fc2 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.voxelvalue/resources/icon.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/Plugins/org.mitk.gui.qt.voxelvalue/src/internal/QmitkVoxelValueView.cpp b/Plugins/org.mitk.gui.qt.voxelvalue/src/internal/QmitkVoxelValueView.cpp new file mode 100644 index 0000000000..d47cbedb25 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.voxelvalue/src/internal/QmitkVoxelValueView.cpp @@ -0,0 +1,168 @@ +/*============================================================================ + +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 "QmitkVoxelValueView.h" + +#include +#include +#include +#include +#include + +#include + + +const std::string QmitkVoxelValueView::VIEW_ID = "org.mitk.views.qmitkvoxelvalue"; + +QmitkVoxelValueView::QmitkVoxelValueView(QObject*) + : m_Layout(nullptr) + , m_Label(nullptr) + , m_TextWidget(nullptr) +{ +} + +QmitkVoxelValueView::~QmitkVoxelValueView() +{ +} + +void QmitkVoxelValueView::CreateQtPartControl(QWidget *parent) +{ + m_Layout = new QHBoxLayout(parent); + m_Layout->setMargin(0); + + m_Label = new QLabel(parent); + m_Label->setText("Pixel value:"); + m_Layout->addWidget(m_Label); + + m_TextWidget = new QLineEdit(parent); + m_TextWidget->setReadOnly(true); + m_Layout->addWidget(m_TextWidget); + + this->m_SliceNavigationListener.RenderWindowPartActivated(this->GetRenderWindowPart()); + connect(&m_SliceNavigationListener, &QmitkSliceNavigationListener::SliceChanged, this, &QmitkVoxelValueView::OnSliceChanged); +} + +void QmitkVoxelValueView::RenderWindowPartActivated(mitk::IRenderWindowPart* renderWindowPart) +{ + this->m_SliceNavigationListener.RenderWindowPartActivated(renderWindowPart); +} + +void QmitkVoxelValueView::RenderWindowPartDeactivated(mitk::IRenderWindowPart* renderWindowPart) +{ + this->m_SliceNavigationListener.RenderWindowPartDeactivated(renderWindowPart); +} + +void QmitkVoxelValueView::OnSliceChanged() +{ + const auto position = m_SliceNavigationListener.GetCurrentSelectedPosition(); + const auto timePoint = m_SliceNavigationListener.GetCurrentSelectedTimePoint(); + + mitk::TNodePredicateDataType::Pointer isImageData = mitk::TNodePredicateDataType::New(); + mitk::DataStorage::SetOfObjects::ConstPointer nodes = GetDataStorage()->GetSubset(isImageData).GetPointer(); + if (nodes.IsNull()) + { + return; + } + + mitk::Image::Pointer image3D; + mitk::DataNode::Pointer node; + mitk::DataNode::Pointer topSourceNode; + + int component = 0; + + node = mitk::FindTopmostVisibleNode(nodes, position, timePoint, nullptr); + if (node.IsNull()) + { + return; + } + + bool isBinary(false); + node->GetBoolProperty("binary", isBinary); + if (isBinary) + { + mitk::DataStorage::SetOfObjects::ConstPointer sourcenodes = GetDataStorage()->GetSources(node, nullptr, true); + if (!sourcenodes->empty()) + { + topSourceNode = FindTopmostVisibleNode(nodes, position, timePoint, nullptr); + } + if (topSourceNode.IsNotNull()) + { + image3D = dynamic_cast(topSourceNode->GetData()); + topSourceNode->GetIntProperty("Image.Displayed Component", component); + } + else + { + image3D = dynamic_cast(node->GetData()); + node->GetIntProperty("Image.Displayed Component", component); + } + } + else + { + image3D = dynamic_cast(node->GetData()); + node->GetIntProperty("Image.Displayed Component", component); + } + + // get the position and pixel value from the image and build up voxel view text + std::string voxelText = ""; + if (image3D.IsNotNull()) + { + itk::Index<3> p; + image3D->GetGeometry()->WorldToIndex(position, p); + + auto pixelType = image3D->GetChannelDescriptor().GetPixelType().GetPixelType(); + if (pixelType == itk::IOPixelEnum::RGB || pixelType == itk::IOPixelEnum::RGBA) + { + m_Label->setText("Pixel RGB(A) value: "); + voxelText.append(ConvertCompositePixelValueToString(image3D, p)); + } + else if (pixelType == itk::IOPixelEnum::DIFFUSIONTENSOR3D || pixelType == itk::IOPixelEnum::SYMMETRICSECONDRANKTENSOR) + { + m_Label->setText("See ODF Details view. "); + } + else + { + m_Label->setText("Pixel value: "); + mitk::ScalarType pixelValue; + mitkPixelTypeMultiplex5( + mitk::FastSinglePixelAccess, + image3D->GetChannelDescriptor().GetPixelType(), + image3D, + image3D->GetVolumeData(image3D->GetTimeGeometry()->TimePointToTimeStep(timePoint)), + p, + pixelValue, + component); + + std::ostringstream stream; + stream.imbue(std::locale::classic()); + stream.precision(2); + + if (fabs(pixelValue) > 1000000 || fabs(pixelValue) < 0.01) + { + stream << std::scientific; + } + else + { + stream << std::fixed; + } + + stream << pixelValue; + + voxelText = stream.str(); + } + + m_TextWidget->setText(QString(voxelText.c_str())); + } + else + { + m_TextWidget->setText(QString("")); + } +} diff --git a/Plugins/org.mitk.gui.qt.voxelvalue/src/internal/QmitkVoxelValueView.h b/Plugins/org.mitk.gui.qt.voxelvalue/src/internal/QmitkVoxelValueView.h new file mode 100644 index 0000000000..97c0fab670 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.voxelvalue/src/internal/QmitkVoxelValueView.h @@ -0,0 +1,54 @@ +/*============================================================================ + +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 QmitkVoxelValueView_h +#define QmitkVoxelValueView_h + +#include +#include +#include + +#include +#include +#include + +class QmitkVoxelValueView : public QmitkAbstractView, public mitk::IRenderWindowPartListener +{ + + Q_OBJECT + +public: + static const std::string VIEW_ID; + + QmitkVoxelValueView(QObject *parent = nullptr); + + ~QmitkVoxelValueView() override; + + void CreateQtPartControl(QWidget *parent) override; + + void SetFocus() override { }; + +protected Q_SLOTS: + void OnSliceChanged(); + +protected: + void RenderWindowPartActivated(mitk::IRenderWindowPart* renderWindowPart) override; + void RenderWindowPartDeactivated(mitk::IRenderWindowPart* renderWindowPart) override; + +private: + QHBoxLayout* m_Layout; + QLabel* m_Label; + QLineEdit* m_TextWidget; + QmitkSliceNavigationListener m_SliceNavigationListener; +}; + +#endif // QmitkVoxelValueView_h diff --git a/Plugins/org.mitk.gui.qt.voxelvalue/src/internal/mitkPluginActivator.cpp b/Plugins/org.mitk.gui.qt.voxelvalue/src/internal/mitkPluginActivator.cpp new file mode 100644 index 0000000000..21f4f19664 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.voxelvalue/src/internal/mitkPluginActivator.cpp @@ -0,0 +1,23 @@ +/*============================================================================ + +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 "mitkPluginActivator.h" +#include "QmitkVoxelValueView.h" + +void mitk::mitkPluginActivator::start(ctkPluginContext* context) +{ + BERRY_REGISTER_EXTENSION_CLASS(QmitkVoxelValueView, context) +} + +void mitk::mitkPluginActivator::stop(ctkPluginContext*) +{ +} diff --git a/Plugins/org.mitk.gui.qt.voxelvalue/src/internal/mitkPluginActivator.h b/Plugins/org.mitk.gui.qt.voxelvalue/src/internal/mitkPluginActivator.h new file mode 100644 index 0000000000..2fb0eff4ad --- /dev/null +++ b/Plugins/org.mitk.gui.qt.voxelvalue/src/internal/mitkPluginActivator.h @@ -0,0 +1,32 @@ +/*============================================================================ + +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 org_mitk_gui_qt_voxelvalue_Activator_h +#define org_mitk_gui_qt_voxelvalue_Activator_h + +#include + +namespace mitk +{ + class mitkPluginActivator : public QObject, public ctkPluginActivator + { + Q_OBJECT + Q_PLUGIN_METADATA(IID "org_mitk_gui_qt_voxelvalue") + Q_INTERFACES(ctkPluginActivator) + + public: + void start(ctkPluginContext* context) override; + void stop(ctkPluginContext* context) override; + }; +} + +#endif