00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00047
#ifndef __vtkRenderWindowInteractor_h
00048
#define __vtkRenderWindowInteractor_h
00049
00050
#include "vtkObject.h"
00051
00052
00053 #define VTKI_TIMER_FIRST 0
00054 #define VTKI_TIMER_UPDATE 1
00055
00056
class vtkAbstractPicker;
00057
class vtkAbstractPropPicker;
00058
class vtkInteractorObserver;
00059
class vtkInteractorObserver;
00060
class vtkRenderWindow;
00061
class vtkRenderer;
00062
00063 class VTK_RENDERING_EXPORT vtkRenderWindowInteractor :
public vtkObject
00064 {
00065
public:
00066
static vtkRenderWindowInteractor *
New();
00067 vtkTypeRevisionMacro(vtkRenderWindowInteractor,
vtkObject);
00068
void PrintSelf(ostream& os,
vtkIndent indent);
00069
00071
00073
virtual void Initialize();
00074 void ReInitialize() { this->Initialized = 0; this->Enabled = 0;
00075 this->Initialize(); }
00077
00080
virtual void UnRegister(
vtkObjectBase *o);
00081
00085 virtual void Start() {};
00086
00088
00095 virtual void Enable() { this->Enabled = 1; this->
Modified();};
00096 virtual void Disable() { this->Enabled = 0; this->
Modified();};
00097 vtkGetMacro(Enabled,
int);
00099
00101
00102
void SetRenderWindow(
vtkRenderWindow *aren);
00103 vtkGetObjectMacro(RenderWindow,
vtkRenderWindow);
00105
00107
virtual void UpdateSize(
int x,
int y);
00108
00110
00115 virtual int CreateTimer(
int ) {
return 1; };
00116 virtual int DestroyTimer() {
return 1; };
00118
00122 virtual void TerminateApp(
void) {};
00123
00125
00126
virtual void SetInteractorStyle(
vtkInteractorObserver *);
00127 vtkGetObjectMacro(InteractorStyle,
vtkInteractorObserver);
00129
00131
00133 vtkSetMacro(LightFollowCamera,
int);
00134 vtkGetMacro(LightFollowCamera,
int);
00135 vtkBooleanMacro(LightFollowCamera,
int);
00137
00139
00143 vtkSetClampMacro(DesiredUpdateRate,
float,0.0001f,VTK_LARGE_FLOAT);
00144 vtkGetMacro(DesiredUpdateRate,
float);
00146
00148
00150 vtkSetClampMacro(StillUpdateRate,
float,0.0001f,VTK_LARGE_FLOAT);
00151 vtkGetMacro(StillUpdateRate,
float);
00153
00155
00156 vtkGetMacro(Initialized,
int);
00158
00160
00164
virtual void SetPicker(
vtkAbstractPicker*);
00165 vtkGetObjectMacro(Picker,
vtkAbstractPicker);
00167
00170
virtual vtkAbstractPropPicker *CreateDefaultPicker();
00171
00172
#ifndef VTK_REMOVE_LEGACY_CODE
00173
00174
00175
void SetStartPickMethod(
void (*f)(
void *),
void *arg);
00176
void SetStartPickMethodArgDelete(
void (*f)(
void *));
00177
void SetEndPickMethod(
void (*f)(
void *),
void *arg);
00178
void SetEndPickMethodArgDelete(
void (*f)(
void *));
00179
void SetUserMethod(
void (*f)(
void *),
void *arg);
00180
void SetUserMethodArgDelete(
void (*f)(
void *));
00181
void SetExitMethod(
void (*f)(
void *),
void *arg);
00182
void SetExitMethodArgDelete(
void (*f)(
void *));
00184
#endif
00185
00187
00189
virtual void ExitCallback();
00190
virtual void UserCallback();
00191
virtual void StartPickCallback();
00192
virtual void EndPickCallback();
00194
00196 virtual void GetMousePosition(
int *x,
int *y) { *x = 0 ; *y = 0; }
00197
00199
00201
void HideCursor();
00202
void ShowCursor();
00204
00207
virtual void Render();
00208
00210
00213
void FlyTo(
vtkRenderer *ren,
float x,
float y,
float z);
00214 void FlyTo(
vtkRenderer *ren,
float *x)
00215 {this->FlyTo(ren, x[0], x[1], x[2]);}
00216
void FlyToImage(
vtkRenderer *ren,
float x,
float y);
00217 void FlyToImage(
vtkRenderer *ren,
float *x)
00218 {this->FlyToImage(ren, x[0], x[1]);}
00220
00222
00223 vtkSetClampMacro(NumberOfFlyFrames,
int,1,VTK_LARGE_INTEGER);
00224 vtkGetMacro(NumberOfFlyFrames,
int);
00226
00228
00230 vtkSetMacro(Dolly,
float);
00231 vtkGetMacro(Dolly,
float);
00233
00235
00240 vtkGetVector2Macro(EventPosition,
int);
00241 vtkGetVector2Macro(LastEventPosition,
int);
00242 virtual void SetEventPosition(
int x,
int y)
00243 {
00244 vtkDebugMacro(<< this->GetClassName() <<
" (" <<
this
00245 <<
"): setting EventPosition to (" << x <<
"," << y <<
")");
00246
if (this->EventPosition[0] != x || this->EventPosition[1] != y)
00247 {
00248 this->LastEventPosition[0] = this->EventPosition[0];
00249 this->LastEventPosition[1] = this->EventPosition[1];
00250 this->EventPosition[0] = x;
00251 this->EventPosition[1] = y;
00252 this->
Modified();
00253 }
00254 };
00255 virtual void SetEventPosition(
int pos[2])
00256 {
00257 this->SetEventPosition(pos[0], pos[1]);
00258 }
00259 virtual void SetEventPositionFlipY(
int x,
int y)
00260 {
00261 this->SetEventPosition(x, this->Size[1] - y - 1);
00262 }
00263 virtual void SetEventPositionFlipY(
int pos[2])
00264 {
00265 this->SetEventPositionFlipY(pos[0], pos[1]);
00266 }
00267 vtkSetMacro(ControlKey,
int);
00268 vtkGetMacro(ControlKey,
int);
00269 vtkSetMacro(ShiftKey,
int);
00270 vtkGetMacro(ShiftKey,
int);
00271 vtkSetMacro(KeyCode,
char);
00272 vtkGetMacro(KeyCode,
char);
00273 vtkSetMacro(RepeatCount,
int);
00274 vtkGetMacro(RepeatCount,
int);
00275 vtkSetStringMacro(KeySym);
00276 vtkGetStringMacro(KeySym);
00278
00280
00281 void SetEventInformation(
int x,
00282
int y,
00283
int ctrl=0,
00284
int shift=0,
00285
char keycode=0,
00286
int repeatcount=0,
00287
const char* keysym=0)
00288 {
00289 this->LastEventPosition[0] = this->EventPosition[0];
00290 this->LastEventPosition[1] = this->EventPosition[1];
00291 this->EventPosition[0] = x;
00292 this->EventPosition[1] = y;
00293 this->ControlKey = ctrl;
00294 this->ShiftKey = shift;
00295 this->KeyCode = keycode;
00296 this->RepeatCount = repeatcount;
00297
if(keysym)
00298 {
00299 this->SetKeySym(keysym);
00300 }
00301 this->
Modified();
00302 }
00304
00306
00308 void SetEventInformationFlipY(
int x,
00309
int y,
00310
int ctrl=0,
00311
int shift=0,
00312
char keycode=0,
00313
int repeatcount=0,
00314
const char* keysym=0)
00315 {
00316 this->SetEventInformation(x,
00317 this->Size[1] - y - 1,
00318 ctrl,
00319 shift,
00320 keycode,
00321 repeatcount,
00322 keysym);
00323 }
00325
00327
00328 void SetKeyEventInformation(
int ctrl=0,
00329
int shift=0,
00330
char keycode=0,
00331
int repeatcount=0,
00332
const char* keysym=0)
00333 {
00334 this->ControlKey = ctrl;
00335 this->ShiftKey = shift;
00336 this->KeyCode = keycode;
00337 this->RepeatCount = repeatcount;
00338
if(keysym)
00339 {
00340 this->SetKeySym(keysym);
00341 }
00342 this->
Modified();
00343 }
00345
00347
00353 vtkSetVector2Macro(Size,
int);
00354 vtkGetVector2Macro(Size,
int);
00355 vtkSetVector2Macro(EventSize,
int);
00356 vtkGetVector2Macro(EventSize,
int);
00358
00362
vtkRenderer *FindPokedRenderer(
int,
int);
00363
00364
protected:
00365 vtkRenderWindowInteractor();
00366 ~vtkRenderWindowInteractor();
00367
00368 vtkRenderWindow *RenderWindow;
00369 vtkInteractorObserver *InteractorStyle;
00370
00371
00372 vtkAbstractPicker *Picker;
00373
00374 int Initialized;
00375 int Enabled;
00376 int Style;
00377 int LightFollowCamera;
00378 int ActorMode;
00379 float DesiredUpdateRate;
00380 float StillUpdateRate;
00381
00382
00383 int ControlKey;
00384 int ShiftKey;
00385 char KeyCode;
00386 int RepeatCount;
00387 char* KeySym;
00388 int EventPosition[2];
00389 int LastEventPosition[2];
00390 int EventSize[2];
00391 int Size[2];
00392
00393
00394
00395
00396
00397 unsigned long StartPickTag;
00398 unsigned long EndPickTag;
00399 unsigned long UserTag;
00400 unsigned long ExitTag;
00401
00402
00403 int NumberOfFlyFrames;
00404 float Dolly;
00405
00406
private:
00407 vtkRenderWindowInteractor(
const vtkRenderWindowInteractor&);
00408
void operator=(
const vtkRenderWindowInteractor&);
00409 };
00410
00411
#endif