Medical Imaging Interaction Toolkit  2024.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 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 
90  void SetDataStorage(
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  };
118  itkSetEnumMacro(PickingMode, PickingMode);
119  itkGetEnumMacro(PickingMode, PickingMode);
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 
159  bool SetWorldGeometryToDataStorageBounds() override;
160 
165  void InitPathTraversal();
166 
171  vtkAssemblyPath *GetNextPath();
172 
173  int GetNumberOfPaths();
174 
175  const vtkWorldPointPicker *GetWorldPointPicker() const;
176  const vtkPointPicker *GetPointPicker() const;
177  const vtkCellPicker *GetCellPicker() const;
178 
183  virtual void ReleaseGraphicsResources(vtkWindow *renWin);
184 
185  MappersMapType GetMappersMap() const;
186 
187  static bool useImmediateModeRendering();
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
mitk::VtkPropRenderer::RenderType
RenderType
Definition: mitkVtkPropRenderer.h:71
mitkNewMacro2Param
#define mitkNewMacro2Param(classname, typea, typeb)
Definition: mitkCommon.h:81
mitkDataStorage.h
vtkSmartPointer< vtkAssemblyPaths >
DEPRECATED
#define DEPRECATED(func)
Definition: mitkCommon.h:175
mitk::VtkPropRenderer::PickingMode
PickingMode
Definition: mitkVtkPropRenderer.h:102
itk::SmartPointer< mitk::Mapper >
mitk::VtkPropRenderer
VtkPropRenderer.
Definition: mitkVtkPropRenderer.h:55
mitk::VtkPropRenderer::Overlay
@ Overlay
Definition: mitkVtkPropRenderer.h:75
mitk
Find image slices visible on a given plane.
Definition: RenderingTests.dox:1
mitk::VtkPropRenderer::Translucent
@ Translucent
Definition: mitkVtkPropRenderer.h:74
MitkCoreExports.h
mitk::Point< ScalarType, 2 >
mitk::VtkPropRenderer::PointPicking
@ PointPicking
Definition: mitkVtkPropRenderer.h:105
mitk::DataStorage
Data management class that handles 'was created by' relations.
Definition: mitkDataStorage.h:43
mitk::VtkPropRenderer::MappersMapType
std::map< int, Mapper * > MappersMapType
Definition: mitkVtkPropRenderer.h:66
mitkClassMacro
#define mitkClassMacro(className, SuperClassName)
Definition: mitkCommon.h:36
mitk::VtkPropRenderer::Opaque
@ Opaque
Definition: mitkVtkPropRenderer.h:73
mitk::BaseRenderer
Definition: mitkBaseRenderer.h:56
mitkRenderingManager.h
MapperSlotId
unsigned int MapperSlotId
Definition: mitkCommon.h:29
mitkBaseRenderer.h
MITKCORE_EXPORT
#define MITKCORE_EXPORT
Definition: MitkCoreExports.h:15
mitk::DataNode
Class for nodes of the DataTree.
Definition: mitkDataNode.h:63
mitk::VtkPropRenderer::WorldPointPicking
@ WorldPointPicking
Definition: mitkVtkPropRenderer.h:104