Hi , I’ve been messing around with the vtkCaptionActor2D, and wrote an interaction style for it by following this example : https://kitware.github.io/vtk-examples/site/Cxx/Picking/HighlightPickedActor/ such that one can hold down on it and place it’s caption position on mouse click and drag.
However , if I attempt to rotate the camera to look towards either the X or Y coordinate in world space, the vtkCaptionActor2D seems to only accept mouse event positions in one direction only: Here’s the block of code that handles the resolution of it’s position:
virtual void OnLeftButtonUp() override
{
hold = false; //flag to check if the left mouse button is held down
if(LastPickedActor!=NULL && move)
{ //Unhighlight actor
this->LastPickedActor->GetProperty()->SetColor(1,1,1);
//Get Mouse position
int* position = this->GetInteractor()->GetEventPosition();
int x = position[0];
int y = position[1];
//Set coordinate system to display system
vtkSmartPointer<vtkCoordinate> coordinate = vtkSmartPointer<vtkCoordinate>::New();
coordinate->SetCoordinateSystemToDisplay();
coordinate->SetValue(x,y,0); //Set Screen coordinates
//Compute world coordinates from screen display coordinates
double* worldCoordinates = coordinate->GetComputedWorldValue(render->GetRenderWindow()->GetRenderers()->GetFirstRenderer());
double worldX{worldCoordinates[0]};
double worldY{worldCoordinates[1]};
double worldZ{worldCoordinates[2]};
LastPickedActor->GetPositionCoordinate()->SetCoordinateSystemToWorld();
LastPickedActor->SetPosition(worldCoordinates);
this->Interactor->Render();
//flag to check whether mouse is moving or not
move = false;
}
}
Is there something I am missing to transform it’s position to world space or does Actor 2D only work with an x-y plane ?