VTK
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=========================================================================*/
106#ifndef vtkImagePlaneWidget_h
107#define vtkImagePlaneWidget_h
108
109#include "vtkInteractionWidgetsModule.h" // For export macro
111
112class vtkActor;
114class vtkDataSetMapper;
115class vtkImageData;
117class vtkImageReslice;
118class vtkLookupTable;
119class vtkMatrix4x4;
120class vtkPlaneSource;
121class vtkPoints;
122class vtkPolyData;
123class vtkProperty;
124class vtkTextActor;
125class vtkTextProperty;
126class vtkTexture;
127class vtkTransform;
128
129#define VTK_NEAREST_RESLICE 0
130#define VTK_LINEAR_RESLICE 1
131#define VTK_CUBIC_RESLICE 2
132
133class VTKINTERACTIONWIDGETS_EXPORT vtkImagePlaneWidget : public vtkPolyDataSourceWidget
134{
135public:
140
142 void PrintSelf(ostream& os, vtkIndent indent);
143
145
148 virtual void SetEnabled(int);
149 virtual void PlaceWidget(double bounds[6]);
151 {this->Superclass::PlaceWidget();}
152 void PlaceWidget(double xmin, double xmax, double ymin, double ymax,
153 double zmin, double zmax)
154 {this->Superclass::PlaceWidget(xmin,xmax,ymin,ymax,zmin,zmax);}
156
161
163
166 void SetOrigin(double x, double y, double z);
167 void SetOrigin(double xyz[3]);
168 double* GetOrigin();
169 void GetOrigin(double xyz[3]);
171
173
176 void SetPoint1(double x, double y, double z);
177 void SetPoint1(double xyz[3]);
178 double* GetPoint1();
179 void GetPoint1(double xyz[3]);
181
183
186 void SetPoint2(double x, double y, double z);
187 void SetPoint2(double xyz[3]);
188 double* GetPoint2();
189 void GetPoint2(double xyz[3]);
191
193
196 double* GetCenter();
197 void GetCenter(double xyz[3]);
199
201
204 double* GetNormal();
205 void GetNormal(double xyz[3]);
207
211 void GetVector1(double v1[3]);
212
216 void GetVector2(double v2[3]);
217
222
227
232
237
239
243 vtkGetMacro(ResliceInterpolate,int);
245 { this->SetResliceInterpolate(VTK_NEAREST_RESLICE); }
247 { this->SetResliceInterpolate(VTK_LINEAR_RESLICE); }
249 { this->SetResliceInterpolate(VTK_CUBIC_RESLICE); }
251
256
258
262 vtkSetMacro(RestrictPlaneToVolume,int);
263 vtkGetMacro(RestrictPlaneToVolume,int);
264 vtkBooleanMacro(RestrictPlaneToVolume,int);
266
268
273 vtkSetMacro(UserControlledLookupTable,int);
274 vtkGetMacro(UserControlledLookupTable,int);
275 vtkBooleanMacro(UserControlledLookupTable,int);
277
279
285 vtkSetMacro(TextureInterpolate,int);
286 vtkGetMacro(TextureInterpolate,int);
287 vtkBooleanMacro(TextureInterpolate,int);
289
291
295 virtual void SetTextureVisibility(int);
296 vtkGetMacro(TextureVisibility,int);
297 vtkBooleanMacro(TextureVisibility,int);
299
309
317
322 void UpdatePlacement(void);
323
329
331
337 vtkGetObjectMacro(ColorMap, vtkImageMapToColors);
340
342
347 vtkGetObjectMacro(PlaneProperty,vtkProperty);
349 vtkGetObjectMacro(SelectedPlaneProperty,vtkProperty);
351
353
358 vtkGetMacro(PlaneOrientation,int);
360 { this->SetPlaneOrientation(0); }
362 { this->SetPlaneOrientation(1); }
364 { this->SetPlaneOrientation(2); }
366
374
376
384 vtkGetObjectMacro(LookupTable,vtkLookupTable);
386
388
392 vtkSetMacro(DisplayText,int);
393 vtkGetMacro(DisplayText,int);
394 vtkBooleanMacro(DisplayText,int);
396
398
402 vtkGetObjectMacro(CursorProperty,vtkProperty);
404
406
410 vtkGetObjectMacro(MarginProperty,vtkProperty);
412
414
418 vtkSetClampMacro(MarginSizeX,double, 0.0, 0.5);
419 vtkGetMacro(MarginSizeX, double);
420 vtkSetClampMacro(MarginSizeY,double, 0.0, 0.5);
421 vtkGetMacro(MarginSizeY, double);
423
425
431
433
437 vtkGetObjectMacro(TexturePlaneProperty,vtkProperty);
439
441
447 void SetWindowLevel(double window, double level, int copy = 0);
448 void GetWindowLevel(double wl[2]);
449 double GetWindow(){return this->CurrentWindow;}
450 double GetLevel(){return this->CurrentLevel;}
452
457 int GetCursorData(double xyzv[4]);
458
465
467
471 vtkGetVectorMacro(CurrentCursorPosition,double,3);
473
475
480 vtkGetMacro(CurrentImageValue,double);
482
484
487 vtkGetObjectMacro( ResliceAxes, vtkMatrix4x4 );
488 vtkGetObjectMacro( Reslice, vtkImageReslice );
490
492
499 vtkSetMacro(UseContinuousCursor,int);
500 vtkGetMacro(UseContinuousCursor,int);
501 vtkBooleanMacro(UseContinuousCursor,int);
503
505
508 void SetInteraction(int interact);
509 vtkGetMacro(Interaction,int);
510 vtkBooleanMacro(Interaction,int);
512
514
517 enum
518 {
519 VTK_CURSOR_ACTION = 0,
520 VTK_SLICE_MOTION_ACTION = 1,
521 VTK_WINDOW_LEVEL_ACTION = 2
522 };
523 vtkSetClampMacro(LeftButtonAction,int, VTK_CURSOR_ACTION, VTK_WINDOW_LEVEL_ACTION);
524 vtkGetMacro(LeftButtonAction, int);
525 vtkSetClampMacro(MiddleButtonAction,int, VTK_CURSOR_ACTION, VTK_WINDOW_LEVEL_ACTION);
526 vtkGetMacro(MiddleButtonAction, int);
527 vtkSetClampMacro(RightButtonAction,int, VTK_CURSOR_ACTION, VTK_WINDOW_LEVEL_ACTION);
528 vtkGetMacro(RightButtonAction, int);
530
532
540 enum
541 {
542 VTK_NO_MODIFIER = 0,
543 VTK_SHIFT_MODIFIER = 1,
544 VTK_CONTROL_MODIFIER = 2
545 };
546 vtkSetClampMacro(LeftButtonAutoModifier,int, VTK_NO_MODIFIER, VTK_CONTROL_MODIFIER);
547 vtkGetMacro(LeftButtonAutoModifier, int);
548 vtkSetClampMacro(MiddleButtonAutoModifier,int, VTK_NO_MODIFIER, VTK_CONTROL_MODIFIER);
549 vtkGetMacro(MiddleButtonAutoModifier, int);
550 vtkSetClampMacro(RightButtonAutoModifier,int, VTK_NO_MODIFIER, VTK_CONTROL_MODIFIER);
551 vtkGetMacro(RightButtonAutoModifier, int);
553
554protected:
557
559
563
567
568 enum
569 {
570 VTK_NO_BUTTON = 0,
571 VTK_LEFT_BUTTON = 1,
572 VTK_MIDDLE_BUTTON = 2,
573 VTK_RIGHT_BUTTON = 3
574 };
576
577 // Manage the state of the widget
578 int State;
580 {
581 Start=0,
589 Outside
590 };
591
592 // Handles the events
593 static void ProcessEvents(vtkObject* object,
594 unsigned long event,
595 void* clientdata,
596 void* calldata);
597
598 // internal utility method that adds observers to the RenderWindowInteractor
599 // so that our ProcessEvents is eventually called. this method is called
600 // by SetEnabled as well as SetInteraction
602
603 // ProcessEvents() dispatches to these methods.
604 virtual void OnMouseMove();
605 virtual void OnLeftButtonDown();
606 virtual void OnLeftButtonUp();
607 virtual void OnMiddleButtonDown();
608 virtual void OnMiddleButtonUp();
609 virtual void OnRightButtonDown();
610 virtual void OnRightButtonUp();
611 virtual void OnChar();
612
613 virtual void StartCursor();
614 virtual void StopCursor();
615 virtual void StartSliceMotion();
616 virtual void StopSliceMotion();
617 virtual void StartWindowLevel();
618 virtual void StopWindowLevel();
619
620 // controlling ivars
621 int Interaction; // Is the widget responsive to mouse events
636
637 // The geometric represenation of the plane and it's outline
641 void HighlightPlane(int highlight);
643
644 // Re-builds the plane outline based on the plane source
646
647 // Do the picking
649
650 // Register internal Pickers within PickingManager
651 virtual void RegisterPickers();
652
653 // for negative window values.
655
656 // Methods to manipulate the plane
657 void WindowLevel(int X, int Y);
658 void Push(double *p1, double *p2);
659 void Spin(double *p1, double *p2);
660 void Rotate(double *p1, double *p2, double *vpn);
661 void Scale(double *p1, double *p2, int X, int Y);
662 void Translate(double *p1, double *p2);
663
673
674 // Properties used to control the appearance of selected objects and
675 // the manipulator in general. The plane property is actually that for
676 // the outline. The TexturePlaneProperty can be used to control the
677 // lighting etc. of the resliced image data.
684
685 // Reslice and texture management
688
689 // The cross-hair cursor
692 double CurrentCursorPosition[3];
693 double CurrentImageValue; // Set to VTK_DOUBLE_MAX when invalid
695 void UpdateCursor(int,int);
696 void ActivateCursor(int);
698 int UpdateDiscreteCursor(double *q);
700
701 // The text to display W/L, image data
703 char TextBuff[128];
706 void ActivateText(int);
707
708 // Oblique reslice control
709 double RotateAxis[3];
710 double RadiusVector[3];
712
713 // Visible margins to assist user interaction
722
723private:
724 vtkImagePlaneWidget(const vtkImagePlaneWidget&) VTK_DELETE_FUNCTION;
725 void operator=(const vtkImagePlaneWidget&) VTK_DELETE_FUNCTION;
726};
727
728#endif
virtual void PlaceWidget()
abstract API for pickers that can pick an instance of vtkProp
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:52
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:46
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()
void PlaceWidget()
Overrides vtk3DWidget PlaceWidget() so that it doesn't complain if there's no Input and no Prop3D.
vtkPolyDataAlgorithm * GetPolyDataAlgorithm()
Satisfies superclass API.
vtkPolyData * MarginPolyData
virtual void StartWindowLevel()
void GetPolyData(vtkPolyData *pd)
Grab the polydata (including points) that defines the plane.
double * GetPoint1()
void GetVector1(double v1[3])
Get the vector from the plane origin to point1.
vtkProperty * SelectedPlaneProperty
double * GetOrigin()
void SetInteraction(int interact)
Enable/disable mouse interaction so the widget remains on display.
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 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 *)
vtkLookupTable * LookupTable
void ActivateCursor(int)
void SetPoint2(double xyz[3])
virtual void SetCursorProperty(vtkProperty *)
Set the properties of the cross-hair cursor.
virtual void StopWindowLevel()
virtual void StartCursor()
void SetInputConnection(vtkAlgorithmOutput *aout)
Set the vtkImageData* input for the vtkImageReslice.
virtual void OnMiddleButtonUp()
virtual void SetMarginProperty(vtkProperty *)
Set the properties of the margins.
double * GetPoint2()
virtual void RegisterPickers()
Register internal Pickers in the Picking Manager.
void SetOrigin(double x, double y, double z)
Set/Get the origin of the plane.
static vtkImagePlaneWidget * New()
Instantiate the object.
virtual void StopSliceMotion()
void GetPoint2(double xyz[3])
vtkProperty * MarginProperty
virtual void SetTextureVisibility(int)
Control the visibility of the actual texture mapped reformatted plane.
void SetPoint1(double x, double y, double z)
Set/Get the position of the point defining the first axis of the plane.
virtual void SetTexturePlaneProperty(vtkProperty *)
Set/Get the property for the resliced image.
void Translate(double *p1, double *p2)
void GetCenter(double xyz[3])
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()
virtual void OnChar()
Sets up the keypress-i event.
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 PrintSelf(ostream &os, vtkIndent indent)
Methods invoked by print to print information about the object including superclasses.
void UpdatePlacement(void)
Satisfies superclass API.
double GetSlicePosition()
Get the position of the slice along its normal.
void SetOrigin(double xyz[3])
vtkMatrix4x4 * ResliceAxes
void Spin(double *p1, double *p2)
vtkImageData * GetResliceOutput()
Convenience method to get the vtkImageReslice output.
void PlaceWidget(double xmin, double xmax, double ymin, double ymax, double zmin, double zmax)
void ActivateMargins(int)
void GetVector2(double v2[3])
Get the vector from the plane origin to point2.
void GetOrigin(double xyz[3])
vtkTextProperty * GetTextProperty()
void GetPoint1(double xyz[3])
void SetSliceIndex(int index)
Set the slice position in terms of the data extent.
vtkProperty * CursorProperty
int UpdateDiscreteCursor(double *q)
virtual void OnMiddleButtonDown()
void GetWindowLevel(double wl[2])
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.
virtual void StopCursor()
virtual void OnLeftButtonUp()
vtkImageMapToColors * ColorMap
vtkImageReslice * Reslice
void GetNormal(double xyz[3])
vtkLookupTable * CreateDefaultLookupTable()
vtkPolyData * CursorPolyData
void UpdateCursor(int, int)
virtual void PlaceWidget(double bounds[6])
We have to redeclare this abstract, PlaceWidget() requires it.
double * GetCenter()
Get the center of the plane.
virtual void SetColorMap(vtkImageMapToColors *)
void SetPoint1(double xyz[3])
virtual void OnLeftButtonDown()
virtual void OnRightButtonDown()
vtkPolyData * PlaneOutlinePolyData
virtual void SetEnabled(int)
Methods that satisfy the superclass' API.
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:40
map scalar values into colors via a lookup table
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:42
abstract base class for most VTK objects
Definition: vtkObject.h:60
create an array of quadrilaterals located in a plane
represent and manipulate 3D points
Definition: vtkPoints.h:40
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:86
represent surface properties of a geometric object
Definition: vtkProperty.h:65
An actor that displays text.
Definition: vtkTextActor.h:57
represent text properties.
handles properties associated with a texture map
Definition: vtkTexture.h:71
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:61
@ level
Definition: vtkX3D.h:395
@ position
Definition: vtkX3D.h:261
@ index
Definition: vtkX3D.h:246
#define VTK_LINEAR_RESLICE
#define VTK_CUBIC_RESLICE
#define VTK_NEAREST_RESLICE
vtkSetMacro(IgnoreDriverBugs, bool)
Updates the extensions string.
vtkBooleanMacro(IgnoreDriverBugs, bool)
Updates the extensions string.