[vtkusers] vtkResliceCursorWidget observers in Java

Marco Sambin m.sambin at gmail.com
Fri Dec 16 06:16:30 EST 2011


Hi all.

First of all, I am new to VTK, so please bear with me if some of my
questions will be basic or a bit "confused" sometimes...

I need to implement Multi-Planar Reconstruction in a Java-based medical
application, hence I am using the Java version (wrapper) of VTK.

By looking at the VTK documentation, I have found the
"vtkResliceImageViewer" class, which seems to be a very good starting point
for me.
Is this a 'new' class? It does not seem to be present in the official VTK
v5.8.0 yet. In fact, I downloaded and compiled the latest snapshot from the
source repository.

Basically, in my code I have a vtkCanvas-derived class named
"ResliceViewerCanvas", which embeds a vtkResliceImageViewer object.
In the GUI of my application, I have 3 ResliceViewerCanvas's, which shall
implement the 3 different sectional views of MPR.
I have shared the same vtkResliceCursor across the 3 different
ResliceViewerCanvas's (embedding vtkResliceImageViewer's) in my GUI, in
such a way to implement "synchronization" across these 3 panels when acting
upon the reslice cursor widget.

Here is some of my initialization code (located in the constructor of my
ResliceImageViewerCanvas class):

[...]
    resliceImageViewer = new vtkResliceImageViewer();
    resliceImageViewer.SetInput(myImgDataVTK);
    resliceImageViewer.SetColorWindow(myWinWidth);
    resliceImageViewer.SetColorLevel(myWinLevel);

    // TBD: set the correct size depending on original image
    resliceImageViewer.SetSize(512, 512);

    resliceImageViewer.SetSliceOrientation(sliceOrient);

    Dimension dimension = super.getSize();
    rw = resliceImageViewer.GetRenderWindow();
    rw.SetSize(dimension.width, dimension.height);
    ren = resliceImageViewer.GetRenderer();
    resliceImageViewer.SetupInteractor(iren);

    vtkResliceCursorWidget resliceWidget =
resliceImageViewer.GetResliceCursorWidget();
    vtkResliceCursorLineRepresentation rep =
(vtkResliceCursorLineRepresentation) resliceWidget.GetRepresentation();

rep.GetResliceCursorActor().GetCursorAlgorithm().SetReslicePlaneNormal(sliceOrient);

    resliceWidget.SetInteractor(iren);
    resliceWidget.ManagesCursorOn();
    resliceWidget.SetEnabled(1);

    iren.AddObserver("MouseMoveEvent", this, "vtkMouseMoved");
    iren.AddObserver("LeftButtonPressEvent", this, "vtkLeftButtonPressed");
    iren.AddObserver("RightButtonPressEvent", this,
"vtkRightButtonPressed");
    resliceWidget.AddObserver("ResliceAxesChangedEvent", this,
"vtkResliceAxesChanged");
[...]

Obviously, I have defined the vtkMouseMoved(), vtkLeftButtonPressed(),
vtkRightButtonPressed() and vtkResliceAxesChanged() methods in my
ResliceImageViewer canvas class.

Nevertheless, my vtkResliceAxesChanged() method never gets called. On the
other side, vtkMouseMoved() and vtkRightButtonPressed() get correctly
called.

What am I doing wrong? How can I receive notifications by the
vtkResliceCursorWidget when the reslice widget lines are moved, in such a
way I can modify other views in my application?

Thanks in advance for any hint/suggestion, and sorry for the long post.

Regards,

Marco
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20111216/cafac8d2/attachment.htm>


More information about the vtkusers mailing list