[vtkusers] InteractionProp in Java

Ambar C ambarc at gmail.com
Sat Nov 13 15:45:49 EST 2010


Hello,

I understand the way JNI works in VTK, but the member that I'm having
trouble accessing isn't something that I've overloaded any C++ class
with. I'm trying to be able to access the InteractionProp member of
the vtkInteractorStyleTrackballActor, which is a protected member
object of the class. My observation so far is that this member doesn't
seem to be recognized in the Java wrapped implementation. I'm not sure
how JNI would tie into this lack of propagation, but do correct me if
I'm wrong.

Cheers,
Ambar

On Sat, Nov 13, 2010 at 10:37 AM, Jim Peterson <jimcp at cox.net> wrote:
> Ambar,
> The set of vtk classes available in Java are not actually java classes, they
> are interfaces with the C++ vtk classes implemented in the vtk shared
> libraries. The Java terminology is the classes are implemented via the Java
> Native Interface (JNI). As such, you cannot extend vtk classes in Java to
> add functionality as you might in C++. The vtk C++ logic is unaware of the
> Java extensions.
> You have at least three choices are:
> 1. Add your modified C++ class to vtk so that it is included in one of the
> vtk shared libraries and wrapped by the Java interface and available to your
> Java program.
> 2. Use the mouse move or other interaction callbacks in your java code to
> gain control and interact with your vtk model.
> 3. Use the relatively undocumented vtkRenderWindowPanel class from  Java so
> that you can use Java UI events to interact with the vtk object.
>
> I am not exactly sure what your eventual goal is other that the interaction
> modifications, but some examples of the java addObserver callbacks and Swing
> panel implementation are available from here:
> http://www.vtk.org/Wiki/VTK/Examples/Java
>
> Hope that helps,
> Jim
>
> Ambar C wrote:
>>
>> Hi Jim,
>>
>> Could you be more specific? What would I need to do to be able to grab
>> the mouse driven value changes in orientation and position in Java? I
>> don't understand how I'd be able to replace the interaction prop's
>> functionality. Thanks for the help.
>>
>> Best,
>> Ambar
>>
>> On Tue, Nov 9, 2010 at 4:04 AM, Jim Peterson <jimcp at cox.net> wrote:
>>
>>>
>>> Ambar C wrote:
>>>
>>>>
>>>> Hello,
>>>>
>>>> I'm working on modifying an vtkInteractorStyleTrackballActor to have
>>>> my own custom class, and am trying to access it's InteractionProp
>>>> member but it doesn't seem to be coming through. The equivalent code
>>>> works in C++, but something along the lines of
>>>>
>>>> public modifiedClass extends vtkInteractorStyleTrackballActor
>>>> {
>>>>    .....
>>>>    this.InteractionProp. //Doesn't recognize the member.
>>>>
>>>> }
>>>>
>>>>
>>>>
>>>
>>> Ambar,
>>> I think this is not a valid construct for classes that are used for JNI
>>> interfaces. Yes, Java compiles it, but no, there is no runtime
>>> inheritance
>>> to the c++ classes.  The pure java way to modify interaction behavior is
>>> to
>>> use the interaction observers. If you want to use your C++ code you would
>>> need to add it to the vtk source tree and rebuild both vtk and the java
>>> wrappers, The new class can be wrapped and accessible to Java in that
>>> way.
>>>
>>> If you need to address this completely in Java, maybe it would be better
>>> to
>>> identify your desired modification to the interaction rather than the
>>> solution first.
>>>
>>> Hope that helps,
>>> Jim
>>>
>>>
>>
>>
>
>



More information about the vtkusers mailing list