天天看点

【VTK基础】vtk切换交互模式

想自己写command,在command里面针对不同情况切换交互模式,方法如下:

main里面:

vtkSmartPointer<vtkInteractorStyleSwitch>style =

vtkSmartPointer<vtkInteractorStyleSwitch>::New();

ir->SetInteractorStyle(style); //main里面没有这个会报错

自己写的callback里面:

if(XX){

vtkInteractorStyleSwitch::SafeDownCast(

iren->GetInteractorStyle())->SetCurrentStyleToTrackballCamera();

}

else

{

vtkInteractorStyleSwitch::SafeDownCast(

iren->GetInteractorStyle())->SetCurrentStyleToTrackballActor();

}

这样就可以自己切换交互模式了