Slicer  4.11
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 
57  void Copy(vtkMRMLNode *node) override;
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 
234  static void InitializeAxialMatrix(vtkMatrix3x3* orientationMatrix);
235 
237  static void InitializeSagittalMatrix(vtkMatrix3x3* orientationMatrix);
238 
240  static void InitializeCoronalMatrix(vtkMatrix3x3* orientationMatrix);
241 
248  static void AddDefaultSliceOrientationPresets(vtkMRMLScene* scene);
249 
252  vtkGetVector3Macro(FieldOfView, double);
253  void SetFieldOfView(double x, double y, double z);
254 
257  vtkGetVector3Macro(XYZOrigin, double);
258  void SetXYZOrigin(double x, double y, double z);
259 
263  vtkGetVectorMacro(Dimensions,int,3)
264  void SetDimensions(int x, int y, int z);
265 
273  vtkGetVectorMacro(UVWDimensions,int,3)
274  void SetUVWDimensions(int x, int y, int z);
275  void SetUVWDimensions(int xyz[3]);
276 
279  vtkGetVectorMacro(UVWMaximumDimensions,int,3)
280  void SetUVWMaximumDimensions(int x, int y, int z);
281  void SetUVWMaximumDimensions(int xyz[3]);
282 
285  vtkGetVector3Macro(UVWExtents, double);
286  void SetUVWExtents(double x, double y, double z);
287  void SetUVWExtents(double xyz[3]);
288 
291  vtkGetVector3Macro(UVWOrigin, double);
292  void SetUVWOrigin(double x, double y, double z);
293  void SetUVWOrigin(double xyz[3]);
294 
297  void SetSliceOrigin(double xyz[3]);
298  void SetSliceOrigin(double x, double y, double z);
299 
303  void SetUVWExtentsAndDimensions (double extents[3], int dimensions[3]);
304 
305 
309  vtkMatrix4x4 *GetXYToSlice();
310 
314  vtkMatrix4x4 *GetXYToRAS();
315 
319  vtkMatrix4x4 *GetUVWToSlice();
320 
324  vtkMatrix4x4 *GetUVWToRAS();
325 
328  bool MatrixAreEqual(const vtkMatrix4x4 *m1, const vtkMatrix4x4 *m2);
329 
330  bool MatrixAreEqual(const vtkMatrix4x4 *matrix,
331  const vtkMatrix3x3 *orientationMatrix);
335  void UpdateMatrices();
336 
340  void SetLayoutGrid( int rows, int columns );
341 
344  vtkGetMacro(LayoutGridRows, int);
345  virtual void SetLayoutGridRows(int rows);
346 
349  vtkGetMacro(LayoutGridColumns, int);
350  virtual void SetLayoutGridColumns(int cols);
351 
358  void SetSliceToRASByNTP(double Nx, double Ny, double Nz,
359  double Tx, double Ty, double Tz,
360  double Px, double Py, double Pz,
361  int Orientation);
362 
366  void JumpSlice(double r, double a, double s);
367  void JumpAllSlices(double r, double a, double s);
374  static void JumpAllSlices(vtkMRMLScene* scene, double r, double a, double s,
375  int jumpMode = vtkMRMLSliceNode::DefaultJumpSlice, int viewGroup = -1, vtkMRMLSliceNode* exclude = nullptr);
376  void JumpSliceByOffsetting(double r, double a, double s);
377  void JumpSliceByOffsetting(int k, double r, double a, double s);
378  void JumpSliceByCentering(double r, double a, double s);
379 
381  enum {DefaultJumpSlice=-1, CenteredJumpSlice=0, OffsetJumpSlice};
382 
388  vtkSetMacro(JumpMode, int);
389  vtkGetMacro(JumpMode, int);
390  void SetJumpModeToCentered();
391  void SetJumpModeToOffset();
392 
395  enum {AutomaticSliceSpacingMode=0, PrescribedSliceSpacingMode};
396 
400  vtkGetMacro(SliceSpacingMode, int);
401  vtkSetMacro(SliceSpacingMode, int);
402  void SetSliceSpacingModeToAutomatic();
403  void SetSliceSpacingModeToPrescribed();
404 
408  vtkSetVector3Macro(PrescribedSliceSpacing, double);
409  vtkGetVector3Macro(PrescribedSliceSpacing, double);
410 
413  double GetSliceOffset();
414  void SetSliceOffset(double offset);
415 
418  vtkSetMacro(ActiveSlice, int);
419  vtkGetMacro(ActiveSlice, int);
420 
427  void RotateToVolumePlane(vtkMRMLVolumeNode *volumeNode);
428 
436  void RotateToAxes(vtkMatrix4x4 *referenceToRAS, int sliceNormalAxisIndex=-1);
437 
443  void SetInteracting(int);
444  vtkGetMacro(Interacting, int);
445  vtkBooleanMacro(Interacting, int);
446 
462  {
463  None = 0,
464  SliceToRASFlag = 1,
465  FieldOfViewFlag = 2, // broadcast a specific field of view setting
466  OrientationFlag = 4,
467  ResetFieldOfViewFlag = 8, // broadcast a reset to all viewers
468  MultiplanarReformatFlag = 16, // broadcast reformat widget transformation
469  XYZOriginFlag = 32,
470  LabelOutlineFlag = 64,
471  SliceVisibleFlag = 128,
472  SliceSpacingFlag = 256,
473  ResetOrientationFlag = 512,
474  };
475 
481  void SetInteractionFlags(unsigned int);
482  vtkGetMacro(InteractionFlags, unsigned int);
483 
489  void SetInteractionFlagsModifier(unsigned int);
490  vtkGetMacro(InteractionFlagsModifier, unsigned int);
491 
495  void ResetInteractionFlagsModifier();
496 
497 
498 
500 
502  {
503  SliceResolutionMatchVolumes=0,
507  SliceResolutionCustom
508  };
509 
512  virtual void SetSliceResolutionMode(int mode);
513  vtkGetMacro(SliceResolutionMode, int);
514 
515 protected:
517  ~vtkMRMLSliceNode() override;
519  void operator=(const vtkMRMLSliceNode&);
520 
521  vtkSmartPointer<vtkMatrix4x4> SliceToRAS;
522 
523  vtkSmartPointer<vtkMatrix4x4> XYToSlice;
524  vtkSmartPointer<vtkMatrix4x4> XYToRAS;
525 
526  vtkSmartPointer<vtkMatrix4x4> UVWToSlice;
527  vtkSmartPointer<vtkMatrix4x4> UVWToRAS;
528 
529  typedef std::pair <std::string, vtkSmartPointer<vtkMatrix3x3> > OrientationPresetType;
530  std::vector< OrientationPresetType > OrientationMatrices;
531 
532  int JumpMode;
533 
539 
540  double FieldOfView[3];
541  double XYZOrigin[3];
542  double UVWOrigin[3];
543  int Dimensions[3];
544 
546  double UVWExtents[3];
547  int UVWDimensions[3];
548  int UVWMaximumDimensions[3];
549 
550  // Hold the string returned by GetOrientationString
551  std::string OrientationString;
552 
554 
556 
559 
561  double PrescribedSliceSpacing[3];
562 
564 
566  unsigned int InteractionFlags;
568 
570 
571  std::vector< std::string > ThreeDViewIDs;
572 };
573 
574 //----------------------------------------------------------------------------
575 std::vector< std::string > vtkMRMLSliceNode::GetThreeDViewIDs()const
576 {
577  return this->ThreeDViewIDs;
578 }
579 
580 #endif
unsigned int InteractionFlagsModifier
std::vector< std::string > ThreeDViewIDs
unsigned int InteractionFlags
void Copy(vtkMRMLNode *node) override
Copy the node&#39;s attributes to this object.
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:56
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
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:139
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