Medical Imaging Interaction Toolkit  2025.12.02
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 
59  void SetDataStorage(DataStorage* dataStorage);
61 
69  void SetAutoTopMostImage(bool autoTopMost, const DataNode *removedNode = nullptr);
77  void SetSelectedImages(bool selectedImagesMode, const DataNode *removedNode = nullptr);
78 
79  void RecalculateLevelWindowForSelectedComponent(const itk::EventObject&);
85  void Update(const itk::EventObject&);
93  void UpdateSelected(const itk::EventObject&);
99  void SetLevelWindowProperty(LevelWindowProperty::Pointer levelWindowProperty);
103  void SetLevelWindow(const LevelWindow &levelWindow);
109  LevelWindowProperty::Pointer GetLevelWindowProperty() const;
115  const LevelWindow &GetLevelWindow() const;
121  bool IsAutoTopMost() const;
127  bool IsSelectedImages() const;
134  void DataStorageAddedNode(const DataNode *dataNode = nullptr);
141  void DataStorageRemovedNode(const DataNode *dataNode = nullptr);
145  void OnPropertyModified(const itk::EventObject&);
158  int GetNumberOfObservers() const;
167  DataStorage::SetOfObjects::ConstPointer GetRelevantNodes() const;
168 
169  private:
171  ~LevelWindowManager() override;
172 
173  DataStorage::Pointer m_DataStorage;
174  LevelWindowProperty::Pointer m_LevelWindowProperty;
175 
176  typedef std::pair<unsigned long, DataNode::Pointer> PropDataPair;
177  typedef std::map<PropDataPair, BaseProperty::Pointer> ObserverToPropertyValueMap;
178 
179  ObserverToPropertyValueMap m_ObserverToVisibleProperty;
180  ObserverToPropertyValueMap m_ObserverToLayerProperty;
181  ObserverToPropertyValueMap m_ObserverToRenderingModeProperty;
182  ObserverToPropertyValueMap m_ObserverToDisplayedComponentProperty;
183  ObserverToPropertyValueMap m_ObserverToLevelWindowImageProperty;
184  ObserverToPropertyValueMap m_ObserverToSelectedProperty;
185 
186  void UpdateObservers();
187  void ClearPropertyObserverMaps();
188  void CreatePropertyObserverMaps();
189 
190  bool HasLevelWindowRenderingMode(DataNode *dataNode) const;
191 
192  // This variable holds a data node which will be deleted from the datastorage immediately.
193  const DataNode *m_NodeMarkedToDelete;
194 
195  bool m_AutoTopMost;
196  bool m_SelectedImagesMode;
197  unsigned long m_PropertyModifiedTag;
198  Image *m_CurrentImage;
199  std::vector<DataNode::Pointer> m_DataNodesForLevelWindow;
200  bool m_IsPropertyModifiedTagSet;
201  bool m_LevelWindowMutex;
202  };
203 }
204 
205 #endif
#define MITKCORE_EXPORT
Class for nodes of the DataTree.
Definition: mitkDataNode.h:64
Data management class that handles 'was created by' relations.
Image class for storing images.
Definition: mitkImage.h:70
Provides access to the LevelWindowProperty object and LevelWindow of the "current" image.
void RecalculateLevelWindowForSelectedComponent(const itk::EventObject &)
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)
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()
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.