00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00112 #ifndef __vtkImagePlaneWidget_h
00113 #define __vtkImagePlaneWidget_h
00114
00115 #include "vtkPolyDataSourceWidget.h"
00116
00117 class vtkActor;
00118 class vtkAbstractPropPicker;
00119 class vtkDataSetMapper;
00120 class vtkImageData;
00121 class vtkImageMapToColors;
00122 class vtkImageReslice;
00123 class vtkLookupTable;
00124 class vtkMatrix4x4;
00125 class vtkPlaneSource;
00126 class vtkPoints;
00127 class vtkPolyData;
00128 class vtkProperty;
00129 class vtkTextActor;
00130 class vtkTextProperty;
00131 class vtkTexture;
00132 class vtkTransform;
00133
00134 #define VTK_NEAREST_RESLICE 0
00135 #define VTK_LINEAR_RESLICE 1
00136 #define VTK_CUBIC_RESLICE 2
00137
00138 class VTK_WIDGETS_EXPORT vtkImagePlaneWidget : public vtkPolyDataSourceWidget
00139 {
00140 public:
00142 static vtkImagePlaneWidget *New();
00143
00144 vtkTypeMacro(vtkImagePlaneWidget,vtkPolyDataSourceWidget);
00145 void PrintSelf(ostream& os, vtkIndent indent);
00146
00148
00149 virtual void SetEnabled(int);
00150 virtual void PlaceWidget(double bounds[6]);
00151 void PlaceWidget()
00152 {this->Superclass::PlaceWidget();}
00153 void PlaceWidget(double xmin, double xmax, double ymin, double ymax,
00154 double zmin, double zmax)
00155 {this->Superclass::PlaceWidget(xmin,xmax,ymin,ymax,zmin,zmax);}
00157
00159 void SetInput(vtkDataSet* input);
00160
00162
00163 void SetOrigin(double x, double y, double z);
00164 void SetOrigin(double xyz[3]);
00165 double* GetOrigin();
00166 void GetOrigin(double xyz[3]);
00168
00170
00172 void SetPoint1(double x, double y, double z);
00173 void SetPoint1(double xyz[3]);
00174 double* GetPoint1();
00175 void GetPoint1(double xyz[3]);
00177
00179
00181 void SetPoint2(double x, double y, double z);
00182 void SetPoint2(double xyz[3]);
00183 double* GetPoint2();
00184 void GetPoint2(double xyz[3]);
00186
00188
00189 double* GetCenter();
00190 void GetCenter(double xyz[3]);
00192
00194
00195 double* GetNormal();
00196 void GetNormal(double xyz[3]);
00198
00200 void GetVector1(double v1[3]);
00201
00203 void GetVector2(double v2[3]);
00204
00206 int GetSliceIndex();
00207
00209 void SetSliceIndex(int index);
00210
00212 double GetSlicePosition();
00213
00215 void SetSlicePosition(double position);
00216
00218
00219 void SetResliceInterpolate(int);
00220 vtkGetMacro(ResliceInterpolate,int);
00221 void SetResliceInterpolateToNearestNeighbour()
00222 { this->SetResliceInterpolate(VTK_NEAREST_RESLICE); }
00223 void SetResliceInterpolateToLinear()
00224 { this->SetResliceInterpolate(VTK_LINEAR_RESLICE); }
00225 void SetResliceInterpolateToCubic()
00226 { this->SetResliceInterpolate(VTK_CUBIC_RESLICE); }
00228
00230 vtkImageData* GetResliceOutput();
00231
00233
00234 vtkSetMacro(RestrictPlaneToVolume,int);
00235 vtkGetMacro(RestrictPlaneToVolume,int);
00236 vtkBooleanMacro(RestrictPlaneToVolume,int);
00238
00240
00242 vtkSetMacro(UserControlledLookupTable,int);
00243 vtkGetMacro(UserControlledLookupTable,int);
00244 vtkBooleanMacro(UserControlledLookupTable,int);
00246
00248
00252 vtkSetMacro(TextureInterpolate,int);
00253 vtkGetMacro(TextureInterpolate,int);
00254 vtkBooleanMacro(TextureInterpolate,int);
00256
00258
00260 virtual void SetTextureVisibility(int);
00261 vtkGetMacro(TextureVisibility,int);
00262 vtkBooleanMacro(TextureVisibility,int);
00264
00271 void GetPolyData(vtkPolyData *pd);
00272
00278 vtkPolyDataAlgorithm* GetPolyDataAlgorithm();
00279
00283 void UpdatePlacement(void);
00284
00287 vtkTexture *GetTexture();
00288
00290
00294 vtkGetObjectMacro(ColorMap, vtkImageMapToColors);
00295 virtual void SetColorMap(vtkImageMapToColors *);
00297
00299
00301 virtual void SetPlaneProperty(vtkProperty*);
00302 vtkGetObjectMacro(PlaneProperty,vtkProperty);
00303 virtual void SetSelectedPlaneProperty(vtkProperty*);
00304 vtkGetObjectMacro(SelectedPlaneProperty,vtkProperty);
00306
00308
00310 void SetPlaneOrientation(int);
00311 vtkGetMacro(PlaneOrientation,int);
00312 void SetPlaneOrientationToXAxes()
00313 { this->SetPlaneOrientation(0); }
00314 void SetPlaneOrientationToYAxes()
00315 { this->SetPlaneOrientation(1); }
00316 void SetPlaneOrientationToZAxes()
00317 { this->SetPlaneOrientation(2); }
00319
00324 void SetPicker(vtkAbstractPropPicker*);
00325
00327
00332 virtual void SetLookupTable(vtkLookupTable*);
00333 vtkGetObjectMacro(LookupTable,vtkLookupTable);
00335
00337
00339 vtkSetMacro(DisplayText,int);
00340 vtkGetMacro(DisplayText,int);
00341 vtkBooleanMacro(DisplayText,int);
00343
00345
00346 virtual void SetCursorProperty(vtkProperty*);
00347 vtkGetObjectMacro(CursorProperty,vtkProperty);
00349
00351
00352 virtual void SetMarginProperty(vtkProperty*);
00353 vtkGetObjectMacro(MarginProperty,vtkProperty);
00355
00357
00359 vtkSetClampMacro(MarginSizeX,double, 0.0, 0.5);
00360 vtkGetMacro(MarginSizeX, double);
00361 vtkSetClampMacro(MarginSizeY,double, 0.0, 0.5);
00362 vtkGetMacro(MarginSizeY, double);
00364
00366
00368 void SetTextProperty(vtkTextProperty* tprop);
00369 vtkTextProperty* GetTextProperty();
00371
00373
00374 virtual void SetTexturePlaneProperty(vtkProperty*);
00375 vtkGetObjectMacro(TexturePlaneProperty,vtkProperty);
00377
00379
00383 void SetWindowLevel(double window, double level, int copy = 0);
00384 void GetWindowLevel(double wl[2]);
00385 double GetWindow(){return this->CurrentWindow;}
00386 double GetLevel(){return this->CurrentLevel;}
00388
00391 int GetCursorData(double xyzv[4]);
00392
00396 int GetCursorDataStatus();
00397
00399
00401 vtkGetVectorMacro(CurrentCursorPosition,double,3);
00403
00405
00408 vtkGetMacro(CurrentImageValue,double);
00410
00412
00413 vtkGetObjectMacro( ResliceAxes, vtkMatrix4x4 );
00414 vtkGetObjectMacro( Reslice, vtkImageReslice );
00416
00418
00424 vtkSetMacro(UseContinuousCursor,int);
00425 vtkGetMacro(UseContinuousCursor,int);
00426 vtkBooleanMacro(UseContinuousCursor,int);
00428
00430
00431 void SetInteraction(int interact);
00432 vtkGetMacro(Interaction,int);
00433 vtkBooleanMacro(Interaction,int);
00435
00436
00438
00439 enum
00440 {
00441 VTK_CURSOR_ACTION = 0,
00442 VTK_SLICE_MOTION_ACTION = 1,
00443 VTK_WINDOW_LEVEL_ACTION = 2
00444 };
00445
00446 vtkSetClampMacro(LeftButtonAction,int, VTK_CURSOR_ACTION, VTK_WINDOW_LEVEL_ACTION);
00447 vtkGetMacro(LeftButtonAction, int);
00448 vtkSetClampMacro(MiddleButtonAction,int, VTK_CURSOR_ACTION, VTK_WINDOW_LEVEL_ACTION);
00449 vtkGetMacro(MiddleButtonAction, int);
00450 vtkSetClampMacro(RightButtonAction,int, VTK_CURSOR_ACTION, VTK_WINDOW_LEVEL_ACTION);
00451 vtkGetMacro(RightButtonAction, int);
00453
00454
00456
00462 enum
00463 {
00464 VTK_NO_MODIFIER = 0,
00465 VTK_SHIFT_MODIFIER = 1,
00466 VTK_CONTROL_MODIFIER = 2
00467 };
00468
00469 vtkSetClampMacro(LeftButtonAutoModifier,int, VTK_NO_MODIFIER, VTK_CONTROL_MODIFIER);
00470 vtkGetMacro(LeftButtonAutoModifier, int);
00471 vtkSetClampMacro(MiddleButtonAutoModifier,int, VTK_NO_MODIFIER, VTK_CONTROL_MODIFIER);
00472 vtkGetMacro(MiddleButtonAutoModifier, int);
00473 vtkSetClampMacro(RightButtonAutoModifier,int, VTK_NO_MODIFIER, VTK_CONTROL_MODIFIER);
00474 vtkGetMacro(RightButtonAutoModifier, int);
00476
00477 protected:
00478 vtkImagePlaneWidget();
00479 ~vtkImagePlaneWidget();
00480
00481 int TextureVisibility;
00482
00483 int LeftButtonAction;
00484 int MiddleButtonAction;
00485 int RightButtonAction;
00486
00487 int LeftButtonAutoModifier;
00488 int MiddleButtonAutoModifier;
00489 int RightButtonAutoModifier;
00490
00491
00492 enum
00493 {
00494 VTK_NO_BUTTON = 0,
00495 VTK_LEFT_BUTTON = 1,
00496 VTK_MIDDLE_BUTTON = 2,
00497 VTK_RIGHT_BUTTON = 3
00498 };
00499
00500 int LastButtonPressed;
00501
00502
00503 int State;
00504 enum WidgetState
00505 {
00506 Start=0,
00507 Cursoring,
00508 WindowLevelling,
00509 Pushing,
00510 Spinning,
00511 Rotating,
00512 Moving,
00513 Scaling,
00514 Outside
00515 };
00516
00517
00518
00519 static void ProcessEvents(vtkObject* object,
00520 unsigned long event,
00521 void* clientdata,
00522 void* calldata);
00523
00524
00525
00526
00527 void AddObservers();
00528
00529
00530 virtual void OnMouseMove();
00531 virtual void OnLeftButtonDown();
00532 virtual void OnLeftButtonUp();
00533 virtual void OnMiddleButtonDown();
00534 virtual void OnMiddleButtonUp();
00535 virtual void OnRightButtonDown();
00536 virtual void OnRightButtonUp();
00537 virtual void OnChar();
00538
00539 virtual void StartCursor();
00540 virtual void StopCursor();
00541 virtual void StartSliceMotion();
00542 virtual void StopSliceMotion();
00543 virtual void StartWindowLevel();
00544 virtual void StopWindowLevel();
00545
00546
00547 int Interaction;
00548 int PlaneOrientation;
00549 int RestrictPlaneToVolume;
00550 double OriginalWindow;
00551 double OriginalLevel;
00552 double CurrentWindow;
00553 double CurrentLevel;
00554 double InitialWindow;
00555 double InitialLevel;
00556 int StartWindowLevelPositionX;
00557 int StartWindowLevelPositionY;
00558 int ResliceInterpolate;
00559 int TextureInterpolate;
00560 int UserControlledLookupTable;
00561 int DisplayText;
00562
00563
00564 vtkPlaneSource *PlaneSource;
00565 vtkPolyData *PlaneOutlinePolyData;
00566 vtkActor *PlaneOutlineActor;
00567 void HighlightPlane(int highlight);
00568 void GeneratePlaneOutline();
00569
00570
00571 void BuildRepresentation();
00572
00573
00574 vtkAbstractPropPicker *PlanePicker;
00575
00576
00577 void InvertTable();
00578
00579
00580 void WindowLevel(int X, int Y);
00581 void Push(double *p1, double *p2);
00582 void Spin(double *p1, double *p2);
00583 void Rotate(double *p1, double *p2, double *vpn);
00584 void Scale(double *p1, double *p2, int X, int Y);
00585 void Translate(double *p1, double *p2);
00586
00587 vtkImageData *ImageData;
00588 vtkImageReslice *Reslice;
00589 vtkMatrix4x4 *ResliceAxes;
00590 vtkTransform *Transform;
00591 vtkActor *TexturePlaneActor;
00592 vtkImageMapToColors *ColorMap;
00593 vtkTexture *Texture;
00594 vtkLookupTable *LookupTable;
00595 vtkLookupTable *CreateDefaultLookupTable();
00596
00597
00598
00599
00600
00601 vtkProperty *PlaneProperty;
00602 vtkProperty *SelectedPlaneProperty;
00603 vtkProperty *CursorProperty;
00604 vtkProperty *MarginProperty;
00605 vtkProperty *TexturePlaneProperty;
00606 void CreateDefaultProperties();
00607
00608
00609 void UpdatePlane();
00610 void GenerateTexturePlane();
00611
00612
00613 vtkPolyData *CursorPolyData;
00614 vtkActor *CursorActor;
00615 double CurrentCursorPosition[3];
00616 double CurrentImageValue;
00617 void GenerateCursor();
00618 void UpdateCursor(int,int);
00619 void ActivateCursor(int);
00620 int UpdateContinuousCursor(double *q);
00621 int UpdateDiscreteCursor(double *q);
00622 int UseContinuousCursor;
00623
00624
00625 vtkTextActor *TextActor;
00626 char TextBuff[128];
00627 void GenerateText();
00628 void ManageTextDisplay();
00629 void ActivateText(int);
00630
00631
00632 double RotateAxis[3];
00633 double RadiusVector[3];
00634 void AdjustState();
00635
00636
00637 vtkPolyData *MarginPolyData;
00638 vtkActor *MarginActor;
00639 int MarginSelectMode;
00640 void GenerateMargins();
00641 void UpdateMargins();
00642 void ActivateMargins(int);
00643 double MarginSizeX;
00644 double MarginSizeY;
00645
00646 private:
00647 vtkImagePlaneWidget(const vtkImagePlaneWidget&);
00648 void operator=(const vtkImagePlaneWidget&);
00649 };
00650
00651 #endif