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=========================================================================*/
130#ifndef vtkImagePlaneWidget_h
131#define vtkImagePlaneWidget_h
132
133#include "vtkInteractionWidgetsModule.h" // For export macro
135
136class vtkActor;
138class vtkDataSetMapper;
139class vtkImageData;
141class vtkImageReslice;
142class vtkLookupTable;
143class vtkMatrix4x4;
144class vtkPlaneSource;
145class vtkPoints;
146class vtkPolyData;
147class vtkProperty;
148class vtkTextActor;
149class vtkTextProperty;
150class vtkTexture;
151class vtkTransform;
152
153#define VTK_NEAREST_RESLICE 0
154#define VTK_LINEAR_RESLICE 1
155#define VTK_CUBIC_RESLICE 2
156
157// Private.
158#define VTK_IMAGE_PLANE_WIDGET_MAX_TEXTBUFF 128
159
160class VTKINTERACTIONWIDGETS_EXPORT vtkImagePlaneWidget : public vtkPolyDataSourceWidget
161{
162public:
167
169 void PrintSelf(ostream& os, vtkIndent indent) override;
170
172
175 void SetEnabled(int) override;
176 void PlaceWidget(double bounds[6]) override;
177 void PlaceWidget() override { this->Superclass::PlaceWidget(); }
179 double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
180 {
181 this->Superclass::PlaceWidget(xmin, xmax, ymin, ymax, zmin, zmax);
182 }
184
189
191
194 void SetOrigin(double x, double y, double z);
195 void SetOrigin(double xyz[3]);
197 void GetOrigin(double xyz[3]);
199
201
204 void SetPoint1(double x, double y, double z);
205 void SetPoint1(double xyz[3]);
206 double* GetPoint1() VTK_SIZEHINT(3);
207 void GetPoint1(double xyz[3]);
209
211
214 void SetPoint2(double x, double y, double z);
215 void SetPoint2(double xyz[3]);
216 double* GetPoint2() VTK_SIZEHINT(3);
217 void GetPoint2(double xyz[3]);
219
221
224 double* GetCenter() VTK_SIZEHINT(3);
225 void GetCenter(double xyz[3]);
227
229
232 double* GetNormal() VTK_SIZEHINT(3);
233 void GetNormal(double xyz[3]);
235
239 void GetVector1(double v1[3]);
240
244 void GetVector2(double v2[3]);
245
249 int GetSliceIndex();
250
254 void SetSliceIndex(int index);
255
259 double GetSlicePosition();
260
264 void SetSlicePosition(double position);
265
267
270 void SetResliceInterpolate(int);
271 vtkGetMacro(ResliceInterpolate, int);
272 void SetResliceInterpolateToNearestNeighbour()
273 {
274 this->SetResliceInterpolate(VTK_NEAREST_RESLICE);
275 }
276 void SetResliceInterpolateToLinear() { this->SetResliceInterpolate(VTK_LINEAR_RESLICE); }
277 void SetResliceInterpolateToCubic() { this->SetResliceInterpolate(VTK_CUBIC_RESLICE); }
279
284
286
290 vtkSetMacro(RestrictPlaneToVolume, vtkTypeBool);
291 vtkGetMacro(RestrictPlaneToVolume, vtkTypeBool);
292 vtkBooleanMacro(RestrictPlaneToVolume, vtkTypeBool);
294
296
301 vtkSetMacro(UserControlledLookupTable, vtkTypeBool);
302 vtkGetMacro(UserControlledLookupTable, vtkTypeBool);
303 vtkBooleanMacro(UserControlledLookupTable, vtkTypeBool);
305
307
313 vtkSetMacro(TextureInterpolate, vtkTypeBool);
314 vtkGetMacro(TextureInterpolate, vtkTypeBool);
315 vtkBooleanMacro(TextureInterpolate, vtkTypeBool);
317
319
324 vtkGetMacro(TextureVisibility, vtkTypeBool);
325 vtkBooleanMacro(TextureVisibility, vtkTypeBool);
327
337
345
350 void UpdatePlacement(void) override;
351
357
359
365 vtkGetObjectMacro(ColorMap, vtkImageMapToColors);
368
370
375 vtkGetObjectMacro(PlaneProperty, vtkProperty);
377 vtkGetObjectMacro(SelectedPlaneProperty, vtkProperty);
379
381
386 vtkGetMacro(PlaneOrientation, int);
387 void SetPlaneOrientationToXAxes() { this->SetPlaneOrientation(0); }
388 void SetPlaneOrientationToYAxes() { this->SetPlaneOrientation(1); }
389 void SetPlaneOrientationToZAxes() { this->SetPlaneOrientation(2); }
391
399
401
409 vtkGetObjectMacro(LookupTable, vtkLookupTable);
411
413
417 vtkSetMacro(DisplayText, vtkTypeBool);
418 vtkGetMacro(DisplayText, vtkTypeBool);
419 vtkBooleanMacro(DisplayText, vtkTypeBool);
421
423
427 vtkGetObjectMacro(CursorProperty, vtkProperty);
429
431
435 vtkGetObjectMacro(MarginProperty, vtkProperty);
437
439
443 vtkSetClampMacro(MarginSizeX, double, 0.0, 0.5);
444 vtkGetMacro(MarginSizeX, double);
445 vtkSetClampMacro(MarginSizeY, double, 0.0, 0.5);
446 vtkGetMacro(MarginSizeY, double);
448
450
456
458
462 vtkGetObjectMacro(TexturePlaneProperty, vtkProperty);
464
466
472 void SetWindowLevel(double window, double level, int copy = 0);
473 void GetWindowLevel(double wl[2]);
474 double GetWindow() { return this->CurrentWindow; }
475 double GetLevel() { return this->CurrentLevel; }
477
482 int GetCursorData(double xyzv[4]);
483
490
492
496 vtkGetVectorMacro(CurrentCursorPosition, double, 3);
498
500
505 vtkGetMacro(CurrentImageValue, double);
507
509
512 vtkGetObjectMacro(ResliceAxes, vtkMatrix4x4);
513 vtkGetObjectMacro(Reslice, vtkImageReslice);
515
517
524 vtkSetMacro(UseContinuousCursor, vtkTypeBool);
525 vtkGetMacro(UseContinuousCursor, vtkTypeBool);
526 vtkBooleanMacro(UseContinuousCursor, vtkTypeBool);
528
530
534 vtkGetMacro(Interaction, vtkTypeBool);
535 vtkBooleanMacro(Interaction, vtkTypeBool);
537
539
542 enum
543 {
544 VTK_CURSOR_ACTION = 0,
545 VTK_SLICE_MOTION_ACTION = 1,
546 VTK_WINDOW_LEVEL_ACTION = 2
547 };
548 vtkSetClampMacro(LeftButtonAction, int, VTK_CURSOR_ACTION, VTK_WINDOW_LEVEL_ACTION);
549 vtkGetMacro(LeftButtonAction, int);
550 vtkSetClampMacro(MiddleButtonAction, int, VTK_CURSOR_ACTION, VTK_WINDOW_LEVEL_ACTION);
551 vtkGetMacro(MiddleButtonAction, int);
552 vtkSetClampMacro(RightButtonAction, int, VTK_CURSOR_ACTION, VTK_WINDOW_LEVEL_ACTION);
553 vtkGetMacro(RightButtonAction, int);
555
557
565 enum
566 {
567 VTK_NO_MODIFIER = 0,
568 VTK_SHIFT_MODIFIER = 1,
569 VTK_CONTROL_MODIFIER = 2
570 };
571 vtkSetClampMacro(LeftButtonAutoModifier, int, VTK_NO_MODIFIER, VTK_CONTROL_MODIFIER);
572 vtkGetMacro(LeftButtonAutoModifier, int);
573 vtkSetClampMacro(MiddleButtonAutoModifier, int, VTK_NO_MODIFIER, VTK_CONTROL_MODIFIER);
574 vtkGetMacro(MiddleButtonAutoModifier, int);
575 vtkSetClampMacro(RightButtonAutoModifier, int, VTK_NO_MODIFIER, VTK_CONTROL_MODIFIER);
576 vtkGetMacro(RightButtonAutoModifier, int);
578
579protected:
582
584
588
592
593 enum
594 {
595 VTK_NO_BUTTON = 0,
596 VTK_LEFT_BUTTON = 1,
597 VTK_MIDDLE_BUTTON = 2,
598 VTK_RIGHT_BUTTON = 3
599 };
601
602 // Manage the state of the widget
603 int State;
605 {
606 Start = 0,
614 Outside
615 };
616
617 // Handles the events
618 static void ProcessEvents(
619 vtkObject* object, unsigned long event, void* clientdata, void* calldata);
620
621 // internal utility method that adds observers to the RenderWindowInteractor
622 // so that our ProcessEvents is eventually called. this method is called
623 // by SetEnabled as well as SetInteraction
625
626 // ProcessEvents() dispatches to these methods.
627 virtual void OnMouseMove();
628 virtual void OnLeftButtonDown();
629 virtual void OnLeftButtonUp();
630 virtual void OnMiddleButtonDown();
631 virtual void OnMiddleButtonUp();
632 virtual void OnRightButtonDown();
633 virtual void OnRightButtonUp();
634 void OnChar() override;
635
636 virtual void StartCursor();
637 virtual void StopCursor();
638 virtual void StartSliceMotion();
639 virtual void StopSliceMotion();
640 virtual void StartWindowLevel();
641 virtual void StopWindowLevel();
642
643 // controlling ivars
644 vtkTypeBool Interaction; // Is the widget responsive to mouse events
659
660 // The geometric representation of the plane and it's outline
664 void HighlightPlane(int highlight);
666
667 // Re-builds the plane outline based on the plane source
669
670 // Do the picking
672
673 // Register internal Pickers within PickingManager
674 void RegisterPickers() override;
675
676 // for negative window values.
678
679 // Methods to manipulate the plane
680 void WindowLevel(int X, int Y);
681 void Push(double* p1, double* p2);
682 void Spin(double* p1, double* p2);
683 void Rotate(double* p1, double* p2, double* vpn);
684 void Scale(double* p1, double* p2, int X, int Y);
685 void Translate(double* p1, double* p2);
686
696
697 // Properties used to control the appearance of selected objects and
698 // the manipulator in general. The plane property is actually that for
699 // the outline. The TexturePlaneProperty can be used to control the
700 // lighting etc. of the resliced image data.
707
708 // Reslice and texture management
711
712 // The cross-hair cursor
715 double CurrentCursorPosition[3];
716 double CurrentImageValue; // Set to VTK_DOUBLE_MAX when invalid
718 void UpdateCursor(int, int);
719 void ActivateCursor(int);
721 int UpdateDiscreteCursor(double* q);
723
724 // The text to display W/L, image data
729 void ActivateText(int);
730
731 // Oblique reslice control
732 double RotateAxis[3];
733 double RadiusVector[3];
735
736 // Visible margins to assist user interaction
745
746private:
748 void operator=(const vtkImagePlaneWidget&) = delete;
749};
750
751#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:161
Proxy object to connect input/output ports.
map vtkDataSet and derived classes to graphics primitives
topologically and geometrically regular array of data
Definition: vtkImageData.h:163
map the input image through a lookup table
3D widget for reslicing image data
void SetPicker(vtkAbstractPropPicker *)
Set the internal picker to one defined by the user.
virtual void StartSliceMotion()
vtkPolyData * MarginPolyData
virtual void StartWindowLevel()
void GetPolyData(vtkPolyData *pd)
Grab the polydata (including points) that defines the plane.
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)
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.
vtkTypeBool RestrictPlaneToVolume
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.
~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.
vtkProperty * MarginProperty
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()
vtkTexture * GetTexture()
Convenience method to get the texture used by this widget.
void CreateDefaultProperties()
void HighlightPlane(int highlight)
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 SetEnabled(int) override
Methods that satisfy the superclass' API.
vtkTypeBool UserControlledLookupTable
void SetOrigin(double xyz[3])
Set/Get the origin of the plane.
vtkMatrix4x4 * ResliceAxes
void Spin(double *p1, double *p2)
vtkImageData * GetResliceOutput()
Convenience method to get the vtkImageReslice output.
void ActivateMargins(int)
vtkTextProperty * GetTextProperty()
Set/Get the text property for the image data and window-level annotation.
vtkProperty * CursorProperty
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()
vtkPolyData * CursorPolyData
void UpdateCursor(int, int)
void SetInteraction(vtkTypeBool interact)
Enable/disable mouse interaction so the widget remains on display.
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:119
map scalar values into colors via a lookup table
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:151
abstract base class for most VTK objects
Definition: vtkObject.h:79
create an array of quadrilaterals located in a plane
represent and manipulate 3D points
Definition: vtkPoints.h:149
Superclass for algorithms that produce only polydata as output.
abstract PolyDataSource-based 3D widget
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:200
represent surface properties of a geometric object
Definition: vtkProperty.h:177
An actor that displays text.
Definition: vtkTextActor.h:166
represent text properties.
handles properties associated with a texture map
Definition: vtkTexture.h:178
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:170
@ level
Definition: vtkX3D.h:401
@ position
Definition: vtkX3D.h:267
@ index
Definition: vtkX3D.h:252
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(...)