24 if (m_DataStorage != dataStorage)
27 m_DataStorage = dataStorage;
33 if (m_ControlledRenderer != controlledRenderer)
36 m_ControlledRenderer = controlledRenderer;
42 if (
nullptr == dataNode)
47 if (
nullptr == renderer)
50 for (
const auto& renderer : m_ControlledRenderer)
52 if (
nullptr != renderer)
62 if (!stackedLayers.empty())
66 if (layerStackIterator != stackedLayers.end())
69 layerStackIterator->second->GetPropertyList(renderer)->DeleteProperty(
"layer");
70 layerStackIterator->second->SetBoolProperty(
"fixedLayer",
false, renderer);
71 layerStackIterator->second->SetVisibility(
false, renderer);
86 if (
nullptr == dataNode)
91 if (
nullptr == renderer)
94 for (
const auto& renderer : m_ControlledRenderer)
96 if (
nullptr != renderer)
111 InsertLayerNodeInternal(dataNode, layer, renderer);
116 void mitk::RenderWindowLayerController::InsertLayerNodeInternal(
DataNode* dataNode,
int newLayer,
const BaseRenderer* renderer )
122 if (stackedLayers.empty())
139 newLayer = stackedLayers.begin()->first + 1;
149 dataNode->Modified();
155 if (
nullptr == dataNode)
160 if (
nullptr == renderer)
163 for (
const auto& renderer : m_ControlledRenderer)
165 if (
nullptr != renderer)
177 dataNode->Modified();
184 if (
nullptr == dataNode)
189 if (
nullptr == renderer)
192 for (
const auto& renderer : m_ControlledRenderer)
194 if (
nullptr != renderer)
206 if (!stackedLayers.empty())
210 bool wasFound = dataNode->
GetIntProperty(
"layer", currentLayer, renderer);
211 if (wasFound && currentLayer != newLayer)
219 if (currentLayer < newLayer)
222 upperBound = newLayer + 1;
223 lowerBound = currentLayer + 1;
228 upperBound = currentLayer;
229 lowerBound = newLayer;
234 for (
auto& layer : stackedLayers)
236 if (layer.second != dataNode && layer.first < upperBound && layer.first >= lowerBound)
238 layer.second->SetIntProperty(
"layer", layer.first + step, renderer);
244 dataNode->Modified();
257 if (
nullptr == dataNode)
262 if (
nullptr == renderer)
265 for (
const auto& renderer : m_ControlledRenderer)
267 if (
nullptr != renderer)
279 if (!stackedLayers.empty())
282 int topmostLayer = stackedLayers.begin()->first;
285 bool wasFound = dataNode->
GetIntProperty(
"layer", currentLayer, renderer);
286 if (wasFound && currentLayer < topmostLayer)
290 dataNode->Modified();
303 if (
nullptr == dataNode)
308 if (
nullptr == renderer)
311 for (
const auto& renderer : m_ControlledRenderer)
313 if (
nullptr != renderer)
325 if (!stackedLayers.empty())
329 int lowermostLayer = stackedLayers.rbegin()->first;
332 bool wasFound = dataNode->
GetIntProperty(
"layer", currentLayer, renderer);
333 if (wasFound && currentLayer > lowermostLayer)
338 for (
auto& layer : stackedLayers)
340 if (layer.second != dataNode && layer.first < currentLayer)
342 layer.second->SetIntProperty(
"layer", layer.first + 1, renderer);
347 dataNode->Modified();
360 if (
nullptr == dataNode)
365 if (
nullptr == renderer)
368 for (
const auto& renderer : m_ControlledRenderer)
370 if (
nullptr != renderer)
382 if (!stackedLayers.empty())
386 bool wasFound = dataNode->
GetIntProperty(
"layer", currentLayer, renderer);
390 RenderWindowLayerUtilities::LayerStack::const_iterator layerStackIterator = stackedLayers.find(currentLayer);
391 if (layerStackIterator != stackedLayers.end() && layerStackIterator != stackedLayers.begin())
396 RenderWindowLayerUtilities::LayerStack::const_iterator prevLayerStackIterator = std::prev(layerStackIterator);
397 dataNode->
SetIntProperty(
"layer", prevLayerStackIterator->first, renderer);
398 prevLayerStackIterator->second->SetIntProperty(
"layer", currentLayer, renderer);
399 dataNode->Modified();
415 if (
nullptr == dataNode)
420 if (
nullptr == renderer)
423 for (
const auto& renderer : m_ControlledRenderer)
425 if (
nullptr != renderer)
437 if (!stackedLayers.empty())
441 bool wasFound = dataNode->
GetIntProperty(
"layer", currentLayer, renderer);
445 RenderWindowLayerUtilities::LayerStack::const_iterator layerStackIterator = stackedLayers.find(currentLayer);
446 if (layerStackIterator != stackedLayers.end())
449 RenderWindowLayerUtilities::LayerStack::const_iterator nextLayerStackIterator = std::next(layerStackIterator);
450 if (nextLayerStackIterator != stackedLayers.end())
455 dataNode->
SetIntProperty(
"layer", nextLayerStackIterator->first, renderer);
456 nextLayerStackIterator->second->SetIntProperty(
"layer", currentLayer, renderer);
457 dataNode->Modified();
474 if (
nullptr == dataNode)
479 if (
nullptr == renderer)
482 for (
const auto& renderer : m_ControlledRenderer)
484 if (
nullptr != renderer)
493 dataNode->Modified();
500 if (
nullptr == dataNode)
505 for (
const auto& renderer : m_ControlledRenderer)
507 if (
nullptr != renderer)
518 if (
nullptr == renderer)
521 for (
const auto& renderer : m_ControlledRenderer)
523 if (
nullptr != renderer)
533 if (!stackedLayers.empty())
535 for (
const auto& layer : stackedLayers)
538 layer.second->GetIntProperty(
"layer", layerLevel, renderer);
542 layer.second->SetVisibility(
true, renderer);
547 layer.second->SetVisibility(
false, renderer);
553 layer.second->GetPropertyList(renderer)->DeleteProperty(
"layer");
554 layer.second->SetBoolProperty(
"fixedLayer",
false, renderer);
557 layer.second->Modified();
void SetIntProperty(const char *propertyKey, int intValue, const mitk::BaseRenderer *renderer=nullptr)
Convenience method for setting int properties (instances of IntProperty)
void SetBoolProperty(const char *propertyKey, bool boolValue)
Convenience method to set the value of a BoolProperty.
void SetVisibilityOfDataNode(bool visiblity, DataNode *dataNode, const BaseRenderer *renderer=nullptr)
Set the visibility of the given data node for the given renderer.
MITKRENDERWINDOWMANAGER_EXPORT void SetRenderWindowProperties(mitk::DataNode *dataNode, const BaseRenderer *renderer)
Set renderer-specific properties to mark a data node as 'managed by the specific renderer'. In order for a renderer to manage a data node, the 'fixedLayer' property has to be set for the given renderer. Additionally, the 'visible' and the 'layer' property are set and allow to individually render a set of nodes with a specific renderer. The last two mentioned properties are set so that they initially have the same value as the corresponding global property.
void SetVisibility(bool visible, const mitk::BaseRenderer *renderer=nullptr, const char *propertyKey="visible")
Convenience method for setting visibility properties (instances of BoolProperty)
void InsertLayerNode(DataNode *dataNode, int layer=RenderWindowLayerUtilities::TOP_LAYER_INDEX, const BaseRenderer *renderer=nullptr)
Insert the given data node at the specified layer for the given renderer.
const int BASE_LAYER_INDEX
Organizes the rendering process.
void ResetRenderer(bool onlyVisibility=true, const BaseRenderer *renderer=nullptr)
Reset the given render window: If "onlyVisibility = true": set all data nodes for the given render wi...
bool GetIntProperty(const char *propertyKey, int &intValue, const mitk::BaseRenderer *renderer=nullptr) const
Convenience access method for int properties (instances of IntProperty)
bool DeleteProperty(const std::string &propertyKey)
Remove a property from the list/map.
void SetBaseDataNode(DataNode *dataNode, const BaseRenderer *renderer=nullptr)
Set the given node as the base node of the given renderer.
std::vector< BaseRenderer * > RendererVector
bool MoveNodeToBack(DataNode *dataNode, const BaseRenderer *renderer=nullptr)
Set the node in the given renderer as the lowermost layer. This will change only the "layer" property...
const int TOP_LAYER_INDEX
mitk::DataStorage::Pointer m_DataStorage
static RenderingManager * GetInstance()
MITKRENDERWINDOWMANAGER_EXPORT LayerStack GetLayerStack(const DataStorage *dataStorage, const BaseRenderer *renderer, bool withBaseNode)
Return the stack of layers of the given renderer as std::map<int, DataNode::Pointer>, which guarantees ordering of the layers. Stacked layers are only included if they have their "fixedLayer" property set to true and their "layer" property set.
void RemoveLayerNode(DataNode *dataNode, const BaseRenderer *renderer=nullptr)
Remove the given data node for the given renderer.
bool MoveNodeToPosition(DataNode *dataNode, int newLayer, const BaseRenderer *renderer=nullptr)
Move the data node to the given layer. This will change only the "layer" property.
void SetBoolProperty(const char *propertyKey, bool boolValue, const mitk::BaseRenderer *renderer=nullptr)
Convenience method for setting boolean properties (instances of BoolProperty)
void SetControlledRenderer(RenderWindowLayerUtilities::RendererVector controlledRenderer)
Set the controlled base renderer.
void RequestUpdate(vtkRenderWindow *renderWindow)
mitk::PropertyList * GetPropertyList(const mitk::BaseRenderer *renderer=nullptr) const
Get the PropertyList of the renderer. If renderer is nullptr, the BaseRenderer-independent PropertyLi...
vtkRenderWindow * GetRenderWindow() const
Access the RenderWindow into which this renderer renders.
void HideDataNodeInAllRenderer(const DataNode *dataNode)
Hide the given data node by setting the "visible" property of the data node for all controlled render...
bool MoveNodeToFront(DataNode *dataNode, const BaseRenderer *renderer=nullptr)
Set the node in the given renderer as the topmost layer. This will change only the "layer" property...
std::map< int, DataNode::Pointer, std::greater< int > > LayerStack
RenderWindowLayerController()
bool MoveNodeDown(DataNode *dataNode, const BaseRenderer *renderer=nullptr)
Move the node in the given renderer one layer up. This will change only the "layer" property...
void SetDataStorage(DataStorage::Pointer dataStorage)
Set the data storage on which to work.
bool MoveNodeUp(DataNode *dataNode, const BaseRenderer *renderer=nullptr)
Move the node in the given renderer one layer down. This will change only the "layer" property...
void RequestUpdateAll(RequestType type=REQUEST_UPDATE_ALL)
Class for nodes of the DataTree.