Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitkCompositeMapper.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,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 
17 
18 #ifndef COMPOSITEMAPPER_H_HEADER_INCLUDED
19 #define COMPOSITEMAPPER_H_HEADER_INCLUDED
20 
21 #include "mitkGLMapper.h"
22 #include "mitkVtkMapper.h"
23 #include "mitkQBallImage.h"
24 #include "mitkImageVtkMapper2D.h"
25 #include "mitkOdfVtkMapper2D.h"
27 
28 namespace mitk {
29 
31  {
32  public:
34  itkFactorylessNewMacro(Self)
35  itkCloneMacro(Self)
36 
37  friend class CompositeMapper;
38  };
39 
40  //##Documentation
41  //## @brief Composite pattern for combination of different mappers
42  //## @ingroup Mapper
43  class CompositeMapper : public VtkMapper
44  {
45  public:
46 
47  mitkClassMacro(CompositeMapper,VtkMapper);
48  itkFactorylessNewMacro(Self)
49  itkCloneMacro(Self)
50 
51  virtual void MitkRenderOverlay(BaseRenderer* renderer) override
52  {
53  m_ImgMapper->MitkRenderOverlay(renderer);
54  m_OdfMapper->MitkRenderOverlay(renderer);
55  }
56 
57  virtual void MitkRenderOpaqueGeometry(BaseRenderer* renderer) override
58  {
59  m_ImgMapper->MitkRenderOpaqueGeometry(renderer);
60  m_OdfMapper->MitkRenderOpaqueGeometry(renderer);
61  if( mitk::RenderingManager::GetInstance()->GetNextLOD( renderer ) == 0 )
62  {
63  renderer->Modified();
64  }
65  }
66 
67  virtual void MitkRenderTranslucentGeometry(BaseRenderer* renderer) override
68  {
69  m_ImgMapper->MitkRenderTranslucentGeometry(renderer);
70  m_OdfMapper->MitkRenderTranslucentGeometry(renderer);
71  }
72 
73  virtual void MitkRenderVolumetricGeometry(BaseRenderer* renderer) override
74  {
75  m_ImgMapper->MitkRenderVolumetricGeometry(renderer);
76  m_OdfMapper->MitkRenderVolumetricGeometry(renderer);
77  }
78 
79  void SetDataNode(DataNode* node) override
80  {
81  m_DataNode = node;
82  m_ImgMapper->SetDataNode(node);
83  m_OdfMapper->SetDataNode(node);
84  }
85 
87  {
88  ImageVtkMapper2D* retval = m_ImgMapper;
89  return retval;
90  }
91 
92  bool HasVtkProp( const vtkProp* prop, BaseRenderer* renderer ) override
93  {
94  return m_OdfMapper->HasVtkProp(prop, renderer);
95  }
96 
98  {
99  m_ImgMapper->ReleaseGraphicsResources(renderer);
100  m_OdfMapper->ReleaseGraphicsResources(renderer);
101  }
102 
103  static void SetDefaultProperties(DataNode* node, BaseRenderer* renderer = NULL, bool overwrite = false )
104  {
106  mitk::CopyImageMapper2D::SetDefaultProperties(node, renderer, overwrite);
107 
108  mitk::LevelWindow opaclevwin;
109  opaclevwin.SetRangeMinMax(0,255);
110  opaclevwin.SetWindowBounds(0,0);
112  node->AddProperty( "opaclevelwindow", prop );
113  }
114 
115  bool IsLODEnabled( BaseRenderer * renderer ) const override
116  {
117  return m_ImgMapper->IsLODEnabled(renderer) || m_OdfMapper->IsLODEnabled(renderer);
118  }
119 
120  vtkProp* GetVtkProp(mitk::BaseRenderer* renderer) override
121  {
122  vtkPropAssembly* assembly = vtkPropAssembly::New();
123  assembly->AddPart( m_OdfMapper->GetVtkProp(renderer));
124  assembly->AddPart( m_ImgMapper->GetVtkProp(renderer));
125  return assembly;
126  }
127 
128  protected:
129 
130  virtual void Update(mitk::BaseRenderer* renderer) override
131  {
132  m_OdfMapper->Update(renderer);
133  GenerateDataForRenderer(renderer);
134  }
135 
136  virtual void GenerateDataForRenderer(mitk::BaseRenderer* renderer) override
137  {
138  m_ImgMapper->GenerateDataForRenderer(renderer);
139 // if( mitk::RenderingManager::GetInstance()->GetNextLOD( renderer ) > 0 )
140 // {
141 // m_OdfMapper->GenerateDataForRenderer(renderer);
142 // }
143  }
144 
145  CompositeMapper();
146 
147  virtual ~CompositeMapper();
148 
149  private:
150 
153 
154  };
155 
156 } // namespace mitk
157 
158 
159 
160 #endif /* COMPOSITEMAPPER_H_HEADER_INCLUDED */
161 
void SetWindowBounds(ScalarType lowerBound, ScalarType upperBound, bool expandRangesIfNecessary=true)
static void SetDefaultProperties(mitk::DataNode *node, mitk::BaseRenderer *renderer=NULL, bool overwrite=false)
Set the default properties for general image rendering.
virtual void GenerateDataForRenderer(mitk::BaseRenderer *renderer) override
Generate the data needed for rendering into renderer.
void ReleaseGraphicsResources(mitk::BaseRenderer *renderer) override
Release vtk-based graphics resources that are being consumed by this mapper.
mitk::ImageVtkMapper2D::Pointer GetImageMapper()
static void SetDefaultProperties(DataNode *node, BaseRenderer *renderer=NULL, bool overwrite=false)
vtkProp * GetVtkProp(mitk::BaseRenderer *renderer) override
void SetDataNode(DataNode *node) override
Set the DataNode containing the data to map.
static Pointer New()
bool IsLODEnabled(BaseRenderer *renderer) const override
virtual void MitkRenderTranslucentGeometry(BaseRenderer *renderer) override
Checks visiblity and renders transparent geometry.
Organizes the rendering process.
DataCollection - Class to facilitate loading/accessing structured data.
Base class of all Vtk Mappers in order to display primitives by exploiting Vtk functionality.
Definition: mitkVtkMapper.h:53
Base class of all mappers, Vtk as well as OpenGL mappers.
Definition: mitkMapper.h:54
bool HasVtkProp(const vtkProp *prop, BaseRenderer *renderer) override
Returns true if this mapper owns the specified vtkProp for the given BaseRenderer.
virtual void MitkRenderVolumetricGeometry(BaseRenderer *renderer) override
Checks visibility and renders volumes.
void SetRangeMinMax(ScalarType min, ScalarType max)
The LevelWindow class Class to store level/window values.
Composite pattern for combination of different mappers.
Mapper to resample and display 2D slices of a 3D image.
void AddProperty(const char *propertyKey, BaseProperty *property, const mitk::BaseRenderer *renderer=nullptr, bool overwrite=false)
Add the property (instance of BaseProperty) if it does not exist (or always ifoverwrite istrue) with ...
virtual void MitkRenderOverlay(BaseRenderer *renderer)
Checks visibility and renders the overlay.
virtual void GenerateDataForRenderer(mitk::BaseRenderer *renderer) override
Does the actual resampling, without rendering the image yet. All the data is generated inside this me...
static RenderingManager * GetInstance()
mitk::DataNode * m_DataNode
Definition: mitkMapper.h:182
virtual void Update(mitk::BaseRenderer *renderer) override
Calls the time step of the input data for the specified renderer and checks whether the time step is ...
static void SetDefaultProperties(DataNode *node, BaseRenderer *renderer=NULL, bool overwrite=false)
virtual void MitkRenderOpaqueGeometry(BaseRenderer *renderer) override
Checks visibility and renders untransparent geometry.
mitkClassMacro(CopyImageMapper2D, ImageVtkMapper2D)
Class for nodes of the DataTree.
Definition: mitkDataNode.h:66
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.