Slicer  5.0
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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
28 class vtkMRMLNode;
32 class vtkMRMLViewNode;
34 class vtkMRMLVolumeNode;
36 
37 // VTK includes
38 class vtkColorTransferFunction;
39 class vtkLookupTable;
40 class vtkPiecewiseFunction;
41 class vtkScalarsToColors;
42 class vtkVolumeProperty;
43 
44 // STD includes
45 #include <map>
46 #include <vector>
47 
58 class VTK_SLICER_VOLUMERENDERING_MODULE_LOGIC_EXPORT vtkSlicerVolumeRenderingLogic
59  : public vtkSlicerModuleLogic
60 {
61 public:
62 
65  void PrintSelf(ostream& os, vtkIndent indent) override;
66 
71  void RegisterRenderingMethod(const char* methodName,
72  const char* displayNodeClassName);
74  std::map<std::string, std::string> GetRenderingMethods();
79  vtkSetStringMacro(DefaultRenderingMethod);
80  vtkGetStringMacro(DefaultRenderingMethod);
81 
86  vtkSetMacro(UseLinearRamp, bool);
87  vtkGetMacro(UseLinearRamp, bool);
88 
98  vtkMRMLVolumeRenderingDisplayNode* CreateDefaultVolumeRenderingNodes(vtkMRMLVolumeNode* volumeNode);
99 
111  vtkMRMLVolumeRenderingDisplayNode* CreateVolumeRenderingDisplayNode(const char* renderingClassName = nullptr);
112 
119  void AddVolumeRenderingDisplayNode(vtkMRMLVolumeRenderingDisplayNode* node);
120 
123  void RemoveVolumeRenderingDisplayNode(vtkMRMLVolumeRenderingDisplayNode* node);
124 
127  void AddAllVolumeRenderingDisplayNodes();
128 
131  void RemoveAllVolumeRenderingDisplayNodes();
132 
135  void ChangeVolumeRenderingMethod(const char* displayNodeClassName = nullptr);
136 
141  bool SetRecommendedVolumeRenderingProperties(vtkMRMLVolumeRenderingDisplayNode* vrDisplayNode);
142 
152  void CopyDisplayToVolumeRenderingDisplayNode(
154  vtkMRMLVolumeDisplayNode* displayNode = nullptr);
155 
161  void CopyScalarDisplayToVolumeRenderingDisplayNode(
162  vtkMRMLVolumeRenderingDisplayNode* volumeRenderingDisplayNode,
163  vtkMRMLScalarVolumeDisplayNode* scalarDisplayNode = nullptr);
164 
170  void CopyLabelMapDisplayToVolumeRenderingDisplayNode(
171  vtkMRMLVolumeRenderingDisplayNode* volumeRenderingDisplayNode,
172  vtkMRMLLabelMapVolumeDisplayNode* labelMapDisplayNode = nullptr);
173 
189  void SetThresholdToVolumeProp(
190  double scalarRange[2], double threshold[2],
191  vtkVolumeProperty* node,
192  bool linearRamp = false, bool stayUpAtUpperLimit = false);
193 
216  void SetWindowLevelToVolumeProp(
217  double scalarRange[2], double windowLevel[2],
218  vtkLookupTable* lut, vtkVolumeProperty* node);
219 
223  void SetGradientOpacityToVolumeProp(
224  double scalarRange[2], vtkVolumeProperty* node);
225 
229  void SetLabelMapToVolumeProp(
230  vtkScalarsToColors* lut, vtkVolumeProperty* node);
231 
236  void UpdateDisplayNodeFromVolumeNode(vtkMRMLVolumeRenderingDisplayNode *displayNode,
237  vtkMRMLVolumeNode *volumeNode,
238  vtkMRMLVolumePropertyNode *propNode = nullptr,
239  vtkMRMLNode *roiNode = nullptr,
240  bool createROI=true);
241 
243  vtkMRMLDisplayableNode* CreateROINode(vtkMRMLVolumeRenderingDisplayNode* displayNode);
244 
246  void RemoveViewFromVolumeDisplayNodes(vtkMRMLVolumeNode *volumeNode,
247  vtkMRMLViewNode *viewNode);
248 
250  vtkMRMLVolumeRenderingDisplayNode* GetVolumeRenderingDisplayNodeByID(vtkMRMLVolumeNode *volumeNode,
251  char *displayNodeID);
252 
254  vtkMRMLVolumeRenderingDisplayNode* GetVolumeRenderingDisplayNodeForViewNode(
255  vtkMRMLVolumeNode *volumeNode,
256  vtkMRMLViewNode *viewNode);
257 
259  vtkMRMLVolumeRenderingDisplayNode* GetVolumeRenderingDisplayNodeForViewNode(
260  vtkMRMLViewNode *viewNode);
261 
263  vtkMRMLVolumeRenderingDisplayNode* GetFirstVolumeRenderingDisplayNode(vtkMRMLVolumeNode *volumeNode);
264 
266  vtkMRMLVolumeRenderingDisplayNode* GetFirstVolumeRenderingDisplayNodeByROINode(vtkMRMLNode* roiNode);
267 
268  void UpdateTranferFunctionRangeFromImage(vtkMRMLVolumeRenderingDisplayNode* vspNode);
269 
273  void FitROIToVolume(vtkMRMLVolumeRenderingDisplayNode* vspNode);
274 
277  vtkMRMLVolumePropertyNode* AddVolumePropertyFromFile (const char* filename);
278 
281  vtkMRMLShaderPropertyNode* AddShaderPropertyFromFile (const char* filename);
282 
289  vtkMRMLScene* GetPresetsScene();
290 
297  void AddPreset(vtkMRMLVolumePropertyNode* preset, vtkImageData* icon = nullptr, bool appendToEnd=false);
298 
301  void RemovePreset(vtkMRMLVolumePropertyNode* preset);
302 
305  int LoadCustomPresetsScene(const char* sceneFilePath);
306 
310  static const char* GetIconVolumeReferenceRole() { return "IconVolume"; };
311 
317  vtkMRMLVolumePropertyNode* GetPresetByName(const char *presetName);
318 
321  bool IsDifferentFunction(vtkPiecewiseFunction* function1,
322  vtkPiecewiseFunction* function2) const;
323 
326  bool IsDifferentFunction(vtkColorTransferFunction* function1,
327  vtkColorTransferFunction* function2) const;
328 
329  vtkSetMacro(DefaultROIClassName, std::string);
330  vtkGetMacro(DefaultROIClassName, std::string);
331 
332 protected:
334  ~vtkSlicerVolumeRenderingLogic() override;
335 
336  void SetMRMLSceneInternal(vtkMRMLScene* scene) override;
337  // Register local MRML nodes
338  void RegisterNodes() override;
339 
341  void ObserveMRMLScene() override;
342  void OnMRMLSceneNodeAdded(vtkMRMLNode* node) override;
343  void OnMRMLSceneNodeRemoved(vtkMRMLNode* node) override;
344  void OnMRMLNodeModified(vtkMRMLNode* node) override;
345 
346  // Update from
347  void UpdateVolumeRenderingDisplayNode(vtkMRMLVolumeRenderingDisplayNode* node);
348 
349  std::map<std::string, std::string> RenderingMethods;
357 
359 
360  typedef std::vector<vtkMRMLNode*> DisplayNodesType;
362 
363  bool LoadPresets(vtkMRMLScene* scene);
365 
366  std::string DefaultROIClassName;
367 private:
369  void operator=(const vtkSlicerVolumeRenderingLogic&) = delete;
370 };
371 
372 #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:57
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.