VTK  9.2.6
vtkImagePlaneWidget.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: Visualization Toolkit
4 Module: vtkImagePlaneWidget.h
5
6 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7 All rights reserved.
8 See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9
10 This software is distributed WITHOUT ANY WARRANTY; without even
11 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12 PURPOSE. See the above copyright notice for more information.
13
14=========================================================================*/
107
108#ifndef vtkImagePlaneWidget_h
109#define vtkImagePlaneWidget_h
110
111#include "vtkInteractionWidgetsModule.h" // For export macro
113
114class vtkActor;
116class vtkDataSetMapper;
117class vtkImageData;
119class vtkImageReslice;
120class vtkLookupTable;
121class vtkMatrix4x4;
122class vtkPlaneSource;
123class vtkPoints;
124class vtkPolyData;
125class vtkProperty;
126class vtkTextActor;
127class vtkTextProperty;
128class vtkTexture;
129class vtkTransform;
130
131#define VTK_NEAREST_RESLICE 0
132#define VTK_LINEAR_RESLICE 1
133#define VTK_CUBIC_RESLICE 2
134
135// Private.
136#define VTK_IMAGE_PLANE_WIDGET_MAX_TEXTBUFF 128
137
138class VTKINTERACTIONWIDGETS_EXPORT vtkImagePlaneWidget : public vtkPolyDataSourceWidget
139{
140public:
145
147 void PrintSelf(ostream& os, vtkIndent indent) override;
148
150
153 void SetEnabled(int) override;
154 void PlaceWidget(double bounds[6]) override;
155 void PlaceWidget() override { this->Superclass::PlaceWidget(); }
157 double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
158 {
159 this->Superclass::PlaceWidget(xmin, xmax, ymin, ymax, zmin, zmax);
160 }
161
162
167
169
172 void SetOrigin(double x, double y, double z);
173 void SetOrigin(double xyz[3]);
175 void GetOrigin(double xyz[3]);
177
179
182 void SetPoint1(double x, double y, double z);
183 void SetPoint1(double xyz[3]);
185 void GetPoint1(double xyz[3]);
187
189
192 void SetPoint2(double x, double y, double z);
193 void SetPoint2(double xyz[3]);
195 void GetPoint2(double xyz[3]);
197
199
203 void GetCenter(double xyz[3]);
205
207
211 void GetNormal(double xyz[3]);
213
217 void GetVector1(double v1[3]);
218
222 void GetVector2(double v2[3]);
223
228
232 void SetSliceIndex(int index);
233
238
242 void SetSlicePosition(double position);
243
245
249 vtkGetMacro(ResliceInterpolate, int);
257
262
264
272
274
283
285
295
297
305
315
323
328 void UpdatePlacement(void) override;
329
335
337
343 vtkGetObjectMacro(ColorMap, vtkImageMapToColors);
346
348
353 vtkGetObjectMacro(PlaneProperty, vtkProperty);
357
359
364 vtkGetMacro(PlaneOrientation, int);
369
377
379
387 vtkGetObjectMacro(LookupTable, vtkLookupTable);
389
391
397 vtkBooleanMacro(DisplayText, vtkTypeBool);
399
401
405 vtkGetObjectMacro(CursorProperty, vtkProperty);
407
409
413 vtkGetObjectMacro(MarginProperty, vtkProperty);
415
417
421 vtkSetClampMacro(MarginSizeX, double, 0.0, 0.5);
422 vtkGetMacro(MarginSizeX, double);
423 vtkSetClampMacro(MarginSizeY, double, 0.0, 0.5);
424 vtkGetMacro(MarginSizeY, double);
426
428
434
436
442
444
450 void SetWindowLevel(double window, double level, int copy = 0);
451 void GetWindowLevel(double wl[2]);
452 double GetWindow() { return this->CurrentWindow; }
453 double GetLevel() { return this->CurrentLevel; }
455
460 int GetCursorData(double xyzv[4]);
461
468
470
474 vtkGetVectorMacro(CurrentCursorPosition, double, 3);
476
478
483 vtkGetMacro(CurrentImageValue, double);
485
487
490 vtkGetObjectMacro(ResliceAxes, vtkMatrix4x4);
491 vtkGetObjectMacro(Reslice, vtkImageReslice);
493
495
506
508
513 vtkBooleanMacro(Interaction, vtkTypeBool);
515
517
520 enum
521 {
525 };
527 vtkGetMacro(LeftButtonAction, int);
529 vtkGetMacro(MiddleButtonAction, int);
531 vtkGetMacro(RightButtonAction, int);
533
535
543 enum
544 {
548 };
550 vtkGetMacro(LeftButtonAutoModifier, int);
552 vtkGetMacro(MiddleButtonAutoModifier, int);
554 vtkGetMacro(RightButtonAutoModifier, int);
556
557protected:
560
562
566
570
571 enum
572 {
577 };
579
580 // Manage the state of the widget
581 int State;
594
595 // Handles the events
596 static void ProcessEvents(
597 vtkObject* object, unsigned long event, void* clientdata, void* calldata);
598
599 // internal utility method that adds observers to the RenderWindowInteractor
600 // so that our ProcessEvents is eventually called. this method is called
601 // by SetEnabled as well as SetInteraction
603
604 // ProcessEvents() dispatches to these methods.
605 virtual void OnMouseMove();
606 virtual void OnLeftButtonDown();
607 virtual void OnLeftButtonUp();
608 virtual void OnMiddleButtonDown();
609 virtual void OnMiddleButtonUp();
610 virtual void OnRightButtonDown();
611 virtual void OnRightButtonUp();
612 void OnChar() override;
613
614 virtual void StartCursor();
615 virtual void StopCursor();
616 virtual void StartSliceMotion();
617 virtual void StopSliceMotion();
618 virtual void StartWindowLevel();
619 virtual void StopWindowLevel();
620
621 // controlling ivars
622 vtkTypeBool Interaction; // Is the widget responsive to mouse events
637
638 // The geometric representation of the plane and it's outline
642 void HighlightPlane(int highlight);
644
645 // Re-builds the plane outline based on the plane source
647
648 // Do the picking
650
651 // Register internal Pickers within PickingManager
652 void RegisterPickers() override;
653
654 // for negative window values.
656
657 // Methods to manipulate the plane
658 void WindowLevel(int X, int Y);
659 void Push(double* p1, double* p2);
660 void Spin(double* p1, double* p2);
661 void Rotate(double* p1, double* p2, double* vpn);
662 void Scale(double* p1, double* p2, int X, int Y);
663 void Translate(double* p1, double* p2);
664
674
675 // Properties used to control the appearance of selected objects and
676 // the manipulator in general. The plane property is actually that for
677 // the outline. The TexturePlaneProperty can be used to control the
678 // lighting etc. of the resliced image data.
685
686 // Reslice and texture management
689
690 // The cross-hair cursor
694 double CurrentImageValue; // Set to VTK_DOUBLE_MAX when invalid
696 void UpdateCursor(int, int);
697 void ActivateCursor(int);
699 int UpdateDiscreteCursor(double* q);
701
702 // The text to display W/L, image data
707 void ActivateText(int);
708
709 // Oblique reslice control
710 double RotateAxis[3];
711 double RadiusVector[3];
713
714 // Visible margins to assist user interaction
723
724private:
726 void operator=(const vtkImagePlaneWidget&) = delete;
727};
728
729#endif
virtual void PlaceWidget()
This method is used to initially place the widget.
abstract API for pickers that can pick an instance of vtkProp
represents an object (geometry & properties) in a rendered scene
Definition vtkActor.h:46
Proxy object to connect input/output ports.
map vtkDataSet and derived classes to graphics primitives
topologically and geometrically regular array of data
map the input image through a lookup table
void SetPicker(vtkAbstractPropPicker *)
Set the internal picker to one defined by the user.
virtual void StartSliceMotion()
virtual void StartWindowLevel()
void GetPolyData(vtkPolyData *pd)
Grab the polydata (including points) that defines the plane.
double * GetPoint1()
Set/Get the position of the point defining the first axis of the plane.
void GetVector1(double v1[3])
Get the vector from the plane origin to point1.
vtkProperty * SelectedPlaneProperty
void SetPlaneOrientationToZAxes()
Convenience method sets the plane orientation normal to the x, y, or z axes.
double * GetOrigin()
Set/Get the origin of the plane.
void PlaceWidget() override
Methods that satisfy the superclass' API.
void WindowLevel(int X, int Y)
void SetSlicePosition(double position)
Set the position of the slice along its normal.
vtkAbstractPropPicker * PlanePicker
vtkProperty * TexturePlaneProperty
void SetPlaneOrientation(int)
Convenience method sets the plane orientation normal to the x, y, or z axes.
vtkPlaneSource * PlaneSource
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void SetResliceInterpolate(int)
Set the interpolation to use when texturing the plane.
void Rotate(double *p1, double *p2, double *vpn)
void Push(double *p1, double *p2)
virtual void SetSelectedPlaneProperty(vtkProperty *)
Set/Get the plane's outline properties.
vtkLookupTable * LookupTable
double GetWindow()
Set/Get the current window and level values.
void ActivateCursor(int)
virtual void SetCursorProperty(vtkProperty *)
Set the properties of the cross-hair cursor.
virtual void StopWindowLevel()
virtual void StartCursor()
virtual void OnMiddleButtonUp()
virtual void SetMarginProperty(vtkProperty *)
Set the properties of the margins.
double * GetPoint2()
Set/Get the position of the point defining the second axis of the plane.
~vtkImagePlaneWidget() override
void SetOrigin(double x, double y, double z)
Set/Get the origin of the plane.
static vtkImagePlaneWidget * New()
Instantiate the object.
virtual void StopSliceMotion()
double GetLevel()
Set/Get the current window and level values.
void SetPlaneOrientationToYAxes()
Convenience method sets the plane orientation normal to the x, y, or z axes.
void PlaceWidget(double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
Methods that satisfy the superclass' API.
void SetPoint1(double x, double y, double z)
Set/Get the position of the point defining the first axis of the plane.
virtual void SetTextureVisibility(vtkTypeBool)
Control the visibility of the actual texture mapped reformatted plane.
virtual void SetTexturePlaneProperty(vtkProperty *)
Set/Get the property for the resliced image.
void Translate(double *p1, double *p2)
void SetResliceInterpolateToCubic()
Set the interpolation to use when texturing the plane.
virtual void OnMouseMove()
int GetSliceIndex()
Get the slice position in terms of the data extent.
vtkTexture * GetTexture()
Convenience method to get the texture used by this widget.
double * GetNormal()
Get the normal to the plane.
void CreateDefaultProperties()
void HighlightPlane(int highlight)
void SetResliceInterpolateToNearestNeighbour()
Set the interpolation to use when texturing the plane.
void SetResliceInterpolateToLinear()
Set the interpolation to use when texturing the plane.
vtkPolyDataAlgorithm * GetPolyDataAlgorithm() override
Satisfies superclass API.
void SetInputConnection(vtkAlgorithmOutput *aout) override
Set the vtkImageData* input for the vtkImageReslice.
int UpdateContinuousCursor(double *q)
void SetWindowLevel(double window, double level, int copy=0)
Set/Get the current window and level values.
int GetCursorData(double xyzv[4])
Get the image coordinate position and voxel value.
static void ProcessEvents(vtkObject *object, unsigned long event, void *clientdata, void *calldata)
virtual void SetLookupTable(vtkLookupTable *)
Set/Get the internal lookuptable (lut) to one defined by the user, or, alternatively,...
void SetPoint2(double x, double y, double z)
Set/Get the position of the point defining the second axis of the plane.
void SetEnabled(int) override
Methods that satisfy the superclass' API.
vtkTypeBool UserControlledLookupTable
double GetSlicePosition()
Get the position of the slice along its normal.
void SetOrigin(double xyz[3])
Set/Get the origin of the plane.
void Spin(double *p1, double *p2)
vtkImageData * GetResliceOutput()
Convenience method to get the vtkImageReslice output.
void ActivateMargins(int)
void GetVector2(double v2[3])
Get the vector from the plane origin to point2.
vtkTextProperty * GetTextProperty()
Set/Get the text property for the image data and window-level annotation.
char TextBuff[VTK_IMAGE_PLANE_WIDGET_MAX_TEXTBUFF]
void SetSliceIndex(int index)
Set the slice position in terms of the data extent.
int UpdateDiscreteCursor(double *q)
virtual void OnMiddleButtonDown()
void GetWindowLevel(double wl[2])
Set/Get the current window and level values.
void SetTextProperty(vtkTextProperty *tprop)
Set/Get the text property for the image data and window-level annotation.
virtual void OnRightButtonUp()
virtual void SetPlaneProperty(vtkProperty *)
Set/Get the plane's outline properties.
int GetCursorDataStatus()
Get the status of the cursor data.
void PlaceWidget(double bounds[6]) override
Methods that satisfy the superclass' API.
virtual void StopCursor()
virtual void OnLeftButtonUp()
vtkImageMapToColors * ColorMap
vtkImageReslice * Reslice
vtkLookupTable * CreateDefaultLookupTable()
void UpdateCursor(int, int)
void SetInteraction(vtkTypeBool interact)
Enable/disable mouse interaction so the widget remains on display.
double * GetCenter()
Get the center of the plane.
virtual void SetColorMap(vtkImageMapToColors *)
Convenience method to get the vtkImageMapToColors filter used by this widget.
virtual void OnLeftButtonDown()
void UpdatePlacement(void) override
Satisfies superclass API.
void RegisterPickers() override
Register internal Pickers in the Picking Manager.
virtual void OnRightButtonDown()
vtkPolyData * PlaneOutlinePolyData
void SetPlaneOrientationToXAxes()
Convenience method sets the plane orientation normal to the x, y, or z axes.
void OnChar() override
Sets up the keypress-i event.
void ActivateText(int)
void Scale(double *p1, double *p2, int X, int Y)
Reslices a volume along a new set of axes.
a simple class to control print indentation
Definition vtkIndent.h:34
map scalar values into colors via a lookup table
represent and manipulate 4x4 transformation matrices
abstract base class for most VTK objects
Definition vtkObject.h:57
create an array of quadrilaterals located in a plane
represent and manipulate 3D points
Definition vtkPoints.h:34
Superclass for algorithms that produce only polydata as output.
vtkPolyDataSourceWidget()
Empty constructor that calls the parent constructor.
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition vtkPolyData.h:85
represent surface properties of a geometric object
Definition vtkProperty.h:62
An actor that displays text.
represent text properties.
handles properties associated with a texture map
Definition vtkTexture.h:66
describes linear transformations via a 4x4 matrix
int vtkTypeBool
Definition vtkABI.h:69
#define VTK_LINEAR_RESLICE
#define VTK_CUBIC_RESLICE
#define VTK_IMAGE_PLANE_WIDGET_MAX_TEXTBUFF
#define VTK_NEAREST_RESLICE
#define VTK_SIZEHINT(...)