医学开源项目Paraview学习-------体绘制中的旋转事件

ParaView是对二维和三维数据进行分析和可视化的程序,它既是一个应用程序框架,也可以直接使用(Turn-Key)。ParaView支持并行,可以运行于单处理器的工作站,也可以运行于分布式存储器的大型计算机。 ParaView用C++编写,基于VTK(Visualization ToolKit)开发,图形用户界面用Qt开发,开源、跨平台。ParaView用户可以迅速的建立起可视化环境利用定量或者是定性的手段去分析数据。利用它的批量处理能力可以在三维或者是在报表中交互进行“数据挖掘”。

最近研究Paraview开源项目,一直想把整个架构搞清楚,苦于能力,目前还只能读懂其中一部分,先作一下记录:

QVTKOpenGLNativeWidget(父类QOpenGLWidget,Qt中的类)::mouseMoveEvent(QMouseEvent)---->QVTKInteractorAdapter::ProcessEvent(QEvent* e,vtkRenderWindowInteractor* iren){
iren->InvokeEvent(vtkCommand::MouseMoveEvent e2) //通过iren::InvokeEvent函数
}
————————>vtkObject::InvokeEvent(unsigned long event, void* callData);{
SubjectHelper->InvokeEvent(event, callData, this); //通过SubjectHelper函数
}

------->vtkCallbackCommand::Execute(vtkObject* caller, unsigned long event){
this->Callback(caller,event, this->ClientData, callData);
}

------->vtkInteractorStyle::processEvents(vtkObject*, unsigned long event, void* ClientData, void* calldata){
    self->OnMouseMove();//通过此函数调用到下一个类
}

------>vtkPVInteractorStyle::vtkInteractorStyleTrackballcamera
{
    CurrentManipulator->onMouseMOve();
}

------>vtkPVTrackballRotate::OnMouseMove(x, y, vtkRender* ren, vtkRenderWindowInteractor rwi)
{
    rwi->Render()
}

------>vtkRenderWindowInteractor::Render()
{
    this->InvokeEvent(vtkCommand::RenderEvent, nullptr);
}

------>vtkObject::InvokeEvent(unsigned long event, void* calldata)
{
    SubjectHelper->InvokeEvent(event, calldata, this);
}

------>vtkSubjectHelper::InvokEvent(event, calldata, self)
{
    elem->Command->execute(self,event, calldata);
}

----->vtkMemberFunctionCommand : public vtkCommand
(vtkMemberFunctionCommand是一个模板类)
{
    this->Object->*this->Method2(caller, event, calldata)
}

----->vtkSMViewProxyInteractorHelper::Execute(caller, event, calldata)
{
    this->Render();
}

----->vtkSMViewProxyInteractorHelper::Render()
{
    this->ViewProxy->InteractiveRender();
}

----->vtkSMViewProxy::InteractiveRender()
//vtkSMViewProx继承自vtkSMProxy继承自vtkSMRemoteObject继承自vtkSessionObject继承自//vtkSMObject继承自vtkObject
{
    this->ExecuteStream(stream,false,render_location);
}

------>vtkPVSessionBase::ExecuteStream(location, stream, ignore_errors)
//vtkPVSessionBase继承自vtkPVSession继承自vtkSession
{
    thhis->SessionCore->ExecuteStream(location, stream, ignore_errors);
}

----->vtkPVSessionCore::ExecuteStream()
{
    this->ExecuteStreamInternal(stream,ignore_errors);
}

----->vtkPVSessionCore::ExecuteStreamInternal(stream, ignore_errors)
{
    this->interpreter->ProcessStream(Stream);
}

---->vtkClientServerInterpreter::ProcessStream(css)
{
    this->ProcessOneMessage(css,i)
}

----->vtkClientServerInterpreter::ProcessOneMessage()
{
    this->ProcessCommandInvoke(css, message);
}

-----vtkClientServerInterpreter::ProcessCommandInvoke(obj->GetClassName(),obj,method,msg,void*)
{
    vtkClientServerCommandFunction Function = n->Function;
}

