Slicer  5.0
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
vtkMRMLSliceNode.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: vtkMRMLSliceNode.h,v $
10  Date: $Date: 2006/03/19 17:12:29 $
11  Version: $Revision: 1.3 $
12 
13 =========================================================================auto=*/
14 
15 #ifndef __vtkMRMLSliceNode_h
16 #define __vtkMRMLSliceNode_h
17 
18 // MRML includes
20 class vtkMRMLVolumeNode;
21 
22 // VTK includes
23 class vtkMatrix3x3;
24 class vtkMatrix4x4;
25 
32 class VTK_MRML_EXPORT vtkMRMLSliceNode : public vtkMRMLAbstractViewNode
33 {
34  public:
41  static vtkMRMLSliceNode *New();
43  void PrintSelf(ostream& os, vtkIndent indent) override;
44 
45  vtkMRMLNode* CreateNodeInstance() override;
46 
49  void ReadXMLAttributes( const char** atts) override;
50 
53  void WriteXML(ostream& of, int indent) override;
54 
58 
62  void Reset(vtkMRMLNode* defaultNode) override;
63 
66  const char* GetNodeTagName() override {return "Slice";};
67 
74  virtual vtkMatrix4x4 *GetSliceToRAS();
75 
78  vtkGetMacro(SliceVisible, int);
79  vtkSetMacro(SliceVisible, int);
80 
83  vtkGetMacro(WidgetVisible, int);
84  vtkSetMacro(WidgetVisible, int);
85 
87  vtkGetMacro(WidgetOutlineVisible, int);
88  vtkSetMacro(WidgetOutlineVisible, int);
89 
92  void AddThreeDViewID(const char* viewNodeID);
95  void RemoveThreeDViewID(char* viewNodeID);
98  void RemoveAllThreeDViewIDs();
102  int GetNumberOfThreeDViewIDs()const;
106  const char* GetNthThreeDViewID(unsigned int index);
110  inline std::vector< std::string > GetThreeDViewIDs()const;
114  bool IsThreeDViewIDPresent(const char* ThreeDViewID)const;
119  bool IsDisplayableInThreeDView(const char* viewNodeID)const;
120 
123  vtkGetMacro(WidgetNormalLockedToCamera, int);
124  vtkSetMacro(WidgetNormalLockedToCamera, int);
125 
128  vtkGetMacro(UseLabelOutline, int);
129  vtkSetMacro(UseLabelOutline, int);
130  vtkBooleanMacro(UseLabelOutline, int);
131 
138  bool SetOrientationToAxial();
139  bool SetOrientationToSagittal();
140  bool SetOrientationToCoronal();
141 
144  bool SetOrientationToDefault();
145 
152  std::string GetOrientation();
153 
155  std::string GetOrientation(vtkMatrix4x4* sliceToRAS);
156 
167  bool SetOrientation(const char* orientation);
168 
173  vtkSetStringMacro(DefaultOrientation);
174  vtkGetStringMacro(DefaultOrientation);
175 
179  virtual const char* GetOrientationString();
180 
181 protected:
182 
187  vtkGetStringMacro(OrientationReference);
188  vtkSetStringMacro(OrientationReference);
189 
190 public:
191 
193  vtkMatrix3x3 *GetSliceOrientationPreset(const std::string& name);
194 
199  std::string GetSliceOrientationPresetName(vtkMatrix3x3* orientationMatrix);
200 
202  void GetSliceOrientationPresetNames(vtkStringArray* presetOrientationNames);
203 
206  int GetNumberOfSliceOrientationPresets() const;
207 
212  bool AddSliceOrientationPreset(const std::string& name, vtkMatrix3x3* orientationMatrix);
213 
217  bool RemoveSliceOrientationPreset(const std::string& name);
218 
222  bool RenameSliceOrientationPreset(const std::string& name, const std::string& updatedName);
223 
227  bool HasSliceOrientationPreset(const std::string& name);
228 
231  static const char* GetReformatOrientationName() { return "Reformat"; }
232 
236  static void GetAxialSliceToRASMatrix(vtkMatrix3x3* orientationMatrix, bool patientRightIsScreenLeft=true);
237 
241  static void GetSagittalSliceToRASMatrix(vtkMatrix3x3* orientationMatrix, bool patientRightIsScreenLeft=true);
242 
246  static void GetCoronalSliceToRASMatrix(vtkMatrix3x3* orientationMatrix, bool patientRightIsScreenLeft=true);
247 
253  static void AddDefaultSliceOrientationPresets(vtkMRMLScene* scene, bool patientRightIsScreenLeft=true);
254 
257  vtkGetVector3Macro(FieldOfView, double);
258  void SetFieldOfView(double x, double y, double z);
259 
262  vtkGetVector3Macro(XYZOrigin, double);
263  void SetXYZOrigin(double x, double y, double z);
264 
268  vtkGetVectorMacro(Dimensions,int,3)
269  void SetDimensions(int x, int y, int z);
270 
278  vtkGetVectorMacro(UVWDimensions,int,3)
279  void SetUVWDimensions(int x, int y, int z);
280  void SetUVWDimensions(int xyz[3]);
281 
284  vtkGetVectorMacro(UVWMaximumDimensions,int,3)
285  void SetUVWMaximumDimensions(int x, int y, int z);
286  void SetUVWMaximumDimensions(int xyz[3]);
287 
290  vtkGetVector3Macro(UVWExtents, double);
291  void SetUVWExtents(double x, double y, double z);
292  void SetUVWExtents(double xyz[3]);
293 
296  vtkGetVector3Macro(UVWOrigin, double);
297  void SetUVWOrigin(double x, double y, double z);
298  void SetUVWOrigin(double xyz[3]);
299 
302  void SetSliceOrigin(double xyz[3]);
303  void SetSliceOrigin(double x, double y, double z);
304 
308  void SetUVWExtentsAndDimensions (double extents[3], int dimensions[3]);
309 
310 
314  vtkMatrix4x4 *GetXYToSlice();
315 
319  vtkMatrix4x4 *GetXYToRAS();
320 
324  vtkMatrix4x4 *GetUVWToSlice();
325 
329  vtkMatrix4x4 *GetUVWToRAS();
330 
333  bool MatrixAreEqual(const vtkMatrix4x4 *m1, const vtkMatrix4x4 *m2);
334 
335  bool MatrixAreEqual(const vtkMatrix4x4 *matrix,
336  const vtkMatrix3x3 *orientationMatrix);
340  void UpdateMatrices();
341 
345  void SetLayoutGrid( int rows, int columns );
346 
349  vtkGetMacro(LayoutGridRows, int);
350  virtual void SetLayoutGridRows(int rows);
351 
354  vtkGetMacro(LayoutGridColumns, int);
355  virtual void SetLayoutGridColumns(int cols);
356 
363  void SetSliceToRASByNTP(double Nx, double Ny, double Nz,
364  double Tx, double Ty, double Tz,
365  double Px, double Py, double Pz,
366  int Orientation);
367 
371  void JumpSlice(double r, double a, double s);
372  void JumpAllSlices(double r, double a, double s);
379  static void JumpAllSlices(vtkMRMLScene* scene, double r, double a, double s,
380  int jumpMode = vtkMRMLSliceNode::DefaultJumpSlice, int viewGroup = -1, vtkMRMLSliceNode* exclude = nullptr);
381  void JumpSliceByOffsetting(double r, double a, double s);
382  void JumpSliceByOffsetting(int k, double r, double a, double s);
383  void JumpSliceByCentering(double r, double a, double s);
384 
386  enum {DefaultJumpSlice=-1, CenteredJumpSlice=0, OffsetJumpSlice};
387 
393  vtkSetMacro(JumpMode, int);
394  vtkGetMacro(JumpMode, int);
395  void SetJumpModeToCentered();
396  void SetJumpModeToOffset();
397 
400  enum {AutomaticSliceSpacingMode=0, PrescribedSliceSpacingMode};
401 
405  vtkGetMacro(SliceSpacingMode, int);
406  vtkSetMacro(SliceSpacingMode, int);
407  void SetSliceSpacingModeToAutomatic();
408  void SetSliceSpacingModeToPrescribed();
409 
413  vtkSetVector3Macro(PrescribedSliceSpacing, double);
414  vtkGetVector3Macro(PrescribedSliceSpacing, double);
415 
418  double GetSliceOffset();
419  void SetSliceOffset(double offset);
420 
423  vtkSetMacro(ActiveSlice, int);
424  vtkGetMacro(ActiveSlice, int);
425 
433  void RotateToVolumePlane(vtkMRMLVolumeNode *volumeNode, bool forceSlicePlaneToSingleSlice=true);
434 
442  void RotateToAxes(vtkMatrix4x4 *referenceToRAS, int sliceNormalAxisIndex=-1);
443 
449  void SetInteracting(int);
450  vtkGetMacro(Interacting, int);
451  vtkBooleanMacro(Interacting, int);
452 
468  {
469  None = 0,
470  SliceToRASFlag = 1,
471  FieldOfViewFlag = 2, // broadcast a specific field of view setting
472  OrientationFlag = 4,
473  ResetFieldOfViewFlag = 8, // broadcast a reset to all viewers
474  MultiplanarReformatFlag = 16, // broadcast reformat widget transformation
475  XYZOriginFlag = 32,
476  LabelOutlineFlag = 64,
477  SliceVisibleFlag = 128,
478  SliceSpacingFlag = 256,
479  ResetOrientationFlag = 512,
480  RotateToBackgroundVolumePlaneFlag = 1024
481  };
482 
488  void SetInteractionFlags(unsigned int);
489  vtkGetMacro(InteractionFlags, unsigned int);
490 
496  void SetInteractionFlagsModifier(unsigned int);
497  vtkGetMacro(InteractionFlagsModifier, unsigned int);
498 
502  void ResetInteractionFlagsModifier();
503 
504 
505 
507 
509  {
510  SliceResolutionMatchVolumes=0,
514  SliceResolutionCustom
515  };
516 
519  virtual void SetSliceResolutionMode(int mode);
520  vtkGetMacro(SliceResolutionMode, int);
521 
522 protected:
524  ~vtkMRMLSliceNode() override;
526  void operator=(const vtkMRMLSliceNode&);
527 
528  vtkSmartPointer<vtkMatrix4x4> SliceToRAS;
529 
530  vtkSmartPointer<vtkMatrix4x4> XYToSlice;
531  vtkSmartPointer<vtkMatrix4x4> XYToRAS;
532 
533  vtkSmartPointer<vtkMatrix4x4> UVWToSlice;
534  vtkSmartPointer<vtkMatrix4x4> UVWToRAS;
535 
536  typedef std::pair <std::string, vtkSmartPointer<vtkMatrix3x3> > OrientationPresetType;
537  std::vector< OrientationPresetType > OrientationMatrices;
538 
539  int JumpMode;
540 
546 
547  double FieldOfView[3];
548  double XYZOrigin[3];
549  double UVWOrigin[3];
550  int Dimensions[3];
551 
553  double UVWExtents[3];
554  int UVWDimensions[3];
555  int UVWMaximumDimensions[3];
556 
557  // Hold the string returned by GetOrientationString
558  std::string OrientationString;
559 
561 
563 
566 
568  double PrescribedSliceSpacing[3];
569 
571 
573  unsigned int InteractionFlags;
575 
577 
578  std::vector< std::string > ThreeDViewIDs;
579 };
580 
581 //----------------------------------------------------------------------------
582 std::vector< std::string > vtkMRMLSliceNode::GetThreeDViewIDs()const
583 {
584  return this->ThreeDViewIDs;
585 }
586 
587 #endif
unsigned int InteractionFlagsModifier
std::vector< std::string > ThreeDViewIDs
unsigned int InteractionFlags
MRML node for storing a slice through RAS space.
vtkSmartPointer< vtkMatrix4x4 > UVWToRAS
vtkSmartPointer< vtkMatrix4x4 > XYToRAS
void Reset(vtkMRMLNode *defaultNode) override
Reimplemented to preserve layout label when reset.
void operator=(const vtkMRMLAbstractViewNode &)
virtual vtkMRMLNode * CreateNodeInstance()=0
Create instance of the default node. Like New only virtual.
vtkSmartPointer< vtkMatrix4x4 > SliceToRAS
std::vector< std::string > GetThreeDViewIDs() const
Abstract MRML node to represent a view. The class holds the properties common to any view type (3D...
A set of MRML Nodes that supports serialization and undo/redo.
Definition: vtkMRMLScene.h:57
void ReadXMLAttributes(const char **atts) override
MRMLNode methods.
static const char * GetReformatOrientationName()
std::vector< OrientationPresetType > OrientationMatrices
MRML node for representing a volume (image stack).
const char * GetNodeTagName() override
Get node XML tag name (like Volume, Model)
vtkSmartPointer< vtkMatrix4x4 > XYToSlice
vtkMRMLCopyContentMacro(vtkMRMLAbstractViewNode)
void PrintSelf(ostream &os, vtkIndent indent) override
SliceResolutionModeType
Enum to specify the method for setting UVW extents.
Abstract Superclass for all specific types of MRML nodes.
Definition: vtkMRMLNode.h:167
vtkSmartPointer< vtkMatrix4x4 > UVWToSlice
std::pair< std::string, vtkSmartPointer< vtkMatrix3x3 > > OrientationPresetType
void WriteXML(ostream &of, int indent) override
Write this node&#39;s information to a MRML file in XML format.
std::string OrientationString