Slicer  4.10
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
vtkMRMLSliceLogic.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: vtkMRMLSliceLogic.h,v $
10  Date: $Date$
11  Version: $Revision: 18866
12 
13 =========================================================================auto=*/
14 
15 #ifndef __vtkMRMLSliceLogic_h
16 #define __vtkMRMLSliceLogic_h
17 
18 // MRMLLogic includes
19 #include "vtkMRMLAbstractLogic.h"
20 
21 // STD includes
22 #include <vector>
23 #include <deque>
24 
25 class vtkMRMLDisplayNode;
28 class vtkMRMLModelNode;
31 class vtkMRMLSliceNode;
32 class vtkMRMLVolumeNode;
33 
34 class vtkAlgorithmOutput;
35 class vtkCollection;
36 class vtkImageBlend;
37 class vtkTransform;
38 class vtkImageData;
39 class vtkImageReslice;
40 class vtkTransform;
41 
42 struct SliceLayerInfo;
43 struct BlendPipeline;
44 
57 class VTK_MRML_LOGIC_EXPORT vtkMRMLSliceLogic : public vtkMRMLAbstractLogic
58 {
59 public:
61  static vtkMRMLSliceLogic *New();
63  void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
64 
67  void Initialize(vtkMRMLSliceNode* newSliceNode);
68  bool IsInitialized();
69 
71  vtkSetStringMacro(Name);
72  vtkGetStringMacro(Name);
73 
76  vtkGetObjectMacro (SliceNode, vtkMRMLSliceNode);
77  void SetSliceNode (vtkMRMLSliceNode * newSliceNode);
78 
81  vtkGetObjectMacro (SliceCompositeNode, vtkMRMLSliceCompositeNode);
82  void SetSliceCompositeNode (vtkMRMLSliceCompositeNode *SliceCompositeNode);
83 
87  vtkGetObjectMacro (BackgroundLayer, vtkMRMLSliceLayerLogic);
88  void SetBackgroundLayer (vtkMRMLSliceLayerLogic *BackgroundLayer);
89 
93  vtkGetObjectMacro (ForegroundLayer, vtkMRMLSliceLayerLogic);
94  void SetForegroundLayer (vtkMRMLSliceLayerLogic *ForegroundLayer);
95 
99  vtkGetObjectMacro (LabelLayer, vtkMRMLSliceLayerLogic);
100  void SetLabelLayer (vtkMRMLSliceLayerLogic *LabelLayer);
101 
104  void SetBackgroundWindowLevel(double window, double level);
105 
108  void GetBackgroundWindowLevelAndRange(double& window, double& level,
109  double& rangeLow, double& rangeHigh);
110 
113  void SetForegroundWindowLevel(double window, double level);
114 
117  void GetForegroundWindowLevelAndRange(double& window, double& level,
118  double& rangeLow, double& rangeHigh);
121  vtkGetObjectMacro(SliceModelNode, vtkMRMLModelNode);
122 
125  vtkGetObjectMacro(SliceModelDisplayNode, vtkMRMLModelDisplayNode);
126 
129  vtkGetObjectMacro(SliceModelTransformNode, vtkMRMLLinearTransformNode);
130 
134  vtkImageBlend* GetBlend();
135  vtkImageBlend* GetBlendUVW();
136 
140  vtkGetObjectMacro(ExtractModelTexture, vtkImageReslice);
141 
145  vtkAlgorithmOutput *GetImageDataConnection();
146 
149  void UpdatePipeline();
150 
152  void UpdateImageData();
153 
156  virtual bool EnterMRMLCallback()const;
157 
160  void UpdateSliceNode();
161 
164  void UpdateSliceNodeFromLayout();
165 
168  void UpdateSliceCompositeNode();
169 
173  vtkMRMLVolumeNode *GetLayerVolumeNode(int layer);
174 
177  static void GetVolumeRASBox(vtkMRMLVolumeNode *volumeNode, double rasDimensions[3], double rasCenter[3]);
178 
181  void GetVolumeSliceDimensions(vtkMRMLVolumeNode *volumeNode, double sliceDimensions[3], double sliceCenter[3]);
182 
187  double *GetVolumeSliceSpacing(vtkMRMLVolumeNode *volumeNode);
188 
193  void GetVolumeSliceBounds(vtkMRMLVolumeNode *volumeNode, double sliceBounds[6]);
194 
197  void FitSliceToVolume(vtkMRMLVolumeNode *volumeNode, int width, int height);
198 
201  void GetBackgroundRASBox(double rasDimensions[3], double rasCenter[3]);
202 
205  void GetBackgroundSliceDimensions(double sliceDimensions[3], double sliceCenter[3]);
206 
211  double *GetBackgroundSliceSpacing();
212 
217  void GetBackgroundSliceBounds(double sliceBounds[6]);
218 
221  void FitSliceToBackground(int width, int height);
222 
226  void FitSliceToAll(int width = -1, int height = -1);
227 
230  void FitFOVToBackground(double fov);
231 
237  void ResizeSliceNode(double newWidth, double newHeight);
238 
244  double *GetLowestVolumeSliceSpacing();
245 
251  void GetLowestVolumeSliceBounds(double sliceBounds[6]);
252 
255  double GetSliceOffset();
256  void SetSliceOffset(double offset);
257 
260  void GetSliceBounds(double sliceBounds[6]);
261 
264  void SetSliceExtentsToSliceNode();
265 
269  void StartSliceNodeInteraction(unsigned int parameters);
270 
272  void EndSliceNodeInteraction();
273 
277  void StartSliceCompositeNodeInteraction(unsigned int parameters);
278 
280  void EndSliceCompositeNodeInteraction();
281 
283  void StartSliceOffsetInteraction();
284 
286  void EndSliceOffsetInteraction();
287 
291  void SnapSliceOffsetToIJK();
292 
293  static const int SLICE_INDEX_ROTATED;
294  static const int SLICE_INDEX_OUT_OF_VOLUME;
295  static const int SLICE_INDEX_NO_VOLUME;
296 
302  int GetSliceIndexFromOffset(double sliceOffset, vtkMRMLVolumeNode *volumeNode);
303 
312  int GetSliceIndexFromOffset(double sliceOffset);
313 
316  void CreateSliceModel();
317  void DeleteSliceModel();
318 
321  std::vector< vtkMRMLDisplayNode*> GetPolyDataDisplayNodes();
323  static vtkMRMLSliceCompositeNode* GetSliceCompositeNode(vtkMRMLSliceNode* node);
325  static vtkMRMLSliceNode* GetSliceNode(vtkMRMLSliceCompositeNode* node);
326 
330  static const std::string SLICE_MODEL_NODE_NAME_SUFFIX;
331 
335  static bool IsSliceModelNode(vtkMRMLNode *mrmlNode);
340  static bool IsSliceModelDisplayNode(vtkMRMLDisplayNode *mrmlDisplayNode);
341 
342 protected:
343 
345  virtual ~vtkMRMLSliceLogic();
346 
347  virtual void SetMRMLSceneInternal(vtkMRMLScene * newScene) VTK_OVERRIDE;
348 
351  virtual void ProcessMRMLLogicsEvents(vtkObject * caller,
352  unsigned long event,
353  void * callData) VTK_OVERRIDE;
355 
356  virtual void OnMRMLSceneNodeAdded(vtkMRMLNode* node) VTK_OVERRIDE;
357  virtual void OnMRMLSceneNodeRemoved(vtkMRMLNode* node) VTK_OVERRIDE;
358  virtual void UpdateFromMRMLScene() VTK_OVERRIDE;
359  virtual void OnMRMLSceneStartClose() VTK_OVERRIDE;
360  virtual void OnMRMLSceneEndImport() VTK_OVERRIDE;
361  virtual void OnMRMLSceneEndRestore() VTK_OVERRIDE;
362 
363  void UpdateSliceNodes();
364  void SetupCrosshairNode();
365 
366  virtual void OnMRMLNodeModified(vtkMRMLNode* node) VTK_OVERRIDE;
367  static vtkMRMLSliceCompositeNode* GetSliceCompositeNode(vtkMRMLScene* scene,
368  const char* layoutName);
369  static vtkMRMLSliceNode* GetSliceNode(vtkMRMLScene* scene,
370  const char* layoutName);
371 
374  void SetWindowLevel(double window, double level, int layer);
375 
380  bool UpdateBlendLayers(vtkImageBlend* blend, const std::deque<SliceLayerInfo> &layers);
381 
382  bool AddingSliceModelNodes;
383  bool Initialized;
384 
385  char * Name;
386  vtkMRMLSliceNode * SliceNode;
387  vtkMRMLSliceCompositeNode * SliceCompositeNode;
388  vtkMRMLSliceLayerLogic * BackgroundLayer;
389  vtkMRMLSliceLayerLogic * ForegroundLayer;
391 
392  BlendPipeline* Pipeline;
393  BlendPipeline* PipelineUVW;
394  vtkImageReslice * ExtractModelTexture;
395  vtkAlgorithmOutput * ImageDataConnection;
396  vtkTransform * ActiveSliceTransform;
397 
398  vtkMRMLModelNode * SliceModelNode;
399  vtkMRMLModelDisplayNode * SliceModelDisplayNode;
400  vtkMRMLLinearTransformNode * SliceModelTransformNode;
401  double SliceSpacing[3];
402 
403 private:
404 
406  void operator=(const vtkMRMLSliceLogic&);
407 
408 };
409 
410 #endif
static const int SLICE_INDEX_ROTATED
Superclass for MRML logic classes.
static const int SLICE_INDEX_OUT_OF_VOLUME
MRML node to represent a display property of 3D surface model.
MRML node to represent a 3D surface model.
static const int SLICE_INDEX_NO_VOLUME
MRML node for storing a slice through RAS space.
LRU Cache.
MRML node for storing a slice through RAS space.
virtual void ProcessMRMLLogicsEvents(vtkObject *caller, unsigned long event, void *callData)
void PrintSelf(ostream &os, vtkIndent indent) VTK_OVERRIDE
MRML node for representing a linear transformation.
A set of MRML Nodes that supports serialization and undo/redo.
Definition: vtkMRMLScene.h:54
virtual void OnMRMLSceneNodeAdded(vtkMRMLNode *)
static const std::string SLICE_MODEL_NODE_NAME_SUFFIX
virtual void OnMRMLSceneNodeRemoved(vtkMRMLNode *)
virtual void SetMRMLSceneInternal(vtkMRMLScene *newScene)
MRML node for representing a volume (image stack).
Abstract class that contains graphical display properties for displayable nodes.
virtual void UpdateFromMRMLScene()
Abstract Superclass for all specific types of MRML nodes.
Definition: vtkMRMLNode.h:138
static vtkMRMLAbstractLogic * New()
Slicer logic class for slice manipulation.