Medical Imaging Interaction Toolkit  2018.4.99-bd7b41ba
Medical Imaging Interaction Toolkit
mitk::LevelWindowManager Class Reference

Provides access to the LevelWindowProperty object and LevelWindow of the "current" image. More...

#include <mitkLevelWindowManager.h>

Inheritance diagram for mitk::LevelWindowManager:
Collaboration diagram for mitk::LevelWindowManager:

Public Types

typedef LevelWindowManager Self
 
typedef itk::Object Superclass
 
typedef itk::SmartPointer< SelfPointer
 
typedef itk::SmartPointer< const SelfConstPointer
 

Public Member Functions

virtual std::vector< std::string > GetClassHierarchy () const
 
virtual const char * GetClassName () const
 
Pointer Clone () const
 
void SetDataStorage (DataStorage *ds)
 
DataStorageGetDataStorage ()
 
void SetAutoTopMostImage (bool autoTopMost, const DataNode *removedNode=nullptr)
 (Re-)Initialize the LevelWindowManager by setting the topmost image. Use the removedNode parameter if a node was removed. More...
 
void SetSelectedImages (bool selectedImagesMode, const DataNode *removedNode=nullptr)
 (Re-)Initialize the LevelWindowManager by setting the selected images. Use the removedNode parameter if a node was removed. More...
 
void RecalculateLevelWindowForSelectedComponent (const itk::EventObject &)
 
void Update (const itk::EventObject &)
 Update the level window. This function is called if a property of a data node is changed. Relevant properties are defined in the protected 'ObserverToPropertyValueMap'-members. More...
 
void UpdateSelected (const itk::EventObject &)
 Update the level window. This function is only called if the 'selected' property of a data node is changed. This is done in order to avoid finding the correct image each time a node is selected but the 'm_SelectedImages' bool value is set to false (as the normal 'Update'-function would do). Changes of the 'selected' property happen quite a lot so this should not slow down the application. More...
 
void SetLevelWindowProperty (LevelWindowProperty::Pointer levelWindowProperty)
 Set a specific LevelWindowProperty; all changes will affect the image belonging to this property. More...
 
void SetLevelWindow (const LevelWindow &levelWindow)
 Set new Level/Window values and inform all listeners about changes. More...
 
LevelWindowProperty::Pointer GetLevelWindowProperty ()
 Return the current LevelWindowProperty object from the image that is affected by changes. More...
 
const LevelWindowGetLevelWindow ()
 Return Level/Window values for the current image. More...
 
bool IsAutoTopMost ()
 Return true, if the changes on slider or line-edits will affect the topmost layer image. More...
 
bool IsSelectedImages ()
 Return true, if changes on slider or line-edits will affect the currently selected images. More...
 
void DataStorageAddedNode (const DataNode *n=nullptr)
 This method is called when a node is added to the data storage. A listener on the data storage is used to call this method automatically after a node was added. More...
 
void DataStorageRemovedNode (const DataNode *removedNode=nullptr)
 This method is called when a node is removed to the data storage. A listener on the data storage is used to call this method automatically directly before a node will be removed. More...
 
void OnPropertyModified (const itk::EventObject &e)
 Change notifications from mitkLevelWindowProperty. More...
 
ImageGetCurrentImage ()
 Return the currently active image. More...
 
int GetNumberOfObservers ()
 
DataStorage::SetOfObjects::ConstPointer GetRelevantNodes ()
 Returns all nodes in the DataStorage that have the following properties: More...
 

Static Public Member Functions

static const char * GetStaticNameOfClass ()
 
static Pointer New ()
 

Protected Types

typedef std::pair< unsigned long, DataNode::PointerPropDataPair
 
typedef std::map< PropDataPair, BaseProperty::PointerObserverToPropertyValueMap
 

Protected Member Functions

 LevelWindowManager ()
 
 ~LevelWindowManager () override
 
void UpdateObservers ()
 
void ClearPropObserverLists ()
 Internal help method to clear both lists/maps. More...
 
void CreatePropObserverLists ()
 Internal help method to create both lists/maps. More...
 
bool IgnoreNode (const DataNode *dataNode)
 

Protected Attributes

DataStorage::Pointer m_DataStorage
 
LevelWindowProperty::Pointer m_LevelWindowProperty
 Pointer to the LevelWindowProperty of the current image. More...
 
ObserverToPropertyValueMap m_ObserverToVisibleProperty
 Map to hold observer IDs to every "visible" property of DataNode's BaseProperty. More...
 
