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