Medical Imaging Interaction Toolkit  2025.12.02
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 vtkTextActor;
32 class vtkTextProperty;
33 class vtkAssemblyPath;
34 
35 #include <vtkAssemblyPaths.h>
36 #include <vtkSmartPointer.h>
37 
38 namespace mitk
39 {
40  class Mapper;
41 
56  {
57  // Workaround for Displaylistbug
58  private:
59  bool didCount;
60  void checkState();
61 
62  // Workaround END
63 
64  public:
66  mitkNewMacro2Param(VtkPropRenderer, const char*, vtkRenderWindow*);
67 
68  typedef std::map<int, Mapper *> MappersMapType;
69 
70  // Render - called by vtkMitkRenderProp, returns the number of props rendered
72  {
76  Volumetric
77  };
78 
80  void SetPropertyKeys(vtkInformation *info);
81 
82  int Render(RenderType type);
83 
85  virtual void PrepareRender();
86 
87  // Active current renderwindow
88  virtual void MakeCurrent();
89 
91  mitk::DataStorage *storage) override;
92 
93  void InitRenderer(vtkRenderWindow *renderwindow) override;
94  virtual void Update(mitk::DataNode *datatreenode);
95  void SetMapperID(const MapperSlotId mapperId) override;
96 
97  // Size
98  void InitSize(int w, int h) override;
99  void Resize(int w, int h) override;
100 
101  // Picking
103  {
106  CellPicking
107  };
120 
121  void PickWorldPoint(const Point2D &displayPoint, Point3D &worldPoint) const override;
122  mitk::DataNode *PickObject(const Point2D &displayPosition, Point3D &worldPosition) const override;
123 
134  DEPRECATED(int WriteSimpleText(std::string text,
135  double posX,
136  double posY,
137  double color1 = 0.0,
138  double color2 = 1.0,
139  double color3 = 0.0,
140  float opacity = 1.0));
141 
149  DEPRECATED(vtkTextProperty *GetTextLabelProperty(int text_id));
150 
160 
166 
171  vtkAssemblyPath *GetNextPath();
172 
174 
175  const vtkWorldPointPicker *GetWorldPointPicker() const;
176  const vtkPointPicker *GetPointPicker() const;
177  const vtkCellPicker *GetCellPicker() const;
178 
183  virtual void ReleaseGraphicsResources(vtkWindow *renWin);
184 
186 
188 
189  protected:
190  VtkPropRenderer(const char *name = "VtkPropRenderer", vtkRenderWindow *renWin = nullptr);
191  ~VtkPropRenderer() override;
192  void Update() override;
193 
194  static void RenderingCallback(vtkObject *caller, unsigned long eid, void *clientdata, void *calldata);
195 
196  virtual void UpdatePaths(); // apply transformations and properties recursively
197 
198  private:
200  vtkTimeStamp m_PathTime;
201 
202  // prepare all mitk::mappers for rendering
203  void PrepareMapperQueue();
204 
206  void PropagateRenderInfoToMappers();
207 
209  bool Initialize2DvtkCamera();
210 
211  bool m_InitNeeded;
212  bool m_ResizeNeeded;
213  MapperSlotId m_CameraInitializedForMapperID;
214 
215  // Picking
216  vtkWorldPointPicker *m_WorldPointPicker;
217  vtkPointPicker *m_PointPicker;
218  vtkCellPicker *m_CellPicker;
219 
220  PickingMode m_PickingMode;
221 
222  // Explicit use of SmartPointer to avoid circular #includes
223  itk::SmartPointer<mitk::Mapper> m_CurrentWorldPlaneGeometryMapper;
224 
225  vtkLightKit *m_LightKit;
226 
227  // sorted list of mappers
228  MappersMapType m_MappersMap;
229 
230  // rendering of text
231  vtkRenderer *m_TextRenderer;
232  typedef std::map<unsigned int, vtkTextActor *> TextMapType;
233  TextMapType m_TextCollection;
234 
241  vtkInformation* m_VtkRenderInfo = nullptr;
242  };
243 } // namespace mitk
244 
245 #endif
#define MITKCORE_EXPORT
Class for nodes of the DataTree.
Definition: mitkDataNode.h:64
Data management class that handles 'was created by' relations.
itkGetEnumMacro(PickingMode, PickingMode)
vtkTextProperty * GetTextLabelProperty(int text_id)
CGetTextLabelProperty an be used in order to get a vtkTextProperty for a specific text_id....
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)
const vtkCellPicker * GetCellPicker() const
virtual void Update(mitk::DataNode *datatreenode)
MappersMapType GetMappersMap() const
~VtkPropRenderer() override
void SetPropertyKeys(vtkInformation *info)
Store/propagate vtkInformation during rendering.
mitk::DataNode * PickObject(const Point2D &displayPosition, Point3D &worldPosition) const override
Determines the object (mitk::DataNode) closest to the current position by means of picking.
void InitRenderer(vtkRenderWindow *renderwindow) override
Initialize the base renderer with a vtk render window. Set the new renderer for the camera controller...
virtual void MakeCurrent()
VtkPropRenderer(const char *name="VtkPropRenderer", vtkRenderWindow *renWin=nullptr)
int Render(RenderType type)
static bool useImmediateModeRendering()
void PickWorldPoint(const Point2D &displayPoint, Point3D &worldPoint) const override
Pick a world coordinate (x,y,z) given a display coordinate (x,y).
mitkNewMacro2Param(VtkPropRenderer, const char *, vtkRenderWindow *)
void SetMapperID(const MapperSlotId mapperId) override
Set the used mapperID.
void InitPathTraversal()
Used by vtkPointPicker/vtkPicker. This will query a list of all objects in MITK and provide every vtk...
const vtkPointPicker * GetPointPicker() const
void Update() override
mitkClassMacro(VtkPropRenderer, BaseRenderer)
void SetDataStorage(mitk::DataStorage *storage) override
set the datastorage that will be used for rendering
virtual void PrepareRender()
This methods contains all method neceassary before a VTK Render() call.
virtual void ReleaseGraphicsResources(vtkWindow *renWin)
Release vtk-based graphics resources. Called by vtkMitkRenderProp::ReleaseGraphicsResources.
std::map< int, Mapper * > MappersMapType
bool SetWorldGeometryToDataStorageBounds() override
const vtkWorldPointPicker * GetWorldPointPicker() const
void InitSize(int w, int h) override
Set the initial size for the render window.
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
Set a new size for the render window.
unsigned int MapperSlotId
Definition: mitkCommon.h:29
#define DEPRECATED(func)
Definition: mitkCommon.h:175
Find image slices visible on a given plane.