[vtkusers] How to get 'proper' coordinates from 2dwidget

Totte Karlsson totte at dunescientific.com
Wed Apr 8 14:56:46 EDT 2015


Hello,
I want to use a seedwidget (using the cross) to allow a user to 
translate (drag) a vtk actor in a scene, in the xy dimension. In short, 
I do want the translation, dragging action to be the same as the 
interaction you have when using a vtkInteractorStyleTrackballActor 
interactor.

The code below does the job, except it moves, resets the position, of 
the actor in the direction of projection.

The coordinates are obtained in the widgets interaction Event:

             double pos[3];
this->SeedRepresentation->GetSeedDisplayPosition(0, pos);

             if(mMyActor)
             {
                 vtkSmartPointer<vtkCoordinate> coordinate = 
vtkSmartPointer<vtkCoordinate>::New();
                 coordinate->SetCoordinateSystemToDisplay();
                 coordinate->SetValue(pos[0], pos[1], pos[2]);
                 double *pos2 = coordinate->GetComputedWorldValue(ren);
                 mMyActor->setPosition(pos2[0], pos2[1], pos2[2]);
             }

How can one mask out the translation in the 'depth', direction of 
projection dimension??

Reason for not using InteractorStyleTrackballActor is that I may want to 
move several actors based on the seeds position, not just one.

-totte

-- 
.........................
Totte Karlsson, Ph.D.
Dune Scientific, LLC
425-780 9648 (cell)
www.dunescientific.com
.........................



More information about the vtkusers mailing list