diff --git a/Modules/CMakeLists.txt b/Modules/CMakeLists.txt index 495bff51bb..cfbddcc599 100644 --- a/Modules/CMakeLists.txt +++ b/Modules/CMakeLists.txt @@ -1,78 +1,79 @@ # Modules must be listed according to their dependencies set(module_dirs DataTypesExt AlgorithmsExt MapperExt IOExt Qt4Qt5TestModule SceneSerializationBase PlanarFigure ImageDenoising ImageExtraction ImageStatistics LegacyAdaptors IpPicSupport Ext SceneSerialization GraphAlgorithms ContourModel SurfaceInterpolation Segmentation PlanarFigureSegmentation OpenViewCore QmlItems QtWidgets QtWidgetsExt SegmentationUI DiffusionImaging GPGPU IGTBase IGT CameraCalibration RigidRegistration RigidRegistrationUI DeformableRegistration DeformableRegistrationUI OpenCL OpenCVVideoSupport Overlays InputDevices ToFHardware ToFProcessing ToFUI US USUI DicomUI Simulation Remeshing Python Persistence IGTUI VtkShaders DicomRT + RTUI ) if(MITK_ENABLE_PIC_READER) list(APPEND module_dirs IpPicSupportIO) endif() set(MITK_DEFAULT_SUBPROJECTS MITK-Modules) foreach(module_dir ${module_dirs}) add_subdirectory(${module_dir}) endforeach() if(MITK_PRIVATE_MODULES) file(GLOB all_subdirs RELATIVE ${MITK_PRIVATE_MODULES} ${MITK_PRIVATE_MODULES}/*) foreach(subdir ${all_subdirs}) string(FIND ${subdir} "." _result) if(_result EQUAL -1) if(EXISTS ${MITK_PRIVATE_MODULES}/${subdir}/CMakeLists.txt) message(STATUS "Found private module ${subdir}") add_subdirectory(${MITK_PRIVATE_MODULES}/${subdir} private_modules/${subdir}) endif() endif() endforeach() endif(MITK_PRIVATE_MODULES) diff --git a/Modules/RTUI/CMakeLists.txt b/Modules/RTUI/CMakeLists.txt new file mode 100644 index 0000000000..4c3873ac17 --- /dev/null +++ b/Modules/RTUI/CMakeLists.txt @@ -0,0 +1,5 @@ +MITK_CREATE_MODULE( + INCLUDE_DIRS Qmitk Helper + DEPENDS MitkDicomRT MitkQtWidgets MitkQtWidgetsExt + PACKAGE_DEPENDS CTK Qt4|Qtcore +) diff --git a/Modules/RTUI/Helper/mitkIsoLevelsGenerator.cpp b/Modules/RTUI/Helper/mitkIsoLevelsGenerator.cpp new file mode 100644 index 0000000000..8496c1cb47 --- /dev/null +++ b/Modules/RTUI/Helper/mitkIsoLevelsGenerator.cpp @@ -0,0 +1,134 @@ +/*=================================================================== + +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 "mitkIsoLevelsGenerator.h" + +mitk::IsoDoseLevelSet::Pointer mitk::GeneratIsoLevels_Virtuos() +{ + mitk::IsoDoseLevelSet::Pointer levelSet = mitk::IsoDoseLevelSet::New(); + + mitk::IsoDoseLevel::ColorType color; + color[0] = 0.0; + color[1] = 0.0; + color[2] = 0.4; + mitk::IsoDoseLevel::Pointer level = mitk::IsoDoseLevel::New(0.01,color,true,true); + levelSet->SetIsoDoseLevel(level); + + color[0] = 0.0; + color[1] = 0.2; + color[2] = 0.8; + level = mitk::IsoDoseLevel::New(0.1,color,true,true); + levelSet->SetIsoDoseLevel(level); + + color[0] = 0.0; + color[1] = 0.4; + color[2] = 1.0; + level = mitk::IsoDoseLevel::New(0.2,color,true,true); + levelSet->SetIsoDoseLevel(level); + + color[0] = 0.0; + color[1] = 0.7; + color[2] = 1.0; + level = mitk::IsoDoseLevel::New(0.3,color,true,true); + levelSet->SetIsoDoseLevel(level); + + color[0] = 0.0; + color[1] = 0.7; + color[2] = 0.6; + level = mitk::IsoDoseLevel::New(0.4,color,true,true); + levelSet->SetIsoDoseLevel(level); + + color[0] = 0.0; + color[1] = 1.0; + color[2] = 0.3; + level = mitk::IsoDoseLevel::New(0.5,color,true,true); + levelSet->SetIsoDoseLevel(level); + + color[0] = 1.0; + color[1] = 1.0; + color[2] = 0.6; + level = mitk::IsoDoseLevel::New(0.6,color,true,true); + levelSet->SetIsoDoseLevel(level); + + color[0] = 1.0; + color[1] = 1.0; + color[2] = 0.0; + level = mitk::IsoDoseLevel::New(0.7,color,true,true); + levelSet->SetIsoDoseLevel(level); + + color[0] = 1.0; + color[1] = 0.8; + color[2] = 0.0; + level = mitk::IsoDoseLevel::New(0.8,color,true,true); + levelSet->SetIsoDoseLevel(level); + + color[0] = 1.0; + color[1] = 0.5; + color[2] = 0.0; + level = mitk::IsoDoseLevel::New(0.9,color,true,true); + levelSet->SetIsoDoseLevel(level); + + color[0] = 1.0; + color[1] = 0.4; + color[2] = 0.0; + level = mitk::IsoDoseLevel::New(0.95,color,true,true); + levelSet->SetIsoDoseLevel(level); + + color[0] = 1.0; + color[1] = 0.2; + color[2] = 0.0; + level = mitk::IsoDoseLevel::New(1.0,color,true,true); + levelSet->SetIsoDoseLevel(level); + + color[0] = 1.0; + color[1] = 0.0; + color[2] = 0.3; + level = mitk::IsoDoseLevel::New(1.07,color,true,true); + levelSet->SetIsoDoseLevel(level); + + color[0] = 1.0; + color[1] = 0.0; + color[2] = 0.4; + level = mitk::IsoDoseLevel::New(1.1,color,true,true); + levelSet->SetIsoDoseLevel(level); + + color[0] = 1.0; + color[1] = 0.4; + color[2] = 0.4; + level = mitk::IsoDoseLevel::New(1.2,color,true,true); + levelSet->SetIsoDoseLevel(level); + + color[0] = 1.0; + color[1] = 0.7; + color[2] = 0.7; + level = mitk::IsoDoseLevel::New(1.3,color,true,true); + levelSet->SetIsoDoseLevel(level); + + color[0] = 0.8; + color[1] = 0.6; + color[2] = 0.6; + level = mitk::IsoDoseLevel::New(1.4,color,true,true); + levelSet->SetIsoDoseLevel(level); + + color[0] = 0.65; + color[1] = 0.4; + color[2] = 0.4; + level = mitk::IsoDoseLevel::New(1.5,color,true,true); + levelSet->SetIsoDoseLevel(level); + + return levelSet; +} diff --git a/Modules/RTUI/Helper/mitkIsoLevelsGenerator.h b/Modules/RTUI/Helper/mitkIsoLevelsGenerator.h new file mode 100644 index 0000000000..9631246478 --- /dev/null +++ b/Modules/RTUI/Helper/mitkIsoLevelsGenerator.h @@ -0,0 +1,30 @@ +/*=================================================================== + +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 __ISO_LEVELS_GENERATOR_H +#define __ISO_LEVELS_GENERATOR_H + +#include "mitkIsoDoseLevelCollections.h" + +#include "MitkRTUIExports.h" + +namespace mitk +{ +IsoDoseLevelSet::Pointer MitkRTUI_EXPORT GeneratIsoLevels_Virtuos(); +} + +#endif diff --git a/Modules/RTUI/Helper/mitkRTUIConstants.cpp b/Modules/RTUI/Helper/mitkRTUIConstants.cpp new file mode 100644 index 0000000000..fcb00705ef --- /dev/null +++ b/Modules/RTUI/Helper/mitkRTUIConstants.cpp @@ -0,0 +1,45 @@ +/*=================================================================== + +The Medical Imaging Interaction Toolkit (MITK) + +Copyright (c) German Cancer Research Center, +Division of Medical and Biological Informatics. +All rights reserved. + +This software is distributed WITHOUT ANY WARRANTY; without +even the implied warranty of MERCHANTABILITY or FITNESS FOR +A PARTICULAR PURPOSE. + +See LICENSE.txt or http://www.mitk.org for details. + +===================================================================*/ + +#include "mitkRTUIConstants.h" + +const std::string mitk::RTUIConstants::ROOT_PREFERENCE_NODE_ID = "/RT/UI"; +const std::string mitk::RTUIConstants::UNKNOWN_PRESCRIBED_DOSE_HANDLING_AS_DEFAULT_ID = "unkownDoseHandlingStyle"; +const std::string mitk::RTUIConstants::UNKNOWN_PRESCRIBED_DOSE_HANDLING_VALUE_ID = "unkownDoseHandlingValue"; + + +const std::string mitk::RTUIConstants::ROOT_DOSE_VIS_PREFERENCE_NODE_ID = "/RT/UI/doseVis"; +const std::string mitk::RTUIConstants::ROOT_ISO_PRESETS_PREFERENCE_NODE_ID = "/RT/UI/doseVis/isoPresets"; +const std::string mitk::RTUIConstants::REFERENCE_DOSE_ID = "referenceDose"; +const std::string mitk::RTUIConstants::GLOBAL_REFERENCE_DOSE_SYNC_ID = "globalReferenceDoseSync"; +const std::string mitk::RTUIConstants::DOSE_DISPLAY_ABSOLUTE_ID = "doseDisplayAbsolute"; +const std::string mitk::RTUIConstants::GLOBAL_VISIBILITY_ISOLINES_ID = "globalVisibilityIsoLines"; +const std::string mitk::RTUIConstants::GLOBAL_VISIBILITY_COLORWASH_ID = "globalVisibilityColorWash"; +const std::string mitk::RTUIConstants::SELECTED_ISO_PRESET_ID = "selectedIsoPreset"; + +const std::string mitk::RTUIConstants::ISO_LEVEL_DOSE_VALUE_ID = "doseValue"; +const std::string mitk::RTUIConstants::ISO_LEVEL_COLOR_RED_ID = "color_R"; +const std::string mitk::RTUIConstants::ISO_LEVEL_COLOR_GREEN_ID = "color_G"; +const std::string mitk::RTUIConstants::ISO_LEVEL_COLOR_BLUE_ID = "color_B"; +const std::string mitk::RTUIConstants::ISO_LEVEL_VISIBILITY_ISOLINES_ID = "visibleIsoLines"; +const std::string mitk::RTUIConstants::ISO_LEVEL_VISIBILITY_COLORWASH_ID = "visibleColorWash"; + +const mitk::DoseValueAbs mitk::RTUIConstants::DEFAULT_REFERENCE_DOSE_VALUE = 40.0; + +const std::string mitk::RTCTKEventConstants::TOPIC_ISO_DOSE_LEVEL_PRESETS = "org/mitk/rt/dosevisualization/presets"; +const std::string mitk::RTCTKEventConstants::TOPIC_ISO_DOSE_LEVEL_PRESETS_CHANGED = "org/mitk/rt/dosevisualization/presets/CHANGED"; +const std::string mitk::RTCTKEventConstants::TOPIC_REFERENCE_DOSE = "org/mitk/rt/dosevisualization/referenceDose"; +const std::string mitk::RTCTKEventConstants::TOPIC_REFERENCE_DOSE_CHANGED = "org/mitk/rt/dosevisualization/referenceDose/CHANGED"; diff --git a/Modules/RTUI/Helper/mitkRTUIConstants.h b/Modules/RTUI/Helper/mitkRTUIConstants.h new file mode 100644 index 0000000000..d59f1e1a5f --- /dev/null +++ b/Modules/RTUI/Helper/mitkRTUIConstants.h @@ -0,0 +1,83 @@ +/*=================================================================== + +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_UI_CONSTANTS_H_ +#define _MITK_RT_UI_CONSTANTS_H_ + +#include +#include + +#include "MitkRTUIExports.h" + +namespace mitk +{ +struct MitkRTUI_EXPORT RTUIConstants +{ + /** 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.*/ + 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. */ + 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 MitkRTUI_EXPORT RTCTKEventConstants +{ + /** 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.cpp b/Modules/RTUI/Qmitk/QmitkDoseColorDelegate.cpp new file mode 100644 index 0000000000..548b5cde00 --- /dev/null +++ b/Modules/RTUI/Qmitk/QmitkDoseColorDelegate.cpp @@ -0,0 +1,83 @@ +/*=================================================================== + +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 "QmitkDoseColorDelegate.h" + +#include +#include +#include +#include +#include +#include + +QmitkDoseColorDelegate::QmitkDoseColorDelegate(QObject * /*parent*/) +{ +} + +void QmitkDoseColorDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, + const QModelIndex &index) const +{ + QVariant data = index.data(Qt::EditRole); + + if (data.canConvert()) + { + QColor color = data.value(); + + painter->fillRect(option.rect, color); + } + else + { + QStyledItemDelegate::paint(painter, option, index); + } +} + +bool QmitkDoseColorDelegate::editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option, + const QModelIndex &index) +{ + Q_ASSERT(event); + Q_ASSERT(model); + + // make sure that the item is checkable + Qt::ItemFlags flags = model->flags(index); + if (!(flags & Qt::ItemIsEditable) || !(flags & Qt::ItemIsEnabled)) + { + return false; + } + + // make sure that we have the right event type + QMouseEvent* mouseEvent = dynamic_cast(event); + if (!mouseEvent) + { + return false; + } + else + { + if (mouseEvent->type() != QEvent::MouseButtonRelease || mouseEvent->button() != Qt::LeftButton) + { + return false; + } + } + + QColor oldcolor = index.data(Qt::EditRole).value(); + QColor newColor = QColorDialog::getColor(oldcolor, NULL); + + if (newColor.isValid()) + { + return model->setData(index, QVariant(newColor), Qt::EditRole); + } + + return false; +}; diff --git a/Modules/RTUI/Qmitk/QmitkDoseColorDelegate.h b/Modules/RTUI/Qmitk/QmitkDoseColorDelegate.h new file mode 100644 index 0000000000..78f027f81b --- /dev/null +++ b/Modules/RTUI/Qmitk/QmitkDoseColorDelegate.h @@ -0,0 +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 "MitkRTUIExports.h" + +/** \class QmitkDoseColorDelegate +\brief An item delegate for rendering and editing dose color in a QTableView.*/ +class MitkRTUI_EXPORT QmitkDoseColorDelegate : public QStyledItemDelegate +{ + Q_OBJECT + +public: + /// + /// Creates a new PropertyDelegate. + /// + QmitkDoseColorDelegate(QObject *parent = 0); + + bool editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option, + const QModelIndex &index); + + 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 new file mode 100644 index 0000000000..34ed4b28eb --- /dev/null +++ b/Modules/RTUI/Qmitk/QmitkDoseValueDelegate.cpp @@ -0,0 +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(); + + QVariant doubleValueVariant(doubleValue); + model->setData(index, doubleValueVariant); + } + else + { + QStyledItemDelegate::setModelData(editor, model, index); + } +} diff --git a/Modules/RTUI/Qmitk/QmitkDoseValueDelegate.h b/Modules/RTUI/Qmitk/QmitkDoseValueDelegate.h new file mode 100644 index 0000000000..5116d84c62 --- /dev/null +++ b/Modules/RTUI/Qmitk/QmitkDoseValueDelegate.h @@ -0,0 +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 "MitkRTUIExports.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).*/ +class MitkRTUI_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; +}; + +#endif /* QMITKPROPERTIESTABLEMODEL_H_ */ diff --git a/Modules/RTUI/Qmitk/QmitkDoseVisualStyleDelegate.cpp b/Modules/RTUI/Qmitk/QmitkDoseVisualStyleDelegate.cpp new file mode 100644 index 0000000000..9de4f0b4c8 --- /dev/null +++ b/Modules/RTUI/Qmitk/QmitkDoseVisualStyleDelegate.cpp @@ -0,0 +1,94 @@ +/*=================================================================== + +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 "QmitkDoseVisualStyleDelegate.h" + +#include +#include +#include +#include +#include + +static QRect CheckBoxRect(const QStyleOptionViewItem &view_item_style_options) { + QStyleOptionButton check_box_style_option; + QRect check_box_rect = QApplication::style()->subElementRect( + QStyle::SE_CheckBoxIndicator, + &check_box_style_option); + QPoint check_box_point(view_item_style_options.rect.x() + + view_item_style_options.rect.width() / 2 - + check_box_rect.width() / 2, + view_item_style_options.rect.y() + + view_item_style_options.rect.height() / 2 - + check_box_rect.height() / 2); + return QRect(check_box_point, check_box_rect.size()); +} + +QmitkDoseVisualStyleDelegate::QmitkDoseVisualStyleDelegate(QObject * /*parent*/) +{ +} + +void QmitkDoseVisualStyleDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const +{ + bool checkValue = index.data(Qt::DisplayRole).toBool(); + + QStyleOptionButton BtnStyle; + BtnStyle.state = QStyle::State_Enabled; + + if(checkValue) + { + BtnStyle.state |= QStyle::State_On; + } + else + { + BtnStyle.state |= QStyle::State_Off; + } + + BtnStyle.direction = QApplication::layoutDirection(); + BtnStyle.rect = CheckBoxRect(option); + QApplication::style()->drawControl(QStyle::CE_CheckBox,&BtnStyle,painter ); +} + +bool QmitkDoseVisualStyleDelegate::editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option, + const QModelIndex &index) +{ + Q_ASSERT(event); + Q_ASSERT(model); + + // make sure that the item is checkable + Qt::ItemFlags flags = model->flags(index); + if (!(flags & Qt::ItemIsEditable) || !(flags & Qt::ItemIsEnabled)) + { + return false; + } + + // make sure that we have the right event type + QMouseEvent* mouseEvent = dynamic_cast(event); + if (!mouseEvent) + { + return false; + } + else + { + if (mouseEvent->type() != QEvent::MouseButtonRelease || mouseEvent->button() != Qt::LeftButton) + { + return false; + } + } + + bool newState = !(index.data(Qt::EditRole).toBool()); + + return model->setData(index, QVariant(newState), Qt::EditRole); +}; diff --git a/Modules/RTUI/Qmitk/QmitkDoseVisualStyleDelegate.h b/Modules/RTUI/Qmitk/QmitkDoseVisualStyleDelegate.h new file mode 100644 index 0000000000..7032fd11d0 --- /dev/null +++ b/Modules/RTUI/Qmitk/QmitkDoseVisualStyleDelegate.h @@ -0,0 +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 "MitkRTUIExports.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.*/ +class MitkRTUI_EXPORT QmitkDoseVisualStyleDelegate : public QStyledItemDelegate +{ + Q_OBJECT + +public: + + QmitkDoseVisualStyleDelegate(QObject *parent = 0); + + void paint(QPainter *painter, const QStyleOptionViewItem &option + , const QModelIndex &index) const; + + 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 new file mode 100644 index 0000000000..0a313dbedd --- /dev/null +++ b/Modules/RTUI/Qmitk/QmitkFreeIsoDoseLevelWidget.cpp @@ -0,0 +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 (40.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::IsoDoseLevel* + QmitkFreeIsoDoseLevelWidget:: + getIsoDoseLevel() const +{ + return this->m_IsoDoseLevel; +}; + +void QmitkFreeIsoDoseLevelWidget:: + setReferenceDose(double newReferenceDose) +{ + if (newReferenceDose != m_ReferenceDose) + { + this->m_ReferenceDose = newReferenceDose; + this->update(); + } +}; + +void QmitkFreeIsoDoseLevelWidget:: + setIsoDoseLevel(mitk::IsoDoseLevel* level) +{ + if (level != m_IsoDoseLevel) + { + if(!level) + { + mitkThrow() << "Error. Cannot set iso dose level for widget to NULL pointer."; + } + + this->m_IsoDoseLevel = level; + this->update(); + } +} + +void QmitkFreeIsoDoseLevelWidget:: + OnRelValueChanged(double newValue) +{ + if(!m_InternalUpdate) + { + updateValue(newValue/100.0); + } +}; + +void QmitkFreeIsoDoseLevelWidget:: + OnAbsValueChanged(double newValue) +{ + if(!m_InternalUpdate) + { + updateValue(newValue/this->m_ReferenceDose); + } +}; + +void QmitkFreeIsoDoseLevelWidget:: + OnSliderChanged(int newValue) +{ + if(!m_InternalUpdate) + { + updateValue(newValue/100.0); + } +}; + +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; + + 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; + + emit ValueChanged(this->m_IsoDoseLevel,oldValue); +}; + +void QmitkFreeIsoDoseLevelWidget:: + update() +{ + updateValue(this->m_IsoDoseLevel->GetDoseValue()); + + 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); +}; diff --git a/Modules/RTUI/Qmitk/QmitkFreeIsoDoseLevelWidget.h b/Modules/RTUI/Qmitk/QmitkFreeIsoDoseLevelWidget.h new file mode 100644 index 0000000000..8973071578 --- /dev/null +++ b/Modules/RTUI/Qmitk/QmitkFreeIsoDoseLevelWidget.h @@ -0,0 +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 "MitkRTUIExports.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 MitkRTUI_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: + /** + * \brief Slot that can be used to set the reference dose. + */ + 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 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. + */ + 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/QmitkFreeIsoDoseLevelWidget.ui b/Modules/RTUI/Qmitk/QmitkFreeIsoDoseLevelWidget.ui new file mode 100644 index 0000000000..1f168c8044 --- /dev/null +++ b/Modules/RTUI/Qmitk/QmitkFreeIsoDoseLevelWidget.ui @@ -0,0 +1,201 @@ + + + QmitkFreeIsoDoseLevelWidget + + + + 0 + 0 + 395 + 32 + + + + Form + + + + 2 + + + + + + 0 + 0 + + + + + 40 + 16777215 + + + + Color of the iso dose level + + + + + + + + + + + 0 + 0 + + + + + 60 + 0 + + + + 150 + + + Qt::Horizontal + + + false + + + false + + + QSlider::NoTicks + + + 0 + + + + + + + + 0 + 0 + + + + + 50 + 0 + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + % + + + 9999.000000000000000 + + + 0.500000000000000 + + + + + + + = + + + + + + + + 0 + 0 + + + + + 50 + 0 + + + + Minimum dose value of this level. + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + Gy + + + 9999.000000000000000 + + + 0.500000000000000 + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + + 50 + 16777215 + + + + Show isoline for this dose level + + + Qt::LeftToRight + + + + + + + :/RTUI/eye_open.png + :/RTUI/eye_open.png + :/RTUI/eye_open.png:/RTUI/eye_open.png + + + + 24 + 16 + + + + false + + + + + + + + ctkColorPickerButton + QPushButton +
ctkColorPickerButton.h
+
+
+ + + + +
diff --git a/Modules/RTUI/Qmitk/QmitkIsoDoseLevelSetModel.cpp b/Modules/RTUI/Qmitk/QmitkIsoDoseLevelSetModel.cpp new file mode 100644 index 0000000000..18348d2073 --- /dev/null +++ b/Modules/RTUI/Qmitk/QmitkIsoDoseLevelSetModel.cpp @@ -0,0 +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 +#include + +#include "QmitkIsoDoseLevelSetModel.h" +#include "mitkRTUIConstants.h" + +QmitkIsoDoseLevelSetModel:: + QmitkIsoDoseLevelSetModel(QObject *parent) : +QAbstractTableModel(parent), m_referenceDose(mitk::RTUIConstants::DEFAULT_REFERENCE_DOSE_VALUE), m_showAbsoluteDose(false), m_visibilityEditOnly(false), m_modified(false) +{ + m_DoseSet = mitk::IsoDoseLevelSet::New(); +} + +void + QmitkIsoDoseLevelSetModel:: + setIsoDoseLevelSet(mitk::IsoDoseLevelSet *pSet) +{ + if (pSet) + { + emit beginResetModel(); + + m_DoseSet = pSet; + m_modified = false; + + emit endResetModel(); + } +}; + +int + QmitkIsoDoseLevelSetModel:: + rowCount(const QModelIndex &parent) const +{ + if(parent.isValid()) + { + return 0; + } + + return m_DoseSet->Size(); +} + +int + QmitkIsoDoseLevelSetModel:: + columnCount(const QModelIndex &parent) const +{ + if(parent.isValid()) + return 0; + + return 4; +} + +QVariant + QmitkIsoDoseLevelSetModel:: + data(const QModelIndex &index, int role) const +{ + if(!index.isValid()) + return QVariant(); + + QVariant result; + + if(index.row()Size()) + { + const mitk::IsoDoseLevel& level = m_DoseSet->GetIsoDoseLevel(static_cast(index.row())); + + 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) + { + 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; +} + +Qt::ItemFlags + 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 +{ + if( (Qt::DisplayRole == role) && + (Qt::Horizontal == orientation)) + { + 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(); +} + +bool + QmitkIsoDoseLevelSetModel:: + setData(const QModelIndex &index, const QVariant &value, int role) +{ + 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()) + { + 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(); + + m_DoseSet->DeleteIsoDoseLevel(static_cast(index.row())); + m_DoseSet->SetIsoDoseLevel(pNewLevel); + + m_modified = true; + + emit endResetModel(); + + return true; + } + + return false; +}; + +void QmitkIsoDoseLevelSetModel:: + setReferenceDose(double newReferenceDose) +{ + if (newReferenceDose<= 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) + { + mitk::IsoDoseLevel::Pointer pNewLevel = m_DoseSet->GetIsoDoseLevel(pos).Clone(); + pNewLevel->SetVisibleColorWash(activate); + m_DoseSet->SetIsoDoseLevel(pNewLevel); + } + + m_modified = true; + + emit endResetModel(); +} + +void QmitkIsoDoseLevelSetModel::invertVisibilityIsoLines() +{ + emit beginResetModel(); + + 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(); +} + +void QmitkIsoDoseLevelSetModel::invertVisibilityColorWash() +{ + emit beginResetModel(); + + 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(); +} + +void QmitkIsoDoseLevelSetModel::swapVisibility() +{ + emit beginResetModel(); + + 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(); +} + +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); + m_modified = true; + emit endResetModel(); +} + +void QmitkIsoDoseLevelSetModel::deleteLevel(const QModelIndex &index) +{ + if(!index.isValid() || (m_DoseSet->Size() <= index.row()) || (index.column()>3)) + { + return; + } + + emit beginResetModel(); + m_DoseSet->DeleteIsoDoseLevel(static_cast(index.row())); + 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 new file mode 100644 index 0000000000..0940072072 --- /dev/null +++ b/Modules/RTUI/Qmitk/QmitkIsoDoseLevelSetModel.h @@ -0,0 +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 "MitkRTUIExports.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 MitkRTUI_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); + + /**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/Modules/RTUI/files.cmake b/Modules/RTUI/files.cmake new file mode 100644 index 0000000000..d49a968f4c --- /dev/null +++ b/Modules/RTUI/files.cmake @@ -0,0 +1,27 @@ +set(CPP_FILES + Qmitk/QmitkFreeIsoDoseLevelWidget.cpp + Qmitk/QmitkIsoDoseLevelSetModel.cpp + Qmitk/QmitkDoseColorDelegate.cpp + Qmitk/QmitkDoseValueDelegate.cpp + Qmitk/QmitkDoseVisualStyleDelegate.cpp + Helper/mitkRTUIConstants.cpp + Helper/mitkIsoLevelsGenerator.cpp +) + +set(UI_FILES + Qmitk/QmitkFreeIsoDoseLevelWidget.ui +) + +set(MOC_H_FILES + Qmitk/QmitkFreeIsoDoseLevelWidget.h + Qmitk/QmitkIsoDoseLevelSetModel.h + Qmitk/QmitkDoseColorDelegate.h + Qmitk/QmitkDoseValueDelegate.h + Qmitk/QmitkDoseVisualStyleDelegate.h +) + +set(QRC_FILES + resources/RTUI.qrc +) + + diff --git a/Modules/RTUI/resources/RTUI.qrc b/Modules/RTUI/resources/RTUI.qrc new file mode 100644 index 0000000000..174c9563ea --- /dev/null +++ b/Modules/RTUI/resources/RTUI.qrc @@ -0,0 +1,8 @@ + + + powerGreen.png + eye_close.png + eye_open.png + powerRed.png + + diff --git a/Modules/RTUI/resources/eye_close.png b/Modules/RTUI/resources/eye_close.png new file mode 100644 index 0000000000..9b82203c2a Binary files /dev/null and b/Modules/RTUI/resources/eye_close.png differ diff --git a/Modules/RTUI/resources/eye_open.png b/Modules/RTUI/resources/eye_open.png new file mode 100644 index 0000000000..a1c2bb9f35 Binary files /dev/null and b/Modules/RTUI/resources/eye_open.png differ diff --git a/Modules/RTUI/resources/powerGreen.png b/Modules/RTUI/resources/powerGreen.png new file mode 100644 index 0000000000..9e8e0903d9 Binary files /dev/null and b/Modules/RTUI/resources/powerGreen.png differ diff --git a/Modules/RTUI/resources/powerRed.png b/Modules/RTUI/resources/powerRed.png new file mode 100644 index 0000000000..bb3f33bef5 Binary files /dev/null and b/Modules/RTUI/resources/powerRed.png differ