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 =========================================================================*/
108 #ifndef vtkImagePlaneWidget_h
109 #define vtkImagePlaneWidget_h
110 
111 #include "vtkInteractionWidgetsModule.h" // For export macro
112 #include "vtkPolyDataSourceWidget.h"
113 
114 class vtkActor;
116 class vtkDataSetMapper;
117 class vtkImageData;
118 class vtkImageMapToColors;
119 class vtkImageReslice;
120 class vtkLookupTable;
121 class vtkMatrix4x4;
122 class vtkPlaneSource;
123 class vtkPoints;
124 class vtkPolyData;
125 class vtkProperty;
126 class vtkTextActor;
127 class vtkTextProperty;
128 class vtkTexture;
129 class vtkTransform;
130 
131 #define VTK_NEAREST_RESLICE 0
132 #define VTK_LINEAR_RESLICE 1
133 #define VTK_CUBIC_RESLICE 2
134 
136 {
137 public:
139  static vtkImagePlaneWidget *New();
140 
142  void PrintSelf(ostream& os, vtkIndent indent);
143 
145 
146  virtual void SetEnabled(int);
147  virtual void PlaceWidget(double bounds[6]);
148  void PlaceWidget()
149  {this->Superclass::PlaceWidget();}
150  void PlaceWidget(double xmin, double xmax, double ymin, double ymax,
151  double zmin, double zmax)
152  {this->Superclass::PlaceWidget(xmin,xmax,ymin,ymax,zmin,zmax);}
154 
157 
159 
160  void SetOrigin(double x, double y, double z);
161  void SetOrigin(double xyz[3]);
162  double* GetOrigin();
163  void GetOrigin(double xyz[3]);
165 
167 
169  void SetPoint1(double x, double y, double z);
170  void SetPoint1(double xyz[3]);
171  double* GetPoint1();
172  void GetPoint1(double xyz[3]);
174 
176 
178  void SetPoint2(double x, double y, double z);
179  void SetPoint2(double xyz[3]);
180  double* GetPoint2();
181  void GetPoint2(double xyz[3]);
183 
185 
186  double* GetCenter();
187  void GetCenter(double xyz[3]);
189 
191 
192  double* GetNormal();
193  void GetNormal(double xyz[3]);
195 
197  void GetVector1(double v1[3]);
198 
200  void GetVector2(double v2[3]);
201 
203  int GetSliceIndex();
204 
206  void SetSliceIndex(int index);
207 
209  double GetSlicePosition();
210 
212  void SetSlicePosition(double position);
213 
215 
216  void SetResliceInterpolate(int);
217  vtkGetMacro(ResliceInterpolate,int);
219  { this->SetResliceInterpolate(VTK_NEAREST_RESLICE); }
221  { this->SetResliceInterpolate(VTK_LINEAR_RESLICE); }
223  { this->SetResliceInterpolate(VTK_CUBIC_RESLICE); }
225 
227  vtkImageData* GetResliceOutput();
228 
230 
231  vtkSetMacro(RestrictPlaneToVolume,int);
232  vtkGetMacro(RestrictPlaneToVolume,int);
233  vtkBooleanMacro(RestrictPlaneToVolume,int);
235 
237 
239  vtkSetMacro(UserControlledLookupTable,int);
240  vtkGetMacro(UserControlledLookupTable,int);
241  vtkBooleanMacro(UserControlledLookupTable,int);
243 
245 
249  vtkSetMacro(TextureInterpolate,int);
250  vtkGetMacro(TextureInterpolate,int);
251  vtkBooleanMacro(TextureInterpolate,int);
253 
255 
257  virtual void SetTextureVisibility(int);
258  vtkGetMacro(TextureVisibility,int);
259  vtkBooleanMacro(TextureVisibility,int);
261 
268  void GetPolyData(vtkPolyData *pd);
269 
276 
280  void UpdatePlacement(void);
281 
284  vtkTexture *GetTexture();
285 
287 
291  vtkGetObjectMacro(ColorMap, vtkImageMapToColors);
292  virtual void SetColorMap(vtkImageMapToColors *);
294 
296 
298  virtual void SetPlaneProperty(vtkProperty*);
299  vtkGetObjectMacro(PlaneProperty,vtkProperty);
300  virtual void SetSelectedPlaneProperty(vtkProperty*);
301  vtkGetObjectMacro(SelectedPlaneProperty,vtkProperty);
303 
305 
307  void SetPlaneOrientation(int);
308  vtkGetMacro(PlaneOrientation,int);
310  { this->SetPlaneOrientation(0); }
312  { this->SetPlaneOrientation(1); }
314  { this->SetPlaneOrientation(2); }
316 
321  void SetPicker(vtkAbstractPropPicker*);
322 
324 
329  virtual void SetLookupTable(vtkLookupTable*);
330  vtkGetObjectMacro(LookupTable,vtkLookupTable);
332 
334 
336  vtkSetMacro(DisplayText,int);
337  vtkGetMacro(DisplayText,int);
338  vtkBooleanMacro(DisplayText,int);
340 
342 
343  virtual void SetCursorProperty(vtkProperty*);
344  vtkGetObjectMacro(CursorProperty,vtkProperty);
346 
348 
349  virtual void SetMarginProperty(vtkProperty*);
350  vtkGetObjectMacro(MarginProperty,vtkProperty);
352 
354 
356  vtkSetClampMacro(MarginSizeX,double, 0.0, 0.5);
357  vtkGetMacro(MarginSizeX, double);
358  vtkSetClampMacro(MarginSizeY,double, 0.0, 0.5);
359  vtkGetMacro(MarginSizeY, double);
361 
363 
365  void SetTextProperty(vtkTextProperty* tprop);
366  vtkTextProperty* GetTextProperty();
368 
370 
371  virtual void SetTexturePlaneProperty(vtkProperty*);
372  vtkGetObjectMacro(TexturePlaneProperty,vtkProperty);
374 
376 
380  void SetWindowLevel(double window, double level, int copy = 0);
381  void GetWindowLevel(double wl[2]);
382  double GetWindow(){return this->CurrentWindow;}
383  double GetLevel(){return this->CurrentLevel;}
385 
388  int GetCursorData(double xyzv[4]);
389 
393  int GetCursorDataStatus();
394 
396 
398  vtkGetVectorMacro(CurrentCursorPosition,double,3);
400 
402 
405  vtkGetMacro(CurrentImageValue,double);
407 
409 
410  vtkGetObjectMacro( ResliceAxes, vtkMatrix4x4 );
411  vtkGetObjectMacro( Reslice, vtkImageReslice );
413 
415 
421  vtkSetMacro(UseContinuousCursor,int);
422  vtkGetMacro(UseContinuousCursor,int);
423  vtkBooleanMacro(UseContinuousCursor,int);
425 
427 
428  void SetInteraction(int interact);
429  vtkGetMacro(Interaction,int);
430  vtkBooleanMacro(Interaction,int);
432 
434 
435  enum
436  {
437  VTK_CURSOR_ACTION = 0,
438  VTK_SLICE_MOTION_ACTION = 1,
439  VTK_WINDOW_LEVEL_ACTION = 2
440  };
441  vtkSetClampMacro(LeftButtonAction,int, VTK_CURSOR_ACTION, VTK_WINDOW_LEVEL_ACTION);
442  vtkGetMacro(LeftButtonAction, int);
443  vtkSetClampMacro(MiddleButtonAction,int, VTK_CURSOR_ACTION, VTK_WINDOW_LEVEL_ACTION);
444  vtkGetMacro(MiddleButtonAction, int);
445  vtkSetClampMacro(RightButtonAction,int, VTK_CURSOR_ACTION, VTK_WINDOW_LEVEL_ACTION);
446  vtkGetMacro(RightButtonAction, int);
448 
450 
456  enum
457  {
458  VTK_NO_MODIFIER = 0,
459  VTK_SHIFT_MODIFIER = 1,
460  VTK_CONTROL_MODIFIER = 2
461  };
462  vtkSetClampMacro(LeftButtonAutoModifier,int, VTK_NO_MODIFIER, VTK_CONTROL_MODIFIER);
463  vtkGetMacro(LeftButtonAutoModifier, int);
464  vtkSetClampMacro(MiddleButtonAutoModifier,int, VTK_NO_MODIFIER, VTK_CONTROL_MODIFIER);
465  vtkGetMacro(MiddleButtonAutoModifier, int);
466  vtkSetClampMacro(RightButtonAutoModifier,int, VTK_NO_MODIFIER, VTK_CONTROL_MODIFIER);
467  vtkGetMacro(RightButtonAutoModifier, int);
469 
470 protected:
473 
475 
479 
483 
484  enum
485  {
486  VTK_NO_BUTTON = 0,
487  VTK_LEFT_BUTTON = 1,
488  VTK_MIDDLE_BUTTON = 2,
489  VTK_RIGHT_BUTTON = 3
490  };
492 
493  // Manage the state of the widget
494  int State;
496  {
497  Start=0,
505  Outside
506  };
507 
508  // Handles the events
509  static void ProcessEvents(vtkObject* object,
510  unsigned long event,
511  void* clientdata,
512  void* calldata);
513 
514  // internal utility method that adds observers to the RenderWindowInteractor
515  // so that our ProcessEvents is eventually called. this method is called
516  // by SetEnabled as well as SetInteraction
517  void AddObservers();
518 
519  // ProcessEvents() dispatches to these methods.
520  virtual void OnMouseMove();
521  virtual void OnLeftButtonDown();
522  virtual void OnLeftButtonUp();
523  virtual void OnMiddleButtonDown();
524  virtual void OnMiddleButtonUp();
525  virtual void OnRightButtonDown();
526  virtual void OnRightButtonUp();
527  virtual void OnChar();
528 
529  virtual void StartCursor();
530  virtual void StopCursor();
531  virtual void StartSliceMotion();
532  virtual void StopSliceMotion();
533  virtual void StartWindowLevel();
534  virtual void StopWindowLevel();
535 
536  // controlling ivars
537  int Interaction; // Is the widget responsive to mouse events
543  double CurrentLevel;
545  double InitialLevel;
552 
553  // The geometric represenation of the plane and it's outline
557  void HighlightPlane(int highlight);
558  void GeneratePlaneOutline();
559 
560  // Re-builds the plane outline based on the plane source
561  void BuildRepresentation();
562 
563  // Do the picking
565 
566  // Register internal Pickers within PickingManager
567  virtual void RegisterPickers();
568 
569  // for negative window values.
570  void InvertTable();
571 
572  // Methods to manipulate the plane
573  void WindowLevel(int X, int Y);
574  void Push(double *p1, double *p2);
575  void Spin(double *p1, double *p2);
576  void Rotate(double *p1, double *p2, double *vpn);
577  void Scale(double *p1, double *p2, int X, int Y);
578  void Translate(double *p1, double *p2);
579 
588  vtkLookupTable *CreateDefaultLookupTable();
589 
590  // Properties used to control the appearance of selected objects and
591  // the manipulator in general. The plane property is actually that for
592  // the outline. The TexturePlaneProperty can be used to control the
593  // lighting etc. of the resliced image data.
599  void CreateDefaultProperties();
600 
601  // Reslice and texture management
602  void UpdatePlane();
603  void GenerateTexturePlane();
604 
605  // The cross-hair cursor
608  double CurrentCursorPosition[3];
609  double CurrentImageValue; // Set to VTK_DOUBLE_MAX when invalid
610  void GenerateCursor();
611  void UpdateCursor(int,int);
612  void ActivateCursor(int);
613  int UpdateContinuousCursor(double *q);
614  int UpdateDiscreteCursor(double *q);
616 
617  // The text to display W/L, image data
619  char TextBuff[128];
620  void GenerateText();
621  void ManageTextDisplay();
622  void ActivateText(int);
623 
624  // Oblique reslice control
625  double RotateAxis[3];
626  double RadiusVector[3];
627  void AdjustState();
628 
629  // Visible margins to assist user interaction
633  void GenerateMargins();
634  void UpdateMargins();
635  void ActivateMargins(int);
636  double MarginSizeX;
637  double MarginSizeY;
638 
639 private:
640  vtkImagePlaneWidget(const vtkImagePlaneWidget&); //Not implemented
641  void operator=(const vtkImagePlaneWidget&); //Not implemented
642 };
643 
644 #endif
#define VTK_CUBIC_RESLICE
virtual vtkPolyDataAlgorithm * GetPolyDataAlgorithm()=0
void PrintSelf(ostream &os, vtkIndent indent)
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:50
abstract base class for most VTK objects
Definition: vtkObject.h:61
#define VTK_LINEAR_RESLICE
abstract PolyDataSource-based 3D widget
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:38
represent surface properties of a geometric object
Definition: vtkProperty.h:63
vtkPolyData * PlaneOutlinePolyData
static void ProcessEvents(vtkObject *object, unsigned long event, void *clientdata, void *calldata)
virtual void SetEnabled(int)
map scalar values into colors via a lookup table
vtkPlaneSource * PlaneSource
vtkProperty * MarginProperty
vtkLookupTable * LookupTable
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:59
vtkProperty * CursorProperty
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:84
virtual void SetInputConnection(vtkAlgorithmOutput *)
vtkProperty * SelectedPlaneProperty
virtual void UpdatePlacement()=0
void SetResliceInterpolateToNearestNeighbour()
Proxy object to connect input/output ports.
virtual void RegisterPickers()
vtkImageMapToColors * ColorMap
#define VTKINTERACTIONWIDGETS_EXPORT
An actor that displays text. Scaled or unscaled.
Definition: vtkTextActor.h:54
map vtkDataSet and derived classes to graphics primitives
Superclass for algorithms that produce only polydata as output.
a simple class to control print indentation
Definition: vtkIndent.h:38
#define VTK_NEAREST_RESLICE
topologically and geometrically regular array of data
Definition: vtkImageData.h:44
map the input image through a lookup table
vtkProperty * TexturePlaneProperty
handles properties associated with a texture map
Definition: vtkTexture.h:69
represent text properties.
Reslices a volume along a new set of axes.
create an array of quadrilaterals located in a plane
virtual void PlaceWidget()
vtkImageReslice * Reslice
vtkAbstractPropPicker * PlanePicker
abstract API for pickers that can pick an instance of vtkProp
3D widget for reslicing image data
vtkPolyData * MarginPolyData
void PlaceWidget(double xmin, double xmax, double ymin, double ymax, double zmin, double zmax)
vtkMatrix4x4 * ResliceAxes
vtkPolyData * CursorPolyData
VTKWRAPPINGJAVA_EXPORT jlong q(JNIEnv *env, jobject obj)
virtual void OnChar()
static vtkObject * New()
virtual void PlaceWidget()
represent and manipulate 3D points
Definition: vtkPoints.h:38