[vtkusers] Question About selecting a point in vtkCanvas -- Java.

Sebastien Jourdain sebastien.jourdain at kitware.com
Mon Jun 11 11:56:19 EDT 2012


I guess it's because you said that the point is at z=0 so the z will
still be wrong after your convert ion. On the other hand, point and
cell picker do work in Java as I remember doing it a while ago.
By default its the "p" key that you need to hit to trigger the picking...

On Mon, Jun 11, 2012 at 11:36 AM, satyanarayana reddy
<satyajanga at gmail.com> wrote:
>
>
> Dear vtkusers,
>             I have a requirement in which I need to select a point( by mouse
> click) in Cube. I am not using vtkPointPicker/vtkCellPicker as they does not
> seem to compatible in Java.
>   I am creating a class which extends vtkCanvas to render the cube and I am
> overriding the mouse listeners in vtkCanvas  to pick the event position and
> converting it to World Coordinates using the following code as I am not sure
> how to use the static methods in vtkInteractorObserver(in Java wrapped vtk),
>
>     double[] GetDisplayToWorldCoordinates(double x, double y)
>     {
> /* x,y represent the event position*/
>         double[] coordinates = new double[3];
>         coordinates[0]=(double)x;
>         coordinates[1]=(double)y;
>         coordinates[2]=0;
>         double[] worldCord = new double[3];
>
>         this.GetRenderer().SetDisplayPoint(coordinates);
>         this.GetRenderer().DisplayToView();
>         this.GetRenderer().ViewToWorld();
>         worldCord=    this.GetRenderer().GetWorldPoint();
>
>        return worldCord;
>    }
>
>
> My box source is (0,200,0,200,0,200). But the worldCord returned from the
> function is not what I expected. They are not even coming in the  extent.
>
> Please check If I am doing anything wrong. Or suggest how to convert the
> event position in object coordinate system.
>
>
> Thanks in advance,
>
> Best Regards,
> Satya.
>
>
>
>



More information about the vtkusers mailing list