ParaView-2

对于paraview的编译就不再多说,直接cmake 有个别注意的地方,网上这方面的资料很多这里不做熬述。打开源码,发现有很多文件和文件夹,代码量很大。

从例子中得pqPipelineApp看起,main函数中得的

pqApplicationCore

这是paraview的关键类,

/// This class is the crux of the ParaView application. It creates

/// and manages various managers which are necessary for the ParaView-based

/// client to work with the ServerManager.

/// For clients based of the pqCore library,

/// simply instantiate this pqApplicationCore after QApplication initialization

/// and then create your main window etc. like a standard Qt application. You can then

/// use the facilities provided by pqCore such as the pqObjectBuilder,

/// pqUndoStack etc. in your application. After that point.

在QApplication初始化后初始化,然后就可以创建mainwindow

 

然后到MainPipeineWindow,构造函数中,首先要做的是初始化Paraview,这个很重要,首先声明并初始化pqApplictionCore,

然后就是pqObjectBuilder

/// pqObjectBuilder is loosely based on the \c Builder design pattern.

/// It is used to create as well as destroy complex objects such as

/// views, displays, sources etc. Since most of the public API is

/// virtual, it is possible for custom applications to subclass

/// pqObjectBuilder to provide their own implementation for creation/

/// destroying these objects. The application layer accesses the

/// ObjectBuilder through the pqApplicationCore singleton.

/// NOTE: pqObjectBuilder replaces the previously supported

/// pqPipelineBuilder. Unlink, pqPipelineBuilder, this class

/// no longer deals with undo/redo stack. The application layer

/// components that use the ObjectBuilder are supposed to bother

/// about the undo stack i.e. call begin/end on the undo stack

/// before/after calling creation/destruction method on the ObjectBuilder.

它是基于C的设计模式,它的作用是创建或者销毁views displays sources 等。因为大部分的公共API是虚函数。对于自定义应用程序可以生成子类,从而实现自定义的执行。应用程序通过pqApplication访问pqObejectBuilder。

pqInterfaceTracker

/// pqInterfaceTracker is used by ParaView components to locate

 

/// interface-implementations. These implementations can be either those loaded

/// from plugins or registered explicitly using addInterface/removeInterface API.

/// In previous versions of ParaView, this role was performed by the

/// pqPluginManager class itself.

pqInterfaceTracker以组件调用,接口的实现可用插件或者显示的添加接口/移除接口 API 以前版本都是有pqPluginManager类实现

一下的代码就很简单了

// Set Filter selector

设置Filter/Annotation list

// Set Pipeline Widget

设置管道窗口

// Create server only after a pipeline browser get created...

只能在管线浏览器被创建以后,然后创建服务器

// Init and layout the UI

初始化或创建UI

  // Create a complex pipeline with different annotations

void MainPipelineWindow::createPipelineWithAnnotation(pqServer* server)

{

  pqApplicationCore* core = pqApplicationCore::instance();

  pqObjectBuilder* ob = core->getObjectBuilder();

 

  // create source and elevation filter

  pqPipelineSource* wavelet;

  pqPipelineSource* cone;

  pqPipelineSource* clip1;

  pqPipelineSource* clip2;

  pqPipelineSource* append;

  pqPipelineSource* groupDS;

 

  wavelet = ob->createSource("sources", "RTAnalyticSource", server);

  vtkSMSourceProxy::SafeDownCast(wavelet->getProxy())->UpdatePipeline();

 

  clip1 = ob->createFilter("filters", "Clip", wavelet);

  vtkSMSourceProxy::SafeDownCast(clip1->getProxy())->UpdatePipeline();

 

  clip2 = ob->createFilter("filters", "Clip", clip1);

  vtkSMSourceProxy::SafeDownCast(clip2->getProxy())->UpdatePipeline();

 

  cone = ob->createSource("sources", "ConeSource", server);

  vtkSMSourceProxy::SafeDownCast(cone->getProxy())->UpdatePipeline();

 

  append = ob->createFilter("filters", "Append", clip2);

  vtkSMPropertyHelper(append->getProxy(), "Input").Add(cone->getProxy(), 0);

  vtkSMSourceProxy::SafeDownCast(append->getProxy())->UpdatePipeline();

 

  groupDS = ob->createFilter("filters", "GroupDataSets", clip2);

  vtkSMPropertyHelper(groupDS->getProxy(), "Input").Add(cone->getProxy(), 0);

  vtkSMSourceProxy::SafeDownCast(groupDS->getProxy())->UpdatePipeline();

 

  // Setup annotations:

  wavelet->getProxy()->SetAnnotation(this->FilterNames.at(1).toAscii().data(), "-");

  clip1->getProxy()->SetAnnotation(this->FilterNames.at(1).toAscii().data(), "-");

  clip2->getProxy()->SetAnnotation(this->FilterNames.at(1).toAscii().data(), "-");

 

  append->getProxy()->SetAnnotation(this->FilterNames.at(2).toAscii().data(), "-");

  groupDS->getProxy()->SetAnnotation(this->FilterNames.at(2).toAscii().data(), "-");

 

  wavelet->getProxy()->SetAnnotation(this->FilterNames.at(3).toAscii().data(), "-");

  clip1->getProxy()->SetAnnotation(this->FilterNames.at(3).toAscii().data(), "-");

  clip2->getProxy()->SetAnnotation(this->FilterNames.at(3).toAscii().data(), "-");

  append->getProxy()->SetAnnotation(this->FilterNames.at(3).toAscii().data(), "-");

 

  wavelet->getProxy()->SetAnnotation(this->FilterNames.at(4).toAscii().data(), "-");

  cone->getProxy()->SetAnnotation(this->FilterNames.at(4).toAscii().data(), "-");

 

  // Tooltip

  wavelet->getProxy()->SetAnnotation("tooltip", "1+3+4");

  clip1->getProxy()->SetAnnotation("tooltip", "1+3");

  clip2->getProxy()->SetAnnotation("tooltip", "1+3");

  cone->getProxy()->SetAnnotation("tooltip", "4");

  append->getProxy()->SetAnnotation("tooltip", "2+3");

  groupDS->getProxy()->SetAnnotation("tooltip", "2");

}

通过这个例子,大致了解paraview的思想,主要有pqApplicationCore(核心)pqObjectBuilder(对象 view sources 等删除创建)、pqInterfaceTracker(插件以及接口。。。)…

你可能感兴趣的:(ParaView)