diff --git a/Modules/RTUI/Helper/mitkRTUIConstants.cpp b/Modules/RTUI/Helper/mitkRTUIConstants.cpp index fcb00705ef..a927b4f7a7 100644 --- a/Modules/RTUI/Helper/mitkRTUIConstants.cpp +++ b/Modules/RTUI/Helper/mitkRTUIConstants.cpp @@ -1,45 +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. ===================================================================*/ #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"; +const std::string mitk::RTCTKEventConstants::TOPIC_GLOBAL_VISIBILITY_CHANGED = "org/mitk/rt/dosevisualization/globalVis/CHANGED"; diff --git a/Modules/RTUI/Helper/mitkRTUIConstants.h b/Modules/RTUI/Helper/mitkRTUIConstants.h index db13c0ac0d..87fed4df09 100644 --- a/Modules/RTUI/Helper/mitkRTUIConstants.h +++ b/Modules/RTUI/Helper/mitkRTUIConstants.h @@ -1,83 +1,84 @@ /*=================================================================== 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; + static const std::string TOPIC_GLOBAL_VISIBILITY_CHANGED; }; } #endif diff --git a/Plugins/org.mitk.gui.qt.dosevisualization/src/internal/DoseVisualizationPreferencePage.cpp b/Plugins/org.mitk.gui.qt.dosevisualization/src/internal/DoseVisualizationPreferencePage.cpp index 08b0037f13..c0e7e11274 100644 --- a/Plugins/org.mitk.gui.qt.dosevisualization/src/internal/DoseVisualizationPreferencePage.cpp +++ b/Plugins/org.mitk.gui.qt.dosevisualization/src/internal/DoseVisualizationPreferencePage.cpp @@ -1,378 +1,391 @@ /*=================================================================== 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_dosevisualization_Activator.h" DoseVisualizationPreferencePage::DoseVisualizationPreferencePage() - : m_MainControl(0), m_Controls(0), m_referenceDoseChanged(false), m_presetMapChanged(false) + : m_MainControl(0), m_Controls(0), m_referenceDoseChanged(false), m_presetMapChanged(false), m_globalVisChanged(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* prefService = berry::Platform::GetPreferencesService(); m_DoseVisNode = prefService->GetSystemPreferences()->Node(mitk::RTUIConstants::ROOT_DOSE_VIS_PREFERENCE_NODE_ID.c_str()); m_LevelSetModel = new QmitkIsoDoseLevelSetModel(this); m_DoseColorDelegate = new QmitkDoseColorDelegate(this); m_DoseValueDelegate = new QmitkDoseValueDelegate(this); m_DoseVisualDelegate = new QmitkDoseVisualStyleDelegate(this); m_MainControl = new QWidget(parent); m_Controls = new Ui::DoseVisualizationPreferencePageControls; m_Controls->setupUi( m_MainControl ); 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))); + connect(m_Controls->checkGlobalVisColorWash, SIGNAL(toggled(bool)), this, SLOT(OnGlobalVisChanged(bool))); + connect(m_Controls->checkGlobalVisIsoLine, SIGNAL(toggled(bool)), this, SLOT(OnGlobalVisChanged(bool))); this->Update(); } QWidget* DoseVisualizationPreferencePage::GetQtControl() const { return m_MainControl; } bool DoseVisualizationPreferencePage::PerformOk() { m_DoseVisNode->PutBool(mitk::RTUIConstants::DOSE_DISPLAY_ABSOLUTE_ID.c_str(),m_Controls->radioAbsDose->isChecked()); m_DoseVisNode->PutBool(mitk::RTUIConstants::GLOBAL_VISIBILITY_COLORWASH_ID.c_str(),m_Controls->checkGlobalVisColorWash->isChecked()); m_DoseVisNode->PutBool(mitk::RTUIConstants::GLOBAL_VISIBILITY_ISOLINES_ID.c_str(),m_Controls->checkGlobalVisIsoLine->isChecked()); m_DoseVisNode->PutDouble(mitk::RTUIConstants::REFERENCE_DOSE_ID.c_str(),m_Controls->spinReferenceDose->value()); m_DoseVisNode->PutBool(mitk::RTUIConstants::GLOBAL_REFERENCE_DOSE_SYNC_ID.c_str(), m_Controls->checkGlobalSync->isChecked()); mitk::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::SetSelectedPresetName(this->m_Presets.begin()->first); } if (this->m_LevelSetModel->isModified()) { this->m_presetMapChanged = true; } if (m_referenceDoseChanged) { mitk::SignalReferenceDoseChange(m_Controls->checkGlobalSync->isChecked(), m_Controls->spinReferenceDose->value(), mitk::org_mitk_gui_qt_dosevisualization_Activator::GetContext()); } if (m_presetMapChanged) { mitk::SignalPresetMapChange(mitk::org_mitk_gui_qt_dosevisualization_Activator::GetContext()); } + if(m_globalVisChanged) + { + mitk::SignalGlobalVisChange(m_Controls->checkGlobalSync->isChecked(), m_Controls->checkGlobalVisIsoLine->isChecked(), m_Controls->checkGlobalVisColorWash->isChecked(), mitk::org_mitk_gui_qt_dosevisualization_Activator::GetContext()); + } + return true; } void DoseVisualizationPreferencePage::PerformCancel() { } void DoseVisualizationPreferencePage::Update() { m_Controls->checkGlobalVisColorWash->setChecked(m_DoseVisNode->GetBool(mitk::RTUIConstants::GLOBAL_VISIBILITY_COLORWASH_ID.c_str(), true)); m_Controls->checkGlobalVisIsoLine->setChecked(m_DoseVisNode->GetBool(mitk::RTUIConstants::GLOBAL_VISIBILITY_ISOLINES_ID.c_str(), true)); m_Controls->radioAbsDose->setChecked(m_DoseVisNode->GetBool(mitk::RTUIConstants::DOSE_DISPLAY_ABSOLUTE_ID.c_str(), true)); m_Controls->radioRelDose->setChecked(!(m_DoseVisNode->GetBool(mitk::RTUIConstants::DOSE_DISPLAY_ABSOLUTE_ID.c_str(), false))); m_Controls->spinReferenceDose->setValue(m_DoseVisNode->GetDouble(mitk::RTUIConstants::REFERENCE_DOSE_ID.c_str(), mitk::RTUIConstants::DEFAULT_REFERENCE_DOSE_VALUE)); m_Controls->checkGlobalSync->setChecked(m_DoseVisNode->GetBool(mitk::RTUIConstants::GLOBAL_REFERENCE_DOSE_SYNC_ID.c_str(), true)); m_referenceDoseChanged = false; m_presetMapChanged = false; + m_globalVisChanged = false; this->m_Presets = mitk::LoadPresetsMap(); if(m_Presets.empty()) return; this->m_selectedPresetName = mitk::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(); 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); } 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)); } 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; } mitk::IsoDoseLevelSet::Pointer newSet = mitk::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::GeneratIsoLevels_Virtuos(); m_Presets.clear(); m_Presets.insert(std::make_pair("Virtuos",newSet)); 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; -}; +} + +void DoseVisualizationPreferencePage::OnGlobalVisChanged(bool vis) +{ + this->m_globalVisChanged = true; +} diff --git a/Plugins/org.mitk.gui.qt.dosevisualization/src/internal/DoseVisualizationPreferencePage.h b/Plugins/org.mitk.gui.qt.dosevisualization/src/internal/DoseVisualizationPreferencePage.h index e2835ecc14..60489483e8 100644 --- a/Plugins/org.mitk.gui.qt.dosevisualization/src/internal/DoseVisualizationPreferencePage.h +++ b/Plugins/org.mitk.gui.qt.dosevisualization/src/internal/DoseVisualizationPreferencePage.h @@ -1,123 +1,125 @@ /*=================================================================== 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 : public QObject, public berry::IQtPreferencePage { Q_OBJECT Q_INTERFACES(berry::IPreferencePage) public: DoseVisualizationPreferencePage(); ~DoseVisualizationPreferencePage(); /** * \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. */ void CreateQtControl(QWidget* widget); /** * \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 */ virtual bool PerformOk(); /** * \see IPreferencePage::PerformCancel */ virtual void PerformCancel(); /** * \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); + void OnGlobalVisChanged(bool vis); 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::PresetMapType PresetMapType; PresetMapType m_Presets; std::string m_selectedPresetName; bool m_referenceDoseChanged; bool m_presetMapChanged; + bool m_globalVisChanged; QmitkIsoDoseLevelSetModel* m_LevelSetModel; QmitkDoseColorDelegate* m_DoseColorDelegate; QmitkDoseValueDelegate* m_DoseValueDelegate; QmitkDoseVisualStyleDelegate* m_DoseVisualDelegate; }; #endif diff --git a/Plugins/org.mitk.gui.qt.dosevisualization/src/internal/RTDoseVisualizer.cpp b/Plugins/org.mitk.gui.qt.dosevisualization/src/internal/RTDoseVisualizer.cpp index 70dea34897..c94a7b8391 100644 --- a/Plugins/org.mitk.gui.qt.dosevisualization/src/internal/RTDoseVisualizer.cpp +++ b/Plugins/org.mitk.gui.qt.dosevisualization/src/internal/RTDoseVisualizer.cpp @@ -1,688 +1,710 @@ /*=================================================================== 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 #include "org_mitk_gui_qt_dosevisualization_Activator.h" #include #include #include #include "QmitkRenderWindow.h" #include "vtkDecimatePro.h" const std::string RTDoseVisualizer::VIEW_ID = "org.mitk.views.rt.dosevisualization"; RTDoseVisualizer::RTDoseVisualizer() { m_selectedNode = NULL; m_selectedPresetName = ""; m_internalUpdate = false; m_PrescribedDose_Data = 0.0; m_freeIsoValuesCount = 0; } 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); this->m_Controls.btnRemoveFreeValue->setDisabled(true); 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())); connect(m_Controls.isoLevelSetView->model(), SIGNAL( modelReset()), this, SLOT(OnDataChangedInIsoLevelSetView())); ctkServiceReference ref = mitk::org_mitk_gui_qt_dosevisualization_Activator::GetContext()->getServiceReference(); ctkDictionary propsForSlot; if (ref) { ctkEventAdmin* eventAdmin = mitk::org_mitk_gui_qt_dosevisualization_Activator::GetContext()->getService(ref); propsForSlot[ctkEventConstants::EVENT_TOPIC] = mitk::RTCTKEventConstants::TOPIC_ISO_DOSE_LEVEL_PRESETS_CHANGED.c_str(); eventAdmin->subscribeSlot(this, SLOT(OnHandleCTKEventPresetsChanged(ctkEvent)), propsForSlot); propsForSlot[ctkEventConstants::EVENT_TOPIC] = mitk::RTCTKEventConstants::TOPIC_REFERENCE_DOSE_CHANGED.c_str(); eventAdmin->subscribeSlot(this, SLOT(OnHandleCTKEventReferenceDoseChanged(ctkEvent)), propsForSlot); + + propsForSlot[ctkEventConstants::EVENT_TOPIC] = mitk::RTCTKEventConstants::TOPIC_GLOBAL_VISIBILITY_CHANGED.c_str(); + eventAdmin->subscribeSlot(this, SLOT(OnHandleCTKEventGlobalVisChanged(ctkEvent)), propsForSlot); } this->UpdateBySelectedNode(); } void RTDoseVisualizer::OnReferenceDoseChanged(double value) { if (! m_internalUpdate) { mitk::DoseValueAbs referenceDose = 0.0; bool globalSync = mitk::GetReferenceDoseValue(referenceDose); if (globalSync) { mitk::SetReferenceDoseValue(globalSync, value); this->ActualizeReferenceDoseForAllDoseDataNodes(); } else { if (this->m_selectedNode.IsNotNull()) { this->m_selectedNode->SetFloatProperty(mitk::RTConstants::REFERENCE_DOSE_PROPERTY_NAME.c_str(), value); mitk::DataNode::Pointer isoDoseNode = this->GetIsoDoseNode(m_selectedNode); isoDoseNode->SetFloatProperty(mitk::RTConstants::REFERENCE_DOSE_PROPERTY_NAME.c_str(), value); } } if (this->m_selectedNode.IsNotNull()) { this->UpdateColorWashTransferFunction(); mitk::RenderingManager::GetInstance()->RequestUpdateAll(); } } } 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_freeIsoValuesCount*85)%360,255,255); mitk::IsoDoseLevel::ColorType mColor; mColor[0]=newColor.redF(); mColor[1]=newColor.greenF(); mColor[2]=newColor.blueF(); mitk::IsoDoseLevelVector::Pointer freeIsoDoseVector; mitk::IsoDoseLevelVectorProperty::Pointer propIsoVector; mitk::DataNode::Pointer isoDoseNode = this->GetIsoDoseNode(m_selectedNode); propIsoVector = dynamic_cast(isoDoseNode->GetProperty(mitk::RTConstants::DOSE_FREE_ISO_VALUES_PROPERTY_NAME.c_str())); freeIsoDoseVector = propIsoVector->GetValue(); if (freeIsoDoseVector.IsNull()) mitk::IsoDoseLevelVector::Pointer freeIsoDoseVector = mitk::IsoDoseLevelVector::New(); mitk::IsoDoseLevel::Pointer newLevel = mitk::IsoDoseLevel::New(0.5,mColor,true,false); freeIsoDoseVector->InsertElement(m_freeIsoValuesCount,newLevel); propIsoVector = mitk::IsoDoseLevelVectorProperty::New(freeIsoDoseVector); isoDoseNode->SetProperty(mitk::RTConstants::DOSE_FREE_ISO_VALUES_PROPERTY_NAME.c_str(),propIsoVector); m_freeIsoValuesCount++; this->m_Controls.btnRemoveFreeValue->setEnabled(true); //Update Widget this->UpdateFreeIsoValues(); //Update Rendering this->ActualizeFreeIsoLine(); } void RTDoseVisualizer::OnRemoveFreeValueClicked() { int index = this->m_Controls.listFreeValues->currentRow(); if (index > m_freeIsoValuesCount || index < 0) return; mitk::IsoDoseLevelVectorProperty::Pointer propfreeIsoVec; mitk::DataNode::Pointer isoDoseNode = this->GetIsoDoseNode(m_selectedNode); propfreeIsoVec = dynamic_cast(isoDoseNode->GetProperty(mitk::RTConstants::DOSE_FREE_ISO_VALUES_PROPERTY_NAME.c_str())); mitk::IsoDoseLevelVector::Pointer freeIsoDoseLevelVec = propfreeIsoVec->GetValue(); if(freeIsoDoseLevelVec->IndexExists(index)) { //freeIsoDoseLevelVec->DeleteIndex(index); freeIsoDoseLevelVec->erase(freeIsoDoseLevelVec->begin()+index); --m_freeIsoValuesCount; if(m_freeIsoValuesCount == 0) this->m_Controls.btnRemoveFreeValue->setEnabled(true); this->UpdateFreeIsoValues(); this->ActualizeFreeIsoLine(); } } void RTDoseVisualizer::OnUsePrescribedDoseClicked() { m_Controls.spinReferenceDose->setValue(this->m_PrescribedDose_Data); } void RTDoseVisualizer::OnDataChangedInIsoLevelSetView() { //colorwash visibility changed, update the colorwash this->UpdateColorWashTransferFunction(); if(m_selectedNode.IsNotNull()) { //Hack: This is a dirty hack to reinit the isodose contour node. Only if the node (or property) has changed the rendering process register the RequestUpdateAll //Only way to render the isoline by changes without a global reinit mitk::DataNode::Pointer isoDoseNode = this->GetIsoDoseNode(m_selectedNode); isoDoseNode->Modified(); // Reinit if visibility of colorwash or isodoselevel changed mitk::RenderingManager::GetInstance()->RequestUpdateAll(); } } 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(); mitk::DataNode::Pointer isoDoseNode = this->GetIsoDoseNode(m_selectedNode); mitk::IsoDoseLevelVectorProperty::Pointer propfreeIsoVec; propfreeIsoVec = dynamic_cast(isoDoseNode->GetProperty(mitk::RTConstants::DOSE_FREE_ISO_VALUES_PROPERTY_NAME.c_str())); mitk::IsoDoseLevelVector::Pointer freeIsoDoseLevelVec = propfreeIsoVec->GetValue(); for (mitk::IsoDoseLevelVector::Iterator pos = freeIsoDoseLevelVec->Begin(); pos != freeIsoDoseLevelVec->End(); ++pos) { QListWidgetItem* item = new QListWidgetItem; item->setSizeHint(QSize(0,25)); QmitkFreeIsoDoseLevelWidget* widget = new QmitkFreeIsoDoseLevelWidget; float pref; m_selectedNode->GetFloatProperty(mitk::RTConstants::REFERENCE_DOSE_PROPERTY_NAME.c_str(),pref); widget->setIsoDoseLevel(pos.Value()); widget->setReferenceDose(pref); connect(m_Controls.spinReferenceDose, SIGNAL(valueChanged(double)), widget, SLOT(setReferenceDose(double))); connect(widget,SIGNAL(ColorChanged(mitk::IsoDoseLevel*)), this, SLOT(ActualizeFreeIsoLine())); connect(widget,SIGNAL(ValueChanged(mitk::IsoDoseLevel*,mitk::DoseValueRel)), this, SLOT(ActualizeFreeIsoLine())); connect(widget,SIGNAL(VisualizationStyleChanged(mitk::IsoDoseLevel*)), this, SLOT(ActualizeFreeIsoLine())); this->m_Controls.listFreeValues->addItem(item); this->m_Controls.listFreeValues->setItemWidget(item,widget); } } void RTDoseVisualizer::ActualizeFreeIsoLine() { if(m_selectedNode.IsNotNull()) { //Hack: This is a dirty hack to reinit the isodose contour node. Only if the node (or property) has changed the rendering process register the RequestUpdateAll //Only way to render the isoline by changes without a global reinit mitk::DataNode::Pointer isoDoseNode = this->GetIsoDoseNode(m_selectedNode); isoDoseNode->Modified(); // Reinit if visibility of colorwash or isodoselevel changed mitk::RenderingManager::GetInstance()->RequestUpdateAll(); } } void RTDoseVisualizer::OnAbsDoseToggled(bool showAbs) { if (! m_internalUpdate) { mitk::SetDoseDisplayAbsolute(showAbs); this->ActualizeDisplayStyleForAllDoseDataNodes(); } } void RTDoseVisualizer::OnGlobalVisColorWashToggled(bool showColorWash) { if (m_selectedNode.IsNotNull()) { m_selectedNode->SetBoolProperty(mitk::RTConstants::DOSE_SHOW_COLORWASH_PROPERTY_NAME.c_str(), showColorWash); //The rendering mode could be set in the dose mapper: Refactoring! mitk::RenderingModeProperty::Pointer renderingMode = mitk::RenderingModeProperty::New(); if(showColorWash) renderingMode->SetValue(mitk::RenderingModeProperty::COLORTRANSFERFUNCTION_COLOR); else renderingMode->SetValue(mitk::RenderingModeProperty::LOOKUPTABLE_LEVELWINDOW_COLOR); m_selectedNode->SetProperty("Image Rendering.Mode", renderingMode); mitk::RenderingManager::GetInstance()->RequestUpdateAll(); } } void RTDoseVisualizer::OnGlobalVisIsoLineToggled(bool showIsoLines) { if (m_selectedNode.IsNotNull()) { mitk::DataNode::Pointer isoDoseNode = this->GetIsoDoseNode(m_selectedNode); isoDoseNode->SetBoolProperty(mitk::RTConstants::DOSE_SHOW_ISOLINES_PROPERTY_NAME.c_str(), showIsoLines); //toggle the visibility of the free isolevel sliders this->m_Controls.listFreeValues->setEnabled(showIsoLines); mitk::RenderingManager::GetInstance()->RequestUpdateAll(); } } void RTDoseVisualizer::UpdateColorWashTransferFunction() { //Generating the Colorwash vtkSmartPointer transferFunction = vtkSmartPointer::New(); if(m_selectedNode.IsNotNull()) { mitk::IsoDoseLevelSetProperty::Pointer propIsoSet = dynamic_cast(m_selectedNode->GetProperty(mitk::RTConstants::DOSE_ISO_LEVELS_PROPERTY_NAME.c_str())); mitk::IsoDoseLevelSet::Pointer isoDoseLevelSet = propIsoSet->GetValue(); float referenceDose; m_selectedNode->GetFloatProperty(mitk::RTConstants::REFERENCE_DOSE_PROPERTY_NAME.c_str(),referenceDose); mitk::TransferFunction::ControlPoints scalarOpacityPoints; scalarOpacityPoints.push_back( std::make_pair(0, 1 ) ); //Backgroud transferFunction->AddHSVPoint(((isoDoseLevelSet->Begin())->GetDoseValue()*referenceDose)-0.001,0,0,0,1.0,1.0); for(mitk::IsoDoseLevelSet::ConstIterator itIsoDoseLevel = isoDoseLevelSet->Begin(); itIsoDoseLevel != isoDoseLevelSet->End(); ++itIsoDoseLevel) { float *hsv = new float[3]; //used for transfer rgb to hsv vtkSmartPointer cCalc = vtkSmartPointer::New(); if(itIsoDoseLevel->GetVisibleColorWash()) { cCalc->RGBToHSV(itIsoDoseLevel->GetColor()[0],itIsoDoseLevel->GetColor()[1],itIsoDoseLevel->GetColor()[2],&hsv[0],&hsv[1],&hsv[2]); transferFunction->AddHSVPoint(itIsoDoseLevel->GetDoseValue()*referenceDose,hsv[0],hsv[1],hsv[2],1.0,1.0); } else { scalarOpacityPoints.push_back( std::make_pair(itIsoDoseLevel->GetDoseValue()*referenceDose, 1 ) ); } } mitk::TransferFunction::Pointer mitkTransFunc = mitk::TransferFunction::New(); mitk::TransferFunctionProperty::Pointer mitkTransFuncProp = mitk::TransferFunctionProperty::New(); mitkTransFunc->SetColorTransferFunction(transferFunction); mitkTransFunc->SetScalarOpacityPoints(scalarOpacityPoints); mitkTransFuncProp->SetValue(mitkTransFunc); m_selectedNode->SetProperty("Image Rendering.Transfer Function", mitkTransFuncProp); } } 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::RTConstants::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()); m_Controls.checkGlobalVisColorWash->setEnabled(m_selectedNode.IsNotNull()); m_Controls.checkGlobalVisIsoLine->setEnabled(m_selectedNode.IsNotNull()); m_Controls.isoLevelSetView->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")); } else { //dose specific information int fracCount = 1; m_selectedNode->GetIntProperty(mitk::RTConstants::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::RTConstants::PRESCRIBED_DOSE_PROPERTY_NAME.c_str(),tmp); m_PrescribedDose_Data = (double)tmp; m_Controls.prescribedDoseSpecific->setText(QString::number(m_PrescribedDose_Data)); //free iso lines mitk::DataNode::Pointer isoDoseNode = this->GetIsoDoseNode(m_selectedNode); mitk::IsoDoseLevelVectorProperty::Pointer propIsoVector; propIsoVector = dynamic_cast(isoDoseNode->GetProperty(mitk::RTConstants::DOSE_FREE_ISO_VALUES_PROPERTY_NAME.c_str())); if (propIsoVector.IsNull()) { mitk::IsoDoseLevelVector::Pointer freeIsoValues = mitk::IsoDoseLevelVector::New(); propIsoVector = mitk::IsoDoseLevelVectorProperty::New(freeIsoValues); isoDoseNode->SetProperty(mitk::RTConstants::DOSE_FREE_ISO_VALUES_PROPERTY_NAME.c_str(),propIsoVector); } UpdateFreeIsoValues(); //global dose issues //ATM the IsoDoseContours have an own (helper) node which is a child of dose node; Will be fixed with the doseMapper refactoring - bool showIsoLine = false; - - isoDoseNode->GetBoolProperty(mitk::RTConstants::DOSE_SHOW_ISOLINES_PROPERTY_NAME.c_str(),showIsoLine); - + bool showIsoLine = mitk::GetGlobalIsolineVis(); + isoDoseNode->SetBoolProperty(mitk::RTConstants::DOSE_SHOW_ISOLINES_PROPERTY_NAME.c_str(),showIsoLine); m_Controls.checkGlobalVisIsoLine->setChecked(showIsoLine); - bool showColorWash = false; - m_selectedNode->GetBoolProperty(mitk::RTConstants::DOSE_SHOW_COLORWASH_PROPERTY_NAME.c_str(),showColorWash); + //toggle the visibility of the free isolevel sliders + this->m_Controls.listFreeValues->setEnabled(showIsoLine); + + bool showColorWash = mitk::GetGlobalColorwashVis(); + m_selectedNode->SetBoolProperty(mitk::RTConstants::DOSE_SHOW_COLORWASH_PROPERTY_NAME.c_str(),showColorWash); m_Controls.checkGlobalVisColorWash->setChecked(showColorWash); + mitk::RenderingModeProperty::Pointer renderingMode = mitk::RenderingModeProperty::New(); + if(showColorWash) + renderingMode->SetValue(mitk::RenderingModeProperty::COLORTRANSFERFUNCTION_COLOR); + else + renderingMode->SetValue(mitk::RenderingModeProperty::LOOKUPTABLE_LEVELWINDOW_COLOR); + m_selectedNode->SetProperty("Image Rendering.Mode", renderingMode); + +// -> Handled by the DoseVisPreferenceHelper::GetGlobalIsolineVis and GetGlobalColorwashVis + float referenceDose = 0.0; m_selectedNode->GetFloatProperty(mitk::RTConstants::REFERENCE_DOSE_PROPERTY_NAME.c_str(),referenceDose); m_Controls.spinReferenceDose->setValue(referenceDose); mitk::IsoDoseLevelSetProperty::Pointer propIsoSet = dynamic_cast(m_selectedNode->GetProperty(mitk::RTConstants::DOSE_ISO_LEVELS_PROPERTY_NAME.c_str())); if (propIsoSet) { this->m_LevelSetModel->setIsoDoseLevelSet(propIsoSet->GetValue()); } } } void RTDoseVisualizer::NodeRemoved(const mitk::DataNode* node) { mitk::DataStorage::SetOfObjects::ConstPointer childNodes = this->GetDataStorage()->GetDerivations(node); mitk::DataStorage::SetOfObjects::const_iterator iterChildNodes = childNodes->begin(); while (iterChildNodes != childNodes->end()) { this->GetDataStorage()->Remove((*iterChildNodes)); ++iterChildNodes; } } void RTDoseVisualizer::NodeChanged(const mitk::DataNode *node) { bool isdose = false; if(node->GetBoolProperty(mitk::RTConstants::DOSE_PROPERTY_NAME.c_str(),isdose) && isdose) { bool isvisible = true; if(node->GetBoolProperty("visible", isvisible)) { mitk::DataStorage::SetOfObjects::ConstPointer childNodes = this->GetDataStorage()->GetDerivations(node); mitk::DataStorage::SetOfObjects::const_iterator iterChildNodes = childNodes->begin(); while (iterChildNodes != childNodes->end()) { (*iterChildNodes)->SetVisibility(isvisible); ++iterChildNodes; } } } } void RTDoseVisualizer::UpdateByPreferences() { m_Presets = mitk::LoadPresetsMap(); m_internalUpdate = true; m_Controls.comboPresets->clear(); this->m_selectedPresetName = mitk::GetSelectedPresetName(); + m_Controls.checkGlobalVisIsoLine->setChecked(mitk::GetGlobalIsolineVis()); + m_Controls.checkGlobalVisColorWash->setChecked(mitk::GetGlobalColorwashVis()); + if(m_Presets.empty()) return; int index = 0; int selectedIndex = -1; for (mitk::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::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_LevelSetModel->setIsoDoseLevelSet(this->m_Presets[this->m_selectedPresetName]); mitk::DoseValueAbs referenceDose = 0.0; bool globalSync = mitk::GetReferenceDoseValue(referenceDose); if (globalSync || this->m_selectedNode.IsNull()) { m_Controls.spinReferenceDose->setValue(referenceDose); } bool displayAbsoluteDose = mitk::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::SetSelectedPresetName(presetName.toStdString()); this->UpdateByPreferences(); this->ActualizeIsoLevelsForAllDoseDataNodes(); this->UpdateBySelectedNode(); } } void RTDoseVisualizer::ActualizeIsoLevelsForAllDoseDataNodes() { std::string presetName = mitk::GetSelectedPresetName(); mitk::PresetMapType presetMap = mitk::LoadPresetsMap(); mitk::NodePredicateProperty::Pointer isDoseNode = mitk::NodePredicateProperty::New(mitk::RTConstants::DOSE_PROPERTY_NAME.c_str(), mitk::BoolProperty::New(true)); mitk::DataStorage::SetOfObjects::ConstPointer nodes = this->GetDataStorage()->GetSubset(isDoseNode); if(presetMap.empty()) return; 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::RTConstants::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::GetReferenceDoseValue(value); if (sync) { mitk::NodePredicateProperty::Pointer isDoseNode = mitk::NodePredicateProperty::New(mitk::RTConstants::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::RTConstants::REFERENCE_DOSE_PROPERTY_NAME.c_str(), value); //ATM the IsoDoseContours have an own (helper) node which is a child of dose node; Will be fixed with the doseMapper refactoring mitk::DataStorage::SetOfObjects::ConstPointer childNodes = this->GetDataStorage()->GetDerivations(*pos); mitk::DataStorage::SetOfObjects::const_iterator iterChildNodes = childNodes->begin(); while (iterChildNodes != childNodes->end()) { (*iterChildNodes)->SetFloatProperty(mitk::RTConstants::REFERENCE_DOSE_PROPERTY_NAME.c_str(), value); ++iterChildNodes; } } } } 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::GetReferenceDoseValue(referenceDose); this->m_Controls.spinReferenceDose->setValue(referenceDose); } +void RTDoseVisualizer::OnHandleCTKEventGlobalVisChanged(const ctkEvent& event) +{ + this->m_Controls.checkGlobalVisIsoLine->setChecked(mitk::GetGlobalIsolineVis()); + this->m_Controls.checkGlobalVisColorWash->setChecked(mitk::GetGlobalColorwashVis()); +} + void RTDoseVisualizer::OnHandleCTKEventPresetsChanged(const ctkEvent& event) { std::string currentPresetName = mitk::GetSelectedPresetName(); this->OnCurrentPresetChanged(QString::fromStdString(currentPresetName)); } //ATM the IsoDoseContours have an own (helper) node which is a child of dose node; Will be fixed with the doseMapper refactoring mitk::DataNode::Pointer RTDoseVisualizer::GetIsoDoseNode(mitk::DataNode::Pointer doseNode) { mitk::DataStorage::SetOfObjects::ConstPointer childNodes = this->GetDataStorage()->GetDerivations(doseNode); return doseNode = (*childNodes->begin()); } diff --git a/Plugins/org.mitk.gui.qt.dosevisualization/src/internal/RTDoseVisualizer.h b/Plugins/org.mitk.gui.qt.dosevisualization/src/internal/RTDoseVisualizer.h index eb78abdb21..feb2b25bf4 100644 --- a/Plugins/org.mitk.gui.qt.dosevisualization/src/internal/RTDoseVisualizer.h +++ b/Plugins/org.mitk.gui.qt.dosevisualization/src/internal/RTDoseVisualizer.h @@ -1,166 +1,168 @@ /*=================================================================== 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 "ui_RTDoseVisualizerControls.h" #include #include #include "mitkDoseVisPreferenceHelper.h" // Shader #include #include #include #include #include #include #include #include /*forward declarations*/ class QmitkIsoDoseLevelSetModel; class QmitkDoseColorDelegate; class QmitkDoseValueDelegate; class QmitkDoseVisualStyleDelegate; class ctkEvent; /** \brief RTDoseVisualizer \warning This class is not yet documented. Use "git blame" and ask the author to provide basic documentation. \sa QmitkAbstractView \ingroup ${plugin_target}_internal */ class RTDoseVisualizer : public QmitkAbstractView { // this is needed for all Qt objects that should have a Qt meta-object // (everything that derives from QObject and wants to have signal/slots) Q_OBJECT public: RTDoseVisualizer(); virtual ~RTDoseVisualizer(); static const std::string VIEW_ID; void OnSliceChanged(itk::Object *sender, const itk::EventObject &e); protected slots: void OnAddFreeValueClicked(); void OnRemoveFreeValueClicked(); void OnUsePrescribedDoseClicked(); void OnDataChangedInIsoLevelSetView(); void OnAbsDoseToggled(bool); void OnGlobalVisColorWashToggled(bool); void OnGlobalVisIsoLineToggled(bool); void OnShowContextMenuIsoSet(const QPoint&); void OnCurrentPresetChanged(const QString&); void OnReferenceDoseChanged(double); void OnHandleCTKEventReferenceDoseChanged(const ctkEvent& event); void OnHandleCTKEventPresetsChanged(const ctkEvent& event); + void OnHandleCTKEventGlobalVisChanged(const ctkEvent& event); + void ActualizeFreeIsoLine(); protected: virtual void CreateQtPartControl(QWidget *parent); virtual void SetFocus(); /// \brief called by QmitkFunctionality when DataManager's selection has changed virtual void OnSelectionChanged( berry::IWorkbenchPart::Pointer source, const QList& nodes ); /** Update the transfer funtion property for the color wash*/ void UpdateColorWashTransferFunction(); /** Method updates the list widget according to the current free iso values.*/ void UpdateFreeIsoValues(); /** Update the members according to the currently selected node */ void UpdateBySelectedNode(); /** Update the member widgets according to the information stored in the application preferences*/ void UpdateByPreferences(); /**helper function that iterates throug all data nodes and sets there iso level set property according to the selected preset. @TODO: should be moved outside the class, to be available for other classes at well.*/ void ActualizeIsoLevelsForAllDoseDataNodes(); /**helper function that iterates throug all data nodes and sets there reference dose value according to the preference. @TODO: should be moved outside the class, to be available for other classes at well.*/ void ActualizeReferenceDoseForAllDoseDataNodes(); /**helper function that iterates through all data nodes and sets there dose display style (relative/absolute) according to the preference. @TODO: should be moved outside the class, to be available for other classes at well.*/ void ActualizeDisplayStyleForAllDoseDataNodes(); void NodeRemoved(const mitk::DataNode* node) override; void NodeChanged(const mitk::DataNode *node) override; Ui::RTDoseVisualizerControls m_Controls; mitk::DataNode::Pointer m_selectedNode; unsigned int m_freeIsoValuesCount; mitk::PresetMapType m_Presets; std::string m_selectedPresetName; /** Prescribed Dose of the selected data.*/ mitk::DoseValueAbs m_PrescribedDose_Data; QmitkIsoDoseLevelSetModel* m_LevelSetModel; QmitkDoseColorDelegate* m_DoseColorDelegate; QmitkDoseValueDelegate* m_DoseValueDelegate; QmitkDoseVisualStyleDelegate* m_DoseVisualDelegate; bool m_internalUpdate; private: mitk::DataNode::Pointer GetIsoDoseNode(mitk::DataNode::Pointer doseNode); }; #endif // RTDoseVisualizer_h diff --git a/Plugins/org.mitk.gui.qt.dosevisualization/src/internal/mitkDoseVisPreferenceHelper.cpp b/Plugins/org.mitk.gui.qt.dosevisualization/src/internal/mitkDoseVisPreferenceHelper.cpp index f5a80a611b..1c81bd7724 100644 --- a/Plugins/org.mitk.gui.qt.dosevisualization/src/internal/mitkDoseVisPreferenceHelper.cpp +++ b/Plugins/org.mitk.gui.qt.dosevisualization/src/internal/mitkDoseVisPreferenceHelper.cpp @@ -1,248 +1,285 @@ /*=================================================================== 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::StorePresetsMap(const PresetMapType& presetMap) { berry::IPreferencesService* prefService = berry::Platform::GetPreferencesService(); berry::IPreferences::Pointer doseVisNode = prefService->GetSystemPreferences()->Node(mitk::RTUIConstants::ROOT_DOSE_VIS_PREFERENCE_NODE_ID.c_str()); // berry::IPreferences::Pointer presetsNode = doseVisNode->Node(mitk::RTUIConstants::ROOT_ISO_PRESETS_PREFERENCE_NODE_ID.c_str()); berry::IPreferences::Pointer presetsNode = doseVisNode->Node("isoPresets"); presetsNode->RemoveNode(); doseVisNode->Flush(); //new empty preset node // presetsNode = doseVisNode->Node(mitk::RTUIConstants::ROOT_ISO_PRESETS_PREFERENCE_NODE_ID.c_str()); presetsNode = doseVisNode->Node("isoPresets"); //store map in new node for (PresetMapType::const_iterator pos = presetMap.begin(); pos != presetMap.end(); ++pos) { berry::IPreferences::Pointer aPresetNode = presetsNode->Node(pos->first.c_str()); 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(QString::fromStdString(stream.str())); levelNode->PutDouble(mitk::RTUIConstants::ISO_LEVEL_DOSE_VALUE_ID.c_str(),levelPos->GetDoseValue()); levelNode->PutFloat(mitk::RTUIConstants::ISO_LEVEL_COLOR_RED_ID.c_str(),levelPos->GetColor().GetRed()); levelNode->PutFloat(mitk::RTUIConstants::ISO_LEVEL_COLOR_GREEN_ID.c_str(),levelPos->GetColor().GetGreen()); levelNode->PutFloat(mitk::RTUIConstants::ISO_LEVEL_COLOR_BLUE_ID.c_str(),levelPos->GetColor().GetBlue()); levelNode->PutBool(mitk::RTUIConstants::ISO_LEVEL_VISIBILITY_ISOLINES_ID.c_str(),levelPos->GetVisibleIsoLine()); levelNode->PutBool(mitk::RTUIConstants::ISO_LEVEL_VISIBILITY_COLORWASH_ID.c_str(),levelPos->GetVisibleColorWash()); levelNode->Flush(); } aPresetNode->Flush(); } presetsNode->Flush(); } +bool mitk::GetGlobalIsolineVis() +{ + berry::IPreferencesService* prefService = berry::Platform::GetPreferencesService(); + + berry::IPreferences::Pointer glIsolineVisNode = prefService->GetSystemPreferences()->Node(mitk::RTUIConstants::ROOT_DOSE_VIS_PREFERENCE_NODE_ID.c_str()); + + bool vis = glIsolineVisNode->GetBool(mitk::RTUIConstants::GLOBAL_VISIBILITY_ISOLINES_ID.c_str(),false); + + return vis; +} + +bool mitk::GetGlobalColorwashVis() +{ + berry::IPreferencesService* prefService = berry::Platform::GetPreferencesService(); + + berry::IPreferences::Pointer glDoseVisNode = prefService->GetSystemPreferences()->Node(mitk::RTUIConstants::ROOT_DOSE_VIS_PREFERENCE_NODE_ID.c_str()); + + bool vis = glDoseVisNode->GetBool(mitk::RTUIConstants::GLOBAL_VISIBILITY_COLORWASH_ID.c_str(),false); + + return vis; +} + mitk::PresetMapType mitk::LoadPresetsMap() { berry::IPreferencesService* prefService = berry::Platform::GetPreferencesService(); berry::IPreferences::Pointer presetsNode = prefService->GetSystemPreferences()->Node(mitk::RTUIConstants::ROOT_ISO_PRESETS_PREFERENCE_NODE_ID.c_str()); typedef QStringList NamesType; NamesType names = presetsNode->ChildrenNames(); PresetMapType presetMap; if(!names.empty()){ 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 find preset node under given name. Name: "<<(*pos).toStdString(); } 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 find level node under given preset name. Name: "<<(*pos).toStdString()<<"; Level id: "<<(*levelName).toStdString(); } mitk::IsoDoseLevel::Pointer isoLevel = mitk::IsoDoseLevel::New(); isoLevel->SetDoseValue(levelNode->GetDouble(mitk::RTUIConstants::ISO_LEVEL_DOSE_VALUE_ID.c_str(),0.0)); mitk::IsoDoseLevel::ColorType color; color.SetRed(levelNode->GetFloat(mitk::RTUIConstants::ISO_LEVEL_COLOR_RED_ID.c_str(),1.0)); color.SetGreen(levelNode->GetFloat(mitk::RTUIConstants::ISO_LEVEL_COLOR_GREEN_ID.c_str(),1.0)); color.SetBlue(levelNode->GetFloat(mitk::RTUIConstants::ISO_LEVEL_COLOR_BLUE_ID.c_str(),1.0)); isoLevel->SetColor(color); isoLevel->SetVisibleIsoLine(levelNode->GetBool(mitk::RTUIConstants::ISO_LEVEL_VISIBILITY_ISOLINES_ID.c_str(),true)); isoLevel->SetVisibleColorWash(levelNode->GetBool(mitk::RTUIConstants::ISO_LEVEL_VISIBILITY_COLORWASH_ID.c_str(),true)); levelSet->SetIsoDoseLevel(isoLevel); } presetMap.insert(std::make_pair((*pos).toStdString(),levelSet)); } } if (presetMap.size() == 0) { //if there are no presets use fallback and store it. presetMap = mitk::GenerateDefaultPresetsMap(); StorePresetsMap(presetMap); } return presetMap; } mitk::PresetMapType mitk::GenerateDefaultPresetsMap() { mitk::PresetMapType result; result.insert(std::make_pair(std::string("Virtuos"), mitk::GeneratIsoLevels_Virtuos())); return result; } std::string mitk::GetSelectedPresetName() { berry::IPreferencesService* prefService = berry::Platform::GetPreferencesService(); berry::IPreferences::Pointer prefNode = prefService->GetSystemPreferences()->Node(mitk::RTUIConstants::ROOT_DOSE_VIS_PREFERENCE_NODE_ID.c_str()); QString result = prefNode->Get(mitk::RTUIConstants::SELECTED_ISO_PRESET_ID.c_str(), ""); return result.toStdString(); } void mitk::SetSelectedPresetName(const std::string& presetName) { berry::IPreferencesService* prefService = berry::Platform::GetPreferencesService(); berry::IPreferences::Pointer prefNode = prefService->GetSystemPreferences()->Node(mitk::RTUIConstants::ROOT_DOSE_VIS_PREFERENCE_NODE_ID.c_str()); berry::IPreferences::Pointer presetsNode = prefService->GetSystemPreferences()->Node(mitk::RTUIConstants::ROOT_ISO_PRESETS_PREFERENCE_NODE_ID.c_str()); typedef QStringList NamesType; typedef std::vector StdNamesType; NamesType presetNames = presetsNode->ChildrenNames(); StdNamesType stdPresetNames; for (NamesType::const_iterator pos = presetNames.begin(); pos != presetNames.end(); ++pos) { stdPresetNames.push_back((*pos).toStdString()); } StdNamesType::iterator finding = std::find(stdPresetNames.begin(),stdPresetNames.end(),presetName); if (finding == stdPresetNames.end()) { mitkThrow()<< "Error. Tried to set invalid selected preset name. Preset name does not exist in the defined presets. Preset name: "<Put(mitk::RTUIConstants::SELECTED_ISO_PRESET_ID.c_str(),presetName.c_str()); } bool mitk::GetReferenceDoseValue(mitk::DoseValueAbs& value) { berry::IPreferencesService* prefService = berry::Platform::GetPreferencesService(); berry::IPreferences::Pointer prefNode = prefService->GetSystemPreferences()->Node(mitk::RTUIConstants::ROOT_DOSE_VIS_PREFERENCE_NODE_ID.c_str()); bool result = prefNode->GetBool(mitk::RTUIConstants::GLOBAL_REFERENCE_DOSE_SYNC_ID.c_str(), true); value = prefNode->GetDouble(mitk::RTUIConstants::REFERENCE_DOSE_ID.c_str(), mitk::RTUIConstants::DEFAULT_REFERENCE_DOSE_VALUE); return result; } void mitk::SetReferenceDoseValue(bool globalSync, mitk::DoseValueAbs value) { berry::IPreferencesService* prefService = berry::Platform::GetPreferencesService(); berry::IPreferences::Pointer prefNode = prefService->GetSystemPreferences()->Node(mitk::RTUIConstants::ROOT_DOSE_VIS_PREFERENCE_NODE_ID.c_str()); prefNode->PutBool(mitk::RTUIConstants::GLOBAL_REFERENCE_DOSE_SYNC_ID.c_str(), globalSync); if (value >= 0) { prefNode->PutDouble(mitk::RTUIConstants::REFERENCE_DOSE_ID.c_str(), value); } } bool mitk::GetDoseDisplayAbsolute() { berry::IPreferencesService* prefService = berry::Platform::GetPreferencesService(); berry::IPreferences::Pointer prefNode = prefService->GetSystemPreferences()->Node(mitk::RTUIConstants::ROOT_DOSE_VIS_PREFERENCE_NODE_ID.c_str()); bool result = prefNode->GetBool(mitk::RTUIConstants::DOSE_DISPLAY_ABSOLUTE_ID.c_str(), false); return result; } void mitk::SetDoseDisplayAbsolute(bool isAbsolute) { berry::IPreferencesService* prefService = berry::Platform::GetPreferencesService(); berry::IPreferences::Pointer prefNode = prefService->GetSystemPreferences()->Node(mitk::RTUIConstants::ROOT_DOSE_VIS_PREFERENCE_NODE_ID.c_str()); prefNode->PutBool(mitk::RTUIConstants::DOSE_DISPLAY_ABSOLUTE_ID.c_str(), isAbsolute); } void mitk::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::RTCTKEventConstants::TOPIC_REFERENCE_DOSE_CHANGED.c_str()); eventAdmin->sendEvent(presetMapChangedEvent); } } +void mitk::SignalGlobalVisChange(bool globalSync, bool isolineVis, bool colorwashVis, ctkPluginContext *context) +{ + ctkServiceReference ref = context->getServiceReference(); + if (ref) + { + ctkEventAdmin* eventAdmin = context->getService(ref); + ctkProperties props; + props["globalIsolineVis"] = isolineVis; + props["globalColorwashVis"] = colorwashVis; + props["globalSync"] = globalSync; + ctkEvent presetMapChangedEvent(mitk::RTCTKEventConstants::TOPIC_GLOBAL_VISIBILITY_CHANGED.c_str()); + eventAdmin->sendEvent(presetMapChangedEvent); + } +} + void mitk::SignalPresetMapChange(ctkPluginContext* context) { ctkServiceReference ref = context->getServiceReference(); if (ref) { ctkEventAdmin* eventAdmin = context->getService(ref); ctkEvent presetMapChangedEvent(mitk::RTCTKEventConstants::TOPIC_ISO_DOSE_LEVEL_PRESETS_CHANGED.c_str()); eventAdmin->sendEvent(presetMapChangedEvent); } } diff --git a/Plugins/org.mitk.gui.qt.dosevisualization/src/internal/mitkDoseVisPreferenceHelper.h b/Plugins/org.mitk.gui.qt.dosevisualization/src/internal/mitkDoseVisPreferenceHelper.h index 6f5a9d8eed..a5416bdb44 100644 --- a/Plugins/org.mitk.gui.qt.dosevisualization/src/internal/mitkDoseVisPreferenceHelper.h +++ b/Plugins/org.mitk.gui.qt.dosevisualization/src/internal/mitkDoseVisPreferenceHelper.h @@ -1,70 +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 { 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. @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(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.*/ void SetReferenceDoseValue(bool globalSync, DoseValueAbs value = -1); bool GetDoseDisplayAbsolute(); void SetDoseDisplayAbsolute(bool isAbsolute); + bool GetGlobalIsolineVis(); + bool GetGlobalColorwashVis(); + void SignalReferenceDoseChange(bool globalSync, mitk::DoseValueAbs value, ctkPluginContext* context); void SignalPresetMapChange(ctkPluginContext* context); + void SignalGlobalVisChange(bool globalSync, bool isolineVis, bool colorwashVis, ctkPluginContext* context); } #endif