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

satyanarayana reddy satyajanga at gmail.com
Mon Jun 11 10:50:32 EDT 2012


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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20120611/16ebdbb3/attachment.htm>


More information about the vtkusers mailing list