diff --git a/Applications/PluginGenerator/PluginTemplate/src/internal/QmitkTemplateView.h b/Applications/PluginGenerator/PluginTemplate/src/internal/QmitkTemplateView.h index 7009ec6c2e..9bf52d0733 100644 --- a/Applications/PluginGenerator/PluginTemplate/src/internal/QmitkTemplateView.h +++ b/Applications/PluginGenerator/PluginTemplate/src/internal/QmitkTemplateView.h @@ -1,44 +1,44 @@ $(license) #ifndef $(view-file-name)_h #define $(view-file-name)_h #include #include #include "ui_$(view-file-name)Controls.h" /** \brief $(view-class-name) \warning This class is not yet documented. Use "git blame" and ask the author to provide basic documentation. \sa QmitkAbstractView \ingroup ${plugin_target}_internal */ class $(view-class-name) : 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; protected: virtual void CreateQtPartControl(QWidget *parent) override; virtual void SetFocus() override; - /// \brief called by QmitkFunctionality when DataManager's selection has changed + /// \brief Overridden from QmitkAbstractView virtual void OnSelectionChanged(berry::IWorkbenchPart::Pointer source, const QList &nodes) override; /// \brief Called when the user clicks the GUI button void DoImageProcessing(); Ui::$(view-file-name)Controls m_Controls; }; #endif // $(view-file-name)_h diff --git a/Examples/Plugins/org.mitk.example.gui.pcaexample/src/internal/PCAExample.h b/Examples/Plugins/org.mitk.example.gui.pcaexample/src/internal/PCAExample.h index 6e0e4ecea6..684a6f3876 100644 --- a/Examples/Plugins/org.mitk.example.gui.pcaexample/src/internal/PCAExample.h +++ b/Examples/Plugins/org.mitk.example.gui.pcaexample/src/internal/PCAExample.h @@ -1,80 +1,77 @@ /*============================================================================ 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 PCAExample_h #define PCAExample_h #include #include #include "ui_PCAExampleControls.h" /** \brief PCAExample \warning This class is not yet documented. Use "git blame" and ask the author to provide basic documentation. \sa QmitkAbstractView \ingroup ${plugin_target}_internal */ class PCAExample : 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; PCAExample(); ~PCAExample() override; protected slots: /// \brief Called when the user clicks the GUI button void BtnPerfomPCAClicked(); protected: void CreateQtPartControl(QWidget *parent) override; void SetFocus() override; - /// \brief called by QmitkFunctionality when DataManager's selection has changed void OnSelectionChanged(berry::IWorkbenchPart::Pointer source, const QList &nodes) override; /** Performs a PCA on a (3D) point set. * @param input Point set to work on. * @param[out] eigenVectors Eigenvectors as computed by the PCA. Returns an empty vector * if PCA failed or did not run before. * @param[out] eigenValues Eigenvalues as computed by the PCA. Returns an empty vector * if PCA failed or did not run before. The ID inside the vector * corresponds to the ID inside the eigenvector vector. For a 3D * pointset 3 eigenvalues and -vectors will be computed. * @param[out] pointsMean Returns the mean/center of the pointset */ bool comutePCA(mitk::PointSet::Pointer input, std::vector &eigenVectors, std::vector &eigenValues, mitk::Vector3D &pointsMean); /** Adds mitk data nodes for all eigenvectors to visualize them in the multi widget. */ void showEigenvectors(std::vector eigenVectors, std::vector eigenValues, mitk::Vector3D center); mitk::DataNode::Pointer m_Axis1Node; mitk::DataNode::Pointer m_Axis2Node; mitk::DataNode::Pointer m_Axis3Node; Ui::PCAExampleControls m_Controls; }; #endif // PCAExample_h diff --git a/Modules/DICOMUI/include/QmitkDicomExternalDataWidget.h b/Modules/DICOMUI/include/QmitkDicomExternalDataWidget.h index 588628e1a4..afc501c30c 100644 --- a/Modules/DICOMUI/include/QmitkDicomExternalDataWidget.h +++ b/Modules/DICOMUI/include/QmitkDicomExternalDataWidget.h @@ -1,120 +1,119 @@ /*============================================================================ 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 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. */ ~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 slots: void OnProgressStep(const QString&); void OnProgressDetail(const QString&); 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; QString m_ProgressStep; Ui::QmitkDicomExternalDataWidgetControls *m_Controls; }; #endif // _QmitkDicomExternalDataWidget_H_INCLUDED diff --git a/Modules/DICOMUI/include/QmitkDicomLocalStorageWidget.h b/Modules/DICOMUI/include/QmitkDicomLocalStorageWidget.h index 86d2cedc3e..b5da4acd91 100644 --- a/Modules/DICOMUI/include/QmitkDicomLocalStorageWidget.h +++ b/Modules/DICOMUI/include/QmitkDicomLocalStorageWidget.h @@ -1,117 +1,115 @@ /*============================================================================ 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 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. */ ~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 _t1 containing dicom UIDs properties. */ void SignalDicomToDataManager(QHash _t1); /// \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/MatchPointRegistrationUI/Qmitk/QmitkRegistrationManipulationWidget.h b/Modules/MatchPointRegistrationUI/Qmitk/QmitkRegistrationManipulationWidget.h index 11747ef3ee..e90dca3216 100644 --- a/Modules/MatchPointRegistrationUI/Qmitk/QmitkRegistrationManipulationWidget.h +++ b/Modules/MatchPointRegistrationUI/Qmitk/QmitkRegistrationManipulationWidget.h @@ -1,129 +1,128 @@ /*============================================================================ 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 __Q_MITK_REGISTRATION_MANIPULATION_WIDGET_H #define __Q_MITK_REGISTRATION_MANIPULATION_WIDGET_H #include #include "mapRegistration.h" #include "mapContinuous.h" #include #include #include #include "ui_QmitkRegistrationManipulationWidget.h" /*! \brief QmitkMatchPointRegistrationManipulator \warning This class is not yet documented. Use "git blame" and ask the author to provide basic documentation. -\sa QmitkFunctionality \ingroup ${plugin_target}_internal */ class MITKMATCHPOINTREGISTRATIONUI_EXPORT QmitkRegistrationManipulationWidget : public QWidget, private Ui::QmitkRegistrationManipulationWidget { Q_OBJECT public: QmitkRegistrationManipulationWidget(QWidget *parent = nullptr); ~QmitkRegistrationManipulationWidget() override; /** Type of transform that can be provided as preceding transform.*/ typedef map::core::Registration<3, 3> MAPRegistrationType; /** Initializing/reset widget with identity transform.*/ void Initialize(); /** Initializing/reset widget with a preceding registration.*/ void Initialize(MAPRegistrationType* precedingRegistration); /** Initializing/reset widget with an translation transform deduced by the to passed reference points.*/ void Initialize(const mitk::Point3D& movingReference, const mitk::Point3D& targetReference); /**This function offers access to a registration instance that represents the internal state of the registration currently manipulated by the widget. It can be used for example to update the visualization.*/ map::core::RegistrationBase* GetInterimRegistration() const; /**This function generates a new registration instance that resembles the state when the method was called. Ownership of the return goes to the caller.*/ map::core::RegistrationBase::Pointer GenerateRegistration()const ; public Q_SLOTS: void SetCenterOfRotation(const mitk::Point3D& center); /** Sets the internal m_CenterOfRotationIsRelativeToTarget. see below.*/ void SetCenterOfRotationIsRelativeToTarget(bool targetRelative); signals: void RegistrationChanged(map::core::RegistrationBase *registration); protected slots: void OnRotXChanged(double); void OnRotYChanged(double); void OnRotZChanged(double); void OnTransXChanged(double); void OnTransYChanged(double); void OnTransZChanged(double); void OnRotXSlideChanged(int); void OnRotYSlideChanged(int); void OnRotZSlideChanged(int); void OnTransXSlideChanged(int); void OnTransYSlideChanged(int); void OnTransZSlideChanged(int); private: /** Initializes/resets the transforms.*/ void ResetTransforms(); /** Initialize the sub widgets according to the internal state of the transforms.*/ void InitControls(); /** * Updates the widgets that manipulate the transform according to the transform.*/ void UpdateTransformWidgets(); /** * Updates the transform according to the widgets that manipulate the transform.*/ void UpdateTransform(bool updateRotation = false); void ConfigureTransformCenter(); MAPRegistrationType::Pointer m_PreRegistration; using TransformType = itk::Euler3DTransform<::map::core::continuous::ScalarType>; TransformType::Pointer m_InverseCurrentTransform; TransformType::Pointer m_DirectCurrentTransform; MAPRegistrationType::Pointer m_CurrentRegistration; mitk::Point3D m_CenterOfRotation; /** This flag indicates if the center of rotation is specified relative to the target (true; thus must be updated when the inverse transform is changed) or relative to the moving (false; thus must not be updated).*/ bool m_CenterOfRotationIsRelativeToTarget; bool m_internalUpdate; }; #endif // MatchPoint_h diff --git a/Modules/OpenCVVideoSupport/mitkUndistortCameraImage.h b/Modules/OpenCVVideoSupport/mitkUndistortCameraImage.h index b2ffc3aa30..1f9509b827 100644 --- a/Modules/OpenCVVideoSupport/mitkUndistortCameraImage.h +++ b/Modules/OpenCVVideoSupport/mitkUndistortCameraImage.h @@ -1,126 +1,125 @@ /*============================================================================ 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 __mitkUndistortCameraImage_h #define __mitkUndistortCameraImage_h #include "mitkCommon.h" #include #include "itkObject.h" #include "mitkPoint.h" #include "opencv2/core.hpp" #include "opencv2/imgproc.hpp" /*! \brief UndistortCameraImage This class is used to undistort camera images. Before any undistortion the class has to be initialized using the functions: SetFocalLength(),SetPrinzipalPoint() and SetCameraDistortion(). After this you can either use UndistortPixel() to undistort a single pixel's coordinates or UndistortImage() to undistort an OpenCV image. A faster version of UndistortImage() is UndistortImageFast(), however, it has to be initialized once with SetUndistortImageFastInfo() instead of the Set... methods before use. -\sa QmitkFunctionality \ingroup Functionalities */ namespace mitk { class MITKOPENCVVIDEOSUPPORT_EXPORT UndistortCameraImage : public itk::Object { public: mitkClassMacroItkParent(UndistortCameraImage,itk::Object); itkFactorylessNewMacro(Self); itkCloneMacro(Self); /// Initialization /// /* * Set the camera's intrinsic focal length */ void SetFocalLength(float fc_x, float fc_y) { m_fcX = fc_x; m_fcY = fc_y; } /* * Set the camera's intrinsic principal point */ void SetPrincipalPoint(float cc_x, float cc_y) { m_ccX = cc_x; m_ccY = cc_y; } /* * Set the camera's intrinsic distortion parameters */ void SetCameraDistortion(float kc1, float kc2, float kc3, float kc4) { m_distortionMatrixData[0] = kc1; m_distortionMatrixData[1] = kc2; m_distortionMatrixData[2] = kc3; m_distortionMatrixData[3] = kc4; } /* * Pre-Calculates matrices for the later use of UndistortImageFast() */ void InitRemapUndistortion(int sizeX, int sizeY); /// USAGE /// /* * Undistort a single pixel, returns undistorted pixel */ mitk::Point2D UndistortPixel(const mitk::Point2D& src); /* * Complete undistortion of an OpenCV image, including all calculations */ void UndistortImage(IplImage* src, IplImage* dst); /* * Complete undistortion of an OpenCV image, using pre-calculated matrices from SetUndistortImageFastInfo() * The use of only a source parameter will cause the source to be overwritten. * NOTE: Using the Fast undistortion methods does not require a initialization via the Set... methods. */ void UndistortImageFast( IplImage * src, IplImage* dst = nullptr ); void SetUndistortImageFastInfo(float in_dF1, float in_dF2, float in_dPrincipalX, float in_dPrincipalY, float in_Dist[4], float ImageSizeX, float ImageSizeY); UndistortCameraImage(); ~UndistortCameraImage() override; protected: // principal point and focal length parameters float m_ccX, m_ccY, m_fcX, m_fcY; // undistortion parameters float m_distortionMatrixData[4]; // intrinsic camera parameters float m_intrinsicMatrixData[9]; // precalculated matrices for fast image undistortion with UndistortImageFast() CvMat * m_mapX, * m_mapY; // intrinsic and undistortion camera matrices CvMat m_intrinsicMatrix, m_distortionMatrix; // temp image IplImage * m_tempImage; CvMat *m_DistortionCoeffs; CvMat *m_CameraMatrix; }; } #endif diff --git a/Plugins/PluginList.cmake b/Plugins/PluginList.cmake index ac518360a0..793c9f1210 100644 --- a/Plugins/PluginList.cmake +++ b/Plugins/PluginList.cmake @@ -1,90 +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.common.legacy: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.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.gui.qt.multilabelsegmentation: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.cest/src/internal/QmitkCESTStatisticsView.h b/Plugins/org.mitk.gui.qt.cest/src/internal/QmitkCESTStatisticsView.h index 9954b55c84..444a12b7a0 100644 --- a/Plugins/org.mitk.gui.qt.cest/src/internal/QmitkCESTStatisticsView.h +++ b/Plugins/org.mitk.gui.qt.cest/src/internal/QmitkCESTStatisticsView.h @@ -1,133 +1,130 @@ /*============================================================================ 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 QmitkCESTStatisticsView_h #define QmitkCESTStatisticsView_h #include #include #include #include "ui_QmitkCESTStatisticsViewControls.h" #include #include #include /** \brief QmitkCESTStatisticsView \warning Basic statistics view for CEST data. \sa QmitkAbstractView \ingroup ${plugin_target}_internal */ class QmitkCESTStatisticsView : public QmitkAbstractView, public mitk::IRenderWindowPartListener { - // 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; /*! \brief default constructor */ QmitkCESTStatisticsView(QObject *parent = nullptr, const char *name = nullptr); /*! \brief default destructor */ ~QmitkCESTStatisticsView() override; protected slots: /// \brief Called when the user clicks the GUI button void OnThreeDimToFourDimPushButtonClicked(); /// \brief takes care of processing the computed data void OnThreadedStatisticsCalculationEnds(); /// \brief Toggle whether or not the plot uses a fixed x range void OnFixedRangeCheckBoxToggled(bool state); /// \brief Adapt axis scale when manual ranges are set void OnFixedRangeDoubleSpinBoxChanged(); /// \brief What to do if the crosshair moves void OnSliceChanged(); protected: void CreateQtPartControl(QWidget *parent) override; void SetFocus() override; void RenderWindowPartActivated(mitk::IRenderWindowPart* renderWindowPart) override; void RenderWindowPartDeactivated(mitk::IRenderWindowPart* renderWindowPart) override; - /// \brief called by QmitkFunctionality when DataManager's selection has changed void OnSelectionChanged( berry::IWorkbenchPart::Pointer source, const QList& nodes ) override; /// parse string and set data vector returns true if succesfull bool SetZSpectrum(mitk::StringProperty* zSpectrumProperty); /** Checks whether the currently set data appears reasonable */ bool DataSanityCheck(); /** Fills the plot based on a point set * * This will only use the first timestep */ template void PlotPointSet(itk::Image* image); /** Deletes all data */ void Clear(); /** Remove MZeros * * Will remove the data for the M0 images from the given input */ void RemoveMZeros(QmitkPlotWidget::DataVector& xValues, QmitkPlotWidget::DataVector& yValues); void RemoveMZeros(QmitkPlotWidget::DataVector& xValues, QmitkPlotWidget::DataVector& yValues, QmitkPlotWidget::DataVector& stdDevs); /** Copies the first timestep of a segmentation to all others */ template void CopyTimesteps(itk::Image* image); Ui::QmitkCESTStatisticsViewControls m_Controls; QmitkImageStatisticsCalculationJob* m_CalculatorJob; QmitkPlotWidget::DataVector m_zSpectrum; mitk::Image::Pointer m_ZImage; mitk::Image::Pointer m_MaskImage; mitk::PlanarFigure::Pointer m_MaskPlanarFigure; mitk::PointSet::Pointer m_PointSet; mitk::PointSet::Pointer m_CrosshairPointSet; QmitkSliceNavigationListener m_SliceChangeListener; itk::TimeStamp m_selectedNodeTime; itk::TimeStamp m_currentPositionTime; /** @brief currently valid selected position in the inspector*/ mitk::Point3D m_currentSelectedPosition; mitk::TimePointType m_currentSelectedTimePoint; }; #endif // QmitkCESTStatisticsView_h diff --git a/Plugins/org.mitk.gui.qt.classificationsegmentation/src/internal/ClassificationRegionGrow.h b/Plugins/org.mitk.gui.qt.classificationsegmentation/src/internal/ClassificationRegionGrow.h index 3de437f3f4..04987f3a46 100644 --- a/Plugins/org.mitk.gui.qt.classificationsegmentation/src/internal/ClassificationRegionGrow.h +++ b/Plugins/org.mitk.gui.qt.classificationsegmentation/src/internal/ClassificationRegionGrow.h @@ -1,102 +1,99 @@ /*============================================================================ 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 ClassificationRegionGrow_h #define ClassificationRegionGrow_h #include #include #include "ui_ClassificationRegionGrowControls.h" #include #include #include #include #include #include #include #include /** \brief ClassificationRegionGrow \warning This class is not yet documented. Use "git blame" and ask the author to provide basic documentation. \sa QmitkAbstractView \ingroup ${plugin_target}_internal */ class ctkSliderWidget; class ClassificationRegionGrow : 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; bool m_CalculateFeatures; std::vector m_FeatureImageVector; std::vector m_ResultImageVector; bool m_BlockManualSegmentation; QFutureWatcher> m_ManualSegmentationFutureWatcher; bool m_BlockPostProcessing; QFutureWatcher> m_PostProcessingFutureWatcher; public slots: /// \brief Called when the user clicks the GUI button void DoAutomSegmentation(); void AddInputField(); void RemoveItemFromLabelList(); void OnFeatureSettingsChanged(); void OnInitializeSession(const mitk::DataNode*); protected: std::vector > m_SegmentedLocations; std::vector > m_SegmentedOrganLocations; typedef float MeasurementType; typedef itk::Statistics::Histogram< MeasurementType, itk::Statistics::DenseFrequencyContainer2 > HistogramType; void CreateQtPartControl(QWidget *parent) override; void SetFocus() override; mitk::DataNode::Pointer AddAsDataNode(const mitk::BaseData::Pointer & data_, const std::string & name ); void ProcessFeatureImages(const mitk::Image::Pointer & raw_image); void TrainClassifier(const mitk::Image::Pointer & raw_image, const mitk::Image::Pointer & mask_image); void PredictSegmentation(const mitk::Image::Pointer & raw_image, const mitk::Image::Pointer & mask_image); - /// \brief called by QmitkFunctionality when DataManager's selection has changed void OnSelectionChanged( berry::IWorkbenchPart::Pointer source, const QList& nodes ) override; Ui::ClassificationRegionGrowControls m_Controls; mitk::VigraRandomForestClassifier::Pointer m_Classifier; }; #endif // ClassificationRegionGrow_h diff --git a/Plugins/org.mitk.gui.qt.classificationsegmentation/src/internal/ClassificationSegmentation.h b/Plugins/org.mitk.gui.qt.classificationsegmentation/src/internal/ClassificationSegmentation.h index f13eb8f9ef..5894d95171 100644 --- a/Plugins/org.mitk.gui.qt.classificationsegmentation/src/internal/ClassificationSegmentation.h +++ b/Plugins/org.mitk.gui.qt.classificationsegmentation/src/internal/ClassificationSegmentation.h @@ -1,137 +1,134 @@ /*============================================================================ 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 ClassificationSegmentation_h #define ClassificationSegmentation_h #include #include #include "ui_ClassificationSegmentationControls.h" #include #include #include #include #include #include #include #include #include #include #include #include #include /** \brief ClassificationSegmentation \warning This class is not yet documented. Use "git blame" and ask the author to provide basic documentation. \sa QmitkAbstractView \ingroup ${plugin_target}_internal */ class ctkSliderWidget; class ClassificationSegmentation : 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; std::vector m_PointSetList; bool m_CalculateFeatures; std::vector m_FeatureImageVector; std::vector m_ResultImageVector; std::vector m_PostProcessingImageVector; bool m_BlockManualSegmentation; QFutureWatcher> m_ManualSegmentationFutureWatcher; bool m_BlockPostProcessing; QFutureWatcher> m_PostProcessingFutureWatcher; protected slots: /// \brief Called when the user clicks the GUI button void DoAutomSegmentation(); void DoSavePointsAsMask(); void OnButtonCSFToggle(bool); void OnButtonLESToggle(bool); void OnButtonBRAToggle(bool); void OnButtonNoInteractionToggle(bool); void OnAddForestToDataManager(); void ManualSegmentationTrigger(); std::vector ManualSegmentationCallback(); void ManualSegmentationFinished(); void PostProcessingTrigger(); std::vector PostProcessingCallback(); void PostProcessingFinished(); void OnFeatureSettingsChanged(); void OnPostProcessingSettingsChanged(); void OnInitializeSession(const mitk::DataNode*); protected: typedef float MeasurementType; typedef itk::Statistics::Histogram< MeasurementType, itk::Statistics::DenseFrequencyContainer2 > HistogramType; // void RenderWindowPartActivated(mitk::IRenderWindowPart* renderWindowPart); // void RenderWindowPartDeactivated(mitk::IRenderWindowPart* renderWindowPart); void CreateQtPartControl(QWidget *parent) override; void SetFocus() override; mitk::DataNode::Pointer AddAsDataNode(const mitk::BaseData::Pointer & data_, const std::string & name ); void SampleClassMaskByPointSet(const mitk::Image::Pointer & ref_img, mitk::PointSet::Pointer & pointset, mitk::Image::Pointer & outimage); void ProcessFeatureImages(const mitk::Image::Pointer & raw_image, const mitk::Image::Pointer & mask_image); - /// \brief called by QmitkFunctionality when DataManager's selection has changed void OnSelectionChanged( berry::IWorkbenchPart::Pointer source, const QList& nodes ) override; mitk::Image::Pointer CreateClassMaskByPointsetList(std::map a_args); Ui::ClassificationSegmentationControls m_Controls; // Feature settings ctkSliderWidget * m_GaussSlider; ctkSliderWidget * m_HessianSlider; ctkSliderWidget * m_STInnerSlider; ctkSliderWidget * m_STOuterSlider; ctkSliderWidget * m_GaussCSFSlider; ctkSliderWidget * m_GaussLESSlider; ctkSliderWidget * m_GaussBRASlider; ctkSliderWidget * m_WeightCSFSlider; ctkSliderWidget * m_WeightLESSlider; ctkSliderWidget * m_WeightBRASlider; mitk::PointSetDataInteractor::Pointer m_PointSetDataInteractor; mitk::VigraRandomForestClassifier::Pointer m_TempClassifier; }; #endif // ClassificationSegmentation_h diff --git a/Plugins/org.mitk.gui.qt.common.legacy/CMakeLists.txt b/Plugins/org.mitk.gui.qt.common.legacy/CMakeLists.txt deleted file mode 100755 index 50b2016664..0000000000 --- a/Plugins/org.mitk.gui.qt.common.legacy/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -project(org_mitk_gui_qt_common_legacy) - -mitk_create_plugin( - EXPORT_DIRECTIVE MITK_QT_COMMON_LEGACY - EXPORTED_INCLUDE_SUFFIXES src - MODULE_DEPENDS MitkQtWidgets - ) diff --git a/Plugins/org.mitk.gui.qt.common.legacy/documentation/doxygen/modules.dox b/Plugins/org.mitk.gui.qt.common.legacy/documentation/doxygen/modules.dox deleted file mode 100755 index bd669c5afb..0000000000 --- a/Plugins/org.mitk.gui.qt.common.legacy/documentation/doxygen/modules.dox +++ /dev/null @@ -1,19 +0,0 @@ -/** - \defgroup org_mitk_gui_qt_common_legacy org.mitk.gui.qt.common.legacy - \ingroup MITKPlugins - - \brief Provides legacy classes and functionality common for MITK plug-ins. - - \deprecated This plug-in is deprecated. Old plug-ins having a dependency on it should - migrate to the org_mitk_gui_qt_common Plug-in using https://www.mitk.org/wiki/Views_Without_Multi_Widget - -*/ - -/** - \defgroup org_mitk_gui_qt_common_legacy_internal Internal - \ingroup org_mitk_gui_qt_common_legacy - - \brief This subcategory includes the internal classes of the org.mitk.gui.qt.common.legacy plugin. Other - plugins must not rely on these classes. They contain implementation details and their interface - may change at any time. We mean it. -*/ diff --git a/Plugins/org.mitk.gui.qt.common.legacy/files.cmake b/Plugins/org.mitk.gui.qt.common.legacy/files.cmake deleted file mode 100755 index 331c6b063f..0000000000 --- a/Plugins/org.mitk.gui.qt.common.legacy/files.cmake +++ /dev/null @@ -1,33 +0,0 @@ -set(SRC_CPP_FILES - QmitkFunctionality.cpp - QmitkFunctionality2.cpp - QmitkFunctionalityCoordinator.cpp -) - -set(INTERNAL_CPP_FILES - QmitkCommonLegacyActivator.cpp - QmitkFunctionalityUtil.cpp -) - -set(MOC_H_FILES - src/internal/QmitkCommonLegacyActivator.h -) - -set(UI_FILES -) - -set(CACHED_RESOURCE_FILES -) - -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.common.legacy/manifest_headers.cmake b/Plugins/org.mitk.gui.qt.common.legacy/manifest_headers.cmake deleted file mode 100644 index 525768d803..0000000000 --- a/Plugins/org.mitk.gui.qt.common.legacy/manifest_headers.cmake +++ /dev/null @@ -1,6 +0,0 @@ -set(Plugin-Name "Legacy Plug-in for QmitkStdMultiWidgetEditor") -set(Plugin-Version "1.0.0") -set(Plugin-Vendor "German Cancer Research Center (DKFZ)") -set(Plugin-ContactAddress "http://www.mitk.org") -set(Require-Plugin org.mitk.gui.qt.stdmultiwidgeteditor) - diff --git a/Plugins/org.mitk.gui.qt.common.legacy/src/QmitkFunctionality.cpp b/Plugins/org.mitk.gui.qt.common.legacy/src/QmitkFunctionality.cpp deleted file mode 100644 index a18f8f3b53..0000000000 --- a/Plugins/org.mitk.gui.qt.common.legacy/src/QmitkFunctionality.cpp +++ /dev/null @@ -1,373 +0,0 @@ -/*============================================================================ - -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 "QmitkFunctionality.h" -#include "internal/QmitkFunctionalityUtil.h" -#include "internal/QmitkCommonLegacyActivator.h" - -// other includes -#include - -// mitk Includes -#include -#include - -// berry Includes -#include -#include -#include -#include - -// Qmitk Includes -#include - -// Qt Includes -#include -#include -#include -#include - -QmitkFunctionality::QmitkFunctionality() - : m_Parent(nullptr) - , m_Active(false) - , m_Visible(false) - , m_SelectionProvider(nullptr) - , m_DataStorageServiceTracker(QmitkCommonLegacyActivator::GetContext()) - , m_HandlesMultipleDataStorages(false) - , m_InDataStorageChanged(false) -{ - m_DataStorageServiceTracker.open(); -} - -void QmitkFunctionality::SetHandleMultipleDataStorages(bool multiple) -{ - m_HandlesMultipleDataStorages = multiple; -} - -bool QmitkFunctionality::HandlesMultipleDataStorages() const -{ - return m_HandlesMultipleDataStorages; -} - -mitk::DataStorage::Pointer -QmitkFunctionality::GetDataStorage() const -{ - mitk::IDataStorageService* service = m_DataStorageServiceTracker.getService(); - - if (service != nullptr) - { - if(m_HandlesMultipleDataStorages) - return service->GetActiveDataStorage()->GetDataStorage(); - else - return service->GetDefaultDataStorage()->GetDataStorage(); - } - - return nullptr; -} - -mitk::DataStorage::Pointer QmitkFunctionality::GetDefaultDataStorage() const -{ - mitk::IDataStorageService* service = m_DataStorageServiceTracker.getService(); - - if (service != nullptr) - { - return service->GetDefaultDataStorage()->GetDataStorage(); - } - - return nullptr; -} - -mitk::IDataStorageReference::Pointer QmitkFunctionality::GetDataStorageReference() const -{ - mitk::IDataStorageService* dsService = m_DataStorageServiceTracker.getService(); - - if (dsService != nullptr) - { - return dsService->GetDataStorage(); - } - - return mitk::IDataStorageReference::Pointer(nullptr); -} - -void QmitkFunctionality::CreatePartControl(QWidget* parent) -{ - - // scrollArea - QScrollArea* scrollArea = new QScrollArea; - //QVBoxLayout* scrollAreaLayout = new QVBoxLayout(scrollArea); - scrollArea->setFrameShadow(QFrame::Plain); - scrollArea->setFrameShape(QFrame::NoFrame); - scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded); - scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); - - // m_Parent - m_Parent = new QWidget; - //m_Parent->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding)); - this->CreateQtPartControl(m_Parent); - - //scrollAreaLayout->addWidget(m_Parent); - //scrollArea->setLayout(scrollAreaLayout); - - // set the widget now - scrollArea->setWidgetResizable(true); - scrollArea->setWidget(m_Parent); - - // add the scroll area to the real parent (the view tabbar) - QWidget* parentQWidget = static_cast(parent); - QVBoxLayout* parentLayout = new QVBoxLayout(parentQWidget); - parentLayout->setMargin(0); - parentLayout->setSpacing(0); - parentLayout->addWidget(scrollArea); - - // finally set the layout containing the scroll area to the parent widget (= show it) - parentQWidget->setLayout(parentLayout); - - this->AfterCreateQtPartControl(); -} - -void QmitkFunctionality::AfterCreateQtPartControl() -{ - // REGISTER DATASTORAGE LISTENER - this->GetDefaultDataStorage()->AddNodeEvent.AddListener( mitk::MessageDelegate1 - ( this, &QmitkFunctionality::NodeAddedProxy ) ); - this->GetDefaultDataStorage()->ChangedNodeEvent.AddListener( mitk::MessageDelegate1 - ( this, &QmitkFunctionality::NodeChangedProxy ) ); - this->GetDefaultDataStorage()->RemoveNodeEvent.AddListener( mitk::MessageDelegate1 - ( this, &QmitkFunctionality::NodeRemovedProxy ) ); - - // REGISTER PREFERENCES LISTENER - berry::IBerryPreferences::Pointer prefs = this->GetPreferences().Cast(); - if(prefs.IsNotNull()) - prefs->OnChanged.AddListener(berry::MessageDelegate1(this, &QmitkFunctionality::OnPreferencesChanged)); - - // REGISTER FOR WORKBENCH SELECTION EVENTS - m_BlueBerrySelectionListener.reset(new berry::SelectionChangedAdapter( - this, - &QmitkFunctionality::BlueBerrySelectionChanged) - ); - this->GetSite()->GetWorkbenchWindow()->GetSelectionService()->AddPostSelectionListener( - /*"org.mitk.views.datamanager",*/ m_BlueBerrySelectionListener.data()); - - // REGISTER A SELECTION PROVIDER - QmitkFunctionalitySelectionProvider::Pointer _SelectionProvider( - new QmitkFunctionalitySelectionProvider(this)); - m_SelectionProvider = _SelectionProvider.GetPointer(); - this->GetSite()->SetSelectionProvider(berry::ISelectionProvider::Pointer(m_SelectionProvider)); - - // EMULATE INITIAL SELECTION EVENTS - - // by default a multi widget is always available - this->MultiWidgetAvailable(*this->GetActiveMultiWidget()); - - // send datamanager selection - this->OnSelectionChanged(this->GetDataManagerSelection()); - - // send preferences changed event - this->OnPreferencesChanged(this->GetPreferences().Cast().GetPointer()); -} - -void QmitkFunctionality::ClosePart() -{ - -} - -void QmitkFunctionality::ClosePartProxy() -{ - this->GetDefaultDataStorage()->AddNodeEvent.RemoveListener( mitk::MessageDelegate1 - ( this, &QmitkFunctionality::NodeAddedProxy ) ); - this->GetDefaultDataStorage()->RemoveNodeEvent.RemoveListener( mitk::MessageDelegate1 - ( this, &QmitkFunctionality::NodeRemovedProxy) ); - this->GetDefaultDataStorage()->ChangedNodeEvent.RemoveListener( mitk::MessageDelegate1 - ( this, &QmitkFunctionality::NodeChangedProxy ) ); - - berry::IBerryPreferences::Pointer prefs = this->GetPreferences().Cast(); - if(prefs.IsNotNull()) - { - prefs->OnChanged.RemoveListener(berry::MessageDelegate1(this, &QmitkFunctionality::OnPreferencesChanged)); - // flush the preferences here (disabled, everyone should flush them by themselves at the right moment) - // prefs->Flush(); - } - - // REMOVE SELECTION PROVIDER - this->GetSite()->SetSelectionProvider(berry::ISelectionProvider::Pointer(nullptr)); - - berry::ISelectionService* s = GetSite()->GetWorkbenchWindow()->GetSelectionService(); - if(s) - { - s->RemovePostSelectionListener(m_BlueBerrySelectionListener.data()); - } - - this->ClosePart(); -} - -QmitkFunctionality::~QmitkFunctionality() -{ - this->Register(); - this->ClosePartProxy(); - - this->UnRegister(false); - - m_DataStorageServiceTracker.close(); -} - -void QmitkFunctionality::OnPreferencesChanged( const berry::IBerryPreferences* ) -{ -} - -void QmitkFunctionality::BlueBerrySelectionChanged(const berry::IWorkbenchPart::Pointer& sourcepart, - const berry::ISelection::ConstPointer& selection) -{ - if(sourcepart.IsNull() || sourcepart->GetSite()->GetId() != "org.mitk.views.datamanager") - return; - - mitk::DataNodeSelection::ConstPointer _DataNodeSelection - = selection.Cast(); - this->OnSelectionChanged(this->DataNodeSelectionToVector(_DataNodeSelection)); -} - -bool QmitkFunctionality::IsVisible() const -{ - return m_Visible; -} - -void QmitkFunctionality::SetFocus() -{ -} - -void QmitkFunctionality::Activated() -{ -} - -void QmitkFunctionality::Deactivated() -{ -} - -void QmitkFunctionality::MultiWidgetAvailable( QmitkAbstractMultiWidget& /*multiWidget*/ ) -{ -} -void QmitkFunctionality::MultiWidgetNotAvailable() -{ -} - -void QmitkFunctionality::DataStorageChanged() -{ - -} - -QmitkAbstractMultiWidget* QmitkFunctionality::GetActiveMultiWidget( bool reCreateWidget ) -{ - QmitkAbstractMultiWidget* activeMultiWidget = nullptr; - - berry::IEditorPart::Pointer editor = - this->GetSite()->GetPage()->GetActiveEditor(); - - if (reCreateWidget || editor.Cast().IsNull()) - { - mitk::DataStorageEditorInput::Pointer editorInput( - new mitk::DataStorageEditorInput( this->GetDataStorageReference() )); - // open a new multi-widget editor, but do not give it the focus - berry::IEditorPart::Pointer editor = this->GetSite()->GetPage()->OpenEditor(editorInput, QmitkStdMultiWidgetEditor::EDITOR_ID, false, berry::IWorkbenchPage::MATCH_ID); - activeMultiWidget = editor.Cast()->GetMultiWidget(); - } - else if (editor.Cast().IsNotNull()) - { - activeMultiWidget = editor.Cast()->GetMultiWidget(); - } - - return activeMultiWidget; -} - -void QmitkFunctionality::HandleException( const char* str, QWidget* parent, bool showDialog ) const -{ - //itkGenericOutputMacro( << "Exception caught: " << str ); - MITK_ERROR << str; - if ( showDialog ) - { - QMessageBox::critical ( parent, "Exception caught!", str ); - } -} - -void QmitkFunctionality::HandleException( std::exception& e, QWidget* parent, bool showDialog ) const -{ - HandleException( e.what(), parent, showDialog ); -} - -void QmitkFunctionality::MultiWidgetClosed( QmitkAbstractMultiWidget& /*multiWidget*/ ) -{ - -} - -void QmitkFunctionality::WaitCursorOn() -{ - QApplication::setOverrideCursor( QCursor(Qt::WaitCursor) ); -} - -void QmitkFunctionality::BusyCursorOn() -{ - QApplication::setOverrideCursor( QCursor(Qt::BusyCursor) ); -} - -void QmitkFunctionality::WaitCursorOff() -{ - this->RestoreOverrideCursor(); -} - -void QmitkFunctionality::BusyCursorOff() -{ - this->RestoreOverrideCursor(); -} - -void QmitkFunctionality::RestoreOverrideCursor() -{ - QApplication::restoreOverrideCursor(); -} - -berry::IPreferences::Pointer QmitkFunctionality::GetPreferences() const -{ - berry::IPreferencesService* prefService = berry::Platform::GetPreferencesService(); - // const_cast workaround for bad programming: const uncorrectness this->GetViewSite() should be const - QString id = "/" + (const_cast(this))->GetViewSite()->GetId(); - return prefService != nullptr ? prefService->GetSystemPreferences()->Node(id): berry::IPreferences::Pointer(nullptr); -} - -void QmitkFunctionality::Visible() -{ - -} - -void QmitkFunctionality::Hidden() -{ - -} - -bool QmitkFunctionality::IsExclusiveFunctionality() const -{ - return true; -} - -void QmitkFunctionality::SetVisible( bool visible ) -{ - m_Visible = visible; -} - -void QmitkFunctionality::SetActivated( bool activated ) -{ - m_Active = activated; -} - -bool QmitkFunctionality::IsActivated() const -{ - return m_Active; -} - diff --git a/Plugins/org.mitk.gui.qt.common.legacy/src/QmitkFunctionality.h b/Plugins/org.mitk.gui.qt.common.legacy/src/QmitkFunctionality.h deleted file mode 100755 index fae0b394ce..0000000000 --- a/Plugins/org.mitk.gui.qt.common.legacy/src/QmitkFunctionality.h +++ /dev/null @@ -1,397 +0,0 @@ -/*============================================================================ - -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 QMITKFUNCTIONALITY_H_ -#define QMITKFUNCTIONALITY_H_ - -//# blueberry stuff -#include -#include -#include - -#include - -//# mitk stuff -#include -#include "mitkDataNodeSelection.h" -#include -#include -#include -#include - -// CTK Includes -#include - - -//# forward declarations - -namespace mitk { - class DataNode; - struct IDataStorageService; -} - -namespace berry { - struct IBerryPreferences; -} - -class QmitkFunctionalitySelectionProvider; - -/// -/// \ingroup org_mitk_gui_qt_common_legacy -/// -/// \class QmitkFunctionality -/// -/// \brief The base class of all MITK related blueberry views (~ in the old version of MITK, this was called "Functionality") -/// -/// QmitkFunctionality provides several convenience methods that eases the introduction of a new view: -/// -///
    -///
  1. Access to the DataStorage (~ the shared data repository) -///
  2. Access to the MultiWidget -///
  3. Access to and update notification for the functionality/view preferences -///
  4. Access to and update notification for the current DataNode selection / to DataNode selection events send through the SelectionService -///
  5. Methods to send DataNode selections through the SelectionService -///
  6. Some events for unproblematic inter-View communication (e.g. when to add/remove interactors) -///
  7. Some minor important convenience methods (like changing the mouse cursor/exception handling) -///
