Slicer  4.11
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
vtkSlicerVolumeRenderingLogic.h
Go to the documentation of this file.
1 /*=auto=========================================================================
2 
3  Portions (c) Copyright 2005 Brigham and Women's Hospital (BWH) All Rights Reserved.
4 
5  See COPYRIGHT.txt
6  or http://www.slicer.org/copyright/copyright.txt for details.
7 
8  Program: 3D Slicer
9  Module: $RCSfile: vtkSlicerVolumeRenderingLogic.h,v $
10  Date: $Date: 2006/01/08 04:48:05 $
11  Version: $Revision: 1.45 $
12 
13 =========================================================================auto=*/
14 
15 #ifndef __vtkSlicerVolumeRenderingLogic_h
16 #define __vtkSlicerVolumeRenderingLogic_h
17 
18 // VolumeRendering includes
19 #include "vtkSlicerVolumeRenderingModuleLogicExport.h"
21 
22 // Slicer includes
23 #include "vtkSlicerModuleLogic.h"
24 
25 // MRML includes
27 class vtkMRMLNode;
30 class vtkMRMLViewNode;
32 class vtkMRMLVolumeNode;
35 
36 // VTK includes
37 class vtkColorTransferFunction;
38 class vtkLookupTable;
39 class vtkPiecewiseFunction;
40 class vtkScalarsToColors;
41 class vtkVolumeProperty;
42 
43 // STD includes
44 #include <map>
45 #include <vector>
46 
57 class VTK_SLICER_VOLUMERENDERING_MODULE_LOGIC_EXPORT vtkSlicerVolumeRenderingLogic
58  : public vtkSlicerModuleLogic
59 {
60 public:
61 
64  void PrintSelf(ostream& os, vtkIndent indent) override;
65 
70  void RegisterRenderingMethod(const char* methodName,
71  const char* displayNodeClassName);
73  std::map<std::string, std::string> GetRenderingMethods();
78  vtkSetStringMacro(DefaultRenderingMethod);
79  vtkGetStringMacro(DefaultRenderingMethod);
80 
85  vtkSetMacro(UseLinearRamp, bool);
86  vtkGetMacro(UseLinearRamp, bool);
87 
97  vtkMRMLVolumeRenderingDisplayNode* CreateDefaultVolumeRenderingNodes(vtkMRMLVolumeNode* volumeNode);
98 
110  vtkMRMLVolumeRenderingDisplayNode* CreateVolumeRenderingDisplayNode(const char* renderingClassName = nullptr);
111 
118  void AddVolumeRenderingDisplayNode(vtkMRMLVolumeRenderingDisplayNode* node);
119 
122  void RemoveVolumeRenderingDisplayNode(vtkMRMLVolumeRenderingDisplayNode* node);
123 
126  void AddAllVolumeRenderingDisplayNodes();
127 
130  void RemoveAllVolumeRenderingDisplayNodes();
131 
134  void ChangeVolumeRenderingMethod(const char* displayNodeClassName = nullptr);
135 
140  bool SetRecommendedVolumeRenderingProperties(vtkMRMLVolumeRenderingDisplayNode* vrDisplayNode);
141 
151  void CopyDisplayToVolumeRenderingDisplayNode(
153  vtkMRMLVolumeDisplayNode* displayNode = nullptr);
154 
160  void CopyScalarDisplayToVolumeRenderingDisplayNode(
161  vtkMRMLVolumeRenderingDisplayNode* volumeRenderingDisplayNode,
162  vtkMRMLScalarVolumeDisplayNode* scalarDisplayNode = nullptr);
163 
169  void CopyLabelMapDisplayToVolumeRenderingDisplayNode(
170  vtkMRMLVolumeRenderingDisplayNode* volumeRenderingDisplayNode,
171  vtkMRMLLabelMapVolumeDisplayNode* labelMapDisplayNode = nullptr);
172 
188  void SetThresholdToVolumeProp(
189  double scalarRange[2], double threshold[2],
190  vtkVolumeProperty* node,
191  bool linearRamp = false, bool stayUpAtUpperLimit = false);
192 
215  void SetWindowLevelToVolumeProp(
216  double scalarRange[2], double windowLevel[2],
217  vtkLookupTable* lut, vtkVolumeProperty* node);
218 
222  void SetGradientOpacityToVolumeProp(
223  double scalarRange[2], vtkVolumeProperty* node);
224 
228  void SetLabelMapToVolumeProp(
229  vtkScalarsToColors* lut, vtkVolumeProperty* node);
230 
235  void UpdateDisplayNodeFromVolumeNode(vtkMRMLVolumeRenderingDisplayNode *displayNode,
236  vtkMRMLVolumeNode *volumeNode,
237  vtkMRMLVolumePropertyNode *propNode = nullptr,
238  vtkMRMLNode *roiNode = nullptr);
239 
241  void RemoveViewFromVolumeDisplayNodes(vtkMRMLVolumeNode *volumeNode,
242  vtkMRMLViewNode *viewNode);
243 
245  vtkMRMLVolumeRenderingDisplayNode* GetVolumeRenderingDisplayNodeByID(vtkMRMLVolumeNode *volumeNode,
246  char *displayNodeID);
247 
249  vtkMRMLVolumeRenderingDisplayNode* GetVolumeRenderingDisplayNodeForViewNode(
250  vtkMRMLVolumeNode *volumeNode,
251  vtkMRMLViewNode *viewNode);
252 
254  vtkMRMLVolumeRenderingDisplayNode* GetVolumeRenderingDisplayNodeForViewNode(
255  vtkMRMLViewNode *viewNode);
256 
258  vtkMRMLVolumeRenderingDisplayNode* GetFirstVolumeRenderingDisplayNode(vtkMRMLVolumeNode *volumeNode);
259 
261  vtkMRMLVolumeRenderingDisplayNode* GetFirstVolumeRenderingDisplayNodeByROINode(vtkMRMLNode* roiNode);
262 
263  void UpdateTranferFunctionRangeFromImage(vtkMRMLVolumeRenderingDisplayNode* vspNode);
264 
268  void FitROIToVolume(vtkMRMLVolumeRenderingDisplayNode* vspNode);
269 
272  vtkMRMLVolumePropertyNode* AddVolumePropertyFromFile (const char* filename);
273 
276  vtkMRMLShaderPropertyNode* AddShaderPropertyFromFile (const char* filename);
277 
284  vtkMRMLScene* GetPresetsScene();
285 
291  void AddPreset(vtkMRMLVolumePropertyNode* preset, vtkImageData* icon = nullptr);
292 
295  void RemovePreset(vtkMRMLVolumePropertyNode* preset);
296 
299  int LoadCustomPresetsScene(const char* sceneFilePath);
300 
304  static const char* GetIconVolumeReferenceRole() { return "IconVolume"; };
305 
311  vtkMRMLVolumePropertyNode* GetPresetByName(const char *presetName);
312 
315  bool IsDifferentFunction(vtkPiecewiseFunction* function1,
316  vtkPiecewiseFunction* function2) const;
317 
320  bool IsDifferentFunction(vtkColorTransferFunction* function1,
321  vtkColorTransferFunction* function2) const;
322 
323  vtkSetMacro(DefaultROIClassName, std::string);
324  vtkGetMacro(DefaultROIClassName, std::string);
325 
326 protected:
328  ~vtkSlicerVolumeRenderingLogic() override;
329 
330  void SetMRMLSceneInternal(vtkMRMLScene* scene) override;
331  // Register local MRML nodes
332  void RegisterNodes() override;
333 
335  void ObserveMRMLScene() override;
336  void OnMRMLSceneNodeAdded(vtkMRMLNode* node) override;
337  void OnMRMLSceneNodeRemoved(vtkMRMLNode* node) override;
338  void OnMRMLNodeModified(vtkMRMLNode* node) override;
339 
340  // Update from
341  void UpdateVolumeRenderingDisplayNode(vtkMRMLVolumeRenderingDisplayNode* node);
342 
343  std::map<std::string, std::string> RenderingMethods;
351 
353 
354  typedef std::vector<vtkMRMLNode*> DisplayNodesType;
356 
357  bool LoadPresets(vtkMRMLScene* scene);
359 
360  std::string DefaultROIClassName;
361 private:
363  void operator=(const vtkSlicerVolumeRenderingLogic&) = delete;
364 };
365 
366 #endif
void PrintSelf(ostream &os, vtkIndent indent) override
static vtkSlicerModuleLogic * New()
The Usual vtk class functions.
vtkMRMLShaderPropertyNode volume shader custom code and custom uniform variables defined by users or ...
MRML node for representing a volume display attributes.
std::vector< vtkMRMLNode * > DisplayNodesType
virtual void OnMRMLNodeModified(vtkMRMLNode *)
A set of MRML Nodes that supports serialization and undo/redo.
Definition: vtkMRMLScene.h:61
virtual void OnMRMLSceneNodeAdded(vtkMRMLNode *)
virtual void OnMRMLSceneNodeRemoved(vtkMRMLNode *)
virtual void ObserveMRMLScene()
virtual void SetMRMLSceneInternal(vtkMRMLScene *newScene)
MRML node for representing a volume (image stack).
MRML node to represent a 3D view.
std::map< std::string, std::string > RenderingMethods
MRML node for representing a volume (image stack).
Abstract Superclass for all specific types of MRML nodes.
Definition: vtkMRMLNode.h:167
vtkMRMLVolumePropertyNode contains the transfer functions (scalar opacity, color and gradient opacity...
MRML node for representing a volume display attributes.
MRML node for representing a volume display attributes.