Provides a contextmenu for Level/Window functionality. Either creates a new contextmenu with standard functions or adds Level/Window standard functions to an predefined contextmenu. More...
#include <QmitkLevelWindowWidgetContextMenu.h>
Public Member Functions | |
QmitkLevelWindowWidgetContextMenu (QWidget *parent, Qt::WindowFlags f=0) | |
constructor | |
virtual | ~QmitkLevelWindowWidgetContextMenu () |
void | getContextMenu (QMenu *contextmenu) |
void | getContextMenu () |
returns the contextmenu with standard functions for Level/Window | |
void | setLevelWindowManager (mitk::LevelWindowManager *levelWindowManager) |
lets this object know about the LevelWindowManager to get all images and tell about changes | |
Public Attributes | |
mitk::LevelWindowPreset * | m_LevelWindowPreset |
mitk::LevelWindow | m_LevelWindow |
QMenu * | m_PresetSubmenu |
submenu with all presets for contextmenu | |
QMenu * | m_ImageSubmenu |
submenu with all images for contextmenu | |
mitk::LevelWindowManager * | m_Manager |
std::map< QAction *, mitk::LevelWindowProperty::Pointer > | m_Images |
Protected Slots | |
void | setPreset (QAction *presetAction) |
sets level and window value of the current image to the values defined for the selected preset | |
void | useAllGreyvaluesFromImage () |
calls the mitkLevelWindow SetAuto method with guessByCentralSlice false, so that the greyvalues from whole image will be considered | |
void | setFixed () |
sets the level window slider to be fixed | |
void | addPreset () |
adds a new Preset for presets-contextmenu | |
void | setDefaultLevelWindow () |
resets the current images Level/Window to its default values | |
void | setDefaultScaleRange () |
resets the current images scalerange to its default values | |
void | changeScaleRange () |
changes the current images scalerange | |
void | setImage (QAction *imageAction) |
sets the selected image or the topmost layer image to the new current image | |
void | setMaximumWindow () |
sets the window to its maximum Size to fit the scalerange | |
Protected Attributes | |
QAction * | m_PresetAction |
ID of preset selected in contextmenu. | |
QAction * | m_ImageAction |
ID of image selected in contextmenu. |
Provides a contextmenu for Level/Window functionality. Either creates a new contextmenu with standard functions or adds Level/Window standard functions to an predefined contextmenu.
Definition at line 33 of file QmitkLevelWindowWidgetContextMenu.h.
QmitkLevelWindowWidgetContextMenu::QmitkLevelWindowWidgetContextMenu | ( | QWidget * | parent, |
Qt::WindowFlags | f = 0 |
||
) |
constructor
Definition at line 24 of file QmitkLevelWindowWidgetContextMenu.cpp.
References mitk::LevelWindowPreset::LoadPreset(), m_LevelWindowPreset, and mitk::LevelWindowPreset::New().
: QWidget( parent, f ) { m_LevelWindowPreset = mitk::LevelWindowPreset::New(); m_LevelWindowPreset->LoadPreset(); }
QmitkLevelWindowWidgetContextMenu::~QmitkLevelWindowWidgetContextMenu | ( | ) | [virtual] |
Definition at line 31 of file QmitkLevelWindowWidgetContextMenu.cpp.
References m_LevelWindowPreset.
{ m_LevelWindowPreset->Delete(); }
void QmitkLevelWindowWidgetContextMenu::addPreset | ( | ) | [protected, slot] |
adds a new Preset for presets-contextmenu
Definition at line 82 of file QmitkLevelWindowWidgetContextMenu.cpp.
References mitk::LevelWindow::GetLevel(), QmitkLevelWindowPresetDefinitionDialog::getLevelPresets(), mitk::LevelWindowPreset::getLevelPresets(), mitk::LevelWindow::GetWindow(), QmitkLevelWindowPresetDefinitionDialog::getWindowPresets(), mitk::LevelWindowPreset::getWindowPresets(), m_LevelWindow, m_LevelWindowPreset, mitk::LevelWindowPreset::newPresets(), and QmitkLevelWindowPresetDefinitionDialog::setPresets().
Referenced by getContextMenu().
{ QmitkLevelWindowPresetDefinitionDialog addPreset(this); addPreset.setPresets(m_LevelWindowPreset->getLevelPresets(), m_LevelWindowPreset->getWindowPresets(), QString::number( (int) m_LevelWindow.GetLevel() ), QString::number( (int) m_LevelWindow.GetWindow() )); if(addPreset.exec()) { m_LevelWindowPreset->newPresets(addPreset.getLevelPresets(), addPreset.getWindowPresets()); } }
void QmitkLevelWindowWidgetContextMenu::changeScaleRange | ( | ) | [protected, slot] |
changes the current images scalerange
Definition at line 127 of file QmitkLevelWindowWidgetContextMenu.cpp.
References mitk::RenderingManager::GetInstance(), mitk::LevelWindow::GetLevel(), QmitkLevelWindowRangeChangeDialog::getLowerLimit(), mitk::LevelWindow::GetRangeMax(), mitk::LevelWindow::GetRangeMin(), QmitkLevelWindowRangeChangeDialog::getUpperLimit(), mitk::LevelWindow::GetWindow(), m_LevelWindow, m_Manager, mitk::LevelWindowManager::SetLevelWindow(), mitk::LevelWindow::SetLevelWindow(), QmitkLevelWindowRangeChangeDialog::setLowerLimit(), mitk::LevelWindow::SetRangeMinMax(), and QmitkLevelWindowRangeChangeDialog::setUpperLimit().
Referenced by getContextMenu().
{ QmitkLevelWindowRangeChangeDialog changeRange(this); changeRange.setLowerLimit((int)m_LevelWindow.GetRangeMin()); changeRange.setUpperLimit((int)m_LevelWindow.GetRangeMax()); if(changeRange.exec()) { m_LevelWindow.SetRangeMinMax(changeRange.getLowerLimit(), changeRange.getUpperLimit()); m_LevelWindow.SetLevelWindow(m_LevelWindow.GetLevel(), m_LevelWindow.GetWindow()); m_Manager->SetLevelWindow(m_LevelWindow); mitk::RenderingManager::GetInstance()->RequestUpdateAll(); } }
void QmitkLevelWindowWidgetContextMenu::getContextMenu | ( | ) |
returns the contextmenu with standard functions for Level/Window
Definition at line 232 of file QmitkLevelWindowWidgetContextMenu.cpp.
References addPreset(), changeScaleRange(), mitk::LevelWindowPreset::getLevelPresets(), mitk::LevelWindowManager::GetLevelWindow(), mitk::LevelWindowManager::GetLevelWindowProperty(), mitk::DataNode::GetName(), mitk::DataNode::GetProperty(), mitk::LevelWindowManager::GetRelevantNodes(), mitk::LevelWindowManager::isAutoTopMost(), mitk::LevelWindow::IsFixed(), m_ImageAction, m_Images, m_ImageSubmenu, m_LevelWindow, m_LevelWindowPreset, m_Manager, m_PresetAction, m_PresetSubmenu, setDefaultLevelWindow(), setDefaultScaleRange(), setFixed(), setImage(), setMaximumWindow(), setPreset(), and useAllGreyvaluesFromImage().
{ try { m_LevelWindow = m_Manager->GetLevelWindow(); QMenu* contextMenu = new QMenu( this ); Q_CHECK_PTR( contextMenu ); //contextMenu->setCheckable(true); QAction* sliderFixed = contextMenu->addAction(tr("Set Slider Fixed"), this, SLOT(setFixed())); sliderFixed->setCheckable(true); sliderFixed->setChecked(m_LevelWindow.IsFixed()); contextMenu->addSeparator(); contextMenu->addAction(tr("Use Whole Image Greyvalues"), this, SLOT(useAllGreyvaluesFromImage())); contextMenu->addSeparator(); contextMenu->addAction(tr("Set Maximum Window"), this, SLOT(setMaximumWindow())); contextMenu->addAction(tr("Default Level/Window"), this, SLOT(setDefaultLevelWindow())); contextMenu->addSeparator(); contextMenu->addAction(tr("Change Scale Range"), this, SLOT(changeScaleRange())); contextMenu->addAction(tr("Default Scale Range"), this, SLOT(setDefaultScaleRange())); contextMenu->addSeparator(); m_PresetSubmenu = new QMenu( this ); Q_CHECK_PTR( m_PresetSubmenu ); m_PresetSubmenu->setTitle("Presets"); m_PresetAction = m_PresetSubmenu->addAction(tr("Preset Definition"), this, SLOT(addPreset())); m_PresetSubmenu->addSeparator(); std::map<std::string, double> preset = m_LevelWindowPreset->getLevelPresets(); for( std::map<std::string, double>::iterator iter = preset.begin(); iter != preset.end(); iter++ ) { QString item = ((*iter).first.c_str()); m_PresetSubmenu->addAction(item); } connect(m_PresetSubmenu, SIGNAL(triggered(QAction*)), this, SLOT(setPreset(QAction*))); contextMenu->addMenu( m_PresetSubmenu ); contextMenu->addSeparator(); m_ImageSubmenu = new QMenu( this ); m_ImageSubmenu->setTitle("Images"); //m_ImageSubmenu->setCheckable(true); m_ImageAction = m_ImageSubmenu->addAction(tr("Set Topmost Image")); m_ImageAction->setCheckable(true); if (m_Manager->isAutoTopMost()) m_ImageAction->setChecked(true); m_ImageSubmenu->addSeparator(); Q_CHECK_PTR( m_ImageSubmenu ); mitk::DataStorage::SetOfObjects::ConstPointer allObjects = m_Manager->GetRelevantNodes(); for ( mitk::DataStorage::SetOfObjects::ConstIterator objectIter = allObjects->Begin(); objectIter != allObjects->End(); ++objectIter) { mitk::DataNode* node = objectIter->Value(); if (node) { mitk::LevelWindowProperty::Pointer levelWindowProperty = dynamic_cast<mitk::LevelWindowProperty*>(node->GetProperty("levelwindow")); if (levelWindowProperty.IsNotNull()) { std::string name; node->GetName(name); QString item = name.c_str(); QAction* id = m_ImageSubmenu->addAction(item); id->setCheckable(true); m_Images[id] = levelWindowProperty; if (levelWindowProperty == m_Manager->GetLevelWindowProperty()) { id->setChecked(true); } } } } connect(m_ImageSubmenu, SIGNAL(activated(int)), this, SLOT(setImage(int))); contextMenu->addMenu( m_ImageSubmenu ); contextMenu->exec( QCursor::pos() ); delete contextMenu; } catch(...) { } }
void QmitkLevelWindowWidgetContextMenu::getContextMenu | ( | QMenu * | contextmenu ) |
returns the contextmenu with standard functions for Level/Window
input is a prefilled contextmenu to which standard functions will be added
Definition at line 152 of file QmitkLevelWindowWidgetContextMenu.cpp.
References addPreset(), changeScaleRange(), mitk::LevelWindowPreset::getLevelPresets(), mitk::LevelWindowManager::GetLevelWindow(), mitk::LevelWindowManager::GetLevelWindowProperty(), mitk::DataNode::GetName(), mitk::DataNode::GetProperty(), mitk::LevelWindowManager::GetRelevantNodes(), mitk::LevelWindowManager::isAutoTopMost(), mitk::LevelWindow::IsFixed(), mitk::DataNode::IsVisible(), m_ImageAction, m_Images, m_ImageSubmenu, m_LevelWindow, m_LevelWindowPreset, m_Manager, m_PresetAction, m_PresetSubmenu, setDefaultLevelWindow(), setDefaultScaleRange(), setFixed(), setImage(), setMaximumWindow(), setPreset(), and useAllGreyvaluesFromImage().
{ try { m_LevelWindow = m_Manager->GetLevelWindow(); QMenu* contextMenu = contextmenu; Q_CHECK_PTR( contextMenu ); //contextMenu->setCheckable(true); QAction* sliderFixed = contextMenu->addAction(tr("Set Slider Fixed"), this, SLOT(setFixed())); sliderFixed->setCheckable(true); sliderFixed->setChecked(m_LevelWindow.IsFixed()); contextMenu->addSeparator(); contextMenu->addAction(tr("Use Whole Image Greyvalues"), this, SLOT(useAllGreyvaluesFromImage())); contextMenu->addSeparator(); contextMenu->addAction(tr("Set Maximum Window"), this, SLOT(setMaximumWindow())); contextMenu->addAction(tr("Default Level/Window"), this, SLOT(setDefaultLevelWindow())); contextMenu->addSeparator(); contextMenu->addAction(tr("Change Scale Range"), this, SLOT(changeScaleRange())); contextMenu->addAction(tr("Default Scale Range"), this, SLOT(setDefaultScaleRange())); contextMenu->addSeparator(); m_PresetSubmenu = new QMenu( this ); Q_CHECK_PTR( m_PresetSubmenu ); m_PresetSubmenu->setTitle("Presets"); m_PresetAction = m_PresetSubmenu->addAction(tr("Preset Definition"), this, SLOT(addPreset())); m_PresetSubmenu->addSeparator(); std::map<std::string, double> preset = m_LevelWindowPreset->getLevelPresets(); for( std::map<std::string, double>::iterator iter = preset.begin(); iter != preset.end(); iter++ ) { QString item = ((*iter).first.c_str()); m_PresetSubmenu->addAction(item); } connect(m_PresetSubmenu, SIGNAL(triggered(QAction*)), this, SLOT(setPreset(QAction*))); contextMenu->addMenu(m_PresetSubmenu); contextMenu->addSeparator(); m_ImageSubmenu = new QMenu( this ); m_ImageSubmenu->setTitle("Images"); //m_ImageSubmenu->setCheckable(true); m_ImageAction = m_ImageSubmenu->addAction(tr("Set Topmost Image")); m_ImageAction->setCheckable(true); if (m_Manager->isAutoTopMost()) m_ImageAction->setChecked(true); m_ImageSubmenu->addSeparator(); Q_CHECK_PTR( m_ImageSubmenu ); mitk::DataStorage::SetOfObjects::ConstPointer allObjects = m_Manager->GetRelevantNodes(); for ( mitk::DataStorage::SetOfObjects::ConstIterator objectIter = allObjects->Begin(); objectIter != allObjects->End(); ++objectIter) { mitk::DataNode* node = objectIter->Value(); if (node) { if (node->IsVisible(NULL) == false) continue; mitk::LevelWindowProperty::Pointer levelWindowProperty = dynamic_cast<mitk::LevelWindowProperty*>(node->GetProperty("levelwindow")); if (levelWindowProperty.IsNotNull()) { std::string name; node->GetName(name); QString item = name.c_str(); QAction* id = m_ImageSubmenu->addAction(item); id->setCheckable(true); m_Images[id] = levelWindowProperty; if (levelWindowProperty == m_Manager->GetLevelWindowProperty()) { id->setChecked(true); } } } } connect(m_ImageSubmenu, SIGNAL(triggered(QAction*)), this, SLOT(setImage(QAction*))); contextMenu->addMenu( m_ImageSubmenu ); contextMenu->exec( QCursor::pos() ); delete contextMenu; } catch(...) { } }
void QmitkLevelWindowWidgetContextMenu::setDefaultLevelWindow | ( | ) | [protected, slot] |
resets the current images Level/Window to its default values
Definition at line 105 of file QmitkLevelWindowWidgetContextMenu.cpp.
References mitk::RenderingManager::GetInstance(), m_LevelWindow, m_Manager, mitk::LevelWindow::ResetDefaultLevelWindow(), and mitk::LevelWindowManager::SetLevelWindow().
Referenced by getContextMenu().
{ m_LevelWindow.ResetDefaultLevelWindow(); m_Manager->SetLevelWindow(m_LevelWindow); mitk::RenderingManager::GetInstance()->RequestUpdateAll(); }
void QmitkLevelWindowWidgetContextMenu::setDefaultScaleRange | ( | ) | [protected, slot] |
resets the current images scalerange to its default values
Definition at line 119 of file QmitkLevelWindowWidgetContextMenu.cpp.
References mitk::RenderingManager::GetInstance(), mitk::LevelWindow::GetLevel(), mitk::LevelWindow::GetWindow(), m_LevelWindow, m_Manager, mitk::LevelWindow::ResetDefaultRangeMinMax(), mitk::LevelWindowManager::SetLevelWindow(), and mitk::LevelWindow::SetLevelWindow().
Referenced by getContextMenu().
{ m_LevelWindow.ResetDefaultRangeMinMax(); m_LevelWindow.SetLevelWindow(m_LevelWindow.GetLevel(), m_LevelWindow.GetWindow()); m_Manager->SetLevelWindow(m_LevelWindow); mitk::RenderingManager::GetInstance()->RequestUpdateAll(); }
void QmitkLevelWindowWidgetContextMenu::setFixed | ( | ) | [protected, slot] |
sets the level window slider to be fixed
Definition at line 92 of file QmitkLevelWindowWidgetContextMenu.cpp.
References mitk::LevelWindow::GetFixed(), m_LevelWindow, m_Manager, mitk::LevelWindow::SetFixed(), and mitk::LevelWindowManager::SetLevelWindow().
Referenced by getContextMenu().
void QmitkLevelWindowWidgetContextMenu::setImage | ( | QAction * | imageAction ) | [protected, slot] |
sets the selected image or the topmost layer image to the new current image
Definition at line 141 of file QmitkLevelWindowWidgetContextMenu.cpp.
References mitk::LevelWindowManager::isAutoTopMost(), m_ImageAction, m_Images, m_Manager, mitk::LevelWindowManager::SetAutoTopMostImage(), and mitk::LevelWindowManager::SetLevelWindowProperty().
Referenced by getContextMenu().
{ if (imageAction == m_ImageAction) if ( m_Manager->isAutoTopMost() == false) m_Manager->SetAutoTopMostImage(true); else m_Manager->SetAutoTopMostImage(false); else m_Manager->SetLevelWindowProperty(m_Images[imageAction]); }
void QmitkLevelWindowWidgetContextMenu::setLevelWindowManager | ( | mitk::LevelWindowManager * | levelWindowManager ) |
lets this object know about the LevelWindowManager to get all images and tell about changes
Definition at line 77 of file QmitkLevelWindowWidgetContextMenu.cpp.
References m_Manager.
{ m_Manager = levelWindowManager; }
void QmitkLevelWindowWidgetContextMenu::setMaximumWindow | ( | ) | [protected, slot] |
sets the window to its maximum Size to fit the scalerange
Definition at line 112 of file QmitkLevelWindowWidgetContextMenu.cpp.
References mitk::RenderingManager::GetInstance(), m_LevelWindow, m_Manager, mitk::LevelWindowManager::SetLevelWindow(), and mitk::LevelWindow::SetToMaxWindowSize().
Referenced by getContextMenu().
{ m_LevelWindow.SetToMaxWindowSize(); m_Manager->SetLevelWindow(m_LevelWindow); mitk::RenderingManager::GetInstance()->RequestUpdateAll(); }
void QmitkLevelWindowWidgetContextMenu::setPreset | ( | QAction * | presetAction ) | [protected, slot] |
sets level and window value of the current image to the values defined for the selected preset
Definition at line 36 of file QmitkLevelWindowWidgetContextMenu.cpp.
References mitk::RenderingManager::GetInstance(), mitk::LevelWindowPreset::getLevel(), mitk::LevelWindow::GetRangeMax(), mitk::LevelWindow::GetRangeMin(), mitk::LevelWindowPreset::getWindow(), m_LevelWindow, m_LevelWindowPreset, m_Manager, m_PresetAction, mitk::LevelWindowManager::SetLevelWindow(), and mitk::LevelWindow::SetLevelWindow().
Referenced by getContextMenu().
{ QString item = presetAction->text(); if (!(presetAction == m_PresetAction)) { double dlevel = m_LevelWindowPreset->getLevel(item.toStdString()); double dwindow = m_LevelWindowPreset->getWindow(item.toStdString()); if ((dlevel + dwindow/2) > m_LevelWindow.GetRangeMax()) { double lowerBound = (dlevel - dwindow/2); if (!(lowerBound > m_LevelWindow.GetRangeMax())) { dwindow = m_LevelWindow.GetRangeMax() - lowerBound; dlevel = lowerBound + dwindow/2; } else { dlevel = m_LevelWindow.GetRangeMax() - 1; dwindow = 2; } } else if ((dlevel - dwindow/2) < m_LevelWindow.GetRangeMin()) { double upperBound = (dlevel + dwindow/2); if (!(upperBound < m_LevelWindow.GetRangeMin())) { dwindow = m_LevelWindow.GetRangeMin() + upperBound; dlevel = upperBound - dwindow/2; } else { dlevel = m_LevelWindow.GetRangeMin() + 1; dwindow = 2; } } m_LevelWindow.SetLevelWindow(dlevel, dwindow); m_Manager->SetLevelWindow(m_LevelWindow); mitk::RenderingManager::GetInstance()->RequestUpdateAll(); } }
void QmitkLevelWindowWidgetContextMenu::useAllGreyvaluesFromImage | ( | ) | [protected, slot] |
calls the mitkLevelWindow SetAuto method with guessByCentralSlice false, so that the greyvalues from whole image will be considered
Definition at line 98 of file QmitkLevelWindowWidgetContextMenu.cpp.
References mitk::LevelWindowManager::GetCurrentImage(), mitk::RenderingManager::GetInstance(), m_LevelWindow, m_Manager, mitk::LevelWindow::SetAuto(), and mitk::LevelWindowManager::SetLevelWindow().
Referenced by getContextMenu().
{ m_LevelWindow.SetAuto(m_Manager->GetCurrentImage(), true, false); m_Manager->SetLevelWindow(m_LevelWindow); mitk::RenderingManager::GetInstance()->RequestUpdateAll(); }
QAction* QmitkLevelWindowWidgetContextMenu::m_ImageAction [protected] |
ID of image selected in contextmenu.
Definition at line 87 of file QmitkLevelWindowWidgetContextMenu.h.
Referenced by getContextMenu(), and setImage().
std::map<QAction*, mitk::LevelWindowProperty::Pointer> QmitkLevelWindowWidgetContextMenu::m_Images |
map to hold all image-properties, one can get the image which is selected in the contextmenu with the QAction representing the image for the contextmenu
Definition at line 66 of file QmitkLevelWindowWidgetContextMenu.h.
Referenced by getContextMenu(), and setImage().
submenu with all images for contextmenu
Definition at line 58 of file QmitkLevelWindowWidgetContextMenu.h.
Referenced by getContextMenu().
data structure which stores the values manipulated by a QmitkLevelWindowWidgetContextMenu
Definition at line 52 of file QmitkLevelWindowWidgetContextMenu.h.
Referenced by addPreset(), changeScaleRange(), getContextMenu(), setDefaultLevelWindow(), setDefaultScaleRange(), setFixed(), setMaximumWindow(), setPreset(), and useAllGreyvaluesFromImage().
data structure which reads and writes presets defined in a XML-file
Definition at line 46 of file QmitkLevelWindowWidgetContextMenu.h.
Referenced by addPreset(), getContextMenu(), QmitkLevelWindowWidgetContextMenu(), setPreset(), and ~QmitkLevelWindowWidgetContextMenu().
pointer to the object which manages all Level/Window changes on images and holds the LevelWindowProperty of the current image
Definition at line 62 of file QmitkLevelWindowWidgetContextMenu.h.
Referenced by changeScaleRange(), getContextMenu(), setDefaultLevelWindow(), setDefaultScaleRange(), setFixed(), setImage(), setLevelWindowManager(), setMaximumWindow(), setPreset(), and useAllGreyvaluesFromImage().
QAction* QmitkLevelWindowWidgetContextMenu::m_PresetAction [protected] |
ID of preset selected in contextmenu.
Definition at line 84 of file QmitkLevelWindowWidgetContextMenu.h.
Referenced by getContextMenu(), and setPreset().
submenu with all presets for contextmenu
Definition at line 55 of file QmitkLevelWindowWidgetContextMenu.h.
Referenced by getContextMenu().