[vtkusers] custom vtkAbstractWidget + vtkWidgetRepresentation in Java
Sebastien Jourdain
sebastien.jourdain at kitware.com
Thu Sep 7 10:54:28 EDT 2017
Hi Petr,
I think you have to implement your code in C++ and then use it within Java.
Seb
On Thu, Sep 7, 2017 at 8:08 AM, Petr Matoušek <p3tr.matousek at gmail.com>
wrote:
> Hello,
>
> can anybody suggest how to implement custom vtkAbstractWidget and
> vtkWidgetRepresentation in Java? Is it even possible?
>
> I tried it but failed.
>
> 1. The first problem I encountered was that vtkAbstractWidget uses its
> protected field WidgetRep, but there is no way how to set it from Java
> code. Only public methods are accessible from Java. So I introduced my own
> field in the Java class and overrided the GetRepresentation() method to
> return it. So far so good:
>
> public class CoordRangeVtkLineWidget extends vtkAbstractWidget {
>
> private final vtkLineRepresentation representation;
>
> public CoordRangeVtkLineWidget(final CoordRange coordRange) {
> super();
> this.representation = new vtkLineRepresentation();
> }
>
> @Override
> public vtkWidgetRepresentation GetRepresentation() {
> return this.representation;
> }
> }
>
> 2. But then the SetInteractor() method started to fail for my widget with
> SIGSEGV crash. I guess this is due to the fact that the observer mechanism
> is implemented a bit differently in Java. So it is not possible to call the
> original AddObserver() methods with Java object instances.
>
> So I skipped the interactor for the moment:
>
> @Override
> public void SetInteractor(final vtkRenderWindowInteractor interactor) {
> // TODO
> }
>
> 3. Then vtkAbstractWidget::SetEnabled() started to fail with SIGSEGV of
> course.
>
> So I stopped and start to think: this would be quite difficult. In fact I
> will probably have to reimplement the whole vtkAbstractWidget in Java to
> make it work.
>
> So does anybody any experience with this. Any suggestions? Am I going
> wrong direction? Please.
>
> Best regards, Petr Matousek
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensou
> rce/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Search the list archives at: http://markmail.org/search/?q=vtkusers
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/vtkusers
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20170907/60396e6e/attachment.html>
More information about the vtkusers
mailing list