Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
mitkVtkPropRenderer.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 mitkVtkPropRenderer_h
14 #define mitkVtkPropRenderer_h
15 
16 #include <mitkBaseRenderer.h>
17 #include <MitkCoreExports.h>
18 #include <itkCommand.h>
19 #include <mitkDataStorage.h>
20 #include <mitkRenderingManager.h>
21 
22 #include <map>
23 #include <utility>
24 
25 class vtkRenderWindow;
26 class vtkLight;
27 class vtkLightKit;
28 class vtkWorldPointPicker;
29 class vtkPointPicker;
30 class vtkCellPicker;
31 class vtkAssemblyPath;
32 
33 #include <vtkAssemblyPaths.h>
34 #include <vtkSmartPointer.h>
35 
36 namespace mitk
37 {
38  class Mapper;
39 
51  {
52  // Workaround for Displaylistbug
53  private:
54  bool didCount;
55  void checkState();
56 
57  // Workaround END
58 
59  public:
61  mitkNewMacro2Param(VtkPropRenderer, const char*, vtkRenderWindow*);
62 
63  typedef std::map<int, Mapper *> MappersMapType;
64 
67  {
71  Volumetric
72  };
73 
78  void SetPropertyKeys(vtkInformation *info);
79 
88  int Render(RenderType type);
89 
91  virtual void PrepareRender();
92 
94  virtual void MakeCurrent();
95 
100  void SetDataStorage(mitk::DataStorage *storage) override;
101 
106  void InitRenderer(vtkRenderWindow *renderwindow) override;
107 
112  virtual void Update(mitk::DataNode *datatreenode);
113 
118  void SetMapperID(const MapperSlotId mapperId) override;
119 
125  void InitSize(int w, int h) override;
126 
132  void Resize(int w, int h) override;
133 
134  // Picking
136  {
139  CellPicking
140  };
153 
160  void PickWorldPoint(const Point2D &displayPoint, Point3D &worldPoint) const override;
161 
169  mitk::DataNode *PickObject(const Point2D &displayPosition, Point3D &worldPosition) const override;
170 
180 
186 
191  vtkAssemblyPath *GetNextPath();
192 
198 
203  const vtkWorldPointPicker *GetWorldPointPicker() const;
204 
209  const vtkPointPicker *GetPointPicker() const;
210 
215  const vtkCellPicker *GetCellPicker() const;
216 
224  virtual void ReleaseGraphicsResources(vtkWindow *renWin);
225 
231 
237 
238  protected:
239  VtkPropRenderer(const char *name = "VtkPropRenderer", vtkRenderWindow *renWin = nullptr);
240  ~VtkPropRenderer() override;
241  void Update() override;
242 
243  static void RenderingCallback(vtkObject *caller, unsigned long eid, void *clientdata, void *calldata);
244 
245  virtual void UpdatePaths(); // apply transformations and properties recursively
246 
247  private:
249  vtkTimeStamp m_PathTime;
250 
251  // prepare all mitk::mappers for rendering
252  void PrepareMapperQueue();
253 
255  void PropagateRenderInfoToMappers();
256 
258  bool Initialize2DvtkCamera();
259 
260  bool m_InitNeeded;
261  bool m_ResizeNeeded;
262  MapperSlotId m_CameraInitializedForMapperID;
263 
264  // Picking
265  vtkWorldPointPicker *m_WorldPointPicker;
266  vtkPointPicker *m_PointPicker;
267  vtkCellPicker *m_CellPicker;
268 
269  PickingMode m_PickingMode;
270 
271  // Explicit use of SmartPointer to avoid circular #includes
272  itk::SmartPointer<mitk::Mapper> m_CurrentWorldPlaneGeometryMapper;
273 
274  vtkLightKit *m_LightKit;
275 
276  // sorted list of mappers
277  MappersMapType m_MappersMap;
278 
285  vtkInformation* m_VtkRenderInfo = nullptr;
286  };
287 } // namespace mitk
288 
289 #endif
#define MITKCORE_EXPORT
Organizes the rendering process.
Central node class of the MITK data tree, associating a data object with properties and mappers.
Definition: mitkDataNode.h:72
Abstract data management class that organizes DataNode objects in a directed acyclic graph.
Organizes the MITK rendering process within the VTK rendering pipeline.
itkGetEnumMacro(PickingMode, PickingMode)
itkSetEnumMacro(PickingMode, PickingMode)
Set the picking mode. This method is used to set the picking mode for 3D object picking....
static void RenderingCallback(vtkObject *caller, unsigned long eid, void *clientdata, void *calldata)
int GetNumberOfPaths()
Return the number of assembly paths in the current traversal.
const vtkCellPicker * GetCellPicker() const
Return the cell picker.
virtual void Update(mitk::DataNode *datatreenode)
Update a specific data node in the rendering pipeline.
MappersMapType GetMappersMap() const
Return the current map of mappers sorted by layer.
~VtkPropRenderer() override
void SetPropertyKeys(vtkInformation *info)
Store and propagate vtkInformation during rendering.
mitk::DataNode * PickObject(const Point2D &displayPosition, Point3D &worldPosition) const override
Pick the data node at the given display position.
void InitRenderer(vtkRenderWindow *renderwindow) override
Initialize the renderer with the given VTK render window.
virtual void MakeCurrent()
Make the current render window the active OpenGL context.
RenderType
Enumeration of render pass types.
VtkPropRenderer(const char *name="VtkPropRenderer", vtkRenderWindow *renWin=nullptr)
int Render(RenderType type)
Render the scene for the given render type.
static bool useImmediateModeRendering()
Return whether immediate mode rendering is used.
void PickWorldPoint(const Point2D &displayPoint, Point3D &worldPoint) const override
Pick a world point from a display position using the current picking mode.
mitkNewMacro2Param(VtkPropRenderer, const char *, vtkRenderWindow *)
void SetMapperID(const MapperSlotId mapperId) override
Set the mapper slot ID to select 2D or 3D mappers.
void InitPathTraversal()
Used by vtkPointPicker/vtkPicker. This will query a list of all objects in MITK and provide every vtk...
const vtkPointPicker * GetPointPicker() const
Return the point picker.
void Update() override
mitkClassMacro(VtkPropRenderer, BaseRenderer)
void SetDataStorage(mitk::DataStorage *storage) override
Set the data storage that will be used for rendering.
virtual void PrepareRender()
Perform all preparations necessary before a VTK Render() call.
virtual void ReleaseGraphicsResources(vtkWindow *renWin)
Release VTK-based graphics resources.
std::map< int, Mapper * > MappersMapType
bool SetWorldGeometryToDataStorageBounds() override
const vtkWorldPointPicker * GetWorldPointPicker() const
Return the world point picker.
void InitSize(int w, int h) override
Initialize the renderer size.
virtual void UpdatePaths()
vtkAssemblyPath * GetNextPath()
Used by vtkPointPicker/vtkPicker. This will query a list of all objects in MITK and provide every vtk...
void Resize(int w, int h) override
Resize the renderer.
unsigned int MapperSlotId
Definition: mitkCommon.h:23
Find image slices visible on a given plane.