我正在使用VTK制作一个线程软件,需要在实时更新模型本身的同时更改其渲染方式。一切都正常运作,但是问题出现在
我需要类似这样的东西:
我成功让窗口关闭了,但只能使用
我处理VTK的方式是使用两个线程,第一个线程只和vtk iren循环有关,第二个线程则处理模型并检查iren是否需要更新。
在我的理想代码中,应该是这样的:
=======================================================
interactor->start();
,模型数据得到了很好的更新,但只有当我移动摄像头时才会在屏幕上显示。此外,我选择了一些从imagedata文件生成3D数据的方法,为此需要关闭vtk窗口(交互式窗口),然后代码将重新打开它并将新生成的数据发送给它...。我需要类似这样的东西:
int force close_window = false; int refresh_interactor = false;
我成功让窗口关闭了,但只能使用
vtkcommand :: Keypressed
命令,但我不知道如何使用新命令:S,我尝试过vtkcommand :: UserEvent
,但我没有找到任何有关如何处理该数据的好信息(如一些调用它的方法)。我处理VTK的方式是使用两个线程,第一个线程只和vtk iren循环有关,第二个线程则处理模型并检查iren是否需要更新。
在我的理想代码中,应该是这样的:
=======================================================
bool VTKWindow()
{
...
vtkSmartPointer ator = vtkSmartPointer::New();
iren = vtkSmartPointer::New();
RenWindow = vtkSmartPointer::New();
render->SetBackground(.1, .2, .3);
RenWindow->AddRenderer(renderer);
iren->SetRenderWindow(RenWindow);
if(data_type == voxel_type)
{
Render->AddViewProp(VoxelData);
}
else
{
actor->SetMapper(PolyData);
Render->AddActor(Actor);
}
RenWindow->Render();
iren->Start();
}
void ManageVTK()
{
while true loop...
if(force close_window == true)
do some command to exit the iren loop
if(refresh_interactor == true)
do some command to refresh iren
}
抱歉我的母语不是英语,对于问题的格式还请见谅,这是我第一次使用stackoverflow
vtkCommand::TimerEvent
作为触发观察者的事件。创建新事件的正确方法是使用vtkCommand::UserEvent + intShift
,其中 intShift 是一个整数,可以允许创建更多的新事件。可以通过更新 vtkAllEventsMacro 来注册这些新事件。在这个示例中,文件 vtkTestFilter.h 显示了如何创建一个未注册的新事件。 - gallo