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
问问题
179 次
1 回答
1
在特定事件上添加回调方法与 C++ 不同。正如您在一些vtk Java示例中所见,您不必创建从 vtkCallbackCommand 扩展的类来重写执行方法。要添加特定行为,您必须使用 Java AddObserver() 方法,它应该类似于:
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();
}
}
于 2013-07-04T14:33:54.150 回答