Medical Imaging Interaction Toolkit  2016.11.0
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,
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 #ifndef mitkVtkPropRenderer_h
18 #define mitkVtkPropRenderer_h
19 
20 #include "mitkBaseRenderer.h"
21 #include <MitkCoreExports.h>
22 #include <itkCommand.h>
23 #include <mitkDataStorage.h>
24 #include <mitkRenderingManager.h>
25 
26 #include <map>
27 #include <utility>
28 
29 class vtkRenderWindow;
30 class vtkLight;
31 class vtkLightKit;
32 class vtkWorldPointPicker;
33 class vtkPointPicker;
34 class vtkCellPicker;
35 class vtkTextActor;
36 class vtkTextProperty;
37 class vtkAssemblyPath;
38 
39 #include <vtkAssemblyPaths.h>
40 #include <vtkSmartPointer.h>
41 
42 namespace mitk
43 {
44  class Mapper;
45 
60  {
61  // Workaround for Displaylistbug
62  private:
63  bool didCount;
64  void checkState();
65 
66  // Workaround END
67 
68  public:
70  mitkNewMacro3Param(VtkPropRenderer, const char *, vtkRenderWindow *, mitk::RenderingManager *);
72  const char *,
73  vtkRenderWindow *,
76 
77  typedef std::map<int, Mapper *> MappersMapType;
78 
79  // Render - called by vtkMitkRenderProp, returns the number of props rendered
81  {
85  Volumetric
86  };
87 
88  int Render(RenderType type);
89 
91  virtual void PrepareRender();
92 
93  // Active current renderwindow
94  virtual void MakeCurrent();
95 
96  virtual void SetDataStorage(
97  mitk::DataStorage *storage) override;
98 
99  virtual void InitRenderer(vtkRenderWindow *renderwindow) override;
100  virtual void Update(mitk::DataNode *datatreenode);
101  virtual void SetMapperID(const MapperSlotId mapperId) override;
102 
103  // Size
104  virtual void InitSize(int w, int h) override;
105  virtual void Resize(int w, int h) override;
106 
107  // Picking
109  {
112  CellPicking
113  };
124  itkSetEnumMacro(PickingMode, PickingMode);
125  itkGetEnumMacro(PickingMode, PickingMode);
126 
127  virtual void PickWorldPoint(const Point2D &displayPoint, Point3D &worldPoint) const override;
128  virtual mitk::DataNode *PickObject(const Point2D &displayPosition, Point3D &worldPosition) const override;
129 
140  DEPRECATED(int WriteSimpleText(std::string text,
141  double posX,
142  double posY,
143  double color1 = 0.0,
144  double color2 = 1.0,
145  double color3 = 0.0,
146  float opacity = 1.0));
147 
155  DEPRECATED(vtkTextProperty *GetTextLabelProperty(int text_id));
156 
165  virtual bool SetWorldGeometryToDataStorageBounds() override;
166 
171  void InitPathTraversal();
172 
177  vtkAssemblyPath *GetNextPath();
178 
179  int GetNumberOfPaths();
180 
181  const vtkWorldPointPicker *GetWorldPointPicker() const;
182  const vtkPointPicker *GetPointPicker() const;
183  const vtkCellPicker *GetCellPicker() const;
184 
189  virtual void ReleaseGraphicsResources(vtkWindow *renWin);
190 
191  MappersMapType GetMappersMap() const;
192 
193  static bool useImmediateModeRendering();
194 
195  protected:
197  const char *name = "VtkPropRenderer",
198  vtkRenderWindow *renWin = nullptr,
199  mitk::RenderingManager *rm = nullptr,
201  virtual ~VtkPropRenderer();
202  virtual void Update() override;
203 
204  static void RenderingCallback(vtkObject *caller, unsigned long eid, void *clientdata, void *calldata);
205 
206  virtual void UpdatePaths(); // apply transformations and properties recursively
207 
208  private:
209  vtkSmartPointer<vtkAssemblyPaths> m_Paths;
210  vtkTimeStamp m_PathTime;
211 
212  // prepare all mitk::mappers for rendering
213  void PrepareMapperQueue();
214 
216  bool Initialize2DvtkCamera();
217 
218  bool m_InitNeeded;
219  bool m_ResizeNeeded;
220  MapperSlotId m_CameraInitializedForMapperID;
221 
222  // Picking
223  vtkWorldPointPicker *m_WorldPointPicker;
224  vtkPointPicker *m_PointPicker;
225  vtkCellPicker *m_CellPicker;
226 
227  PickingMode m_PickingMode;
228 
229  // Explicit use of SmartPointer to avoid circular #includes
230  itk::SmartPointer<mitk::Mapper> m_CurrentWorldPlaneGeometryMapper;
231 
232  vtkLightKit *m_LightKit;
233 
234  // sorted list of mappers
235  MappersMapType m_MappersMap;
236 
237  // rendering of text
238  vtkRenderer *m_TextRenderer;
239  typedef std::map<unsigned int, vtkTextActor *> TextMapType;
240  TextMapType m_TextCollection;
241  };
242 } // namespace mitk
243 
244 #endif /* mitkVtkPropRenderer_h */
std::map< int, Mapper * > MappersMapType
Data management class that handles 'was created by' relations.
#define MITKCORE_EXPORT
Organizes the rendering process.
static void Update(vtkPolyData *)
Definition: mitkSurface.cpp:35
DataCollection - Class to facilitate loading/accessing structured data.
#define DEPRECATED(func)
Definition: mitkCommon.h:183
#define mitkNewMacro4Param(classname, typea, typeb, typec, typed)
Definition: mitkCommon.h:115
Manager for coordinating the rendering process.
#define mitkClassMacro(className, SuperClassName)
Definition: mitkCommon.h:44
#define mitkNewMacro3Param(classname, typea, typeb, typec)
Definition: mitkCommon.h:102
unsigned int MapperSlotId
Definition: mitkCommon.h:37
Class for nodes of the DataTree.
Definition: mitkDataNode.h:66