百度和google以后,发现自己很孤单,只有自己在研究paraview源码,以下只为后来人和自己有共同兴趣爱好的人共勉之。qq:569979266.lost&last
如果你对paraview的架构毫无头绪,建议你可以将pqPipelineApp设为启动项,然后逐步跟踪
![](http://s14.sinaimg.cn/middle/84181a794cef7cb0ab7fd&690)
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。