Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
mitkLevelWindowManager.h
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 #ifndef mitkLevelWindowManager_h
14 #define mitkLevelWindowManager_h
15 
16 // mitk core
17 #include <mitkBaseProperty.h>
18 #include <mitkDataStorage.h>
20 
21 // c++
22 #include <map>
23 #include <utility>
24 
25 namespace mitk
26 {
51  class MITKCORE_EXPORT LevelWindowManager : public itk::Object
52  {
53  public:
54 
56  itkFactorylessNewMacro(Self);
57  itkCloneMacro(Self);
58 
67  void SetDataStorage(DataStorage* dataStorage);
68 
74 
82  void SetAutoTopMostImage(bool autoTopMost, const DataNode *removedNode = nullptr);
90  void SetSelectedImages(bool selectedImagesMode, const DataNode *removedNode = nullptr);
91 
100  void RecalculateLevelWindowForSelectedComponent(const itk::EventObject&);
106  void Update(const itk::EventObject&);
114  void UpdateSelected(const itk::EventObject&);
120  void SetLevelWindowProperty(LevelWindowProperty::Pointer levelWindowProperty);
124  void SetLevelWindow(const LevelWindow &levelWindow);
130  LevelWindowProperty::Pointer GetLevelWindowProperty() const;
136  const LevelWindow &GetLevelWindow() const;
142  bool IsAutoTopMost() const;
148  bool IsSelectedImages() const;
155  void DataStorageAddedNode(const DataNode *dataNode = nullptr);
162  void DataStorageRemovedNode(const DataNode *dataNode = nullptr);
166  void OnPropertyModified(const itk::EventObject&);
179  int GetNumberOfObservers() const;
188  DataStorage::SetOfObjects::ConstPointer GetRelevantNodes() const;
189 
190  private:
192  ~LevelWindowManager() override;
193 
194  DataStorage::Pointer m_DataStorage;
195  LevelWindowProperty::Pointer m_LevelWindowProperty;
196 
197  typedef std::pair<unsigned long, DataNode::Pointer> PropDataPair;
198  typedef std::map<PropDataPair, BaseProperty::Pointer> ObserverToPropertyValueMap;
199 
200  ObserverToPropertyValueMap m_ObserverToVisibleProperty;
201  ObserverToPropertyValueMap m_ObserverToLayerProperty;
202  ObserverToPropertyValueMap m_ObserverToRenderingModeProperty;
203  ObserverToPropertyValueMap m_ObserverToDisplayedComponentProperty;
204  ObserverToPropertyValueMap m_ObserverToLevelWindowImageProperty;
205  ObserverToPropertyValueMap m_ObserverToSelectedProperty;
206 
207  void UpdateObservers();
208  void ClearPropertyObserverMaps();
209  void CreatePropertyObserverMaps();
210 
211  bool HasLevelWindowRenderingMode(DataNode *dataNode) const;
212 
213  // This variable holds a data node which will be deleted from the datastorage immediately.
214  const DataNode *m_NodeMarkedToDelete;
215 
216  bool m_AutoTopMost;
217  bool m_SelectedImagesMode;
218  unsigned long m_PropertyModifiedTag;
219  Image *m_CurrentImage;
220  std::vector<DataNode::Pointer> m_DataNodesForLevelWindow;
221  bool m_IsPropertyModifiedTagSet;
222  bool m_LevelWindowMutex;
223  };
224 }
225 
226 #endif
#define MITKCORE_EXPORT
Central node class of the MITK data tree, associating a data object with properties and mappers.
Definition: mitkDataNode.h:72
Abstract data management class that organizes DataNode objects in a directed acyclic graph.
Image class for storing multi-dimensional medical image data.
Definition: mitkImage.h:76
Provides access to the LevelWindowProperty object and LevelWindow of the "current" image.
void RecalculateLevelWindowForSelectedComponent(const itk::EventObject &)
Recalculate the level window for the currently displayed component of selected images.
void SetSelectedImages(bool selectedImagesMode, const DataNode *removedNode=nullptr)
(Re-)Initialize the LevelWindowManager by setting the selected images. Use the removedNode parameter ...
LevelWindowProperty::Pointer GetLevelWindowProperty() const
Return the current LevelWindowProperty object from the image that is affected by changes.
const LevelWindow & GetLevelWindow() const
Return Level/Window values for the current image.
void SetLevelWindow(const LevelWindow &levelWindow)
Set new Level/Window values and inform all listeners about changes.
void SetAutoTopMostImage(bool autoTopMost, const DataNode *removedNode=nullptr)
(Re-)Initialize the LevelWindowManager by setting the topmost image. Use the removedNode parameter if...
mitkClassMacroItkParent(LevelWindowManager, itk::Object)
DataStorage::SetOfObjects::ConstPointer GetRelevantNodes() const
Return all nodes in the data storage that have the following properties:
void Update(const itk::EventObject &)
Update the level window. This function is called if a property of a data node is changed....
void SetDataStorage(DataStorage *dataStorage)
Set the DataStorage to observe for image nodes.
Image * GetCurrentImage() const
Return the currently active image.
void DataStorageAddedNode(const DataNode *dataNode=nullptr)
This method is called when a node is added to the data storage. A listener on the data storage is use...
void UpdateSelected(const itk::EventObject &)
Update the level window. This function is only called if the 'selected' property of a data node is ch...
bool IsSelectedImages() const
Return true, if level window changes will affect the currently selected images.
int GetNumberOfObservers() const
Return the number of observers for data node's "visible" property. This basically returns the number ...
DataStorage * GetDataStorage()
Get the currently observed DataStorage.
void DataStorageRemovedNode(const DataNode *dataNode=nullptr)
This method is called when a node is removed from the data storage. A listener on the data storage is...
void SetLevelWindowProperty(LevelWindowProperty::Pointer levelWindowProperty)
Set a specific LevelWindowProperty; all changes will affect the image belonging to this property.
void OnPropertyModified(const itk::EventObject &)
Change notifications from mitkLevelWindowProperty.
bool IsAutoTopMost() const
Return true, if level window changes will affect the topmost layer image.
The LevelWindow class Class to store level/window values.
Find image slices visible on a given plane.