之前的几篇学习笔记,讲了关于Render的事情,详细叙述了在Paraview中的一个从前端Python到后台vtk库的一个渲染调用的过程。下面我们来看一下数据的事情。
首先我们来看在之前提高过的simple.py中的Show():
def Show(proxy=None, view=None, **params):
"""Turns the visibility of a given pipeline object on in the given view.
If pipeline object and/or view are not specified, active objects are used."""
if proxy == None:
proxy = GetActiveSource()
if proxy == None:
raise RuntimeError, "Show() needs a proxy argument or that an active source is set."
if not view:
# it here's now active view, controller.Show() will create a new preferred view.
# if possible.
view = active_objects.view
controller = servermanager.ParaViewPipelineController()
rep = controller.Show(proxy, proxy.Port, view)
if rep == None:
raise RuntimeError, "Could not create a representation object for proxy %s" % proxy.GetXMLLabel()
for param in params.keys():
setattr(rep, param, params[param])
return rep
在这段代码中,controller=servermanager.ParaViewPipelineController():
class ParaViewPipelineController(object):
"""ParaViewPipelineController wraps vtkSMParaViewPipelineController class
to manage conversion of arguments passed around from Pyhton Proxy objects to
vtkSMProxy instances are vice-versa."""
def __init__(self):
"""Constructor. Creates a new instance of
vtkSMParaViewPipelineController."""
self.SMController = vtkSMParaViewPipelineController()
可以看到他的构造函数,是调用了vtkSMParaViewPiplineController()这个类的构造函数,所以controller就是一个vtkSMParaViewPiplineController类的一个对象。但是不知道为什么在这个类中根本找不到这个方法Show。这有一点走不通,下面我们来看与它有相似意义的一段函数:
def CreateRepresentation(aProxy, view, **extraArgs):
"""Creates a representation for the proxy and adds it to the render
module.
This method can also be used to initialize properties by passing
keyword arguments where the key is the name of the property.In addition
registrationGroup and registrationName (op