21 #ifndef __vtkMRMLMarkupsPlaneNode_h 22 #define __vtkMRMLMarkupsPlaneNode_h 30 #include "vtkSlicerMarkupsModuleMRMLExport.h" 33 #include <vtkMatrix4x4.h> 61 void PrintSelf(ostream& os, vtkIndent indent)
override;
63 const char*
GetIcon()
override {
return ":/Icons/MarkupsPlane.png";}
64 const char*
GetAddIcon()
override {
return ":/Icons/MarkupsPlaneMouseModePlace.png";}
65 const char*
GetPlaceAddIcon()
override {
return ":/Icons/MarkupsPlaneMouseModePlaceAdd.png";}
104 void WriteXML(ostream& of,
int indent)
override;
114 void SetSizeMode(
int sizeMode);
119 vtkGetMacro(SizeMode,
int);
120 static const char* GetSizeModeAsString(
int sizeMode);
121 static int GetSizeModeFromString(
const char* sizeMode);
127 vtkGetMacro(AutoSizeScalingFactor,
double);
128 vtkSetMacro(AutoSizeScalingFactor,
double);
132 void GetSize(
double size[2]);
137 double* GetSize() VTK_SIZEHINT(2);
138 virtual
void SetSize(
double x,
double y);
139 virtual
void SetSize(
double size[2]) { this->
SetSize(size[0], size[1]); }
143 void GetSizeWorld(
double size[2]);
148 double* GetSizeWorld() VTK_SIZEHINT(2);
149 void SetSizeWorld(const
double normal[2]);
150 void SetSizeWorld(
double x,
double y);
154 vtkGetVector4Macro(PlaneBounds,
double);
156 virtual
void SetPlaneBounds(
double x0,
double x1,
double y0,
double y1);
157 virtual
void SetPlaneBounds(
double bounds[4]) { this->
SetPlaneBounds(bounds[0], bounds[1], bounds[2], bounds[3]); };
161 void GetNormal(
double normal[3]);
163 double* GetNormal() VTK_SIZEHINT(3);
164 void GetNormalWorld(
double normal[3]);
165 double* GetNormalWorld() VTK_SIZEHINT(3);
166 void SetNormal(const
double normal[3]);
167 void SetNormal(
double x,
double y,
double z);
168 void SetNormalWorld(const
double normal[3]);
169 void SetNormalWorld(
double x,
double y,
double z);
173 void GetOrigin(
double origin[3]);
175 double* GetOrigin() VTK_SIZEHINT(3);
176 void GetOriginWorld(
double origin[3]);
177 double* GetOriginWorld() VTK_SIZEHINT(3);
178 void SetOrigin(const
double origin[3]);
179 void SetOrigin(
double x,
double y,
double z);
180 void SetOriginWorld(const
double origin[3]);
181 void SetOriginWorld(
double x,
double y,
double z);
185 void GetCenter(
double origin[3]) { this->GetOrigin(origin); };
187 double*
GetCenter() VTK_SIZEHINT(3) {
return this->GetOrigin(); };
190 void SetCenter(
const double origin[3]) { this->SetOrigin(origin); };
191 void SetCenter(
double x,
double y,
double z) { this->SetOrigin(x, y, z); };
193 void SetCenterWorld(
double x,
double y,
double z) { this->SetOriginWorld(x, y, z); };
197 void GetAxes(
double x[3],
double y[3],
double z[3]);
203 void SetAxes(
const double x[3],
const double y[3],
const double z[3]);
204 void GetAxesWorld(
double x[3],
double y[3],
double z[3]);
205 void SetAxesWorld(
const double x[3],
const double y[3],
const double z[3]);
209 virtual void GetObjectToNodeMatrix(vtkMatrix4x4* objectToNodeMatrix);
211 virtual void GetObjectToWorldMatrix(vtkMatrix4x4* objectToWorldMatrix);
213 virtual void GetBaseToWorldMatrix(vtkMatrix4x4* baseToWorldMatrix);
215 virtual void GetBaseToNodeMatrix(vtkMatrix4x4* matrix);
217 virtual vtkMatrix4x4* GetBaseToNodeMatrix();
222 virtual vtkMatrix4x4* GetObjectToBaseMatrix();
231 double GetClosestPointOnPlaneWorld(
const double posWorld[3],
double closestPosWorld[3],
bool infinitePlane =
true);
243 void GetBounds(
double bounds[6])
override;
247 vtkGetMacro(PlaneType,
int);
253 void SetPlaneType(
int planeType);
254 static const char* GetPlaneTypeAsString(
int planeType);
255 static int GetPlaneTypeFromString(
const char* planeType);
259 vtkGetMacro(IsPlaneValid,
bool);
262 static void GenerateOrthogonalMatrix(vtkMatrix4x4* inputMatrix,
265 vtkMatrix4x4* outputMatrix, vtkAbstractTransform* transform =
nullptr,
bool applyScaling =
true);
266 static void GenerateOrthogonalMatrix(
double xAxis[3],
double yAxis[3],
double zAxis[3],
double origin[3],
267 vtkMatrix4x4* outputMatrix, vtkAbstractTransform* transform =
nullptr,
bool applyScaling =
true);
271 void ProcessMRMLEvents(vtkObject* caller,
unsigned long event,
void* callData)
override;
274 void GetPlaneCornerPoints(vtkPoints* points_Node);
276 void GetPlaneCornerPointsWorld(vtkPoints* points_World);
281 vtkSetMacro(MaximumNumberOfControlPoints,
int);
282 vtkSetMacro(RequiredNumberOfControlPoints,
int);
285 vtkSetMacro(IsPlaneValid,
bool);
291 void CalculateAxesFromPoints(
const double point0[3],
const double point1[3],
const double point2[3],
double x[3],
double y[3],
double z[3]);
294 void CalculatePlaneBounds(vtkPoints* cornerPoints,
double bounds[6]);
297 void CalculatePlaneCornerPoints(vtkPoints* points,
double xAxis[3],
double yAxis[3],
double center[3],
double size[2]);
300 virtual void UpdatePlaneFromControlPoints();
301 virtual void UpdatePlaneFromPointNormal();
302 virtual void UpdatePlaneFrom3Points();
303 virtual void UpdatePlaneFromPlaneFit();
304 virtual void UpdatePlaneSize();
307 virtual void UpdateControlPointsFromPlane();
308 virtual void UpdateControlPointsFromPointNormal();
309 virtual void UpdateControlPointsFrom3Points();
310 virtual void UpdateControlPointsFromPlaneFit();
311 bool GetClosestFitPlaneFromControlPoints(vtkMatrix4x4* closestFitPlane);
318 virtual void SetNormalPointRequired(
bool);
319 vtkGetMacro(NormalPointRequired,
bool);
322 bool IsUpdatingControlPointsFromPlane{
false };
323 bool IsUpdatingPlaneFromControlPoints{
false };
325 int SizeMode{ SizeModeAuto };
326 double AutoSizeScalingFactor{ 1.0 };
331 double Size[2] = { 100.0, 100.0 };
332 double PlaneBounds[4] = { -50.0, 50.0, -50.0, 50.0 };
335 double Normal[3] = { 0.0, 0.0, 0.0 };
336 double NormalWorld[3] = { 0.0, 0.0, 0.0 };
337 double Origin[3] = { 0.0, 0.0, 0.0 };
338 double OriginWorld[3] = { 0.0, 0.0, 0.0 };
339 double SizeWorld[2] = { 0.0, 0.0 };
341 int PlaneType{ PlaneTypePointNormal };
342 bool IsPlaneValid{
false };
343 bool NormalPointRequired{
false };
void ApplyTransform(vtkAbstractTransform *transform) override
vtkSmartPointer< vtkMatrix4x4 > BaseToNodeMatrix
const char * GetIcon() override
double * GetCenter() VTK_SIZEHINT(3)
void SetCenter(const double origin[3])
const char * GetTypeDisplayName() override
virtual void SetPlaneBounds(double bounds[4])
void operator=(const vtkMRMLMarkupsNode &)
void CreateDefaultDisplayNodes() override
Create and observe default display node(s)
void GetBounds(double bounds[6]) override
void GetRASBounds(double bounds[6]) override
void OnTransformNodeReferenceChanged(vtkMRMLTransformNode *transformNode) override
Called when transform node reference added/modified/removed.
void SetCenter(double x, double y, double z)
void GetCenterWorld(double origin[3])
const char * GetNodeTagName() override
Get node XML tag name (like Volume, Model)
virtual void UpdateInteractionHandleToWorldMatrix()
Calculates the handle to world matrix based on the current control points.
void SetCenterWorld(double x, double y, double z)
const char * GetMarkupType() override
Get markup type internal name.
const char * GetDefaultNodeNamePrefix() override
Get markup short name.
MRML node to represent a plane markup Plane Markups nodes contain three control points. Visualization parameters are set in the vtkMRMLMarkupsDisplayNode class.
Default representation for the plane widget.
vtkMRMLCopyContentMacro(vtkMRMLMarkupsNode)
vtkMRMLStorageNode * CreateDefaultStorageNode() override
Create default storage node or nullptr if does not have one.
A superclass for other storage nodes.
vtkSmartPointer< vtkMatrix4x4 > ObjectToBaseMatrix
vtkMRMLNode * CreateNodeInstance() override=0
MRMLNode methods.
const char * GetAddIcon() override
double * GetCenterWorld() VTK_SIZEHINT(3)
void ReadXMLAttributes(const char **atts) override
Read node attributes from XML file.
virtual void SetSize(double size[2])
Abstract Superclass for all specific types of MRML nodes.
void SetCenterWorld(const double origin[3])
const char * GetPlaceAddIcon() override
void WriteXML(ostream &of, int indent) override
Write this node's information to a MRML file in XML format.
Default representation for the plane widget.
void ProcessMRMLEvents(vtkObject *, unsigned long, void *) override
Alternative method to propagate events generated in Display nodes.
void PrintSelf(ostream &os, vtkIndent indent) override