Slicer  4.8
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
vtkMRMLVolumeRenderingDisplayableManager.h
Go to the documentation of this file.
1 /*==============================================================================
2 
3  Program: 3D Slicer
4 
5  Copyright (c) Kitware Inc.
6 
7  See COPYRIGHT.txt
8  or http://www.slicer.org/copyright/copyright.txt for details.
9 
10  Unless required by applicable law or agreed to in writing, software
11  distributed under the License is distributed on an "AS IS" BASIS,
12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  See the License for the specific language governing permissions and
14  limitations under the License.
15 
16  This file was originally developed by Julien Finet, Kitware Inc.
17  and was partially funded by NIH grant 3P41RR013218-12S1
18 
19 ==============================================================================*/
20 
21 #ifndef __vtkMRMLVolumeRenderingDisplayableManager_h
22 #define __vtkMRMLVolumeRenderingDisplayableManager_h
23 
24 // VolumeRendering includes
25 #include "vtkSlicerVolumeRenderingModuleMRMLDisplayableManagerExport.h"
26 class vtkGPUVolumeRayCastMapper;
27 class vtkFixedPointVolumeRayCastMapper;
30 class vtkMRMLVolumeNode;
34 class vtkVolumeProperty;
35 
36 // MRML DisplayableManager includes
38 
39 // VTK includes
40 class vtkIntArray;
41 class vtkMatrix4x4;
42 class vtkPlanes;
43 class vtkTimerLog;
44 class vtkVolume;
45 class vtkVolumeMapper;
46 class vtkVolumeProperty;
47 
48 #define VTKIS_VOLUME_PROPS 100
49 
51 class VTK_SLICER_VOLUMERENDERING_MODULE_MRMLDISPLAYABLEMANAGER_EXPORT vtkMRMLVolumeRenderingDisplayableManager
53 {
54 public:
57  void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
58 
59  virtual void Reset();
60 
61  void SetGUICallbackCommand(vtkCommand* callback);
62 
63  virtual void Create() VTK_OVERRIDE;
64 
67  virtual vtkVolumeMapper* GetVolumeMapper(vtkMRMLVolumeRenderingDisplayNode* vspNode);
68 
71  void SetupMapperFromVolumeNode(vtkMRMLVolumeRenderingDisplayNode* vspNode);
72 
75  void SetupMapperFromVolumeNode(vtkMRMLVolumeNode* volumeNode,
76  vtkVolumeMapper* volumeMapper,
77  int inputIndex = 0);
78 
79  // Description:
80  // setup mapper based on current parameters node
81  // return values:
82  // -1: requested mapper not supported
83  // 0: invalid input parameter
84  // 1: success
85  virtual int SetupMapperFromParametersNode(vtkMRMLVolumeRenderingDisplayNode* vspNode);
86 
87  // Description:
88  // Get Volume Actor
89  vtkVolume* GetVolumeActor(){return this->Volume;}
90 
91  void SetupHistograms(vtkMRMLVolumeRenderingDisplayNode* vspNode);
92  //vtkKWHistogramSet* GetHistogramSet(){return this->Histograms;}
93 
94  virtual bool UpdateMapper(vtkMRMLVolumeRenderingDisplayNode* vspNode);
95 
96  void UpdateMapper(vtkVolumeMapper* mapper,
98  void UpdateCPURaycastMapper(vtkFixedPointVolumeRayCastMapper* mapper,
100  void UpdateGPURaycastMapper(vtkGPUVolumeRayCastMapper* mapper,
102  void UpdateDesiredUpdateRate(vtkMRMLVolumeRenderingDisplayNode* vspNode);
103  void UpdateClipping(vtkVolumeMapper* mapper, vtkMRMLVolumeRenderingDisplayNode* vspNode);
104 
105  //void CreateVolumePropertyGPURaycast3(vtkMRMLVolumeRenderingDisplayNode* vspNode);
106  //void UpdateVolumePropertyGPURaycast3(vtkMRMLVolumeRenderingDisplayNode* vspNode);
107 
108  void TransformModified(vtkMRMLVolumeRenderingDisplayNode* vspNode);
109 
110  void SetVolumeVisibility(int isVisible);
111 
112  //void SetupVolumeRenderingInteractive(vtkMRMLVolumeRenderingDisplayNode* vspNode, int buttonDown);
113 
114  /* return values:
115  * 0: mapper not supported
116  * 1: mapper supported
117  */
118  int IsMapperSupported(vtkMRMLVolumeRenderingDisplayNode* vspNode);
119  virtual int IsMapperSupported(vtkVolumeMapper* volumeMapper,
121 
122  virtual void OnMRMLSceneStartClose() VTK_OVERRIDE;
123  virtual void OnMRMLSceneEndClose() VTK_OVERRIDE;
124  virtual void OnMRMLSceneEndImport() VTK_OVERRIDE;
125  virtual void OnMRMLSceneEndRestore() VTK_OVERRIDE;
126  virtual void OnMRMLSceneNodeAdded(vtkMRMLNode* node) VTK_OVERRIDE;
127  virtual void OnMRMLSceneNodeRemoved(vtkMRMLNode* node) VTK_OVERRIDE;
128 
129  void UpdateDisplayNodeList();
130 
131  void AddDisplayNode(vtkMRMLVolumeRenderingDisplayNode* dnode);
132  void RemoveDisplayNode(vtkMRMLVolumeRenderingDisplayNode* dnode);
133  void RemoveDisplayNodes();
134 
136 
137 protected:
141  void operator=(const vtkMRMLVolumeRenderingDisplayableManager&);
142 
143  virtual int ActiveInteractionModes() VTK_OVERRIDE;
144  // Description:
145  // Don't support nested event processing
146  // TODO: Probably a bad idea to not support nested calls
147  virtual bool EnterMRMLNodesCallback()const VTK_OVERRIDE;
148 
149  // Description:
150  // Update MRML events
151  virtual void ProcessMRMLNodesEvents(vtkObject * caller,
152  unsigned long event,
153  void * callData) VTK_OVERRIDE;
154 
155  virtual void OnInteractorStyleEvent(int eventId) VTK_OVERRIDE;
156 
157  //virtual void OnMRMLSceneNodeAdded(vtkMRMLNode* node);
158 
159  //virtual void OnMRMLSceneNodeRemoved(vtkMRMLNode* node);
160 
161  void OnCreate();
162 
163  static bool First;
164 
165  vtkSlicerVolumeRenderingLogic *VolumeRenderingLogic;
166 
167  // Description:
168  // The software accelerated software mapper
169  vtkFixedPointVolumeRayCastMapper *MapperRaycast;
170 
171  // Description:
172  // The gpu ray cast mapper.
173  vtkGPUVolumeRayCastMapper *MapperGPURaycast3;
174 
175  // Description:
176  // Actor used for Volume Rendering
177  vtkVolume *Volume;
178 
179  // Description:
180  // internal histogram instance (bg)
181  //vtkKWHistogramSet *Histograms;
182 
183  // Description:
184  // internal histogram instance (fg)
185  //vtkKWHistogramSet *HistogramsFg;
186 
188  //vtkCallbackCommand *MRMLCallback;
189 
190  //vtkVolumeProperty *VolumePropertyGPURaycast3;
191 
193 
195  DisplayNodesType DisplayNodes;
196 
197  vtkIntArray* DisplayObservedEvents;
198  // When interaction is >0, we are in interactive mode (low LOD)
199  int Interaction;
200  double OriginalDesiredUpdateRate;
201 
202 protected:
203  void OnScenarioNodeModified();
204  void OnVolumeRenderingDisplayNodeModified(vtkMRMLVolumeRenderingDisplayNode* dnode);
205 
206  void CalculateMatrix(vtkMRMLVolumeRenderingDisplayNode *vspNode, vtkMatrix4x4 *output);
207  void EstimateSampleDistance(vtkMRMLVolumeRenderingDisplayNode* vspNode);
208 
210  bool AddVolumeToView();
211  void RemoveVolumeFromView();
212  void RemoveVolumeFromView(vtkVolume* volume);
213  bool IsVolumeInView();
214  bool IsVolumeInView(vtkVolume* volume);
215  void UpdatePipelineFromDisplayNode(vtkMRMLVolumeRenderingDisplayNode* vspNode);
216  int ValidateDisplayNode(vtkMRMLVolumeRenderingDisplayNode* vspNode);
217  double GetSampleDistance(vtkMRMLVolumeRenderingDisplayNode* vspNode);
218  double GetFramerate(vtkMRMLVolumeRenderingDisplayNode* vspNode);
219  virtual vtkIdType GetMaxMemoryInBytes(vtkVolumeMapper* mapper, vtkMRMLVolumeRenderingDisplayNode* vspNode);
220 
221 };
222 
223 #endif
virtual void OnMRMLSceneStartClose()
virtual void OnMRMLSceneEndImport()
virtual void OnMRMLSceneEndClose()
LRU Cache.
virtual void OnMRMLSceneNodeAdded(vtkMRMLNode *)
static vtkMRMLAbstractThreeDViewDisplayableManager * New()
virtual void OnMRMLSceneNodeRemoved(vtkMRMLNode *)
MRML node for representing a volume (image stack).
virtual void OnMRMLSceneEndRestore()
std::map< std::string, vtkMRMLVolumeRenderingDisplayNode * > DisplayNodesType
void PrintSelf(ostream &os, vtkIndent indent) VTK_OVERRIDE
Abstract Superclass for all specific types of MRML nodes.
Definition: vtkMRMLNode.h:135