00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00123 #ifndef __vtkImagePlaneWidget_h
00124 #define __vtkImagePlaneWidget_h
00125
00126 #include "vtkPolyDataSourceWidget.h"
00127
00128 class vtkActor;
00129 class vtkCellPicker;
00130 class vtkDataSetMapper;
00131 class vtkImageData;
00132 class vtkImageMapToColors;
00133 class vtkImageReslice;
00134 class vtkLookupTable;
00135 class vtkMatrix4x4;
00136 class vtkPlaneSource;
00137 class vtkPoints;
00138 class vtkPolyData;
00139 class vtkPolyDataMapper;
00140 class vtkProperty;
00141 class vtkTextActor;
00142 class vtkTextProperty;
00143 class vtkTexture;
00144 class vtkTextureMapToPlane;
00145 class vtkTransform;
00146
00147 #define VTK_NEAREST_RESLICE 0
00148 #define VTK_LINEAR_RESLICE 1
00149 #define VTK_CUBIC_RESLICE 2
00150
00151 class VTK_EXPORT vtkImagePlaneWidget : public vtkPolyDataSourceWidget
00152 {
00153 public:
00155 static vtkImagePlaneWidget *New();
00156
00157 vtkTypeRevisionMacro(vtkImagePlaneWidget,vtkPolyDataSourceWidget);
00158 void PrintSelf(ostream& os, vtkIndent indent);
00159
00161
00162 virtual void SetEnabled(int);
00163 virtual void PlaceWidget(float bounds[6]);
00164 void PlaceWidget()
00165 {this->Superclass::PlaceWidget();}
00166 void PlaceWidget(float xmin, float xmax, float ymin, float ymax,
00167 float zmin, float zmax)
00168 {this->Superclass::PlaceWidget(xmin,xmax,ymin,ymax,zmin,zmax);}
00170
00172 void SetInput(vtkDataSet* input);
00173
00175
00176 void SetOrigin(float x, float y, float z);
00177 void SetOrigin(float xyz[3]);
00178 float* GetOrigin();
00179 void GetOrigin(float xyz[3]);
00181
00183
00185 void SetPoint1(float x, float y, float z);
00186 void SetPoint1(float xyz[3]);
00187 float* GetPoint1();
00188 void GetPoint1(float xyz[3]);
00190
00192
00194 void SetPoint2(float x, float y, float z);
00195 void SetPoint2(float xyz[3]);
00196 float* GetPoint2();
00197 void GetPoint2(float xyz[3]);
00199
00201
00202 float* GetCenter();
00203 void GetCenter(float xyz[3]);
00205
00207
00208 float* GetNormal();
00209 void GetNormal(float xyz[3]);
00211
00213 void GetVector1(float v1[3]);
00214
00216 void GetVector2(float v2[3]);
00217
00219 int GetSliceIndex();
00220
00222 void SetSliceIndex(int index);
00223
00225 float GetSlicePosition();
00226
00228 void SetSlicePosition(float position);
00229
00231
00232 void SetResliceInterpolate(int);
00233 vtkGetMacro(ResliceInterpolate,int);
00234 void SetResliceInterpolateToNearestNeighbour()
00235 { this->SetResliceInterpolate(VTK_NEAREST_RESLICE); }
00236 void SetResliceInterpolateToLinear()
00237 { this->SetResliceInterpolate(VTK_LINEAR_RESLICE); }
00238 void SetResliceInterpolateToCubic()
00239 { this->SetResliceInterpolate(VTK_CUBIC_RESLICE); }
00241
00243 vtkImageData* GetResliceOutput();
00244
00246
00247 vtkSetMacro(RestrictPlaneToVolume,int);
00248 vtkGetMacro(RestrictPlaneToVolume,int);
00249 vtkBooleanMacro(RestrictPlaneToVolume,int);
00251
00253
00255 vtkSetMacro(UserControlledLookupTable,int);
00256 vtkGetMacro(UserControlledLookupTable,int);
00257 vtkBooleanMacro(UserControlledLookupTable,int);
00259
00261
00265 vtkSetMacro(TextureInterpolate,int);
00266 vtkGetMacro(TextureInterpolate,int);
00267 vtkBooleanMacro(TextureInterpolate,int);
00269
00277 void GetPolyData(vtkPolyData *pd);
00278
00284 vtkPolyDataSource* GetPolyDataSource();
00285
00288 void UpdatePlacement(void);
00289
00292 vtkTexture *GetTexture();
00293
00298 vtkImageMapToColors* GetImageMapToColors();
00299
00301
00303 virtual void SetPlaneProperty(vtkProperty*);
00304 vtkGetObjectMacro(PlaneProperty,vtkProperty);
00305 virtual void SetSelectedPlaneProperty(vtkProperty*);
00306 vtkGetObjectMacro(SelectedPlaneProperty,vtkProperty);
00308
00310
00312 void SetPlaneOrientation(int);
00313 vtkGetMacro(PlaneOrientation,int);
00314 void SetPlaneOrientationToXAxes()
00315 { this->SetPlaneOrientation(0); }
00316 void SetPlaneOrientationToYAxes()
00317 { this->SetPlaneOrientation(1); }
00318 void SetPlaneOrientationToZAxes()
00319 { this->SetPlaneOrientation(2); }
00321
00326 void SetPicker(vtkCellPicker*);
00327
00329
00334 virtual void SetLookupTable(vtkLookupTable*);
00335 vtkGetObjectMacro(LookupTable,vtkLookupTable);
00337
00339
00341 vtkSetMacro(DisplayText,int);
00342 vtkGetMacro(DisplayText,int);
00343 vtkBooleanMacro(DisplayText,int);
00345
00347
00348 virtual void SetCursorProperty(vtkProperty*);
00349 vtkGetObjectMacro(CursorProperty,vtkProperty);
00351
00353
00354 virtual void SetMarginProperty(vtkProperty*);
00355 vtkGetObjectMacro(MarginProperty,vtkProperty);
00357
00359
00361 void SetTextProperty(vtkTextProperty* tprop);
00362 vtkTextProperty* GetTextProperty();
00364
00366
00367 virtual void SetTexturePlaneProperty(vtkProperty*);
00368 vtkGetObjectMacro(TexturePlaneProperty,vtkProperty);
00370
00372 void GetWindowLevel(float wl[2]);
00373
00376 int GetCursorData(float xyzv[4]);
00377
00379
00380 void SetInteraction(int interact);
00381 vtkGetMacro(Interaction,int);
00382 vtkBooleanMacro(Interaction,int);
00384
00385 protected:
00386 vtkImagePlaneWidget();
00387 ~vtkImagePlaneWidget();
00388
00389
00390 int State;
00391 enum WidgetState
00392 {
00393 Start=0,
00394 Cursoring,
00395 WindowLevelling,
00396 Pushing,
00397 Spinning,
00398 Rotating,
00399 Moving,
00400 Scaling,
00401 Outside
00402 };
00403
00404
00405
00406 static void ProcessEvents(vtkObject* object,
00407 unsigned long event,
00408 void* clientdata,
00409 void* calldata);
00410
00411
00412 void OnMouseMove();
00413 void OnLeftButtonDown();
00414 void OnLeftButtonUp();
00415 void OnMiddleButtonDown();
00416 void OnMiddleButtonUp();
00417 void OnRightButtonDown();
00418 void OnRightButtonUp();
00419
00420
00421 int Interaction;
00422 int PlaneOrientation;
00423 int RestrictPlaneToVolume;
00424 float OriginalWindow;
00425 float OriginalLevel;
00426 float CurrentWindow;
00427 float CurrentLevel;
00428 int ResliceInterpolate;
00429 int TextureInterpolate;
00430 int UserControlledLookupTable;
00431 int DisplayText;
00432
00433
00434 vtkPlaneSource *PlaneSource;
00435 float Normal[3];
00436 vtkPolyData *PlaneOutlinePolyData;
00437 vtkActor *PlaneOutlineActor;
00438 vtkPolyDataMapper *PlaneOutlineMapper;
00439 void HighlightPlane(int highlight);
00440 void GeneratePlaneOutline();
00441
00442
00443 void BuildRepresentation();
00444
00445
00446 vtkCellPicker *PlanePicker;
00447
00448
00449 void WindowLevel(int X, int Y);
00450 void Push(double *p1, double *p2);
00451 void Spin(double *p1, double *p2);
00452 void Rotate(double *p1, double *p2, double *vpn);
00453 void Scale(double *p1, double *p2, int X, int Y);
00454 void Translate(double *p1, double *p2);
00455
00456 vtkImageData *ImageData;
00457 vtkImageReslice *Reslice;
00458 vtkMatrix4x4 *ResliceAxes;
00459 vtkTransform *Transform;
00460 vtkTextureMapToPlane *TexturePlaneCoords;
00461 vtkDataSetMapper *TexturePlaneMapper;
00462 vtkActor *TexturePlaneActor;
00463 vtkImageMapToColors *ColorMap;
00464 vtkTexture *Texture;
00465 vtkLookupTable *LookupTable;
00466 vtkLookupTable *CreateDefaultLookupTable();
00467
00468
00469
00470
00471
00472 vtkProperty *PlaneProperty;
00473 vtkProperty *SelectedPlaneProperty;
00474 vtkProperty *CursorProperty;
00475 vtkProperty *MarginProperty;
00476 vtkProperty *TexturePlaneProperty;
00477 void CreateDefaultProperties();
00478
00479
00480 void UpdateNormal();
00481 void UpdateOrigin();
00482 void GenerateTexturePlane();
00483
00484
00485 vtkPolyData *CursorPolyData;
00486 vtkPolyDataMapper *CursorMapper;
00487 vtkActor *CursorActor;
00488 int CurrentCursorPosition[3];
00489 float CurrentImageValue;
00490 void GenerateCursor();
00491 void UpdateCursor(int,int);
00492 void ActivateCursor(int);
00493
00494
00495 vtkTextActor *TextActor;
00496 char TextBuff[128];
00497 void GenerateText();
00498 void ManageTextDisplay();
00499 void ActivateText(int);
00500
00501
00502 float RotateAxis[3];
00503 float RadiusVector[3];
00504 void AdjustState();
00505
00506
00507 vtkPolyData *MarginPolyData;
00508 vtkPolyDataMapper *MarginMapper;
00509 vtkActor *MarginActor;
00510 int MarginSelectMode;
00511 void GenerateMargins();
00512 void UpdateMargins();
00513 void ActivateMargins(int);
00514
00515 private:
00516 vtkImagePlaneWidget(const vtkImagePlaneWidget&);
00517 void operator=(const vtkImagePlaneWidget&);
00518 };
00519
00520 #endif