ObserverToPropertyValueMap m_ObserverToLayerProperty
 Map to hold observer IDs to every "layer" property of DataNode's BaseProperty. More...
 
ObserverToPropertyValueMap m_ObserverToRenderingModeProperty
 Map to hold observer IDs to every "Image Rendering.Mode" property of DataNode's BaseProperty. More...
 
ObserverToPropertyValueMap m_ObserverToDisplayedComponentProperty
 Map to hold observer IDs to every "Image.Displayed Component" property of DataNode's BaseProperty. More...
 
ObserverToPropertyValueMap m_ObserverToLevelWindowImageProperty
 Map to hold observer IDs to every "imageForLevelWindow" property of DataNode's BaseProperty. More...
 
ObserverToPropertyValueMap m_ObserverToSelectedProperty
 Map to hold observer IDs to every "selected" property of DataNode's BaseProperty. More...
 
const DataNodem_NodeMarkedToDelete
 
bool m_AutoTopMost
 
bool m_SelectedImagesMode
 
unsigned long m_ObserverTag
 
bool m_IsObserverTagSet
 
unsigned long m_PropertyModifiedTag
 
Imagem_CurrentImage
 
std::vector< DataNode::Pointerm_RelevantDataNodes
 
bool m_IsPropertyModifiedTagSet
 
bool m_LevelWindowMutex
 

Detailed Description

Provides access to the LevelWindowProperty object and LevelWindow of the "current" image.

  • provides a LevelWindowProperty for purposes like GUI editors
  • this property comes from one of two possible sources
    • either something (e.g. the application) sets the property because of some user selection
    • OR the "Auto top-most" logic is used to search a DataStorage for the image with the highest "layer" property value

Changes on Level/Window can be set with SetLevelWindow() and will affect either the topmost layer image, if isAutoTopMost() returns true, or an image which is set by SetLevelWindowProperty(LevelWindowProperty::Pointer levelWindowProperty).

Changes to Level/Window, when another image gets active or by SetLevelWindow(const LevelWindow& levelWindow), will be sent to all listeners by Modified().

DataStorageChanged() listens to the DataStorage for new or removed images. Depending on how m_AutoTopMost is set, the new image becomes active or not. If an image is removed from the DataStorage and m_AutoTopMost is false, there is a check to proof, if the active image is still available. If not, then m_AutoTopMost becomes true.

Note that this class is not thread safe at the moment!

Definition at line 49 of file mitkLevelWindowManager.h.

Member Typedef Documentation

◆ ConstPointer

◆ ObserverToPropertyValueMap

◆ Pointer

◆ PropDataPair

typedef std::pair<unsigned long, DataNode::Pointer> mitk::LevelWindowManager::PropDataPair
protected

Definition at line 174 of file mitkLevelWindowManager.h.

◆ Self

◆ Superclass

Definition at line 53 of file mitkLevelWindowManager.h.

Constructor & Destructor Documentation

◆ LevelWindowManager()

mitk::LevelWindowManager::LevelWindowManager ( )
protected

Definition at line 27 of file mitkLevelWindowManager.cpp.

◆ ~LevelWindowManager()

mitk::LevelWindowManager::~LevelWindowManager ( )
overrideprotected

Member Function Documentation

◆ ClearPropObserverLists()

void mitk::LevelWindowManager::ClearPropObserverLists ( )
protected

◆ Clone()

Pointer mitk::LevelWindowManager::Clone ( ) const

◆ CreatePropObserverLists()

◆ DataStorageAddedNode()

void mitk::LevelWindowManager::DataStorageAddedNode ( const DataNode n = nullptr)

This method is called when a node is added to the data storage. A listener on the data storage is used to call this method automatically after a node was added.

Exceptions
mitk::ExceptionThrows an exception if something is wrong, e.g. if the number of observers differs from the number of nodes.

Definition at line 465 of file mitkLevelWindowManager.cpp.

References GetRelevantNodes(), m_ObserverToLayerProperty, m_ObserverToVisibleProperty, mitkThrow, SetAutoTopMostImage(), and UpdateObservers().

Referenced by SetDataStorage(), and ~LevelWindowManager().

◆ DataStorageRemovedNode()

void mitk::LevelWindowManager::DataStorageRemovedNode ( const DataNode removedNode = nullptr)

This method is called when a node is removed to the data storage. A listener on the data storage is used to call this method automatically directly before a node will be removed.

Exceptions
mitk::ExceptionThrows an exception if something is wrong, e.g. if the number of observers differs from the number of nodes.

