[vtkusers] extending c++ interaction classes and using them with Java

Henrik Westerberg henrik.westerberg at crg.es
Wed Dec 16 04:52:40 EST 2009


On 2009/12/15 Henrik Westerberg wrote:
>
> Hi vtkusers,
>
> After some checking on the list I realized that its not possible to sub class a vtk class in Java and use
> the class due to the Wrapping.
>
> So I have chosen to extend vtkInteractorTrackballActor.cxx. However I don't know anything about programming
> in C++ or changing VTK classes so if someone can eyeball my class and tell me if I missed anything obvious
> I would really appreciate it. I have attempted to override UniformScale to only scale in X .
>
> The reason is I am quite often getting a Java VM crash when swapping interactor styles between my extended
> Interactor and any of the default VTK ones. The swap is going through: setInteractorStyle in vtkCanvas.
[...]

Maybe your code is not at fault, did you try switching between
different VTK interactor styles?

Denis


Hello Denis and vtkusers,

Thank-you for your reply. I am changing interaction style through:

vtkInteractorStyleSwitch istyle = new vtkInteractorStyleSwitch():
istyle.SetCurrentStyleToTrackballActor();
renWin.setInteractorStyle(istyle);

vtkInteractorStyleSwitch istyle = new vtkInteractorStyleSwitch():
istyle.SetCurrentStyleToTrackballActor();
renWin.setInteractorStyle(istyle);

where renWin is a vtkCanvas.

I have switched between these two in my gui plenty of times without any crashes.

I set the new extended version of the class using:

vtkInteractorStyleTrackballActorResizeX xscale = new vtkInteractorStyleTrackballActorResizeX():
renWin.setInteractorStyle(xscale)

And it is at this point when using the program that when I switch interaction style I will 
sometimes get  a java vm crash, or less often a segmentation fault. I am not sure yet 
if it is when I am switching to the new style or switching out, or both, but its not happening
on every switch to the new style.

thanks,
Henrik




More information about the vtkusers mailing list