Slicer  4.11
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
vtkMRMLMarkupsROINode.h
Go to the documentation of this file.
1 /*==============================================================================
2 
3  Copyright (c) Laboratory for Percutaneous Surgery (PerkLab)
4  Queen's University, Kingston, ON, Canada. All Rights Reserved.
5 
6  See COPYRIGHT.txt
7  or http://www.slicer.org/copyright/copyright.txt for details.
8 
9  Unless required by applicable law or agreed to in writing, software
10  distributed under the License is distributed on an "AS IS" BASIS,
11  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  See the License for the specific language governing permissions and
13  limitations under the License.
14 
15  This file was centerally developed by Kyle Sunderland, PerkLab, Queen's University
16  and was supported through CANARIE's Research Software Program, Cancer
17  Care Ontario, OpenAnatomy, and Brigham and Women's Hospital through NIH grant R01MH112748.
18 
19 ==============================================================================*/
20 
21 #ifndef __vtkMRMLMarkupsROINode_h
22 #define __vtkMRMLMarkupsROINode_h
23 
24 // MRML includes
25 #include "vtkMRMLDisplayableNode.h"
26 #include "vtkMRMLModelNode.h"
27 
28 // Markups includes
29 #include "vtkSlicerMarkupsModuleMRMLExport.h"
31 #include "vtkMRMLMarkupsNode.h"
32 
33 // VTK includes
34 #include <vtkMatrix4x4.h>
35 #include <vtkSmartPointer.h>
36 #include <vtkStringArray.h>
37 #include <vtkTransform.h>
38 
39 // std includes
40 #include <vector>
41 
42 class vtkImplicitFunction;
43 class vtkPlanes;
44 
53 class VTK_SLICER_MARKUPS_MODULE_MRML_EXPORT vtkMRMLMarkupsROINode : public vtkMRMLMarkupsNode
54 {
55 public:
56  static vtkMRMLMarkupsROINode *New();
59  void PrintSelf(ostream& os, vtkIndent indent) override;
60 
61  const char* GetIcon() override {return ":/Icons/MarkupsCurveMouseModePlace.png";}
62 
63  //--------------------------------------------------------------------------
64  // MRMLNode methods
65  //--------------------------------------------------------------------------
66 
67  vtkMRMLNode* CreateNodeInstance() override;
69  const char* GetNodeTagName() override {return "MarkupsROI";}
70 
74 
76  vtkGetVector3Macro(Size, double);
77  void SetSize(const double size[3]);
78  void SetSize(double x, double y, double z);
79 
81  void GetCenter(double center[3]);
82  void GetCenterWorld(double center[3]);
83  void SetCenterWorld(const double center[3]);
84  void SetCenter(const double center[3]);
85 
88  void GetXAxisWorld(double axis_World[3]);
89  void GetYAxisWorld(double axis_World[3]);
90  void GetZAxisWorld(double axis_World[3]);
91  void GetAxisWorld(int axisIndex, double axis_World[3]);
92  void GetXAxisLocal(double axis_Local[3]);
93  void GetYAxisLocal(double axis_Local[3]);
94  void GetZAxisLocal(double axis_Local[3]);
95  void GetAxisLocal(int axisIndex, double axis_Local[3]);
96 
98  vtkMatrix4x4* GetROIToLocalMatrix()
99  {
100  return this->ROIToLocalMatrix;
101  };
102 
104  void GetBoundsROI(double bounds[6]);
105 
108  vtkGetMacro(ROIType, int);
109  void SetROIType(int roiType);
110  static const char* GetROITypeAsString(int roiType);
111  static int GetROITypeFromString(const char* roiType);
112 
114  virtual void UpdateROIFromControlPoints();
115  virtual void UpdateBoxROIFromControlPoints();
116  virtual void UpdateBoundingBoxROIFromControlPoints();
117 
119  virtual void UpdateControlPointsFromROI();
120  virtual void UpdateControlPointsFromBoundingBoxROI();
121  virtual void UpdateControlPointsFromBoxROI();
122 
123  // ROI type enum defines the calculation method that should be used to convert to and from control points.
124  enum
125  {
126  ROITypeBox, // Requires two Control points that are removed after they have been placed.
127  ROITypeBoundingBox, // ROI forms a bounding box around the control points.
128  ROIType_Last
129  };
130 
131  // Scale handle indexes
132  enum
133  {
140 
149  };
150 
152  void OnTransformNodeReferenceChanged(vtkMRMLTransformNode* transformNode) override;
153 
154 
155  void ProcessMRMLEvents(vtkObject* caller, unsigned long event, void* callData) override;
156 
158  void UpdateInteractionHandleToWorldMatrix() override;
159 
162 
164  void CreateDefaultDisplayNodes() override;
165 
169 
179  int SetXYZ(double center[3]);
180  int SetXYZ(double x, double y, double z);
181  bool GetXYZ(double center[3]);
182 
190  void SetRadiusXYZ(double radiusXYZ[3]);
191  void SetRadiusXYZ(double x, double y, double z);
192  void GetRadiusXYZ(double radiusXYZ[3]);
193 
195  void GetTransformedPlanes(vtkPlanes* planes);
196 
199  vtkSetMacro(InsideOut, bool);
200  vtkGetMacro(InsideOut, bool);
201  vtkBooleanMacro(InsideOut, bool);
202 
203 protected:
204  bool InsideOut{false};
206 
207  double Size[3]{ 0.0, 0.0, 0.0 };
208 
209  bool IsUpdatingControlPointsFromROI{false};
210  bool IsUpdatingROIFromControlPoints{false};
211 
212  vtkSmartPointer<vtkMatrix4x4> ROIToLocalMatrix;
213 
215  ~vtkMRMLMarkupsROINode() override;
217  void operator=(const vtkMRMLMarkupsROINode&);
218 };
219 
220 #endif
static vtkMRMLMarkupsNode * New()
MRML node to represent an ROI markup.
MRML node for representing a transformation between this node space and a parent node space...
void operator=(const vtkMRMLMarkupsNode &)
void CreateDefaultDisplayNodes() override
Create and observe default display node(s)
void OnTransformNodeReferenceChanged(vtkMRMLTransformNode *transformNode) override
Called when transform node reference added/modified/removed.
virtual void UpdateInteractionHandleToWorldMatrix()
Calculates the handle to world matrix based on the current control points.
const char * GetNodeTagName() override
Get node XML tag name (like Volume, Model)
vtkMRMLCopyContentMacro(vtkMRMLMarkupsNode)
const char * GetIcon() override
vtkMRMLStorageNode * CreateDefaultStorageNode() override
Create default storage node or nullptr if does not have one.
A superclass for other storage nodes.
vtkMRMLNode * CreateNodeInstance() override
MRMLNode methods.
vtkMatrix4x4 * GetROIToLocalMatrix()
4x4 matrix defining the ROI center and axis directions within the local coordinate system...
vtkSmartPointer< vtkMatrix4x4 > ROIToLocalMatrix
Abstract Superclass for all specific types of MRML nodes.
Definition: vtkMRMLNode.h:167
void ProcessMRMLEvents(vtkObject *, unsigned long, void *) override
Alternative method to propagate events generated in Display nodes.
void PrintSelf(ostream &os, vtkIndent indent) override