Slicer  4.11
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
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 
245  void RotateSliceToLowestVolumeAxes(bool forceSlicePlaneToSingleSlice = true);
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 
414 
420 
421  BlendPipeline* Pipeline;
422  BlendPipeline* PipelineUVW;
423  vtkImageReslice * ExtractModelTexture;
424  vtkAlgorithmOutput * ImageDataConnection;
425  vtkTransform * ActiveSliceTransform;
426 
430  double SliceSpacing[3];
431 
432 private:
433 
434  vtkMRMLSliceLogic(const vtkMRMLSliceLogic&) = delete;
435  void operator=(const vtkMRMLSliceLogic&) = delete;
436 
437 };
438 
439 #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