-/// -/// Please use the Activated/Deactivated method to add/remove interactors, disabling multiwidget crosshair or anything which may -/// "affect" other functionalities. For further reading please have a look at QmitkFunctionality::IsExclusiveFunctionality(). -/// -class MITK_QT_COMMON_LEGACY QmitkFunctionality : public berry::QtViewPart -{ - -//# public virtual methods which can be overwritten -public: - /// - /// Creates smartpointer typedefs - /// - berryObjectMacro(QmitkFunctionality); - /// - /// Nothing to do in the standard ctor. Initiliaze your GUI in CreateQtPartControl(QWidget*) - /// \see berry::QtViewPart::CreateQtPartControl(QWidget*) - /// - QmitkFunctionality(); - /// - /// Disconnects all standard event listeners - /// - ~QmitkFunctionality() override; - /// - /// Called, when the WorkbenchPart gets closed - /// by the user directly or by closing the whole - /// app (e.g. for removing event listeners) - /// - virtual void ClosePart(); - /// - /// Called when the selection in the workbench changed - /// - virtual void OnSelectionChanged(std::vector /*nodes*/); - /// - /// Called when the preferences object of this view changed. - /// \see GetPreferences() - /// - virtual void OnPreferencesChanged(const berry::IBerryPreferences*); - /// - /// Make this view manage multiple DataStorage. If set to true GetDataStorage() - /// will return the currently active DataStorage (and not the default one). - /// \see GetDataStorage() - /// - void SetHandleMultipleDataStorages(bool multiple); - /// - /// \return true if this view handles multiple DataStorages, false otherwise - /// - bool HandlesMultipleDataStorages() const; - /// - /// Called when a MultiWidget is available. Should not be used anymore, see GetActiveMultiWidget() - /// \see GetActiveMultiWidget() - /// - virtual void MultiWidgetAvailable(QmitkAbstractMultiWidget& multiWidget); - /// - /// Called when a MultiWidget is available. Should not be used anymore, see GetActiveMultiWidget() - /// \see GetActiveMultiWidget() - /// - virtual void MultiWidgetClosed(QmitkAbstractMultiWidget& multiWidget); - /// - /// Called when no MultiWidget is available anymore. Should not be used anymore, see GetActiveMultiWidget() - /// \see GetActiveMultiWidget() - /// - virtual void MultiWidgetNotAvailable(); - /// - /// Only called when IsExclusiveFunctionality() returns true. - /// \see IsExclusiveFunctionality() - /// - virtual void Activated(); - /// - /// \return true if this view is currently activated, false otherwise - /// - bool IsActivated() const; - /// - /// Only called when IsExclusiveFunctionality() returns true. - /// \see IsExclusiveFunctionality() - /// - virtual void Deactivated(); - /// - /// Some functionalities need to add special interactors, removes the crosshair from the multiwidget, etc. - /// In this case the functionality has to tidy up when changing to another functionality - /// which also wants to change the "default configuration". In the old Qt3-based - /// version of MITK, two functionalities could never be opened at the same time so that the - /// methods Activated() and Deactivated() were the right place for the functionalitites to - /// add/remove their interactors, etc. This is still true for the new MITK Workbench, - /// but as there can be several functionalities visible at the same time, the behaviour concerning - /// when Activated() and Deactivated() are called has changed: - /// - /// 1. Activated() and Deactivated() are only called if IsExclusiveFunctionality() returns true - /// - /// 2. If only one standalone functionality is or becomes visible, Activated() will be called on that functionality - /// - /// 3. If two or more standalone functionalities are visible, - /// Activated() will be called on the functionality that receives focus, Deactivated() will be called - /// on the one that looses focus, gets hidden or closed - /// - /// - /// As a consequence of 1. if you overwrite IsExclusiveFunctionality() and let it return false, you - /// signalize the MITK Workbench that this functionality does nothing to the "default configuration" - /// and can easily be visible while other functionalities are also visible. - /// - /// By default the method returns true. - /// - /// \return true if this functionality is meant to work as a standalone view, false otherwise - /// - virtual bool IsExclusiveFunctionality() const; - /// - /// Informs other parts of the workbench that node is selected via the blueberry selection service. - /// - void FireNodeSelected(mitk::DataNode* node); - /// - /// Informs other parts of the workbench that the nodes are selected via the blueberry selection service. - /// - void FireNodesSelected(std::vector nodes); - /// - /// Called when this functionality becomes visible ( no matter what IsExclusiveFunctionality() returns ) - /// - virtual void Visible(); - /// - /// \return true if this view is currently visible, false otherwise - /// - bool IsVisible() const; - /// - /// Called when this functionality is hidden ( no matter what IsExclusiveFunctionality() returns ) - /// - virtual void Hidden(); -//# protected virtual methods which can be overwritten -protected: - /// - /// Called when a DataStorage Add event was thrown. May be reimplemented - /// by deriving classes. - /// - virtual void NodeAdded(const mitk::DataNode* node); - /// - /// Called when a DataStorage Changed event was thrown. May be reimplemented - /// by deriving classes. - /// - virtual void NodeChanged(const mitk::DataNode* /*node*/); - /// - /// Called when a DataStorage Remove event was thrown. May be reimplemented - /// by deriving classes. - /// - virtual void NodeRemoved(const mitk::DataNode* node); - /// - /// Called when a DataStorage add *or* remove *or* change event was thrown. May be reimplemented - /// by deriving classes. - /// - virtual void DataStorageChanged(); - /// - /// \return the selection of the currently active part of the workbench or an empty vector - /// if nothing is selected - /// - std::vector GetCurrentSelection() const; - /// - /// Returns the current selection made in the datamanager bundle or an empty vector - /// if nothing`s selected or if the bundle does not exist - /// - std::vector GetDataManagerSelection() const; - /// - /// Returns the Preferences object for this Functionality. - /// Important: When refering to this preferences, e.g. in a PreferencePage: The ID - /// for this preferences object is "/", e.g. "/org.mitk.views.datamanager" - /// - berry::IPreferences::Pointer GetPreferences() const; - /// - /// Returns the default or the currently active DataStorage if m_HandlesMultipleDataStorages - /// is set to true - /// \see SetHandleMultipleDataStorages(bool) - /// \see HandlesMultipleDataStorages() - /// - mitk::DataStorage::Pointer GetDataStorage() const; - /// - /// \return always returns the default DataStorage - /// - mitk::DataStorage::Pointer GetDefaultDataStorage() const; - - mitk::IDataStorageReference::Pointer GetDataStorageReference() const; - - /// - /// Returns the default and active MultiWidget. - /// \param reCreateWidget a boolean flag to en-/disable the attempt to re-create the StdWidget - /// If there is not MultiWidget yet a new one is - /// created in this method when called with default parameter! - /// - QmitkAbstractMultiWidget* GetActiveMultiWidget( bool reCreateWidget = true); - /// - /// Outputs an error message to the console and displays a message box containing - /// the exception description. - /// \param e the exception which should be handled - /// \param parent - /// \param showDialog controls, whether additionally a message box should be - /// displayed to inform the user that something went wrong - /// - void HandleException( std::exception& e, QWidget* parent = nullptr, bool showDialog = true ) const; - /// - /// Calls HandleException ( std::exception&, QWidget*, bool ) internally - /// \see HandleException ( std::exception&, QWidget*, bool ) - /// - void HandleException( const char* str, QWidget* parent = nullptr, bool showDialog = true ) const; - /// - /// Convenient method to set and reset a wait cursor ("hourglass") - /// - void WaitCursorOn(); - /// - /// Convenient method to restore the standard cursor - /// - void WaitCursorOff(); - /// - /// Convenient method to set and reset a busy cursor - /// - void BusyCursorOn(); - /// - /// Convenient method to restore the standard cursor - /// - void BusyCursorOff(); - /// - /// Convenient method to restore the standard cursor - /// - void RestoreOverrideCursor(); - -//# other public methods which should not be overwritten -public: - /// - /// Creates a scroll area for this view and calls CreateQtPartControl then - /// - void CreatePartControl(QWidget* parent) override; - /// - /// Called when this view receives the focus. Same as Activated() - /// \see Activated() - /// - void SetFocus() override; - /// - /// Called when a DataStorage Add Event was thrown. Sets - /// m_InDataStorageChanged to true and calls NodeAdded afterwards. - /// \see m_InDataStorageChanged - /// - void NodeAddedProxy(const mitk::DataNode* node); - /// - /// Called when a DataStorage remove event was thrown. Sets - /// m_InDataStorageChanged to true and calls NodeRemoved afterwards. - /// \see m_InDataStorageChanged - /// - void NodeRemovedProxy(const mitk::DataNode* node); - /// - /// Called when a DataStorage changed event was thrown. Sets - /// m_InDataStorageChanged to true and calls NodeChanged afterwards. - /// \see m_InDataStorageChanged - /// - void NodeChangedProxy(const mitk::DataNode* node); - /// - /// Toggles the visible flag m_Visible - /// - void SetVisible(bool visible); - /// - /// Toggles the activated flag m_Activated - /// - void SetActivated(bool activated); - /// - /// Called, when the WorkbenchPart gets closed for removing event listeners - /// Internally this method calls ClosePart after it removed the listeners registered - /// by QmitkFunctionality. By having this proxy method the user does not have to - /// call QmitkFunctionality::ClosePart() when overwriting ClosePart() - /// - void ClosePartProxy(); - -//# other protected methods which should not be overwritten (or which are deprecated) -protected: - /// - /// Called immediately after CreateQtPartControl(). - /// Here standard event listeners for a QmitkFunctionality are registered - /// - void AfterCreateQtPartControl(); - /// - /// code to activate the last visible functionality - /// - void ActivateLastVisibleFunctionality(); - /// - /// reactions to selection events from data manager (and potential other senders) - /// - void BlueBerrySelectionChanged(const berry::IWorkbenchPart::Pointer& sourcepart, const berry::ISelection::ConstPointer& selection); - /// - /// Converts a mitk::DataNodeSelection to a std::vector (possibly empty - /// - std::vector DataNodeSelectionToVector(mitk::DataNodeSelection::ConstPointer currentSelection) const; - //# protected fields -protected: - /// - /// helper stuff to observe BlueBerry selections - /// - friend struct berry::SelectionChangedAdapter; - /// - /// Saves the parent of this view (this is the scrollarea created in CreatePartControl(QWidget*) - /// \see CreatePartControl(QWidget*) - /// - QWidget* m_Parent; - /// - /// Saves if this view is the currently active one. - /// - bool m_Active; - /// - /// Saves if this view is visible - /// - bool m_Visible; - - //# private fields: - -private: - /// - /// Holds the current selection (selection made by this Functionality !!!) - /// - QmitkFunctionalitySelectionProvider* m_SelectionProvider; - /// - /// object to observe BlueBerry selections - /// - QScopedPointer m_BlueBerrySelectionListener; - - ctkServiceTracker m_DataStorageServiceTracker; - - - /// - /// Saves if this view handles multiple datastorages - /// - bool m_HandlesMultipleDataStorages; - /// - /// Saves if this class is currently working on DataStorage changes. - /// This is a protector variable to avoid recursive calls on event listener functions. - bool m_InDataStorageChanged; - /// - /// saves all visible functionalities - /// - std::set m_VisibleFunctionalities; -}; - -#endif /*QMITKFUNCTIONALITY_H_*/ diff --git a/Plugins/org.mitk.gui.qt.common.legacy/src/QmitkFunctionality2.cpp b/Plugins/org.mitk.gui.qt.common.legacy/src/QmitkFunctionality2.cpp deleted file mode 100644 index cc16019d2f..0000000000 --- a/Plugins/org.mitk.gui.qt.common.legacy/src/QmitkFunctionality2.cpp +++ /dev/null @@ -1,138 +0,0 @@ -/*============================================================================ - -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 "QmitkFunctionality.h" -#include "internal/QmitkFunctionalityUtil.h" - -#include -#include - -#include - -std::vector QmitkFunctionality::GetCurrentSelection() const -{ - berry::ISelection::ConstPointer selection( this->GetSite()->GetWorkbenchWindow()->GetSelectionService()->GetSelection()); - // buffer for the data manager selection - mitk::DataNodeSelection::ConstPointer currentSelection = selection.Cast(); - return this->DataNodeSelectionToVector(currentSelection); -} - -std::vector QmitkFunctionality::GetDataManagerSelection() const -{ - berry::ISelection::ConstPointer selection( this->GetSite()->GetWorkbenchWindow()->GetSelectionService()->GetSelection("org.mitk.views.datamanager")); - // buffer for the data manager selection - mitk::DataNodeSelection::ConstPointer currentSelection = selection.Cast(); - return this->DataNodeSelectionToVector(currentSelection); -} - -void QmitkFunctionality::OnSelectionChanged(std::vector /*nodes*/) -{ -} - -std::vector QmitkFunctionality::DataNodeSelectionToVector(mitk::DataNodeSelection::ConstPointer currentSelection) const -{ - - std::vector selectedNodes; - if(currentSelection.IsNull()) - return selectedNodes; - - mitk::DataNodeObject* _DataNodeObject = nullptr; - mitk::DataNode* _DataNode = nullptr; - - for(mitk::DataNodeSelection::iterator it = currentSelection->Begin(); - it != currentSelection->End(); ++it) - { - _DataNodeObject = dynamic_cast((*it).GetPointer()); - if(_DataNodeObject) - { - _DataNode = _DataNodeObject->GetDataNode(); - if(_DataNode) - selectedNodes.push_back(_DataNode); - } - } - - return selectedNodes; -} - -void QmitkFunctionality::NodeAddedProxy( const mitk::DataNode* node ) -{ - // garantuee no recursions when a new node event is thrown in NodeAdded() - if(!m_InDataStorageChanged) - { - m_InDataStorageChanged = true; - this->NodeAdded(node); - this->DataStorageChanged(); - m_InDataStorageChanged = false; - } - -} - -void QmitkFunctionality::NodeAdded( const mitk::DataNode* /*node*/ ) -{ - -} - -void QmitkFunctionality::NodeRemovedProxy( const mitk::DataNode* node ) -{ - // garantuee no recursions when a new node event is thrown in NodeAdded() - if(!m_InDataStorageChanged) - { - m_InDataStorageChanged = true; - this->NodeRemoved(node); - this->DataStorageChanged(); - m_InDataStorageChanged = false; - } -} - -void QmitkFunctionality::NodeRemoved( const mitk::DataNode* /*node*/ ) -{ - -} - -void QmitkFunctionality::NodeChanged( const mitk::DataNode* /*node*/ ) -{ - -} - -void QmitkFunctionality::NodeChangedProxy( const mitk::DataNode* node ) -{ - // garantuee no recursions when a new node event is thrown in NodeAdded() - if(!m_InDataStorageChanged) - { - m_InDataStorageChanged = true; - this->NodeChanged(node); - this->DataStorageChanged(); - m_InDataStorageChanged = false; - } -} - -void QmitkFunctionality::FireNodeSelected( mitk::DataNode* node ) -{ - std::vector nodes; - nodes.push_back(node); - this->FireNodesSelected(nodes); -} - -void QmitkFunctionality::FireNodesSelected( std::vector nodes ) -{ - if( !m_SelectionProvider ) - return; - - std::vector nodesSmartPointers; - for (std::vector::iterator it = nodes.begin() - ; it != nodes.end(); it++) - { - nodesSmartPointers.push_back( *it ); - } - m_SelectionProvider->FireNodesSelected(nodesSmartPointers); - -} diff --git a/Plugins/org.mitk.gui.qt.common.legacy/src/QmitkFunctionalityCoordinator.cpp b/Plugins/org.mitk.gui.qt.common.legacy/src/QmitkFunctionalityCoordinator.cpp deleted file mode 100644 index 8caec50f33..0000000000 --- a/Plugins/org.mitk.gui.qt.common.legacy/src/QmitkFunctionalityCoordinator.cpp +++ /dev/null @@ -1,216 +0,0 @@ -/*============================================================================ - -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 "QmitkFunctionalityCoordinator.h" -#include "QmitkFunctionality.h" -#include -#include -#include - -#include - -QmitkFunctionalityCoordinator::QmitkFunctionalityCoordinator() - : m_StandaloneFuntionality(nullptr) -{ -} - -void QmitkFunctionalityCoordinator::Start() -{ - berry::PlatformUI::GetWorkbench()->AddWindowListener(this); - QList wnds(berry::PlatformUI::GetWorkbench()->GetWorkbenchWindows()); - for (auto i = wnds.begin(); i != wnds.end(); ++i) - { - (*i)->GetPartService()->AddPartListener(this); - } -} - -void QmitkFunctionalityCoordinator::Stop() -{ - if (!berry::PlatformUI::IsWorkbenchRunning()) return; - - berry::PlatformUI::GetWorkbench()->RemoveWindowListener(this); - QList wnds(berry::PlatformUI::GetWorkbench()->GetWorkbenchWindows()); - for (auto i = wnds.begin(); i != wnds.end(); ++i) - { - (*i)->GetPartService()->RemovePartListener(this); - } -} - -QmitkFunctionalityCoordinator::~QmitkFunctionalityCoordinator() -{ -} - -berry::IPartListener::Events::Types QmitkFunctionalityCoordinator::GetPartEventTypes() const -{ - return berry::IPartListener::Events::ACTIVATED | berry::IPartListener::Events::DEACTIVATED - | berry::IPartListener::Events::CLOSED | berry::IPartListener::Events::HIDDEN - | berry::IPartListener::Events::VISIBLE | berry::IPartListener::Events::OPENED; -} - -void QmitkFunctionalityCoordinator::PartActivated( const berry::IWorkbenchPartReference::Pointer& partRef ) -{ - // change the active standalone functionality - this->ActivateStandaloneFunctionality(partRef.GetPointer()); -} - -void QmitkFunctionalityCoordinator::PartDeactivated( const berry::IWorkbenchPartReference::Pointer& /*partRef*/ ) -{ - // nothing to do here: see PartActivated() -} - -void QmitkFunctionalityCoordinator::PartOpened( const berry::IWorkbenchPartReference::Pointer& partRef ) -{ - // check for multiwidget and inform views that it is available now - if ( partRef->GetId() == QmitkStdMultiWidgetEditor::EDITOR_ID ) - { - for (std::set::iterator it = m_Functionalities.begin() - ; it != m_Functionalities.end(); it++) - { - (*it)->MultiWidgetAvailable(*(partRef - ->GetPart(false).Cast()->GetMultiWidget())); - } - } - else - { - // Check for QmitkFunctionality - QmitkFunctionality::Pointer _QmitkFunctionality = partRef->GetPart(false).Cast(); - if(_QmitkFunctionality.IsNotNull()) - { - m_Functionalities.insert(_QmitkFunctionality.GetPointer()); // save as opened functionality - } - } -} - -void QmitkFunctionalityCoordinator::PartClosed( const berry::IWorkbenchPartReference::Pointer& partRef ) -{ - // check for multiwidget and inform views that it not available any more - if ( partRef->GetId() == QmitkStdMultiWidgetEditor::EDITOR_ID ) - { - - QmitkStdMultiWidgetEditor::Pointer stdMultiWidgetEditor = partRef->GetPart(false).Cast(); - for (std::set::iterator it = m_Functionalities.begin() - ; it != m_Functionalities.end(); it++) - { - (*it)->MultiWidgetClosed(*(stdMultiWidgetEditor->GetMultiWidget())); - (*it)->MultiWidgetNotAvailable(); // deprecated call, provided for consistence - } - } - else - { - // check for functionality - QmitkFunctionality::Pointer _QmitkFunctionality = partRef->GetPart(false).Cast(); - if(_QmitkFunctionality.IsNotNull()) - { - // deactivate on close ( the standalone functionality may still be activated ) - this->DeactivateStandaloneFunctionality(partRef.GetPointer(), nullptr); - - // and set pointer to 0 - if(m_StandaloneFuntionality == partRef.GetPointer()) - m_StandaloneFuntionality = nullptr; - - m_Functionalities.erase(_QmitkFunctionality.GetPointer()); // remove as opened functionality - - // call PartClosed on the QmitkFunctionality - _QmitkFunctionality->ClosePartProxy(); - //m_VisibleStandaloneFunctionalities.erase(_QmitkFunctionality.GetPointer()); // remove if necessary (should be done before in PartHidden() - } - } -} - -void QmitkFunctionalityCoordinator::PartHidden( const berry::IWorkbenchPartReference::Pointer& partRef ) -{ - // Check for QmitkFunctionality - QmitkFunctionality::Pointer _QmitkFunctionality = partRef->GetPart(false).Cast(); - if(_QmitkFunctionality != 0) - { - _QmitkFunctionality->SetVisible(false); - _QmitkFunctionality->Hidden(); - - // tracking of Visible Standalone Functionalities - m_VisibleStandaloneFunctionalities.erase(partRef.GetPointer()); - - // activate Functionality if just one Standalone Functionality is visible - if( m_VisibleStandaloneFunctionalities.size() == 1 ) - this->ActivateStandaloneFunctionality( *m_VisibleStandaloneFunctionalities.begin() ); - } -} - -void QmitkFunctionalityCoordinator::PartVisible( const berry::IWorkbenchPartReference::Pointer& partRef ) -{ - // Check for QmitkFunctionality - QmitkFunctionality::Pointer _QmitkFunctionality = partRef->GetPart(false).Cast(); - if(_QmitkFunctionality.IsNotNull()) - { - _QmitkFunctionality->SetVisible(true); - _QmitkFunctionality->Visible(); - - // tracking of Visible Standalone Functionalities - if( _QmitkFunctionality->IsExclusiveFunctionality() ) - { - m_VisibleStandaloneFunctionalities.insert(partRef.GetPointer()); - - // activate Functionality if just one Standalone Functionality is visible - if( m_VisibleStandaloneFunctionalities.size() == 1 ) - this->ActivateStandaloneFunctionality( *m_VisibleStandaloneFunctionalities.begin() ); - } - } -} - -void QmitkFunctionalityCoordinator::ActivateStandaloneFunctionality( berry::IWorkbenchPartReference* partRef ) -{ - QmitkFunctionality* functionality = dynamic_cast(partRef->GetPart(false).GetPointer()); - if( functionality && !functionality->IsActivated() && functionality->IsExclusiveFunctionality() ) - { - MITK_INFO << "**** Activating legacy standalone functionality"; - // deactivate old one if necessary - this->DeactivateStandaloneFunctionality(m_StandaloneFuntionality, partRef); - m_StandaloneFuntionality = partRef; - - MITK_INFO << "setting active flag"; - // call activated on this functionality - functionality->SetActivated(true); - functionality->Activated(); - } - else if (dynamic_cast(partRef->GetPart(false).GetPointer()) && - m_StandaloneFuntionality != partRef) - { - this->DeactivateStandaloneFunctionality(m_StandaloneFuntionality, partRef); - m_StandaloneFuntionality = partRef; - } -} - -void QmitkFunctionalityCoordinator::DeactivateStandaloneFunctionality(berry::IWorkbenchPartReference* partRef, - berry::IWorkbenchPartReference* newRef) -{ - if (partRef == nullptr) return; - - QmitkFunctionality* functionality = dynamic_cast(partRef->GetPart(false).GetPointer()); - if(functionality && functionality->IsActivated()) - { - functionality->SetActivated(false); - functionality->Deactivated(); - } - else if (mitk::IZombieViewPart* zombie = dynamic_cast(partRef->GetPart(false).GetPointer())) - { - zombie->ActivatedZombieView(berry::IWorkbenchPartReference::Pointer(newRef)); - } -} - -void QmitkFunctionalityCoordinator::WindowClosed(const berry::IWorkbenchWindow::Pointer& /*window*/ ) -{ - -} - -void QmitkFunctionalityCoordinator::WindowOpened(const berry::IWorkbenchWindow::Pointer& window ) -{ - window->GetPartService()->AddPartListener(this); -} diff --git a/Plugins/org.mitk.gui.qt.common.legacy/src/QmitkFunctionalityCoordinator.h b/Plugins/org.mitk.gui.qt.common.legacy/src/QmitkFunctionalityCoordinator.h deleted file mode 100644 index c8b1075222..0000000000 --- a/Plugins/org.mitk.gui.qt.common.legacy/src/QmitkFunctionalityCoordinator.h +++ /dev/null @@ -1,117 +0,0 @@ -/*============================================================================ - -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 QmitkFunctionalityCoordinator_h -#define QmitkFunctionalityCoordinator_h - -#include -#include -#include - -#include -#include - -class QmitkFunctionality; - -/// -/// \ingroup org_mitk_gui_qt_common_legacy -/// -/// A class which coordinates active QmitkFunctionalities, e.g. calling activated and hidden on them. -/// -class MITK_QT_COMMON_LEGACY QmitkFunctionalityCoordinator : virtual public berry::IPartListener, virtual public berry::IWindowListener -{ -public: - - QmitkFunctionalityCoordinator(); - - ~QmitkFunctionalityCoordinator() override; - - /// - /// Add listener - /// - void Start(); - - /// - /// Remove listener - /// - void Stop(); - - //#IPartListener methods (these methods internally call Activated() or other similar methods) - /// - /// \see IPartListener::GetPartEventTypes() - /// - berry::IPartListener::Events::Types GetPartEventTypes() const override; - /// - /// \see IPartListener::PartActivated() - /// - void PartActivated (const berry::IWorkbenchPartReference::Pointer& partRef) override; - /// - /// \see IPartListener::PartDeactivated() - /// - void PartDeactivated(const berry::IWorkbenchPartReference::Pointer& /*partRef*/) override; - /// - /// \see IPartListener::PartOpened() - /// - void PartOpened(const berry::IWorkbenchPartReference::Pointer& partRef) override; - /// - /// \see IPartListener::PartClosed() - /// - void PartClosed (const berry::IWorkbenchPartReference::Pointer& partRef) override; - /// - /// \see IPartListener::PartHidden() - /// - void PartHidden (const berry::IWorkbenchPartReference::Pointer& partRef) override; - /// - /// \see IPartListener::PartVisible() - /// - void PartVisible (const berry::IWorkbenchPartReference::Pointer& partRef) override; - - /** - * Notifies this listener that the given window has been closed. - */ - void WindowClosed(const berry::IWorkbenchWindow::Pointer& window) override; - - /** - * Notifies this listener that the given window has been opened. - */ - void WindowOpened(const berry::IWorkbenchWindow::Pointer& /*window*/) override; - -protected: - /// - /// Activates the standalone functionality - /// - void ActivateStandaloneFunctionality(berry::IWorkbenchPartReference *partRef); - /// - /// Deactivates the standalone functionality - /// - void DeactivateStandaloneFunctionality(berry::IWorkbenchPartReference *functionality, berry::IWorkbenchPartReference *newRef); - /// - /// Saves the workbench window - /// - berry::IWorkbenchWindow::WeakPtr m_Window; - /// - /// Saves the last part that added interactors - /// - berry::IWorkbenchPartReference* m_StandaloneFuntionality; - - /// - /// Saves all opened QmitkFclassunctionalities - /// - std::set m_Functionalities; - /// - /// Saves all visible QmitkFunctionalities - /// - std::set m_VisibleStandaloneFunctionalities; -}; - -#endif // QmitkFunctionalityCoordinator_h diff --git a/Plugins/org.mitk.gui.qt.common.legacy/src/internal/QmitkCommonLegacyActivator.cpp b/Plugins/org.mitk.gui.qt.common.legacy/src/internal/QmitkCommonLegacyActivator.cpp deleted file mode 100644 index 38dd4642cd..0000000000 --- a/Plugins/org.mitk.gui.qt.common.legacy/src/internal/QmitkCommonLegacyActivator.cpp +++ /dev/null @@ -1,47 +0,0 @@ -/*============================================================================ - -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 "QmitkCommonLegacyActivator.h" -#include -#include - -ctkPluginContext* QmitkCommonLegacyActivator::m_Context = nullptr; - -void -QmitkCommonLegacyActivator::start(ctkPluginContext* context) -{ - Q_UNUSED(context) - - if(berry::PlatformUI::IsWorkbenchRunning()) - { - m_FunctionalityCoordinator.Start(); - m_Context = context; - } - else - { - MITK_ERROR << "BlueBerry Workbench not running!"; - } -} - -void -QmitkCommonLegacyActivator::stop(ctkPluginContext* context) -{ - Q_UNUSED(context) - - m_FunctionalityCoordinator.Stop(); - m_Context = nullptr; -} - -ctkPluginContext*QmitkCommonLegacyActivator::GetContext() -{ - return m_Context; -} diff --git a/Plugins/org.mitk.gui.qt.common.legacy/src/internal/QmitkCommonLegacyActivator.h b/Plugins/org.mitk.gui.qt.common.legacy/src/internal/QmitkCommonLegacyActivator.h deleted file mode 100644 index 49407c0bc3..0000000000 --- a/Plugins/org.mitk.gui.qt.common.legacy/src/internal/QmitkCommonLegacyActivator.h +++ /dev/null @@ -1,49 +0,0 @@ -/*============================================================================ - -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 QMITKCOMMONLEGACYACTIVATOR_H_ -#define QMITKCOMMONLEGACYACTIVATOR_H_ - -#include - -#include "QmitkFunctionalityCoordinator.h" - -/** - * \ingroup org_mitk_gui_qt_common_legacy_internal - */ -class QmitkCommonLegacyActivator : public QObject, public ctkPluginActivator -{ - Q_OBJECT - Q_PLUGIN_METADATA(IID "org_mitk_gui_qt_common_legacy") - Q_INTERFACES(ctkPluginActivator) - -public: - - /** - * Sets default StateMachine to EventMapper. - */ - void start(ctkPluginContext* context) override; - void stop(ctkPluginContext* context) override; - - static ctkPluginContext* GetContext(); - -private: - - QmitkFunctionalityCoordinator m_FunctionalityCoordinator; - - static ctkPluginContext* m_Context; - -}; - -#endif /* QMITKCOMMONLEGACYACTIVATOR_H_ */ - diff --git a/Plugins/org.mitk.gui.qt.common.legacy/src/internal/QmitkFunctionalityUtil.cpp b/Plugins/org.mitk.gui.qt.common.legacy/src/internal/QmitkFunctionalityUtil.cpp deleted file mode 100644 index dcff198c77..0000000000 --- a/Plugins/org.mitk.gui.qt.common.legacy/src/internal/QmitkFunctionalityUtil.cpp +++ /dev/null @@ -1,58 +0,0 @@ -/*============================================================================ - -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 "QmitkFunctionalityUtil.h" - -#include "../QmitkFunctionality.h" - -QmitkFunctionalitySelectionProvider::QmitkFunctionalitySelectionProvider( QmitkFunctionality* _Functionality ) -: m_Functionality(_Functionality) -{ - -} - -QmitkFunctionalitySelectionProvider::~QmitkFunctionalitySelectionProvider() -{ - m_Functionality = nullptr; -} - -void QmitkFunctionalitySelectionProvider::AddSelectionChangedListener( berry::ISelectionChangedListener* listener ) -{ - m_SelectionEvents.AddListener(listener); -} - - -berry::ISelection::ConstPointer QmitkFunctionalitySelectionProvider::GetSelection() const -{ - return m_CurrentSelection; -} - -void QmitkFunctionalitySelectionProvider::RemoveSelectionChangedListener( berry::ISelectionChangedListener* listener ) -{ - m_SelectionEvents.RemoveListener(listener); -} - -void QmitkFunctionalitySelectionProvider::SetSelection(const berry::ISelection::ConstPointer& selection ) -{ - m_CurrentSelection = selection.Cast(); -} - -void QmitkFunctionalitySelectionProvider::FireNodesSelected(const std::vector& nodes ) -{ - mitk::DataNodeSelection::Pointer sel(new mitk::DataNodeSelection(nodes)); - m_CurrentSelection = sel; - berry::SelectionChangedEvent::Pointer event(new berry::SelectionChangedEvent(berry::ISelectionProvider::Pointer(this) - , m_CurrentSelection)); - m_SelectionEvents.selectionChanged(event); - -} diff --git a/Plugins/org.mitk.gui.qt.common.legacy/src/internal/QmitkFunctionalityUtil.h b/Plugins/org.mitk.gui.qt.common.legacy/src/internal/QmitkFunctionalityUtil.h deleted file mode 100644 index 14c7521f6f..0000000000 --- a/Plugins/org.mitk.gui.qt.common.legacy/src/internal/QmitkFunctionalityUtil.h +++ /dev/null @@ -1,79 +0,0 @@ -/*============================================================================ - -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 QMITKFUNCTIONALITYUTIL_H -#define QMITKFUNCTIONALITYUTIL_H - -#include - -class QmitkFunctionality; - -#include -#include - -/// -/// Internal class for selection providing -/// -class QmitkFunctionalitySelectionProvider: public berry::ISelectionProvider -{ - -public: - - /// - /// Creates smartpointer typedefs - /// - berryObjectMacro(QmitkFunctionalitySelectionProvider); - - QmitkFunctionalitySelectionProvider(QmitkFunctionality* _Functionality); - - ~QmitkFunctionalitySelectionProvider() override; - - //# ISelectionProvider methods - /// - /// \see ISelectionProvider::AddSelectionChangedListener() - /// - void AddSelectionChangedListener(berry::ISelectionChangedListener* listener) override; - /// - /// \see ISelectionProvider::GetSelection() - /// - berry::ISelection::ConstPointer GetSelection() const override; - /// - /// \see ISelectionProvider::RemoveSelectionChangedListener() - /// - void RemoveSelectionChangedListener(berry::ISelectionChangedListener* listener) override; - /// - /// \see ISelectionProvider::SetSelection() - /// - void SetSelection(const berry::ISelection::ConstPointer& selection) override; - /// - /// Sends the nodes as selected to the workbench - /// - void FireNodesSelected(const std::vector& nodes ); - -protected: - - /// - /// the functionality parent - /// - QmitkFunctionality* m_Functionality; - /// - /// Holds the current selection (selection made by m_Functionality !!!) - /// - mitk::DataNodeSelection::ConstPointer m_CurrentSelection; - /// - /// The selection events other parts can listen too - /// - berry::ISelectionChangedListener::Events m_SelectionEvents; -}; - -#endif // QMITKFUNCTIONALITYUTIL_H diff --git a/Plugins/org.mitk.gui.qt.dosevisualization/src/internal/RTDoseVisualizer.h b/Plugins/org.mitk.gui.qt.dosevisualization/src/internal/RTDoseVisualizer.h index 4570098249..2181adbeb5 100644 --- a/Plugins/org.mitk.gui.qt.dosevisualization/src/internal/RTDoseVisualizer.h +++ b/Plugins/org.mitk.gui.qt.dosevisualization/src/internal/RTDoseVisualizer.h @@ -1,172 +1,169 @@ /*============================================================================ 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 RTDoseVisualizer_h #define RTDoseVisualizer_h #include #include #include "ui_RTDoseVisualizerControls.h" #include #include #include #include "mitkDoseVisPreferenceHelper.h" // Shader #include #include #include #include #include /*forward declarations*/ class QmitkIsoDoseLevelSetModel; class QmitkDoseColorDelegate; class QmitkDoseValueDelegate; class QmitkDoseVisualStyleDelegate; class ctkEvent; /** \brief RTDoseVisualizer \warning This class is not yet documented. Use "git blame" and ask the author to provide basic documentation. \sa QmitkAbstractView \ingroup ${plugin_target}_internal */ class RTDoseVisualizer : 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: RTDoseVisualizer(); ~RTDoseVisualizer() override; static const std::string VIEW_ID; static const std::string ISO_LINE_NODE_NAME; void OnSliceChanged(itk::Object *sender, const itk::EventObject &e); protected slots: void OnAddFreeValueClicked(); void OnRemoveFreeValueClicked(); void OnUsePrescribedDoseClicked(); void OnDataChangedInIsoLevelSetView(); void OnAbsDoseToggled(bool); void OnGlobalVisColorWashToggled(bool); void OnGlobalVisIsoLineToggled(bool); void OnShowContextMenuIsoSet(const QPoint&); void OnCurrentPresetChanged(const QString&); void OnReferenceDoseChanged(double); void OnHandleCTKEventReferenceDoseChanged(const ctkEvent& event); void OnHandleCTKEventPresetsChanged(const ctkEvent& event); void OnHandleCTKEventGlobalVisChanged(const ctkEvent& event); void ActualizeFreeIsoLine(); protected: void CreateQtPartControl(QWidget *parent) override; void SetFocus() override; - /// \brief called by QmitkFunctionality when DataManager's selection has changed void OnSelectionChanged( berry::IWorkbenchPart::Pointer source, const QList& nodes ) override; void PrepareDoseNode(mitk::DataNode* doseNode) const; /** Update the transfer funtion property for the color wash*/ void UpdateColorWashTransferFunction(); /** Method updates the list widget according to the current free iso values.*/ void UpdateFreeIsoValues(); /** Update the members according to the currently selected node */ void UpdateBySelectedNode(); /** Update the member widgets according to the information stored in the application preferences*/ void UpdateByPreferences(); /**helper function that iterates throug all data nodes and sets there iso level set property according to the selected preset. @TODO: should be moved outside the class, to be available for other classes at well.*/ void ActualizeIsoLevelsForAllDoseDataNodes(); /**helper function that iterates throug all data nodes and sets there reference dose value according to the preference. @TODO: should be moved outside the class, to be available for other classes at well.*/ void ActualizeReferenceDoseForAllDoseDataNodes(); /**helper function that iterates through all data nodes and sets there dose display style (relative/absolute) according to the preference. @TODO: should be moved outside the class, to be available for other classes at well.*/ void ActualizeDisplayStyleForAllDoseDataNodes(); void NodeRemoved(const mitk::DataNode* node) override; void NodeChanged(const mitk::DataNode *node) override; Ui::RTDoseVisualizerControls m_Controls; mitk::DataNode::Pointer m_selectedNode; unsigned int m_freeIsoValuesCount; mitk::PresetMapType m_Presets; std::string m_selectedPresetName; /** Prescribed Dose of the selected data.*/ mitk::DoseValueAbs m_PrescribedDose_Data; QmitkIsoDoseLevelSetModel* m_LevelSetModel; QmitkDoseColorDelegate* m_DoseColorDelegate; QmitkDoseValueDelegate* m_DoseValueDelegate; QmitkDoseVisualStyleDelegate* m_DoseVisualDelegate; bool m_internalUpdate; /**Predicate for dose nodes (excluding iso line nodes)*/ mitk::NodePredicateBase::Pointer m_isDosePredicate; /**Predicate for dose nodes and all iso line nodes*/ mitk::NodePredicateBase::Pointer m_isDoseOrIsoPredicate; /**Predicate for iso line nodes*/ mitk::NodePredicateBase::Pointer m_isIsoPredicate; private: mitk::DataNode::Pointer GetIsoDoseNode(mitk::DataNode::Pointer doseNode) const; }; #endif // RTDoseVisualizer_h diff --git a/Plugins/org.mitk.gui.qt.fit.demo/src/internal/FitGeneratorDemoView.h b/Plugins/org.mitk.gui.qt.fit.demo/src/internal/FitGeneratorDemoView.h index 8bc6f90026..422fc15952 100644 --- a/Plugins/org.mitk.gui.qt.fit.demo/src/internal/FitGeneratorDemoView.h +++ b/Plugins/org.mitk.gui.qt.fit.demo/src/internal/FitGeneratorDemoView.h @@ -1,89 +1,87 @@ /*============================================================================ 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 FitGeneratorDemoView_h #define FitGeneratorDemoView_h #include #include #include #include "ui_FitGeneratorDemoView.h" #include #include #include #include /*! * @brief Test Plugin for generation of model parameter images */ class FitGeneratorDemoView : public QmitkAbstractView { Q_OBJECT public: /*! @brief The view's unique ID - required by MITK */ static const std::string VIEW_ID; FitGeneratorDemoView(); protected slots: void OnModellingButtonClicked(); void OnGenerateTestDataButtonClicked(); void OnJobFinished(); void OnJobError(QString err); void OnJobResultsAreAvailable(mitk::modelFit::ModelFitResultNodeVectorType results, const ParameterFitBackgroundJob* pJob); void OnJobProgress(double progress); void OnJobStatusChanged(QString info); protected: // Overridden base class functions /*! * @brief Sets up the UI controls and connects the slots and signals. Gets * called by the framework to create the GUI at the right time. * @param[in,out] parent The parent QWidget, as this class itself is not a QWidget * subclass. */ void CreateQtPartControl(QWidget* parent) override; /*! * @brief Sets the focus to the plot curve button. Gets called by the framework to set the * focus on the right widget. */ void SetFocus() override; void Generate(); - /*! \brief called by QmitkFunctionality when DataManager's selection has changed - */ void OnSelectionChanged( berry::IWorkbenchPart::Pointer source, const QList& nodes) override; Ui::FitGeneratorDemoViewControls m_Controls; mitk::DataNode::Pointer m_selectedNode; mitk::Image::Pointer m_selectedImage; mitk::DataNode::Pointer m_selectedMaskNode; mitk::Image::Pointer m_selectedMask; mitk::ModelFactoryBase::Pointer m_ModelFactory; }; #endif diff --git a/Plugins/org.mitk.gui.qt.fit.genericfitting/src/internal/GenericDataFittingView.h b/Plugins/org.mitk.gui.qt.fit.genericfitting/src/internal/GenericDataFittingView.h index 755355ee05..6367d7ece5 100644 --- a/Plugins/org.mitk.gui.qt.fit.genericfitting/src/internal/GenericDataFittingView.h +++ b/Plugins/org.mitk.gui.qt.fit.genericfitting/src/internal/GenericDataFittingView.h @@ -1,153 +1,151 @@ /*============================================================================ 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 GenericDataFittingView_h #define GenericDataFittingView_h #include #include "QmitkAbstractView.h" #include "itkCommand.h" #include "ui_GenericDataFittingViewControls.h" #include "mitkModelBase.h" #include "QmitkParameterFitBackgroundJob.h" #include "mitkModelFitResultHelper.h" #include "mitkModelFactoryBase.h" #include "mitkLevenbergMarquardtModelFitFunctor.h" #include "mitkSimpleBarrierConstraintChecker.h" #include /*! * @brief Plugin for generic dynamic image data fitting */ class GenericDataFittingView : public QmitkAbstractView { Q_OBJECT public: /*! @brief The view's unique ID - required by MITK */ static const std::string VIEW_ID; GenericDataFittingView(); protected slots: void OnModellingButtonClicked(); void OnJobFinished(); void OnJobError(QString err); void OnJobResultsAreAvailable(mitk::modelFit::ModelFitResultNodeVectorType results, const ParameterFitBackgroundJob* pJob); void OnJobProgress(double progress); void OnJobStatusChanged(QString info); void OnModellSet(int); void OnNrOfParamsChanged(); /**Sets visibility and enabled state of the GUI depending on the settings and workflow state.*/ void UpdateGUIControls(); protected: typedef QList SelectedDataNodeVectorType; // Overridden base class functions /*! * @brief Sets up the UI controls and connects the slots and signals. Gets * called by the framework to create the GUI at the right time. * @param[in,out] parent The parent QWidget, as this class itself is not a QWidget * subclass. */ void CreateQtPartControl(QWidget* parent) override; /*! * @brief Sets the focus to the plot curve button. Gets called by the framework to set the * focus on the right widget. */ void SetFocus() override; template void GenerateModelFit_ROIBased(mitk::modelFit::ModelFitInfo::Pointer& modelFitInfo, mitk::ParameterFitImageGeneratorBase::Pointer& generator); template void GenerateModelFit_PixelBased(mitk::modelFit::ModelFitInfo::Pointer& modelFitInfo, mitk::ParameterFitImageGeneratorBase::Pointer& generator); /** Helper function that configures the initial parameter strategy of a parameterizer according to the settings of the GUI.*/ void ConfigureInitialParametersOfParameterizer(mitk::ModelParameterizerBase* parameterizer) const; void PrepareFitConfiguration(); bool IsGenericParamFactorySelected() const; /*! Starts the fitting job with the passed generator and session info*/ void DoFit(const mitk::modelFit::ModelFitInfo* fitSession, mitk::ParameterFitImageGeneratorBase* generator); /**Checks if the settings in the GUI are valid for the chosen model.*/ bool CheckModelSettings() const; void InitModelComboBox() const; - /*! \brief called by QmitkFunctionality when DataManager's selection has changed - */ void OnSelectionChanged(berry::IWorkbenchPart::Pointer source, const QList& selectedNodes) override; // Variables /*! @brief The view's UI controls */ Ui::GeneralDataFittingViewControls m_Controls; /* Nodes selected by user/ui for the fit */ mitk::DataNode::Pointer m_selectedNode; mitk::DataNode::Pointer m_selectedMaskNode; /* Images selected by user/ui for the fit */ mitk::Image::Pointer m_selectedImage; mitk::Image::Pointer m_selectedMask; mitk::ModelFactoryBase::Pointer m_selectedModelFactory; mitk::SimpleBarrierConstraintChecker::Pointer m_modelConstraints; private: bool m_FittingInProgress; typedef std::vector ModelFactoryStackType; ModelFactoryStackType m_FactoryStack; /**Helper function that generates a default fitting functor * default is a levenberg marquart based optimizer with all scales set to 1.0. * Constraint setter will be set based on the gui setting and a evaluation parameter * "sum of squared differences" will always be set.*/ mitk::ModelFitFunctorBase::Pointer CreateDefaultFitFunctor(const mitk::ModelParameterizerBase* parameterizer) const; /**Returns the default fit name, derived from the current GUI settings.*/ std::string GetDefaultFitName() const; /**Returns the current set name of the fit (either default name or use defined name).*/ std::string GetFitName() const; mitk::NodePredicateBase::Pointer m_IsNotABinaryImagePredicate; mitk::NodePredicateBase::Pointer m_IsBinaryImagePredicate; }; #endif diff --git a/Plugins/org.mitk.gui.qt.igt.app.hummelprotocolmeasurements/manifest_headers.cmake b/Plugins/org.mitk.gui.qt.igt.app.hummelprotocolmeasurements/manifest_headers.cmake index e4fbb21aac..473ac96eb1 100644 --- a/Plugins/org.mitk.gui.qt.igt.app.hummelprotocolmeasurements/manifest_headers.cmake +++ b/Plugins/org.mitk.gui.qt.igt.app.hummelprotocolmeasurements/manifest_headers.cmake @@ -1,5 +1,5 @@ set(Plugin-Name "IGT APP: Hummel Protocol Measurements") set(Plugin-Version "0.1") set(Plugin-Vendor "German Cancer Research Center (DKFZ)") set(Plugin-ContactAddress "http://www.mitk.org") -set(Require-Plugin org.mitk.gui.qt.common.legacy) +set(Require-Plugin org.mitk.gui.qt.common) diff --git a/Plugins/org.mitk.gui.qt.igt.app.hummelprotocolmeasurements/src/internal/QmitkIGTTrackingDataEvaluationView.cpp b/Plugins/org.mitk.gui.qt.igt.app.hummelprotocolmeasurements/src/internal/QmitkIGTTrackingDataEvaluationView.cpp index 37a99df5ab..7ca288ff21 100644 --- a/Plugins/org.mitk.gui.qt.igt.app.hummelprotocolmeasurements/src/internal/QmitkIGTTrackingDataEvaluationView.cpp +++ b/Plugins/org.mitk.gui.qt.igt.app.hummelprotocolmeasurements/src/internal/QmitkIGTTrackingDataEvaluationView.cpp @@ -1,1164 +1,1152 @@ /*============================================================================ 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 // Blueberry #include #include // Qmitk #include "QmitkIGTTrackingDataEvaluationView.h" // Qt #include #include #include // MITK #include "mitkNavigationDataCSVSequentialPlayer.h" #include #include #include #include #include //ITK #include //VNL #include //vtk headers #include #include #include const std::string QmitkIGTTrackingDataEvaluationView::VIEW_ID = "org.mitk.views.igttrackingdataevaluation"; QmitkIGTTrackingDataEvaluationView::QmitkIGTTrackingDataEvaluationView() - : QmitkFunctionality() - , m_Controls(nullptr) - , m_MultiWidget(nullptr) + : m_Controls(nullptr) , m_scalingfactor(1) { m_CSVtoXMLInputFilenameVector = std::vector(); m_CSVtoXMLOutputFilenameVector = std::vector(); } QmitkIGTTrackingDataEvaluationView::~QmitkIGTTrackingDataEvaluationView() { } void QmitkIGTTrackingDataEvaluationView::CreateQtPartControl(QWidget *parent) { // build up qt view, unless already done if (!m_Controls) { // create GUI widgets from the Qt Designer's .ui file m_Controls = new Ui::QmitkIGTTrackingDataEvaluationViewControls; m_Controls->setupUi(parent); connect(m_Controls->m_LoadInputFileList, SIGNAL(clicked()), this, SLOT(OnLoadFileList())); connect(m_Controls->m_StartEvaluation, SIGNAL(clicked()), this, SLOT(OnEvaluateData())); connect(m_Controls->m_AddToCurrentList, SIGNAL(clicked()), this, SLOT(OnAddToCurrentList())); connect(m_Controls->m_GeneratePointSetOfMeanPositions, SIGNAL(clicked()), this, SLOT(OnGeneratePointSet())); connect(m_Controls->m_GenerateRotationLines, SIGNAL(clicked()), this, SLOT(OnGenerateRotationLines())); connect(m_Controls->m_GeneratePointSet, SIGNAL(clicked()), this, SLOT(OnGenerateGroundTruthPointSet())); connect(m_Controls->m_Convert, SIGNAL(clicked()), this, SLOT(OnConvertCSVtoXMLFile())); connect(m_Controls->m_loadCSVtoXMLInputList, SIGNAL(clicked()), this, SLOT(OnCSVtoXMLLoadInputList())); connect(m_Controls->m_loadCSVtoXMLOutputList, SIGNAL(clicked()), this, SLOT(OnCSVtoXMLLoadOutputList())); connect(m_Controls->m_OrientationCalculationGenerateReference, SIGNAL(clicked()), this, SLOT(OnOrientationCalculation_CalcRef())); connect(m_Controls->m_OrientationCalculationWriteOrientationsToFile, SIGNAL(clicked()), this, SLOT(OnOrientationCalculation_CalcOrientandWriteToFile())); connect(m_Controls->m_GeneratePointSetsOfSinglePositions, SIGNAL(clicked()), this, SLOT(OnGeneratePointSetsOfSinglePositions())); connect(m_Controls->m_StartEvaluationAll, SIGNAL(clicked()), this, SLOT(OnEvaluateDataAll())); connect(m_Controls->m_GridMatching, SIGNAL(clicked()), this, SLOT(OnPerfomGridMatching())); connect(m_Controls->m_ComputeRotation, SIGNAL(clicked()), this, SLOT(OnComputeRotation())); //initialize data storage combo boxes m_Controls->m_ReferencePointSetComboBox->SetDataStorage(this->GetDataStorage()); m_Controls->m_ReferencePointSetComboBox->SetAutoSelectNewItems(true); m_Controls->m_ReferencePointSetComboBox->SetPredicate(mitk::NodePredicateDataType::New("PointSet")); m_Controls->m_MeasurementPointSetComboBox->SetDataStorage(this->GetDataStorage()); m_Controls->m_MeasurementPointSetComboBox->SetAutoSelectNewItems(true); m_Controls->m_MeasurementPointSetComboBox->SetPredicate(mitk::NodePredicateDataType::New("PointSet")); } } void QmitkIGTTrackingDataEvaluationView::OnComputeRotation() { //Get all data from UI auto EvaluationDataCollection = GetAllDataFromUIList(); //Compute mean Quaternions auto OrientationVector = GetMeanOrientationsOfAllData(EvaluationDataCollection); //Compute Rotations itk::Vector rotationVec; //adapt for Aurora 5D tools: [0,0,1000] rotationVec[0] = m_Controls->m_rotVecX->value(); //X rotationVec[1] = m_Controls->m_rotVecY->value(); //Y rotationVec[2] = m_Controls->m_rotVecZ->value(); //Z std::vector allOrientationErrors; for (std::vector::size_type i = 0; i < OrientationVector.size() - 1; ++i) { double AngleBetweenTwoQuaternions = mitk::StaticIGTHelperFunctions::GetAngleBetweenTwoQuaterions(OrientationVector.at(i), OrientationVector.at(i+1), rotationVec); double AngularError = fabs(AngleBetweenTwoQuaternions - 11.25); std::stringstream description; description << "Rotation Error ROT" << (i + 1) << " / ROT" << (i + 2); allOrientationErrors.push_back({ AngularError, description.str() }); MITK_INFO << description.str() << ": " << AngularError; } //compute statistics std::vector orientationErrorStatistics; orientationErrorStatistics = mitk::HummelProtocolEvaluation::ComputeStatistics(allOrientationErrors); MITK_INFO << "## Rotation error statistics: ##"; for (auto stat : orientationErrorStatistics) { MITK_INFO << stat.description << ": " << stat.distanceError; } //write results to file allOrientationErrors.insert(allOrientationErrors.end(), orientationErrorStatistics.begin(), orientationErrorStatistics.end()); allOrientationErrors.push_back({rotationVec[0],"Rot Vector [x]"}); allOrientationErrors.push_back({rotationVec[1], "Rot Vector [y]"}); allOrientationErrors.push_back({rotationVec[2], "Rot Vector [z]"}); std::stringstream filenameOrientationStat; filenameOrientationStat << std::string(m_Controls->m_OutputFilename->text().toUtf8()).c_str() << ".orientationStatistics.csv"; MITK_INFO << "Writing output to file " << filenameOrientationStat.str(); writeToFile(filenameOrientationStat.str(), allOrientationErrors); } void QmitkIGTTrackingDataEvaluationView::OnPerfomGridMatching() { mitk::PointSet::Pointer reference = dynamic_cast(m_Controls->m_ReferencePointSetComboBox->GetSelectedNode()->GetData()); mitk::PointSet::Pointer measurement = dynamic_cast(m_Controls->m_MeasurementPointSetComboBox->GetSelectedNode()->GetData()); //convert point sets to vtk poly data vtkSmartPointer sourcePoints = vtkSmartPointer::New(); vtkSmartPointer targetPoints = vtkSmartPointer::New(); for (int i = 0; iGetSize(); i++) { double point[3] = { reference->GetPoint(i)[0], reference->GetPoint(i)[1], reference->GetPoint(i)[2] }; sourcePoints->InsertNextPoint(point); double point_targets[3] = { measurement->GetPoint(i)[0], measurement->GetPoint(i)[1], measurement->GetPoint(i)[2] }; targetPoints->InsertNextPoint(point_targets); } //compute transform vtkSmartPointer transform = vtkSmartPointer::New(); transform->SetSourceLandmarks(sourcePoints); transform->SetTargetLandmarks(targetPoints); transform->SetModeToRigidBody(); transform->Modified(); transform->Update(); //compute FRE of transform double FRE = mitk::StaticIGTHelperFunctions::ComputeFRE(reference, measurement, transform); MITK_INFO << "FRE after grid matching: " + QString::number(FRE) + " mm"; //convert from vtk to itk data types itk::Matrix rotationFloat = itk::Matrix(); itk::Vector translationFloat = itk::Vector(); itk::Matrix rotationDouble = itk::Matrix(); itk::Vector translationDouble = itk::Vector(); vtkSmartPointer m = transform->GetMatrix(); for (int k = 0; k<3; k++) for (int l = 0; l<3; l++) { rotationFloat[k][l] = m->GetElement(k, l); rotationDouble[k][l] = m->GetElement(k, l); } for (int k = 0; k<3; k++) { translationFloat[k] = m->GetElement(k, 3); translationDouble[k] = m->GetElement(k, 3); } //create affine transform 3D mitk::AffineTransform3D::Pointer mitkTransform = mitk::AffineTransform3D::New(); mitkTransform->SetMatrix(rotationDouble); mitkTransform->SetOffset(translationDouble); mitk::NavigationData::Pointer transformNavigationData = mitk::NavigationData::New(mitkTransform); m_Controls->m_ReferencePointSetComboBox->GetSelectedNode()->GetData()->GetGeometry()->SetIndexToWorldTransform(mitkTransform); m_Controls->m_ReferencePointSetComboBox->GetSelectedNode()->GetData()->GetGeometry()->Modified(); //write to file std::stringstream filename; filename << std::string(m_Controls->m_OutputFilename->text().toUtf8()).c_str() << ".GridMatchingResult.csv"; MITK_INFO << "Writing output to file " << filename.str(); std::vector FRE_Error; FRE_Error.push_back({ FRE, "FRE after grid matching [mm]" }); writeToFile(filename.str(), FRE_Error); } void QmitkIGTTrackingDataEvaluationView::OnOrientationCalculation_CalcRef() { if (m_FilenameVector.size() != 3) { MessageBox("Need exactly three points as reference, aborting!"); return; } //start loop and iterate through all files of list for (std::size_t i = 0; i < m_FilenameVector.size(); ++i) { //create navigation data player mitk::NavigationDataCSVSequentialPlayer::Pointer myPlayer = ConstructNewNavigationDataPlayer(); myPlayer->SetFiletype(mitk::NavigationDataCSVSequentialPlayer::ManualLoggingCSV); myPlayer->SetFileName(m_FilenameVector[i]); //check if the stream is valid and skip file if not //create evaluation filter mitk::NavigationDataEvaluationFilter::Pointer myEvaluationFilter = mitk::NavigationDataEvaluationFilter::New(); //connect pipeline for (unsigned int j = 0; j < myPlayer->GetNumberOfOutputs(); ++j) myEvaluationFilter->SetInput(j, myPlayer->GetOutput(j)); //update pipline until number of samples is reached for (int j = 0; j < m_Controls->m_NumberOfSamples->value(); ++j) myEvaluationFilter->Update(); //store mean position as reference switch (i) { case 0: m_RefPoint1 = myEvaluationFilter->GetPositionMean(0); break; case 1: m_RefPoint2 = myEvaluationFilter->GetPositionMean(0); break; case 2: m_RefPoint3 = myEvaluationFilter->GetPositionMean(0); break; } } MessageBox("Created Reference!"); } void QmitkIGTTrackingDataEvaluationView::OnOrientationCalculation_CalcOrientandWriteToFile() { //start loop and iterate through all files of list for (std::size_t i = 0; i < m_FilenameVector.size(); ++i) { //create navigation data player mitk::NavigationDataCSVSequentialPlayer::Pointer myPlayer = ConstructNewNavigationDataPlayer(); myPlayer->SetFiletype(mitk::NavigationDataCSVSequentialPlayer::ManualLoggingCSV); myPlayer->SetFileName(m_FilenameVector.at(i)); //open file header QString outputname = QString(m_FilenameVector.at(i).c_str()) + "_orientationFile.csv"; m_CurrentWriteFile.open(outputname.toStdString().c_str(), std::ios::out); if (m_CurrentWriteFile.bad()) { MessageBox("Error: Can't open output file!"); return; } //write header to file m_CurrentWriteFile << "Nr;Calypso_Time;Valid_Reference;MeasureTool_Measurement-Tool[x];MeasureTool_Measurement-Tool[y];MeasureTool_Measurement-Tool[z];MeasureTool_Measurement-Tool[qx];MeasureTool_Measurement-Tool[qy];MeasureTool_Measurement-Tool[qz];MeasureTool_Measurement-Tool[qr]\n"; //update pipeline until number of samples is reached int step = 0; mitk::Point3D point1, point2, point3; mitk::Quaternion current_orientation; for (int j = 0; !myPlayer->IsAtEnd(); j++) { myPlayer->Update(); mitk::NavigationData::Pointer currentNavData = myPlayer->GetOutput(0); switch (step) { case 0: step++; point1 = currentNavData->GetPosition(); break; case 1: step++; point2 = currentNavData->GetPosition(); break; case 2: step = 0; point3 = currentNavData->GetPosition(); //compute transform from reference to current points if (point1[0] == 0 && point1[1] == 0 && point1[2] == 0 && point2[0] == 0 && point2[1] == 0 && point2[2] == 0 && point3[0] == 0 && point3[1] == 0 && point3[2] == 0 ) current_orientation.fill(0); else { vtkSmartPointer transform = vtkSmartPointer::New(); vtkSmartPointer sourcePoints = vtkSmartPointer::New(); double sourcepoint1[3] = { point1[0], point1[1], point1[2] }; double sourcepoint2[3] = { point2[0], point2[1], point2[2] }; double sourcepoint3[3] = { point3[0], point3[1], point3[2] }; sourcePoints->InsertNextPoint(sourcepoint1); sourcePoints->InsertNextPoint(sourcepoint2); sourcePoints->InsertNextPoint(sourcepoint3); vtkSmartPointer targetPoints = vtkSmartPointer::New(); double targetpoint1[3] = { m_RefPoint1[0], m_RefPoint1[1], m_RefPoint1[2] }; double targetpoint2[3] = { m_RefPoint2[0], m_RefPoint2[1], m_RefPoint2[2] }; double targetpoint3[3] = { m_RefPoint3[0], m_RefPoint3[1], m_RefPoint3[2] }; targetPoints->InsertNextPoint(targetpoint1); targetPoints->InsertNextPoint(targetpoint2); targetPoints->InsertNextPoint(targetpoint3); transform->SetSourceLandmarks(sourcePoints); transform->SetTargetLandmarks(targetPoints); transform->Modified(); transform->Update(); mitk::Transform::Pointer newTransform = mitk::Transform::New(); newTransform->SetMatrix(transform->GetMatrix()); current_orientation = newTransform->GetOrientation(); //add pointset with the three positions if ((j > 15) && (j < 18)) { mitk::DataNode::Pointer newNode = mitk::DataNode::New(); mitk::PointSet::Pointer newPointSet = mitk::PointSet::New(); newPointSet->InsertPoint(0, point1); newPointSet->InsertPoint(1, point2); newPointSet->InsertPoint(2, point3); QString name = QString(m_FilenameVector.at(i).c_str()); newNode->SetName(name.toStdString().c_str()); newNode->SetData(newPointSet); newNode->SetFloatProperty("pointsize", 0.1); this->GetDataStorage()->Add(newNode); } } break; } m_CurrentWriteFile << i << ";"; m_CurrentWriteFile << currentNavData->GetTimeStamp() << ";"; //IMPORTANT: change to GetIGTTimeStamp in new version! m_CurrentWriteFile << "true;"; m_CurrentWriteFile << currentNavData->GetPosition()[0] << ";"; m_CurrentWriteFile << currentNavData->GetPosition()[1] << ";"; m_CurrentWriteFile << currentNavData->GetPosition()[2] << ";"; m_CurrentWriteFile << current_orientation.x() << ";"; m_CurrentWriteFile << current_orientation.y() << ";"; m_CurrentWriteFile << current_orientation.z() << ";"; m_CurrentWriteFile << current_orientation.r() << ";"; m_CurrentWriteFile << "\n"; } //close output file m_CurrentWriteFile.close(); } MessageBox("Finished!"); } -void QmitkIGTTrackingDataEvaluationView::MultiWidgetAvailable(QmitkAbstractMultiWidget &multiWidget) -{ - m_MultiWidget = dynamic_cast(&multiWidget); -} - -void QmitkIGTTrackingDataEvaluationView::MultiWidgetNotAvailable() -{ - m_MultiWidget = nullptr; -} - void QmitkIGTTrackingDataEvaluationView::OnAddToCurrentList() { //read in files QStringList files = QFileDialog::getOpenFileNames(nullptr, "Select one or more files to open", "/", "CSV (*.csv)"); if (files.isEmpty()) return; for (int i = 0; i < files.size(); i++) { std::string tmp = files.at(i).toStdString().c_str(); m_FilenameVector.push_back(tmp); } //fill list at GUI m_Controls->m_FileList->clear(); for (unsigned int i = 0; i < m_FilenameVector.size(); i++) { new QListWidgetItem(tr(m_FilenameVector.at(i).c_str()), m_Controls->m_FileList); } } void QmitkIGTTrackingDataEvaluationView::OnLoadFileList() { m_FilenameVector = std::vector(); m_FilenameVector.clear(); OnAddToCurrentList(); } void QmitkIGTTrackingDataEvaluationView::OnEvaluateDataAll() { std::vector results5cm, results15cm, results30cm, resultsAccum; mitk::HummelProtocolEvaluation::HummelProtocolMeasurementVolume volume; if (m_Controls->m_standardVolume->isChecked()) { volume = mitk::HummelProtocolEvaluation::standard; mitk::HummelProtocolEvaluation::Evaluate5cmDistances(m_PointSetMeanPositions, volume, results5cm); mitk::HummelProtocolEvaluation::Evaluate15cmDistances(m_PointSetMeanPositions, volume, results15cm); mitk::HummelProtocolEvaluation::Evaluate30cmDistances(m_PointSetMeanPositions, volume, results30cm); mitk::HummelProtocolEvaluation::EvaluateAccumulatedDistances(m_PointSetMeanPositions, volume, resultsAccum); } else if (m_Controls->m_smallVolume->isChecked()) { volume = mitk::HummelProtocolEvaluation::small; mitk::HummelProtocolEvaluation::Evaluate5cmDistances(m_PointSetMeanPositions, volume, results5cm); } else if (m_Controls->m_mediumVolume->isChecked()) { volume = mitk::HummelProtocolEvaluation::medium; mitk::HummelProtocolEvaluation::Evaluate5cmDistances(m_PointSetMeanPositions, volume, results5cm); } //write results to file std::stringstream filename5cm; filename5cm << std::string(m_Controls->m_OutputFilename->text().toUtf8()).c_str() << ".results5cm.csv"; MITK_INFO << "Writing output to file " << filename5cm.str(); writeToFile(filename5cm.str(), results5cm); std::stringstream filename15cm; filename15cm << std::string(m_Controls->m_OutputFilename->text().toUtf8()).c_str() << ".results15cm.csv"; MITK_INFO << "Writing output to file " << filename15cm.str(); writeToFile(filename15cm.str(), results15cm); std::stringstream filename30cm; filename30cm << std::string(m_Controls->m_OutputFilename->text().toUtf8()).c_str() << ".results30cm.csv"; MITK_INFO << "Writing output to file " << filename30cm.str(); writeToFile(filename30cm.str(), results30cm); std::stringstream filenameAccum; filenameAccum << std::string(m_Controls->m_OutputFilename->text().toUtf8()).c_str() << ".resultsAccumDist.csv"; MITK_INFO << "Writing output to file " << filenameAccum.str(); writeToFile(filenameAccum.str(), resultsAccum); } void QmitkIGTTrackingDataEvaluationView::OnEvaluateData() { //open output file m_CurrentWriteFile.open(std::string(m_Controls->m_OutputFilename->text().toUtf8()).c_str(), std::ios::out); if (m_CurrentWriteFile.bad()) { MessageBox("Error: Can't open output file!"); return; } std::vector jitterValues; //write output file header WriteHeader(); //start loop and iterate through all files of list for (std::size_t i = 0; i < m_FilenameVector.size(); ++i) { //create navigation data player mitk::NavigationDataCSVSequentialPlayer::Pointer myPlayer = ConstructNewNavigationDataPlayer(); myPlayer->SetFiletype(mitk::NavigationDataCSVSequentialPlayer::ManualLoggingCSV); myPlayer->SetFileName(m_FilenameVector.at(i)); //create evaluation filter mitk::NavigationDataEvaluationFilter::Pointer myEvaluationFilter = mitk::NavigationDataEvaluationFilter::New(); //connect pipeline for (unsigned int j = 0; j < myPlayer->GetNumberOfOutputs(); ++i) { myEvaluationFilter->SetInput(j, myPlayer->GetOutput(j)); } if (myPlayer->GetNumberOfSnapshots() < m_Controls->m_NumberOfSamples->value()) { MITK_WARN << "Number of snapshots (" << myPlayer->GetNumberOfSnapshots() << ") smaller than number of samples to evaluate (" << m_Controls->m_NumberOfSamples->value() << ") ! Cannot proceed!"; return; } //update pipline until number of samples is reached for (int j = 0; j < m_Controls->m_NumberOfSamples->value(); j++) myEvaluationFilter->Update(); //store all jitter values in separate vector for statistics jitterValues.push_back({ myEvaluationFilter->GetPositionErrorRMS(0), "RMS" }); //write result to output file WriteDataSet(myEvaluationFilter, m_FilenameVector.at(i)); } //close output file for single data m_CurrentWriteFile.close(); //compute statistics std::vector jitterStatistics = mitk::HummelProtocolEvaluation::ComputeStatistics(jitterValues); MITK_INFO << "## Jitter (RMS) statistics: ##"; for (auto jitterStat : jitterStatistics) {MITK_INFO << jitterStat.description << ": " << jitterStat.distanceError;} //write statistic results to separate file std::stringstream filenameJitterStat; filenameJitterStat << std::string(m_Controls->m_OutputFilename->text().toUtf8()).c_str() << ".resultsJitterStatistics.csv"; MITK_INFO << "Writing output to file " << filenameJitterStat.str(); writeToFile(filenameJitterStat.str(), jitterStatistics); //calculate angles if option is on if (m_Controls->m_settingDifferenceAngles->isChecked() || m_Controls->m_DifferencesSLERP->isChecked()) CalculateDifferenceAngles(); MessageBox("Finished!"); } void QmitkIGTTrackingDataEvaluationView::OnGeneratePointSetsOfSinglePositions() { m_scalingfactor = m_Controls->m_ScalingFactor->value(); //start loop and iterate through all files of list for (std::size_t i = 0; i < m_FilenameVector.size(); ++i) { //create point set for this file mitk::PointSet::Pointer thisPointSet = mitk::PointSet::New(); //create navigation data player mitk::NavigationDataCSVSequentialPlayer::Pointer myPlayer = ConstructNewNavigationDataPlayer(); myPlayer->SetFiletype(mitk::NavigationDataCSVSequentialPlayer::ManualLoggingCSV); myPlayer->SetFileName(m_FilenameVector.at(i)); //update pipline until number of samlples is reached and store every single point for (int j = 0; j < m_Controls->m_NumberOfSamples->value(); j++) { myPlayer->Update(); mitk::Point3D thisPoint = myPlayer->GetOutput()->GetPosition(); thisPoint[0] *= m_scalingfactor; thisPoint[1] *= m_scalingfactor; thisPoint[2] *= m_scalingfactor; thisPointSet->InsertPoint(j, thisPoint); } //add point set to data storage mitk::DataNode::Pointer newNode = mitk::DataNode::New(); QString name = this->m_Controls->m_prefix->text() + QString("PointSet_of_All_Positions_") + QString::number(i); newNode->SetName(name.toStdString()); newNode->SetData(thisPointSet); this->GetDataStorage()->Add(newNode); } } void QmitkIGTTrackingDataEvaluationView::OnGeneratePointSet() { m_scalingfactor = m_Controls->m_ScalingFactor->value(); mitk::PointSet::Pointer generatedPointSet = mitk::PointSet::New(); //start loop and iterate through all files of list for (std::size_t i = 0; i < m_FilenameVector.size(); ++i) { //create navigation data player mitk::NavigationDataCSVSequentialPlayer::Pointer myPlayer = ConstructNewNavigationDataPlayer(); myPlayer->SetFiletype(mitk::NavigationDataCSVSequentialPlayer::ManualLoggingCSV); myPlayer->SetFileName(m_FilenameVector.at(i)); //create evaluation filter mitk::NavigationDataEvaluationFilter::Pointer myEvaluationFilter = mitk::NavigationDataEvaluationFilter::New(); //connect pipeline for (unsigned int j = 0; j < myPlayer->GetNumberOfOutputs(); ++j) { myEvaluationFilter->SetInput(j, myPlayer->GetOutput(j)); } //update pipline until number of samlples is reached for (int j = 0; j < m_Controls->m_NumberOfSamples->value(); ++j) { myEvaluationFilter->Update(); } //add mean position to point set mitk::Point3D meanPos = myEvaluationFilter->GetPositionMean(0); if (m_scalingfactor != 1) { meanPos[0] *= m_scalingfactor; meanPos[1] *= m_scalingfactor; meanPos[2] *= m_scalingfactor; } generatedPointSet->InsertPoint(i, meanPos); } //add point set to data storage mitk::DataNode::Pointer newNode = mitk::DataNode::New(); QString name = this->m_Controls->m_prefix->text() + "PointSet_of_Mean_Positions"; newNode->SetName(name.toStdString()); newNode->SetData(generatedPointSet); newNode->SetFloatProperty("pointsize", 5); this->GetDataStorage()->Add(newNode); m_PointSetMeanPositions = generatedPointSet; } void QmitkIGTTrackingDataEvaluationView::OnGenerateRotationLines() { m_scalingfactor = m_Controls->m_ScalingFactor->value(); //start loop and iterate through all files of list for (std::size_t i = 0; i < m_FilenameVector.size(); ++i) { //create navigation data player mitk::NavigationDataCSVSequentialPlayer::Pointer myPlayer = ConstructNewNavigationDataPlayer(); myPlayer->SetFiletype(mitk::NavigationDataCSVSequentialPlayer::ManualLoggingCSV); myPlayer->SetFileName(m_FilenameVector.at(i)); //create evaluation filter mitk::NavigationDataEvaluationFilter::Pointer myEvaluationFilter = mitk::NavigationDataEvaluationFilter::New(); //connect pipeline for (unsigned int j = 0; j < myPlayer->GetNumberOfOutputs(); ++j) { myEvaluationFilter->SetInput(j, myPlayer->GetOutput(j)); } //update pipline until number of samlples is reached for (int j = 0; j < m_Controls->m_NumberOfSamples->value(); ++j) myEvaluationFilter->Update(); //create line from mean pos to a second point which lies along the sensor (1,0,0 in tool coordinates for aurora) mitk::Point3D meanPos = myEvaluationFilter->GetPositionMean(0); if (m_scalingfactor != 1) { meanPos[0] *= m_scalingfactor; meanPos[1] *= m_scalingfactor; meanPos[2] *= m_scalingfactor; } mitk::Point3D secondPoint; mitk::Point3D thirdPoint; mitk::Point3D fourthPoint; mitk::FillVector3D(secondPoint, 2, 0, 0); //X vnl_vector secondPointTransformed = myEvaluationFilter->GetQuaternionMean(0).rotation_matrix_transpose().transpose() * secondPoint.GetVnlVector() + meanPos.GetVnlVector(); mitk::Point3D secondPointTransformedMITK; mitk::FillVector3D(secondPointTransformedMITK, secondPointTransformed[0], secondPointTransformed[1], secondPointTransformed[2]); mitk::FillVector3D(thirdPoint, 0, 4, 0); //Y vnl_vector thirdPointTransformed = myEvaluationFilter->GetQuaternionMean(0).rotation_matrix_transpose().transpose() * thirdPoint.GetVnlVector() + meanPos.GetVnlVector(); mitk::Point3D thirdPointTransformedMITK; mitk::FillVector3D(thirdPointTransformedMITK, thirdPointTransformed[0], thirdPointTransformed[1], thirdPointTransformed[2]); mitk::FillVector3D(fourthPoint, 0, 0, 6); //Z vnl_vector fourthPointTransformed = myEvaluationFilter->GetQuaternionMean(0).rotation_matrix_transpose().transpose() * fourthPoint.GetVnlVector() + meanPos.GetVnlVector(); mitk::Point3D fourthPointTransformedMITK; mitk::FillVector3D(fourthPointTransformedMITK, fourthPointTransformed[0], fourthPointTransformed[1], fourthPointTransformed[2]); mitk::PointSet::Pointer rotationLine = mitk::PointSet::New(); rotationLine->InsertPoint(0, secondPointTransformedMITK); rotationLine->InsertPoint(1, meanPos); rotationLine->InsertPoint(2, thirdPointTransformedMITK); rotationLine->InsertPoint(3, meanPos); rotationLine->InsertPoint(4, fourthPointTransformedMITK); mitk::DataNode::Pointer newNode = mitk::DataNode::New(); QString nodeName = this->m_Controls->m_prefix->text() + "RotationLineNumber" + QString::number(i); newNode->SetName(nodeName.toStdString()); newNode->SetData(rotationLine); newNode->SetBoolProperty("show contour", true); newNode->SetFloatProperty("pointsize", 0.5); this->GetDataStorage()->Add(newNode); } } void QmitkIGTTrackingDataEvaluationView::OnGenerateGroundTruthPointSet() { mitk::PointSet::Pointer generatedPointSet = mitk::PointSet::New(); int currentPointID = 0; mitk::Point3D currentPoint; mitk::FillVector3D(currentPoint, 0, 0, 0); for (int i = 0; i < m_Controls->m_PointNumber2->value(); i++) { for (int j = 0; j < m_Controls->m_PointNumber1->value(); j++) { generatedPointSet->InsertPoint(currentPointID, currentPoint); currentPointID++; currentPoint[1] += m_Controls->m_PointDistance->value(); } currentPoint[1] = 0; currentPoint[2] += m_Controls->m_PointDistance->value(); } mitk::DataNode::Pointer newNode = mitk::DataNode::New(); QString nodeName = "GroundTruthPointSet_" + QString::number(m_Controls->m_PointNumber1->value()) + "x" + QString::number(m_Controls->m_PointNumber2->value()) + "_(" + QString::number(m_Controls->m_PointDistance->value()) + "mm)"; newNode->SetName(nodeName.toStdString()); newNode->SetData(generatedPointSet); newNode->SetFloatProperty("pointsize", 5); this->GetDataStorage()->Add(newNode); } void QmitkIGTTrackingDataEvaluationView::OnConvertCSVtoXMLFile() { if (m_Controls->m_ConvertSingleFile->isChecked()) { //convert one file int lines = ConvertOneFile(this->m_Controls->m_InputCSV->text().toStdString(), this->m_Controls->m_OutputXML->text().toStdString()); QString result = "Converted one file with" + QString::number(lines) + " data sets"; MessageBox(result.toStdString()); } else //converte file list { if (m_CSVtoXMLInputFilenameVector.empty() || m_CSVtoXMLOutputFilenameVector.empty()) { MessageBox("Error: one list is not loaded!"); return; } else if (m_CSVtoXMLInputFilenameVector.size() != m_CSVtoXMLOutputFilenameVector.size()) { MessageBox("Error: lists do not have the same number of files!"); return; } for (std::size_t i = 0; i < m_CSVtoXMLInputFilenameVector.size(); ++i) { ConvertOneFile(m_CSVtoXMLInputFilenameVector.at(i), m_CSVtoXMLOutputFilenameVector.at(i)); } QString result = "Converted " + QString::number(m_CSVtoXMLInputFilenameVector.size()) + " files from file list!"; MessageBox(result.toStdString()); } } int QmitkIGTTrackingDataEvaluationView::ConvertOneFile(std::string inputFilename, std::string outputFilename) { std::vector myNavigationDatas = GetNavigationDatasFromFile(inputFilename); mitk::NavigationDataRecorderDeprecated::Pointer myRecorder = mitk::NavigationDataRecorderDeprecated::New(); myRecorder->SetFileName(outputFilename.c_str()); mitk::NavigationData::Pointer input = mitk::NavigationData::New(); if (m_Controls->m_ConvertCSV->isChecked()) myRecorder->SetOutputFormat(mitk::NavigationDataRecorderDeprecated::csv); myRecorder->AddNavigationData(input); myRecorder->StartRecording(); for (std::size_t i = 0; i < myNavigationDatas.size(); ++i) { input->Graft(myNavigationDatas.at(i)); myRecorder->Update(); } myRecorder->StopRecording(); return myNavigationDatas.size(); } void QmitkIGTTrackingDataEvaluationView::OnCSVtoXMLLoadInputList() { //read in filename QString filename = QFileDialog::getOpenFileName(nullptr, tr("Open Measurement Filename List"), "/", tr("All Files (*.*)")); if (filename.isNull()) return; m_CSVtoXMLInputFilenameVector = this->GetFileContentLineByLine(filename.toStdString()); m_Controls->m_labelCSVtoXMLInputList->setText("READY"); } void QmitkIGTTrackingDataEvaluationView::OnCSVtoXMLLoadOutputList() { //read in filename QString filename = QFileDialog::getOpenFileName(nullptr, tr("Open Measurement Filename List"), "/", tr("All Files (*.*)")); if (filename.isNull()) return; m_CSVtoXMLOutputFilenameVector = this->GetFileContentLineByLine(filename.toStdString()); m_Controls->m_labelCSVtoXMLOutputList->setText("READY"); } void QmitkIGTTrackingDataEvaluationView::MessageBox(std::string s) { QMessageBox msgBox; msgBox.setText(s.c_str()); msgBox.exec(); } void QmitkIGTTrackingDataEvaluationView::WriteHeader() { m_CurrentWriteFile << "Filename;"; m_CurrentWriteFile << "N;"; m_CurrentWriteFile << "N_invalid;"; m_CurrentWriteFile << "Percentage_invalid;"; if (m_Controls->m_settingPosMean->isChecked()) { m_CurrentWriteFile << "Position_Mean[x];"; m_CurrentWriteFile << "Position_Mean[y];"; m_CurrentWriteFile << "Position_Mean[z];"; } if (m_Controls->m_settingPosStabw->isChecked()) { m_CurrentWriteFile << "Position_StandDev[x];"; m_CurrentWriteFile << "Position_StandDev[y];"; m_CurrentWriteFile << "Position_StandDev[z];"; } if (m_Controls->m_settingPosSampleStabw->isChecked()) { m_CurrentWriteFile << "Position_SampleStandDev[x];"; m_CurrentWriteFile << "Position_SampleStandDev[y];"; m_CurrentWriteFile << "Position_SampleStandDev[z];"; } if (m_Controls->m_settingQuaternionMean->isChecked()) { m_CurrentWriteFile << "Quaternion_Mean[qx];"; m_CurrentWriteFile << "Quaternion_Mean[qy];"; m_CurrentWriteFile << "Quaternion_Mean[qz];"; m_CurrentWriteFile << "Quaternion_Mean[qr];"; } if (m_Controls->m_settionQuaternionStabw->isChecked()) { m_CurrentWriteFile << "Quaternion_StandDev[qx];"; m_CurrentWriteFile << "Quaternion_StandDev[qy];"; m_CurrentWriteFile << "Quaternion_StandDev[qz];"; m_CurrentWriteFile << "Quaternion_StandDev[qr];"; } if (m_Controls->m_settingPosErrorMean->isChecked()) m_CurrentWriteFile << "PositionError_Mean;"; if (m_Controls->m_settingPosErrorStabw->isChecked()) m_CurrentWriteFile << "PositionError_StandDev;"; if (m_Controls->m_settingPosErrorSampleStabw->isChecked()) m_CurrentWriteFile << "PositionError_SampleStandDev;"; if (m_Controls->m_settingPosErrorRMS->isChecked()) m_CurrentWriteFile << "PositionError_RMS;"; if (m_Controls->m_settingPosErrorMedian->isChecked()) m_CurrentWriteFile << "PositionError_Median;"; if (m_Controls->m_settingPosErrorMinMax->isChecked()) { m_CurrentWriteFile << "PositionError_Max;"; m_CurrentWriteFile << "PositionError_Min;"; } if (m_Controls->m_settingEulerMean->isChecked()) { m_CurrentWriteFile << "Euler_tx;"; m_CurrentWriteFile << "Euler_ty;"; m_CurrentWriteFile << "Euler_tz;"; } if (m_Controls->m_settingEulerRMS->isChecked()) { m_CurrentWriteFile << "EulerErrorRMS (rad);"; m_CurrentWriteFile << "EulerErrorRMS (grad);"; } m_CurrentWriteFile << "\n"; } void QmitkIGTTrackingDataEvaluationView::WriteDataSet(mitk::NavigationDataEvaluationFilter::Pointer myEvaluationFilter, std::string dataSetName) { if (myEvaluationFilter->GetNumberOfOutputs() == 0) m_CurrentWriteFile << "Error: no input \n"; else { m_CurrentWriteFile << dataSetName << ";"; m_CurrentWriteFile << myEvaluationFilter->GetNumberOfAnalysedNavigationData(0) << ";"; m_CurrentWriteFile << myEvaluationFilter->GetNumberOfInvalidSamples(0) << ";"; m_CurrentWriteFile << myEvaluationFilter->GetPercentageOfInvalidSamples(0) << ";"; if (m_Controls->m_settingPosMean->isChecked()) { m_CurrentWriteFile << myEvaluationFilter->GetPositionMean(0)[0] << ";"; m_CurrentWriteFile << myEvaluationFilter->GetPositionMean(0)[1] << ";"; m_CurrentWriteFile << myEvaluationFilter->GetPositionMean(0)[2] << ";"; } if (m_Controls->m_settingPosStabw->isChecked()) { m_CurrentWriteFile << myEvaluationFilter->GetPositionStandardDeviation(0)[0] << ";"; m_CurrentWriteFile << myEvaluationFilter->GetPositionStandardDeviation(0)[1] << ";"; m_CurrentWriteFile << myEvaluationFilter->GetPositionStandardDeviation(0)[2] << ";"; } if (m_Controls->m_settingPosSampleStabw->isChecked()) { m_CurrentWriteFile << myEvaluationFilter->GetPositionSampleStandardDeviation(0)[0] << ";"; m_CurrentWriteFile << myEvaluationFilter->GetPositionSampleStandardDeviation(0)[1] << ";"; m_CurrentWriteFile << myEvaluationFilter->GetPositionSampleStandardDeviation(0)[2] << ";"; } if (m_Controls->m_settingQuaternionMean->isChecked()) { m_CurrentWriteFile << myEvaluationFilter->GetQuaternionMean(0).x() << ";"; m_CurrentWriteFile << myEvaluationFilter->GetQuaternionMean(0).y() << ";"; m_CurrentWriteFile << myEvaluationFilter->GetQuaternionMean(0).z() << ";"; m_CurrentWriteFile << myEvaluationFilter->GetQuaternionMean(0).r() << ";"; } if (m_Controls->m_settionQuaternionStabw->isChecked()) { m_CurrentWriteFile << myEvaluationFilter->GetQuaternionStandardDeviation(0).x() << ";"; m_CurrentWriteFile << myEvaluationFilter->GetQuaternionStandardDeviation(0).y() << ";"; m_CurrentWriteFile << myEvaluationFilter->GetQuaternionStandardDeviation(0).z() << ";"; m_CurrentWriteFile << myEvaluationFilter->GetQuaternionStandardDeviation(0).r() << ";"; } if (m_Controls->m_settingPosErrorMean->isChecked()) m_CurrentWriteFile << myEvaluationFilter->GetPositionErrorMean(0) << ";"; if (m_Controls->m_settingPosErrorStabw->isChecked()) m_CurrentWriteFile << myEvaluationFilter->GetPositionErrorStandardDeviation(0) << ";"; if (m_Controls->m_settingPosErrorSampleStabw->isChecked()) m_CurrentWriteFile << myEvaluationFilter->GetPositionErrorSampleStandardDeviation(0) << ";"; if (m_Controls->m_settingPosErrorRMS->isChecked()) m_CurrentWriteFile << myEvaluationFilter->GetPositionErrorRMS(0) << ";"; if (m_Controls->m_settingPosErrorMedian->isChecked()) m_CurrentWriteFile << myEvaluationFilter->GetPositionErrorMedian(0) << ";"; if (m_Controls->m_settingPosErrorMinMax->isChecked()) { m_CurrentWriteFile << myEvaluationFilter->GetPositionErrorMax(0) << ";"; m_CurrentWriteFile << myEvaluationFilter->GetPositionErrorMin(0) << ";"; } if (m_Controls->m_settingEulerMean->isChecked()) { m_CurrentWriteFile << myEvaluationFilter->GetEulerAnglesMean(0)[0] << ";"; m_CurrentWriteFile << myEvaluationFilter->GetEulerAnglesMean(0)[1] << ";"; m_CurrentWriteFile << myEvaluationFilter->GetEulerAnglesMean(0)[2] << ";"; } if (m_Controls->m_settingEulerRMS->isChecked()) { m_CurrentWriteFile << myEvaluationFilter->GetEulerAnglesRMS(0) << ";"; m_CurrentWriteFile << myEvaluationFilter->GetEulerAnglesRMSDegree(0) << ";"; } m_CurrentWriteFile << "\n"; } } std::vector QmitkIGTTrackingDataEvaluationView::GetMeanOrientationsOfAllData(std::vector allData, bool useSLERP) { std::vector returnValue; for (auto dataSet : allData) { if (useSLERP) returnValue.push_back(GetSLERPAverage(dataSet)); else returnValue.push_back(dataSet->GetQuaternionMean(0)); } return returnValue; } std::vector QmitkIGTTrackingDataEvaluationView::GetAllDataFromUIList() { std::vector EvaluationDataCollection; //start loop and iterate through all files of list: store the evaluation data for (std::size_t i = 0; i < m_FilenameVector.size(); ++i) { //create navigation data player mitk::NavigationDataCSVSequentialPlayer::Pointer myPlayer = ConstructNewNavigationDataPlayer(); myPlayer->SetFiletype(mitk::NavigationDataCSVSequentialPlayer::ManualLoggingCSV); myPlayer->SetFileName(m_FilenameVector.at(i)); //create evaluation filter mitk::NavigationDataEvaluationFilter::Pointer myEvaluationFilter = mitk::NavigationDataEvaluationFilter::New(); //connect pipeline for (unsigned int j = 0; j < myPlayer->GetNumberOfOutputs(); ++j) myEvaluationFilter->SetInput(j, myPlayer->GetOutput(j)); //update pipline until number of samlples is reached for (int j = 0; j < m_Controls->m_NumberOfSamples->value(); ++j) myEvaluationFilter->Update(); myEvaluationFilter->SetInput(nullptr); myPlayer = nullptr; EvaluationDataCollection.push_back(myEvaluationFilter); } return EvaluationDataCollection; } void QmitkIGTTrackingDataEvaluationView::CalculateDifferenceAngles() { //Get all data from UI std::vector EvaluationDataCollection = GetAllDataFromUIList(); //calculation and writing of output data //open output file m_CurrentAngleDifferencesWriteFile.open(std::string((m_Controls->m_OutputFilename->text() + ".angledifferences.csv").toUtf8()).c_str(), std::ios::out); if (m_CurrentAngleDifferencesWriteFile.bad()) { MessageBox("Error: Can't open output file for angle differences calculation!"); return; } //write header WriteDifferenceAnglesHeader(); //compute angle differences QString pos1 = "invalid"; QString pos2 = "invalid"; //now iterate through all evaluation data and calculate the angles for (std::size_t i = 0; i < m_FilenameVector.size(); ++i) { pos1 = QString::fromStdString(itksys::SystemTools::GetFilenameWithoutLastExtension(m_FilenameVector.at(i))); for (std::size_t j = 0; j < m_FilenameVector.size(); ++j) { pos2 = QString::fromStdString(itksys::SystemTools::GetFilenameWithoutLastExtension(m_FilenameVector.at(j))); mitk::Quaternion q1; mitk::Quaternion q2; if (m_Controls->m_DifferencesSLERP->isChecked()) { //compute slerp average q1 = GetSLERPAverage(EvaluationDataCollection.at(i)); q2 = GetSLERPAverage(EvaluationDataCollection.at(j)); } else { //compute arithmetic average q1 = EvaluationDataCollection.at(i)->GetQuaternionMean(0); q2 = EvaluationDataCollection.at(j)->GetQuaternionMean(0); } itk::Vector rotationVec; //adapt for Aurora 5D tools: [0,0,1000] rotationVec[0] = 10000; //X rotationVec[1] = 0; //Y rotationVec[2] = 0; //Z double AngleBetweenTwoQuaternions = mitk::StaticIGTHelperFunctions::GetAngleBetweenTwoQuaterions(q1, q2, rotationVec); //write data set WriteDifferenceAnglesDataSet(pos1.toStdString(), pos2.toStdString(), i, j, AngleBetweenTwoQuaternions); } } //close output file m_CurrentAngleDifferencesWriteFile.close(); } void QmitkIGTTrackingDataEvaluationView::WriteDifferenceAnglesHeader() { m_CurrentAngleDifferencesWriteFile << "Name;Idx1;Idx2;Angle [Degree]\n"; } void QmitkIGTTrackingDataEvaluationView::WriteDifferenceAnglesDataSet(std::string pos1, std::string pos2, int idx1, int idx2, double angle) { m_CurrentAngleDifferencesWriteFile << "Angle between " << pos1 << " and " << pos2 << ";" << idx1 << ";" << idx2 << ";" << angle << "\n"; MITK_INFO << "Angle: " << angle; } std::vector QmitkIGTTrackingDataEvaluationView::GetNavigationDatasFromFile(std::string filename) { std::vector returnValue = std::vector(); std::vector fileContentLineByLine = GetFileContentLineByLine(filename); for (std::size_t i = 1; i < fileContentLineByLine.size(); ++i) //skip header so start at 1 { returnValue.push_back(GetNavigationDataOutOfOneLine(fileContentLineByLine.at(i))); } return returnValue; } std::vector QmitkIGTTrackingDataEvaluationView::GetFileContentLineByLine(std::string filename) { std::vector readData = std::vector(); //save old locale char * oldLocale; oldLocale = setlocale(LC_ALL, nullptr); //define own locale std::locale C("C"); setlocale(LC_ALL, "C"); //read file std::ifstream file; file.open(filename.c_str(), std::ios::in); if (file.good()) { //read out file file.seekg(0L, std::ios::beg); // move to begin of file while (!file.eof()) { std::string buffer; std::getline(file, buffer); // read out file line by line if (buffer.size() > 0) readData.push_back(buffer); } } file.close(); //switch back to old locale setlocale(LC_ALL, oldLocale); return readData; } mitk::NavigationData::Pointer QmitkIGTTrackingDataEvaluationView::GetNavigationDataOutOfOneLine(std::string line) { mitk::NavigationData::Pointer returnValue = mitk::NavigationData::New(); QString myLine = QString(line.c_str()); QStringList myLineList = myLine.split(';'); mitk::Point3D position; mitk::Quaternion orientation; bool valid = false; if (myLineList.at(2).toStdString() == "1") valid = true; position[0] = myLineList.at(3).toDouble(); position[1] = myLineList.at(4).toDouble(); position[2] = myLineList.at(5).toDouble(); orientation[0] = myLineList.at(6).toDouble(); orientation[1] = myLineList.at(7).toDouble(); orientation[2] = myLineList.at(8).toDouble(); orientation[3] = myLineList.at(9).toDouble(); returnValue->SetDataValid(valid); returnValue->SetPosition(position); returnValue->SetOrientation(orientation); return returnValue; } mitk::Quaternion QmitkIGTTrackingDataEvaluationView::GetSLERPAverage(mitk::NavigationDataEvaluationFilter::Pointer evaluationFilter) { mitk::Quaternion average; //build a vector of quaternions from the evaulation filter (caution always takes the first (0) input of the filter std::vector quaternions = std::vector(); for (int i = 0; i < evaluationFilter->GetNumberOfAnalysedNavigationData(0); i++) { mitk::Quaternion currentq = evaluationFilter->GetLoggedOrientation(i, 0); quaternions.push_back(currentq); } //compute the slerp average using the quaternion averaging class mitk::QuaternionAveraging::Pointer myAverager = mitk::QuaternionAveraging::New(); average = myAverager->CalcAverage(quaternions); return average; } void QmitkIGTTrackingDataEvaluationView::writeToFile(std::string filename, std::vector values) { std::fstream currentFile; currentFile.open(filename.c_str(), std::ios::out); if (currentFile.bad()) { MITK_WARN << "Cannot open file, aborting!"; return; } currentFile << "Description" << ";" << "Error[mm]" << "\n"; for (auto currentError : values) { currentFile << currentError.description << ";" << currentError.distanceError << "\n"; } currentFile.close(); } mitk::NavigationDataCSVSequentialPlayer::Pointer QmitkIGTTrackingDataEvaluationView::ConstructNewNavigationDataPlayer() { bool rightHanded = m_Controls->m_RigthHanded->isChecked(); QString separator = m_Controls->m_SeparatorSign->text(); QChar sepaSign = separator.at(0); //char separatorSign; char separatorSign = sepaSign.toLatin1(); //std::string separatorSign = m_Controls->m_SeparatorSign->text().toStdString(); int sampleCount = m_Controls->m_SampleCount->value(); bool headerRow = m_Controls->m_HeaderRow->isChecked(); int xPos = m_Controls->m_XPos->value(); int yPos = m_Controls->m_YPos->value(); int zPos = m_Controls->m_ZPos->value(); bool useQuats = m_Controls->m_UseQuats->isChecked(); int qx = m_Controls->m_Qx->value(); int qy = m_Controls->m_Qy->value(); int qz = m_Controls->m_Qz->value(); int qr = m_Controls->m_Qr->value(); int azimuth = m_Controls->m_Azimuth->value(); int elevation = m_Controls->m_Elevation->value(); int roll = m_Controls->m_Roll->value(); bool eulersInRad = m_Controls->m_Radiants->isChecked(); //need to find the biggest column number to determine the minimal number of columns the .csv file has to have int allInts[] = {xPos, yPos, zPos, qx, qy, qr, azimuth, elevation, roll}; int minNumberOfColumns = (*std::max_element(allInts, allInts+9)+1); //size needs to be +1 because columns start at 0 but size at 1 mitk::NavigationDataCSVSequentialPlayer::Pointer navDataPlayer = mitk::NavigationDataCSVSequentialPlayer::New(); navDataPlayer->SetOptions(rightHanded, separatorSign, sampleCount, headerRow, xPos, yPos, zPos, useQuats, qx, qy, qz, qr, azimuth, elevation, roll, eulersInRad, minNumberOfColumns); return navDataPlayer; } diff --git a/Plugins/org.mitk.gui.qt.igt.app.hummelprotocolmeasurements/src/internal/QmitkIGTTrackingDataEvaluationView.h b/Plugins/org.mitk.gui.qt.igt.app.hummelprotocolmeasurements/src/internal/QmitkIGTTrackingDataEvaluationView.h index fce8ea93d0..e83f5bc590 100644 --- a/Plugins/org.mitk.gui.qt.igt.app.hummelprotocolmeasurements/src/internal/QmitkIGTTrackingDataEvaluationView.h +++ b/Plugins/org.mitk.gui.qt.igt.app.hummelprotocolmeasurements/src/internal/QmitkIGTTrackingDataEvaluationView.h @@ -1,139 +1,128 @@ /*============================================================================ 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 QmitkIGTTrackingDataEvaluationView_h #define QmitkIGTTrackingDataEvaluationView_h #include -#include -#include +#include #include "ui_QmitkIGTTrackingDataEvaluationViewControls.h" #include "mitkHummelProtocolEvaluation.h" #include #include "mitkNavigationDataCSVSequentialPlayer.h" - - /*! \brief QmitkIGTTrackingDataEvaluationView \warning This application module is not yet documented. Use "svn blame/praise/annotate" and ask the author to provide basic documentation. - \sa QmitkFunctionality - \ingroup Functionalities */ -class QmitkIGTTrackingDataEvaluationView : public QmitkFunctionality +class QmitkIGTTrackingDataEvaluationView : 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; QmitkIGTTrackingDataEvaluationView(); ~QmitkIGTTrackingDataEvaluationView() override; void CreateQtPartControl(QWidget *parent) override; - - virtual void MultiWidgetAvailable(QmitkAbstractMultiWidget &multiWidget) override; - virtual void MultiWidgetNotAvailable() override; + void SetFocus() override {} protected slots: void OnLoadFileList(); void OnAddToCurrentList(); void OnEvaluateData(); void OnEvaluateDataAll(); void OnGeneratePointSet(); void OnGeneratePointSetsOfSinglePositions(); void OnGenerateRotationLines(); void OnGenerateGroundTruthPointSet(); void OnConvertCSVtoXMLFile(); void OnCSVtoXMLLoadInputList(); void OnCSVtoXMLLoadOutputList(); void OnPerfomGridMatching(); void OnComputeRotation(); /** Reads in exactly three position files als reference. */ void OnOrientationCalculation_CalcRef(); /** Uses always three positions (1,2,3: first orientation; 4,5,6: second orientation; and so on) in every file to calcualte a orientation. */ void OnOrientationCalculation_CalcOrientandWriteToFile(); protected: Ui::QmitkIGTTrackingDataEvaluationViewControls* m_Controls; - QmitkStdMultiWidget* m_MultiWidget; - std::vector m_FilenameVector; void MessageBox(std::string s); std::fstream m_CurrentWriteFile; void WriteHeader(); void WriteDataSet(mitk::NavigationDataEvaluationFilter::Pointer evaluationFilter, std::string dataSetName); //members for orientation calculation mitk::Point3D m_RefPoint1; mitk::Point3D m_RefPoint2; mitk::Point3D m_RefPoint3; double m_scalingfactor; //scaling factor for visualization, 1 by default //angle diffrences: seperated file std::fstream m_CurrentAngleDifferencesWriteFile; void CalculateDifferenceAngles(); void WriteDifferenceAnglesHeader(); void WriteDifferenceAnglesDataSet(std::string pos1, std::string pos2, int idx1, int idx2, double angle); void writeToFile(std::string filename, std::vector values); //different help methods to read a csv logging file std::vector GetNavigationDatasFromFile(std::string filename); std::vector GetFileContentLineByLine(std::string filename); mitk::NavigationData::Pointer GetNavigationDataOutOfOneLine(std::string line); //help method to sonstruct the NavigationDataCSVSequentialPlayer filled with all the options from the UI mitk::NavigationDataCSVSequentialPlayer::Pointer ConstructNewNavigationDataPlayer(); //CSV to XML members std::vector m_CSVtoXMLInputFilenameVector; std::vector m_CSVtoXMLOutputFilenameVector; //returns the number of converted lines int ConvertOneFile(std::string inputFilename, std::string outputFilename); /** @brief calculates the angle in the plane perpendicular to the rotation axis of the two quaterions. */ double GetAngleBetweenTwoQuaterions(mitk::Quaternion a, mitk::Quaternion b); /** @brief calculates the slerp average of a set of quaternions which is stored in the navigation data evaluation filter */ mitk::Quaternion GetSLERPAverage(mitk::NavigationDataEvaluationFilter::Pointer); /** @brief Stores the mean positions of all evaluated data */ mitk::PointSet::Pointer m_PointSetMeanPositions; /** @return returns the mean orientation of all given data */ std::vector GetMeanOrientationsOfAllData(std::vector allData, bool useSLERP = false); /** @return returns all data read from the data list as NavigationDataEvaluationFilters */ std::vector GetAllDataFromUIList(); }; #endif // _QMITKIGTTRACKINGDATAEVALUATIONVIEW_H_INCLUDED diff --git a/Plugins/org.mitk.gui.qt.igt.app.hummelprotocolmeasurements/src/internal/QmitkIGTTrackingSemiAutomaticMeasurementView.cpp b/Plugins/org.mitk.gui.qt.igt.app.hummelprotocolmeasurements/src/internal/QmitkIGTTrackingSemiAutomaticMeasurementView.cpp index 4c14d4c333..85bbb1257e 100644 --- a/Plugins/org.mitk.gui.qt.igt.app.hummelprotocolmeasurements/src/internal/QmitkIGTTrackingSemiAutomaticMeasurementView.cpp +++ b/Plugins/org.mitk.gui.qt.igt.app.hummelprotocolmeasurements/src/internal/QmitkIGTTrackingSemiAutomaticMeasurementView.cpp @@ -1,618 +1,606 @@ /*============================================================================ 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. ============================================================================*/ // Blueberry #include #include // Qmitk #include "QmitkIGTTrackingSemiAutomaticMeasurementView.h" // Qt #include #include #include #include // MITK #include #include #include #include "mitkHummelProtocolEvaluation.h" // POCO #include #include const std::string QmitkIGTTrackingSemiAutomaticMeasurementView::VIEW_ID = "org.mitk.views.igttrackingsemiautomaticmeasurement"; QmitkIGTTrackingSemiAutomaticMeasurementView::QmitkIGTTrackingSemiAutomaticMeasurementView() - : QmitkFunctionality() - , m_Controls(nullptr) - , m_MultiWidget(nullptr) + : m_Controls(nullptr) { m_NextFile = 0; m_FilenameVector = std::vector(); m_Timer = new QTimer(this); m_logging = false; m_referenceValid = true; m_tracking = false; m_EvaluationFilter = mitk::NavigationDataEvaluationFilter::New(); } QmitkIGTTrackingSemiAutomaticMeasurementView::~QmitkIGTTrackingSemiAutomaticMeasurementView() { } void QmitkIGTTrackingSemiAutomaticMeasurementView::CreateResults() { QString LogFileName = m_Controls->m_OutputPath->text() + "_results.log"; mitk::LoggingBackend::Unregister(); mitk::LoggingBackend::SetLogFile(LogFileName.toStdString().c_str()); mitk::LoggingBackend::Register(); double RMSmean = 0; for (std::size_t i = 0; i < m_RMSValues.size(); ++i) { MITK_INFO << "RMS at " << this->m_FilenameVector.at(i) << ": " << m_RMSValues.at(i); RMSmean += m_RMSValues.at(i); } RMSmean /= m_RMSValues.size(); MITK_INFO << "RMS mean over " << m_RMSValues.size() << " values: " << RMSmean; mitk::DataNode::Pointer newNode = mitk::DataNode::New(); newNode->SetName("Tracking Results"); newNode->SetData(this->m_MeanPoints); this->GetDataStorage()->Add(newNode); std::vector results5cmDistances; if (m_Controls->m_mediumVolume->isChecked()) mitk::HummelProtocolEvaluation::Evaluate5cmDistances(m_MeanPoints, mitk::HummelProtocolEvaluation::medium, results5cmDistances); else if (m_Controls->m_smallVolume->isChecked()) mitk::HummelProtocolEvaluation::Evaluate5cmDistances(m_MeanPoints, mitk::HummelProtocolEvaluation::small, results5cmDistances); else if (m_Controls->m_standardVolume->isChecked()) mitk::HummelProtocolEvaluation::Evaluate5cmDistances(m_MeanPoints, mitk::HummelProtocolEvaluation::standard, results5cmDistances); } void QmitkIGTTrackingSemiAutomaticMeasurementView::CreateQtPartControl(QWidget *parent) { // build up qt view, unless already done if (!m_Controls) { // create GUI widgets from the Qt Designer's .ui file m_Controls = new Ui::QmitkIGTTrackingSemiAutomaticMeasurementViewControls; m_Controls->setupUi(parent); //buttons connect(m_Controls->m_LoadMeasurementToolStorage, SIGNAL(clicked()), this, SLOT(OnLoadMeasurementStorage())); connect(m_Controls->m_LoadReferenceToolStorage, SIGNAL(clicked()), this, SLOT(OnLoadReferenceStorage())); connect(m_Controls->m_StartTracking, SIGNAL(clicked()), this, SLOT(OnStartTracking())); connect(m_Controls->m_LoadList, SIGNAL(clicked()), this, SLOT(OnMeasurementLoadFile())); connect(m_Controls->m_StartNextMeasurement, SIGNAL(clicked()), this, SLOT(StartNextMeasurement())); connect(m_Controls->m_ReapeatLastMeasurement, SIGNAL(clicked()), this, SLOT(RepeatLastMeasurement())); connect(m_Controls->m_SetReference, SIGNAL(clicked()), this, SLOT(OnSetReference())); connect(m_Controls->m_UseReferenceTrackingSystem, SIGNAL(toggled(bool)), this, SLOT(OnUseReferenceToggled(bool))); connect(m_Controls->m_CreateResults, SIGNAL(clicked()), this, SLOT(CreateResults())); //event filter qApp->installEventFilter(this); //timers connect(m_Timer, SIGNAL(timeout()), this, SLOT(UpdateTimer())); } //initialize some view m_Controls->m_StopTracking->setEnabled(false); } -void QmitkIGTTrackingSemiAutomaticMeasurementView::MultiWidgetAvailable(QmitkAbstractMultiWidget &multiWidget) -{ - m_MultiWidget = dynamic_cast(&multiWidget); -} - -void QmitkIGTTrackingSemiAutomaticMeasurementView::MultiWidgetNotAvailable() -{ - m_MultiWidget = nullptr; -} - void QmitkIGTTrackingSemiAutomaticMeasurementView::OnUseReferenceToggled(bool state) { if (state) { m_Controls->m_ReferenceBox->setEnabled(true); m_Controls->m_SetReference->setEnabled(true); } else { m_Controls->m_ReferenceBox->setEnabled(false); m_Controls->m_SetReference->setEnabled(false); } } mitk::NavigationToolStorage::Pointer QmitkIGTTrackingSemiAutomaticMeasurementView::ReadStorage(std::string file) { mitk::NavigationToolStorage::Pointer returnValue; //initialize tool storage returnValue = mitk::NavigationToolStorage::New(); //read tool storage from disk mitk::NavigationToolStorageDeserializer::Pointer myDeserializer = mitk::NavigationToolStorageDeserializer::New(GetDataStorage()); returnValue = myDeserializer->Deserialize(file); if (returnValue.IsNull()) { QMessageBox msgBox; msgBox.setText(myDeserializer->GetErrorMessage().c_str()); msgBox.exec(); returnValue = nullptr; } return returnValue; } void QmitkIGTTrackingSemiAutomaticMeasurementView::OnSetReference() { //initialize reference m_ReferenceStartPositions = std::vector(); m_ReferenceTrackingDeviceSource->Update(); QString Label = "Positions At Start: "; for (unsigned int i = 0; i < m_ReferenceTrackingDeviceSource->GetNumberOfOutputs(); ++i) { mitk::Point3D position = m_ReferenceTrackingDeviceSource->GetOutput(i)->GetPosition(); Label = Label + "Tool" + QString::number(i) + ":[" + QString::number(position[0]) + ":" + QString::number(position[1]) + ":" + QString::number(position[1]) + "] "; m_ReferenceStartPositions.push_back(position); } m_Controls->m_ReferencePosAtStart->setText(Label); } void QmitkIGTTrackingSemiAutomaticMeasurementView::OnLoadMeasurementStorage() { //read in filename QString filename = QFileDialog::getOpenFileName(nullptr, tr("Open Toolfile"), "/", tr("All Files (*.*)")); if (filename.isNull()) return; m_MeasurementStorage = ReadStorage(filename.toStdString()); //update label Poco::Path myPath = Poco::Path(filename.toStdString()); //use this to seperate filename from path QString toolLabel = QString("Tool Storage: ") + QString::number(m_MeasurementStorage->GetToolCount()) + " Tools from " + myPath.getFileName().c_str(); m_Controls->m_MeasurementToolStorageLabel->setText(toolLabel); //update status widget m_Controls->m_ToolStatusWidget->RemoveStatusLabels(); m_Controls->m_ToolStatusWidget->PreShowTools(m_MeasurementStorage); } void QmitkIGTTrackingSemiAutomaticMeasurementView::OnLoadReferenceStorage() { //read in filename static QString oldFile; if (oldFile.isNull()) oldFile = "/"; QString filename = QFileDialog::getOpenFileName(nullptr, tr("Open Toolfile"), oldFile, tr("All Files (*.*)")); if (filename.isNull()) return; oldFile = filename; m_ReferenceStorage = ReadStorage(filename.toStdString()); //update label Poco::Path myPath = Poco::Path(filename.toStdString()); //use this to seperate filename from path QString toolLabel = QString("Tool Storage: ") + QString::number(m_ReferenceStorage->GetToolCount()) + " Tools from " + myPath.getFileName().c_str(); m_Controls->m_ReferenceToolStorageLabel->setText(toolLabel); } void QmitkIGTTrackingSemiAutomaticMeasurementView::OnStartTracking() { //check if everything is ready to start tracking if (m_MeasurementStorage.IsNull()) { MessageBox("Error: No measurement tools loaded yet!"); return; } else if (m_ReferenceStorage.IsNull() && m_Controls->m_UseReferenceTrackingSystem->isChecked()) { MessageBox("Error: No refernce tools loaded yet!"); return; } else if (m_MeasurementStorage->GetToolCount() == 0) { MessageBox("Error: No way to track without tools!"); return; } else if (m_Controls->m_UseReferenceTrackingSystem->isChecked() && (m_ReferenceStorage->GetToolCount() == 0)) { MessageBox("Error: No way to track without tools!"); return; } //build the first IGT pipeline (MEASUREMENT) mitk::TrackingDeviceSourceConfigurator::Pointer myTrackingDeviceSourceFactory1 = mitk::TrackingDeviceSourceConfigurator::New(this->m_MeasurementStorage, this->m_Controls->m_MeasurementTrackingDeviceConfigurationWidget->GetTrackingDevice()); m_MeasurementTrackingDeviceSource = myTrackingDeviceSourceFactory1->CreateTrackingDeviceSource(this->m_MeasurementToolVisualizationFilter); if (m_MeasurementTrackingDeviceSource.IsNull()) { MessageBox(myTrackingDeviceSourceFactory1->GetErrorMessage()); return; } //connect the tool visualization widget for (unsigned int i = 0; i < m_MeasurementTrackingDeviceSource->GetNumberOfOutputs(); ++i) { m_Controls->m_ToolStatusWidget->AddNavigationData(m_MeasurementTrackingDeviceSource->GetOutput(i)); m_EvaluationFilter->SetInput(i, m_MeasurementTrackingDeviceSource->GetOutput(i)); } m_Controls->m_ToolStatusWidget->ShowStatusLabels(); m_Controls->m_ToolStatusWidget->SetShowPositions(true); m_Controls->m_ToolStatusWidget->SetShowQuaternions(true); //build the second IGT pipeline (REFERENCE) if (m_Controls->m_UseReferenceTrackingSystem->isChecked()) { mitk::TrackingDeviceSourceConfigurator::Pointer myTrackingDeviceSourceFactory2 = mitk::TrackingDeviceSourceConfigurator::New(this->m_ReferenceStorage, this->m_Controls->m_ReferenceDeviceConfigurationWidget->GetTrackingDevice()); m_ReferenceTrackingDeviceSource = myTrackingDeviceSourceFactory2->CreateTrackingDeviceSource(); if (m_ReferenceTrackingDeviceSource.IsNull()) { MessageBox(myTrackingDeviceSourceFactory2->GetErrorMessage()); return; } } //initialize tracking try { m_MeasurementTrackingDeviceSource->Connect(); m_MeasurementTrackingDeviceSource->StartTracking(); if (m_Controls->m_UseReferenceTrackingSystem->isChecked()) { m_ReferenceTrackingDeviceSource->Connect(); m_ReferenceTrackingDeviceSource->StartTracking(); } } catch (...) { MessageBox("Error while starting the tracking device!"); return; } //set reference if (m_Controls->m_UseReferenceTrackingSystem->isChecked()) OnSetReference(); //start timer m_Timer->start(1000 / (m_Controls->m_SamplingRate->value())); m_Controls->m_StartTracking->setEnabled(false); m_Controls->m_StartTracking->setEnabled(true); m_tracking = true; } void QmitkIGTTrackingSemiAutomaticMeasurementView::OnStopTracking() { if (this->m_logging) FinishMeasurement(); m_MeasurementTrackingDeviceSource->Disconnect(); m_MeasurementTrackingDeviceSource->StopTracking(); if (m_Controls->m_UseReferenceTrackingSystem->isChecked()) { m_ReferenceTrackingDeviceSource->Disconnect(); m_ReferenceTrackingDeviceSource->StopTracking(); } m_Timer->stop(); m_Controls->m_StartTracking->setEnabled(true); m_Controls->m_StartTracking->setEnabled(false); m_tracking = false; } void QmitkIGTTrackingSemiAutomaticMeasurementView::OnMeasurementLoadFile() { m_FilenameVector = std::vector(); m_FilenameVector.clear(); m_NextFile = 0; //read in filename QString filename = QFileDialog::getOpenFileName(nullptr, tr("Open Measurement Filename List"), "/", tr("All Files (*.*)")); if (filename.isNull()) return; //define own locale std::locale C("C"); setlocale(LC_ALL, "C"); //read file std::ifstream file; file.open(filename.toStdString().c_str(), std::ios::in); if (file.good()) { //read out file file.seekg(0L, std::ios::beg); // move to begin of file while (!file.eof()) { std::string buffer; std::getline(file, buffer); // read out file line by line if (buffer.size() > 0) m_FilenameVector.push_back(buffer); } } //fill list at GUI m_Controls->m_MeasurementList->clear(); for (unsigned int i = 0; i < m_FilenameVector.size(); i++) { new QListWidgetItem(tr(m_FilenameVector.at(i).c_str()), m_Controls->m_MeasurementList); } //update label next measurement std::stringstream label; label << "Next Measurement: " << m_FilenameVector.at(0); m_Controls->m_NextMeasurement->setText(label.str().c_str()); //reset results files m_MeanPoints = mitk::PointSet::New(); m_RMSValues = std::vector(); m_EvaluationFilter = mitk::NavigationDataEvaluationFilter::New(); if (m_MeasurementToolVisualizationFilter.IsNotNull()) m_EvaluationFilter->SetInput(0, m_MeasurementToolVisualizationFilter->GetOutput(0)); } void QmitkIGTTrackingSemiAutomaticMeasurementView::UpdateTimer() { if (m_EvaluationFilter.IsNotNull() && m_logging) m_EvaluationFilter->Update(); else m_MeasurementToolVisualizationFilter->Update(); m_Controls->m_ToolStatusWidget->Refresh(); //update reference if (m_Controls->m_UseReferenceTrackingSystem->isChecked()) { m_ReferenceTrackingDeviceSource->Update(); QString Label = "Current Positions: "; bool distanceThresholdExceeded = false; for (unsigned int i = 0; i < m_ReferenceTrackingDeviceSource->GetNumberOfOutputs(); ++i) { mitk::Point3D position = m_ReferenceTrackingDeviceSource->GetOutput(i)->GetPosition(); Label = Label + "Tool" + QString::number(i) + ":[" + QString::number(position[0]) + ":" + QString::number(position[1]) + ":" + QString::number(position[1]) + "] "; if (position.EuclideanDistanceTo(m_ReferenceStartPositions.at(i)) > m_Controls->m_ReferenceThreshold->value()) distanceThresholdExceeded = true; } m_Controls->m_ReferenceCurrentPos->setText(Label); if (distanceThresholdExceeded) { m_Controls->m_ReferenceOK->setText("NOT OK!"); m_referenceValid = false; } else { m_Controls->m_ReferenceOK->setText("OK"); m_referenceValid = true; } } //update logging if (m_logging) { //check for missing objects if (m_MeasurementLoggingFilterXML.IsNull() || m_MeasurementLoggingFilterCSV.IsNull() ) { return; } //log/measure m_MeasurementLoggingFilterXML->Update(); m_MeasurementLoggingFilterCSV->Update(); if (m_Controls->m_UseReferenceTrackingSystem->isChecked() && m_ReferenceLoggingFilterXML.IsNotNull() && m_ReferenceLoggingFilterCSV.IsNotNull()) { m_ReferenceLoggingFilterXML->Update(); m_ReferenceLoggingFilterCSV->Update(); } m_loggedFrames++; LogAdditionalCSVFile(); //check if all frames are logged ... if yes finish the measurement if (m_loggedFrames > m_Controls->m_SamplesPerMeasurement->value()) { FinishMeasurement(); } //update logging label QString loggingLabel = "Collected Samples: " + QString::number(m_loggedFrames); m_Controls->m_CollectedSamples->setText(loggingLabel); } } void QmitkIGTTrackingSemiAutomaticMeasurementView::StartNextMeasurement() { if (this->m_NextFile >= static_cast(m_FilenameVector.size())) { MessageBox("Last Measurement reached!"); return; } m_loggedFrames = 0; m_logging = true; //check if directory exists, if not create one Poco::File myPath(std::string(m_Controls->m_OutputPath->text().toUtf8()).c_str()); if (!myPath.exists()) myPath.createDirectory(); QString LogFileName = m_Controls->m_OutputPath->text() + QString(m_FilenameVector.at(m_NextFile).c_str()) + ".log"; mitk::LoggingBackend::Unregister(); mitk::LoggingBackend::SetLogFile(LogFileName.toStdString().c_str()); mitk::LoggingBackend::Register(); //initialize logging filters m_MeasurementLoggingFilterXML = mitk::NavigationDataRecorderDeprecated::New(); m_MeasurementLoggingFilterXML->SetRecordingMode(mitk::NavigationDataRecorderDeprecated::NormalFile); m_MeasurementLoggingFilterCSV = mitk::NavigationDataRecorderDeprecated::New(); m_MeasurementLoggingFilterCSV->SetRecordingMode(mitk::NavigationDataRecorderDeprecated::NormalFile); m_MeasurementLoggingFilterXML->SetOutputFormat(mitk::NavigationDataRecorderDeprecated::xml); m_MeasurementLoggingFilterCSV->SetOutputFormat(mitk::NavigationDataRecorderDeprecated::csv); QString MeasurementFilenameXML = m_Controls->m_OutputPath->text() + QString(m_FilenameVector.at(m_NextFile).c_str()) + ".xml"; QString MeasurementFilenameCSV = m_Controls->m_OutputPath->text() + QString(m_FilenameVector.at(m_NextFile).c_str()) + ".csv"; m_MeasurementLoggingFilterXML->SetFileName(MeasurementFilenameXML.toStdString()); m_MeasurementLoggingFilterCSV->SetFileName(MeasurementFilenameCSV.toStdString()); m_MeasurementLoggingFilterXML->SetRecordCountLimit(m_Controls->m_SamplesPerMeasurement->value()); m_MeasurementLoggingFilterCSV->SetRecordCountLimit(m_Controls->m_SamplesPerMeasurement->value()); if (m_Controls->m_UseReferenceTrackingSystem->isChecked()) { m_ReferenceLoggingFilterXML = mitk::NavigationDataRecorderDeprecated::New(); m_ReferenceLoggingFilterXML->SetRecordingMode(mitk::NavigationDataRecorderDeprecated::NormalFile); m_ReferenceLoggingFilterCSV = mitk::NavigationDataRecorderDeprecated::New(); m_ReferenceLoggingFilterCSV->SetRecordingMode(mitk::NavigationDataRecorderDeprecated::NormalFile); m_ReferenceLoggingFilterXML->SetOutputFormat(mitk::NavigationDataRecorderDeprecated::xml); m_ReferenceLoggingFilterCSV->SetOutputFormat(mitk::NavigationDataRecorderDeprecated::csv); QString ReferenceFilenameXML = m_Controls->m_OutputPath->text() + "Reference_" + QString(m_FilenameVector.at(m_NextFile).c_str()) + ".xml"; QString ReferenceFilenameCSV = m_Controls->m_OutputPath->text() + "Reference_" + QString(m_FilenameVector.at(m_NextFile).c_str()) + ".csv"; m_ReferenceLoggingFilterXML->SetFileName(ReferenceFilenameXML.toStdString()); m_ReferenceLoggingFilterCSV->SetFileName(ReferenceFilenameCSV.toStdString()); m_ReferenceLoggingFilterXML->SetRecordCountLimit(m_Controls->m_SamplesPerMeasurement->value()); m_ReferenceLoggingFilterCSV->SetRecordCountLimit(m_Controls->m_SamplesPerMeasurement->value()); } //start additional csv logging StartLoggingAdditionalCSVFile(m_FilenameVector.at(m_NextFile)); //connect filter for (unsigned int i = 0; i < m_MeasurementToolVisualizationFilter->GetNumberOfOutputs(); ++i) { m_MeasurementLoggingFilterXML->AddNavigationData(m_MeasurementToolVisualizationFilter->GetOutput(i)); m_MeasurementLoggingFilterCSV->AddNavigationData(m_MeasurementToolVisualizationFilter->GetOutput(i)); } if (m_Controls->m_UseReferenceTrackingSystem->isChecked()) for (unsigned int i = 0; i < m_ReferenceTrackingDeviceSource->GetNumberOfOutputs(); ++i) { m_ReferenceLoggingFilterXML->AddNavigationData(m_ReferenceTrackingDeviceSource->GetOutput(i)); m_ReferenceLoggingFilterCSV->AddNavigationData(m_ReferenceTrackingDeviceSource->GetOutput(i)); } //start filter m_MeasurementLoggingFilterXML->StartRecording(); m_MeasurementLoggingFilterCSV->StartRecording(); if (m_Controls->m_UseReferenceTrackingSystem->isChecked()) { m_ReferenceLoggingFilterXML->StartRecording(); m_ReferenceLoggingFilterCSV->StartRecording(); } //disable all buttons DisableAllButtons(); //update label next measurement std::stringstream label; if ((m_NextFile + 1) >= static_cast(m_FilenameVector.size())) label << "Next Measurement: "; else label << "Next Measurement: " << m_FilenameVector.at(m_NextFile + 1); m_Controls->m_NextMeasurement->setText(label.str().c_str()); //update label last measurement std::stringstream label2; label2 << "Last Measurement: " << m_FilenameVector.at(m_NextFile); m_Controls->m_LastMeasurement->setText(label2.str().c_str()); m_NextFile++; } void QmitkIGTTrackingSemiAutomaticMeasurementView::RepeatLastMeasurement() { m_NextFile--; StartNextMeasurement(); } void QmitkIGTTrackingSemiAutomaticMeasurementView::MessageBox(std::string s) { QMessageBox msgBox; msgBox.setText(s.c_str()); msgBox.exec(); } void QmitkIGTTrackingSemiAutomaticMeasurementView::DisableAllButtons() { m_Controls->m_LoadList->setEnabled(false); m_Controls->m_StartNextMeasurement->setEnabled(false); m_Controls->m_ReapeatLastMeasurement->setEnabled(false); m_Controls->m_SamplingRate->setEnabled(false); m_Controls->m_SamplesPerMeasurement->setEnabled(false); m_Controls->m_ReferenceThreshold->setEnabled(false); } void QmitkIGTTrackingSemiAutomaticMeasurementView::EnableAllButtons() { m_Controls->m_LoadList->setEnabled(true); m_Controls->m_StartNextMeasurement->setEnabled(true); m_Controls->m_ReapeatLastMeasurement->setEnabled(true); m_Controls->m_SamplingRate->setEnabled(true); m_Controls->m_SamplesPerMeasurement->setEnabled(true); m_Controls->m_ReferenceThreshold->setEnabled(true); } void QmitkIGTTrackingSemiAutomaticMeasurementView::FinishMeasurement() { m_logging = false; m_MeasurementLoggingFilterXML->StopRecording(); m_MeasurementLoggingFilterCSV->StopRecording(); if (m_Controls->m_UseReferenceTrackingSystem->isChecked()) { m_ReferenceLoggingFilterXML->StopRecording(); m_ReferenceLoggingFilterCSV->StopRecording(); } StopLoggingAdditionalCSVFile(); int id = m_NextFile - 1; mitk::Point3D positionMean = m_EvaluationFilter->GetPositionMean(0); MITK_INFO << "Evaluated " << m_EvaluationFilter->GetNumberOfAnalysedNavigationData(0) << " samples."; double rms = m_EvaluationFilter->GetPositionErrorRMS(0); MITK_INFO << "RMS: " << rms; MITK_INFO << "Position Mean: " << positionMean; m_MeanPoints->SetPoint(id, positionMean); if (static_cast(m_RMSValues.size()) <= id) m_RMSValues.push_back(rms); else m_RMSValues[id] = rms; m_EvaluationFilter->ResetStatistic(); EnableAllButtons(); } void QmitkIGTTrackingSemiAutomaticMeasurementView::StartLoggingAdditionalCSVFile(std::string filePostfix) { //write logfile header QString header = "Nr;MITK_Time;Valid_Reference;"; QString tool = QString("MeasureTool_") + QString(m_MeasurementTrackingDeviceSource->GetOutput(0)->GetName()); header = header + tool + "[x];" + tool + "[y];" + tool + "[z];" + tool + "[qx];" + tool + "[qy];" + tool + "[qz];" + tool + "[qr]\n"; //open logfile and write header m_logFileCSV.open(std::string(m_Controls->m_OutputPath->text().toUtf8()).append("/LogFileCombined").append(filePostfix.c_str()).append(".csv").c_str(), std::ios::out); m_logFileCSV << header.toStdString().c_str(); } void QmitkIGTTrackingSemiAutomaticMeasurementView::LogAdditionalCSVFile() { mitk::Point3D pos = m_MeasurementTrackingDeviceSource->GetOutput(0)->GetPosition(); mitk::Quaternion rot = m_MeasurementTrackingDeviceSource->GetOutput(0)->GetOrientation(); std::string valid = ""; if (m_referenceValid) valid = "true"; else valid = "false"; std::stringstream timestamp; timestamp << m_MeasurementTrackingDeviceSource->GetOutput(0)->GetTimeStamp(); QString dataSet = QString::number(m_loggedFrames) + ";" + QString(timestamp.str().c_str()) + ";" + QString(valid.c_str()) + ";" + QString::number(pos[0]) + ";" + QString::number(pos[1]) + ";" + QString::number(pos[2]) + ";" + QString::number(rot.x()) + ";" + QString::number(rot.y()) + ";" + QString::number(rot.z()) + ";" + QString::number(rot.r()) + "\n"; m_logFileCSV << dataSet.toStdString(); } void QmitkIGTTrackingSemiAutomaticMeasurementView::StopLoggingAdditionalCSVFile() { m_logFileCSV.close(); } bool QmitkIGTTrackingSemiAutomaticMeasurementView::eventFilter(QObject *, QEvent *ev) { if (ev->type() == QEvent::KeyPress) { QKeyEvent *k = (QKeyEvent *)ev; bool down = k->key() == 16777239; if (down && m_tracking && !m_logging) StartNextMeasurement(); } return false; } diff --git a/Plugins/org.mitk.gui.qt.igt.app.hummelprotocolmeasurements/src/internal/QmitkIGTTrackingSemiAutomaticMeasurementView.h b/Plugins/org.mitk.gui.qt.igt.app.hummelprotocolmeasurements/src/internal/QmitkIGTTrackingSemiAutomaticMeasurementView.h index f2de6c39d5..44ccea0f48 100644 --- a/Plugins/org.mitk.gui.qt.igt.app.hummelprotocolmeasurements/src/internal/QmitkIGTTrackingSemiAutomaticMeasurementView.h +++ b/Plugins/org.mitk.gui.qt.igt.app.hummelprotocolmeasurements/src/internal/QmitkIGTTrackingSemiAutomaticMeasurementView.h @@ -1,129 +1,120 @@ /*============================================================================ 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 QmitkIGTTrackingSemiAutomaticMeasurementView_h #define QmitkIGTTrackingSemiAutomaticMeasurementView_h #include -#include -#include +#include //QT #include //MITK #include #include #include #include #include #include "ui_QmitkIGTTrackingSemiAutomaticMeasurementViewControls.h" /*! \brief QmitkIGTTrackingSemiAutomaticMeasurementView \warning This application module is not yet documented. Use "svn blame/praise/annotate" and ask the author to provide basic documentation. - \sa QmitkFunctionality - \ingroup Functionalities */ -class QmitkIGTTrackingSemiAutomaticMeasurementView : public QmitkFunctionality +class QmitkIGTTrackingSemiAutomaticMeasurementView : 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; QmitkIGTTrackingSemiAutomaticMeasurementView(); ~QmitkIGTTrackingSemiAutomaticMeasurementView() override; void CreateQtPartControl(QWidget *parent) override; + void SetFocus() override {} - virtual void MultiWidgetAvailable(QmitkAbstractMultiWidget &multiWidget) override; - virtual void MultiWidgetNotAvailable() override; - - protected slots: +protected slots: void OnLoadMeasurementStorage(); void OnLoadReferenceStorage(); void OnStartTracking(); void OnStopTracking(); void OnMeasurementLoadFile(); void OnSetReference(); void StartNextMeasurement(); void RepeatLastMeasurement(); void UpdateTimer(); void CreateResults(); void OnUseReferenceToggled(bool state); protected: Ui::QmitkIGTTrackingSemiAutomaticMeasurementViewControls* m_Controls; - QmitkStdMultiWidget* m_MultiWidget; - //the tool storages mitk::NavigationToolStorage::Pointer m_MeasurementStorage; mitk::NavigationToolStorage::Pointer m_ReferenceStorage; //members for the filter pipeline mitk::TrackingDeviceSource::Pointer m_MeasurementTrackingDeviceSource; mitk::NavigationDataObjectVisualizationFilter::Pointer m_MeasurementToolVisualizationFilter; mitk::NavigationDataRecorderDeprecated::Pointer m_MeasurementLoggingFilterXML; mitk::NavigationDataRecorderDeprecated::Pointer m_MeasurementLoggingFilterCSV; mitk::TrackingDeviceSource::Pointer m_ReferenceTrackingDeviceSource; mitk::NavigationDataRecorderDeprecated::Pointer m_ReferenceLoggingFilterXML; mitk::NavigationDataRecorderDeprecated::Pointer m_ReferenceLoggingFilterCSV; //members for file name list std::vector m_FilenameVector; int m_NextFile; //help methods mitk::NavigationToolStorage::Pointer ReadStorage(std::string file); void MessageBox(std::string s); void DisableAllButtons(); void EnableAllButtons(); void FinishMeasurement(); void StartLoggingAdditionalCSVFile(std::string filePostfix); void LogAdditionalCSVFile(); void StopLoggingAdditionalCSVFile(); //timer QTimer* m_Timer; //memebers for reference checking std::vector m_ReferenceStartPositions; bool m_referenceValid; //logging members int m_loggedFrames; bool m_logging; std::fstream m_logFileCSV; //event filter for key presses bool eventFilter(QObject *obj, QEvent *ev) override; //results members mitk::PointSet::Pointer m_MeanPoints; std::vector m_RMSValues; mitk::NavigationDataEvaluationFilter::Pointer m_EvaluationFilter; bool m_tracking; }; #endif // _QMITKIGTTRACKINGSEMIAUTOMATICMEASUREMENTVIEW_H_INCLUDED diff --git a/Plugins/org.mitk.gui.qt.igt.app.ultrasoundtrackingnavigation/src/internal/QmitkUltrasoundCalibration.h b/Plugins/org.mitk.gui.qt.igt.app.ultrasoundtrackingnavigation/src/internal/QmitkUltrasoundCalibration.h index d351794e7d..63f779b670 100644 --- a/Plugins/org.mitk.gui.qt.igt.app.ultrasoundtrackingnavigation/src/internal/QmitkUltrasoundCalibration.h +++ b/Plugins/org.mitk.gui.qt.igt.app.ultrasoundtrackingnavigation/src/internal/QmitkUltrasoundCalibration.h @@ -1,384 +1,380 @@ /*============================================================================ 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 QmitkUltrasoundCalibration_h #define QmitkUltrasoundCalibration_h #include #include // MITK #include #include #include #include #include #include // Microservices #include "ui_QmitkUltrasoundCalibrationControls.h" #include #include #include #include /*! \brief QmitkUltrasoundCalibration \warning This view provides a simple calibration process. - \sa QmitkFunctionality \ingroup ${plugin_target}_internal */ class QmitkUltrasoundCalibration : 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: QmitkUltrasoundCalibration(); ~QmitkUltrasoundCalibration() override; static const std::string VIEW_ID; void CreateQtPartControl(QWidget *parent) override; void OnUSDepthChanged(const std::string &, const std::string &); protected slots: /** * \brief Triggered, whenever the user switches Tabs * */ void OnTabSwitch(int index); /** * \brief Triggered, when the user has clicked "select Devices". * */ void OnDeviceSelected(); void OnDeviceDeselected(); /** * \brief Triggered, when the user clicks "Add Point" * */ void OnAddCalibPoint(); /** * \brief Triggered, when the user clicks "Calibrate" * */ void OnCalibration(); /** * \brief Triggered, when the user clicks "Add Target Points". * * Adds an image point and an tracking point to their respective evaluation pointsets */ void OnAddEvalTargetPoint(); /** * \brief Triggered, when the user clicks "Add Point". * * Adds a projected point to the projected point evaluation set. */ void OnAddEvalProjectedPoint(); /** * \brief Triggered when the user clicks "Save Results" in the Evaluation tab. */ void OnSaveEvaluation(); /** * \brief Triggered when the user clicks "Save Calibration" in the Calibration tab. */ void OnSaveCalibration(); /** * \brief Triggered when the user clicks "Run Next Round". Also used as a reset mechanism. */ void OnReset(); /** * \brief Triggered in regular intervals by a timer, when live view is enabled. * */ void Update(); /** * \brief Freezes or unfreezes the image. */ void SwitchFreeze(); /** * */ void OnStartCalibrationProcess(); /** *\brief Method to use the PLUS-Toolkoit for Calibration of EchoTrack */ void OnStartPlusCalibration(); void OnStopPlusCalibration(); /** *\ brief Starts the Streaming of USImage and Navigation Data when PLUS is connected */ void OnStartStreaming(); void OnNewConnection(); /** \*brief Get the Calibration from the PLUS-Toolkit once Calibration with fCal is done */ void OnGetPlusCalibration(); /** \*brief Convert the recieved igtl::Matrix into an mitk::AffineTransform3D which can be used to calibrate the CombinedModality */ void ProcessPlusCalibration(igtl::Matrix4x4 &imageToTracker); void OnStreamingTimerTimeout(); /** * */ void OnStopCalibrationProcess(); void OnAddCurrentTipPositionToReferencePoints(); void OnStartVerification(); void OnAddCurrentTipPositionForVerification(); void OnDeviceServiceEvent(const ctkServiceEvent event); void OnFreezeClicked(); void OnAddSpacingPoint(); void OnCalculateSpacing(); /* * \brief load the configuration of the phantom fiducials which have to be saved as points in the sensor coordinate * system of the tracking sensor attached to the phantom */ void OnLoadPhantomConfiguration(); /* * \brief match the annotation pointset with the geometry of the phantom configuration */ void OnMatchAnnotationToPhantomConfiguration(); /* * \brief move the annotation pointset up */ void OnMovePhantomAnnotationsUp(); /* * \brief move the annotation pointset down */ void OnMovePhantomAnnotationsDown(); /* * \brief move the annotation pointset left */ void OnMovePhantomAnnotationsLeft(); /* * \brief move the annotation pointset right */ void OnMovePhantomAnnotationsRight(); /* * \brief rotate the annotation pointset right */ void OnRotatePhantomAnnotationsRight(); /* * \brief rotate the annotation pointset left */ void OnRotatePhantomAnnotationsLeft(); /* * \brief add a calibration point to be used for phantom based calibration */ void OnPhantomCalibPointsChanged(); /* * \brief perform phantom based calibration */ void OnPhantomBasedCalibration(); signals: /** * \brief used for thread seperation, the worker thread must not call OnNewConnection directly. * QT signals are thread safe and separate the threads */ void NewConnectionSignal(); protected: void SetFocus() override; - /// \brief called by QmitkFunctionality when DataManager's selection has changed void OnSelectionChanged(berry::IWorkbenchPart::Pointer source, const QList &nodes) override; void UpdatePhantomAnnotationPointVisualization(int index = -1); /*! \brief translate the annotated image feature m_CalibPoints image by the specified translation vector */ void TranslatePhantomAnnotations(double tx, double ty, double tz); /*! \brief rotate the annotated image feature m_CalibPoints image by the specified angle */ void RotatePhantomAnnotations(double angle); Ui::QmitkUltrasoundCalibrationControls m_Controls; /** * \brief Internal function that activates display of the needle path. */ void ShowNeedlePath(); /** * \brief Clears all member attributes which are holding intermediate results for the calibration. */ void ClearTemporaryMembers(); void OnPlusConnected(); /** * \brief The combined modality used for imaging and tracking. */ mitk::AbstractUltrasoundTrackerDevice::Pointer m_CombinedModality; /** * \brief NavigationDataSource used for tracking data. * This will be gotten by the combined modality. */ mitk::NavigationDataSource::Pointer m_Tracker; QTimer *m_Timer; mitk::DataNode::Pointer m_Node; mitk::DataNode::Pointer m_CalibNode; mitk::DataNode::Pointer m_WorldNode; // IGTL Servers and Devices needed for the communication with PLUS mitk::IGTLServer::Pointer m_USServer; mitk::IGTLMessageProvider::Pointer m_USMessageProvider; mitk::ImageToIGTLMessageFilter::Pointer m_USImageToIGTLMessageFilter; mitk::IGTLServer::Pointer m_TrackingServer; mitk::IGTLMessageProvider::Pointer m_TrackingMessageProvider; mitk::NavigationDataToIGTLMessageFilter::Pointer m_TrackingToIGTLMessageFilter; mitk::IGTLClient::Pointer m_TransformClient; mitk::IGTLDeviceSource::Pointer m_TransformDeviceSource; QTimer *m_StreamingTimer; unsigned long m_NewConnectionObserverTag; /** * \brief The current Ultrasound Image. */ mitk::Image::Pointer m_Image; /** * \brief Current point when the image was last frozen. */ mitk::Point3D m_FreezePoint; /** * \brief Pointset containing all tool points. */ mitk::PointSet::Pointer m_CalibPointsImage; /** * \brief Pointset containing corresponding points on the image. */ mitk::PointSet::Pointer m_CalibPointsTool; mitk::PointSet::Pointer m_PhantomConfigurationPointSet; ///< pointset holding the feature position of the phantom in tool coordinates /** * \brief Pointset containing Projected Points (aka "where we thought the needle was gonna land") */ mitk::PointSet::Pointer m_EvalPointsProjected; /** * \brief Pointset containing the evaluated points on the image. */ mitk::PointSet::Pointer m_EvalPointsImage; /** * \brief Pointset containing tracked evaluation points. */ mitk::PointSet::Pointer m_EvalPointsTool; /** * \brief Pointset containing tracked evaluation points. */ mitk::PointSet::Pointer m_VerificationReferencePoints; mitk::DataNode::Pointer m_VerificationReferencePointsDataNode; int m_currentPoint; std::vector m_allReferencePoints; std::vector m_allErrors; /** * \brief Creates a Pointset that projects the needle's path */ mitk::NeedleProjectionFilter::Pointer m_NeedleProjectionFilter; /** * \brief Total number of calibration points set. */ int m_CalibPointsCount; QString m_CurrentDepth; /** * \brief StatisticsRegarding Projection Accuracy. * (Compares m_EvalPointsProjected to m_EvalPointsImage) */ mitk::PointSetDifferenceStatisticsCalculator::Pointer m_ProjectionStatistics; /** * \brief StatisticsRegarding Evaluation Accuracy. * (Compares m_EvalPointsTool to m_EvalPointsImage) */ mitk::PointSetDifferenceStatisticsCalculator::Pointer m_EvaluationStatistics; /** * \brief StatisticsRegarding Calibration Accuracy. * (Compares m_CalibPointsTool to a transformed copy of m_CalibPointsImage). */ mitk::PointSetDifferenceStatisticsCalculator::Pointer m_CalibrationStatistics; /** * \brief Result of the Calibration. */ mitk::AffineTransform3D::Pointer m_Transformation; /** * This method is copied from PointSetModifier which is part of MBI. It should be replaced * by external method call as soon as this functionality will be available in MITK. */ vtkSmartPointer ConvertPointSetToVtkPolyData(mitk::PointSet::Pointer PointSet); double ComputeFRE(mitk::PointSet::Pointer imageFiducials, mitk::PointSet::Pointer realWorldFiducials, vtkSmartPointer transform = nullptr); void ApplyTransformToPointSet(mitk::PointSet::Pointer pointSet, vtkSmartPointer transform); mitk::PointSet::Pointer m_SpacingPoints; mitk::DataNode::Pointer m_SpacingNode; int m_SpacingPointsCount; private: mitk::MessageDelegate2 m_USDeviceChanged; }; #endif // UltrasoundCalibration_h diff --git a/Plugins/org.mitk.gui.qt.igt.app.ultrasoundtrackingnavigation/src/internal/USNavigation.h b/Plugins/org.mitk.gui.qt.igt.app.ultrasoundtrackingnavigation/src/internal/USNavigation.h index 807cca9712..681bd8a093 100644 --- a/Plugins/org.mitk.gui.qt.igt.app.ultrasoundtrackingnavigation/src/internal/USNavigation.h +++ b/Plugins/org.mitk.gui.qt.igt.app.ultrasoundtrackingnavigation/src/internal/USNavigation.h @@ -1,171 +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. ============================================================================*/ #ifndef USNavigation_h #define USNavigation_h // Blueberry, QMITK #include #include #include "ui_USNavigationControls.h" // QT #include #include // MITK #include #include #include #include #include #include #include /*! \brief USNavigation \warning This class is not yet documented. Use "git blame" and ask the author to provide basic documentation. - \sa QmitkFunctionality \ingroup ${plugin_target}_internal */ class USNavigation : 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; USNavigation(); virtual void CreateQtPartControl(QWidget *parent); protected slots: /** * \brief Triggered, when the user selects a device from either the list of USDevices or Tracking Devices */ //void OnClickDevices(); void OnDeviceSelected(); void OnDeviceDeselected(); /** * \brief Triggered, when the user has clicked "select Devices". */ void OnSelectDevices(); /** * \brief Triggered, when the user has clicked "Load Calibration". */ //void OnLoadCalibration(); /** * \brief */ void OnStartIntervention(); /** * \brief */ void OnFreeze(); /** * \brief */ void OnReset(); /** * \brief */ void OnNeedleViewToggle(); void OnZoneAdded(); /** * \brief */ void Update(); void UpdateMeters(); protected: mitk::NavigationToolStorage::Pointer m_ToolStorage; std::vector m_Zones; mitk::DataNode::Pointer m_USStream; bool m_Freeze; QString m_RangeMeterStyle; /** * \brief The CombinedModality used for imaging. */ mitk::USCombinedModality::Pointer m_USDevice; /** * \brief Temporary saving point for loaded calibration data. */ std::string m_LoadedCalibration; /** * \brief NavigationDataSource used for tracking data. */ mitk::NavigationDataSource::Pointer m_Tracker; mitk::NodeDisplacementFilter::Pointer m_ZoneFilter; mitk::NavigationDataSmoothingFilter::Pointer m_SmoothingFilter; mitk::CameraVisualization::Pointer m_CameraVis; /** * \brief Creates a Pointset that projects the needle's path */ mitk::NeedleProjectionFilter::Pointer m_NeedleProjectionFilter; /** * \brief Colors the given node according to the color selected in the "Edit Zone" section, names it correctly and adjusts it's size. */ void FormatZoneNode(mitk::DataNode::Pointer node, mitk::Point3D center); /** * \brief Sets up the RangeMeter Section of the Navigation by creating and initializing all necessary Progress Bars. */ void SetupProximityView(); QProgressBar* CreateRangeMeter(int i); void ResetRangeMeters(); std::vector< QProgressBar* > m_RangeMeters; virtual void SetFocus(); QTimer *m_Timer; QTimer *m_RangeMeterTimer; bool m_UpdateImage; bool m_IsNeedleViewActive; static const int MAXRANGE = 60; static const int WARNRANGE = 25; Ui::USNavigationControls m_Controls; bool m_ImageAlreadySetToNode; }; #endif // USNavigation_h diff --git a/Plugins/org.mitk.gui.qt.igtexamples/src/internal/OpenIGTLinkPlugin.h b/Plugins/org.mitk.gui.qt.igtexamples/src/internal/OpenIGTLinkPlugin.h index d32c533518..f4f94bf978 100644 --- a/Plugins/org.mitk.gui.qt.igtexamples/src/internal/OpenIGTLinkPlugin.h +++ b/Plugins/org.mitk.gui.qt.igtexamples/src/internal/OpenIGTLinkPlugin.h @@ -1,104 +1,101 @@ /*============================================================================ 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 OpenIGTLinkPlugin_h #define OpenIGTLinkPlugin_h #include #include #include "ui_OpenIGTLinkPluginControls.h" #include "qtimer.h" //OIGTL #include "mitkIGTLClient.h" #include "mitkIGTL2DImageDeviceSource.h" #include "mitkIGTL3DImageDeviceSource.h" #include "mitkIGTLTrackingDataDeviceSource.h" //mitk #include "mitkNavigationDataObjectVisualizationFilter.h" #include "mitkIGTLMessageToNavigationDataFilter.h" #include "mitkIGTLMessageToUSImageFilter.h" #include #include //vtk #include /** \brief OpenIGTLinkPlugin \warning This class is not yet documented. Use "git blame" and ask the author to provide basic documentation. \sa QmitkAbstractView \ingroup ${plugin_target}_internal */ class OpenIGTLinkPlugin : 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; protected slots: void ConnectButtonClicked(); void ReceivingButtonClicked(); void UpdatePipeline(); protected: enum State{ IDLE, CONNECTED, RECEIVING }; void CreateQtPartControl(QWidget *parent) override; void SetFocus() override; - /// \brief called by QmitkFunctionality when DataManager's selection has changed void OnSelectionChanged(berry::IWorkbenchPart::Pointer source, const QList& nodes) override; Ui::OpenIGTLinkPluginControls m_Controls; mitk::IGTL2DImageDeviceSource::Pointer m_IGTL2DImageDeviceSource; mitk::IGTL3DImageDeviceSource::Pointer m_IGTL3DImageDeviceSource; mitk::IGTLTrackingDataDeviceSource::Pointer m_IGTLTransformDeviceSource; mitk::IGTLClient::Pointer m_IGTLClient; QTimer m_Timer; mitk::IGTLMessageToNavigationDataFilter::Pointer m_IGTLMessageToNavigationDataFilter; mitk::NavigationDataObjectVisualizationFilter::Pointer m_NavigationDataObjectVisualizationFilter; mitk::IGTLMessageToUSImageFilter::Pointer m_ImageFilter3D; mitk::IGTLMessageToUSImageFilter::Pointer m_ImageFilter2D; mitk::DataNode::Pointer m_Image2dNode; private: void StateChanged(State newState); State m_State; }; #endif // OpenIGTLinkPlugin_h diff --git a/Plugins/org.mitk.gui.qt.igttracking/src/internal/QmitkIGTFiducialRegistration.h b/Plugins/org.mitk.gui.qt.igttracking/src/internal/QmitkIGTFiducialRegistration.h index e04e4e4294..214c835c6c 100644 --- a/Plugins/org.mitk.gui.qt.igttracking/src/internal/QmitkIGTFiducialRegistration.h +++ b/Plugins/org.mitk.gui.qt.igttracking/src/internal/QmitkIGTFiducialRegistration.h @@ -1,68 +1,65 @@ /*============================================================================ 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 QmitkIGTFiducialRegistration_h #define QmitkIGTFiducialRegistration_h #include #include #include "ui_QmitkIGTFiducialRegistrationControls.h" #include /*! \brief QmitkIGTFiducialRegistration -\sa QmitkFunctionality \ingroup ${plugin_target}_internal */ class QmitkIGTFiducialRegistration : 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: void SetFocus() override; static const std::string VIEW_ID; void CreateQtPartControl(QWidget *parent) override; QmitkIGTFiducialRegistration(); ~QmitkIGTFiducialRegistration() override; public slots: protected slots: void PointerSelectionChanged(); void ImageSelectionChanged(); protected: void InitializeRegistration(); Ui::IGTFiducialRegistrationControls m_Controls; mitk::NavigationData::Pointer m_TrackingPointer; }; #endif // IGTFiducialRegistration_h diff --git a/Plugins/org.mitk.gui.qt.matchpoint.algorithm.browser/src/internal/QmitkMatchPointBrowser.h b/Plugins/org.mitk.gui.qt.matchpoint.algorithm.browser/src/internal/QmitkMatchPointBrowser.h index 1e410ac03a..9aaab74c8c 100644 --- a/Plugins/org.mitk.gui.qt.matchpoint.algorithm.browser/src/internal/QmitkMatchPointBrowser.h +++ b/Plugins/org.mitk.gui.qt.matchpoint.algorithm.browser/src/internal/QmitkMatchPointBrowser.h @@ -1,126 +1,125 @@ /*============================================================================ 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 __Q_MITK_MATCHPOINT_H #define __Q_MITK_MATCHPOINT_H #include #include #include #include #include //QT #include // MatchPoint #include #include #include #include "ui_QmitkMatchPointBrowserControls.h" #include "QmitkMAPAlgorithmModel.h" #include "QmitkAlgorithmListModel.h" #include "mitkAlgorithmInfoSelectionProvider.h" /*! \brief MatchPoint \warning This class is not yet documented. Use "git blame" and ask the author to provide basic documentation. -\sa QmitkFunctionality \ingroup ${plugin_target}_internal */ class QmitkMatchPointBrowser : 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; /** * Creates smartpointer typedefs */ berryObjectMacro(QmitkMatchPointBrowser); QmitkMatchPointBrowser(); ~QmitkMatchPointBrowser() override; /** * \brief Called by the framework to indicate that the preferences have changed. * \param prefs not used, as we call RetrievePreferenceValues(). */ void OnPreferencesChanged(const berry::IBerryPreferences* prefs) override; protected slots: /** * @brief Connect all GUI elements to its corresponding slots */ virtual void CreateConnections(); /// \brief Called when the user clicks the GUI button void OnSearchFolderButtonPushed(); void OnAlgoListSelectionChanged(const QModelIndex&); void OnSearchChanged(const QString&); protected: void CreateQtPartControl(QWidget* parent) override; void SetFocus() override; Ui::MatchPointBrowserControls m_Controls; //! [Qt Selection Provider] /** @brief this pointer holds the selection provider*/ mitk::AlgorithmInfoSelectionProvider::Pointer m_SelectionProvider; //! [Qt Selection Provider] private: void SetSelectionProvider() override; void Error(QString msg); /** * \brief Called on startup and by OnPreferencesChanged to load all * preferences except the temporary folder into member variables. */ void RetrieveAndStorePreferenceValues(); void OnInvalidDeploymentEvent(const ::itk::Object *, const itk::EventObject &event); void OnValidDeploymentEvent(const ::itk::Object *, const itk::EventObject &event); /** * \brief Called to get hold of the actual preferences node. */ berry::IBerryPreferences::Pointer RetrievePreferences(); QWidget* m_Parent; ::map::deployment::DLLDirectoryBrowser::DLLInfoListType m_DLLInfoList; QStringList m_currentSearchPaths; QmitkAlgorithmListModel* m_algModel; QSortFilterProxyModel* m_filterProxy; ::map::deployment::DLLHandle::Pointer m_LoadedDLLHandle; ::map::algorithm::RegistrationAlgorithmBase::Pointer m_LoadedAlgorithm; }; #endif // MatchPoint_h diff --git a/Plugins/org.mitk.gui.qt.matchpoint.algorithm.control/src/internal/QmitkMatchPoint.h b/Plugins/org.mitk.gui.qt.matchpoint.algorithm.control/src/internal/QmitkMatchPoint.h index 7ac80659cd..b503f44bd9 100644 --- a/Plugins/org.mitk.gui.qt.matchpoint.algorithm.control/src/internal/QmitkMatchPoint.h +++ b/Plugins/org.mitk.gui.qt.matchpoint.algorithm.control/src/internal/QmitkMatchPoint.h @@ -1,206 +1,205 @@ /*============================================================================ 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 __Q_MITK_MATCHPOINT_H #define __Q_MITK_MATCHPOINT_H #include #include #include "ui_QmitkMatchPointControls.h" #include // MatchPoint #include #include #include #include #include #include #include class QmitkRegistrationJob; class QmitkMappingJob; /*! \brief MatchPoint \warning This class is not yet documented. Use "git blame" and ask the author to provide basic documentation. -\sa QmitkFunctionality \ingroup ${plugin_target}_internal */ class QmitkMatchPoint : 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; /** * Creates smartpointer typedefs */ berryObjectMacro(QmitkMatchPoint); QmitkMatchPoint(); ~QmitkMatchPoint() override; protected slots: /** * @brief Connect all GUI elements to its corresponding slots */ virtual void CreateConnections(); /// \brief Called when the user clicks the GUI button void OnLoadAlgorithmButtonPushed(); void OnSelectedAlgorithmChanged(); void OnNodeSelectionChanged(QList nodes); void OnStartRegBtnPushed(); void OnStopRegBtnPushed(); void OnSaveLogBtnPushed(); void OnRegJobError(QString err); void OnRegResultIsAvailable(mitk::MAPRegistrationWrapper::Pointer spResultRegistration, const QmitkRegistrationJob* pRegJob); void OnRegJobFinished(); void OnMapJobError(QString err); void OnMapResultIsAvailable(mitk::BaseData::Pointer spMappedData, const QmitkMappingJob* job); void OnAlgorithmIterated(QString info, bool hasIterationCount, unsigned long currentIteration); void OnLevelChanged(QString info, bool hasLevelCount, unsigned long currentLevel); void OnAlgorithmStatusChanged(QString info); void OnAlgorithmInfo(QString info); protected: void CreateQtPartControl(QWidget* parent) override; void SetFocus() override; private: /** * @brief Adapt the visibility of GUI elements depending on the current data loaded */ void AdaptFolderGUIElements(); void Error(QString msg); void UpdateAlgorithmList(); /** * checks if appropriated nodes are selected in the data manager. If nodes are selected, * they are stored m_MovingData and m_TargetData. It also sets the info lables accordingly. * @return True: All inputs are set and valid (images). False: At least one input is not set * or invalid */ bool CheckInputs(); /** * Updates the state of registration control buttons. Regarding to selected * inputs, loaded algorithm and its state.*/ void ConfigureRegistrationControls(); /** * Configures the progress bars according to the chosen algorithm. */ void ConfigureProgressInfos(); /** Configure the node selectors predicates and informations according to the selected algorithm. */ void ConfigureNodeSelectors(); /** Methods returns a list of all nodes in the data manager containing a registration wrapper. * The list may be empty.*/ mitk::DataStorage::SetOfObjects::Pointer GetRegNodes() const; /** Returns a proposal for a (unique) default reg job name */ std::string GetDefaultRegJobName() const; /** Returns the display name of the passed node. Normally it is just node->GetName(). * if the node contains a point set it is additionally checked if the point set node * has a source node and its name will be added in parentheses.*/ std::string GetInputNodeDisplayName(const mitk::DataNode* node) const; /** Returns the Pointer to the DLL info of the algorithm currently selected by the system. The info is received via m_AlgorithmSelectionListener. @return If there is no item selected the returning pointer will be null. */ const map::deployment::DLLInfo* GetSelectedAlgorithmDLL() const; //! [Qt Selection Listener method and pointer] /** * @brief Method of berry::ISelectionListener that implements the selection listener functionality. * @param sourcepart The workbench part responsible for the selection change. * @param selection This parameter holds the current selection. * * @see ISelectionListener */ void OnAlgorithmSelectionChanged(const berry::IWorkbenchPart::Pointer& sourcepart, const berry::ISelection::ConstPointer& selection); void UpdateAlgorithmSelection(berry::ISelection::ConstPointer selection); friend struct berry::SelectionChangedAdapter; QWidget* m_Parent; /** @brief this pointer holds the algorithm selection listener */ QScopedPointer m_AlgorithmSelectionListener; ::map::deployment::DLLHandle::Pointer m_LoadedDLLHandle; ::map::algorithm::RegistrationAlgorithmBase::Pointer m_LoadedAlgorithm; ::map::deployment::DLLInfo::ConstPointer m_SelectedAlgorithmInfo; typedef map::algorithm::facet::IterativeAlgorithmInterface IIterativeAlgorithm; typedef map::algorithm::facet::MultiResRegistrationAlgorithmInterface IMultiResAlgorithm; typedef map::algorithm::facet::StoppableAlgorithmInterface IStoppableAlgorithm; mitk::DataNode::Pointer m_spSelectedTargetNode; mitk::DataNode::Pointer m_spSelectedMovingNode; /*Data of the selected target node that should be used for registration. Can be the direct return of node->GetData(), but can also be a sub set (like a special time frame).*/ mitk::BaseData::ConstPointer m_spSelectedTargetData; /*Data of the selected moving node that should be used for registration. Can be the direct return of node->GetData(), but can also be a sub set (like a special time frame).*/ mitk::BaseData::ConstPointer m_spSelectedMovingData; mitk::DataNode::Pointer m_spSelectedTargetMaskNode; mitk::DataNode::Pointer m_spSelectedMovingMaskNode; /*Data of the selected target mask node that should be used for registration. Can be the direct return of node->GetData(), but can also be a sub set (like a special time frame).*/ mitk::Image::ConstPointer m_spSelectedTargetMaskData; /*Data of the selected moving mask node that should be used for registration. Can be the direct return of node->GetData(), but can also be a sub set (like a special time frame).*/ mitk::Image::ConstPointer m_spSelectedMovingMaskData; // boolean variables to control visibility of GUI elements bool m_CanLoadAlgorithm; bool m_ValidInputs; bool m_Working; Ui::MatchPointAdvancedControls m_Controls; }; #endif // MatchPoint_h diff --git a/Plugins/org.mitk.gui.qt.matchpoint.evaluator/src/internal/QmitkMatchPointRegistrationEvaluator.h b/Plugins/org.mitk.gui.qt.matchpoint.evaluator/src/internal/QmitkMatchPointRegistrationEvaluator.h index 5aaa24643b..ca79c1c513 100644 --- a/Plugins/org.mitk.gui.qt.matchpoint.evaluator/src/internal/QmitkMatchPointRegistrationEvaluator.h +++ b/Plugins/org.mitk.gui.qt.matchpoint.evaluator/src/internal/QmitkMatchPointRegistrationEvaluator.h @@ -1,115 +1,114 @@ /*============================================================================ 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 __Q_MITK_MATCHPOINT_REGISTRATION_EVALUATOR_H #define __Q_MITK_MATCHPOINT_REGISTRATION_EVALUATOR_H #include #include #include #include "ui_QmitkMatchPointRegistrationEvaluator.h" /*! \brief QmitkMatchPointRegistrationEvaluator \warning This class is not yet documented. Use "git blame" and ask the author to provide basic documentation. -\sa QmitkFunctionality \ingroup ${plugin_target}_internal */ class QmitkMatchPointRegistrationEvaluator : public QmitkAbstractView, public mitk::IRenderWindowPartListener { // 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; /** * Creates smartpointer typedefs */ berryObjectMacro(QmitkMatchPointRegistrationEvaluator); QmitkMatchPointRegistrationEvaluator(); ~QmitkMatchPointRegistrationEvaluator() override; void CreateQtPartControl(QWidget *parent) override; protected slots: /// \brief Called when the user clicks the GUI button void OnEvalBtnPushed(); void OnStopBtnPushed(); void OnSettingsChanged(mitk::DataNode*); void OnSliceChanged(); void OnNodeSelectionChanged(QList nodes); protected: void NodeRemoved(const mitk::DataNode* node) override; void SetFocus() override; void RenderWindowPartActivated(mitk::IRenderWindowPart* renderWindowPart) override; void RenderWindowPartDeactivated(mitk::IRenderWindowPart* renderWindowPart) override; Ui::MatchPointRegistrationEvaluatorControls m_Controls; private: QWidget *m_Parent; void Error(QString msg); /** * Checks if appropriated nodes are selected in the data manager. If nodes are selected, * they are stored m_spSelectedRegNode, m_spSelectedInputNode and m_spSelectedRefNode. * They are also checked for vadility and stored in m_ValidInput,... . * It also sets the info lables accordingly.*/ void CheckInputs(); /** * Updates the state of controls regarding to selected eval object.*/ void ConfigureControls(); /** Configure the node selectors predicates according to the selected algorithm. */ void ConfigureNodePredicates(); mitk::DataNode::Pointer m_selectedEvalNode; QmitkSliceNavigationListener m_SliceChangeListener; itk::TimeStamp m_selectedNodeTime; itk::TimeStamp m_currentPositionTime; bool m_activeEvaluation; /** @brief currently valid selected position in the inspector*/ mitk::Point3D m_currentSelectedPosition; /** @brief currently selected timepoint*/ mitk::TimePointType m_currentSelectedTimePoint; mitk::DataNode::Pointer m_spSelectedRegNode; mitk::DataNode::Pointer m_spSelectedMovingNode; mitk::DataNode::Pointer m_spSelectedTargetNode; static const std::string HelperNodeName; }; #endif // MatchPoint_h diff --git a/Plugins/org.mitk.gui.qt.matchpoint.manipulator/src/internal/QmitkMatchPointRegistrationManipulator.h b/Plugins/org.mitk.gui.qt.matchpoint.manipulator/src/internal/QmitkMatchPointRegistrationManipulator.h index 79786b709f..54e9cf1e3e 100644 --- a/Plugins/org.mitk.gui.qt.matchpoint.manipulator/src/internal/QmitkMatchPointRegistrationManipulator.h +++ b/Plugins/org.mitk.gui.qt.matchpoint.manipulator/src/internal/QmitkMatchPointRegistrationManipulator.h @@ -1,149 +1,148 @@ /*============================================================================ 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 __Q_MITK_MATCHPOINT_REGISTRATION_MANIPULATOR_H #define __Q_MITK_MATCHPOINT_REGISTRATION_MANIPULATOR_H #include #include #include #include #include #include "ui_QmitkMatchPointRegistrationManipulator.h" class QmitkMappingJob; /*! \brief QmitkMatchPointRegistrationManipulator \warning This class is not yet documented. Use "git blame" and ask the author to provide basic documentation. -\sa QmitkFunctionality \ingroup ${plugin_target}_internal */ class QmitkMatchPointRegistrationManipulator : public QmitkAbstractView, public mitk::IRenderWindowPartListener { // 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; /** * Creates smartpointer typedefs */ berryObjectMacro(QmitkMatchPointRegistrationManipulator); QmitkMatchPointRegistrationManipulator(); ~QmitkMatchPointRegistrationManipulator() override; void CreateQtPartControl(QWidget *parent) override; protected slots: /// \brief Called when the user clicks the GUI button void OnStartBtnPushed(); void OnCancelBtnPushed(); void OnStoreBtnPushed(); void OnSettingsChanged(mitk::DataNode*); void OnRegSourceChanged(); void OnNodeSelectionChanged(QList nodes); void OnRegistrationChanged(); void OnCenterTypeChanged(int); void OnSliceChanged(); void OnMapResultIsAvailable(mitk::BaseData::Pointer spMappedData, const QmitkMappingJob* job); void Error(QString msg); protected: void NodeRemoved(const mitk::DataNode* node) override; void SetFocus() override; void RenderWindowPartActivated(mitk::IRenderWindowPart* renderWindowPart) override; void RenderWindowPartDeactivated(mitk::IRenderWindowPart* renderWindowPart) override; Ui::MatchPointRegistrationManipulatorControls m_Controls; private: QWidget *m_Parent; /** Methods returns a list of all eval nodes in the data manager.*/ QList GetEvalNodes(); /** * Checks if appropriated nodes are selected in the data manager. If nodes are selected, * they are stored m_spSelectedRegNode, m_spSelectedInputNode and m_spSelectedRefNode. * They are also checked for validity.*/ void CheckInputs(); /** * Updates the state of controls regarding to the state of the view and it objects.*/ void ConfigureControls(); /** Configure the node selectors predicates according to the selected algorithm. */ void ConfigureNodePredicates(); /** Initialize the state of the view, so the manipulation can start.*/ void InitSession(); /** Stops session, removes all obsolete members (e.g. RegEvalObject). After that the view is in a valid but inactive state.*/ void StopSession(); void ConfigureTransformCenter(int centerType); mitk::DataNode::Pointer m_EvalNode; QmitkSliceNavigationListener m_SliceChangeListener; itk::TimeStamp m_selectedNodeTime; itk::TimeStamp m_currentPositionTime; bool m_activeManipulation; /** @brief currently valid selected position in the inspector*/ mitk::Point3D m_currentSelectedPosition; /** @brief currently selected timepoint*/ mitk::TimePointType m_currentSelectedTimePoint; mitk::DataNode::Pointer m_SelectedPreRegNode; mitk::DataNode::Pointer m_SelectedMovingNode; mitk::DataNode::Pointer m_SelectedTargetNode; mitk::MAPRegistrationWrapper::Pointer m_CurrentRegistrationWrapper; map::core::RegistrationBase::Pointer m_CurrentRegistration; using MAPRegistrationType = map::core::Registration<3, 3>; MAPRegistrationType::Pointer m_SelectedPreReg; bool m_internalUpdate; static const std::string HelperNodeName; }; #endif // MatchPoint_h diff --git a/Plugins/org.mitk.gui.qt.matchpoint.mapper/src/internal/QmitkMatchPointMapper.h b/Plugins/org.mitk.gui.qt.matchpoint.mapper/src/internal/QmitkMatchPointMapper.h index 05287a2d75..f505b8316a 100644 --- a/Plugins/org.mitk.gui.qt.matchpoint.mapper/src/internal/QmitkMatchPointMapper.h +++ b/Plugins/org.mitk.gui.qt.matchpoint.mapper/src/internal/QmitkMatchPointMapper.h @@ -1,159 +1,158 @@ /*============================================================================ 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 __Q_MITK_MATCHPOINT_MAPPER_H #define __Q_MITK_MATCHPOINT_MAPPER_H #include #include #include #include "ui_QmitkMatchPointMapper.h" #include "QmitkMappingJob.h" /*! \brief QmitkMatchPointMapper View class that implements the logic/functionality to map point sets or images based on MatchPoint registration objects. - \sa QmitkFunctionality \ingroup ${plugin_target}_internal */ class QmitkMatchPointMapper : public QmitkAbstractView { Q_OBJECT public: static const std::string VIEW_ID; /** * Creates smartpointer typedefs */ berryObjectMacro(QmitkMatchPointMapper); QmitkMatchPointMapper(); void CreateQtPartControl(QWidget *parent) override; protected slots: /** * @brief Connect all GUI elements to its corresponding slots */ virtual void CreateConnections(); void OnManualRefChecked(); void OnLinkSampleFactorChecked(); void OnXFactorChanged(double d); void OnMapBtnPushed(); void OnRefineBtnPushed(); void OnMapJobError(QString err); void OnMapResultIsAvailable(mitk::BaseData::Pointer spMappedData, const QmitkMappingJob* job); void OnMappingInfo(QString info); void OnRegNodeSelectionChanged(QList nodes); void OnInputNodeSelectionChanged(QList nodes); void OnReferenceNodeSelectionChanged(QList nodes); protected: void SetFocus() override; Ui::MatchPointMapperControls m_Controls; private: QWidget *m_Parent; void Error(QString msg); /** Method checks if the currently selected reg node has a direct kernel that * can be decomposed in a rotation matrix and a offset. If this is true, true * is returned. In all other cases false is returned.*/ bool IsAbleToRefineGeometry() const; /** Method checks if the currently selected input is a binary image (property binary == true). * If this is true, true is returned. In all other cases false is returned.*/ bool IsBinaryInput() const; /** Method checks if the currently selected input is a point set. * If this is true, true is returned. In all other cases false is returned.*/ bool IsPointSetInput() const; /** If a registration node is set, this function determines the auto reference node. * The auto reference node is the node of the target data used to determine the * registration object or, if the first cannot be determined, the currently selected input * node. * @return Pointer to the reference node (target data of the registration algorithm run). * Function may return nullptr if the referenced node cannot be found or is not defined * by the registration.*/ mitk::DataNode::Pointer GetAutoRefNodeByReg(); /** * Checks if appropriated nodes are selected in the data manager. If nodes are selected, * they are stored m_spSelectedRegNode, m_spSelectedInputNode and m_spSelectedRefNode. * They are also checked for vadility and stored in m_ValidInput,... . * It also sets the info lables accordingly.*/ void CheckInputs(); /** Methods checks the validity of the currently stored * m_spSelectedRegNode, m_spSelectedInputNode and m_spSelectedRefNode. * Results are returned via the parameters. Details of the evaluation are * printed to the log widget.*/ void CheckNodesValidity(bool& validReg, bool& validInput, bool& validRef); /** * Updates the state of mapping control button regarding to selected * input, registration and reference.*/ void ConfigureMappingControls(); /** * Configures the progress bars accoarding to the choosen algorithm. */ void ConfigureProgressInfos(); /** Configure the reg node selector predicates. If a input pointer is passed, the predicate will be configured according to the input. */ void ConfigureRegNodePredicate(const mitk::DataNode* input = nullptr); /** Configure the input and ref node selector predicates. If a reg pointer is passed, the predicate will be configured according to the input. */ void ConfigureNodePredicates(const mitk::DataNode* reg = nullptr); /** * Used to generate, configure and execute a mapping job regarding the * current settings. * @param doGeometryRefinement Set true if only a geometry refinement should be done. * Set to false if a mapping/resampling of the input should be done.*/ void SpawnMappingJob(bool doGeometryRefinement = false); mitk::DataNode::Pointer m_spSelectedRegNode; mitk::DataNode::Pointer m_spSelectedInputNode; mitk::DataNode::Pointer m_spSelectedRefNode; /** used for the internal logic to indicate of the current settings are set for mapping binary images (used by ConfigureMappingControls()).*/ bool m_preparedForBinaryInput; }; #endif // MatchPoint_h diff --git a/Plugins/org.mitk.gui.qt.matchpoint.visualizer/src/internal/QmitkMatchPointRegistrationVisualizer.h b/Plugins/org.mitk.gui.qt.matchpoint.visualizer/src/internal/QmitkMatchPointRegistrationVisualizer.h index b24a326d2e..b05981c2ab 100644 --- a/Plugins/org.mitk.gui.qt.matchpoint.visualizer/src/internal/QmitkMatchPointRegistrationVisualizer.h +++ b/Plugins/org.mitk.gui.qt.matchpoint.visualizer/src/internal/QmitkMatchPointRegistrationVisualizer.h @@ -1,159 +1,158 @@ /*============================================================================ 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 __Q_MITK_MATCHPOINT_REGISTRATION_VISUALIZER_H #define __Q_MITK_MATCHPOINT_REGISTRATION_VISUALIZER_H #include #include #include #include #include #include "mitkMAPRegistrationWrapper.h" #include "ui_QmitkMatchPointRegistrationVisualizer.h" /*! \brief QmitkMatchPointRegistrationVisualizer \warning This class is not yet documented. Use "git blame" and ask the author to provide basic documentation. - \sa QmitkFunctionality \ingroup ${plugin_target}_internal */ class QmitkMatchPointRegistrationVisualizer : 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; /** * Creates smartpointer typedefs */ berryObjectMacro(QmitkMatchPointRegistrationVisualizer); QmitkMatchPointRegistrationVisualizer(); void CreateQtPartControl(QWidget* parent) override; /** Returns the registration currently handled by the plugin. * May return nullptr, if no registration is selected/handled by * the plugin*/ mitk::MAPRegistrationWrapper* GetCurrentRegistration(); protected slots: /** * @brief Connect all GUI elements to its corresponding slots */ virtual void CreateConnections(); void OnStyleButtonPushed(); void OnDirectionChanged(int index); void OnUpdateBtnPushed(); void OnColorInterpolationChecked(bool); void OnNodeSelectionChanged(QList nodes); void TransferFOVRefGeometry(); protected: void SetFocus() override; void ActualizeRegInfo(mitk::MAPRegistrationWrapper* currentReg); Ui::MatchPointRegVisControls* m_Controls; private: QWidget* m_Parent; void Error(QString msg); void CheckInputs(); /** Function returns the first data node containing a registration wrapper * in the current selection of the data manager. If nothing is selected or * no registration wrapper is selected it return nullptr.*/ mitk::DataNode::Pointer GetSelectedRegNode() const; /** If a registration node is set, this function determines the relevant referenced node. * The reference node is the node of the target or moving data (depending on the selected directions) * used to determine the* registration object. * @return Pointer to the reference node (moving or target data of the registration algorithm run). * Function may return nullptr if the referenced node cannot be found or is not defined * by the registration.*/ mitk::DataNode::Pointer GetRefNodeOfReg(bool target) const; /** Methods returns the first node selected in the data manager that does * NOT contain a registration wrapper and has a data pointer with a geometry. * Returned pointer may be nullptr if nothing is selected or no appropriate data * node is selected.*/ mitk::DataNode::Pointer GetSelectedDataNode(); /** Methods checks if the given gridRes is larger than maxGridRes and scales down the spacing if necessary. * @param gridRes the resolution of the "grid". * @param spacing the spacing that would be used on the grid. * @param maxGridRes the maximum resolution of the "grid".*/ mitk::ScalarType GetSaveSpacing(mitk::ScalarType gridRes, mitk::ScalarType spacing, unsigned int maxGridRes) const; /** * Checks for mandatory node properties and defines them with default values if they are missing.*/ void InitRegNode(); /** * Updates the gui controls regarding the current state of the instance.*/ void ConfigureVisualizationControls(); /** Configure the node selectors predicates according to the selected algorithm. */ void ConfigureNodePredicates(); /** * Updates the properties of the selected node according to the states of the gui controls.*/ void StoreStateInNode(); /** * Updates the state of the gui controls according to the properties of the selected node.*/ void LoadStateFromNode(); /** * Checks accordung to the current direction if there is a default FOV ref and sets it, * if the current FOV ref is not locked.*/ void CheckAndSetDefaultFOVRef(); void UpdateOrientationMatrixWidget(); /**indicates if the gui updates is triggered internally or by user. Needed to * avoid update loops by ConfigureVisualizationControlls();*/ bool m_internalUpdateGuard; mitk::DataNode::Pointer m_spSelectedFOVRefNode; mitk::DataNode::Pointer m_spSelectedRegNode; /**Used to store informations about the FOV reference orientation. Default is identity matrix.*/ mitk::AffineTransform3D::MatrixType m_FOVRefOrientation; }; #endif // MatchPoint_h diff --git a/Plugins/org.mitk.gui.qt.pharmacokinetics.concentration.mri/src/internal/ConcentrationCurveConverterView.h b/Plugins/org.mitk.gui.qt.pharmacokinetics.concentration.mri/src/internal/ConcentrationCurveConverterView.h index 24bc782d46..c34767cb4a 100644 --- a/Plugins/org.mitk.gui.qt.pharmacokinetics.concentration.mri/src/internal/ConcentrationCurveConverterView.h +++ b/Plugins/org.mitk.gui.qt.pharmacokinetics.concentration.mri/src/internal/ConcentrationCurveConverterView.h @@ -1,104 +1,98 @@ /*============================================================================ 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 ConcentrationCurveConverterView_h #define ConcentrationCurveConverterView_h #include #include #include "ui_ConcentrationCurveConverterViewControls.h" #include - /*! * @brief Test Plugin for SUV calculations of PET images */ class ConcentrationCurveConverterView : public QmitkAbstractView { Q_OBJECT public: // typedef itk::Image ImageType; typedef itk::Image ConvertedImageType; /*! @brief The view's unique ID - required by MITK */ static const std::string VIEW_ID; ConcentrationCurveConverterView(); protected slots: /*! * @brief Is triggered of the update button is clicked and the selected node should get the (new) iso level set. */ void OnConvertToConcentrationButtonClicked(); void OnSettingChanged(); bool CheckSettings() const; - - protected: // Overridden base class functions /*! * @brief Sets up the UI controls and connects the slots and signals. Gets * called by the framework to create the GUI at the right time. * @param[in,out] parent The parent QWidget, as this class itself is not a QWidget * subclass. */ void CreateQtPartControl(QWidget* parent) override; /*! * @brief Sets the focus to the plot curve button. Gets called by the framework to set the * focus on the right widget. */ void SetFocus() override; bool CheckBaselineSelectionSettings() const; - /*! Helper method that adds an concentration image as child node to the current m_selectedNode and returns this new child node.*/ - mitk::DataNode::Pointer AddConcentrationImage(mitk::Image* image, std::string nodeName) const; - + /*! Helper method that adds an concentration image as child node to the current m_selectedNode and returns this new child node.*/ + mitk::DataNode::Pointer AddConcentrationImage(mitk::Image* image, std::string nodeName) const; - /*! \brief called by QmitkFunctionality when DataManager's selection has changed - */ void OnNodeSelectionChanged(QList/*nodes*/); // Variables /*! @brief The view's UI controls */ Ui::ConcentrationCurveConverterViewControls m_Controls; mitk::DataNode::Pointer m_selectedNode; mitk::Image::Pointer m_selectedImage; mitk::DataNode::Pointer m_selectedBaselineNode; mitk::Image::Pointer m_selectedBaselineImage; private: /**Converts the selected image to a concentration image based on the given gui settings.*/ mitk::Image::Pointer Convert4DConcentrationImage(mitk::Image::Pointer inputImage); mitk::Image::Pointer Convert3DConcentrationImage(mitk::Image::Pointer inputImage, mitk::Image::Pointer baselineImage); mitk::Image::Pointer ConvertT2ConcentrationImgage(mitk::Image::Pointer inputImage); mitk::NodePredicateBase::Pointer m_IsNoMaskImagePredicate; mitk::NodePredicateBase::Pointer m_IsMaskPredicate; mitk::NodePredicateBase::Pointer m_isValidPDWImagePredicate; mitk::NodePredicateBase::Pointer m_isValidTimeSeriesImagePredicate; }; #endif diff --git a/Plugins/org.mitk.gui.qt.pharmacokinetics.curvedescriptor/src/internal/PerfusionCurveDescriptionParameterView.h b/Plugins/org.mitk.gui.qt.pharmacokinetics.curvedescriptor/src/internal/PerfusionCurveDescriptionParameterView.h index 0e91491a8c..7695df513a 100644 --- a/Plugins/org.mitk.gui.qt.pharmacokinetics.curvedescriptor/src/internal/PerfusionCurveDescriptionParameterView.h +++ b/Plugins/org.mitk.gui.qt.pharmacokinetics.curvedescriptor/src/internal/PerfusionCurveDescriptionParameterView.h @@ -1,106 +1,102 @@ /*============================================================================ 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 PerfusionCurveDescriptionParameterView_h #define PerfusionCurveDescriptionParameterView_h #include #include #include "ui_PerfusionCurveDescriptionParameterViewControls.h" #include "mitkCurveDescriptionParameterBase.h" #include #include namespace mitk { class CurveParameterFunctor; } /*! * @brief Test Plugin for SUV calculations of PET images */ class PerfusionCurveDescriptionParameterView : public QmitkAbstractView { Q_OBJECT public: typedef mitk::CurveDescriptionParameterBase::CurveDescriptionParameterNameType ParameterNameType; /*! @brief The view's unique ID - required by MITK */ static const std::string VIEW_ID; PerfusionCurveDescriptionParameterView(); protected slots: void InitParameterList(); void OnJobFinished(); void OnJobError(QString err); void OnJobResultsAreAvailable(mitk::modelFit::ModelFitResultNodeVectorType results, const DescriptionParameterBackgroundJob* pJob); void OnJobProgress(double progress); void OnJobStatusChanged(QString info); /*! * @brief Is triggered of the update button is clicked and the selected node should get the (new) iso level set. */ void OnCalculateParametersButtonClicked(); protected: // Overridden base class functions /*! * @brief Sets up the UI controls and connects the slots and signals. Gets * called by the framework to create the GUI at the right time. * @param[in,out] parent The parent QWidget, as this class itself is not a QWidget * subclass. */ void CreateQtPartControl(QWidget* parent) override; /*! * @brief Sets the focus to the plot curve button. Gets called by the framework to set the * focus on the right widget. */ void SetFocus() override; /** Configures the passed functor according to the selected image and parameters*/ void ConfigureFunctor(mitk::CurveParameterFunctor* functor) const; - /*! \brief called by QmitkFunctionality when DataManager's selection has changed - */ void OnSelectionChanged( berry::IWorkbenchPart::Pointer source, const QList& nodes) override; // Variables /*! @brief The view's UI controls */ Ui::PerfusionCurveDescriptionParameterViewControls m_Controls; mitk::DataNode::Pointer m_selectedNode; private: - - typedef std::map ParameterMapType; ParameterMapType m_ParameterMap; mitk::Image::Pointer m_selectedImage; mitk::Image::Pointer m_selectedMask; }; #endif diff --git a/Plugins/org.mitk.gui.qt.pharmacokinetics.mri/src/internal/MRPerfusionView.h b/Plugins/org.mitk.gui.qt.pharmacokinetics.mri/src/internal/MRPerfusionView.h index f6738bd796..7c65eca0a4 100644 --- a/Plugins/org.mitk.gui.qt.pharmacokinetics.mri/src/internal/MRPerfusionView.h +++ b/Plugins/org.mitk.gui.qt.pharmacokinetics.mri/src/internal/MRPerfusionView.h @@ -1,214 +1,206 @@ /*============================================================================ 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 MRPerfusionView_h #define MRPerfusionView_h #include #include "QmitkAbstractView.h" #include "itkCommand.h" #include "ui_MRPerfusionViewControls.h" #include "mitkModelBase.h" #include "QmitkParameterFitBackgroundJob.h" #include "mitkModelFitResultHelper.h" #include "mitkModelFactoryBase.h" #include "mitkLevenbergMarquardtModelFitFunctor.h" #include "mitkSimpleBarrierConstraintChecker.h" #include "mitkAIFBasedModelBase.h" - - /*! * @brief Test Plugin for SUV calculations of PET images */ class MRPerfusionView : public QmitkAbstractView { Q_OBJECT public: /*! @brief The view's unique ID - required by MITK */ static const std::string VIEW_ID; MRPerfusionView(); protected slots: void OnModellingButtonClicked(); void OnJobFinished(); void OnJobError(QString err); void OnJobResultsAreAvailable(mitk::modelFit::ModelFitResultNodeVectorType results, const ParameterFitBackgroundJob* pJob); void OnJobProgress(double progress); void OnJobStatusChanged(QString info); void OnModellSet(int); void LoadAIFfromFile(); /**Sets visibility and enabled state of the GUI depending on the settings and workflow state.*/ void UpdateGUIControls(); protected: typedef QList SelectedDataNodeVectorType; // Overridden base class functions /*! * @brief Sets up the UI controls and connects the slots and signals. Gets * called by the framework to create the GUI at the right time. * @param[in,out] parent The parent QWidget, as this class itself is not a QWidget * subclass. */ void CreateQtPartControl(QWidget* parent) override; /*! * @brief Sets the focus to the plot curve button. Gets called by the framework to set the * focus on the right widget. */ void SetFocus() override; /*! @brief Generates a configured fit generator and the corresponding modelinfo for a descriptive brix model with pixel based strategy. * @remark add GenerateFunction for each model in the Combo box*/ void GenerateDescriptiveBrixModel_PixelBased(mitk::modelFit::ModelFitInfo::Pointer& modelFitInfo, mitk::ParameterFitImageGeneratorBase::Pointer& generator); void GenerateDescriptiveBrixModel_ROIBased(mitk::modelFit::ModelFitInfo::Pointer& modelFitInfo, mitk::ParameterFitImageGeneratorBase::Pointer& generator); template void GenerateLinearModelFit_PixelBased(mitk::modelFit::ModelFitInfo::Pointer& modelFitInfo, mitk::ParameterFitImageGeneratorBase::Pointer& generator); template void GenerateLinearModelFit_ROIBased(mitk::modelFit::ModelFitInfo::Pointer& modelFitInfo, mitk::ParameterFitImageGeneratorBase::Pointer& generator); template void GenerateAIFbasedModelFit_ROIBased(mitk::modelFit::ModelFitInfo::Pointer& modelFitInfo, mitk::ParameterFitImageGeneratorBase::Pointer& generator); template void GenerateAIFbasedModelFit_PixelBased(mitk::modelFit::ModelFitInfo::Pointer& modelFitInfo, mitk::ParameterFitImageGeneratorBase::Pointer& generator); /** Helper function that configures the initial parameter strategy of a parameterizer according to the settings of the GUI.*/ void ConfigureInitialParametersOfParameterizer(mitk::ModelParameterizerBase* parameterizer) const; /*! Starts the fitting job with the passed generator and session info*/ void DoFit(const mitk::modelFit::ModelFitInfo* fitSession, mitk::ParameterFitImageGeneratorBase* generator); /**Checks if the settings in the GUI are valid for the chosen model.*/ bool CheckModelSettings() const; bool CheckBaselineSelectionSettings() const; void InitModelComboBox() const; - - - /*! Helper method that generates a node for the passed concentration image.*/ mitk::DataNode::Pointer GenerateConcentrationNode(mitk::Image* image, const std::string& nodeName) const; - /*! \brief called by QmitkFunctionality when DataManager's selection has changed - */ - void OnNodeSelectionChanged(QList /*nodes*/); /*! @brief The view's UI controls */ Ui::MRPerfusionViewControls m_Controls; /* Nodes selected by user/ui for the fit */ mitk::DataNode::Pointer m_selectedNode; mitk::DataNode::Pointer m_selectedMaskNode; mitk::DataNode::Pointer m_selectedAIFMaskNode; mitk::DataNode::Pointer m_selectedAIFImageNode; /* Images selected by user/ui for the fit */ mitk::Image::Pointer m_selectedImage; mitk::Image::Pointer m_selectedMask; mitk::Image::Pointer m_selectedAIFMask; mitk::Image::Pointer m_selectedAIFImage; mitk::ModelFactoryBase::Pointer m_selectedModelFactory; mitk::SimpleBarrierConstraintChecker::Pointer m_modelConstraints; private: bool IsTurboFlashSequenceFlag() const; bool m_FittingInProgress; typedef std::vector ModelFactoryStackType; ModelFactoryStackType m_FactoryStack; /**Converts the selected image to a concentration image based on the given gui settings. AIFMode controls if the concentration image for the fit input or the AIF will be converted.*/ mitk::Image::Pointer ConvertConcentrationImage(bool AIFMode); /**Helper function that (depending on the gui settings) prepares m_inputNode and m_inputImage. Either by directly pass back the selected image/node or the newly generated concentration image/node. After calling this method m_inputImage are always what should be used as input image for the fitting.*/ void PrepareConcentrationImage(); /**Helper function that (depending on the gui settings) prepares m_inputAIFNode and m_inputAIFImage. Either by directly pass back the selected image/node or the newly generated concentration image/node. After calling this method m_inputAIFImage are always what should be used as AIF image for the fitting.*/ void PrepareAIFConcentrationImage(); /**Helper function that (depending on the gui settings) generates and passes back the AIF and its time grid that should be used for fitting. @remark the parameters aif and aifTimeGrid will be initialized accordingly if the method returns.*/ void GetAIF(mitk::AIFBasedModelBase::AterialInputFunctionType& aif, mitk::AIFBasedModelBase::AterialInputFunctionType& aifTimeGrid); /**Helper function that generates a default fitting functor * default is a levenberg marquart based optimizer with all scales set to 1.0. * Constraint setter will be set based on the gui setting and a evaluation parameter * "sum of squared differences" will always be set.*/ mitk::ModelFitFunctorBase::Pointer CreateDefaultFitFunctor(const mitk::ModelParameterizerBase* parameterizer) const; /**Returns the default fit name, derived from the current GUI settings.*/ std::string GetDefaultFitName() const; /**Returns the current set name of the fit (either default name or use defined name).*/ std::string GetFitName() const; std::vector AIFinputGrid; std::vector AIFinputFunction; mitk::NodePredicateBase::Pointer m_IsNoMaskImagePredicate; mitk::NodePredicateBase::Pointer m_IsMaskPredicate; mitk::NodePredicateBase::Pointer m_isValidPDWImagePredicate; mitk::NodePredicateBase::Pointer m_isValidTimeSeriesImagePredicate; /* Node used for the fit (my be the selected image or converted ones (depending on the ui settings */ mitk::DataNode::Pointer m_inputNode; mitk::DataNode::Pointer m_inputAIFNode; bool m_HasGeneratedNewInput; bool m_HasGeneratedNewInputAIF; /* Image used for the fit (my be the selected image or converted ones (depending on the ui settings */ mitk::Image::Pointer m_inputImage; mitk::Image::Pointer m_inputAIFImage; }; #endif diff --git a/Plugins/org.mitk.gui.qt.pharmacokinetics.pet/src/internal/PETDynamicView.h b/Plugins/org.mitk.gui.qt.pharmacokinetics.pet/src/internal/PETDynamicView.h index 78a4e5f33b..80bace9897 100644 --- a/Plugins/org.mitk.gui.qt.pharmacokinetics.pet/src/internal/PETDynamicView.h +++ b/Plugins/org.mitk.gui.qt.pharmacokinetics.pet/src/internal/PETDynamicView.h @@ -1,172 +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. ============================================================================*/ #ifndef PETDynamicView_h #define PETDynamicView_h #include #include "QmitkAbstractView.h" #include "itkCommand.h" #include "ui_PETDynamicViewControls.h" #include "mitkModelBase.h" #include "QmitkParameterFitBackgroundJob.h" #include "mitkModelFitResultHelper.h" #include "mitkModelFactoryBase.h" #include "mitkLevenbergMarquardtModelFitFunctor.h" #include "mitkSimpleBarrierConstraintChecker.h" #include "mitkAIFBasedModelBase.h" /*! * @brief Test Plugin for SUV calculations of PET images */ class PETDynamicView : public QmitkAbstractView { Q_OBJECT public: /*! @brief The view's unique ID - required by MITK */ static const std::string VIEW_ID; PETDynamicView(); protected slots: - void OnModellingButtonClicked(); void OnJobFinished(); void OnJobError(QString err); void OnJobResultsAreAvailable(mitk::modelFit::ModelFitResultNodeVectorType results, const ParameterFitBackgroundJob* pJob); void OnJobProgress(double progress); void OnJobStatusChanged(QString info); void OnModellSet(int); void LoadAIFfromFile(); // void OnModelSettingChanged(); void UpdateGUIControls(); protected: typedef QList SelectedDataNodeVectorType; // Overridden base class functions /*! * @brief Sets up the UI controls and connects the slots and signals. Gets * called by the framework to create the GUI at the right time. * @param[in,out] parent The parent QWidget, as this class itself is not a QWidget * subclass. */ void CreateQtPartControl(QWidget* parent) override; /*! * @brief Sets the focus to the plot curve button. Gets called by the framework to set the * focus on the right widget. */ void SetFocus() override; /*! @brief Generates a configured fit generator and the corresponding modelinfo for a descriptive brix model with pixel based strategy. * @remark add GenerateFunction for each model in the Combo box*/ template void GenerateModelFit_ROIBased(mitk::modelFit::ModelFitInfo::Pointer& modelFitInfo, mitk::ParameterFitImageGeneratorBase::Pointer& generator); template void GenerateModelFit_PixelBased(mitk::modelFit::ModelFitInfo::Pointer& modelFitInfo, mitk::ParameterFitImageGeneratorBase::Pointer& generator); /** Helper function that configures the initial parameter strategy of a parameterizer according to the settings of the GUI.*/ void ConfigureInitialParametersOfParameterizer(mitk::ModelParameterizerBase* parameterizer) const; /*! Starts the fitting job with the passed generator and session info*/ void DoFit(const mitk::modelFit::ModelFitInfo* fitSession, mitk::ParameterFitImageGeneratorBase* generator); bool CheckModelSettings() const; void InitModelComboBox() const; - /*! \brief called by QmitkFunctionality when DataManager's selection has changed - */ void OnSelectionChanged(berry::IWorkbenchPart::Pointer source, const QList& selectedNodes) override; /*! @brief The view's UI controls */ Ui::PETDynamicViewControls m_Controls; mitk::DataNode::Pointer m_selectedNode; mitk::DataNode::Pointer m_selectedMaskNode; mitk::DataNode::Pointer m_selectedAIFMaskNode; mitk::DataNode::Pointer m_selectedAIFImageNode; mitk::Image::Pointer m_selectedImage; mitk::Image::Pointer m_selectedMask; mitk::Image::Pointer m_selectedAIFMask; mitk::Image::Pointer m_selectedAIFImage; /* Node used for the fit (my be the selected image or converted ones (depending on the ui settings */ mitk::DataNode::Pointer m_inputNode; mitk::DataNode::Pointer m_inputAIFNode; /* Image used for the fit (my be the selected image or converted ones (depending on the ui settings */ mitk::Image::Pointer m_inputImage; mitk::Image::Pointer m_inputAIFImage; mitk::ModelFactoryBase::Pointer m_selectedModelFactory; mitk::SimpleBarrierConstraintChecker::Pointer m_modelConstraints; - private: bool m_FittingInProgress; typedef std::vector ModelFactoryStackType; ModelFactoryStackType m_FactoryStack; /**Helper function that (depending on the gui settings) generates and passes back the AIF and its time grid that should be used for fitting. @remark the parameters aif and aifTimeGrid will be initialized accordingly if the method returns.*/ void GetAIF(mitk::AIFBasedModelBase::AterialInputFunctionType& aif, mitk::AIFBasedModelBase::AterialInputFunctionType& aifTimeGrid); /**Helper function that generates a default fitting functor * default is a levenberg marquart based optimizer with all scales set to 1.0. * Constraint setter will be set based on the gui setting and a evaluation parameter * "sum of squared differences" will always be set.*/ mitk::ModelFitFunctorBase::Pointer CreateDefaultFitFunctor(const mitk::ModelParameterizerBase* parameterizer) const; /**Returns the default fit name, derived from the current GUI settings.*/ std::string GetDefaultFitName() const; /**Returns the current set name of the fit (either default name or use defined name).*/ std::string GetFitName() const; std::vector AIFinputGrid; std::vector AIFinputFunction; mitk::NodePredicateBase::Pointer m_IsNoMaskImagePredicate; mitk::NodePredicateBase::Pointer m_IsMaskPredicate; }; #endif diff --git a/Plugins/org.mitk.gui.qt.pharmacokinetics.simulation/src/internal/PerfusionDataSimulationView.h b/Plugins/org.mitk.gui.qt.pharmacokinetics.simulation/src/internal/PerfusionDataSimulationView.h index 54ec965992..7956d413f1 100644 --- a/Plugins/org.mitk.gui.qt.pharmacokinetics.simulation/src/internal/PerfusionDataSimulationView.h +++ b/Plugins/org.mitk.gui.qt.pharmacokinetics.simulation/src/internal/PerfusionDataSimulationView.h @@ -1,129 +1,114 @@ /*============================================================================ 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 PerfusionDataSimulationView_h #define PerfusionDataSimulationView_h #include #include #include "ui_PerfusionDataSimulationViewControls.h" #include "mitkModelBase.h" #include #include "itkArray.h" #include "mitkImage.h" - #include - /*! * @brief Test Plugin for SUV calculations of PET images */ class PerfusionDataSimulationView : public QmitkAbstractView { Q_OBJECT public: /*! @brief The view's unique ID - required by MITK */ static const std::string VIEW_ID; PerfusionDataSimulationView(); protected slots: /*! * @brief Is triggered of the update button is clicked and the selected node should get the (new) iso level set. */ void OnGenerateDataButtonClicked(); void LoadAIFFile(); void OnModellSet(int); void OnSimulationConfigurationChanged(); void UpdateDataSelection(); - protected: typedef std::map ParameterMapType; // Overridden base class functions /*! * @brief Sets up the UI controls and connects the slots and signals. Gets * called by the framework to create the GUI at the right time. * @param[in,out] parent The parent QWidget, as this class itself is not a QWidget * subclass. */ void CreateQtPartControl(QWidget* parent) override; /*! * @brief Sets the focus to the plot curve button. Gets called by the framework to set the * focus on the right widget. */ void SetFocus() override; - - void InitModelComboBox() const; - + void InitModelComboBox() const; mitk::Image::Pointer Generate2CXModelData(); mitk::Image::Pointer GenerateNumeric2CXModelData(); mitk::Image::Pointer GenerateETModelData(); void FillParameterMap2CXM(); void FillParameterMapNumeric2CXM(); void FillParameterMapETM(); - - ///////////////////// dynamic PET Models/////////////// mitk::Image::Pointer Generate2TCModelData(); mitk::Image::Pointer Generate1TCModelData(); void FillParameterMap2TCM(); void FillParameterMap1TCM(); bool CheckModelSettings(); - - /*! \brief called by QmitkFunctionality when DataManager's selection has changed - */ -// virtual void OnSelectionChanged(berry::IWorkbenchPart::Pointer source, -// const QList& selectedNodes); - - // Variables /*! @brief The view's UI controls */ Ui::PerfusionDataSimulationViewControls m_Controls; mitk::DataNode::Pointer m_selectedNode; ParameterMapType m_ParameterImageMap; itk::Array m_AterialInputFunction; itk::Array m_TimeGrid; mitk::ModelFactoryBase::Pointer m_selectedModelFactory; - private: typedef std::vector ModelFactoryStackType; ModelFactoryStackType m_FactoryStack; mitk::NodePredicateBase::Pointer m_IsNotABinaryImagePredicate; double m_CNR, m_MaxConcentration, m_Sigma; }; #endif diff --git a/Plugins/org.mitk.gui.qt.pointsetinteractionmultispectrum/src/internal/PointSetInteractionMultispectrum.h b/Plugins/org.mitk.gui.qt.pointsetinteractionmultispectrum/src/internal/PointSetInteractionMultispectrum.h index 3cc3aca58e..e43934a39d 100644 --- a/Plugins/org.mitk.gui.qt.pointsetinteractionmultispectrum/src/internal/PointSetInteractionMultispectrum.h +++ b/Plugins/org.mitk.gui.qt.pointsetinteractionmultispectrum/src/internal/PointSetInteractionMultispectrum.h @@ -1,90 +1,79 @@ /*============================================================================ 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 PointSetInteractionMultispectrum_h #define PointSetInteractionMultispectrum_h #include #include #include #include "ui_PointSetInteractionMultispectrumControls.h" /////////////added from the regiongrowing plugin////////////// #include "mitkPointSet.h" /////// #include "mitkIRenderWindowPartListener.h" /////// #include /////// ////////////////////////////////////////////////////////////// /** \brief PointSetInteractionMultispectrum \warning This class is not yet documented. Use "git blame" and ask the author to provide basic documentation. \sa QmitkAbstractView \ingroup ${plugin_target}_internal */ - - class QmitkPointListWidget; - - class PointSetInteractionMultispectrum : 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; PointSetInteractionMultispectrum(); protected slots: /// \brief Called when the user clicks the GUI button void DoImageProcessing(); protected: void RenderWindowPartActivated(mitk::IRenderWindowPart* renderWindowPart); void RenderWindowPartDeactivated(mitk::IRenderWindowPart* renderWindowPart); void CreateQtPartControl(QWidget *parent) override; void SetFocus() override; - /// \brief called by QmitkFunctionality when DataManager's selection has changed void OnSelectionChanged( berry::IWorkbenchPart::Pointer source, const QList& nodes ) override; Ui::PointSetInteractionMultispectrumControls m_Controls; private: void PlotReflectance(mitk::PointSet::Pointer m_PointSet, QList dataManagerNodes); mitk::PointSet::Pointer m_PointSet; QmitkPointListWidget* m_PointListWidget; QwtPlot* m_Plot; - - - }; #endif // PointSetInteractionMultispectrum_h diff --git a/Plugins/org.mitk.gui.qt.preprocessing.resampling/manifest_headers.cmake b/Plugins/org.mitk.gui.qt.preprocessing.resampling/manifest_headers.cmake index 36feb434f4..c189578b09 100644 --- a/Plugins/org.mitk.gui.qt.preprocessing.resampling/manifest_headers.cmake +++ b/Plugins/org.mitk.gui.qt.preprocessing.resampling/manifest_headers.cmake @@ -1,5 +1,5 @@ set(Plugin-Name "MITK Preprocessing Resampling") set(Plugin-Version "1.0") set(Plugin-Vendor "German Cancer Research Center (DKFZ)") set(Plugin-ContactAddress "http://www.mitk.org") -set(Require-Plugin org.mitk.gui.qt.common.legacy) +set(Require-Plugin org.mitk.gui.qt.common) diff --git a/Plugins/org.mitk.gui.qt.preprocessing.resampling/src/internal/QmitkPreprocessingResamplingView.h b/Plugins/org.mitk.gui.qt.preprocessing.resampling/src/internal/QmitkPreprocessingResamplingView.h index 8d9d85ddeb..b24d8f7e0d 100644 --- a/Plugins/org.mitk.gui.qt.preprocessing.resampling/src/internal/QmitkPreprocessingResamplingView.h +++ b/Plugins/org.mitk.gui.qt.preprocessing.resampling/src/internal/QmitkPreprocessingResamplingView.h @@ -1,131 +1,122 @@ /*============================================================================ 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. ============================================================================*/ #if !defined(QmitkPreprocessingResamplingView_H__INCLUDED) #define QmitkPreprocessingResamplingView_H__INCLUDED #include #include #include "ui_QmitkPreprocessingResamplingViewControls.h" #include "QmitkStepperAdapter.h" #include /*! \brief This module allows to use some basic image processing filters for preprocessing, image enhancement and testing purposes Several basic ITK image processing filters, like denoising, morphological and edge detection are encapsulated in this module and can be selected via a list and an intuitive parameter input. The selected filter will be applied on the image, and a new image showing the output is displayed as result. Also, some image arithmetic operations are available. Images can be 3D or 4D. In the 4D case, the filters work on the 3D image selected via the time slider. The result is also a 3D image. - -\sa QmitkFunctionality, QObject - -\class QmitkBasicImageProcessing -\author Tobias Schwarz -\version 1.0 (3M3) -\date 2009-05-10 -\ingroup Bundles */ class PREPROCESSING_RESAMPLING_EXPORT QmitkPreprocessingResampling : public QmitkAbstractView { Q_OBJECT public: /*! \brief default constructor */ QmitkPreprocessingResampling(); /*! \brief default destructor */ ~QmitkPreprocessingResampling() override; /*! \brief method for creating the widget containing the application controls, like sliders, buttons etc. */ void CreateQtPartControl(QWidget *parent) override; void SetFocus() override; /*! \brief method for creating the connections of main and control widget */ virtual void CreateConnections(); /*! \brief Invoked when the DataManager selection changed */ void OnSelectionChanged(berry::IWorkbenchPart::Pointer, const QList& nodes) override; protected slots: /* * The "Execute" button in the "one image ops" box was triggered */ void StartButtonClicked(); void StartMultipleImagesButtonClicked(); void SelectInterpolator(int interpolator); private: /* * After a one image operation, reset the "one image ops" panel */ void ResetOneImageOpPanel(); /* * Helper method to reset the parameter set panel */ void ResetParameterPanel(); /* * After a two image operation, reset the "two image ops" panel */ void ResetTwoImageOpPanel(); /** retrieve the tnc from renderwindow part */ void InternalGetTimeNavigationController(); /*! * controls containing sliders for scrolling through the slices */ Ui::QmitkPreprocessingResamplingViewControls *m_Controls; - //mitk::DataNode* m_SelectedImageNode; mitk::DataStorageSelection::Pointer m_SelectedImageNode; QmitkStepperAdapter* m_TimeStepperAdapter; std::vector m_SelectedNodes; enum InterpolationType{ LINEAR, NEAREST, SPLINE } m_SelectedInterpolation; }; -#endif // !defined(QmitkBasicImageProcessing_H__INCLUDED) +#endif