Medical Imaging Interaction Toolkit  2018.04.99-aba3194f
Medical Imaging Interaction Toolkit
mitkPointSetVtkMapper2D.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 mitkPointSetVtkMapper2D_h
14 #define mitkPointSetVtkMapper2D_h
15 
16 #include "mitkBaseRenderer.h"
18 #include "mitkVtkMapper.h"
19 #include <MitkCoreExports.h>
21 
22 // VTK
23 #include <vtkSmartPointer.h>
24 class vtkActor;
25 class vtkPropAssembly;
26 class vtkPolyData;
27 class vtkPolyDataMapper;
28 class vtkGlyphSource2D;
29 class vtkGlyph3D;
30 class vtkFloatArray;
31 class vtkCellArray;
32 
33 namespace mitk
34 {
35  class PointSet;
36 
118  {
119  public:
121 
122  itkFactorylessNewMacro(Self);
123 
124  itkCloneMacro(Self);
125 
126  virtual const mitk::PointSet *GetInput() const;
127 
129  vtkProp *GetVtkProp(mitk::BaseRenderer *renderer) override;
130 
132  static void SetDefaultProperties(mitk::DataNode *node, mitk::BaseRenderer *renderer = nullptr, bool overwrite = false);
133 
136  {
137  public:
138  /* constructor */
139  LocalStorage();
140 
141  /* destructor */
142  ~LocalStorage() override;
143 
144  // points
145  vtkSmartPointer<vtkPoints> m_UnselectedPoints;
146  vtkSmartPointer<vtkPoints> m_SelectedPoints;
147  vtkSmartPointer<vtkPoints> m_ContourPoints;
148 
149  // scales
150  vtkSmartPointer<vtkFloatArray> m_UnselectedScales;
151  vtkSmartPointer<vtkFloatArray> m_SelectedScales;
152 
153  // distances
154  vtkSmartPointer<vtkFloatArray> m_DistancesBetweenPoints;
155 
156  // lines
157  vtkSmartPointer<vtkCellArray> m_ContourLines;
158 
159  // glyph source (provides different shapes for the points)
160  vtkSmartPointer<vtkGlyphSource2D> m_UnselectedGlyphSource2D;
161  vtkSmartPointer<vtkGlyphSource2D> m_SelectedGlyphSource2D;
162 
163  // glyph
164  vtkSmartPointer<vtkGlyph3D> m_UnselectedGlyph3D;
165  vtkSmartPointer<vtkGlyph3D> m_SelectedGlyph3D;
166 
167  // polydata
168  vtkSmartPointer<vtkPolyData> m_VtkUnselectedPointListPolyData;
169  vtkSmartPointer<vtkPolyData> m_VtkSelectedPointListPolyData;
170  vtkSmartPointer<vtkPolyData> m_VtkContourPolyData;
171 
172  // actor
173  vtkSmartPointer<vtkActor> m_UnselectedActor;
174  vtkSmartPointer<vtkActor> m_SelectedActor;
175  vtkSmartPointer<vtkActor> m_ContourActor;
176  vtkSmartPointer<vtkTextActor> m_VtkTextActor;
177 
178  std::vector<vtkSmartPointer<vtkTextActor>> m_VtkTextLabelActors;
179  std::vector<vtkSmartPointer<vtkTextActor>> m_VtkTextDistanceActors;
180  std::vector<vtkSmartPointer<vtkTextActor>> m_VtkTextAngleActors;
181 
182  // mappers
183  vtkSmartPointer<vtkPolyDataMapper> m_VtkUnselectedPolyDataMapper;
184  vtkSmartPointer<vtkPolyDataMapper> m_VtkSelectedPolyDataMapper;
185  vtkSmartPointer<vtkPolyDataMapper> m_VtkContourPolyDataMapper;
186 
187  // propassembly
188  vtkSmartPointer<vtkPropAssembly> m_PropAssembly;
189  };
190 
193 
194  protected:
195  /* constructor */
197 
198  /* destructor */
199  ~PointSetVtkMapper2D() override;
200 
201  /* \brief Applies the color and opacity properties and calls CreateVTKRenderObjects */
202  void GenerateDataForRenderer(mitk::BaseRenderer *renderer) override;
203  /* \brief Called in mitk::Mapper::Update
204  * If TimeSlicedGeometry or time step is not valid of point set: reset mapper so that nothing is
205  * displayed e.g. toggle visiblity of the propassembly */
206  void ResetMapper(BaseRenderer *renderer) override;
207 
208  /* \brief Fills the vtk objects, thus it is only called when the point set has been changed.
209  * This function iterates over the input point set and determines the glyphs which lie in a specific
210  * range around the current slice. Those glyphs are rendered using a specific shape defined in vtk glyph source
211  * to mark each point. The shape can be changed in MITK using the property "PointSet.2D.shape".
212  *
213  * There were issues when rendering vtk glyphs in the 2D-render windows. By default, the glyphs are
214  * rendered within the x-y plane in each 2D-render window, so you would only see them from the
215  * side in the saggital and coronal 2D-render window. The solution to this is to rotate the glyphs in order
216  * to be ortogonal to the current view vector. To achieve this, the rotation (vtktransform) of the current
217  * PlaneGeometry is applied to the orienation of the glyphs. */
218  virtual void CreateVTKRenderObjects(mitk::BaseRenderer *renderer);
219 
220  // member variables holding the current value of the properties used in this mapper
221  bool m_ShowContour; // "show contour" property
222  bool m_CloseContour; // "close contour" property
223  bool m_ShowPoints; // "show points" property
224  bool m_ShowDistances; // "show distances" property
225  int m_DistancesDecimalDigits; // "distance decimal digits" property
226  bool m_ShowAngles; // "show angles" property
227  bool m_ShowDistantLines; // "show distant lines" property
228  int m_LineWidth; // "line width" property
229  int m_PointLineWidth; // "point line width" property
230  float m_Point2DSize; // "point 2D size" property
231  int m_IDShapeProperty; // ID for mitkPointSetShape Enumeration Property "Pointset.2D.shape"
232  bool m_FillShape; // "Pointset.2D.fill shape" property
233  float m_DistanceToPlane; // "Pointset.2D.distance to plane" property
234  };
235 
236 } // namespace mitk
237 
238 #endif /* mitkPointSetVtkMapper2D_h */
std::vector< vtkSmartPointer< vtkTextActor > > m_VtkTextLabelActors
Base class for mapper specific rendering ressources.
Definition: mitkMapper.h:193
#define MITKCORE_EXPORT
vtkSmartPointer< vtkPropAssembly > m_PropAssembly
vtkSmartPointer< vtkPolyDataMapper > m_VtkSelectedPolyDataMapper
Organizes the rendering process.
vtkSmartPointer< vtkGlyph3D > m_UnselectedGlyph3D
DataCollection - Class to facilitate loading/accessing structured data.
vtkSmartPointer< vtkPolyData > m_VtkUnselectedPointListPolyData
vtkSmartPointer< vtkFloatArray > m_DistancesBetweenPoints
Base class of all Vtk Mappers in order to display primitives by exploiting Vtk functionality.
Definition: mitkVtkMapper.h:48
mitk::LocalStorageHandler< LocalStorage > m_LSH
The LocalStorageHandler holds all (three) LocalStorages for the three 2D render windows.
Base class of all mappers, Vtk as well as OpenGL mappers.
Definition: mitkMapper.h:49
vtkSmartPointer< vtkFloatArray > m_UnselectedScales
vtkSmartPointer< vtkPolyDataMapper > m_VtkContourPolyDataMapper
std::vector< vtkSmartPointer< vtkTextActor > > m_VtkTextAngleActors
vtkSmartPointer< vtkPolyDataMapper > m_VtkUnselectedPolyDataMapper
vtkSmartPointer< vtkFloatArray > m_SelectedScales
Vtk-based 2D mapper for PointSet.
vtkSmartPointer< vtkPoints > m_UnselectedPoints
vtkSmartPointer< vtkPolyData > m_VtkSelectedPointListPolyData
Data structure which stores a set of points.
Definition: mitkPointSet.h:71
vtkSmartPointer< vtkPolyData > m_VtkContourPolyData
Internal class holding the mapper, actor, etc. for each of the 3 2D render windows.
#define mitkClassMacro(className, SuperClassName)
Definition: mitkCommon.h:40
vtkSmartPointer< vtkCellArray > m_ContourLines
vtkSmartPointer< vtkGlyphSource2D > m_SelectedGlyphSource2D
vtkSmartPointer< vtkGlyph3D > m_SelectedGlyph3D
vtkSmartPointer< vtkTextActor > m_VtkTextActor
vtkSmartPointer< vtkGlyphSource2D > m_UnselectedGlyphSource2D
std::vector< vtkSmartPointer< vtkTextActor > > m_VtkTextDistanceActors
Class for nodes of the DataTree.
Definition: mitkDataNode.h:57