Definition at line 481 of file mitkLevelWindowManager.cpp.

References GetRelevantNodes(), m_AutoTopMost, m_DataStorage, m_LevelWindowProperty, m_NodeMarkedToDelete, m_ObserverToLayerProperty, m_ObserverToVisibleProperty, mitkThrow, mitk::NodePredicateProperty::New(), SetAutoTopMostImage(), and UpdateObservers().

Referenced by SetDataStorage(), and ~LevelWindowManager().

◆ GetClassHierarchy()

virtual std::vector<std::string> mitk::LevelWindowManager::GetClassHierarchy ( ) const
inlinevirtual

Definition at line 53 of file mitkLevelWindowManager.h.

◆ GetClassName()

virtual const char* mitk::LevelWindowManager::GetClassName ( ) const
virtual

◆ GetCurrentImage()

mitk::Image * mitk::LevelWindowManager::GetCurrentImage ( )

Return the currently active image.

Returns
The member variable holding the currently active image.

Definition at line 538 of file mitkLevelWindowManager.cpp.

References m_CurrentImage.

Referenced by QmitkLevelWindowWidgetContextMenu::OnUseAllGreyvaluesFromImage(), and QmitkLevelWindowWidgetContextMenu::OnUseOptimizedLevelWindow().

◆ GetDataStorage()

mitk::DataStorage * mitk::LevelWindowManager::GetDataStorage ( )

Definition at line 84 of file mitkLevelWindowManager.cpp.

References m_DataStorage.

◆ GetLevelWindow()

const mitk::LevelWindow & mitk::LevelWindowManager::GetLevelWindow ( )

Return Level/Window values for the current image.

Returns
The LevelWindow value for the current image.

Definition at line 443 of file mitkLevelWindowManager.cpp.

References m_LevelWindowProperty, and mitkThrow.

Referenced by QmitkLevelWindowWidgetContextMenu::GetContextMenu().

◆ GetLevelWindowProperty()

mitk::LevelWindowProperty::Pointer mitk::LevelWindowManager::GetLevelWindowProperty ( )

Return the current LevelWindowProperty object from the image that is affected by changes.

Returns
The current LevelWindowProperty

Definition at line 438 of file mitkLevelWindowManager.cpp.

References m_LevelWindowProperty.

Referenced by QmitkLevelWindowWidgetContextMenu::GetContextMenu().

◆ GetNumberOfObservers()

int mitk::LevelWindowManager::GetNumberOfObservers ( )
Returns
Returns the current number of observers which are registered in this object.
Exceptions
mitk::ExceptionThrows an exception if the number of observers differs from the number of relevant objects which means that something is wrong.

Definition at line 543 of file mitkLevelWindowManager.cpp.

References m_ObserverToVisibleProperty.

◆ GetRelevantNodes()

mitk::DataStorage::SetOfObjects::ConstPointer mitk::LevelWindowManager::GetRelevantNodes ( )

◆ GetStaticNameOfClass()

static const char* mitk::LevelWindowManager::GetStaticNameOfClass ( )
inlinestatic

Definition at line 53 of file mitkLevelWindowManager.h.

◆ IgnoreNode()

bool mitk::LevelWindowManager::IgnoreNode ( const DataNode dataNode)
protected

◆ IsAutoTopMost()

bool mitk::LevelWindowManager::IsAutoTopMost ( )

Return true, if the changes on slider or line-edits will affect the topmost layer image.

Returns
Return the member value that denotes the auto-topmost mode.

Definition at line 455 of file mitkLevelWindowManager.cpp.

References m_AutoTopMost.

Referenced by QmitkLevelWindowWidgetContextMenu::GetContextMenu(), and QmitkLevelWindowWidgetContextMenu::OnSetImage().

◆ IsSelectedImages()

bool mitk::LevelWindowManager::IsSelectedImages ( )

Return true, if changes on slider or line-edits will affect the currently selected images.

Returns
Return the member value that denotes the selected-images mode.

Definition at line 460 of file mitkLevelWindowManager.cpp.

References m_SelectedImagesMode.

Referenced by QmitkLevelWindowWidgetContextMenu::GetContextMenu(), and QmitkLevelWindowWidgetContextMenu::OnSetImage().

◆ New()

◆ OnPropertyModified()

void mitk::LevelWindowManager::OnPropertyModified ( const itk::EventObject &  e)

Change notifications from mitkLevelWindowProperty.

Definition at line 533 of file mitkLevelWindowManager.cpp.

Referenced by SetLevelWindowProperty().

