00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00119 #ifndef __vtkImagePlaneWidget_h
00120 #define __vtkImagePlaneWidget_h
00121
00122 #include "vtkPolyDataSourceWidget.h"
00123
00124 class vtkActor;
00125 class vtkCellPicker;
00126 class vtkDataSetMapper;
00127 class vtkImageData;
00128 class vtkImageMapToColors;
00129 class vtkImageReslice;
00130 class vtkLookupTable;
00131 class vtkMatrix4x4;
00132 class vtkPlaneSource;
00133 class vtkPoints;
00134 class vtkPolyData;
00135 class vtkPolyDataMapper;
00136 class vtkProperty;
00137 class vtkTextActor;
00138 class vtkTextProperty;
00139 class vtkTexture;
00140 class vtkTextureMapToPlane;
00141 class vtkTransform;
00142
00143 #define VTK_NEAREST_RESLICE 0
00144 #define VTK_LINEAR_RESLICE 1
00145 #define VTK_CUBIC_RESLICE 2
00146
00147 class VTK_EXPORT vtkImagePlaneWidget : public vtkPolyDataSourceWidget
00148 {
00149 public:
00151 static vtkImagePlaneWidget *New();
00152
00153 vtkTypeRevisionMacro(vtkImagePlaneWidget,vtkPolyDataSourceWidget);
00154 void PrintSelf(ostream& os, vtkIndent indent);
00155
00157
00158 virtual void SetEnabled(int);
00159 virtual void PlaceWidget(double bounds[6]);
00160 void PlaceWidget()
00161 {this->Superclass::PlaceWidget();}
00162 void PlaceWidget(double xmin, double xmax, double ymin, double ymax,
00163 double zmin, double zmax)
00164 {this->Superclass::PlaceWidget(xmin,xmax,ymin,ymax,zmin,zmax);}
00166
00168 void SetInput(vtkDataSet* input);
00169
00171
00172 void SetOrigin(double x, double y, double z);
00173 void SetOrigin(double xyz[3]);
00174 double* GetOrigin();
00175 void GetOrigin(double xyz[3]);
00177
00179
00181 void SetPoint1(double x, double y, double z);
00182 void SetPoint1(double xyz[3]);
00183 double* GetPoint1();
00184 void GetPoint1(double xyz[3]);
00186
00188
00190 void SetPoint2(double x, double y, double z);
00191 void SetPoint2(double xyz[3]);
00192 double* GetPoint2();
00193 void GetPoint2(double xyz[3]);
00195
00197
00198 double* GetCenter();
00199 void GetCenter(double xyz[3]);
00201
00203
00204 double* GetNormal();
00205 void GetNormal(double xyz[3]);
00207
00209 void GetVector1(double v1[3]);
00210
00212 void GetVector2(double v2[3]);
00213
00215 int GetSliceIndex();
00216
00218 void SetSliceIndex(int index);
00219
00221 double GetSlicePosition();
00222
00224 void SetSlicePosition(double position);
00225
00227
00228 void SetResliceInterpolate(int);
00229 vtkGetMacro(ResliceInterpolate,int);
00230 void SetResliceInterpolateToNearestNeighbour()
00231 { this->SetResliceInterpolate(VTK_NEAREST_RESLICE); }
00232 void SetResliceInterpolateToLinear()
00233 { this->SetResliceInterpolate(VTK_LINEAR_RESLICE); }
00234 void SetResliceInterpolateToCubic()
00235 { this->SetResliceInterpolate(VTK_CUBIC_RESLICE); }
00237
00239 vtkImageData* GetResliceOutput();
00240
00242
00243 vtkSetMacro(RestrictPlaneToVolume,int);
00244 vtkGetMacro(RestrictPlaneToVolume,int);
00245 vtkBooleanMacro(RestrictPlaneToVolume,int);
00247
00249
00251 vtkSetMacro(UserControlledLookupTable,int);
00252 vtkGetMacro(UserControlledLookupTable,int);
00253 vtkBooleanMacro(UserControlledLookupTable,int);
00255
00257
00261 vtkSetMacro(TextureInterpolate,int);
00262 vtkGetMacro(TextureInterpolate,int);
00263 vtkBooleanMacro(TextureInterpolate,int);
00265
00267
00269 virtual void SetTextureVisibility(int);
00270 vtkGetMacro(TextureVisibility,int);
00271 vtkBooleanMacro(TextureVisibility,int);
00273
00281 void GetPolyData(vtkPolyData *pd);
00282
00288 vtkPolyDataSource* GetPolyDataSource();
00289
00292 void UpdatePlacement(void);
00293
00296 vtkTexture *GetTexture();
00297
00299
00303 vtkGetObjectMacro(ColorMap, vtkImageMapToColors);
00304 virtual void SetColorMap(vtkImageMapToColors *);
00306
00308
00310 virtual void SetPlaneProperty(vtkProperty*);
00311 vtkGetObjectMacro(PlaneProperty,vtkProperty);
00312 virtual void SetSelectedPlaneProperty(vtkProperty*);
00313 vtkGetObjectMacro(SelectedPlaneProperty,vtkProperty);
00315
00317
00319 void SetPlaneOrientation(int);
00320 vtkGetMacro(PlaneOrientation,int);
00321 void SetPlaneOrientationToXAxes()
00322 { this->SetPlaneOrientation(0); }
00323 void SetPlaneOrientationToYAxes()
00324 { this->SetPlaneOrientation(1); }
00325 void SetPlaneOrientationToZAxes()
00326 { this->SetPlaneOrientation(2); }
00328
00333 void SetPicker(vtkCellPicker*);
00334
00336
00341 virtual void SetLookupTable(vtkLookupTable*);
00342 vtkGetObjectMacro(LookupTable,vtkLookupTable);
00344
00346
00348 vtkSetMacro(DisplayText,int);
00349 vtkGetMacro(DisplayText,int);
00350 vtkBooleanMacro(DisplayText,int);
00352
00354
00355 virtual void SetCursorProperty(vtkProperty*);
00356 vtkGetObjectMacro(CursorProperty,vtkProperty);
00358
00360
00361 virtual void SetMarginProperty(vtkProperty*);
00362 vtkGetObjectMacro(MarginProperty,vtkProperty);
00364
00366
00368 void SetTextProperty(vtkTextProperty* tprop);
00369 vtkTextProperty* GetTextProperty();
00371
00373
00374 virtual void SetTexturePlaneProperty(vtkProperty*);
00375 vtkGetObjectMacro(TexturePlaneProperty,vtkProperty);
00377
00379
00381 void SetWindowLevel(double window, double level);
00382 void GetWindowLevel(double wl[2]);
00384
00387 int GetCursorData(double xyzv[4]);
00388
00390
00396 vtkSetMacro(UseContinuousCursor,int);
00397 vtkGetMacro(UseContinuousCursor,int);
00398 vtkBooleanMacro(UseContinuousCursor,int);
00400
00402
00403 void SetInteraction(int interact);
00404 vtkGetMacro(Interaction,int);
00405 vtkBooleanMacro(Interaction,int);
00407
00409
00410 enum
00411 {
00412 CURSOR_ACTION = 0,
00413 SLICE_MOTION_ACTION = 1,
00414 WINDOW_LEVEL_ACTION = 2
00415 };
00416
00417 vtkSetClampMacro(LeftButtonAction,int, CURSOR_ACTION, WINDOW_LEVEL_ACTION);
00418 vtkGetMacro(LeftButtonAction, int);
00419 vtkSetClampMacro(MiddleButtonAction,int, CURSOR_ACTION, WINDOW_LEVEL_ACTION);
00420 vtkGetMacro(MiddleButtonAction, int);
00421 vtkSetClampMacro(RightButtonAction,int, CURSOR_ACTION, WINDOW_LEVEL_ACTION);
00422 vtkGetMacro(RightButtonAction, int);
00424
00426
00432 enum
00433 {
00434 NO_MODIFIER = 0,
00435 SHIFT_MODIFIER = 1,
00436 CONTROL_MODIFIER = 2
00437 };
00438
00439 vtkSetClampMacro(LeftButtonAutoModifier,int, SHIFT_MODIFIER, CONTROL_MODIFIER);
00440 vtkGetMacro(LeftButtonAutoModifier, int);
00441 vtkSetClampMacro(MiddleButtonAutoModifier,int, SHIFT_MODIFIER, CONTROL_MODIFIER);
00442 vtkGetMacro(MiddleButtonAutoModifier, int);
00443 vtkSetClampMacro(RightButtonAutoModifier,int, SHIFT_MODIFIER, CONTROL_MODIFIER);
00444 vtkGetMacro(RightButtonAutoModifier, int);
00446
00447 protected:
00448 vtkImagePlaneWidget();
00449 ~vtkImagePlaneWidget();
00450
00451 int TextureVisibility;
00452
00453 int LeftButtonAction;
00454 int MiddleButtonAction;
00455 int RightButtonAction;
00456
00457 int LeftButtonAutoModifier;
00458 int MiddleButtonAutoModifier;
00459 int RightButtonAutoModifier;
00460
00461
00462 enum
00463 {
00464 NO_BUTTON = 0,
00465 LEFT_BUTTON = 1,
00466 MIDDLE_BUTTON = 2,
00467 RIGHT_BUTTON = 3
00468 };
00469
00470 int LastButtonPressed;
00471
00472
00473 int State;
00474 enum WidgetState
00475 {
00476 Start=0,
00477 Cursoring,
00478 WindowLevelling,
00479 Pushing,
00480 Spinning,
00481 Rotating,
00482 Moving,
00483 Scaling,
00484 Outside
00485 };
00486
00487
00488
00489 static void ProcessEvents(vtkObject* object,
00490 unsigned long event,
00491 void* clientdata,
00492 void* calldata);
00493
00494
00495
00496
00497 void AddObservers();
00498
00499
00500 virtual void OnMouseMove();
00501 virtual void OnLeftButtonDown();
00502 virtual void OnLeftButtonUp();
00503 virtual void OnMiddleButtonDown();
00504 virtual void OnMiddleButtonUp();
00505 virtual void OnRightButtonDown();
00506 virtual void OnRightButtonUp();
00507
00508 virtual void StartCursor();
00509 virtual void StopCursor();
00510 virtual void StartSliceMotion();
00511 virtual void StopSliceMotion();
00512 virtual void StartWindowLevel();
00513 virtual void StopWindowLevel();
00514
00515
00516 int Interaction;
00517 int PlaneOrientation;
00518 int RestrictPlaneToVolume;
00519 double OriginalWindow;
00520 double OriginalLevel;
00521 double CurrentWindow;
00522 double CurrentLevel;
00523 int ResliceInterpolate;
00524 int TextureInterpolate;
00525 int UserControlledLookupTable;
00526 int DisplayText;
00527
00528
00529 vtkPlaneSource *PlaneSource;
00530 double Normal[3];
00531 vtkPolyData *PlaneOutlinePolyData;
00532 vtkActor *PlaneOutlineActor;
00533 vtkPolyDataMapper *PlaneOutlineMapper;
00534 void HighlightPlane(int highlight);
00535 void GeneratePlaneOutline();
00536
00537
00538 void BuildRepresentation();
00539
00540
00541 vtkCellPicker *PlanePicker;
00542
00543
00544 void WindowLevel(int X, int Y);
00545 void Push(double *p1, double *p2);
00546 void Spin(double *p1, double *p2);
00547 void Rotate(double *p1, double *p2, double *vpn);
00548 void Scale(double *p1, double *p2, int X, int Y);
00549 void Translate(double *p1, double *p2);
00550
00551 vtkImageData *ImageData;
00552 vtkImageReslice *Reslice;
00553 vtkMatrix4x4 *ResliceAxes;
00554 vtkTransform *Transform;
00555 vtkTextureMapToPlane *TexturePlaneCoords;
00556 vtkPolyDataMapper *TexturePlaneMapper;
00557 vtkActor *TexturePlaneActor;
00558 vtkImageMapToColors *ColorMap;
00559 vtkTexture *Texture;
00560 vtkLookupTable *LookupTable;
00561 vtkLookupTable *CreateDefaultLookupTable();
00562
00563
00564
00565
00566
00567 vtkProperty *PlaneProperty;
00568 vtkProperty *SelectedPlaneProperty;
00569 vtkProperty *CursorProperty;
00570 vtkProperty *MarginProperty;
00571 vtkProperty *TexturePlaneProperty;
00572 void CreateDefaultProperties();
00573
00574
00575 void UpdateNormal();
00576 void UpdateOrigin();
00577 void GenerateTexturePlane();
00578
00579
00580 vtkPolyData *CursorPolyData;
00581 vtkPolyDataMapper *CursorMapper;
00582 vtkActor *CursorActor;
00583 double CurrentCursorPosition[3];
00584 double CurrentImageValue;
00585 void GenerateCursor();
00586 void UpdateCursor(int,int);
00587 void ActivateCursor(int);
00588 int UpdateContinuousCursor(double *q);
00589 int UpdateDiscreteCursor(double *q);
00590 int UseContinuousCursor;
00591
00592
00593 vtkTextActor *TextActor;
00594 char TextBuff[128];
00595 void GenerateText();
00596 void ManageTextDisplay();
00597 void ActivateText(int);
00598
00599
00600 double RotateAxis[3];
00601 double RadiusVector[3];
00602 void AdjustState();
00603
00604
00605 vtkPolyData *MarginPolyData;
00606 vtkPolyDataMapper *MarginMapper;
00607 vtkActor *MarginActor;
00608 int MarginSelectMode;
00609 void GenerateMargins();
00610 void UpdateMargins();
00611 void ActivateMargins(int);
00612
00613 private:
00614 vtkImagePlaneWidget(const vtkImagePlaneWidget&);
00615 void operator=(const vtkImagePlaneWidget&);
00616 };
00617
00618 #endif