Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

How can i change the virtual void Execute (vtkObject *caller, unsigned long eid, void *callData) function of the vtkCallbackCommand class (vtk) to java, thanks a lot, AMAL

share|improve this question

1 Answer

Adding an callback method on a specific event is different from C++. As you can see in some vtk Java Exemple you don't have to create a class which extends from vtkCallbackCommand to rewrite the Execute Method. To add specific behavior you have to use the Java AddObserver() method, It should be something like :

public class kbHandler 
{
    private vtkRenderWindowInteractor iren;

    public static void main(String[] args) {
        kbHandler kbh = new kbHandler();
        kbh.doit();
    }

  void callbackHandler ()
  {
     // if i'm here, a key is pressed !!
     // you can get back information from iren (which key : iren.GetKeyCode())
  }

  public void doit ()
  {
     // Do lot of things

    iren = new vtkRenderWindowInteractor();
    iren.SetRenderWindow(renWin);

    // add observer for the handler  arg1 = event to observe, arg2 object handler of the event, arg3: method to call
    iren.AddObserver("CharEvent", this, "callbackHandler");

    iren.Initialize();
    iren.Start();

  }
}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.