目录
QList pqLoadDataReaction::loadData()*>
readerFactory->GetSupportedFileTypes(server->session())
bool CanCreatePrototype(vtkSMSession* session)
void FillInformation(vtkSMSession* session)
pqPipelineSource* pqLoadDataReaction::LoadFile
loadFile第十行:addDataFilesToRecentResources函数
pqPipelineSource : public pqProxy
打开文件操作
打开文件操作actionFileOpen()流程图
图:打开文件操作流程图
打开文件操作流程图中比较核心的工作是pqLoadDataReaction::loadData(),下面是pqLoadDataReaction::loadData()流程图
图:pqLoadDataReaction_loadData流程图
QList<pqPipelineSource*> pqLoadDataReaction::loadData()
QList<pqPipelineSource*> pqLoadDataReaction::loadData()
{
pqServer* server = pqActiveObjects::instance().activeServer();
vtkSMReaderFactory* readerFactory = vtkSMProxyManager::GetProxyManager()->GetReaderFactory();
QString filters = readerFactory->GetSupportedFileTypes(server->session());
// insert "All Files(*)" as the second item after supported files.
int insertIndex = filters.indexOf(";;");
if (insertIndex >= 0)
{
filters.insert(insertIndex, ";;All Files (*)");
}
else
{
assert(filters.isEmpty());
filters = "All Files (*)";
}
pqFileDialog fileDialog(
server, pqCoreUtilities::mainWidget(), tr("Open File:"), QString(), filters);
fileDialog.setObjectName("FileOpenDialog");
fileDialog.setFileMode(pqFileDialog::ExistingFilesAndDirectories);
QList<pqPipelineSource*> sources;
if (fileDialog.exec() == QDialog::Accepted)
{
QList<QStringList> files = fileDialog.getAllSelectedFiles();
pqPipelineSource* source = pqLoadDataReaction::loadData(files);
if (source)
{
sources << source;
}
}
return sources;
}
readerFactory->GetSupportedFileTypes(server->session())
const char* vtkSMReaderFactory::GetSupportedFileTypes(vtkSMSession* session)
const char* vtkSMReaderFactory::GetSupportedFileTypes(vtkSMSession* session)
{
std::ostringstream all_types;
all_types << "Supported Files (";
auto case_insensitive_comp = [](const std::string& s1, const std::string& s2) {
return vtksys::SystemTools::Strucmp(s1.c_str(), s2.c_str()) < 0;
};
std::set<std::string, decltype(case_insensitive_comp)> sorted_types(case_insensitive_comp);
for (auto& proto : this->Internals->Prototypes)
{
if (proto.second.CanCreatePrototype(session))
{
proto.second.FillInformation(session);
for (auto& hint : proto.second.FileEntryHints)
{
std::string ext_list;
if (!hint.Extensions.empty())
{
ext_list = ::vtkJoin(hint.Extensions, "*.", " ");
}
if (!hint.FilenameRegExs.empty())
{
std::string ext_join = ::vtkJoin(hint.FilenamePatterns, "", " ");
if (!ext_list.empty())
{
ext_list += " ";
ext_list += ext_join;
}
else
{
ext_list = ext_join;
}
}
if (!ext_list.empty())
{
std::ostringstream stream;
stream << hint.Description << " (" << ext_list << ")";
sorted_types.insert(stream.str());
all_types << ext_list << " ";
}
}
}
}
all_types << ")";
for (const auto& types : sorted_types)
{
all_types << ";;" << types;
}
this->Internals->SupportedFileTypes = all_types.str();
return this->Internals->SupportedFileTypes.c_str();
}
Internals->Prototypes
设置prototypes,vtkSMProxyManager();
bool CanCreatePrototype(vtkSMSession* session)
Returns true is a prototype proxy can be created on the given connection.
void FillInformation(vtkSMSession* session)
图 pqServerConfiguration
pqPipelineSource* pqLoadDataReaction::LoadFile
pqPipelineSource* pqLoadDataReaction::LoadFile(
const QStringList& files, pqServer* server, const QPair<QString, QString>& readerInfo)
{
pqObjectBuilder* builder = pqApplicationCore::instance()->getObjectBuilder();
pqPipelineSource* reader =
builder->createReader(readerInfo.second, readerInfo.first, files, server);
if (reader)
{
pqStandardRecentlyUsedResourceLoaderImplementation::addDataFilesToRecentResources(
server, files, reader->getProxy()->GetXMLGroup(), reader->getProxy()->GetXMLName());
}
return reader;
}
pqServerResource::pqServerResource()
显示资源
loadFile第十行:addDataFilesToRecentResources函数
bool pqStandardRecentlyUsedResourceLoaderImplementation::addDataFilesToRecentResources(
pqServer* server, const QStringList& files, const QString& smgroup, const QString& smname)
pqStandardRecentlyUsedResourceLoaderImplementation::addDataFilesToRecentResources(
server, files, reader->getProxy()->GetXMLGroup(), reader->getProxy()->GetXMLName());
pqApplicationCore::settings(),加载qt设置
参数files表示文件名(包含路径的全名),下面是参数files的数据流程:
QStringList:字符串列表
图:addDataFilesToRecentResources参数files_数据流程图
void pqServerResource::addData(const QString& key, const QString& value)
{
this->Implementation->ExtraData[key] = value;
}
进一步分析ExtraData数据流程:
暂无评论内容