◆ RecalculateLevelWindowForSelectedComponent()

void mitk::LevelWindowManager::RecalculateLevelWindowForSelectedComponent ( const itk::EventObject &  event)

◆ SetAutoTopMostImage()

void mitk::LevelWindowManager::SetAutoTopMostImage ( bool  autoTopMost,
const DataNode removedNode = nullptr 
)

(Re-)Initialize the LevelWindowManager by setting the topmost image. Use the removedNode parameter if a node was removed.

Parameters
autoTopMostSet the topmost layer image to be affected by changes, if true.
removedNodeA node was removed from the data storage if != nullptr.

Definition at line 89 of file mitkLevelWindowManager.cpp.

References GetRelevantNodes(), IgnoreNode(), m_AutoTopMost, m_CurrentImage, m_DataStorage, m_IsPropertyModifiedTagSet, m_LevelWindowMutex, m_LevelWindowProperty, m_PropertyModifiedTag, m_SelectedImagesMode, min(), mitkThrow, and SetLevelWindowProperty().

Referenced by DataStorageAddedNode(), DataStorageRemovedNode(), QmitkLevelWindowWidgetContextMenu::OnSetImage(), and Update().

◆ SetDataStorage()

void mitk::LevelWindowManager::SetDataStorage ( DataStorage ds)

◆ SetLevelWindow()

◆ SetLevelWindowProperty()

void mitk::LevelWindowManager::SetLevelWindowProperty ( LevelWindowProperty::Pointer  levelWindowProperty)

Set a specific LevelWindowProperty; all changes will affect the image belonging to this property.

Exceptions
mitk::ExceptionThrow an exception if the there is no image in the data storage which belongs to this property.

Definition at line 365 of file mitkLevelWindowManager.cpp.

References m_CurrentImage, m_DataStorage, m_IsPropertyModifiedTagSet, m_LevelWindowMutex, m_LevelWindowProperty, m_PropertyModifiedTag, mitkThrow, and OnPropertyModified().

Referenced by QmitkLevelWindowWidgetContextMenu::OnSetImage(), SetAutoTopMostImage(), SetSelectedImages(), and Update().

◆ SetSelectedImages()

void mitk::LevelWindowManager::SetSelectedImages ( bool  selectedImagesMode,
const DataNode removedNode = nullptr 
)

(Re-)Initialize the LevelWindowManager by setting the selected images. Use the removedNode parameter if a node was removed.

Parameters
selectedImagesModeSet the selected images to be affected by changes, if true.
removedNodeA node was removed from the data storage if != nullptr.

Definition at line 162 of file mitkLevelWindowManager.cpp.

References GetRelevantNodes(), IgnoreNode(), m_AutoTopMost, m_CurrentImage, m_DataStorage, m_IsPropertyModifiedTagSet, m_LevelWindowMutex, m_LevelWindowProperty, m_PropertyModifiedTag, m_RelevantDataNodes, m_SelectedImagesMode, mitkThrow, and SetLevelWindowProperty().

Referenced by QmitkLevelWindowWidgetContextMenu::OnSetImage(), Update(), and UpdateSelected().

◆ Update()

void mitk::LevelWindowManager::Update ( const itk::EventObject &  )

Update the level window. This function is called if a property of a data node is changed. Relevant properties are defined in the protected 'ObserverToPropertyValueMap'-members.

Definition at line 260 of file mitkLevelWindowManager.cpp.

References GetRelevantNodes(), m_AutoTopMost, m_LevelWindowMutex, m_LevelWindowProperty, m_RelevantDataNodes, m_SelectedImagesMode, min(), MITK_ERROR, SetAutoTopMostImage(), SetLevelWindowProperty(), and SetSelectedImages().

Referenced by CreatePropObserverLists(), and RecalculateLevelWindowForSelectedComponent().

◆ UpdateObservers()

void mitk::LevelWindowManager::UpdateObservers ( )
protected

Updates the internal observer list. Ignores nodes which are marked to be deleted in the variable m_NodeMarkedToDelete.

Definition at line 580 of file mitkLevelWindowManager.cpp.

References ClearPropObserverLists(), and CreatePropObserverLists().

Referenced by DataStorageAddedNode(), and DataStorageRemovedNode().

◆ UpdateSelected()

void mitk::LevelWindowManager::UpdateSelected ( const itk::EventObject &  )

Update the level window. This function is only called if the 'selected' property of a data node is changed. This is done in order to avoid finding the correct image each time a node is selected but the 'm_SelectedImages' bool value is set to false (as the normal 'Update'-function would do). Changes of the 'selected' property happen quite a lot so this should not slow down the application.

