Medical Imaging Interaction Toolkit  2018.4.99-389bf124
Medical Imaging Interaction Toolkit
mitkRenderWindowViewDirectionController.cpp
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 
14 
15 // mitk core
17 #include <mitkNodePredicateNot.h>
18 #include <mitkNodePredicateAnd.h>
19 
21  : m_DataStorage(nullptr)
22 {
23  // nothing here
24 }
25 
27 {
28  if (m_DataStorage != dataStorage)
29  {
30  // set the new data storage
31  m_DataStorage = dataStorage;
32  }
33 }
34 
36 {
37  if (m_ControlledRenderer != controlledRenderer)
38  {
39  // set the new set of controlled renderer
40  m_ControlledRenderer = controlledRenderer;
41  }
42 }
43 
44 void mitk::RenderWindowViewDirectionController::SetViewDirectionOfRenderer(const std::string& viewDirection, BaseRenderer* renderer/* =nullptr*/)
45 {
46  if (nullptr == renderer)
47  {
48  // set visibility of data node in all controlled renderer
49  for (auto& renderer : m_ControlledRenderer)
50  {
51  if (nullptr != renderer)
52  {
53  SetViewDirectionOfRenderer(viewDirection, renderer);
54  }
55  }
56  }
57  else
58  {
59  mitk::SliceNavigationController* sliceNavigationController = renderer->GetSliceNavigationController();
60  if ("axial" == viewDirection)
61  {
62  sliceNavigationController->SetDefaultViewDirection(ViewDirection::Axial);
63  }
64  else if ("coronal" == viewDirection)
65  {
66  sliceNavigationController->SetDefaultViewDirection(ViewDirection::Frontal);
67  }
68  else if ("sagittal" == viewDirection)
69  {
70  sliceNavigationController->SetDefaultViewDirection(ViewDirection::Sagittal);
71  }
72 
73  if ("3D" == viewDirection)
74  {
76  }
77  else
78  {
80 
81  }
82  // initialize the views to the bounding geometry
84  }
85 }
86 
88 {
89  if (nullptr == renderer)
90  {
91  // set visibility of data node in all controlled renderer
92  for (auto& renderer : m_ControlledRenderer)
93  {
94  if (nullptr != renderer)
95  {
96  SetViewDirectionOfRenderer(viewDirection, renderer);
97  }
98  }
99  }
100  else
101  {
102  mitk::SliceNavigationController* sliceNavigationController = renderer->GetSliceNavigationController();
103  sliceNavigationController->SetDefaultViewDirection(viewDirection);
104 
105  // initialize the views to the bounding geometry
107  }
108 }
109 
111 {
112  if (nullptr == m_DataStorage || nullptr == renderer)
113  {
114  return;
115  }
116 
117  // get all nodes that have not set "includeInBoundingBox" to false
118  mitk::NodePredicateProperty::Pointer includeInBoundingBox = mitk::NodePredicateProperty::New("includeInBoundingBox", mitk::BoolProperty::New(false));
119  mitk::NodePredicateNot::Pointer notIncludeInBoundingBox = mitk::NodePredicateNot::New(includeInBoundingBox);
120 
121  // get all non-helper objects
123  mitk::NodePredicateNot::Pointer notAHelperObject = mitk::NodePredicateNot::New(helperObject);
124 
125  // get all nodes that have a fixed layer for the given renderer
127 
128  // combine node predicates
129  mitk::NodePredicateAnd::Pointer combinedNodePredicate = mitk::NodePredicateAnd::New(notIncludeInBoundingBox, notAHelperObject, fixedLayer);
130  mitk::DataStorage::SetOfObjects::ConstPointer filteredDataNodes = m_DataStorage->GetSubset(combinedNodePredicate);
131 
132  // calculate bounding geometry of these nodes
133  auto bounds = m_DataStorage->ComputeBoundingGeometry3D(filteredDataNodes, "visible", renderer);
134 
135  // initialize the views to the bounding geometry
137 }
static Pointer New()
void SetDataStorage(DataStorage::Pointer dataStorage)
Set the data storage on which to work.
Organizes the rendering process.
Controls the selection of the slice the associated BaseRenderer will display.
std::vector< BaseRenderer * > RendererVector
static Pointer New()
mitk::DataStorage::Pointer m_DataStorage
static RenderingManager * GetInstance()
ViewDirection
Possible view directions, Original will uses the PlaneGeometry instances in a SlicedGeometry3D provid...
static Pointer New(const mitk::NodePredicateBase *_arg)
virtual void SetMapperID(MapperSlotId _arg)
Set the MapperSlotId to use.
void SetViewDirectionOfRenderer(const std::string &viewDirection, BaseRenderer *renderer=nullptr)
Set the view direction for the given renderer (nullptr = all renderer)
void InitializeViewByBoundingObjects(const BaseRenderer *renderer)
Reinitialize the given renderer with the currently visible nodes.
static Pointer New(const char *_arg)
vtkRenderWindow * GetRenderWindow() const
Access the RenderWindow into which this renderer renders.
void SetControlledRenderer(RenderWindowLayerUtilities::RendererVector controlledRenderer)
Set the controlled base renderer.
virtual SliceNavigationController * GetSliceNavigationController()
virtual bool InitializeView(vtkRenderWindow *renderWindow, const BaseGeometry *geometry, bool initializeGlobalTimeSNC=false)