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  void Initialize(vtkMRMLSliceNode* newSliceNode);
82  bool IsInitialized();
83 
85  vtkSetStringMacro(Name);
86  vtkGetStringMacro(Name);
87 
90  vtkGetObjectMacro (SliceNode, vtkMRMLSliceNode);
91  void SetSliceNode (vtkMRMLSliceNode * newSliceNode);
92 
95  vtkGetObjectMacro (SliceCompositeNode, vtkMRMLSliceCompositeNode);
96  void SetSliceCompositeNode (vtkMRMLSliceCompositeNode *SliceCompositeNode);
97 
101  vtkGetObjectMacro (BackgroundLayer, vtkMRMLSliceLayerLogic);
102  void SetBackgroundLayer (vtkMRMLSliceLayerLogic *BackgroundLayer);
103 
107  vtkGetObjectMacro (ForegroundLayer, vtkMRMLSliceLayerLogic);
108  void SetForegroundLayer (vtkMRMLSliceLayerLogic *ForegroundLayer);
109 
113  vtkGetObjectMacro (LabelLayer, vtkMRMLSliceLayerLogic);
114  void SetLabelLayer (vtkMRMLSliceLayerLogic *LabelLayer);
115 
118  void SetBackgroundWindowLevel(double window, double level);
119 
123  void GetBackgroundWindowLevelAndRange(double& window, double& level,
124  double& rangeLow, double& rangeHigh, bool& autoWindowLevel);
125 
128  void GetBackgroundWindowLevelAndRange(double& window, double& level,
129  double& rangeLow, double& rangeHigh);
130 
133  void SetForegroundWindowLevel(double window, double level);
134 
138  void GetForegroundWindowLevelAndRange(double& window, double& level,
139  double& rangeLow, double& rangeHigh, bool& autoWindowLevel);
140 
143  void GetForegroundWindowLevelAndRange(double& window, double& level,
144  double& rangeLow, double& rangeHigh);
147  vtkGetObjectMacro(SliceModelNode, vtkMRMLModelNode);
148 
151  vtkGetObjectMacro(SliceModelDisplayNode, vtkMRMLModelDisplayNode);
152 
155  vtkGetObjectMacro(SliceModelTransformNode, vtkMRMLLinearTransformNode);
156 
160  vtkImageBlend* GetBlend();
161  vtkImageBlend* GetBlendUVW();
162 
166  vtkGetObjectMacro(ExtractModelTexture, vtkImageReslice);
167 
171  vtkAlgorithmOutput *GetImageDataConnection();
172 
175  void UpdatePipeline();
176 
178  void UpdateImageData();
179 
182  virtual bool EnterMRMLCallback()const;
183 
186  void UpdateSliceNode();
187 
190  void UpdateSliceNodeFromLayout();
191 
194  void UpdateSliceCompositeNode();
195 
199  vtkMRMLVolumeNode *GetLayerVolumeNode(int layer);
200 
203  static void GetVolumeRASBox(vtkMRMLVolumeNode *volumeNode, double rasDimensions[3], double rasCenter[3]);
204 
207  void GetVolumeSliceDimensions(vtkMRMLVolumeNode *volumeNode, double sliceDimensions[3], double sliceCenter[3]);
208 
213  double *GetVolumeSliceSpacing(vtkMRMLVolumeNode *volumeNode);
214 
221  void GetVolumeSliceBounds(vtkMRMLVolumeNode *volumeNode, double sliceBounds[6], bool useVoxelCenter=false);
222 
225  void FitSliceToVolume(vtkMRMLVolumeNode *volumeNode, int width, int height);
226 
229  void GetBackgroundRASBox(double rasDimensions[3], double rasCenter[3]);
230 
233  void GetBackgroundSliceDimensions(double sliceDimensions[3], double sliceCenter[3]);
234 
239  double *GetBackgroundSliceSpacing();
240 
245  void GetBackgroundSliceBounds(double sliceBounds[6]);
246 
249  void FitSliceToBackground(int width, int height);
250 
254  void FitSliceToAll(int width = -1, int height = -1);
255 
258  void FitFOVToBackground(double fov);
259 
265  void ResizeSliceNode(double newWidth, double newHeight);
266 
273  double *GetLowestVolumeSliceSpacing();
274 
282  void GetLowestVolumeSliceBounds(double sliceBounds[6], bool useVoxelCenter=false);
283 
286  double GetSliceOffset();
287  void SetSliceOffset(double offset);
288 
291  void GetSliceBounds(double sliceBounds[6]);
292 
295  void SetSliceExtentsToSliceNode();
296 
300  void StartSliceNodeInteraction(unsigned int parameters);
301 
303  void EndSliceNodeInteraction();
304 
308  void StartSliceCompositeNodeInteraction(unsigned int parameters);
309 
311  void EndSliceCompositeNodeInteraction();
312 
314  void StartSliceOffsetInteraction();
315 
317  void EndSliceOffsetInteraction();
318 
322  void SnapSliceOffsetToIJK();
323 
324  static const int SLICE_INDEX_ROTATED;
325  static const int SLICE_INDEX_OUT_OF_VOLUME;
326  static const int SLICE_INDEX_NO_VOLUME;
327 
333  int GetSliceIndexFromOffset(double sliceOffset, vtkMRMLVolumeNode *volumeNode);
334 
343  int GetSliceIndexFromOffset(double sliceOffset);
344 
347  void CreateSliceModel();
348  void DeleteSliceModel();
349 
352  std::vector< vtkMRMLDisplayNode*> GetPolyDataDisplayNodes();
354  static vtkMRMLSliceCompositeNode* GetSliceCompositeNode(vtkMRMLSliceNode* node);
356  static vtkMRMLSliceNode* GetSliceNode(vtkMRMLSliceCompositeNode* node);
357 
361  static const std::string SLICE_MODEL_NODE_NAME_SUFFIX;
362 
366  static bool IsSliceModelNode(vtkMRMLNode *mrmlNode);
371  static bool IsSliceModelDisplayNode(vtkMRMLDisplayNode *mrmlDisplayNode);
372 
373 protected:
374 
376  ~vtkMRMLSliceLogic() override;
377 
378  void SetMRMLSceneInternal(vtkMRMLScene * newScene) override;
379 
382  void ProcessMRMLLogicsEvents(vtkObject * caller,
383  unsigned long event,
384  void * callData) override;
386 
387  void OnMRMLSceneNodeAdded(vtkMRMLNode* node) override;
388  void OnMRMLSceneNodeRemoved(vtkMRMLNode* node) override;
389  void UpdateFromMRMLScene() override;
390  void OnMRMLSceneStartClose() override;
391  void OnMRMLSceneEndImport() override;
392  void OnMRMLSceneEndRestore() override;
393 
394  void UpdateSliceNodes();
395  void SetupCrosshairNode();
396 
397  void OnMRMLNodeModified(vtkMRMLNode* node) override;
398  static vtkMRMLSliceCompositeNode* GetSliceCompositeNode(vtkMRMLScene* scene,
399  const char* layoutName);
400  static vtkMRMLSliceNode* GetSliceNode(vtkMRMLScene* scene,
401  const char* layoutName);
402 
405  void SetWindowLevel(double window, double level, int layer);
406 
411  bool UpdateBlendLayers(vtkImageBlend* blend, const std::deque<SliceLayerInfo> &layers);
412 
415 
416  char * Name;
422 
423  BlendPipeline* Pipeline;
424  BlendPipeline* PipelineUVW;
425  vtkImageReslice * ExtractModelTexture;
426  vtkAlgorithmOutput * ImageDataConnection;
427  vtkTransform * ActiveSliceTransform;
428 
432  double SliceSpacing[3];
433 
434 private:
435 
436  vtkMRMLSliceLogic(const vtkMRMLSliceLogic&) = delete;
437  void operator=(const vtkMRMLSliceLogic&) = delete;
438 
439 };
440 
441 #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:60
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