paraview源码分析 和源码跟踪

百度和google以后,发现自己很孤单,只有自己在研究paraview源码,以下只为后来人和自己有共同兴趣爱好的人共勉之。qq:569979266.lost&last

如果你对paraview的架构毫无头绪,建议你可以将pqPipelineApp设为启动项,然后逐步跟踪

ob->createFilter("filters", "Clip", wavelet);
  /// Called when the action is triggered.

  virtual void onTriggered(const QString& group, const QString& name)
    { pqSourcesMenuReaction::createSource(group, name); }

QObject::connect(
    menuManager, SIGNAL(triggered(const QString&, const QString&)),
    this, SLOT(onTriggered(const QString&, const QString&)));

pqSourcesMenuReaction

void pqParaViewMenuBuilders::buildSourcesMenu(QMenu&  menu,

void pqObjectInspectorWidget::accept()

void pqObjectPanel::accept()

void pqProxy::setModifiedState(ModifiedState modified)

QObject::connect(this->CurrentPanel->referenceProxy(),
      SIGNAL(modifiedStateChanged(pqServerManagerModelItem*)),
      this, SLOT(updateAcceptState()));

//-----------------------------------------------------------------------------
void pqObjectInspectorWidget::updateAcceptState()

//-----------------------------------------------------------------------------
void pqObjectInspectorWidget::canAccept(bool status)

this->connect(this->AcceptButton,
                  SIGNAL(clicked()),
                  applyPropertiesManager,
                  SLOT(applyProperties())); 绑定apply按钮一个事件 applyProperties()按下执行

void pqApplyPropertiesManager::applyProperties()

this->connect(applyPropertiesManager, 继续执行 accept()
                  SIGNAL(apply()),
                  this,
                  SLOT(accept()));

//-----------------------------------------------------------------------------
void pqPipelineFilter::hideInputIfRequired(pqView* view)

//-----------------------------------------------------------------------------
void pqObjectInspectorWidget::show(pqPipelineSource* source)

//-----------------------------------------------------------------------------
void pqObjectInspectorWidget::accept()

//-----------------------------------------------------------------------------
/// accept the changes made to the properties
/// changes will be propogated down to the server manager
void pqProxyPanel::accept()
{


//-----------------------------------------------------------------------------
void pqPropertyManager::accept()
{

vtkSMProxy* vtkSMSessionProxyManager::NewProxy(vtkPVXMLElement* pelement,
                                        const char* groupname,
                                        const char* proxyname,
                                        const char* subProxyName)
{

object = vtkInstantiator::CreateInstance(cname.str().c_str());


//----------------------------------------------------------------------------
vtkObject* vtkInstantiator::CreateInstance(const char* className)
{
  CreateFunction function = vtkInstantiator::CreatorTable->Find(className);  函数指针
  if(function) { return function(); }
  return 0;
}

vtkInstantiator::RegisterInstantiator("vtkCutter", vtkInstantiatorvtkCutterNew);注册 函数指针
这样调用的时候可以直接通过类名,调用new 函数

vtkClientServerStream

UpdateVTKObjects

UpdateVTKObjects

vtkClientServerInterpreter


//-----------------------------------------------------------------------------
pqPipelineSource* pqObjectBuilder::createFilter(
  const QString& group, const QString& name,
  QMap<QString, QList<pqOutputPort*> > namedInputs,
  pqServer* server,
  const QMap<QString, QVariant>& properties)


pqSMAdaptor::addInputProperty(prop, opPort->getSource()->getProxy(),
        opPort->getPortNumber());

this->Interpreter->ProcessStream(stream);

//----------------------------------------------------------------------------
bool vtkSIProxy::CreateVTKObjects(vtkSMMessage* message)
{

vtkMultiBlockDataSet::SafeDownCast(


static vtkSMInputProperty* getInputProperty(vtkSMProxy* proxy)

//-----------------------------------------------------------------------------
void pqSMAdaptor::setInputProperty(vtkSMProperty* Property,
                                   pqSMProxy Value, int opport)

->GetProperty("Input")

pqSMAdaptor::addInputProperty(

//---------------------------------------------------------------------------
void vtkSMProxy::AddProperty(const char* name, vtkSMProperty* prop)

  vtkSMProxyObserver* obs = vtkSMProxyObserver::New();

virtual void Execute(vtkObject* obj, unsigned long event, void* data)

//-----------------------------------------------------------------------------
void MainPipelineWindow::createPipelineWithAnnotation(pqServer* server)


vtkPVXMLElement* element = this->GetProxyElement( groupName, proxyName,
                                                    subProxyName);  传一个关键字 返回一个类型
element->GetAttribute("class")


// Not found in the cache, look if the definition exists
  vtkPVXMLElement* originalDefinition =
      this->GetProxyDefinition(group, name, throwError);

加载算法 和 数据源 用了个xml 恶心
this->Internals->CoreDefinitions[groupName][proxyName] = element;

//---------------------------------------------------------------------------
bool vtkSIProxyDefinitionManager::LoadConfigurationXML(vtkPVXMLElement* root, bool attachHints)

//---------------------------------------------------------------------------
bool vtkSIProxyDefinitionManager::LoadConfigurationXML(vtkPVXMLElement* root)

vtkParaViewIncludeModulesToSMApplication.h 文件中有
init_string =  vtkSMDefaultModulesfiltersGetInterfaces();
  parser_ret = parser->Parse(init_string);
  assert(parser_ret != 0);
this->LoadConfigurationXML(parser->GetRootElement());

vtkSMGeneratedModules.h 文件中有
// Get single string
char* vtkSMDefaultModulesfiltersGetInterfaces()
{
  size_t len = ( 0
    + strlen(vtkSMDefaultModulesfiltersInterface0)
    + strlen(vtkSMDefaultModulesfiltersInterface1)
    + strlen(vtkSMDefaultModulesfiltersInterface2)
    + strlen(vtkSMDefaultModulesfiltersInterface3)
    + strlen(vtkSMDefaultModulesfiltersInterface4)
    + strlen(vtkSMDefaultModulesfiltersInterface5)
    + strlen(vtkSMDefaultModulesfiltersInterface6)
    + strlen(vtkSMDefaultModulesfiltersInterface7)
    + strlen(vtkSMDefaultModulesfiltersInterface8)
    + strlen(vtkSMDefaultModulesfiltersInterface9)
    + strlen(vtkSMDefaultModulesfiltersInterface10)
    + strlen(vtkSMDefaultModulesfiltersInterface11)
    + strlen(vtkSMDefaultModulesfiltersInterface12)
    + strlen(vtkSMDefaultModulesfiltersInterface13)
    + strlen(vtkSMDefaultModulesfiltersInterface14)
    + strlen(vtkSMDefaultModulesfiltersInterface15)
    + strlen(vtkSMDefaultModulesfiltersInterface16)
    + strlen(vtkSMDefaultModulesfiltersInterface17)
    + strlen(vtkSMDefaultModulesfiltersInterface18)
    + strlen(vtkSMDefaultModulesfiltersInterface19)
    + strlen(vtkSMDefaultModulesfiltersInterface20)
    + strlen(vtkSMDefaultModulesfiltersInterface21)
    + strlen(vtkSMDefaultModulesfiltersInterface22)
    + strlen(vtkSMDefaultModulesfiltersInterface23)
    + strlen(vtkSMDefaultModulesfiltersInterface24)
    + strlen(vtkSMDefaultModulesfiltersInterface25)
    + strlen(vtkSMDefaultModulesfiltersInterface26)
    + strlen(vtkSMDefaultModulesfiltersInterface27)
    + strlen(vtkSMDefaultModulesfiltersInterface28)
    + strlen(vtkSMDefaultModulesfiltersInterface29)
    + strlen(vtkSMDefaultModulesfiltersInterface30)
    + strlen(vtkSMDefaultModulesfiltersInterface31) );
  char* res = new char[ len + 1];
  res[0] = 0;
  strcat(res, vtkSMDefaultModulesfiltersInterface0);
  strcat(res, vtkSMDefaultModulesfiltersInterface1);
  strcat(res, vtkSMDefaultModulesfiltersInterface2);
  strcat(res, vtkSMDefaultModulesfiltersInterface3);
  strcat(res, vtkSMDefaultModulesfiltersInterface4);
  strcat(res, vtkSMDefaultModulesfiltersInterface5);
  strcat(res, vtkSMDefaultModulesfiltersInterface6);
  strcat(res, vtkSMDefaultModulesfiltersInterface7);
  strcat(res, vtkSMDefaultModulesfiltersInterface8);
  strcat(res, vtkSMDefaultModulesfiltersInterface9);
  strcat(res, vtkSMDefaultModulesfiltersInterface10);
  strcat(res, vtkSMDefaultModulesfiltersInterface11);
  strcat(res, vtkSMDefaultModulesfiltersInterface12);
  strcat(res, vtkSMDefaultModulesfiltersInterface13);
  strcat(res, vtkSMDefaultModulesfiltersInterface14);
  strcat(res, vtkSMDefaultModulesfiltersInterface15);
  strcat(res, vtkSMDefaultModulesfiltersInterface16);
  strcat(res, vtkSMDefaultModulesfiltersInterface17);
  strcat(res, vtkSMDefaultModulesfiltersInterface18);
  strcat(res, vtkSMDefaultModulesfiltersInterface19);
  strcat(res, vtkSMDefaultModulesfiltersInterface20);
  strcat(res, vtkSMDefaultModulesfiltersInterface21);
  strcat(res, vtkSMDefaultModulesfiltersInterface22);
  strcat(res, vtkSMDefaultModulesfiltersInterface23);
  strcat(res, vtkSMDefaultModulesfiltersInterface24);
  strcat(res, vtkSMDefaultModulesfiltersInterface25);
  strcat(res, vtkSMDefaultModulesfiltersInterface26);
  strcat(res, vtkSMDefaultModulesfiltersInterface27);
  strcat(res, vtkSMDefaultModulesfiltersInterface28);
  strcat(res, vtkSMDefaultModulesfiltersInterface29);
  strcat(res, vtkSMDefaultModulesfiltersInterface30);
  strcat(res, vtkSMDefaultModulesfiltersInterface31);
  return res;
}


  <!-- ==================================================================== -->\n"
  <SourceProxy name="Cut" class="vtkCutter" label="Slice">\n"
   <Documentation\n"
      long_help="This filter slices a data set with a plane. Slicing is similar to a contour. It creates surfaces from volumes and lines from surfaces."\n"
      short_help="Slice datasets with planes.">\n"
"This filter extracts the portion of the input dataset that lies along the specified plane. The Slice filter takes any type of dataset as input. The output of this filter is polygonal data.\n"
   </Documentation>\n"
   <InputProperty\n"
      name="Input"\n"
      command="SetInputConnection">\n"
"   <ProxyGroupDomain name="groups">\n"
"     <Group name="sources"/>\n"
"     <Group name="filters"/>\n"
"   </ProxyGroupDomain>\n"
"   <DataTypeDomain name="input_type">\n"
"     <DataType value="vtkDataSet"/>\n"
"   </DataTypeDomain>\n"
"   <Documentation>\n"
"     This property specifies the input to the Slice filter.\n"
"   </Documentation>\n"
    </InputProperty>\n"
"\n"
    <ProxyProperty name="CutFunction" command="SetCutFunction"\n"
" label="Slice Type">\n"
"    <ProxyGroupDomain name="groups">\n"
"       <Group name="implicit_functions"/>\n"
"    </ProxyGroupDomain>\n"
"    <ProxyListDomain name="proxy_list">\n"
"       <Proxy group="implicit_functions" name="Plane" />\n"
"       <Proxy group="implicit_functions" name="Box" />\n"
"       <Proxy group="implicit_functions" name="Sphere" />\n"
"    </ProxyListDomain>\n"
"    <Documentation>\n"
"      This property sets the parameters of the slice function.\n"
"    </Documentation>\n"
    </ProxyProperty>\n"
"\n"
    <DoubleVectorProperty\n"
" name="InputBounds" information_only="1">\n"
      <BoundsDomain name="bounds">\n"
" <RequiredProperties>\n"
"     <Property name="Input" function="Input"/>\n"
" </RequiredProperties>\n"
      </BoundsDomain>\n"
    </DoubleVectorProperty>\n"
"\n"
    <DoubleVectorProperty\n"
" name="ContourValues"\n"
" command="SetValue"\n"
" repeat_command="1"\n"
" set_number_command="SetNumberOfContours"\n"
" number_of_elements_per_command="1"\n"
" use_index="1"\n"
" animateable="1"\n"
" label="Slice Offset Values">\n"
"   <BoundsDomain name="bounds" mode="magnitude">\n"
"     <RequiredProperties>\n"
"       <Property name="Input" function="Input"/>\n"
"     </RequiredProperties>\n"
"   </BoundsDomain>\n"
"   <Documentation>\n"
"     The values in this property specify a list of current offset values. This can be used to create multiple slices with different centers. Each entry represents a new slice with its center shifted by the offset value.\n"
"   </Documentation>\n"
    </DoubleVectorProperty>\n"
    <Hints>\n"
      <Visibility replace_input="2" />\n"
    </Hints>\n"
  <!-- End Cut -->\n"
  </SourceProxy>\n"
"\n"


stream << vtkClientServerStream::Invoke
           << this->SIProxyObject
           << "AddInput"
           << this->PortIndex
           << input_connection
           << this->GetCommand()
           << vtkClientServerStream::End;



// Deal with proxy to add
  for (vtkstd::set<vtkTypeUInt32>::iterator iter = to_add.begin();
      iter != to_add.end(); ++iter)
    {
    vtkObjectBase* arg = this->GetObjectBase(*iter);
    if(arg != NULL || this->IsValidNull(*iter))
      {
      stream << vtkClientServerStream::Invoke
             << object
             << this->GetCommand()
             << arg
             << vtkClientServerStream::End;

      // we keep an object cache so that even if the object gets unregistered
      // before the property is pushed, we have a reference to it.
      (*this->ObjectCache)[*iter] = arg;
      }
    else
      {
      vtkWarningMacro("Try to ADD a Proxy to a ProxyProperty but the proxy was not found");
      }
    }


// Write to message because vtkSMProperty do not have state
            property->WriteTo(&message);

vtkAlgorithm* algo = vtkAlgorithm::SafeDownCast(this->GetVTKObject());

this->Internals->OutputPorts[port] = algo->GetOutputPort(port);

const char* className = element->GetAttribute("class");
  if (className && className[0])
    {
    this->SetVTKClassName(className);
    vtkObjectBase* obj = this->Interpreter->NewInstance(className);


  this->VTKObject.TakeReference(obj);


最终结果 查到 那加载ex2文件 是vtkExodusIIReader 类,继承于vtkMultiBlockDataSetAlgorithm
现在要弄懂怎么写一个类 也继承于vtkMultiBlockDataSetAlgorithm。


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
ParaView是一个开源的可视化数据分析和处理软件,其源代码托管在GitHub上。要梳理ParaView的源代码,可以按照以下步骤进行: 1. 获取源代码:首先,您需要从ParaView的GitHub仓库中获取源代码。您可以使用Git工具克隆仓库或直接下载源代码的压缩包。ParaView的GitHub仓库链接为:https://github.com/Kitware/ParaView 2. 了解项目结构:解压源代码后,您可以浏览项目的目录结构。ParaView的源代码包含许多子模块和依赖项,其中主要的模块包括`VTK`(Visualization Toolkit)和`ParaViewCore`。`VTK`是ParaView所依赖的可视化工具包,而`ParaViewCore`则是ParaView的核心功能模块。 3. 阅读文档:ParaView提供了详细的开发者文档,可以帮助您理解项目的结构和各个模块的功能。您可以在ParaView官方网站上找到文档,其中包括ParaView用户指南、开发人员指南、API文档等。 4. 浏览源代码:通过浏览源代码,了解各个模块和类的实现细节。可以从`ParaViewCore`模块开始,深入研究ParaView的核心功能实现。也可以查看与特定功能相关的模块,例如与数据读取、可视化、过滤器、插件等相关的模块。 5. 调试和实验:如果您对特定功能或模块感兴趣,可以在代码中进行调试和实验。可以使用集成开发环境(IDE)来设置断点、观察变量值,并逐步执行代码,以便更好地理解代码的执行流程和数据处理过程。 6. 参考示例和扩展:ParaView的源代码中包含许多示例和扩展,可以帮助您更好地理解代码。可以查看ParaView的示例代码和插件,了解如何使用ParaView的API和数据结构。 请注意,ParaView的源代码庞大且复杂,需要一定的时间和耐心来理解。建议在梳理源代码之前具备一定的C++编程和可视化数据处理的基础知识。同时,参考官方文档和与ParaView社区的交流可以帮助您更好地理解和使用ParaView的源代码。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值