Definition at line 351 of file mitkLevelWindowManager.cpp.

References m_LevelWindowMutex, m_RelevantDataNodes, m_SelectedImagesMode, and SetSelectedImages().

Referenced by CreatePropObserverLists().

Member Data Documentation

◆ m_AutoTopMost

bool mitk::LevelWindowManager::m_AutoTopMost
protected

◆ m_CurrentImage

Image* mitk::LevelWindowManager::m_CurrentImage
protected

◆ m_DataStorage

◆ m_IsObserverTagSet

bool mitk::LevelWindowManager::m_IsObserverTagSet
protected

Definition at line 206 of file mitkLevelWindowManager.h.

◆ m_IsPropertyModifiedTagSet

bool mitk::LevelWindowManager::m_IsPropertyModifiedTagSet
protected

◆ m_LevelWindowMutex

bool mitk::LevelWindowManager::m_LevelWindowMutex
protected

◆ m_LevelWindowProperty

◆ m_NodeMarkedToDelete

const DataNode* mitk::LevelWindowManager::m_NodeMarkedToDelete
protected

This variable holds a data node which will be deleted from the datastorage immediately Nullptr, if there is no data node to be deleted.

Definition at line 201 of file mitkLevelWindowManager.h.

Referenced by CreatePropObserverLists(), and DataStorageRemovedNode().

◆ m_ObserverTag

unsigned long mitk::LevelWindowManager::m_ObserverTag
protected

Definition at line 205 of file mitkLevelWindowManager.h.

◆ m_ObserverToDisplayedComponentProperty

ObserverToPropertyValueMap mitk::LevelWindowManager::m_ObserverToDisplayedComponentProperty
protected

Map to hold observer IDs to every "Image.Displayed Component" property of DataNode's BaseProperty.

Definition at line 183 of file mitkLevelWindowManager.h.

Referenced by ClearPropObserverLists(), and CreatePropObserverLists().

◆ m_ObserverToLayerProperty

ObserverToPropertyValueMap mitk::LevelWindowManager::m_ObserverToLayerProperty
protected

Map to hold observer IDs to every "layer" property of DataNode's BaseProperty.

Definition at line 179 of file mitkLevelWindowManager.h.

Referenced by ClearPropObserverLists(), CreatePropObserverLists(), DataStorageAddedNode(), and DataStorageRemovedNode().

◆ m_ObserverToLevelWindowImageProperty

ObserverToPropertyValueMap mitk::LevelWindowManager::m_ObserverToLevelWindowImageProperty
protected

Map to hold observer IDs to every "imageForLevelWindow" property of DataNode's BaseProperty.

Definition at line 185 of file mitkLevelWindowManager.h.

Referenced by ClearPropObserverLists(), and CreatePropObserverLists().

◆ m_ObserverToRenderingModeProperty

ObserverToPropertyValueMap mitk::LevelWindowManager::m_ObserverToRenderingModeProperty
protected

Map to hold observer IDs to every "Image Rendering.Mode" property of DataNode's BaseProperty.

Definition at line 181 of file mitkLevelWindowManager.h.

Referenced by ClearPropObserverLists(), and CreatePropObserverLists().

◆ m_ObserverToSelectedProperty

ObserverToPropertyValueMap mitk::LevelWindowManager::m_ObserverToSelectedProperty
protected

Map to hold observer IDs to every "selected" property of DataNode's BaseProperty.

Definition at line 187 of file mitkLevelWindowManager.h.

Referenced by ClearPropObserverLists(), and CreatePropObserverLists().

◆ m_ObserverToVisibleProperty

ObserverToPropertyValueMap mitk::LevelWindowManager::m_ObserverToVisibleProperty
protected

Map to hold observer IDs to every "visible" property of DataNode's BaseProperty.

Definition at line 177 of file mitkLevelWindowManager.h.

Referenced by ClearPropObserverLists(), CreatePropObserverLists(), DataStorageAddedNode(), DataStorageRemovedNode(), and GetNumberOfObservers().

◆ m_PropertyModifiedTag

unsigned long mitk::LevelWindowManager::m_PropertyModifiedTag
protected

◆ m_RelevantDataNodes

std::vector<DataNode::Pointer> mitk::LevelWindowManager::m_RelevantDataNodes
protected

◆ m_SelectedImagesMode

bool mitk::LevelWindowManager::m_SelectedImagesMode
protected

The documentation for this class was generated from the following files: