| 85 | } |
| 86 | |
| 87 | void mitk::LevelWindowManager::SetAutoTopMostImage(bool autoTopMost, const DataNode *removedNode/* = nullptr*/) |
| 88 | { |
| 89 | m_AutoTopMost = autoTopMost; |
| 90 | if (false == m_AutoTopMost) |
| 91 | { |
| 92 | return; |
| 93 | } |
| 94 | |
| 95 | // deactivate other mode |
| 96 | m_SelectedImagesMode = false; |
| 97 | |
| 98 | if (m_IsPropertyModifiedTagSet && m_LevelWindowProperty.IsNotNull()) |
| 99 | { |
| 100 | m_LevelWindowProperty->RemoveObserver(m_PropertyModifiedTag); |
| 101 | m_IsPropertyModifiedTagSet = false; |
| 102 | } |
| 103 | |
| 104 | // find topmost image in the data storage |
| 105 | if (m_DataStorage.IsNull()) |
| 106 | { |
| 107 | mitkThrow() << "DataStorage not set"; |
| 108 | } |
| 109 | |
| 110 | DataNode::Pointer topLevelNode; |
| 111 | int maxVisibleLayer = itk::NumericTraits<int>::min(); |
| 112 | m_LevelWindowProperty = nullptr; |
| 113 | m_CurrentImage = nullptr; |
| 114 | |
| 115 | DataStorage::SetOfObjects::ConstPointer all = this->GetRelevantNodes(); |
| 116 | for (DataStorage::SetOfObjects::ConstIterator it = all->Begin(); it != all->End(); ++it) |
| 117 | { |
| 118 | DataNode::Pointer node = it->Value(); |
| 119 | if (node.IsNull() || node == removedNode) |
| 120 | { |
| 121 | continue; |
| 122 | } |
| 123 | |
| 124 | // reset the "imageForLevelWindow" of each node |
| 125 | m_LevelWindowMutex = true; |
| 126 | node->SetBoolProperty("imageForLevelWindow", false); |
| 127 | m_LevelWindowMutex = false; |
| 128 | |
| 129 | if (false == node->IsVisible(nullptr)) |
| 130 | { |
| 131 | continue; |
| 132 | } |
| 133 | |
| 134 | bool validRenderingMode = HasLevelWindowRenderingMode(node); |
| 135 | if (false == validRenderingMode) |
| 136 | { |
| 137 | continue; |
| 138 | } |
| 139 | |
| 140 | int layer = -1; |
| 141 | node->GetIntProperty("layer", layer); |
| 142 | if (layer <= maxVisibleLayer) |
| 143 | { |
| 144 | continue; |