diff --git a/Modules/RTUI/Helper/mitkRTUIConstants.cpp b/Modules/RTUI/Helper/mitkRTUIConstants.cpp index d24e2da3bc..6fa6d768af 100644 --- a/Modules/RTUI/Helper/mitkRTUIConstants.cpp +++ b/Modules/RTUI/Helper/mitkRTUIConstants.cpp @@ -1,38 +1,45 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "mitkRTUIConstants.h" const std::string mitk::rt::UIConstants::ROOT_PREFERENCE_NODE_ID = "/RT/UI"; const std::string mitk::rt::UIConstants::UNKNOWN_PRESCRIBED_DOSE_HANDLING_AS_DEFAULT_ID = "unkownDoseHandlingStyle"; const std::string mitk::rt::UIConstants::UNKNOWN_PRESCRIBED_DOSE_HANDLING_VALUE_ID = "unkownDoseHandlingValue"; const std::string mitk::rt::UIConstants::ROOT_DOSE_VIS_PREFERENCE_NODE_ID = "/RT/UI/doseVis"; const std::string mitk::rt::UIConstants::ROOT_ISO_PRESETS_PREFERENCE_NODE_ID = "/RT/UI/doseVis/isoPresets"; const std::string mitk::rt::UIConstants::REFERENCE_DOSE_ID = "referenceDose"; const std::string mitk::rt::UIConstants::GLOBAL_REFERENCE_DOSE_SYNC_ID = "globalReferenceDoseSync"; const std::string mitk::rt::UIConstants::DOSE_DISPLAY_ABSOLUTE_ID = "doseDisplayAbsolute"; const std::string mitk::rt::UIConstants::GLOBAL_VISIBILITY_ISOLINES_ID = "globalVisibilityIsoLines"; const std::string mitk::rt::UIConstants::GLOBAL_VISIBILITY_COLORWASH_ID = "globalVisibilityColorWash"; const std::string mitk::rt::UIConstants::SELECTED_ISO_PRESET_ID = "selectedIsoPreset"; const std::string mitk::rt::UIConstants::ISO_LEVEL_DOSE_VALUE_ID = "doseValue"; const std::string mitk::rt::UIConstants::ISO_LEVEL_COLOR_RED_ID = "color_R"; const std::string mitk::rt::UIConstants::ISO_LEVEL_COLOR_GREEN_ID = "color_G"; const std::string mitk::rt::UIConstants::ISO_LEVEL_COLOR_BLUE_ID = "color_B"; const std::string mitk::rt::UIConstants::ISO_LEVEL_VISIBILITY_ISOLINES_ID = "visibleIsoLines"; const std::string mitk::rt::UIConstants::ISO_LEVEL_VISIBILITY_COLORWASH_ID = "visibleColorWash"; + +const mitk::DoseValueAbs mitk::rt::UIConstants::DEFAULT_REFERENCE_DOSE_VALUE = 40.0; + +const std::string mitk::rt::CTKEventConstants::TOPIC_ISO_DOSE_LEVEL_PRESETS = "org/mitk/rt/dosevisualization/presets"; +const std::string mitk::rt::CTKEventConstants::TOPIC_ISO_DOSE_LEVEL_PRESETS_CHANGED = "org/mitk/rt/dosevisualization/presets/CHANGED"; +const std::string mitk::rt::CTKEventConstants::TOPIC_REFERENCE_DOSE = "org/mitk/rt/dosevisualization/referenceDose"; +const std::string mitk::rt::CTKEventConstants::TOPIC_REFERENCE_DOSE_CHANGED = "org/mitk/rt/dosevisualization/referenceDose/CHANGED"; diff --git a/Modules/RTUI/Helper/mitkRTUIConstants.h b/Modules/RTUI/Helper/mitkRTUIConstants.h index 02824c9af8..87b1535479 100644 --- a/Modules/RTUI/Helper/mitkRTUIConstants.h +++ b/Modules/RTUI/Helper/mitkRTUIConstants.h @@ -1,73 +1,86 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ -#ifndef _MITK_RT_CONSTANTS_H_ -#define _MITK_RT_CONSTANTS_H_ +#ifndef _MITK_RT_UI_CONSTANTS_H_ +#define _MITK_RT_UI_CONSTANTS_H_ #include +#include #include "RTUIExports.h" namespace mitk { namespace rt { struct RTUI_EXPORT UIConstants { /** ID/Path of main preference node for RT UI. */ static const std::string ROOT_PREFERENCE_NODE_ID; /** Bool that indicates how the prescribed dose should be defined, if unkown. True: UNKNOWN_PRESCRIBED_DOSE_HANDLING_VALUE should be used as - default dose value in Gy; False: it should be used as fraction of the max dose to determin the prescribed dose.*/ + default dose value in Gy; False: it should be used as fraction of the max dose to determin the prescribed dose.*/ static const std::string UNKNOWN_PRESCRIBED_DOSE_HANDLING_AS_DEFAULT_ID; /** Value that is used to determin unknown prescribed doses.*/ static const std::string UNKNOWN_PRESCRIBED_DOSE_HANDLING_VALUE_ID; /** ID/Path of main preference node where all iso dose level presets are stored (e.g. ROOT_ISO_PRESETS_PREFERENCE_NODE_ID+"/[Preset1]"). */ static const std::string ROOT_ISO_PRESETS_PREFERENCE_NODE_ID; /** ID/Path of main preference for dose visualization preferences. */ static const std::string ROOT_DOSE_VIS_PREFERENCE_NODE_ID; /** ID for the reference dose stored as preference. */ static const std::string REFERENCE_DOSE_ID; /** ID for the preference flag that indicates if the reference dose is synced for all nodes*/ static const std::string GLOBAL_REFERENCE_DOSE_SYNC_ID; /** ID for the flag if dose should be displayed as absoulte dose. */ static const std::string DOSE_DISPLAY_ABSOLUTE_ID; /** ID for the global visiblity switch for iso line visualization. */ static const std::string GLOBAL_VISIBILITY_ISOLINES_ID; /** ID for the global visiblity switch for color wash visualization. */ static const std::string GLOBAL_VISIBILITY_COLORWASH_ID; /** ID for the selected iso preset that should be used (value of ROOT_ISO_PRESETS_PREFERENCE_NODE_ID + value of this key can - be used to construct the passed to the selected preset. */ + be used to construct the passed to the selected preset. */ static const std::string SELECTED_ISO_PRESET_ID; /** ID for the relative dose value of an iso dose level. */ static const std::string ISO_LEVEL_DOSE_VALUE_ID; /** ID for the color (red component) of an iso dose level. */ static const std::string ISO_LEVEL_COLOR_RED_ID; /** ID for the color (green component) of an iso dose level. */ static const std::string ISO_LEVEL_COLOR_GREEN_ID; /** ID for the color (blue component) of an iso dose level. */ static const std::string ISO_LEVEL_COLOR_BLUE_ID; /** ID for the visiblity switch for iso line visualization. */ static const std::string ISO_LEVEL_VISIBILITY_ISOLINES_ID; /** ID for the visiblity switch for color wash visualization. */ static const std::string ISO_LEVEL_VISIBILITY_COLORWASH_ID; + /** Default value used as reference_dose_if not defined by application or data node*/ + static const DoseValueAbs DEFAULT_REFERENCE_DOSE_VALUE; }; + + struct RTUI_EXPORT CTKEventConstants + { + /** ID/Path of main preference node for RT UI. */ + static const std::string TOPIC_REFERENCE_DOSE; + static const std::string TOPIC_REFERENCE_DOSE_CHANGED; + static const std::string TOPIC_ISO_DOSE_LEVEL_PRESETS; + static const std::string TOPIC_ISO_DOSE_LEVEL_PRESETS_CHANGED; + }; + } } #endif diff --git a/Modules/RTUI/Qmitk/QmitkDoseColorDelegate.h b/Modules/RTUI/Qmitk/QmitkDoseColorDelegate.h index 0dd9ba6e95..f4e9663a80 100644 --- a/Modules/RTUI/Qmitk/QmitkDoseColorDelegate.h +++ b/Modules/RTUI/Qmitk/QmitkDoseColorDelegate.h @@ -1,44 +1,44 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QmitkDoseColorDelegate_h #define QmitkDoseColorDelegate_h #include #include "RTUIExports.h" /** \class QmitkDoseColorDelegate - \brief An item delegate for rendering and editing dose color in a QTableView.*/ +\brief An item delegate for rendering and editing dose color in a QTableView.*/ class RTUI_EXPORT QmitkDoseColorDelegate : public QStyledItemDelegate { Q_OBJECT - public: - /// - /// Creates a new PropertyDelegate. - /// - QmitkDoseColorDelegate(QObject *parent = 0); +public: + /// + /// Creates a new PropertyDelegate. + /// + QmitkDoseColorDelegate(QObject *parent = 0); - bool editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option, - const QModelIndex &index); + bool editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option, + const QModelIndex &index); - void paint(QPainter *painter, const QStyleOptionViewItem &option, - const QModelIndex &index) const; + void paint(QPainter *painter, const QStyleOptionViewItem &option, + const QModelIndex &index) const; }; #endif diff --git a/Modules/RTUI/Qmitk/QmitkDoseValueDelegate.cpp b/Modules/RTUI/Qmitk/QmitkDoseValueDelegate.cpp index 8c505ebdae..34ed4b28eb 100644 --- a/Modules/RTUI/Qmitk/QmitkDoseValueDelegate.cpp +++ b/Modules/RTUI/Qmitk/QmitkDoseValueDelegate.cpp @@ -1,113 +1,113 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "QmitkDoseValueDelegate.h" #include #include #include #include QmitkDoseValueDelegate::QmitkDoseValueDelegate(QObject * /*parent*/) { } void QmitkDoseValueDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option , const QModelIndex &index) const { QVariant data = index.data(Qt::DisplayRole); QStyleOptionViewItemV4 opt = option; initStyleOption(&opt, index); QStyle *style = QApplication::style(); style->drawItemText(painter, opt.rect.adjusted(0,0,-5,0), Qt::AlignRight | Qt::AlignVCenter, opt.palette,true, data.toString()); } QWidget* QmitkDoseValueDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option , const QModelIndex &index) const { QVariant data = index.data(Qt::EditRole); QVariant displayData = index.data(Qt::DisplayRole); QVariant absoluteDose = index.data(Qt::UserRole+1); if(data.isValid()) { QDoubleSpinBox* spinBox = new QDoubleSpinBox(parent); spinBox->setDecimals(2); if (absoluteDose.toBool()) { spinBox->setSingleStep(0.5); spinBox->setSuffix(QString(" Gy")); } else { spinBox->setSingleStep(1.0); spinBox->setSuffix(QString(" %")); } spinBox->setMinimum(0.0); spinBox->setMaximum(9999.0); spinBox->installEventFilter( const_cast(this) ); return spinBox; } else return new QLabel(displayData.toString(), parent); } void QmitkDoseValueDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const { QVariant data = index.data(Qt::EditRole); if(data.isValid()) { QDoubleSpinBox* spinBox = qobject_cast(editor); if (spinBox) { spinBox->setValue(data.toDouble()); } else { QStyledItemDelegate::setEditorData(editor, index); } } } void QmitkDoseValueDelegate::setModelData(QWidget *editor, QAbstractItemModel* model , const QModelIndex &index) const { QVariant data = index.data(Qt::EditRole); if(data.isValid()) { - QDoubleSpinBox* spinBox = qobject_cast(editor); - double doubleValue = spinBox->value(); + QDoubleSpinBox* spinBox = qobject_cast(editor); + double doubleValue = spinBox->value(); - QVariant doubleValueVariant(doubleValue); - model->setData(index, doubleValueVariant); + QVariant doubleValueVariant(doubleValue); + model->setData(index, doubleValueVariant); } else { - QStyledItemDelegate::setModelData(editor, model, index); + QStyledItemDelegate::setModelData(editor, model, index); } } diff --git a/Modules/RTUI/Qmitk/QmitkDoseValueDelegate.h b/Modules/RTUI/Qmitk/QmitkDoseValueDelegate.h index 60c26f270a..711b536170 100644 --- a/Modules/RTUI/Qmitk/QmitkDoseValueDelegate.h +++ b/Modules/RTUI/Qmitk/QmitkDoseValueDelegate.h @@ -1,63 +1,63 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QmitkDoseValueDelegate_h #define QmitkDoseValueDelegate_h #include #include "RTUIExports.h" /** \class QmitkDoseValueDelegate - \brief An item delegate for rendering and editing dose values. - The delegate assumes that the model uses the role Qt::UserRole+1 - to indicate if the returned dose value is an absolute (data(Qt::UserRole+1) == true) - or an relative dose (data(Qt::UserRole+1) == false).*/ +\brief An item delegate for rendering and editing dose values. +The delegate assumes that the model uses the role Qt::UserRole+1 +to indicate if the returned dose value is an absolute (data(Qt::UserRole+1) == true) +or an relative dose (data(Qt::UserRole+1) == false).*/ class RTUI_EXPORT QmitkDoseValueDelegate : public QStyledItemDelegate { Q_OBJECT - public: - /// - /// Creates a new PropertyDelegate. - /// - QmitkDoseValueDelegate(QObject *parent = 0); - - /// - /// Renders a specific property (overwritten from QItemDelegate) - /// - void paint(QPainter *painter, const QStyleOptionViewItem &option - , const QModelIndex &index) const; - - /// - /// Create an editor for a specific property (overwritten from QItemDelegate) - /// - QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option - , const QModelIndex &index) const; - - /// - /// Create an editor for a specific property (overwritten from QItemDelegate) - /// - void setEditorData(QWidget *editor, const QModelIndex &index) const; - - /// - /// When the user accepts input this func commits the data to the model (overwritten from QItemDelegate) - /// - void setModelData(QWidget *editor, QAbstractItemModel* model, const QModelIndex &index) const; +public: + /// + /// Creates a new PropertyDelegate. + /// + QmitkDoseValueDelegate(QObject *parent = 0); + + /// + /// Renders a specific property (overwritten from QItemDelegate) + /// + void paint(QPainter *painter, const QStyleOptionViewItem &option + , const QModelIndex &index) const; + + /// + /// Create an editor for a specific property (overwritten from QItemDelegate) + /// + QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option + , const QModelIndex &index) const; + + /// + /// Create an editor for a specific property (overwritten from QItemDelegate) + /// + void setEditorData(QWidget *editor, const QModelIndex &index) const; + + /// + /// When the user accepts input this func commits the data to the model (overwritten from QItemDelegate) + /// + void setModelData(QWidget *editor, QAbstractItemModel* model, const QModelIndex &index) const; }; #endif /* QMITKPROPERTIESTABLEMODEL_H_ */ diff --git a/Modules/RTUI/Qmitk/QmitkDoseVisualStyleDelegate.h b/Modules/RTUI/Qmitk/QmitkDoseVisualStyleDelegate.h index ec9f753277..6ee24667c8 100644 --- a/Modules/RTUI/Qmitk/QmitkDoseVisualStyleDelegate.h +++ b/Modules/RTUI/Qmitk/QmitkDoseVisualStyleDelegate.h @@ -1,47 +1,47 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QmitkDoseVisualStyleDelegate_h #define QmitkDoseVisualStyleDelegate_h /// Toolkit includes. #include #include "RTUIExports.h" /** \class QmitkDoseVisualStyleDelegate - \brief An item delegate for rendering and editing dose visualization options. - The delegate is used to handle aspects of a isodose level like visualization - of the isodose lines or colorwash display.*/ +\brief An item delegate for rendering and editing dose visualization options. +The delegate is used to handle aspects of a isodose level like visualization +of the isodose lines or colorwash display.*/ class RTUI_EXPORT QmitkDoseVisualStyleDelegate : public QStyledItemDelegate { Q_OBJECT - public: +public: - QmitkDoseVisualStyleDelegate(QObject *parent = 0); + QmitkDoseVisualStyleDelegate(QObject *parent = 0); - void paint(QPainter *painter, const QStyleOptionViewItem &option - , const QModelIndex &index) const; + void paint(QPainter *painter, const QStyleOptionViewItem &option + , const QModelIndex &index) const; - bool editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option, - const QModelIndex &index); + bool editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option, + const QModelIndex &index); }; #endif diff --git a/Modules/RTUI/Qmitk/QmitkFreeIsoDoseLevelWidget.cpp b/Modules/RTUI/Qmitk/QmitkFreeIsoDoseLevelWidget.cpp index b38d57287f..bfd3c52f86 100644 --- a/Modules/RTUI/Qmitk/QmitkFreeIsoDoseLevelWidget.cpp +++ b/Modules/RTUI/Qmitk/QmitkFreeIsoDoseLevelWidget.cpp @@ -1,145 +1,145 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "QmitkFreeIsoDoseLevelWidget.h" QmitkFreeIsoDoseLevelWidget::QmitkFreeIsoDoseLevelWidget(QWidget*): m_ReferenceDose (30.0), m_InternalUpdate(false) { this->setupUi(this); this->colorBtn->setDisplayColorName(false); this->m_IsoDoseLevel = mitk::IsoDoseLevel::New(); connect(this->sbAbsValue, SIGNAL(valueChanged(double)), this, SLOT(OnAbsValueChanged(double))); connect(this->sbRelValue, SIGNAL(valueChanged(double)), this, SLOT(OnRelValueChanged(double))); connect(this->doseSlider, SIGNAL(valueChanged(int)), this, SLOT(OnSliderChanged(int))); connect(this->checkVisibleIso, SIGNAL(clicked(bool)), this, SLOT(OnVisibleClicked(bool))); connect(this->colorBtn, SIGNAL(colorChanged(QColor)), this, SLOT(OnColorChanged(QColor))); } - mitk::DoseValueAbs - QmitkFreeIsoDoseLevelWidget:: - getReferenceDose() const - { - return this->m_ReferenceDose; - }; +mitk::DoseValueAbs + QmitkFreeIsoDoseLevelWidget:: + getReferenceDose() const +{ + return this->m_ReferenceDose; +}; - mitk::IsoDoseLevel* - QmitkFreeIsoDoseLevelWidget:: - getIsoDoseLevel() const - { - return this->m_IsoDoseLevel; - }; +mitk::IsoDoseLevel* + QmitkFreeIsoDoseLevelWidget:: + getIsoDoseLevel() const +{ + return this->m_IsoDoseLevel; +}; - void QmitkFreeIsoDoseLevelWidget:: - setReferenceDose(double newReferenceDose) +void QmitkFreeIsoDoseLevelWidget:: + setReferenceDose(double newReferenceDose) +{ + if (newReferenceDose != m_ReferenceDose) { - if (newReferenceDose != m_ReferenceDose) - { - this->m_ReferenceDose = newReferenceDose; - this->update(); - } - }; + this->m_ReferenceDose = newReferenceDose; + this->update(); + } +}; - void QmitkFreeIsoDoseLevelWidget:: - setIsoDoseLevel(mitk::IsoDoseLevel* level) +void QmitkFreeIsoDoseLevelWidget:: + setIsoDoseLevel(mitk::IsoDoseLevel* level) +{ + if (level != m_IsoDoseLevel) { - if (level != m_IsoDoseLevel) + if(!level) { - if(!level) - { - mitkThrow() << "Error. Cannot set iso dose level for widget to NULL pointer."; - } - - this->m_IsoDoseLevel = level; - this->update(); + mitkThrow() << "Error. Cannot set iso dose level for widget to NULL pointer."; } + + this->m_IsoDoseLevel = level; + this->update(); } +} - void QmitkFreeIsoDoseLevelWidget:: - OnRelValueChanged(double newValue) +void QmitkFreeIsoDoseLevelWidget:: + OnRelValueChanged(double newValue) +{ + if(!m_InternalUpdate) { - if(!m_InternalUpdate) - { - updateValue(newValue/100.0); - } - }; + updateValue(newValue/100.0); + } +}; - void QmitkFreeIsoDoseLevelWidget:: - OnAbsValueChanged(double newValue) +void QmitkFreeIsoDoseLevelWidget:: + OnAbsValueChanged(double newValue) +{ + if(!m_InternalUpdate) { - if(!m_InternalUpdate) - { - updateValue(newValue/this->m_ReferenceDose); - } - }; + updateValue(newValue/this->m_ReferenceDose); + } +}; - void QmitkFreeIsoDoseLevelWidget:: - OnSliderChanged(int newValue) +void QmitkFreeIsoDoseLevelWidget:: + OnSliderChanged(int newValue) +{ + if(!m_InternalUpdate) { - if(!m_InternalUpdate) - { - updateValue(newValue/100.0); - } - }; + updateValue(newValue/100.0); + } +}; - void QmitkFreeIsoDoseLevelWidget:: - OnVisibleClicked(bool checked) - { - this->m_IsoDoseLevel->SetVisibleIsoLine(checked); - emit VisualizationStyleChanged(this->m_IsoDoseLevel); - }; +void QmitkFreeIsoDoseLevelWidget:: + OnVisibleClicked(bool checked) +{ + this->m_IsoDoseLevel->SetVisibleIsoLine(checked); + emit VisualizationStyleChanged(this->m_IsoDoseLevel); +}; - void QmitkFreeIsoDoseLevelWidget:: - OnColorChanged(QColor color) - { - mitk::IsoDoseLevel::ColorType doseColor; - doseColor.SetRed(color.redF()); - doseColor.SetGreen(color.greenF()); - doseColor.SetBlue(color.blueF()); - this->m_IsoDoseLevel->SetColor(doseColor); - emit ColorChanged(this->m_IsoDoseLevel); - }; - - void QmitkFreeIsoDoseLevelWidget:: - updateValue(mitk::DoseValueRel newDose) - { - m_InternalUpdate = true; +void QmitkFreeIsoDoseLevelWidget:: + OnColorChanged(QColor color) +{ + mitk::IsoDoseLevel::ColorType doseColor; + doseColor.SetRed(color.redF()); + doseColor.SetGreen(color.greenF()); + doseColor.SetBlue(color.blueF()); + this->m_IsoDoseLevel->SetColor(doseColor); + emit ColorChanged(this->m_IsoDoseLevel); +}; + +void QmitkFreeIsoDoseLevelWidget:: + updateValue(mitk::DoseValueRel newDose) +{ + m_InternalUpdate = true; - mitk::DoseValueRel oldValue = this->m_IsoDoseLevel->GetDoseValue(); - this->m_IsoDoseLevel->SetDoseValue(newDose); - this->sbAbsValue->setValue(newDose*this->m_ReferenceDose); - this->sbRelValue->setValue(newDose*100); - this->doseSlider->setValue(newDose*100); + mitk::DoseValueRel oldValue = this->m_IsoDoseLevel->GetDoseValue(); + this->m_IsoDoseLevel->SetDoseValue(newDose); + this->sbAbsValue->setValue(newDose*this->m_ReferenceDose); + this->sbRelValue->setValue(newDose*100); + this->doseSlider->setValue(newDose*100); - m_InternalUpdate = false; + m_InternalUpdate = false; - emit ValueChanged(this->m_IsoDoseLevel,oldValue); - }; + emit ValueChanged(this->m_IsoDoseLevel,oldValue); +}; - void QmitkFreeIsoDoseLevelWidget:: - update() - { - updateValue(this->m_IsoDoseLevel->GetDoseValue()); +void QmitkFreeIsoDoseLevelWidget:: + update() +{ + updateValue(this->m_IsoDoseLevel->GetDoseValue()); - this->checkVisibleIso->setChecked(this->m_IsoDoseLevel->GetVisibleIsoLine()); + this->checkVisibleIso->setChecked(this->m_IsoDoseLevel->GetVisibleIsoLine()); - QColor color; - color.setRgbF(this->m_IsoDoseLevel->GetColor().GetRed(),this->m_IsoDoseLevel->GetColor().GetGreen(),this->m_IsoDoseLevel->GetColor().GetBlue()); - this->colorBtn->setColor(color); - }; + QColor color; + color.setRgbF(this->m_IsoDoseLevel->GetColor().GetRed(),this->m_IsoDoseLevel->GetColor().GetGreen(),this->m_IsoDoseLevel->GetColor().GetBlue()); + this->colorBtn->setColor(color); +}; diff --git a/Modules/RTUI/Qmitk/QmitkFreeIsoDoseLevelWidget.h b/Modules/RTUI/Qmitk/QmitkFreeIsoDoseLevelWidget.h index 12d2698ff0..daf3a6d421 100644 --- a/Modules/RTUI/Qmitk/QmitkFreeIsoDoseLevelWidget.h +++ b/Modules/RTUI/Qmitk/QmitkFreeIsoDoseLevelWidget.h @@ -1,78 +1,78 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QMITK_FREE_ISO_DOSE_LEVEL_WIDGET_H #define QMITK_FREE_ISO_DOSE_LEVEL_WIDGET_H #include "RTUIExports.h" #include "ui_QmitkFreeIsoDoseLevelWidget.h" #include #include "mitkIsoDoseLevel.h" /** - * \class QmitkFreeIsoDoseLevelWidget - * \brief Widget that allows to show and edit the content of an mitk::IsoDoseLevel instance. - */ +* \class QmitkFreeIsoDoseLevelWidget +* \brief Widget that allows to show and edit the content of an mitk::IsoDoseLevel instance. +*/ class RTUI_EXPORT QmitkFreeIsoDoseLevelWidget : public QWidget, private Ui::QmitkFreeIsoDoseLevelWidget { Q_OBJECT public: QmitkFreeIsoDoseLevelWidget(QWidget* parent=0); mitk::DoseValueAbs getReferenceDose() const; mitk::IsoDoseLevel* getIsoDoseLevel() const; signals: void ValueChanged(mitk::IsoDoseLevel*, mitk::DoseValueRel oldValue); void ColorChanged(mitk::IsoDoseLevel*); void VisualizationStyleChanged(mitk::IsoDoseLevel*); -public Q_SLOTS: - /** + public Q_SLOTS: + /** * \brief Slot that can be used to set the reference dose. */ - void setReferenceDose(double newReferenceDose); + void setReferenceDose(double newReferenceDose); - /** + /** * \brief Slot that can be used to set the dose level instance that should be handled by the widget. */ - void setIsoDoseLevel(mitk::IsoDoseLevel* level); + void setIsoDoseLevel(mitk::IsoDoseLevel* level); - void OnRelValueChanged(double newValue); - void OnAbsValueChanged(double newValue); - void OnSliderChanged(int newValue); - void OnVisibleClicked(bool checked); - void OnColorChanged(QColor color); + void OnRelValueChanged(double newValue); + void OnAbsValueChanged(double newValue); + void OnSliderChanged(int newValue); + void OnVisibleClicked(bool checked); + void OnColorChanged(QColor color); protected: /** - * \brief Updates the widget according to its current settings. - */ + * \brief Updates the widget according to its current settings. + */ void update(); void updateValue(mitk::DoseValueRel newDose); mitk::DoseValueAbs m_ReferenceDose; mitk::IsoDoseLevel::Pointer m_IsoDoseLevel; bool m_InternalUpdate; }; #endif // QmitkFreeIsoDoseLevelWidget_H diff --git a/Modules/RTUI/Qmitk/QmitkIsoDoseLevelSetModel.cpp b/Modules/RTUI/Qmitk/QmitkIsoDoseLevelSetModel.cpp index 6f938898ff..8b0bcdcd7e 100644 --- a/Modules/RTUI/Qmitk/QmitkIsoDoseLevelSetModel.cpp +++ b/Modules/RTUI/Qmitk/QmitkIsoDoseLevelSetModel.cpp @@ -1,430 +1,450 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ - -#include "QmitkIsoDoseLevelSetModel.h" - #include #include +#include "QmitkIsoDoseLevelSetModel.h" +#include "mitkRTUIConstants.h" + QmitkIsoDoseLevelSetModel:: -QmitkIsoDoseLevelSetModel(QObject *parent) : - QAbstractTableModel(parent), m_referenceDose(40.0), m_showAbsoluteDose(false), m_visibilityEditOnly(false) + QmitkIsoDoseLevelSetModel(QObject *parent) : +QAbstractTableModel(parent), m_referenceDose(mitk::rt::UIConstants::DEFAULT_REFERENCE_DOSE_VALUE), m_showAbsoluteDose(false), m_visibilityEditOnly(false), m_modified(false) { m_DoseSet = mitk::IsoDoseLevelSet::New(); } void -QmitkIsoDoseLevelSetModel:: -setIsoDoseLevelSet(mitk::IsoDoseLevelSet *pSet) + QmitkIsoDoseLevelSetModel:: + setIsoDoseLevelSet(mitk::IsoDoseLevelSet *pSet) { if (pSet) { emit beginResetModel(); m_DoseSet = pSet; + m_modified = false; emit endResetModel(); } }; int -QmitkIsoDoseLevelSetModel:: -rowCount(const QModelIndex &parent) const + QmitkIsoDoseLevelSetModel:: + rowCount(const QModelIndex &parent) const { - if(parent.isValid()) - { - return 0; - } + if(parent.isValid()) + { + return 0; + } - return m_DoseSet->Size(); + return m_DoseSet->Size(); } int -QmitkIsoDoseLevelSetModel:: -columnCount(const QModelIndex &parent) const + QmitkIsoDoseLevelSetModel:: + columnCount(const QModelIndex &parent) const { - if(parent.isValid()) - return 0; + if(parent.isValid()) + return 0; - return 4; + return 4; } QVariant -QmitkIsoDoseLevelSetModel:: -data(const QModelIndex &index, int role) const + QmitkIsoDoseLevelSetModel:: + data(const QModelIndex &index, int role) const { - if(!index.isValid()) - return QVariant(); + if(!index.isValid()) + return QVariant(); - QVariant result; + QVariant result; - if(index.row()Size()) - { - const mitk::IsoDoseLevel& level = m_DoseSet->GetIsoDoseLevel(static_cast(index.row())); + if(index.row()Size()) + { + const mitk::IsoDoseLevel& level = m_DoseSet->GetIsoDoseLevel(static_cast(index.row())); - switch(index.column()) + switch(index.column()) + { + case 0: + if(role == Qt::EditRole || role == Qt::DecorationRole) + { + QColor color; + color.setRgbF(level.GetColor().GetRed(),level.GetColor().GetGreen(),level.GetColor().GetBlue()); + result = QVariant(color); + } + else if (role == Qt::ToolTipRole) + { + result = QVariant("Color of the iso dose level."); + } + break; + case 1: + if(role == Qt::DisplayRole) + { + if (this->m_showAbsoluteDose) { - case 0: - if(role == Qt::EditRole || role == Qt::DecorationRole) - { - QColor color; - color.setRgbF(level.GetColor().GetRed(),level.GetColor().GetGreen(),level.GetColor().GetBlue()); - result = QVariant(color); - } - else if (role == Qt::ToolTipRole) - { - result = QVariant("Color of the iso dose level."); - } - break; - case 1: - if(role == Qt::DisplayRole) - { - if (this->m_showAbsoluteDose) - { - result = QVariant(QString::number(level.GetDoseValue()*this->m_referenceDose)+QString(" Gy")); - } - else - { - result = QVariant(QString::number(level.GetDoseValue()*100)+QString(" %")); - } - } - else if(role == Qt::EditRole) - { - if (this->m_showAbsoluteDose) - { - result = QVariant(level.GetDoseValue()*this->m_referenceDose); - } - else - { - result = QVariant(level.GetDoseValue()*100); - } - } - else if (role == Qt::ToolTipRole) - { - result = QVariant("Minimum dose value of this level / Value of the iso line."); - } - else if (role == Qt::UserRole+1) - { - result = QVariant(this->m_showAbsoluteDose); - } - break; - case 2: - if(role == Qt::DisplayRole || role == Qt::EditRole) - { - result = QVariant(level.GetVisibleIsoLine()); - } - else if (role == Qt::ToolTipRole) - { - result = QVariant("Show isoline for this dose level."); - } - break; - case 3: - if(role == Qt::DisplayRole || role == Qt::EditRole) - { - result = QVariant(level.GetVisibleColorWash()); - } - else if (role == Qt::ToolTipRole) - { - result = QVariant("Show colorwash for this dose level."); - } - break; + result = QVariant(QString::number(level.GetDoseValue()*this->m_referenceDose)+QString(" Gy")); } + else + { + result = QVariant(QString::number(level.GetDoseValue()*100)+QString(" %")); + } + } + else if(role == Qt::EditRole) + { + if (this->m_showAbsoluteDose) + { + result = QVariant(level.GetDoseValue()*this->m_referenceDose); + } + else + { + result = QVariant(level.GetDoseValue()*100); + } + } + else if (role == Qt::ToolTipRole) + { + result = QVariant("Minimum dose value of this level / Value of the iso line."); + } + else if (role == Qt::UserRole+1) + { + result = QVariant(this->m_showAbsoluteDose); + } + break; + case 2: + if(role == Qt::DisplayRole || role == Qt::EditRole) + { + result = QVariant(level.GetVisibleIsoLine()); + } + else if (role == Qt::ToolTipRole) + { + result = QVariant("Show isoline for this dose level."); + } + break; + case 3: + if(role == Qt::DisplayRole || role == Qt::EditRole) + { + result = QVariant(level.GetVisibleColorWash()); + } + else if (role == Qt::ToolTipRole) + { + result = QVariant("Show colorwash for this dose level."); + } + break; } + } - return result; + return result; } Qt::ItemFlags -QmitkIsoDoseLevelSetModel:: -flags(const QModelIndex &index) const + QmitkIsoDoseLevelSetModel:: + flags(const QModelIndex &index) const { Qt::ItemFlags flags = QAbstractItemModel::flags(index); if(index.row()Size()) { if (index.column() < 4) { if ((index.column() > 1) || (index.column() >= 0 && !this->m_visibilityEditOnly)) { flags |= Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable; } else if (index.column() >= 0 && this->m_visibilityEditOnly) { flags |= Qt::ItemIsEnabled | Qt::ItemIsSelectable; } } } return flags; } QVariant -QmitkIsoDoseLevelSetModel:: -headerData(int section, Qt::Orientation orientation, int role) const + QmitkIsoDoseLevelSetModel:: + headerData(int section, Qt::Orientation orientation, int role) const { - if( (Qt::DisplayRole == role) && - (Qt::Horizontal == orientation)) + if( (Qt::DisplayRole == role) && + (Qt::Horizontal == orientation)) + { + if (section==0) { - if (section==0) - { - return QVariant("Color"); - } - else if (section==1) - { - if (m_showAbsoluteDose) - { - return QVariant("Dose [Gy]"); - } - else - { - return QVariant("Dose [%]"); - } - } - else if (section==2) - { - return QVariant("IsoLines"); - } - else if (section==3) - { - return QVariant("ColorWash"); - } + return QVariant("Color"); } - return QVariant(); + else if (section==1) + { + if (m_showAbsoluteDose) + { + return QVariant("Dose [Gy]"); + } + else + { + return QVariant("Dose [%]"); + } + } + else if (section==2) + { + return QVariant("IsoLines"); + } + else if (section==3) + { + return QVariant("ColorWash"); + } + } + return QVariant(); } bool -QmitkIsoDoseLevelSetModel:: -setData(const QModelIndex &index, const QVariant &value, int role) + QmitkIsoDoseLevelSetModel:: + setData(const QModelIndex &index, const QVariant &value, int role) { - if(!index.isValid() || (m_DoseSet->Size() <= index.row()) || (index.column()>3)) + if(!index.isValid() || (m_DoseSet->Size() <= index.row()) || (index.column()>3)) + { + return false; + } + + if(Qt::EditRole == role) + { + const mitk::IsoDoseLevel& level = m_DoseSet->GetIsoDoseLevel(static_cast(index.row())); + mitk::IsoDoseLevel::Pointer pNewLevel = level.Clone(); + switch(index.column()) { - return false; + case 0: + { + QColor val = value.value(); + mitk::IsoDoseLevel::ColorType color; + color.SetRed(val.redF()); + color.SetGreen(val.greenF()); + color.SetBlue(val.blueF()); + pNewLevel->SetColor(color); + emit dataChanged(index,index); + break; + } + case 1: + if (this->m_showAbsoluteDose) + { + pNewLevel->SetDoseValue(value.toDouble()/this->m_referenceDose); + } + else + { + pNewLevel->SetDoseValue(value.toDouble()/100.0); + } + emit dataChanged(index,index); + break; + case 2: + pNewLevel->SetVisibleIsoLine(value.toBool()); + emit dataChanged(index,index); + break; + case 3: + pNewLevel->SetVisibleColorWash(value.toBool()); + emit dataChanged(index,index); + break; } - if(Qt::EditRole == role) - { - const mitk::IsoDoseLevel& level = m_DoseSet->GetIsoDoseLevel(static_cast(index.row())); - mitk::IsoDoseLevel::Pointer pNewLevel = level.Clone(); - switch(index.column()) - { - case 0: - { - QColor val = value.value(); - mitk::IsoDoseLevel::ColorType color; - color.SetRed(val.redF()); - color.SetGreen(val.greenF()); - color.SetBlue(val.blueF()); - pNewLevel->SetColor(color); - emit dataChanged(index,index); - break; - } - case 1: - if (this->m_showAbsoluteDose) - { - pNewLevel->SetDoseValue(value.toDouble()/this->m_referenceDose); - } - else - { - pNewLevel->SetDoseValue(value.toDouble()/100.0); - } - emit dataChanged(index,index); - break; - case 2: - pNewLevel->SetVisibleIsoLine(value.toBool()); - emit dataChanged(index,index); - break; - case 3: - pNewLevel->SetVisibleColorWash(value.toBool()); - emit dataChanged(index,index); - break; - } + emit beginResetModel(); - emit beginResetModel(); + m_DoseSet->DeleteIsoDoseLevel(static_cast(index.row())); + m_DoseSet->SetIsoDoseLevel(pNewLevel); - m_DoseSet->DeleteIsoDoseLevel(static_cast(index.row())); - m_DoseSet->SetIsoDoseLevel(pNewLevel); + m_modified = true; - emit endResetModel(); + emit endResetModel(); - return true; - } + return true; + } - return false; + return false; }; void QmitkIsoDoseLevelSetModel:: setReferenceDose(double newReferenceDose) { if (newReferenceDose<= 0) { - mitkThrow() << "Error. Passed prescribed dose is negative or equals 0."; + mitkThrow() << "Error. Passed prescribed dose is negative or equals 0."; } if (newReferenceDose != m_referenceDose) { this->m_referenceDose = newReferenceDose; if(m_showAbsoluteDose) { emit beginResetModel(); emit endResetModel(); } } }; void QmitkIsoDoseLevelSetModel:: setShowAbsoluteDose(bool showAbsoluteDose) { if (showAbsoluteDose != m_showAbsoluteDose) { emit beginResetModel(); this->m_showAbsoluteDose = showAbsoluteDose; emit endResetModel(); } }; void QmitkIsoDoseLevelSetModel::setVisibilityEditOnly(bool onlyVisibility) { if (onlyVisibility != m_visibilityEditOnly) { emit beginResetModel(); this->m_visibilityEditOnly = onlyVisibility; emit endResetModel(); } }; bool QmitkIsoDoseLevelSetModel:: getShowAbsoluteDose() const { return this->m_showAbsoluteDose; }; mitk::DoseValueAbs QmitkIsoDoseLevelSetModel:: getReferenceDose() const { return this->m_referenceDose; }; bool QmitkIsoDoseLevelSetModel:: getVisibilityEditOnly() const { return this->m_visibilityEditOnly; }; void QmitkIsoDoseLevelSetModel::switchVisibilityIsoLines(bool activate) { emit beginResetModel(); for (mitk::IsoDoseLevelSet::IsoLevelIndexType pos = 0; pos < m_DoseSet->Size(); ++pos) { mitk::IsoDoseLevel::Pointer pNewLevel = m_DoseSet->GetIsoDoseLevel(pos).Clone(); pNewLevel->SetVisibleIsoLine(activate); m_DoseSet->SetIsoDoseLevel(pNewLevel); } + m_modified = true; + emit endResetModel(); } void QmitkIsoDoseLevelSetModel::switchVisibilityColorWash(bool activate) +{ + emit beginResetModel(); + + for (mitk::IsoDoseLevelSet::IsoLevelIndexType pos = 0; pos < m_DoseSet->Size(); ++pos) { - emit beginResetModel(); + mitk::IsoDoseLevel::Pointer pNewLevel = m_DoseSet->GetIsoDoseLevel(pos).Clone(); + pNewLevel->SetVisibleColorWash(activate); + m_DoseSet->SetIsoDoseLevel(pNewLevel); + } - for (mitk::IsoDoseLevelSet::IsoLevelIndexType pos = 0; pos < m_DoseSet->Size(); ++pos) - { - mitk::IsoDoseLevel::Pointer pNewLevel = m_DoseSet->GetIsoDoseLevel(pos).Clone(); - pNewLevel->SetVisibleColorWash(activate); - m_DoseSet->SetIsoDoseLevel(pNewLevel); - } + m_modified = true; - emit endResetModel(); + emit endResetModel(); } void QmitkIsoDoseLevelSetModel::invertVisibilityIsoLines() +{ + emit beginResetModel(); + + for (mitk::IsoDoseLevelSet::IsoLevelIndexType pos = 0; pos < m_DoseSet->Size(); ++pos) { - emit beginResetModel(); + mitk::IsoDoseLevel::Pointer pNewLevel = m_DoseSet->GetIsoDoseLevel(pos).Clone(); + pNewLevel->SetVisibleIsoLine(!pNewLevel->GetVisibleIsoLine()); + m_DoseSet->SetIsoDoseLevel(pNewLevel); + } - for (mitk::IsoDoseLevelSet::IsoLevelIndexType pos = 0; pos < m_DoseSet->Size(); ++pos) - { - mitk::IsoDoseLevel::Pointer pNewLevel = m_DoseSet->GetIsoDoseLevel(pos).Clone(); - pNewLevel->SetVisibleIsoLine(!pNewLevel->GetVisibleIsoLine()); - m_DoseSet->SetIsoDoseLevel(pNewLevel); - } + m_modified = true; - emit endResetModel(); + emit endResetModel(); } void QmitkIsoDoseLevelSetModel::invertVisibilityColorWash() +{ + emit beginResetModel(); + + for (mitk::IsoDoseLevelSet::IsoLevelIndexType pos = 0; pos < m_DoseSet->Size(); ++pos) { - emit beginResetModel(); + mitk::IsoDoseLevel::Pointer pNewLevel = m_DoseSet->GetIsoDoseLevel(pos).Clone(); + pNewLevel->SetVisibleColorWash(!pNewLevel->GetVisibleColorWash()); + m_DoseSet->SetIsoDoseLevel(pNewLevel); + } - for (mitk::IsoDoseLevelSet::IsoLevelIndexType pos = 0; pos < m_DoseSet->Size(); ++pos) - { - mitk::IsoDoseLevel::Pointer pNewLevel = m_DoseSet->GetIsoDoseLevel(pos).Clone(); - pNewLevel->SetVisibleColorWash(!pNewLevel->GetVisibleColorWash()); - m_DoseSet->SetIsoDoseLevel(pNewLevel); - } + m_modified = true; - emit endResetModel(); + emit endResetModel(); } void QmitkIsoDoseLevelSetModel::swapVisibility() +{ + emit beginResetModel(); + + for (mitk::IsoDoseLevelSet::IsoLevelIndexType pos = 0; pos < m_DoseSet->Size(); ++pos) { - emit beginResetModel(); + mitk::IsoDoseLevel::Pointer pNewLevel = m_DoseSet->GetIsoDoseLevel(pos).Clone(); + bool colorWash = pNewLevel->GetVisibleColorWash(); + pNewLevel->SetVisibleColorWash(pNewLevel->GetVisibleIsoLine()); + pNewLevel->SetVisibleIsoLine(colorWash); + m_DoseSet->SetIsoDoseLevel(pNewLevel); + } - for (mitk::IsoDoseLevelSet::IsoLevelIndexType pos = 0; pos < m_DoseSet->Size(); ++pos) - { - mitk::IsoDoseLevel::Pointer pNewLevel = m_DoseSet->GetIsoDoseLevel(pos).Clone(); - bool colorWash = pNewLevel->GetVisibleColorWash(); - pNewLevel->SetVisibleColorWash(pNewLevel->GetVisibleIsoLine()); - pNewLevel->SetVisibleIsoLine(colorWash); - m_DoseSet->SetIsoDoseLevel(pNewLevel); - } + m_modified = true; - emit endResetModel(); + emit endResetModel(); } void QmitkIsoDoseLevelSetModel::addLevel() { mitk::IsoDoseLevel::DoseValueType doseVal = 0.01; if (m_DoseSet->Size()>0) { doseVal = m_DoseSet->GetIsoDoseLevel(m_DoseSet->Size()-1).GetDoseValue()+0.01; } mitk::IsoDoseLevel::Pointer pNewLevel = mitk::IsoDoseLevel::New(doseVal, mitk::IsoDoseLevel::ColorType(), true, true); emit beginResetModel(); m_DoseSet->SetIsoDoseLevel(pNewLevel); - emit endResetModel(); + m_modified = true; + emit endResetModel(); } void QmitkIsoDoseLevelSetModel::deleteLevel(const QModelIndex &index) { - if(!index.isValid() || (m_DoseSet->Size() <= index.row()) || (index.column()>3)) - { - return; - } + if(!index.isValid() || (m_DoseSet->Size() <= index.row()) || (index.column()>3)) + { + return; + } emit beginResetModel(); m_DoseSet->DeleteIsoDoseLevel(static_cast(index.row())); - emit endResetModel(); + m_modified = true; + emit endResetModel(); +} + +bool QmitkIsoDoseLevelSetModel::isModified() +{ + return m_modified; } diff --git a/Modules/RTUI/Qmitk/QmitkIsoDoseLevelSetModel.h b/Modules/RTUI/Qmitk/QmitkIsoDoseLevelSetModel.h index 9116bff569..b74ebef576 100644 --- a/Modules/RTUI/Qmitk/QmitkIsoDoseLevelSetModel.h +++ b/Modules/RTUI/Qmitk/QmitkIsoDoseLevelSetModel.h @@ -1,91 +1,98 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QmitkIsoDoseLevelSetModel_h #define QmitkIsoDoseLevelSetModel_h #include #include "mitkIsoDoseLevelCollections.h" #include "RTUIExports.h" /*! \class QmitkIsoDoseLevelSetModel Model that handles a iso dose level set and allows viewing and editing of its contents. Please see special delegates (QmitkDoseColorDelegate, QmitkDoseValueDelegate, QmitkDoseVisualStyleDelegate) to handle visualization and editing in views that work on this model. \warning This class is not yet documented. Use "git blame" and ask the author to provide basic documentation. */ class RTUI_EXPORT QmitkIsoDoseLevelSetModel : public QAbstractTableModel { Q_OBJECT public: QmitkIsoDoseLevelSetModel(QObject *parent = NULL); virtual ~QmitkIsoDoseLevelSetModel() {}; + /** Sets the data handled by the model and resets the modified flag*/ void setIsoDoseLevelSet(mitk::IsoDoseLevelSet *pSet); virtual Qt::ItemFlags flags(const QModelIndex &index) const; virtual QVariant data(const QModelIndex &index, int role) const; virtual QVariant headerData(int section, Qt::Orientation orientation, int role) const; virtual int rowCount(const QModelIndex &parent = QModelIndex()) const; virtual int columnCount(const QModelIndex &parent = QModelIndex()) const; virtual bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole); bool getShowAbsoluteDose() const; mitk::DoseValueAbs getReferenceDose() const; bool getVisibilityEditOnly() const; void switchVisibilityIsoLines(bool activate); void switchVisibilityColorWash(bool activate); void invertVisibilityIsoLines(); void invertVisibilityColorWash(); void swapVisibility(); void addLevel(); void deleteLevel(const QModelIndex &index); -public Q_SLOTS: - /** - * \brief Slot that can be used to set the prescribed dose. - */ - void setReferenceDose(double newReferenceDose); - /** - * \brief Slot that can be used to adjust whether the dose should be displayed in absolute or relative units. - */ - void setShowAbsoluteDose(bool showAbsoluteDose); - - /** - * \brief Slat that can be used to adjust wether the model allows to edit only visibilities (no dose value or color) - */ - void setVisibilityEditOnly(bool onlyVisibility); + /**Indicates if the content of the model was modified since the data was set via setIsoDoseLevelSet()*/ + bool isModified(); + + public Q_SLOTS: + /** + * \brief Slot that can be used to set the prescribed dose. + */ + void setReferenceDose(double newReferenceDose); + /** + * \brief Slot that can be used to adjust whether the dose should be displayed in absolute or relative units. + */ + void setShowAbsoluteDose(bool showAbsoluteDose); + + /** + * \brief Slat that can be used to adjust wether the model allows to edit only visibilities (no dose value or color) + */ + void setVisibilityEditOnly(bool onlyVisibility); private: mitk::IsoDoseLevelSet::Pointer m_DoseSet; bool m_showAbsoluteDose; bool m_visibilityEditOnly; mitk::DoseValueAbs m_referenceDose; + /** Indicates if the data of the model was modified, since the model was set. */ + bool m_modified; + }; #endif // QmitkIsoDoseLevelSetModel_h diff --git a/Plugins/org.mitk.gui.qt.rt.dosevisualization/manifest_headers.cmake b/Plugins/org.mitk.gui.qt.rt.dosevisualization/manifest_headers.cmake index 985ab25739..9492c2783b 100644 --- a/Plugins/org.mitk.gui.qt.rt.dosevisualization/manifest_headers.cmake +++ b/Plugins/org.mitk.gui.qt.rt.dosevisualization/manifest_headers.cmake @@ -1,5 +1,5 @@ set(Plugin-Name "RTDoseVisualization") set(Plugin-Version "0.1") set(Plugin-Vendor "DKFZ, Software development for Integrated Diagnostic and Therapy") set(Plugin-ContactAddress "sbr@dkfz-heidelber.de") -set(Require-Plugin org.mitk.gui.qt.common ) +set(Require-Plugin org.mitk.gui.qt.common org.commontk.eventadmin) diff --git a/Plugins/org.mitk.gui.qt.rt.dosevisualization/src/internal/DoseVisualizationPreferencePage.cpp b/Plugins/org.mitk.gui.qt.rt.dosevisualization/src/internal/DoseVisualizationPreferencePage.cpp index f442f66c87..e5e934987f 100644 --- a/Plugins/org.mitk.gui.qt.rt.dosevisualization/src/internal/DoseVisualizationPreferencePage.cpp +++ b/Plugins/org.mitk.gui.qt.rt.dosevisualization/src/internal/DoseVisualizationPreferencePage.cpp @@ -1,327 +1,377 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "DoseVisualizationPreferencePage.h" #include "mitkRTUIConstants.h" #include #include #include #include #include #include #include #include #include #include #include "mitkIsoLevelsGenerator.h" +#include "org_mitk_gui_qt_rt_dosevisualization_Activator.h" + DoseVisualizationPreferencePage::DoseVisualizationPreferencePage() -: m_MainControl(0), m_Controls(0) + : m_MainControl(0), m_Controls(0), m_referenceDoseChanged(false), m_presetMapChanged(false) { } DoseVisualizationPreferencePage::~DoseVisualizationPreferencePage() { delete m_LevelSetModel; delete m_DoseColorDelegate; delete m_DoseValueDelegate; delete m_DoseVisualDelegate; delete m_Controls; } void DoseVisualizationPreferencePage::Init(berry::IWorkbench::Pointer ) { } void DoseVisualizationPreferencePage::CreateQtControl(QWidget* parent) { berry::IPreferencesService::Pointer prefService = berry::Platform::GetServiceRegistry() .GetServiceById(berry::IPreferencesService::ID); m_DoseVisNode = prefService->GetSystemPreferences()->Node(mitk::rt::UIConstants::ROOT_DOSE_VIS_PREFERENCE_NODE_ID); m_MainControl = new QWidget(parent); m_Controls = new Ui::DoseVisualizationPreferencePageControls; m_Controls->setupUi( m_MainControl ); m_LevelSetModel = new QmitkIsoDoseLevelSetModel(this); m_DoseColorDelegate = new QmitkDoseColorDelegate(this); m_DoseValueDelegate = new QmitkDoseValueDelegate(this); m_DoseVisualDelegate = new QmitkDoseVisualStyleDelegate(this); this->m_Controls->isoLevelSetView->setModel(m_LevelSetModel); this->m_Controls->isoLevelSetView->setItemDelegateForColumn(0,m_DoseColorDelegate); this->m_Controls->isoLevelSetView->setItemDelegateForColumn(1,m_DoseValueDelegate); this->m_Controls->isoLevelSetView->setItemDelegateForColumn(2,m_DoseVisualDelegate); this->m_Controls->isoLevelSetView->setItemDelegateForColumn(3,m_DoseVisualDelegate); this->m_Controls->isoLevelSetView->setContextMenuPolicy(Qt::CustomContextMenu); connect(m_Controls->spinReferenceDose, SIGNAL(valueChanged(double)), m_LevelSetModel, SLOT(setReferenceDose(double))); + connect(m_Controls->spinReferenceDose, SIGNAL(valueChanged(double)), this, SLOT(OnReferenceDoseChanged(double))); connect(m_Controls->checkGlobalSync, SIGNAL(toggled(bool)), m_Controls->spinReferenceDose, SLOT(setEnabled(bool))); connect(m_Controls->radioAbsDose, SIGNAL(toggled(bool)), m_LevelSetModel, SLOT(setShowAbsoluteDose(bool))); connect(m_Controls->isoLevelSetView, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(OnShowContextMenuIsoSet(const QPoint&))); connect(m_Controls->listPresets, SIGNAL(currentItemChanged ( QListWidgetItem *, QListWidgetItem *)), this, SLOT(OnCurrentItemChanged ( QListWidgetItem *, QListWidgetItem *))); connect(m_Controls->btnAddPreset, SIGNAL(clicked(bool)), this, SLOT(OnAddPresetClicked(bool))); connect(m_Controls->btnDelPreset, SIGNAL(clicked(bool)), this, SLOT(OnDelPresetClicked(bool))); connect(m_Controls->btnResetPreset, SIGNAL(clicked(bool)), this, SLOT(OnResetPresetClicked(bool))); connect(m_Controls->btnDelLevel, SIGNAL(clicked(bool)), this, SLOT(OnDelLevelClicked(bool))); connect(m_Controls->btnAddLevel, SIGNAL(clicked(bool)), this, SLOT(OnAddLevelClicked(bool))); this->Update(); } QWidget* DoseVisualizationPreferencePage::GetQtControl() const { return m_MainControl; } bool DoseVisualizationPreferencePage::PerformOk() { m_DoseVisNode->PutBool(mitk::rt::UIConstants::DOSE_DISPLAY_ABSOLUTE_ID,m_Controls->radioAbsDose->isChecked()); m_DoseVisNode->PutBool(mitk::rt::UIConstants::GLOBAL_VISIBILITY_COLORWASH_ID,m_Controls->checkGlobalVisColorWash->isChecked()); m_DoseVisNode->PutBool(mitk::rt::UIConstants::GLOBAL_VISIBILITY_ISOLINES_ID,m_Controls->checkGlobalVisIsoLine->isChecked()); m_DoseVisNode->PutDouble(mitk::rt::UIConstants::REFERENCE_DOSE_ID,m_Controls->spinReferenceDose->value()); m_DoseVisNode->PutBool(mitk::rt::UIConstants::GLOBAL_REFERENCE_DOSE_SYNC_ID, m_Controls->checkGlobalSync->isChecked()); mitk::rt::StorePresetsMap(this->m_Presets); + if (this->m_Presets.find(this->m_selectedPresetName)==this->m_Presets.end()) + { //the preset currently selected in the application is not available any more. Change it to a valid one. + mitk::rt::SetSelectedPresetName(this->m_Presets.begin()->first); + } + + if (this->m_LevelSetModel->isModified()) + { + this->m_presetMapChanged = true; + } + + if (m_referenceDoseChanged) + { + mitk::rt::SignalReferenceDoseChange(m_Controls->checkGlobalSync->isChecked(), m_Controls->spinReferenceDose->value(), mitk::org_mitk_gui_qt_rt_dosevisualization_Activator::GetContext()); + } + + if (m_presetMapChanged) + { + mitk::rt::SignalPresetMapChange(mitk::org_mitk_gui_qt_rt_dosevisualization_Activator::GetContext()); + } + return true; } void DoseVisualizationPreferencePage::PerformCancel() { } void DoseVisualizationPreferencePage::Update() { m_Controls->checkGlobalVisColorWash->setChecked(m_DoseVisNode->GetBool(mitk::rt::UIConstants::GLOBAL_VISIBILITY_COLORWASH_ID, true)); m_Controls->checkGlobalVisIsoLine->setChecked(m_DoseVisNode->GetBool(mitk::rt::UIConstants::GLOBAL_VISIBILITY_ISOLINES_ID, true)); m_Controls->radioAbsDose->setChecked(m_DoseVisNode->GetBool(mitk::rt::UIConstants::DOSE_DISPLAY_ABSOLUTE_ID, true)); m_Controls->radioRelDose->setChecked(!(m_DoseVisNode->GetBool(mitk::rt::UIConstants::DOSE_DISPLAY_ABSOLUTE_ID, false))); - m_Controls->spinReferenceDose->setValue(m_DoseVisNode->GetDouble(mitk::rt::UIConstants::REFERENCE_DOSE_ID, 40.0)); + m_Controls->spinReferenceDose->setValue(m_DoseVisNode->GetDouble(mitk::rt::UIConstants::REFERENCE_DOSE_ID, mitk::rt::UIConstants::DEFAULT_REFERENCE_DOSE_VALUE)); m_Controls->checkGlobalSync->setChecked(m_DoseVisNode->GetBool(mitk::rt::UIConstants::GLOBAL_REFERENCE_DOSE_SYNC_ID, true)); + m_referenceDoseChanged = false; + m_presetMapChanged = false; + + berry::IPreferences::Pointer presetsNode = m_DoseVisNode->Node(mitk::rt::UIConstants::ROOT_ISO_PRESETS_PREFERENCE_NODE_ID); this->m_Presets = mitk::rt::LoadPresetsMap(); + this->m_selectedPresetName = mitk::rt::GetSelectedPresetName(); UpdatePresetsWidgets(); } mitk::IsoDoseLevelSet* DoseVisualizationPreferencePage::GetSelectedIsoLevelSet() { QListWidgetItem* selectedItem = m_Controls->listPresets->currentItem(); mitk::IsoDoseLevelSet::Pointer result; if (selectedItem) { result = m_Presets[selectedItem->text().toStdString()]; } return result; } void DoseVisualizationPreferencePage::UpdateLevelSetWidgets() { this->m_Controls->btnAddLevel->setEnabled(this->GetSelectedIsoLevelSet()!=NULL); - QModelIndex selectedIndex = m_Controls->isoLevelSetView->currentIndex(); + QModelIndex selectedIndex = m_Controls->isoLevelSetView->currentIndex(); this->m_Controls->btnDelLevel->setEnabled(this->GetSelectedIsoLevelSet()!=NULL && selectedIndex.isValid()); } void DoseVisualizationPreferencePage::UpdatePresetsWidgets() { m_Controls->listPresets->clear(); QListWidgetItem* selectedItem = NULL; for (PresetMapType::iterator pos = m_Presets.begin(); pos != m_Presets.end(); ++pos) { QListWidgetItem* item = new QListWidgetItem(QString::fromStdString(pos->first)); if (!selectedItem) { selectedItem = item; } m_Controls->listPresets->addItem(item); } if (selectedItem) - { - m_Controls->listPresets->setCurrentItem(selectedItem); + { + m_Controls->listPresets->setCurrentItem(selectedItem); + } + + if (this->m_LevelSetModel->isModified()) + { + this->m_presetMapChanged = true; } this->m_LevelSetModel->setIsoDoseLevelSet(this->GetSelectedIsoLevelSet()); - m_Controls->btnDelPreset->setEnabled((m_Controls->listPresets->currentItem() != NULL) && (m_Controls->listPresets->count()>1)); + m_Controls->btnDelPreset->setEnabled((m_Controls->listPresets->currentItem() != NULL) && (m_Controls->listPresets->count()>1)); } void DoseVisualizationPreferencePage::OnCurrentItemChanged ( QListWidgetItem * currentItem, QListWidgetItem * previousItem) { this->m_LevelSetModel->setIsoDoseLevelSet(this->GetSelectedIsoLevelSet()); } void DoseVisualizationPreferencePage::OnShowContextMenuIsoSet(const QPoint& pos) { QPoint globalPos = m_Controls->isoLevelSetView->viewport()->mapToGlobal(pos); QModelIndex selectedIndex = m_Controls->isoLevelSetView->currentIndex(); QMenu viewMenu; QAction* addLevelAct = viewMenu.addAction("Add new level"); QAction* delLevelAct = viewMenu.addAction("Delete selected level"); delLevelAct->setEnabled(selectedIndex.isValid()); viewMenu.addSeparator(); QAction* invertIsoLineAct = viewMenu.addAction("Invert iso line visibility"); QAction* activateIsoLineAct = viewMenu.addAction("Activate all iso lines"); QAction* deactivateIsoLineAct = viewMenu.addAction("Deactivate all iso lines"); viewMenu.addSeparator(); QAction* invertColorWashAct = viewMenu.addAction("Invert color wash visibility"); QAction* activateColorWashAct = viewMenu.addAction("Activate all color wash levels"); QAction* deactivateColorWashAct = viewMenu.addAction("Deactivate all color wash levels"); viewMenu.addSeparator(); QAction* swapAct = viewMenu.addAction("Swap iso line/color wash visibility"); QAction* selectedItem = viewMenu.exec(globalPos); if (selectedItem == invertIsoLineAct) { this->m_LevelSetModel->invertVisibilityIsoLines(); } else if (selectedItem == activateIsoLineAct) { this->m_LevelSetModel->switchVisibilityIsoLines(true); } else if (selectedItem == deactivateIsoLineAct) { this->m_LevelSetModel->switchVisibilityIsoLines(false); } else if (selectedItem == invertColorWashAct) { this->m_LevelSetModel->invertVisibilityColorWash(); } else if (selectedItem == activateColorWashAct) { this->m_LevelSetModel->switchVisibilityColorWash(true); } else if (selectedItem == deactivateColorWashAct) { this->m_LevelSetModel->switchVisibilityColorWash(false); } else if (selectedItem == swapAct) { this->m_LevelSetModel->swapVisibility(); } else if (selectedItem == addLevelAct) { this->m_LevelSetModel->addLevel(); } else if (selectedItem == delLevelAct) { this->m_LevelSetModel->deleteLevel(selectedIndex); } } void DoseVisualizationPreferencePage::OnAddPresetClicked(bool checked) { bool done = false; QString name = tr("new_preset"); while (!done) { - bool ok; - name = QInputDialog::getText(m_MainControl, tr("Define name of new preset."), tr("Preset name:"), QLineEdit::Normal, name, &ok); - - if (!ok) - { - return; //cancled by user; - } - - bool uniqueName = m_Presets.find(name.toStdString()) == m_Presets.end(); - if (!uniqueName) - { - QMessageBox box; - box.setText(tr("New preset name is not unique. Please, choose another one.")); - box.exec(); - } - - bool validName = name.indexOf(tr("/")) ==-1; - if (!validName) - { - QMessageBox box; - box.setText(tr("New preset name is not valid. Please don't use \"/\".")); - box.exec(); - } - - done = uniqueName && validName; + bool ok; + name = QInputDialog::getText(m_MainControl, tr("Define name of new preset."), tr("Preset name:"), QLineEdit::Normal, name, &ok); + + if (!ok) + { + return; //cancled by user; + } + + bool uniqueName = m_Presets.find(name.toStdString()) == m_Presets.end(); + if (!uniqueName) + { + QMessageBox box; + box.setText(tr("New preset name is not unique. Please, choose another one.")); + box.exec(); + } + + bool validName = name.indexOf(tr("/")) ==-1; + if (!validName) + { + QMessageBox box; + box.setText(tr("New preset name is not valid. Please don't use \"/\".")); + box.exec(); + } + + done = uniqueName && validName; } mitk::IsoDoseLevelSet::Pointer newSet = mitk::rt::GeneratIsoLevels_Virtuos(); m_Presets.insert(std::make_pair(name.toStdString(),newSet)); + m_presetMapChanged = true; + UpdatePresetsWidgets(); } void DoseVisualizationPreferencePage::OnDelPresetClicked(bool checked) { QListWidgetItem* selectedItem = m_Controls->listPresets->currentItem(); if (selectedItem) { if (m_Controls->listPresets->count() > 1) { m_Presets.erase(selectedItem->text().toStdString()); + + m_presetMapChanged = true; this->UpdatePresetsWidgets(); } } } void DoseVisualizationPreferencePage::OnResetPresetClicked(bool checked) { QMessageBox box; box.setText("Do you want to reset the presets?"); box.setInformativeText("If you reset the presets. All user defined presets will be removed and the default presets will be loaded."); box.setStandardButtons(QMessageBox::Yes | QMessageBox::No); box.setDefaultButton(QMessageBox::No); int ret = box.exec(); if (ret == QMessageBox::Yes) { - mitk::IsoDoseLevelSet::Pointer newSet = mitk::rt::GeneratIsoLevels_Virtuos(); - m_Presets.clear(); - m_Presets.insert(std::make_pair("Virtuos",newSet)); + mitk::IsoDoseLevelSet::Pointer newSet = mitk::rt::GeneratIsoLevels_Virtuos(); + m_Presets.clear(); + m_Presets.insert(std::make_pair("Virtuos",newSet)); - UpdatePresetsWidgets(); + m_presetMapChanged = true; + + UpdatePresetsWidgets(); } } void DoseVisualizationPreferencePage::OnAddLevelClicked(bool checked) { this->m_LevelSetModel->addLevel(); } void DoseVisualizationPreferencePage::OnDelLevelClicked(bool checked) { QModelIndex selectedIndex = m_Controls->isoLevelSetView->currentIndex(); + + if (!selectedIndex.isValid()) + { + selectedIndex = m_Controls->isoLevelSetView->indexAt(QPoint(1,1)); + } + this->m_LevelSetModel->deleteLevel(selectedIndex); } + +void DoseVisualizationPreferencePage::OnReferenceDoseChanged(double dose) +{ + this->m_referenceDoseChanged = true; +}; diff --git a/Plugins/org.mitk.gui.qt.rt.dosevisualization/src/internal/DoseVisualizationPreferencePage.h b/Plugins/org.mitk.gui.qt.rt.dosevisualization/src/internal/DoseVisualizationPreferencePage.h index 42c5405376..ed45400c1b 100644 --- a/Plugins/org.mitk.gui.qt.rt.dosevisualization/src/internal/DoseVisualizationPreferencePage.h +++ b/Plugins/org.mitk.gui.qt.rt.dosevisualization/src/internal/DoseVisualizationPreferencePage.h @@ -1,119 +1,123 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef __DOSE_VISUALIZATION_PREFERENCE_PAGE_H #define __DOSE_VISUALIZATION_PREFERENCE_PAGE_H #include "berryIQtPreferencePage.h" #include "berryIPreferences.h" #include "ui_DoseVisualizationPreferencePageControls.h" #include #include "mitkDoseVisPreferenceHelper.h" /*forward declarations*/ class QmitkIsoDoseLevelSetModel; class QmitkDoseColorDelegate; class QmitkDoseValueDelegate; class QmitkDoseVisualStyleDelegate; class QWidget; /** - * \class DoseVisualizationPreferencePage - * \brief Preference page for RT Dose visualization - */ +* \class DoseVisualizationPreferencePage +* \brief Preference page for RT Dose visualization +*/ class DoseVisualizationPreferencePage : public QObject, public berry::IQtPreferencePage { Q_OBJECT - Q_INTERFACES(berry::IPreferencePage) + Q_INTERFACES(berry::IPreferencePage) public: DoseVisualizationPreferencePage(); ~DoseVisualizationPreferencePage(); /** - * \brief Called by framework to initialize this preference page, but currently does nothing. - * \param workbench The workbench. - */ + * \brief Called by framework to initialize this preference page, but currently does nothing. + * \param workbench The workbench. + */ void Init(berry::IWorkbench::Pointer workbench); /** - * \brief Called by framework to create the GUI, and connect signals and slots. - * \param widget The Qt widget that acts as parent to all GUI components, as this class itself is not derived from QWidget. - */ + * \brief Called by framework to create the GUI, and connect signals and slots. + * \param widget The Qt widget that acts as parent to all GUI components, as this class itself is not derived from QWidget. + */ void CreateQtControl(QWidget* widget); /** - * \brief Required by framework to get hold of the GUI. - * \return QWidget* the top most QWidget for the GUI. - */ + * \brief Required by framework to get hold of the GUI. + * \return QWidget* the top most QWidget for the GUI. + */ QWidget* GetQtControl() const; /** - * \see IPreferencePage::PerformOk - */ + * \see IPreferencePage::PerformOk + */ virtual bool PerformOk(); /** - * \see IPreferencePage::PerformCancel - */ + * \see IPreferencePage::PerformCancel + */ virtual void PerformCancel(); /** - * \see IPreferencePage::Update - */ + * \see IPreferencePage::Update + */ virtual void Update(); public slots: void OnCurrentItemChanged ( QListWidgetItem * currentItem, QListWidgetItem * previousItem); void OnShowContextMenuIsoSet(const QPoint& pos); void OnAddPresetClicked(bool checked); void OnDelPresetClicked(bool checked); void OnResetPresetClicked(bool checked); void OnAddLevelClicked(bool checked); void OnDelLevelClicked(bool checked); + void OnReferenceDoseChanged(double dose); protected: /** Method updates the presets widgets according to the internal members*/ void UpdatePresetsWidgets(); /** Method actualizes the level set model and edit buttons according to the currently selected item in the presets list view*/ void UpdateLevelSetWidgets(); /** Method returns the iso dose level set selected in the preset lists. May return NULL if no preset is selected.*/ mitk::IsoDoseLevelSet* GetSelectedIsoLevelSet(); QWidget *m_MainControl; Ui::DoseVisualizationPreferencePageControls* m_Controls; berry::IPreferences::Pointer m_DoseVisNode; typedef mitk::rt::PresetMapType PresetMapType; PresetMapType m_Presets; std::string m_selectedPresetName; + bool m_referenceDoseChanged; + bool m_presetMapChanged; + QmitkIsoDoseLevelSetModel* m_LevelSetModel; QmitkDoseColorDelegate* m_DoseColorDelegate; QmitkDoseValueDelegate* m_DoseValueDelegate; QmitkDoseVisualStyleDelegate* m_DoseVisualDelegate; }; #endif diff --git a/Plugins/org.mitk.gui.qt.rt.dosevisualization/src/internal/DoseVisualizationPreferencePageControls.ui b/Plugins/org.mitk.gui.qt.rt.dosevisualization/src/internal/DoseVisualizationPreferencePageControls.ui index f14b9cc884..ffbdbcad21 100644 --- a/Plugins/org.mitk.gui.qt.rt.dosevisualization/src/internal/DoseVisualizationPreferencePageControls.ui +++ b/Plugins/org.mitk.gui.qt.rt.dosevisualization/src/internal/DoseVisualizationPreferencePageControls.ui @@ -1,304 +1,307 @@ DoseVisualizationPreferencePageControls 0 0 714 651 0 0 QmitkTemplate 5 5 Global viszualization settings: 0 0 105 0 Qt::NoFocus Reference dose [Gy]: 0 0 65 0 Dose display: relative [%] true absolute [Gy] Global visibility: Isolines :/RTUI/eye_open.png 24 16 Colorwash :/RTUI/eye_open.png 24 16 - global sync activated + 1 + + 0.100000000000000 + 9999.000000000000000 global sync Iso dose level presets: 5 5 16777215 100 Qt::Horizontal 40 20 Add Remove Reset Preset editor: true QAbstractItemView::SingleSelection QAbstractItemView::SelectRows 30 20 75 Qt::Horizontal 40 20 Add level Remove level diff --git a/Plugins/org.mitk.gui.qt.rt.dosevisualization/src/internal/RTDoseVisualizer.cpp b/Plugins/org.mitk.gui.qt.rt.dosevisualization/src/internal/RTDoseVisualizer.cpp index 96124d62b6..35b52efc05 100644 --- a/Plugins/org.mitk.gui.qt.rt.dosevisualization/src/internal/RTDoseVisualizer.cpp +++ b/Plugins/org.mitk.gui.qt.rt.dosevisualization/src/internal/RTDoseVisualizer.cpp @@ -1,537 +1,572 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ +// Qt +#include +#include + // Blueberry #include #include + // MITK #include +#include +#include + // Qmitk #include "RTDoseVisualizer.h" #include #include #include #include +#include #include #include #include #include #include -// Qt -#include -#include -#include +#include "org_mitk_gui_qt_rt_dosevisualization_Activator.h" #include #include #include const std::string RTDoseVisualizer::VIEW_ID = "org.mitk.views.rt.dosevisualization"; RTDoseVisualizer::RTDoseVisualizer() { m_freeIsoValues = mitk::IsoDoseLevelVector::New(); m_selectedNodeIsoSet = mitk::IsoDoseLevelSet::New(); m_selectedNode = NULL; m_selectedPresetName = ""; m_internalUpdate = false; m_PrescribedDose_Data = 0.0; // mitk::CoreServicePointer shadoRepo(mitk::CoreServices::GetShaderRepository()); // std::string path = "/home/riecker/mitkShaderLighting.xml"; // std::string isoShaderName = "mitkIsoLineShader"; // MITK_INFO << "shader found under: " << path; // std::ifstream str(path.c_str()); // shadoRepo->LoadShader(str,isoShaderName); } RTDoseVisualizer::~RTDoseVisualizer() { delete m_LevelSetModel; delete m_DoseColorDelegate; delete m_DoseValueDelegate; delete m_DoseVisualDelegate; } void RTDoseVisualizer::SetFocus() { } void RTDoseVisualizer::CreateQtPartControl( QWidget *parent ) { // create GUI widgets from the Qt Designer's .ui file m_Controls.setupUi( parent ); m_LevelSetModel = new QmitkIsoDoseLevelSetModel(this); m_LevelSetModel->setVisibilityEditOnly(true); m_DoseColorDelegate = new QmitkDoseColorDelegate(this); m_DoseValueDelegate = new QmitkDoseValueDelegate(this); m_DoseVisualDelegate = new QmitkDoseVisualStyleDelegate(this); this->UpdateByPreferences(); this->ActualizeIsoLevelsForAllDoseDataNodes(); this->ActualizeReferenceDoseForAllDoseDataNodes(); this->ActualizeDisplayStyleForAllDoseDataNodes(); this->m_Controls.isoLevelSetView->setModel(m_LevelSetModel); this->m_Controls.isoLevelSetView->setItemDelegateForColumn(0,m_DoseColorDelegate); this->m_Controls.isoLevelSetView->setItemDelegateForColumn(1,m_DoseValueDelegate); this->m_Controls.isoLevelSetView->setItemDelegateForColumn(2,m_DoseVisualDelegate); this->m_Controls.isoLevelSetView->setItemDelegateForColumn(3,m_DoseVisualDelegate); this->m_Controls.isoLevelSetView->setContextMenuPolicy(Qt::CustomContextMenu); connect(m_Controls.btnConvert, SIGNAL(clicked()), this, SLOT(OnConvertButtonClicked())); connect(m_Controls.spinReferenceDose, SIGNAL(valueChanged(double)), this, SLOT(OnReferenceDoseChanged(double))); connect(m_Controls.spinReferenceDose, SIGNAL(valueChanged(double)), m_LevelSetModel, SLOT(setReferenceDose(double))); connect(m_Controls.radioAbsDose, SIGNAL(toggled(bool)), m_LevelSetModel, SLOT(setShowAbsoluteDose(bool))); connect(m_Controls.radioAbsDose, SIGNAL(toggled(bool)), this, SLOT(OnAbsDoseToggled(bool))); connect(m_Controls.btnAddFreeValue, SIGNAL(clicked()), this, SLOT(OnAddFreeValueClicked())); connect(m_Controls.btnRemoveFreeValue, SIGNAL(clicked()), this, SLOT(OnRemoveFreeValueClicked())); connect(m_Controls.checkGlobalVisColorWash, SIGNAL(toggled(bool)), this, SLOT(OnGlobalVisColorWashToggled(bool))); connect(m_Controls.checkGlobalVisIsoLine, SIGNAL(toggled(bool)), this, SLOT(OnGlobalVisIsoLineToggled(bool))); connect(m_Controls.isoLevelSetView, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(OnShowContextMenuIsoSet(const QPoint&))); connect(m_Controls.comboPresets, SIGNAL(currentIndexChanged ( const QString&)), this, SLOT(OnCurrentPresetChanged(const QString&))); connect(m_Controls.btnUsePrescribedDose, SIGNAL(clicked()), this, SLOT(OnUsePrescribedDoseClicked())); + ctkServiceReference ref = mitk::org_mitk_gui_qt_rt_dosevisualization_Activator::GetContext()->getServiceReference(); + + ctkDictionary propsForSlot; + if (ref) + { + ctkEventAdmin* eventAdmin = mitk::org_mitk_gui_qt_rt_dosevisualization_Activator::GetContext()->getService(ref); + + propsForSlot[ctkEventConstants::EVENT_TOPIC] = mitk::rt::CTKEventConstants::TOPIC_ISO_DOSE_LEVEL_PRESETS_CHANGED.c_str(); + eventAdmin->subscribeSlot(this, SLOT(OnHandleCTKEventPresetsChanged(ctkEvent)), propsForSlot); + + propsForSlot[ctkEventConstants::EVENT_TOPIC] = mitk::rt::CTKEventConstants::TOPIC_REFERENCE_DOSE_CHANGED.c_str(); + eventAdmin->subscribeSlot(this, SLOT(OnHandleCTKEventReferenceDoseChanged(ctkEvent)), propsForSlot); + } + this->UpdateBySelectedNode(); } void RTDoseVisualizer::OnReferenceDoseChanged(double value) { if (! m_internalUpdate) { mitk::DoseValueAbs referenceDose = 0.0; bool globalSync = mitk::rt::GetReferenceDoseValue(referenceDose); if (globalSync) { mitk::rt::SetReferenceDoseValue(globalSync, value); this->ActualizeReferenceDoseForAllDoseDataNodes(); } else { if (this->m_selectedNode.IsNotNull()) { this->m_selectedNode->SetFloatProperty(mitk::rt::Constants::REFERENCE_DOSE_PROPERTY_NAME.c_str(), value); } } } } void RTDoseVisualizer::OnAddFreeValueClicked() { QColor newColor; //Use HSV schema of QColor to calculate a different color depending on the //number of already existing free iso lines. newColor.setHsv((m_freeIsoValues->Size()*85)%360,255,255); mitk::IsoDoseLevel::ColorType color; color[0] = newColor.redF(); color[1] = newColor.greenF(); color[2] = newColor.blueF(); m_freeIsoValues->push_back(mitk::IsoDoseLevel::New(0.5,color,true,false)); UpdateFreeIsoValues(); } void RTDoseVisualizer::OnRemoveFreeValueClicked() { m_freeIsoValues->pop_back(); UpdateFreeIsoValues(); } void RTDoseVisualizer::OnUsePrescribedDoseClicked() { m_Controls.spinReferenceDose->setValue(this->m_PrescribedDose_Data); }; void RTDoseVisualizer::OnShowContextMenuIsoSet(const QPoint& pos) { QPoint globalPos = m_Controls.isoLevelSetView->viewport()->mapToGlobal(pos); QMenu viewMenu; QAction* invertIsoLineAct = viewMenu.addAction("Invert iso line visibility"); QAction* activateIsoLineAct = viewMenu.addAction("Activate all iso lines"); QAction* deactivateIsoLineAct = viewMenu.addAction("Deactivate all iso lines"); viewMenu.addSeparator(); QAction* invertColorWashAct = viewMenu.addAction("Invert color wash visibility"); QAction* activateColorWashAct = viewMenu.addAction("Activate all color wash levels"); QAction* deactivateColorWashAct = viewMenu.addAction("Deactivate all color wash levels"); viewMenu.addSeparator(); QAction* swapAct = viewMenu.addAction("Swap iso line/color wash visibility"); // ... QAction* selectedItem = viewMenu.exec(globalPos); if (selectedItem == invertIsoLineAct) { this->m_LevelSetModel->invertVisibilityIsoLines(); } else if (selectedItem == activateIsoLineAct) { this->m_LevelSetModel->switchVisibilityIsoLines(true); } else if (selectedItem == deactivateIsoLineAct) { this->m_LevelSetModel->switchVisibilityIsoLines(false); } else if (selectedItem == invertColorWashAct) { this->m_LevelSetModel->invertVisibilityColorWash(); } else if (selectedItem == activateColorWashAct) { this->m_LevelSetModel->switchVisibilityColorWash(true); } else if (selectedItem == deactivateColorWashAct) { this->m_LevelSetModel->switchVisibilityColorWash(false); } else if (selectedItem == swapAct) { this->m_LevelSetModel->swapVisibility(); } } void RTDoseVisualizer::UpdateFreeIsoValues() { this->m_Controls.listFreeValues->clear(); for (mitk::IsoDoseLevelVector::Iterator pos = this->m_freeIsoValues->Begin(); pos != this->m_freeIsoValues->End(); ++pos) { QListWidgetItem* item = new QListWidgetItem; item->setSizeHint(QSize(0,25)); QmitkFreeIsoDoseLevelWidget* widget = new QmitkFreeIsoDoseLevelWidget; widget->setIsoDoseLevel(pos->Value().GetPointer()); connect(m_Controls.spinReferenceDose, SIGNAL(valueChanged(double)), widget, SLOT(setReferenceDose(double))); this->m_Controls.listFreeValues->addItem(item); this->m_Controls.listFreeValues->setItemWidget(item,widget); } } void RTDoseVisualizer::OnAbsDoseToggled(bool showAbs) { if (! m_internalUpdate) { mitk::rt::SetDoseDisplayAbsolute(showAbs); this->ActualizeDisplayStyleForAllDoseDataNodes(); } } void RTDoseVisualizer::OnGlobalVisColorWashToggled(bool showColorWash) { if (m_selectedNode.IsNotNull()) { m_selectedNode->SetBoolProperty(mitk::rt::Constants::DOSE_SHOW_COLORWASH_PROPERTY_NAME.c_str(), showColorWash); } } void RTDoseVisualizer::OnGlobalVisIsoLineToggled(bool showIsoLines) { if (m_selectedNode.IsNotNull()) { m_selectedNode->SetBoolProperty(mitk::rt::Constants::DOSE_SHOW_ISOLINES_PROPERTY_NAME.c_str(), showIsoLines); } } void RTDoseVisualizer::OnConvertButtonClicked() { QList dataNodes = this->GetDataManagerSelection(); mitk::DataNode* selectedNode = NULL; if (!dataNodes.empty()) { selectedNode = dataNodes[0]; } if(selectedNode) { selectedNode->SetBoolProperty(mitk::rt::Constants::DOSE_PROPERTY_NAME.c_str(), true); selectedNode->SetBoolProperty(mitk::rt::Constants::DOSE_SHOW_COLORWASH_PROPERTY_NAME.c_str(), true); selectedNode->SetBoolProperty(mitk::rt::Constants::DOSE_SHOW_ISOLINES_PROPERTY_NAME.c_str(), true); selectedNode->SetFloatProperty(mitk::rt::Constants::REFERENCE_DOSE_PROPERTY_NAME.c_str(), m_Controls.spinReferenceDose->value()); //selectedNode->GetData()->SetProperty(mitk::rt::Constants::PRESCRIBED_DOSE_PROPERTY_NAME.c_str(), mitk::DoubleProperty::New(1.0)); mitk::IsoDoseLevelSet::Pointer clonedPreset = this->m_Presets[this->m_selectedPresetName]->Clone(); mitk::IsoDoseLevelSetProperty::Pointer levelSetProp = mitk::IsoDoseLevelSetProperty::New(clonedPreset); selectedNode->SetProperty(mitk::rt::Constants::DOSE_ISO_LEVELS_PROPERTY_NAME.c_str(),levelSetProp); double hsvValue = 0.002778; float prescribed; m_selectedNode->GetFloatProperty(mitk::rt::Constants::PRESCRIBED_DOSE_PROPERTY_NAME.c_str(),prescribed); vtkSmartPointer transferFunction = vtkSmartPointer::New(); transferFunction->SetColorSpaceToRGB(); mitk::IsoDoseLevelSet::Pointer isoDoseLevelSet = this->m_Presets[this->m_selectedPresetName]; MITK_INFO << "FUNCTION PRESCRIBE " << prescribed << endl; for(mitk::IsoDoseLevelSet::ConstIterator setIT = isoDoseLevelSet->Begin(); setIT != isoDoseLevelSet->End(); ++setIT) { float pref; selectedNode->GetFloatProperty(mitk::rt::Constants::REFERENCE_DOSE_PROPERTY_NAME.c_str(),pref); float *hsv = new float[3]; vtkSmartPointer cCalc = vtkSmartPointer::New(); cCalc->RGBToHSV(setIT->GetColor()[0],setIT->GetColor()[1],setIT->GetColor()[2],&hsv[0],&hsv[1],&hsv[2]); transferFunction->AddHSVPoint(setIT->GetDoseValue()*pref,hsv[0],hsv[1],hsv[2],1.0,1.0); MITK_INFO << "FUNCTION " << setIT->GetDoseValue()*pref << endl; } mitk::TransferFunction::Pointer mitkTransFunc = mitk::TransferFunction::New(); mitk::TransferFunctionProperty::Pointer mitkTransFuncProp = mitk::TransferFunctionProperty::New(); mitkTransFunc->SetColorTransferFunction(transferFunction); mitkTransFuncProp->SetValue(mitkTransFunc); mitk::RenderingModeProperty::Pointer renderingMode = mitk::RenderingModeProperty::New(); renderingMode->SetValue(mitk::RenderingModeProperty::COLORTRANSFERFUNCTION_COLOR); selectedNode->SetProperty("Image Rendering.Transfer Function", mitkTransFuncProp); selectedNode->SetProperty("Image Rendering.Mode", renderingMode); mitk::IsoDoseLevelVector::Pointer levelVector = mitk::IsoDoseLevelVector::New(); mitk::IsoDoseLevelVectorProperty::Pointer levelVecProp = mitk::IsoDoseLevelVectorProperty::New(levelVector); selectedNode->SetProperty(mitk::rt::Constants::DOSE_FREE_ISO_VALUES_PROPERTY_NAME.c_str(),levelVecProp); UpdateBySelectedNode(); // mitk::RenderingModeProperty::Pointer renderingMode = mitk::RenderingModeProperty::New(); // renderingMode->SetValue(mitk::RenderingModeProperty::ISODOSESHADER_COLOR); // selectedNode->SetProperty("shader.mitkIsoLineShader.Gridscale", mitk::FloatProperty::New(10.0)); // selectedNode->SetProperty("Image Rendering.Mode", renderingMode); mitk::RenderingManager::GetInstance()->ForceImmediateUpdateAll(); } } void RTDoseVisualizer::OnSelectionChanged( berry::IWorkbenchPart::Pointer /*source*/, const QList& nodes ) { QList dataNodes = this->GetDataManagerSelection(); mitk::DataNode* selectedNode = NULL; if (!dataNodes.empty()) { bool isDoseNode = false; dataNodes[0]->GetBoolProperty(mitk::rt::Constants::DOSE_PROPERTY_NAME.c_str(),isDoseNode); if (isDoseNode) { selectedNode = dataNodes[0]; } } if (selectedNode != m_selectedNode.GetPointer()) { m_selectedNode = selectedNode; } UpdateBySelectedNode(); } void RTDoseVisualizer::UpdateBySelectedNode() { m_Controls.groupNodeSpecific->setEnabled(m_selectedNode.IsNotNull()); m_Controls.groupFreeValues->setEnabled(m_selectedNode.IsNotNull()); if(m_selectedNode.IsNull()) { m_Controls.NrOfFractions->setText(QString("N/A. No dose selected")); m_Controls.prescribedDoseSpecific->setText(QString("N/A. No dose selected")); m_freeIsoValues = mitk::IsoDoseLevelVector::New(); UpdateFreeIsoValues(); } else { /////////////////////////////////////////// //dose specific information int fracCount = 1; m_selectedNode->GetIntProperty(mitk::rt::Constants::DOSE_FRACTION_COUNT_PROPERTY_NAME.c_str(),fracCount); m_Controls.NrOfFractions->setText(QString::number(fracCount)); m_PrescribedDose_Data = 0.0; float tmp; m_selectedNode->GetFloatProperty(mitk::rt::Constants::PRESCRIBED_DOSE_PROPERTY_NAME.c_str(),tmp); m_PrescribedDose_Data = (double)tmp; // dynamic cast von float zu doubleproperty funktioniert nicht & getProperty von node->getData() funktioniert das ? // mitk::DoubleProperty* propDouble = dynamic_cast(m_selectedNode->GetData()->GetProperty(mitk::rt::Constants::PRESCRIBED_DOSE_PROPERTY_NAME.c_str()).GetPointer()); // if (propDouble) // { // m_PrescribedDose_Data = propDouble->GetValue(); // } m_Controls.prescribedDoseSpecific->setText(QString::number(m_PrescribedDose_Data)); /////////////////////////////////////////// //free iso lines mitk::IsoDoseLevelVectorProperty::Pointer propIsoVector; m_selectedNode->GetProperty(propIsoVector, mitk::rt::Constants::DOSE_FREE_ISO_VALUES_PROPERTY_NAME.c_str()); if (propIsoVector.IsNull()) { m_freeIsoValues = mitk::IsoDoseLevelVector::New(); propIsoVector = mitk::IsoDoseLevelVectorProperty::New(m_freeIsoValues); m_selectedNode->SetProperty(mitk::rt::Constants::DOSE_FREE_ISO_VALUES_PROPERTY_NAME.c_str(),propIsoVector); } else { m_freeIsoValues = propIsoVector->GetValue(); } UpdateFreeIsoValues(); /////////////////////////////////////////// //global dose issues bool showIsoLine = false; m_selectedNode->GetBoolProperty(mitk::rt::Constants::DOSE_SHOW_COLORWASH_PROPERTY_NAME.c_str(),showIsoLine); m_Controls.checkGlobalVisIsoLine->setChecked(showIsoLine); bool showColorWash = false; m_selectedNode->GetBoolProperty(mitk::rt::Constants::DOSE_SHOW_COLORWASH_PROPERTY_NAME.c_str(),showColorWash); m_Controls.checkGlobalVisColorWash->setChecked(showColorWash); float referenceDose = 0.0; m_selectedNode->GetFloatProperty(mitk::rt::Constants::REFERENCE_DOSE_PROPERTY_NAME.c_str(),referenceDose); m_Controls.spinReferenceDose->setValue(referenceDose); mitk::IsoDoseLevelSetProperty::Pointer propIsoSet = - dynamic_cast(m_selectedNode->GetProperty(mitk::rt::Constants::DOSE_ISO_LEVELS_PROPERTY_NAME.c_str())); + dynamic_cast(m_selectedNode->GetProperty(mitk::rt::Constants::DOSE_ISO_LEVELS_PROPERTY_NAME.c_str())); if (propIsoSet) { this->m_selectedNodeIsoSet = propIsoSet->GetValue(); this->m_LevelSetModel->setIsoDoseLevelSet(m_selectedNodeIsoSet); } } } void RTDoseVisualizer::UpdateByPreferences() { m_Presets = mitk::rt::LoadPresetsMap(); m_internalUpdate = true; m_Controls.comboPresets->clear(); this->m_selectedPresetName = mitk::rt::GetSelectedPresetName(); int index = 0; int selectedIndex = -1; for (mitk::rt::PresetMapType::const_iterator pos = m_Presets.begin(); pos != m_Presets.end(); ++pos, ++index) { m_Controls.comboPresets->addItem(QString(pos->first.c_str())); if (this->m_selectedPresetName == pos->first) { selectedIndex = index; } } if (selectedIndex == -1) { selectedIndex = 0; MITK_WARN << "Error. Cannot iso dose level preset specified in preferences does not exist. Preset name: "<m_selectedPresetName; this->m_selectedPresetName = m_Presets.begin()->first; mitk::rt::SetSelectedPresetName(this->m_selectedPresetName); MITK_INFO << "Changed selected iso dose level preset to first existing preset. New preset name: "<m_selectedPresetName; } m_Controls.comboPresets->setCurrentIndex(selectedIndex); this->m_selectedNodeIsoSet = this->m_Presets[this->m_selectedPresetName]; this->m_LevelSetModel->setIsoDoseLevelSet(m_selectedNodeIsoSet); mitk::DoseValueAbs referenceDose = 0.0; bool globalSync = mitk::rt::GetReferenceDoseValue(referenceDose); if (globalSync || this->m_selectedNode.IsNull()) { m_Controls.spinReferenceDose->setValue(referenceDose); } bool displayAbsoluteDose = mitk::rt::GetDoseDisplayAbsolute(); m_Controls.radioAbsDose->setChecked(displayAbsoluteDose); m_Controls.radioRelDose->setChecked(!displayAbsoluteDose); this->m_LevelSetModel->setShowAbsoluteDose(displayAbsoluteDose); m_internalUpdate = false; } void RTDoseVisualizer::OnCurrentPresetChanged(const QString& presetName) { if (! m_internalUpdate) { mitk::rt::SetSelectedPresetName(presetName.toStdString()); this->UpdateByPreferences(); this->ActualizeIsoLevelsForAllDoseDataNodes(); this->UpdateBySelectedNode(); } } void RTDoseVisualizer::ActualizeIsoLevelsForAllDoseDataNodes() { std::string presetName = mitk::rt::GetSelectedPresetName(); mitk::rt::PresetMapType presetMap = mitk::rt::LoadPresetsMap(); mitk::NodePredicateProperty::Pointer isDoseNode = mitk::NodePredicateProperty::New(mitk::rt::Constants::DOSE_PROPERTY_NAME.c_str(), mitk::BoolProperty::New(true)); mitk::DataStorage::SetOfObjects::ConstPointer nodes = this->GetDataStorage()->GetSubset(isDoseNode); mitk::IsoDoseLevelSet* selectedPreset = presetMap[presetName]; if (!selectedPreset) { mitkThrow() << "Error. Cannot actualize iso dose level preset. Selected preset idoes not exist. Preset name: "<begin(); pos != nodes->end(); ++pos) { mitk::IsoDoseLevelSet::Pointer clonedPreset = selectedPreset->Clone(); mitk::IsoDoseLevelSetProperty::Pointer propIsoSet = mitk::IsoDoseLevelSetProperty::New(clonedPreset); (*pos)->SetProperty(mitk::rt::Constants::DOSE_ISO_LEVELS_PROPERTY_NAME.c_str(),propIsoSet); } } void RTDoseVisualizer::ActualizeReferenceDoseForAllDoseDataNodes() { /** @TODO Klären ob diese präsentations info genauso wie*/ mitk::DoseValueAbs value = 0; bool sync = mitk::rt::GetReferenceDoseValue(value); if (sync) { mitk::NodePredicateProperty::Pointer isDoseNode = mitk::NodePredicateProperty::New(mitk::rt::Constants::DOSE_PROPERTY_NAME.c_str(), mitk::BoolProperty::New(true)); mitk::DataStorage::SetOfObjects::ConstPointer nodes = this->GetDataStorage()->GetSubset(isDoseNode); for(mitk::DataStorage::SetOfObjects::const_iterator pos = nodes->begin(); pos != nodes->end(); ++pos) { (*pos)->SetFloatProperty(mitk::rt::Constants::REFERENCE_DOSE_PROPERTY_NAME.c_str(), value); } } } void RTDoseVisualizer::ActualizeDisplayStyleForAllDoseDataNodes() { /** @TODO Klären ob diese präsentations info global oder auch per node gespeichert wird*/ } + +void RTDoseVisualizer::OnHandleCTKEventReferenceDoseChanged(const ctkEvent& event) +{ + mitk::DoseValueAbs referenceDose = 0.0; + bool globalSync = mitk::rt::GetReferenceDoseValue(referenceDose); + + this->m_Controls.spinReferenceDose->setValue(referenceDose); +} + +void RTDoseVisualizer::OnHandleCTKEventPresetsChanged(const ctkEvent& event) +{ + std::string currentPresetName = mitk::rt::GetSelectedPresetName(); + + this->OnCurrentPresetChanged(QString::fromStdString(currentPresetName)); +} diff --git a/Plugins/org.mitk.gui.qt.rt.dosevisualization/src/internal/RTDoseVisualizer.h b/Plugins/org.mitk.gui.qt.rt.dosevisualization/src/internal/RTDoseVisualizer.h index 17c25e8474..e52dc5e537 100644 --- a/Plugins/org.mitk.gui.qt.rt.dosevisualization/src/internal/RTDoseVisualizer.h +++ b/Plugins/org.mitk.gui.qt.rt.dosevisualization/src/internal/RTDoseVisualizer.h @@ -1,145 +1,150 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef RTDoseVisualizer_h #define RTDoseVisualizer_h #include #include #include #include #include "ui_RTDoseVisualizerControls.h" #include #include #include "mitkDoseVisPreferenceHelper.h" // Shader #include #include #include /*forward declarations*/ class QmitkIsoDoseLevelSetModel; class QmitkDoseColorDelegate; class QmitkDoseValueDelegate; class QmitkDoseVisualStyleDelegate; +class ctkEvent; /** - \brief RTDoseVisualizer +\brief RTDoseVisualizer - \warning This class is not yet documented. Use "git blame" and ask the author to provide basic documentation. +\warning This class is not yet documented. Use "git blame" and ask the author to provide basic documentation. - \sa QmitkAbstractView - \ingroup ${plugin_target}_internal +\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: +public: - RTDoseVisualizer(); - virtual ~RTDoseVisualizer(); - static const std::string VIEW_ID; + RTDoseVisualizer(); + virtual ~RTDoseVisualizer(); + static const std::string VIEW_ID; protected slots: void OnConvertButtonClicked(); void OnAddFreeValueClicked(); void OnRemoveFreeValueClicked(); void OnUsePrescribedDoseClicked(); void OnAbsDoseToggled(bool); void OnGlobalVisColorWashToggled(bool); void OnGlobalVisIsoLineToggled(bool); void OnShowContextMenuIsoSet(const QPoint&); void OnCurrentPresetChanged(const QString&); void OnReferenceDoseChanged(double); - protected: + void OnHandleCTKEventReferenceDoseChanged(const ctkEvent& event); - virtual void CreateQtPartControl(QWidget *parent); + void OnHandleCTKEventPresetsChanged(const ctkEvent& event); - virtual void SetFocus(); +protected: - /// \brief called by QmitkFunctionality when DataManager's selection has changed - virtual void OnSelectionChanged( berry::IWorkbenchPart::Pointer source, - const QList& nodes ); + virtual void CreateQtPartControl(QWidget *parent); - /** Method updates the list widget according to the current m_freeIsoValues.*/ - void UpdateFreeIsoValues(); + virtual void SetFocus(); - /** Update the members according to the currently selected node */ - void UpdateBySelectedNode(); + /// \brief called by QmitkFunctionality when DataManager's selection has changed + virtual void OnSelectionChanged( berry::IWorkbenchPart::Pointer source, + const QList& nodes ); - /** Update the member widgets according to the information stored in the application preferences*/ - void UpdateByPreferences(); + /** Method updates the list widget according to the current m_freeIsoValues.*/ + void UpdateFreeIsoValues(); - /**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(); + /** Update the members according to the currently selected node */ + void UpdateBySelectedNode(); - /**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(); + /** Update the member widgets according to the information stored in the application preferences*/ + void UpdateByPreferences(); - /**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(); + /**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(); - Ui::RTDoseVisualizerControls m_Controls; - mitk::DataNode::Pointer m_selectedNode; - mitk::IsoDoseLevelVector::Pointer m_freeIsoValues; - /** Iso level set of the current node. Should normaly be a clone of the - * current iso preset. It held as own member because visibility - * settings may differ.*/ - mitk::IsoDoseLevelSet::Pointer m_selectedNodeIsoSet; - mitk::rt::PresetMapType m_Presets; - std::string m_selectedPresetName; + /**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(); - /** Prescribed Dose of the selected data.*/ - mitk::DoseValueAbs m_PrescribedDose_Data; + /**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(); - QmitkIsoDoseLevelSetModel* m_LevelSetModel; - QmitkDoseColorDelegate* m_DoseColorDelegate; - QmitkDoseValueDelegate* m_DoseValueDelegate; - QmitkDoseVisualStyleDelegate* m_DoseVisualDelegate; + Ui::RTDoseVisualizerControls m_Controls; + mitk::DataNode::Pointer m_selectedNode; + mitk::IsoDoseLevelVector::Pointer m_freeIsoValues; + /** Iso level set of the current node. Should normaly be a clone of the + * current iso preset. It held as own member because visibility + * settings may differ.*/ + mitk::IsoDoseLevelSet::Pointer m_selectedNodeIsoSet; + mitk::rt::PresetMapType m_Presets; + std::string m_selectedPresetName; + /** Prescribed Dose of the selected data.*/ + mitk::DoseValueAbs m_PrescribedDose_Data; - bool m_internalUpdate; + QmitkIsoDoseLevelSetModel* m_LevelSetModel; + QmitkDoseColorDelegate* m_DoseColorDelegate; + QmitkDoseValueDelegate* m_DoseValueDelegate; + QmitkDoseVisualStyleDelegate* m_DoseVisualDelegate; + + + bool m_internalUpdate; }; #endif // RTDoseVisualizer_h diff --git a/Plugins/org.mitk.gui.qt.rt.dosevisualization/src/internal/RTDoseVisualizerControls.ui b/Plugins/org.mitk.gui.qt.rt.dosevisualization/src/internal/RTDoseVisualizerControls.ui index 5cfd2a84e2..7503602792 100644 --- a/Plugins/org.mitk.gui.qt.rt.dosevisualization/src/internal/RTDoseVisualizerControls.ui +++ b/Plugins/org.mitk.gui.qt.rt.dosevisualization/src/internal/RTDoseVisualizerControls.ui @@ -1,502 +1,505 @@ RTDoseVisualizerControls 0 0 421 651 0 0 QmitkTemplate 5 5 5 5 5 Dose specific information: 5 5 5 5 5 Qt::Horizontal 40 20 true 30 Gy Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter true Number of fractions: Prescribed dose [Gy]: Use as reference dose true 0 0 Free iso lines: 5 5 5 5 5 0 0 0 40 16777215 110 0 25 Qt::Horizontal 40 20 Add Remove Global iso dose visualization: 5 5 5 5 5 0 0 65 0 Dose display: 0 0 65 0 Preset style: 0 0 105 0 Qt::NoFocus Reference dose [Gy]: 1 + + 0.100000000000000 + 9999.000000000000000 0.000000000000000 relative [%] true absolute [Gy] true QAbstractItemView::SingleSelection QAbstractItemView::SelectRows 30 20 80 Global visibility: Qt::Horizontal 40 20 Isolines :/RTUI/eye_open.png 24 16 Colorwash :/RTUI/eye_open.png 24 16 255 0 0 255 0 0 255 0 0 255 0 0 120 120 120 120 120 120 Convert nod to dose node (for testing only!) diff --git a/Plugins/org.mitk.gui.qt.rt.dosevisualization/src/internal/RTUIPreferencePage.cpp b/Plugins/org.mitk.gui.qt.rt.dosevisualization/src/internal/RTUIPreferencePage.cpp index 1bfe39131a..445efc1532 100644 --- a/Plugins/org.mitk.gui.qt.rt.dosevisualization/src/internal/RTUIPreferencePage.cpp +++ b/Plugins/org.mitk.gui.qt.rt.dosevisualization/src/internal/RTUIPreferencePage.cpp @@ -1,117 +1,117 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "RTUIPreferencePage.h" #include "mitkRTUIConstants.h" #include #include //----------------------------------------------------------------------------- RTUIPreferencePage::RTUIPreferencePage() -: m_MainControl(0), m_Controls(0) + : m_MainControl(0), m_Controls(0) { } //----------------------------------------------------------------------------- RTUIPreferencePage::~RTUIPreferencePage() { delete m_Controls; } //----------------------------------------------------------------------------- void RTUIPreferencePage::Init(berry::IWorkbench::Pointer ) { } //----------------------------------------------------------------------------- void RTUIPreferencePage::CreateQtControl(QWidget* parent) { berry::IPreferencesService::Pointer prefService = berry::Platform::GetServiceRegistry() .GetServiceById(berry::IPreferencesService::ID); m_PreferencesNode = prefService->GetSystemPreferences()->Node(mitk::rt::UIConstants::ROOT_PREFERENCE_NODE_ID); m_MainControl = new QWidget(parent); m_Controls = new Ui::RTUIPreferencePageControls; m_Controls->setupUi( m_MainControl ); connect(m_Controls->radioDefault, SIGNAL(toggled(bool)), m_Controls->spinDefault, SLOT(setEnabled(bool))); connect(m_Controls->radioRelativeToMax, SIGNAL(toggled(bool)), m_Controls->spinRelativeToMax, SLOT(setEnabled(bool))); this->Update(); } //----------------------------------------------------------------------------- QWidget* RTUIPreferencePage::GetQtControl() const { return m_MainControl; } //----------------------------------------------------------------------------- bool RTUIPreferencePage::PerformOk() { bool useAsDefaultValue = m_Controls->radioDefault->isChecked(); m_PreferencesNode->PutBool(mitk::rt::UIConstants::UNKNOWN_PRESCRIBED_DOSE_HANDLING_AS_DEFAULT_ID,useAsDefaultValue); if (useAsDefaultValue) { - m_PreferencesNode->PutDouble(mitk::rt::UIConstants::UNKNOWN_PRESCRIBED_DOSE_HANDLING_VALUE_ID, m_Controls->spinDefault->value()); + m_PreferencesNode->PutDouble(mitk::rt::UIConstants::UNKNOWN_PRESCRIBED_DOSE_HANDLING_VALUE_ID, m_Controls->spinDefault->value()); } else { m_PreferencesNode->PutDouble(mitk::rt::UIConstants::UNKNOWN_PRESCRIBED_DOSE_HANDLING_VALUE_ID, m_Controls->spinRelativeToMax->value()/100.0); } return true; } //----------------------------------------------------------------------------- void RTUIPreferencePage::PerformCancel() { } //----------------------------------------------------------------------------- void RTUIPreferencePage::Update() { bool useAsDefaultValue = m_PreferencesNode->GetBool(mitk::rt::UIConstants::UNKNOWN_PRESCRIBED_DOSE_HANDLING_AS_DEFAULT_ID, true); double doseValue = m_PreferencesNode->GetDouble(mitk::rt::UIConstants::UNKNOWN_PRESCRIBED_DOSE_HANDLING_VALUE_ID, 50.0); m_Controls->radioDefault->setChecked(useAsDefaultValue); m_Controls->radioRelativeToMax->setChecked(!useAsDefaultValue); m_Controls->spinDefault->setEnabled(useAsDefaultValue); m_Controls->spinRelativeToMax->setEnabled(!useAsDefaultValue); if (useAsDefaultValue) { m_Controls->spinDefault->setValue(doseValue); } else { m_Controls->spinRelativeToMax->setValue(doseValue*100.0); } } diff --git a/Plugins/org.mitk.gui.qt.rt.dosevisualization/src/internal/RTUIPreferencePage.h b/Plugins/org.mitk.gui.qt.rt.dosevisualization/src/internal/RTUIPreferencePage.h index b757709312..208a41773f 100644 --- a/Plugins/org.mitk.gui.qt.rt.dosevisualization/src/internal/RTUIPreferencePage.h +++ b/Plugins/org.mitk.gui.qt.rt.dosevisualization/src/internal/RTUIPreferencePage.h @@ -1,85 +1,85 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef __RT_UI_PREFERENCE_PAGE_H #define __RT_UI_PREFERENCE_PAGE_H #include "berryIQtPreferencePage.h" #include "berryIPreferences.h" #include "ui_RTUIPreferencePageControls.h" class QWidget; /** - * \class RTUIPreferencePage - * \brief Preference page for general RT visualization settings. - */ +* \class RTUIPreferencePage +* \brief Preference page for general RT visualization settings. +*/ class RTUIPreferencePage : public QObject, public berry::IQtPreferencePage { Q_OBJECT - Q_INTERFACES(berry::IPreferencePage) + Q_INTERFACES(berry::IPreferencePage) public: RTUIPreferencePage(); ~RTUIPreferencePage(); /** - * \brief Called by framework to initialize this preference page, but currently does nothing. - * \param workbench The workbench. - */ + * \brief Called by framework to initialize this preference page, but currently does nothing. + * \param workbench The workbench. + */ void Init(berry::IWorkbench::Pointer workbench); /** - * \brief Called by framework to create the GUI, and connect signals and slots. - * \param widget The Qt widget that acts as parent to all GUI components, as this class itself is not derived from QWidget. - */ + * \brief Called by framework to create the GUI, and connect signals and slots. + * \param widget The Qt widget that acts as parent to all GUI components, as this class itself is not derived from QWidget. + */ void CreateQtControl(QWidget* widget); /** - * \brief Required by framework to get hold of the GUI. - * \return QWidget* the top most QWidget for the GUI. - */ + * \brief Required by framework to get hold of the GUI. + * \return QWidget* the top most QWidget for the GUI. + */ QWidget* GetQtControl() const; /** - * \see IPreferencePage::PerformOk - */ + * \see IPreferencePage::PerformOk + */ virtual bool PerformOk(); /** - * \see IPreferencePage::PerformCancel - */ + * \see IPreferencePage::PerformCancel + */ virtual void PerformCancel(); /** - * \see IPreferencePage::Update - */ + * \see IPreferencePage::Update + */ virtual void Update(); -public slots: + public slots: protected: QWidget *m_MainControl; Ui::RTUIPreferencePageControls* m_Controls; berry::IPreferences::Pointer m_PreferencesNode; }; #endif diff --git a/Plugins/org.mitk.gui.qt.rt.dosevisualization/src/internal/mitkDoseVisPreferenceHelper.cpp b/Plugins/org.mitk.gui.qt.rt.dosevisualization/src/internal/mitkDoseVisPreferenceHelper.cpp index e683d2eab4..a8d01b1fd1 100644 --- a/Plugins/org.mitk.gui.qt.rt.dosevisualization/src/internal/mitkDoseVisPreferenceHelper.cpp +++ b/Plugins/org.mitk.gui.qt.rt.dosevisualization/src/internal/mitkDoseVisPreferenceHelper.cpp @@ -1,216 +1,245 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "mitkDoseVisPreferenceHelper.h" #include "mitkRTUIConstants.h" #include "mitkIsoLevelsGenerator.h" #include #include +#include +#include + void mitk::rt::StorePresetsMap(const PresetMapType& presetMap) { berry::IPreferencesService::Pointer prefService = berry::Platform::GetServiceRegistry().GetServiceById(berry::IPreferencesService::ID); berry::IPreferences::Pointer doseVisNode = prefService->GetSystemPreferences()->Node(mitk::rt::UIConstants::ROOT_DOSE_VIS_PREFERENCE_NODE_ID); berry::IPreferences::Pointer presetsNode = doseVisNode->Node(mitk::rt::UIConstants::ROOT_ISO_PRESETS_PREFERENCE_NODE_ID); presetsNode->RemoveNode(); doseVisNode->Flush(); //new empty preset node presetsNode = doseVisNode->Node(mitk::rt::UIConstants::ROOT_ISO_PRESETS_PREFERENCE_NODE_ID); //store map in new node for (PresetMapType::const_iterator pos = presetMap.begin(); pos != presetMap.end(); ++pos) { berry::IPreferences::Pointer aPresetNode = presetsNode->Node(pos->first); unsigned int id = 0; for (mitk::IsoDoseLevelSet::ConstIterator levelPos = pos->second->Begin(); levelPos != pos->second->End(); ++levelPos, ++id ) { std::ostringstream stream; stream << id; berry::IPreferences::Pointer levelNode = aPresetNode->Node(stream.str()); levelNode->PutDouble(mitk::rt::UIConstants::ISO_LEVEL_DOSE_VALUE_ID,levelPos->GetDoseValue()); levelNode->PutFloat(mitk::rt::UIConstants::ISO_LEVEL_COLOR_RED_ID,levelPos->GetColor().GetRed()); levelNode->PutFloat(mitk::rt::UIConstants::ISO_LEVEL_COLOR_GREEN_ID,levelPos->GetColor().GetGreen()); levelNode->PutFloat(mitk::rt::UIConstants::ISO_LEVEL_COLOR_BLUE_ID,levelPos->GetColor().GetBlue()); levelNode->PutBool(mitk::rt::UIConstants::ISO_LEVEL_VISIBILITY_ISOLINES_ID,levelPos->GetVisibleIsoLine()); levelNode->PutBool(mitk::rt::UIConstants::ISO_LEVEL_VISIBILITY_COLORWASH_ID,levelPos->GetVisibleColorWash()); levelNode->Flush(); } aPresetNode->Flush(); } presetsNode->Flush(); } mitk::rt::PresetMapType mitk::rt::LoadPresetsMap() { berry::IPreferencesService::Pointer prefService = berry::Platform::GetServiceRegistry().GetServiceById(berry::IPreferencesService::ID); berry::IPreferences::Pointer presetsNode = prefService->GetSystemPreferences()->Node(mitk::rt::UIConstants::ROOT_ISO_PRESETS_PREFERENCE_NODE_ID); typedef std::vector NamesType; NamesType names = presetsNode->ChildrenNames(); PresetMapType presetMap; for (NamesType::const_iterator pos = names.begin(); pos != names.end(); ++pos) { berry::IPreferences::Pointer aPresetNode = presetsNode->Node(*pos); if (aPresetNode.IsNull()) { - mitkThrow()<< "Error in preference interface. Cannot finde preset node under given name. Name: "<<*pos; + mitkThrow()<< "Error in preference interface. Cannot find preset node under given name. Name: "<<*pos; } mitk::IsoDoseLevelSet::Pointer levelSet = mitk::IsoDoseLevelSet::New(); NamesType levelNames = aPresetNode->ChildrenNames(); for (NamesType::const_iterator levelName = levelNames.begin(); levelName != levelNames.end(); ++levelName) { berry::IPreferences::Pointer levelNode = aPresetNode->Node(*levelName); if (aPresetNode.IsNull()) { - mitkThrow()<< "Error in preference interface. Cannot finde level node under given preset name. Name: "<<*pos<<"; Level id: "<<*levelName; + mitkThrow()<< "Error in preference interface. Cannot find level node under given preset name. Name: "<<*pos<<"; Level id: "<<*levelName; } mitk::IsoDoseLevel::Pointer isoLevel = mitk::IsoDoseLevel::New(); isoLevel->SetDoseValue(levelNode->GetDouble(mitk::rt::UIConstants::ISO_LEVEL_DOSE_VALUE_ID,0.0)); mitk::IsoDoseLevel::ColorType color; color.SetRed(levelNode->GetFloat(mitk::rt::UIConstants::ISO_LEVEL_COLOR_RED_ID,1.0)); color.SetGreen(levelNode->GetFloat(mitk::rt::UIConstants::ISO_LEVEL_COLOR_GREEN_ID,1.0)); color.SetBlue(levelNode->GetFloat(mitk::rt::UIConstants::ISO_LEVEL_COLOR_BLUE_ID,1.0)); isoLevel->SetColor(color); isoLevel->SetVisibleIsoLine(levelNode->GetBool(mitk::rt::UIConstants::ISO_LEVEL_VISIBILITY_ISOLINES_ID,true)); isoLevel->SetVisibleColorWash(levelNode->GetBool(mitk::rt::UIConstants::ISO_LEVEL_VISIBILITY_COLORWASH_ID,true)); levelSet->SetIsoDoseLevel(isoLevel); } presetMap.insert(std::make_pair(*pos,levelSet)); } if (presetMap.size() == 0) - { //if there are no presets use fallback. + { //if there are no presets use fallback and store it. presetMap = mitk::rt::GenerateDefaultPresetsMap(); + StorePresetsMap(presetMap); } return presetMap; } mitk::rt::PresetMapType mitk::rt::GenerateDefaultPresetsMap() { mitk::rt::PresetMapType result; result.insert(std::make_pair(std::string("Virtuos"), mitk::rt::GeneratIsoLevels_Virtuos())); return result; } std::string mitk::rt::GetSelectedPresetName() { berry::IPreferencesService::Pointer prefService = berry::Platform::GetServiceRegistry().GetServiceById(berry::IPreferencesService::ID); berry::IPreferences::Pointer prefNode = prefService->GetSystemPreferences()->Node(mitk::rt::UIConstants::ROOT_DOSE_VIS_PREFERENCE_NODE_ID); std::string result = prefNode->Get(mitk::rt::UIConstants::SELECTED_ISO_PRESET_ID, ""); return result; } -void mitk::rt::SetSelectedPresetName(std::string presetName) +void mitk::rt::SetSelectedPresetName(const std::string& presetName) { berry::IPreferencesService::Pointer prefService = berry::Platform::GetServiceRegistry().GetServiceById(berry::IPreferencesService::ID); berry::IPreferences::Pointer prefNode = prefService->GetSystemPreferences()->Node(mitk::rt::UIConstants::ROOT_DOSE_VIS_PREFERENCE_NODE_ID); berry::IPreferences::Pointer presetsNode = prefService->GetSystemPreferences()->Node(mitk::rt::UIConstants::ROOT_ISO_PRESETS_PREFERENCE_NODE_ID); typedef std::vector NamesType; NamesType presetNames = presetsNode->ChildrenNames(); NamesType::iterator finding = std::find(presetNames.begin(),presetNames.end(),presetName); if (finding == presetNames.end()) { mitkThrow()<< "Error. Tried to set invalid selected preset name. Preset name does not exist in the defined presets. Preset name: "<Put(mitk::rt::UIConstants::SELECTED_ISO_PRESET_ID,presetName); } bool mitk::rt::GetReferenceDoseValue(mitk::DoseValueAbs& value) { berry::IPreferencesService::Pointer prefService = berry::Platform::GetServiceRegistry().GetServiceById(berry::IPreferencesService::ID); berry::IPreferences::Pointer prefNode = prefService->GetSystemPreferences()->Node(mitk::rt::UIConstants::ROOT_DOSE_VIS_PREFERENCE_NODE_ID); bool result = prefNode->GetBool(mitk::rt::UIConstants::GLOBAL_REFERENCE_DOSE_SYNC_ID, true); - value = prefNode->GetDouble(mitk::rt::UIConstants::REFERENCE_DOSE_ID, 0); + value = prefNode->GetDouble(mitk::rt::UIConstants::REFERENCE_DOSE_ID, mitk::rt::UIConstants::DEFAULT_REFERENCE_DOSE_VALUE); return result; } void mitk::rt::SetReferenceDoseValue(bool globalSync, mitk::DoseValueAbs value) { berry::IPreferencesService::Pointer prefService = berry::Platform::GetServiceRegistry().GetServiceById(berry::IPreferencesService::ID); berry::IPreferences::Pointer prefNode = prefService->GetSystemPreferences()->Node(mitk::rt::UIConstants::ROOT_DOSE_VIS_PREFERENCE_NODE_ID); prefNode->PutBool(mitk::rt::UIConstants::GLOBAL_REFERENCE_DOSE_SYNC_ID, globalSync); if (value >= 0) { prefNode->PutDouble(mitk::rt::UIConstants::REFERENCE_DOSE_ID, value); } } bool mitk::rt::GetDoseDisplayAbsolute() { berry::IPreferencesService::Pointer prefService = berry::Platform::GetServiceRegistry().GetServiceById(berry::IPreferencesService::ID); berry::IPreferences::Pointer prefNode = prefService->GetSystemPreferences()->Node(mitk::rt::UIConstants::ROOT_DOSE_VIS_PREFERENCE_NODE_ID); bool result = prefNode->GetBool(mitk::rt::UIConstants::DOSE_DISPLAY_ABSOLUTE_ID, false); return result; } -void mitk::rt::SetDoseDisplayAbsolute(bool& isAbsolute) +void mitk::rt::SetDoseDisplayAbsolute(bool isAbsolute) { berry::IPreferencesService::Pointer prefService = berry::Platform::GetServiceRegistry().GetServiceById(berry::IPreferencesService::ID); berry::IPreferences::Pointer prefNode = prefService->GetSystemPreferences()->Node(mitk::rt::UIConstants::ROOT_DOSE_VIS_PREFERENCE_NODE_ID); prefNode->PutBool(mitk::rt::UIConstants::DOSE_DISPLAY_ABSOLUTE_ID, isAbsolute); } + +void mitk::rt::SignalReferenceDoseChange(bool globalSync, mitk::DoseValueAbs value, ctkPluginContext* context) +{ + ctkServiceReference ref = context->getServiceReference(); + if (ref) + { + ctkEventAdmin* eventAdmin = context->getService(ref); + ctkProperties props; + props["value"] = value; + props["globalSync"] = globalSync; + ctkEvent presetMapChangedEvent(mitk::rt::CTKEventConstants::TOPIC_REFERENCE_DOSE_CHANGED.c_str()); + eventAdmin->sendEvent(presetMapChangedEvent); + } +} + +void mitk::rt::SignalPresetMapChange(ctkPluginContext* context) +{ + ctkServiceReference ref = context->getServiceReference(); + if (ref) + { + ctkEventAdmin* eventAdmin = context->getService(ref); + ctkEvent presetMapChangedEvent(mitk::rt::CTKEventConstants::TOPIC_ISO_DOSE_LEVEL_PRESETS_CHANGED.c_str()); + eventAdmin->sendEvent(presetMapChangedEvent); + } +} diff --git a/Plugins/org.mitk.gui.qt.rt.dosevisualization/src/internal/mitkDoseVisPreferenceHelper.h b/Plugins/org.mitk.gui.qt.rt.dosevisualization/src/internal/mitkDoseVisPreferenceHelper.h index 636ad6d136..ebf9c734b4 100644 --- a/Plugins/org.mitk.gui.qt.rt.dosevisualization/src/internal/mitkDoseVisPreferenceHelper.h +++ b/Plugins/org.mitk.gui.qt.rt.dosevisualization/src/internal/mitkDoseVisPreferenceHelper.h @@ -1,66 +1,74 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef __DOSE_VIS_PREFERENCE_HELPER_H #define __DOSE_VIS_PREFERENCE_HELPER_H #include #include #include "mitkIsoDoseLevelCollections.h" +class ctkPluginContext; + namespace mitk { namespace rt { typedef std::map PresetMapType; /** Stores the given preset map in the application preferences. */ void StorePresetsMap(const PresetMapType& presetMap); /** Loads all defined iso dose level presets from the preferences and stores them - in a map. Key is the name of the preset.*/ + in a map. Key is the name of the preset. + @remark If no presets are stored in the preferences this function will generate default presets + (using GenerateDefaultPresetsMap()) and the stores it in the preferences (to guarantee a consistent state) + before passing the default presets back.*/ PresetMapType LoadPresetsMap(); /** Generate the default presets map.*/ PresetMapType GenerateDefaultPresetsMap(); /**Retrieves the name of the preset, that is currently selected for the application, from the preferences.*/ std::string GetSelectedPresetName(); /** checks if the passed name exists in the preset map. If not an exception is thrown. If it exists, the new - * value will be set.*/ - void SetSelectedPresetName(std::string presetName); - - /** retrieves the reference dose from the preferences and indicates of global sync for reference dose is activated - or not. - @param value The reference dose value stored in the preferences. - @return Indicator for global sync. True: global sync activated -> preference value is relevant. - False: global sync deactivated. Value is irrelevant. Each node has its own value.*/ + * value will be set.*/ + void SetSelectedPresetName(const std::string& presetName); + + /** retrieves the reference dose from the preferences and indicates if global sync for reference dose is activated + or not. + @param value The reference dose value stored in the preferences. + @return Indicator for global sync. True: global sync activated -> preference value is relevant. + False: global sync deactivated. Value is irrelevant. Each node has its own value.*/ bool GetReferenceDoseValue(DoseValueAbs& value); /** Sets the global sync setting and dose reference value in the preferences. - * @param globalSync Indicator if global sync should be set active (true) or inactive (false). If it is true, the value is irrelevant (but will be set). - * @param value The dose reference value that should be stored in the preferences.If set to <0 it will be ignored and not changed/set.*/ + * @param globalSync Indicator if global sync should be set active (true) or inactive (false). If it is true, the value is irrelevant (but will be set). + * @param value The dose reference value that should be stored in the preferences.If set to <0 it will be ignored and not changed/set.*/ void SetReferenceDoseValue(bool globalSync, DoseValueAbs value = -1); bool GetDoseDisplayAbsolute(); - void SetDoseDisplayAbsolute(bool& isAbsolute); + void SetDoseDisplayAbsolute(bool isAbsolute); + + void SignalReferenceDoseChange(bool globalSync, mitk::DoseValueAbs value, ctkPluginContext* context); + void SignalPresetMapChange(ctkPluginContext* context); } } #endif diff --git a/Plugins/org.mitk.gui.qt.rt.dosevisualization/src/internal/mitkRTDoseVisualSyncService.cpp b/Plugins/org.mitk.gui.qt.rt.dosevisualization/src/internal/mitkRTDoseVisualSyncService.cpp deleted file mode 100644 index 616c29fe82..0000000000 --- a/Plugins/org.mitk.gui.qt.rt.dosevisualization/src/internal/mitkRTDoseVisualSyncService.cpp +++ /dev/null @@ -1,79 +0,0 @@ -/*============================================================================= - - MAP4CTK - DKFZ MatchPoint for CommonTK - (c) Copyright, German Cancer Research Center, Heidelberg, Germany - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - -=============================================================================*/ - - -#include "m4cITKImageMapperImpl_p.h" - - m4cITKImageMapperImpl::m4cITKImageMapperImpl() - { - }; - - m4cITKImage2DMapper::ResultFloatImageType::Pointer - m4cITKImageMapperImpl:: - map(const m4cITKImage2DMapper::InputFloatImageType* input, const m4cITKImage2DMapper::RegistrationType* registration, - bool throwOnOutOfInputAreaError, const float& paddingValue, const m4cITKImage2DMapper::ResultImageDescriptorType* resultDescriptor, - bool throwOnMappingError, const float& errorValue) const - { - return m4cITKImage2DMapper::doMap(input, registration, throwOnOutOfInputAreaError, paddingValue, resultDescriptor, throwOnMappingError, errorValue); - }; - - m4cITKImage2DMapper::ResultUShortImageType::Pointer - m4cITKImageMapperImpl:: - map(const m4cITKImage2DMapper::InputUShortImageType* input, const m4cITKImage2DMapper::RegistrationType* registration, - bool throwOnOutOfInputAreaError, const unsigned short& paddingValue, const m4cITKImage2DMapper::ResultImageDescriptorType* resultDescriptor, - bool throwOnMappingError, const unsigned short& errorValue) const - { - return m4cITKImage2DMapper::doMap(input, registration, throwOnOutOfInputAreaError, paddingValue, resultDescriptor, throwOnMappingError, errorValue); - }; - - m4cITKImage2DMapper::ResultUCharImageType::Pointer - m4cITKImageMapperImpl:: - map(const m4cITKImage2DMapper::InputUCharImageType* input, const m4cITKImage2DMapper::RegistrationType* registration, - bool throwOnOutOfInputAreaError, const unsigned char& paddingValue, const m4cITKImage2DMapper::ResultImageDescriptorType* resultDescriptor, - bool throwOnMappingError, const unsigned char& errorValue) const - { - return m4cITKImage2DMapper::doMap(input, registration, throwOnOutOfInputAreaError, paddingValue, resultDescriptor, throwOnMappingError, errorValue); - }; - - m4cITKImage3DMapper::ResultFloatImageType::Pointer - m4cITKImageMapperImpl:: - map(const m4cITKImage3DMapper::InputFloatImageType* input, const m4cITKImage3DMapper::RegistrationType* registration, - bool throwOnOutOfInputAreaError, const float& paddingValue, const m4cITKImage3DMapper::ResultImageDescriptorType* resultDescriptor, - bool throwOnMappingError, const float& errorValue) const - { - return m4cITKImage3DMapper::doMap(input, registration, throwOnOutOfInputAreaError, paddingValue, resultDescriptor, throwOnMappingError, errorValue); - }; - - m4cITKImage3DMapper::ResultUShortImageType::Pointer - m4cITKImageMapperImpl:: - map(const m4cITKImage3DMapper::InputUShortImageType* input, const m4cITKImage3DMapper::RegistrationType* registration, - bool throwOnOutOfInputAreaError, const unsigned short& paddingValue, const m4cITKImage3DMapper::ResultImageDescriptorType* resultDescriptor, - bool throwOnMappingError, const unsigned short& errorValue) const - { - return m4cITKImage3DMapper::doMap(input, registration, throwOnOutOfInputAreaError, paddingValue, resultDescriptor, throwOnMappingError, errorValue); - }; - - m4cITKImage3DMapper::ResultUCharImageType::Pointer - m4cITKImageMapperImpl:: - map(const m4cITKImage3DMapper::InputUCharImageType* input, const m4cITKImage3DMapper::RegistrationType* registration, - bool throwOnOutOfInputAreaError, const unsigned char& paddingValue, const m4cITKImage3DMapper::ResultImageDescriptorType* resultDescriptor, - bool throwOnMappingError, const unsigned char& errorValue) const - { - return m4cITKImage3DMapper::doMap(input, registration, throwOnOutOfInputAreaError, paddingValue, resultDescriptor, throwOnMappingError, errorValue); - }; diff --git a/Plugins/org.mitk.gui.qt.rt.dosevisualization/src/internal/mitkRTDoseVisualSyncService.h b/Plugins/org.mitk.gui.qt.rt.dosevisualization/src/internal/mitkRTDoseVisualSyncService.h deleted file mode 100644 index 63d6a5d403..0000000000 --- a/Plugins/org.mitk.gui.qt.rt.dosevisualization/src/internal/mitkRTDoseVisualSyncService.h +++ /dev/null @@ -1,64 +0,0 @@ -/*============================================================================= - - MAP4CTK - DKFZ MatchPoint for CommonTK - (c) Copyright, German Cancer Research Center, Heidelberg, Germany - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - -=============================================================================*/ - - -#ifndef M4C_ITK_IMAGE_MAPPER_IMPL_P_H -#define M4C_ITK_IMAGE_MAPPER_IMPL_P_H - -#include "m4cConfigure.h" -#include "m4cITKImageMapperExport.h" -#include "m4cITKImageMapper.h" - -#include - -class m4cITKImageMapperImpl : public QObject, public m4cITKImage2DMapper, public m4cITKImage3DMapper -{ - - Q_OBJECT - Q_INTERFACES(m4cITKImage2DMapper m4cITKImage3DMapper) - -public: - virtual m4cITKImage2DMapper::ResultFloatImageType::Pointer map(const m4cITKImage2DMapper::InputFloatImageType* input, const m4cITKImage2DMapper::RegistrationType* registration, - bool throwOnOutOfInputAreaError = false, const float& paddingValue = 0, const m4cITKImage2DMapper::ResultImageDescriptorType* resultDescriptor = NULL, - bool throwOnMappingError = true, const float& errorValue = 0) const; - - virtual m4cITKImage2DMapper::ResultUShortImageType::Pointer map(const m4cITKImage2DMapper::InputUShortImageType* input, const m4cITKImage2DMapper::RegistrationType* registration, - bool throwOnOutOfInputAreaError = false, const unsigned short& paddingValue = 0, const m4cITKImage2DMapper::ResultImageDescriptorType* resultDescriptor = NULL, - bool throwOnMappingError = true, const unsigned short& errorValue = 0)const; - - virtual m4cITKImage2DMapper::ResultUCharImageType::Pointer map(const m4cITKImage2DMapper::InputUCharImageType* input, const m4cITKImage2DMapper::RegistrationType* registration, - bool throwOnOutOfInputAreaError = false, const unsigned char& paddingValue = 0, const m4cITKImage2DMapper::ResultImageDescriptorType* resultDescriptor = NULL, - bool throwOnMappingError = true, const unsigned char& errorValue = 0) const; - - virtual m4cITKImage3DMapper::ResultFloatImageType::Pointer map(const m4cITKImage3DMapper::InputFloatImageType* input, const m4cITKImage3DMapper::RegistrationType* registration, - bool throwOnOutOfInputAreaError = false, const float& paddingValue = 0, const m4cITKImage3DMapper::ResultImageDescriptorType* resultDescriptor = NULL, - bool throwOnMappingError = true, const float& errorValue = 0) const; - - virtual m4cITKImage3DMapper::ResultUShortImageType::Pointer map(const m4cITKImage3DMapper::InputUShortImageType* input, const m4cITKImage3DMapper::RegistrationType* registration, - bool throwOnOutOfInputAreaError = false, const unsigned short& paddingValue = 0, const m4cITKImage3DMapper::ResultImageDescriptorType* resultDescriptor = NULL, - bool throwOnMappingError = true, const unsigned short& errorValue = 0) const; - - virtual m4cITKImage3DMapper::ResultUCharImageType::Pointer map(const m4cITKImage3DMapper::InputUCharImageType* input, const m4cITKImage3DMapper::RegistrationType* registration, - bool throwOnOutOfInputAreaError = false, const unsigned char& paddingValue = 0, const m4cITKImage3DMapper::ResultImageDescriptorType* resultDescriptor = NULL, - bool throwOnMappingError = true, const unsigned char& errorValue = 0) const; - - m4cITKImageMapperImpl(); -}; - -#endif // M4C_IMAGE_MAPPER_P_H diff --git a/Plugins/org.mitk.gui.qt.rt.dosevisualization/src/internal/org_mitk_gui_qt_rt_dosevisualization_Activator.cpp b/Plugins/org.mitk.gui.qt.rt.dosevisualization/src/internal/org_mitk_gui_qt_rt_dosevisualization_Activator.cpp index 9c88998735..eb0e2631cc 100644 --- a/Plugins/org.mitk.gui.qt.rt.dosevisualization/src/internal/org_mitk_gui_qt_rt_dosevisualization_Activator.cpp +++ b/Plugins/org.mitk.gui.qt.rt.dosevisualization/src/internal/org_mitk_gui_qt_rt_dosevisualization_Activator.cpp @@ -1,44 +1,55 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "org_mitk_gui_qt_rt_dosevisualization_Activator.h" #include #include "RTDoseVisualizer.h" #include "RTUIPreferencePage.h" #include "DoseVisualizationPreferencePage.h" #include "LoadingRTView.h" namespace mitk { -void org_mitk_gui_qt_rt_dosevisualization_Activator::start(ctkPluginContext* context) -{ - BERRY_REGISTER_EXTENSION_CLASS(RTDoseVisualizer, context); - BERRY_REGISTER_EXTENSION_CLASS(RTUIPreferencePage, context) - BERRY_REGISTER_EXTENSION_CLASS(DoseVisualizationPreferencePage, context) - BERRY_REGISTER_EXTENSION_CLASS(LoadingRTView, context) -} + ctkPluginContext* org_mitk_gui_qt_rt_dosevisualization_Activator::m_Context = NULL; -void org_mitk_gui_qt_rt_dosevisualization_Activator::stop(ctkPluginContext* context) -{ - Q_UNUSED(context) -} + void org_mitk_gui_qt_rt_dosevisualization_Activator::start(ctkPluginContext* context) + { + BERRY_REGISTER_EXTENSION_CLASS(RTDoseVisualizer, context); + BERRY_REGISTER_EXTENSION_CLASS(RTUIPreferencePage, context) + BERRY_REGISTER_EXTENSION_CLASS(DoseVisualizationPreferencePage, context) + BERRY_REGISTER_EXTENSION_CLASS(LoadingRTView, context) + + m_Context = context; + } + + void org_mitk_gui_qt_rt_dosevisualization_Activator::stop(ctkPluginContext* context) + { + Q_UNUSED(context); + + m_Context = NULL; + } + + ctkPluginContext* org_mitk_gui_qt_rt_dosevisualization_Activator::GetContext() + { + return m_Context; + } } Q_EXPORT_PLUGIN2(org_mitk_gui_qt_rt_dosevisualization, mitk::org_mitk_gui_qt_rt_dosevisualization_Activator) diff --git a/Plugins/org.mitk.gui.qt.rt.dosevisualization/src/internal/org_mitk_gui_qt_rt_dosevisualization_Activator.h b/Plugins/org.mitk.gui.qt.rt.dosevisualization/src/internal/org_mitk_gui_qt_rt_dosevisualization_Activator.h index f478201519..f0f1449354 100644 --- a/Plugins/org.mitk.gui.qt.rt.dosevisualization/src/internal/org_mitk_gui_qt_rt_dosevisualization_Activator.h +++ b/Plugins/org.mitk.gui.qt.rt.dosevisualization/src/internal/org_mitk_gui_qt_rt_dosevisualization_Activator.h @@ -1,40 +1,46 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef org_mitk_gui_qt_rt_dosevisualization_Activator_h #define org_mitk_gui_qt_rt_dosevisualization_Activator_h #include namespace mitk { -class org_mitk_gui_qt_rt_dosevisualization_Activator : - public QObject, public ctkPluginActivator -{ - Q_OBJECT - Q_INTERFACES(ctkPluginActivator) + class org_mitk_gui_qt_rt_dosevisualization_Activator : + public QObject, public ctkPluginActivator + { + Q_OBJECT + Q_INTERFACES(ctkPluginActivator) -public: + public: - void start(ctkPluginContext* context); - void stop(ctkPluginContext* context); + void start(ctkPluginContext* context); + void stop(ctkPluginContext* context); -}; // org_mitk_gui_qt_rt_dosevisualization_Activator + static ctkPluginContext* GetContext(); + + private: + + static ctkPluginContext* m_Context; + + }; // org_mitk_gui_qt_rt_dosevisualization_Activator } #endif // org_mitk_gui_qt_rt_dosevisualization_Activator_h diff --git a/Plugins/org.mitk.gui.qt.rt.dosevisualization/src/mitkRTDoseVisualSyncServiceInterface.h b/Plugins/org.mitk.gui.qt.rt.dosevisualization/src/mitkRTDoseVisualSyncServiceInterface.h deleted file mode 100644 index 362d19a199..0000000000 --- a/Plugins/org.mitk.gui.qt.rt.dosevisualization/src/mitkRTDoseVisualSyncServiceInterface.h +++ /dev/null @@ -1,86 +0,0 @@ -/*============================================================================= - - MAP4CTK - DKFZ MatchPoint for CommonTK - (c) Copyright, German Cancer Research Center, Heidelberg, Germany - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - -=============================================================================*/ - - -#ifndef M4C_ITK_IMAGE_MAPPER_H -#define M4C_ITK_IMAGE_MAPPER_H - -#include "mapImageMappingTask.h" -#include "mapRegistration.h" -#include "itkImage.h" -#include - -template -class m4cITKImageMapper -{ -public: - typedef ::map::core::Registration RegistrationType; - typedef ::map::core::FieldRepresentationDescriptor ResultImageDescriptorType; - - typedef ::itk::Image InputFloatImageType; - typedef ::itk::Image ResultFloatImageType; - typedef ::itk::Image InputUShortImageType; - typedef ::itk::Image ResultUShortImageType; - typedef ::itk::Image InputUCharImageType; - typedef ::itk::Image ResultUCharImageType; - - virtual typename ResultFloatImageType::Pointer map(const InputFloatImageType* input, const RegistrationType* registration, - bool throwOnOutOfInputAreaError = false, const float& paddingValue = 0, const ResultImageDescriptorType* resultDescriptor = NULL, - bool throwOnMappingError = true, const float& errorValue = 0) const = 0; - - virtual typename ResultUShortImageType::Pointer map(const InputUShortImageType* input, const RegistrationType* registration, - bool throwOnOutOfInputAreaError = false, const unsigned short& paddingValue = 0, const ResultImageDescriptorType* resultDescriptor = NULL, - bool throwOnMappingError = true, const unsigned short& errorValue = 0) const = 0; - - virtual typename ResultUCharImageType::Pointer map(const InputUCharImageType* input, const RegistrationType* registration, - bool throwOnOutOfInputAreaError = false, const unsigned char& paddingValue = 0, const ResultImageDescriptorType* resultDescriptor = NULL, - bool throwOnMappingError = true, const unsigned char& errorValue = 0) const = 0; - -protected: - - template typename ::itk::Image::Pointer doMap(const ::itk::Image* input, const RegistrationType* registration, - bool throwOnOutOfInputAreaError, const TPixelType& paddingValue, const ResultImageDescriptorType* resultDescriptor, - bool throwOnMappingError, const TPixelType& errorValue) const - { - typedef ::map::core::ImageMappingTask, ::itk::Image > MappingTaskType; - typename MappingTaskType::Pointer spTask = MappingTaskType::New(); - - spTask->setInputImage(input); - spTask->setRegistration(registration); - spTask->setResultImageDescriptor(resultDescriptor); - spTask->setThrowOnMappingError(throwOnMappingError); - spTask->setErrorValue(errorValue); - spTask->setThrowOnPaddingError(throwOnOutOfInputAreaError); - spTask->setPaddingValue(paddingValue); - - spTask->execute(); - return spTask->getResultImage(); - }; - - m4cITKImageMapper() {}; - virtual ~m4cITKImageMapper() {}; -}; - -typedef m4cITKImageMapper<2,2> m4cITKImage2DMapper; -typedef m4cITKImageMapper<3,3> m4cITKImage3DMapper; - -Q_DECLARE_INTERFACE(m4cITKImage2DMapper, "de.dkfz.matchpoint.mapper.image.itk.2D") -Q_DECLARE_INTERFACE(m4cITKImage3DMapper, "de.dkfz.matchpoint.mapper.image.itk.3D") - -#endif // M4C_MAPPER_P_H