------>vtkPVRenderViewCommand()
{
    cp->InteractiveRender(); //strcmp("InteractiveRender", method);
}

------>vtkPVRenderView::InteractiveRender()

------>vtkPVRenderView::Render(interactive,skip_rendering)
{
    GetRenderWindow->Render();
}

------>vtkGenericOPenGLRenderingWindow::Render()
//vtkGenericOpenGLRenderingWindow继承自vtkRenderWindow
{
    this->SuperClass::Render();
}

------>vtkRenderingWindow::Render()

------>vtkRenderingWindow::DoStereoRender()
{
    this->Renderers->Render();
}

----->vtkRendererCollection::Render()
//vtkRendererCollection继承自vtkCollection继承自vtkObject
{
    ren->Renderer();
}

----->vtkRenderer::Render(void)
//vtkRenderer继承自vtkViewport
{
    this->DeviceRender();
}

----->vtkOpenGLRender::DeviceRender(void)
{
    this->Pass->Render(&s); //Pass是vtkRenderPass的实例
}


----->vtkCameraPass::Render(const vtkRenderState *s)
{
    this->DelegatePass->Render();
}

----->vtkPVDefaultPass::Render(const vtkRenderState* render_state)


----->vtkPVDefaultPass::UpdateGeometry(renderer)
{
    Renderer->UpdateGeometry();
}

----->vtkOpenGLRenderer::UpdateGeometry()
{
    this->NumberOfPnpsRendered += this->PropArray[i]->RenderVolumetricGeometry(this)
}

----->vtkPVLODVolume::RenderVolumetricGeometry(VP)
//vtkPVLODVolume继承自vtkVolume继承自vtkProp3D继承自vtkProp继承自vtkObject
{
    this->LODProp->RenderVolumetricGeometry(VP);
}


------>vtkLODProp3D::RenderVolumetricGeometry(viewport)
{
    retVal = this->LODs[this->SelectedLODIndex].Prop3D->RenderVolumetricGeometry()
}

------>vtkVolume::RenderVolumetricGeometry(vp)
{
    this->Mapper->Render(static(vp), this);
}

----->vtkSmartVolumeMapper::Render(vtkRender *ren, vtkVolume* vol)
//vtkSmartVolumeMapper继承自vtkVolumeMapper继承自vtkAbstractVolumeMapper继承自//vtkAbstractMapper3D继承自vtkAbstractMapper
{
    useMapper->Render(ren, vol);
}

----->vtkGPUVolumeRayCastMapper::Render(vtkRendere *ren, vtkVolume *vol)
{
    this->GPURender(ren,vol);
}

------>vtkOpenGLGPUVolumeRayCastMapper::GPURener(ren, vol)

------>vtkOpenGLGPUVolumeRayCastMapper::DoGpuRender(ren,shaderPragram)

------>vtkOpenGLGpuRayCastMapper::DoGPURender(ren, cam, prog)
{
    this->Impl->RenderSingleInput(ren,cam, prop);
}

------>vtkOpenGLGPUVolumeRayCastMapper::vtkInternal::RenderSingleInput()
{
    this->RenderVolumeGeometry(ren, prop,vol, block->LooderBounds);
}

----->vtkOpenGLGPUVolumeRayCastMapper::vtkInternal::RenderVolumeGeometry()

---->glDrawElements();




特别关注:
1,vtkClientServerInterpreter::AddCommandFunction(const char* cname, vtkClientServer, CommandFunction fun, void* ctx, vtkContextFreeFunction freeFunction)函数中 this->Internal->ClassToFunctionMap[cname] = new vtkClientServerInterpreterInternals::CommandFunction(func, context);

2, vtkCallbackCommand::Execute(vtkObject * caller, unsigned long event, void* calldata)

3, vtkQtConnection::DoCallback(vtkObject* vtk_obj, unsigned long event, void* client_data, void* call_data)
{
    vtkQtConnection* conn = static_cast (client_data);
    conn->execute(vtk_obj, event, call_data);
}

整个过程的调用堆栈大致如此,后续陆续推出相关文章。。。。

 

 

你可能感兴趣的:(ParaView三维医学建模)