Slicer  5.3
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;
32 class vtkMRMLSliceNode;
33 class vtkMRMLVolumeNode;
34 
35 class vtkAlgorithmOutput;
36 class vtkCollection;
37 class vtkImageBlend;
38 class vtkTransform;
39 class vtkImageData;
40 class vtkImageReslice;
41 class vtkTransform;
42 
43 struct SliceLayerInfo;
44 struct BlendPipeline;
45 
58 class VTK_MRML_LOGIC_EXPORT vtkMRMLSliceLogic : public vtkMRMLAbstractLogic
59 {
60 public:
62  static vtkMRMLSliceLogic *New();
64  void PrintSelf(ostream& os, vtkIndent indent) override;
65 
67  enum
68  {
69  CompositeModifiedEvent = 18000
70  };
71 
72  enum
73  {
74  LayerNone = -1,
75  LayerBackground = 0,
76  LayerForeground = 1,
77  LayerLabel = 2
78  };
79 
82  vtkGetObjectMacro (SliceNode, vtkMRMLSliceNode);
83  void SetSliceNode (vtkMRMLSliceNode * newSliceNode);
84 
86  vtkMRMLSliceNode* AddSliceNode(const char* layoutName);
87 
90  vtkGetObjectMacro (SliceCompositeNode, vtkMRMLSliceCompositeNode);
91  void SetSliceCompositeNode (vtkMRMLSliceCompositeNode *SliceCompositeNode);
92 
96  vtkGetObjectMacro (BackgroundLayer, vtkMRMLSliceLayerLogic);
97  void SetBackgroundLayer (vtkMRMLSliceLayerLogic *BackgroundLayer);
98 
102  vtkGetObjectMacro (ForegroundLayer, vtkMRMLSliceLayerLogic);
103  void SetForegroundLayer (vtkMRMLSliceLayerLogic *ForegroundLayer);
104 
108  vtkGetObjectMacro (LabelLayer, vtkMRMLSliceLayerLogic);
109  void SetLabelLayer (vtkMRMLSliceLayerLogic *LabelLayer);
110 
113  void SetBackgroundWindowLevel(double window, double level);
114 
118  void GetBackgroundWindowLevelAndRange(double& window, double& level,
119  double& rangeLow, double& rangeHigh, bool& autoWindowLevel);
120 
123  void GetBackgroundWindowLevelAndRange(double& window, double& level,
124  double& rangeLow, double& rangeHigh);
125 
128  void SetForegroundWindowLevel(double window, double level);
129 
133  void GetForegroundWindowLevelAndRange(double& window, double& level,
134  double& rangeLow, double& rangeHigh, bool& autoWindowLevel);
135 
138  void GetForegroundWindowLevelAndRange(double& window, double& level,
139  double& rangeLow, double& rangeHigh);
142  vtkGetObjectMacro(SliceModelNode, vtkMRMLModelNode);
143 
147  vtkGetObjectMacro(SliceModelDisplayNode, vtkMRMLModelDisplayNode);
148 
151  vtkMRMLSliceDisplayNode* GetSliceDisplayNode();
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 
251  void RotateSliceToLowestVolumeAxes(bool forceSlicePlaneToSingleSlice = true);
252 
255  void FitSliceToBackground(int width, int height);
256 
260  void FitSliceToAll(int width = -1, int height = -1);
261 
264  void FitFOVToBackground(double fov);
265 
271  void ResizeSliceNode(double newWidth, double newHeight);
272 
279  double *GetLowestVolumeSliceSpacing();
280 
288  void GetLowestVolumeSliceBounds(double sliceBounds[6], bool useVoxelCenter=false);
289 
292  double GetSliceOffset();
293  void SetSliceOffset(double offset);
294 
297  void GetSliceBounds(double sliceBounds[6]);
298 
301  void SetSliceExtentsToSliceNode();
302 
306  void StartSliceNodeInteraction(unsigned int parameters);
307 
309  void EndSliceNodeInteraction();
310 
314  void StartSliceCompositeNodeInteraction(unsigned int parameters);
315 
317  void EndSliceCompositeNodeInteraction();
318 
320  void StartSliceOffsetInteraction();
321 
323  void EndSliceOffsetInteraction();
324 
328  void SnapSliceOffsetToIJK();
329 
330  static const int SLICE_INDEX_ROTATED;
331  static const int SLICE_INDEX_OUT_OF_VOLUME;
332  static const int SLICE_INDEX_NO_VOLUME;
333 
339  int GetSliceIndexFromOffset(double sliceOffset, vtkMRMLVolumeNode *volumeNode);
340 
349  int GetSliceIndexFromOffset(double sliceOffset);
350 
353  void CreateSliceModel();
354  void DeleteSliceModel();
355 
358  std::vector< vtkMRMLDisplayNode*> GetPolyDataDisplayNodes();
360  static vtkMRMLSliceCompositeNode* GetSliceCompositeNode(vtkMRMLSliceNode* node);
362  static vtkMRMLSliceNode* GetSliceNode(vtkMRMLSliceCompositeNode* node);
363 
367  static const std::string SLICE_MODEL_NODE_NAME_SUFFIX;
368 
372  static bool IsSliceModelNode(vtkMRMLNode *mrmlNode);
377  static bool IsSliceModelDisplayNode(vtkMRMLDisplayNode *mrmlDisplayNode);
378 
383  int GetEditableLayerAtWorldPosition(double worldPos[3], bool backgroundVolumeEditable = true, bool foregroundVolumeEditable = true);
384 
385 protected:
386 
388  ~vtkMRMLSliceLogic() override;
389 
390  void SetMRMLSceneInternal(vtkMRMLScene * newScene) override;
391 
394  void ProcessMRMLLogicsEvents(vtkObject * caller,
395  unsigned long event,
396  void * callData) override;
398 
399  void OnMRMLSceneNodeAdded(vtkMRMLNode* node) override;
400  void OnMRMLSceneNodeRemoved(vtkMRMLNode* node) override;
401  void UpdateFromMRMLScene() override;
402  void OnMRMLSceneStartClose() override;
403  void OnMRMLSceneEndImport() override;
404  void OnMRMLSceneEndRestore() override;
405 
406  void UpdateSliceNodes();
407  void SetupCrosshairNode();
408 
409  void OnMRMLNodeModified(vtkMRMLNode* node) override;
410  static vtkMRMLSliceCompositeNode* GetSliceCompositeNode(vtkMRMLScene* scene,
411  const char* layoutName);
412  static vtkMRMLSliceNode* GetSliceNode(vtkMRMLScene* scene,
413  const char* layoutName);
414 
417  void SetWindowLevel(double window, double level, int layer);
418 
423  bool UpdateBlendLayers(vtkImageBlend* blend, const std::deque<SliceLayerInfo> &layers);
424 
427  bool IsEventInsideVolume(bool background, double worldPos[3]);
428 
430  bool VolumeWindowLevelEditable(const char* volumeNodeID);
431 
433 
439 
440  BlendPipeline* Pipeline;
441  BlendPipeline* PipelineUVW;
442  vtkImageReslice * ExtractModelTexture;
443  vtkAlgorithmOutput * ImageDataConnection;
444 
448  double SliceSpacing[3];
449 
450 private:
451 
452  vtkMRMLSliceLogic(const vtkMRMLSliceLogic&) = delete;
453  void operator=(const vtkMRMLSliceLogic&) = delete;
454 
455 };
456 
457 #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 to store display properties of slice nodes.
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:57
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()
BlendPipeline * PipelineUVW
Slicer logic class for slice manipulation.
vtkMRMLSliceNode * SliceNode