Slicer  5.2
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 
100  vtkMRMLVolumeRenderingDisplayNode* CreateDefaultVolumeRenderingNodes(vtkMRMLVolumeNode* volumeNode);
101 
113  vtkMRMLVolumeRenderingDisplayNode* CreateVolumeRenderingDisplayNode(const char* renderingClassName = nullptr);
114 
121  void AddVolumeRenderingDisplayNode(vtkMRMLVolumeRenderingDisplayNode* node);
122 
125  void RemoveVolumeRenderingDisplayNode(vtkMRMLVolumeRenderingDisplayNode* node);
126 
129  void AddAllVolumeRenderingDisplayNodes();
130 
133  void RemoveAllVolumeRenderingDisplayNodes();
134 
137  void ChangeVolumeRenderingMethod(const char* displayNodeClassName = nullptr);
138 
143  bool SetRecommendedVolumeRenderingProperties(vtkMRMLVolumeRenderingDisplayNode* vrDisplayNode);
144 
154  void CopyDisplayToVolumeRenderingDisplayNode(
156  vtkMRMLVolumeDisplayNode* displayNode = nullptr);
157 
163  void CopyScalarDisplayToVolumeRenderingDisplayNode(
164  vtkMRMLVolumeRenderingDisplayNode* volumeRenderingDisplayNode,
165  vtkMRMLScalarVolumeDisplayNode* scalarDisplayNode = nullptr);
166 
172  void CopyLabelMapDisplayToVolumeRenderingDisplayNode(
173  vtkMRMLVolumeRenderingDisplayNode* volumeRenderingDisplayNode,
174  vtkMRMLLabelMapVolumeDisplayNode* labelMapDisplayNode = nullptr);
175 
191  void SetThresholdToVolumeProp(
192  double scalarRange[2], double threshold[2],
193  vtkVolumeProperty* node,
194  bool linearRamp = false, bool stayUpAtUpperLimit = false);
195 
218  void SetWindowLevelToVolumeProp(
219  double scalarRange[2], double windowLevel[2],
220  vtkLookupTable* lut, vtkVolumeProperty* node);
221 
225  void SetGradientOpacityToVolumeProp(
226  double scalarRange[2], vtkVolumeProperty* node);
227 
231  void SetLabelMapToVolumeProp(
232  vtkScalarsToColors* lut, vtkVolumeProperty* node);
233 
238  void UpdateDisplayNodeFromVolumeNode(vtkMRMLVolumeRenderingDisplayNode *displayNode,
239  vtkMRMLVolumeNode *volumeNode,
240  vtkMRMLVolumePropertyNode *propNode = nullptr,
241  vtkMRMLNode *roiNode = nullptr,
242  bool createROI=true);
243 
245  vtkMRMLDisplayableNode* CreateROINode(vtkMRMLVolumeRenderingDisplayNode* displayNode);
246 
248  void RemoveViewFromVolumeDisplayNodes(vtkMRMLVolumeNode *volumeNode,
249  vtkMRMLViewNode *viewNode);
250 
252  vtkMRMLVolumeRenderingDisplayNode* GetVolumeRenderingDisplayNodeByID(vtkMRMLVolumeNode *volumeNode,
253  char *displayNodeID);
254 
256  vtkMRMLVolumeRenderingDisplayNode* GetVolumeRenderingDisplayNodeForViewNode(
257  vtkMRMLVolumeNode *volumeNode,
258  vtkMRMLViewNode *viewNode);
259 
261  vtkMRMLVolumeRenderingDisplayNode* GetVolumeRenderingDisplayNodeForViewNode(
262  vtkMRMLViewNode *viewNode);
263 
265  vtkMRMLVolumeRenderingDisplayNode* GetFirstVolumeRenderingDisplayNode(vtkMRMLVolumeNode *volumeNode);
266 
268  vtkMRMLVolumeRenderingDisplayNode* GetFirstVolumeRenderingDisplayNodeByROINode(vtkMRMLNode* roiNode);
269 
270  void UpdateTranferFunctionRangeFromImage(vtkMRMLVolumeRenderingDisplayNode* vspNode);
271 
275  void FitROIToVolume(vtkMRMLVolumeRenderingDisplayNode* vspNode);
276 
279  vtkMRMLVolumePropertyNode* AddVolumePropertyFromFile (const char* filename);
280 
283  vtkMRMLShaderPropertyNode* AddShaderPropertyFromFile (const char* filename);
284 
291  vtkMRMLScene* GetPresetsScene();
292 
299  void AddPreset(vtkMRMLVolumePropertyNode* preset, vtkImageData* icon = nullptr, bool appendToEnd=false);
300 
303  void RemovePreset(vtkMRMLVolumePropertyNode* preset);
304 
307  int LoadCustomPresetsScene(const char* sceneFilePath);
308 
312  static const char* GetIconVolumeReferenceRole() { return "IconVolume"; };
313 
319  vtkMRMLVolumePropertyNode* GetPresetByName(const char *presetName);
320 
323  bool IsDifferentFunction(vtkPiecewiseFunction* function1,
324  vtkPiecewiseFunction* function2) const;
325 
328  bool IsDifferentFunction(vtkColorTransferFunction* function1,
329  vtkColorTransferFunction* function2) const;
330 
331  vtkSetMacro(DefaultROIClassName, std::string);
332  vtkGetMacro(DefaultROIClassName, std::string);
333 
334 protected:
336  ~vtkSlicerVolumeRenderingLogic() override;
337 
338  void SetMRMLSceneInternal(vtkMRMLScene* scene) override;
339  // Register local MRML nodes
340  void RegisterNodes() override;
341 
343  void ObserveMRMLScene() override;
344  void OnMRMLSceneNodeAdded(vtkMRMLNode* node) override;
345  void OnMRMLSceneNodeRemoved(vtkMRMLNode* node) override;
346  void OnMRMLNodeModified(vtkMRMLNode* node) override;
347 
348  // Update from
349  void UpdateVolumeRenderingDisplayNode(vtkMRMLVolumeRenderingDisplayNode* node);
350 
351  std::map<std::string, std::string> RenderingMethods;
359 
361 
362  typedef std::vector<vtkMRMLNode*> DisplayNodesType;
364 
365  bool LoadPresets(vtkMRMLScene* scene);
367 
368  std::string DefaultROIClassName;
369 private:
371  void operator=(const vtkSlicerVolumeRenderingLogic&) = delete;
372 };
373 
374 #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.