[vtkusers] timer problems when subclassing vtkInteractorStyleTrackball
Lawrence M. Lifshitz
Lawrence.Lifshitz at umassmed.edu
Fri Jun 9 10:50:37 EDT 2000
Hi,
I wanted movement of the mouse while the left button was down
to change the zslice of a 3D dataset, instead of rotating the 3D
image. So I derived a new style class (InteractorStyleFlow)
from vtkInteractorStyleTrackball.
I then changed a the left button methods, and added my own state
to OnTimer. But as far as I can tell, the timer is never activated
when I push the left button down; ie, OnTimer is never called when
the left button is down. I saw no documentation on how to use
the timer routines. What am I leaving out? thanks.
I get the error messages from OnMouseMove,OnLeftButtonDown, and
OnLeftButtonUp. The other button functions still work fine (I didn't
override them).
code snippet (win32 platform, vtk 3.1):
void InteractorStyleFlow::OnMouseMove (int ctrl, int shift, int X, int
Y)
{
this->vtkInteractorStyleTrackball::OnMouseMove(ctrl,shift,X,Y);
// this call just does:
//this->LastPos[0] = X;
//this->LastPos[1] = Y;
cerr << "InteractorStyleFlow::OnMouseMove: " << ctrl << " "<<shift<<"
"<<X<<" "<<Y<<"\n";
}
//take out the rotation from the left button, change it to zslice
update.
void InteractorStyleFlow::OnLeftButtonDown(int ctrl, int shift, int X,
int Y)
{
//
this->OldX = X;
this->OldY = Y;
// leave these in. what do they do?
this->UpdateInternalState(ctrl, shift, X, Y);
this->Preprocess = 1;
this->FindPokedCamera(X, Y);
if (this->State == VTKIS_START)
this->State = LML_ZSLICE;
cerr << "state set to "<< this->State << "\n";
}
void InteractorStyleFlow::OnLeftButtonUp(int ctrl, int shift, int X, int
Y)
{
//
this->UpdateInternalState(ctrl, shift, X, Y);
//
if (this->LeftButtonReleaseMethod)
{
(*this->LeftButtonReleaseMethod)(this->LeftButtonReleaseMethodArg);
}
this->OldX = 0.0;
this->OldY = 0.0;
this->State = VTKIS_START;
cerr << "state set to "<< this->State << "\n";
}
// Add LML_ZSLICE to this version of OnTimer (from
vtkInteractorStyleTrackball::OnTimer)
//----------------------------------------------------------------------------
// By overriding the RotateCamera, RotateActor members we can
// use this timer routine for Joystick or Trackball - quite tidy
//----------------------------------------------------------------------------
void InteractorStyleFlow::OnTimer(void)
{
cerr << "InteractorStyleFlow::OnTimer: state = " << this->State <<
"\n";
vtkRenderWindowInteractor *rwi = this->Interactor;
switch (this->State)
{
case LML_ZSLICE:
// OnTimer is never called when State == LML_ZSLICE. why not?
rwi->CreateTimer(VTKI_TIMER_UPDATE);
this->ZsliceChanger();
break;
...
}
}
--
Lawrence M. Lifshitz, Ph.D.
Biomedical Imaging Group - University of Massachusetts Medical School
Phone: (508) 856-3392 email: Lawrence.Lifshitz at umassmed.edu
FAX: (508) 856-1840 web: http://invitro.umassmed.edu/~lml
More information about the vtkusers
mailing list