[vtkusers] vtkImageViewer + vAddObserver()

ruifeng ma mrf341 at gmail.com
Wed Dec 28 10:32:39 EST 2011


Hi,
I wrote a program using several vtkImageViewer to show a image series  for
the user to choose one, and each vtkImageViewer contains one image with
different Z slice. Here is the problem: how to know which vtkImageViewer is
clicked and get its Z slice. I try to use addObserver, the code is like
this:
              .......
              vtkWin32RenderWindowInteractor* interator =
vtkWin32RenderWindowInteractor::New();
     vtkCallbackCommand* command = vtkCallbackCommand::New();
             command->SetCallback(mycallback);
             myviewer->SetupInteractor(interator);
     interator->AddObserver(vtkCommand::LeftButtonPressEvent,command);
             .....

    here i don't know how to write, because the caller is not
vtkImageViewer, if i write it like this:
             void mycallback(vtkObject *caller, unsigned long eid, void
*clientdata, void *calldata)
          {
                vtkImageViewer* viewer =
reinterpret_cast<vtkImageViewer*>(caller);
        viewer ->GetZSlice();
          }
   it works wrong, if i use
        vtkWin32RenderWindowInteractor* interator = reinterpret_cast<
vtkWin32RenderWindowInteractor*>(caller);
   i wouldn't get the Z slice. can you give me some advice to solve this
problem? Thanks very much and with regards.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20111228/ff4d09bb/attachment.htm>


More information about the vtkusers mailing list