Slicer  4.13
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) override;
64 
66  enum
67  {
68  CompositeModifiedEvent = 18000
69  };
70 
71  enum
72  {
73  LayerNone = -1,
74  LayerBackground = 0,
75  LayerForeground = 1,
76  LayerLabel = 2
77  };
78 
81  vtkGetObjectMacro (SliceNode, vtkMRMLSliceNode);
82  void SetSliceNode (vtkMRMLSliceNode * newSliceNode);
83 
85  vtkMRMLSliceNode* AddSliceNode(const char* layoutName);
86 
89  vtkGetObjectMacro (SliceCompositeNode, vtkMRMLSliceCompositeNode);
90  void SetSliceCompositeNode (vtkMRMLSliceCompositeNode *SliceCompositeNode);
91 
95  vtkGetObjectMacro (BackgroundLayer, vtkMRMLSliceLayerLogic);
96  void SetBackgroundLayer (vtkMRMLSliceLayerLogic *BackgroundLayer);
97 
101  vtkGetObjectMacro (ForegroundLayer, vtkMRMLSliceLayerLogic);
102  void SetForegroundLayer (vtkMRMLSliceLayerLogic *ForegroundLayer);
103 
107  vtkGetObjectMacro (LabelLayer, vtkMRMLSliceLayerLogic);
108  void SetLabelLayer (vtkMRMLSliceLayerLogic *LabelLayer);
109 
112  void SetBackgroundWindowLevel(double window, double level);
113 
117  void GetBackgroundWindowLevelAndRange(double& window, double& level,
118  double& rangeLow, double& rangeHigh, bool& autoWindowLevel);
119 
122  void GetBackgroundWindowLevelAndRange(double& window, double& level,
123  double& rangeLow, double& rangeHigh);
124 
127  void SetForegroundWindowLevel(double window, double level);
128 
132  void GetForegroundWindowLevelAndRange(double& window, double& level,
133  double& rangeLow, double& rangeHigh, bool& autoWindowLevel);
134 
137  void GetForegroundWindowLevelAndRange(double& window, double& level,
138  double& rangeLow, double& rangeHigh);
141  vtkGetObjectMacro(SliceModelNode, vtkMRMLModelNode);
142 
145  vtkGetObjectMacro(SliceModelDisplayNode, vtkMRMLModelDisplayNode);
146 
149  vtkGetObjectMacro(SliceModelTransformNode, vtkMRMLLinearTransformNode);
150 
154  vtkImageBlend* GetBlend();
155  vtkImageBlend* GetBlendUVW();
156 
160  vtkGetObjectMacro(ExtractModelTexture, vtkImageReslice);
161 
165  vtkAlgorithmOutput *GetImageDataConnection();
166 
169  void UpdatePipeline();
170 
172  void UpdateImageData();
173 
176  virtual bool EnterMRMLCallback()const;
177 
180  void UpdateSliceNode();
181 
184  void UpdateSliceNodeFromLayout();
185 
188  void UpdateSliceCompositeNode();
189 
193  vtkMRMLVolumeNode *GetLayerVolumeNode(int layer);
194 
197  static void GetVolumeRASBox(vtkMRMLVolumeNode *volumeNode, double rasDimensions[3], double rasCenter[3]);
198 
201  void GetVolumeSliceDimensions(vtkMRMLVolumeNode *volumeNode, double sliceDimensions[3], double sliceCenter[3]);
202 
207  double *GetVolumeSliceSpacing(vtkMRMLVolumeNode *volumeNode);
208 
215  void GetVolumeSliceBounds(vtkMRMLVolumeNode *volumeNode, double sliceBounds[6], bool useVoxelCenter=false);
216 
219  void FitSliceToVolume(vtkMRMLVolumeNode *volumeNode, int width, int height);
220 
223  void GetBackgroundRASBox(double rasDimensions[3], double rasCenter[3]);
224 
227  void GetBackgroundSliceDimensions(double sliceDimensions[3], double sliceCenter[3]);
228 
233  double *GetBackgroundSliceSpacing();
234 
239  void GetBackgroundSliceBounds(double sliceBounds[6]);
240 
242  void RotateSliceToLowestVolumeAxes();
243 
246  void FitSliceToBackground(int width, int height);
247 
251  void FitSliceToAll(int width = -1, int height = -1);
252 
255  void FitFOVToBackground(double fov);
256 
262  void ResizeSliceNode(double newWidth, double newHeight);
263 
270  double *GetLowestVolumeSliceSpacing();
271 
279  void GetLowestVolumeSliceBounds(double sliceBounds[6], bool useVoxelCenter=false);
280 
283  double GetSliceOffset();
284  void SetSliceOffset(double offset);
285 
288  void GetSliceBounds(double sliceBounds[6]);
289 
292  void SetSliceExtentsToSliceNode();
293 
297  void StartSliceNodeInteraction(unsigned int parameters);
298 
300  void EndSliceNodeInteraction();
301 
305  void StartSliceCompositeNodeInteraction(unsigned int parameters);
306 
308  void EndSliceCompositeNodeInteraction();
309 
311  void StartSliceOffsetInteraction();
312 
314  void EndSliceOffsetInteraction();
315 
319  void SnapSliceOffsetToIJK();
320 
321  static const int SLICE_INDEX_ROTATED;
322  static const int SLICE_INDEX_OUT_OF_VOLUME;
323  static const int SLICE_INDEX_NO_VOLUME;
324 
330  int GetSliceIndexFromOffset(double sliceOffset, vtkMRMLVolumeNode *volumeNode);
331 
340  int GetSliceIndexFromOffset(double sliceOffset);
341 
344  void CreateSliceModel();
345  void DeleteSliceModel();
346 
349  std::vector< vtkMRMLDisplayNode*> GetPolyDataDisplayNodes();
351  static vtkMRMLSliceCompositeNode* GetSliceCompositeNode(vtkMRMLSliceNode* node);
353  static vtkMRMLSliceNode* GetSliceNode(vtkMRMLSliceCompositeNode* node);
354 
358  static const std::string SLICE_MODEL_NODE_NAME_SUFFIX;
359 
363  static bool IsSliceModelNode(vtkMRMLNode *mrmlNode);
368  static bool IsSliceModelDisplayNode(vtkMRMLDisplayNode *mrmlDisplayNode);
369 
370 protected:
371 
373  ~vtkMRMLSliceLogic() override;
374 
375  void SetMRMLSceneInternal(vtkMRMLScene * newScene) override;
376 
379  void ProcessMRMLLogicsEvents(vtkObject * caller,
380  unsigned long event,
381  void * callData) override;
383 
384  void OnMRMLSceneNodeAdded(vtkMRMLNode* node) override;
385  void OnMRMLSceneNodeRemoved(vtkMRMLNode* node) override;
386  void UpdateFromMRMLScene() override;
387  void OnMRMLSceneStartClose() override;
388  void OnMRMLSceneEndImport() override;
389  void OnMRMLSceneEndRestore() override;
390 
391  void UpdateSliceNodes();
392  void SetupCrosshairNode();
393 
394  void OnMRMLNodeModified(vtkMRMLNode* node) override;
395  static vtkMRMLSliceCompositeNode* GetSliceCompositeNode(vtkMRMLScene* scene,
396  const char* layoutName);
397  static vtkMRMLSliceNode* GetSliceNode(vtkMRMLScene* scene,
398  const char* layoutName);
399 
402  void SetWindowLevel(double window, double level, int layer);
403 
408  bool UpdateBlendLayers(vtkImageBlend* blend, const std::deque<SliceLayerInfo> &layers);
409 
411 
417 
418  BlendPipeline* Pipeline;
419  BlendPipeline* PipelineUVW;
420  vtkImageReslice * ExtractModelTexture;
421  vtkAlgorithmOutput * ImageDataConnection;
422  vtkTransform * ActiveSliceTransform;
423 
427  double SliceSpacing[3];
428 
429 private:
430 
431  vtkMRMLSliceLogic(const vtkMRMLSliceLogic&) = delete;
432  void operator=(const vtkMRMLSliceLogic&) = delete;
433 
434 };
435 
436 #endif
virtual void OnMRMLSceneStartClose()
static const int SLICE_INDEX_ROTATED
vtkMRMLLinearTransformNode * SliceModelTransformNode
Superclass for MRML logic classes.
static const int SLICE_INDEX_OUT_OF_VOLUME
void PrintSelf(ostream &os, vtkIndent indent) override
vtkAlgorithmOutput * ImageDataConnection
virtual void OnMRMLSceneEndImport()
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.
MRML node for storing a slice through RAS space.
BlendPipeline * Pipeline
vtkMRMLSliceLayerLogic * ForegroundLayer
virtual void ProcessMRMLLogicsEvents(vtkObject *caller, unsigned long event, void *callData)
vtkMRMLModelDisplayNode * SliceModelDisplayNode
vtkMRMLModelNode * SliceModelNode
vtkImageReslice * ExtractModelTexture
vtkMRMLSliceLayerLogic * LabelLayer
MRML node for representing a linear transformation.
vtkMRMLSliceCompositeNode * SliceCompositeNode
virtual void OnMRMLNodeModified(vtkMRMLNode *)
A set of MRML Nodes that supports serialization and undo/redo.
Definition: vtkMRMLScene.h:61
virtual void OnMRMLSceneNodeAdded(vtkMRMLNode *)
vtkMRMLSliceLayerLogic * BackgroundLayer
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).
virtual void OnMRMLSceneEndRestore()
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:167
static vtkMRMLAbstractLogic * New()
vtkTransform * ActiveSliceTransform
BlendPipeline * PipelineUVW
Slicer logic class for slice manipulation.
vtkMRMLSliceNode * SliceNode