00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00110
#ifndef __vtkImagePlaneWidget_h
00111
#define __vtkImagePlaneWidget_h
00112
00113
#include "vtkPolyDataSourceWidget.h"
00114
00115
class vtkActor;
00116
class vtkCellPicker;
00117
class vtkDataSetMapper;
00118
class vtkImageData;
00119
class vtkImageMapToColors;
00120
class vtkImageReslice;
00121
class vtkLookupTable;
00122
class vtkMatrix4x4;
00123
class vtkPlaneSource;
00124
class vtkPoints;
00125
class vtkPolyData;
00126
class vtkPolyDataMapper;
00127
class vtkProperty;
00128
class vtkTextActor;
00129
class vtkTextProperty;
00130
class vtkTexture;
00131
class vtkTextureMapToPlane;
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_EXPORT vtkImagePlaneWidget :
public vtkPolyDataSourceWidget
00139 {
00140
public:
00142
static vtkImagePlaneWidget *
New();
00143
00144 vtkTypeRevisionMacro(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
00272
void GetPolyData(
vtkPolyData *pd);
00273
00279
vtkPolyDataSource*
GetPolyDataSource();
00280
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(
vtkCellPicker*);
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
void SetTextProperty(
vtkTextProperty* tprop);
00360
vtkTextProperty* GetTextProperty();
00362
00364
00365
virtual void SetTexturePlaneProperty(
vtkProperty*);
00366 vtkGetObjectMacro(TexturePlaneProperty,
vtkProperty);
00368
00370
00372
void SetWindowLevel(
double window,
double level);
00373
void GetWindowLevel(
double wl[2]);
00375
00378
int GetCursorData(
double xyzv[4]);
00379
00381
00382
void SetInteraction(
int interact);
00383 vtkGetMacro(Interaction,
int);
00384 vtkBooleanMacro(Interaction,
int);
00386
00388
00389
enum
00390 {
00391 CURSOR_ACTION = 0,
00392 SLICE_MOTION_ACTION = 1,
00393 WINDOW_LEVEL_ACTION = 2
00394 };
00395
00396 vtkSetClampMacro(LeftButtonAction,
int, CURSOR_ACTION, WINDOW_LEVEL_ACTION);
00397 vtkGetMacro(LeftButtonAction,
int);
00398 vtkSetClampMacro(MiddleButtonAction,
int, CURSOR_ACTION, WINDOW_LEVEL_ACTION);
00399 vtkGetMacro(MiddleButtonAction,
int);
00400 vtkSetClampMacro(RightButtonAction,
int, CURSOR_ACTION, WINDOW_LEVEL_ACTION);
00401 vtkGetMacro(RightButtonAction,
int);
00403
00405
00411
enum
00412 {
00413 NO_MODIFIER = 0,
00414 SHIFT_MODIFIER = 1,
00415 CONTROL_MODIFIER = 2
00416 };
00417
00418 vtkSetClampMacro(LeftButtonAutoModifier,
int, SHIFT_MODIFIER, CONTROL_MODIFIER);
00419 vtkGetMacro(LeftButtonAutoModifier,
int);
00420 vtkSetClampMacro(MiddleButtonAutoModifier,
int, SHIFT_MODIFIER, CONTROL_MODIFIER);
00421 vtkGetMacro(MiddleButtonAutoModifier,
int);
00422 vtkSetClampMacro(RightButtonAutoModifier,
int, SHIFT_MODIFIER, CONTROL_MODIFIER);
00423 vtkGetMacro(RightButtonAutoModifier,
int);
00425
00426
protected:
00427 vtkImagePlaneWidget();
00428 ~vtkImagePlaneWidget();
00429
00430 int TextureVisibility;
00431
00432 int LeftButtonAction;
00433 int MiddleButtonAction;
00434 int RightButtonAction;
00435
00436 int LeftButtonAutoModifier;
00437 int MiddleButtonAutoModifier;
00438 int RightButtonAutoModifier;
00439
00440
00441
enum
00442 {
00443 NO_BUTTON = 0,
00444 LEFT_BUTTON = 1,
00445 MIDDLE_BUTTON = 2,
00446 RIGHT_BUTTON = 3
00447 };
00448
00449 int LastButtonPressed;
00450
00451
00452 int State;
00453 enum WidgetState
00454 {
00455 Start=0,
00456 Cursoring,
00457 WindowLevelling,
00458 Pushing,
00459 Spinning,
00460 Rotating,
00461 Moving,
00462 Scaling,
00463 Outside
00464 };
00465
00466
00467
00468
static void ProcessEvents(
vtkObject* object,
00469
unsigned long event,
00470
void* clientdata,
00471
void* calldata);
00472
00473
00474
00475
00476
void AddObservers();
00477
00478
00479
virtual void OnMouseMove();
00480
virtual void OnLeftButtonDown();
00481
virtual void OnLeftButtonUp();
00482
virtual void OnMiddleButtonDown();
00483
virtual void OnMiddleButtonUp();
00484
virtual void OnRightButtonDown();
00485
virtual void OnRightButtonUp();
00486
00487
virtual void StartCursor();
00488
virtual void StopCursor();
00489
virtual void StartSliceMotion();
00490
virtual void StopSliceMotion();
00491
virtual void StartWindowLevel();
00492
virtual void StopWindowLevel();
00493
00494
00495 int Interaction;
00496 int PlaneOrientation;
00497 int RestrictPlaneToVolume;
00498 double OriginalWindow;
00499 double OriginalLevel;
00500 double CurrentWindow;
00501 double CurrentLevel;
00502 int ResliceInterpolate;
00503 int TextureInterpolate;
00504 int UserControlledLookupTable;
00505 int DisplayText;
00506
00507
00508 vtkPlaneSource *PlaneSource;
00509 double Normal[3];
00510 vtkPolyData *PlaneOutlinePolyData;
00511 vtkActor *PlaneOutlineActor;
00512 vtkPolyDataMapper *PlaneOutlineMapper;
00513
void HighlightPlane(
int highlight);
00514
void GeneratePlaneOutline();
00515
00516
00517
void BuildRepresentation();
00518
00519
00520 vtkCellPicker *PlanePicker;
00521
00522
00523
void WindowLevel(
int X,
int Y);
00524
void Push(
double *p1,
double *p2);
00525
void Spin(
double *p1,
double *p2);
00526
void Rotate(
double *p1,
double *p2,
double *vpn);
00527
void Scale(
double *p1,
double *p2,
int X,
int Y);
00528
void Translate(
double *p1,
double *p2);
00529
00530 vtkImageData *ImageData;
00531 vtkImageReslice *Reslice;
00532 vtkMatrix4x4 *ResliceAxes;
00533 vtkTransform *Transform;
00534 vtkTextureMapToPlane *TexturePlaneCoords;
00535 vtkPolyDataMapper *TexturePlaneMapper;
00536 vtkActor *TexturePlaneActor;
00537 vtkImageMapToColors *ColorMap;
00538 vtkTexture *Texture;
00539 vtkLookupTable *LookupTable;
00540
vtkLookupTable *CreateDefaultLookupTable();
00541
00542
00543
00544
00545
00546 vtkProperty *PlaneProperty;
00547 vtkProperty *SelectedPlaneProperty;
00548 vtkProperty *CursorProperty;
00549 vtkProperty *MarginProperty;
00550 vtkProperty *TexturePlaneProperty;
00551
void CreateDefaultProperties();
00552
00553
00554
void UpdateNormal();
00555
void UpdateOrigin();
00556
void GenerateTexturePlane();
00557
00558
00559 vtkPolyData *CursorPolyData;
00560 vtkPolyDataMapper *CursorMapper;
00561 vtkActor *CursorActor;
00562 int CurrentCursorPosition[3];
00563 double CurrentImageValue;
00564
void GenerateCursor();
00565
void UpdateCursor(
int,
int);
00566
void ActivateCursor(
int);
00567
00568
00569 vtkTextActor *TextActor;
00570 char TextBuff[128];
00571
void GenerateText();
00572
void ManageTextDisplay();
00573
void ActivateText(
int);
00574
00575
00576 double RotateAxis[3];
00577 double RadiusVector[3];
00578
void AdjustState();
00579
00580
00581 vtkPolyData *MarginPolyData;
00582 vtkPolyDataMapper *MarginMapper;
00583 vtkActor *MarginActor;
00584 int MarginSelectMode;
00585
void GenerateMargins();
00586
void UpdateMargins();
00587
void ActivateMargins(
int);
00588
00589
private:
00590 vtkImagePlaneWidget(
const vtkImagePlaneWidget&);
00591
void operator=(
const vtkImagePlaneWidget&);
00592 };
00593
00594
#endif