QtVtk-017-EasyView

2024-02-01 07:59
文章标签 017 qtvtk easyview

本文主要是介绍QtVtk-017-EasyView,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

头图

​ 今天这个还是搞不懂,接着更新官方源代码。

文章目录

  • 1 官方示例展示
  • 2 官方源代码
    • 2.1 EasyView.h
    • 2.2 EasyView.cpp
  • ★ 源码 ★

1 官方示例展示

​ 不知道这个Demo和CustomLinkView Demo有什么区别。简单运行没有看到啥不一样的呀,占坑,不要寄刀片。

在这里插入图片描述

2 官方源代码

2.1 EasyView.h

#ifndef EasyView_H
#define EasyView_H#include "vtkSmartPointer.h"    // Required for smart pointer internal ivars.#include <QMainWindow>// Forward Qt class declarations
class Ui_EasyView;// Forward VTK class declarations
class vtkXMLTreeReader;
class vtkGraphLayoutView;
class vtkQtTableView;
class vtkQtTreeView;class EasyView : public QMainWindow
{Q_OBJECTpublic:// Constructor/DestructorEasyView();~EasyView() override;public slots:virtual void slotOpenXMLFile();virtual void slotExit();protected:protected slots:private:// Methodsvoid SetupAnnotationLink();// MembersvtkSmartPointer<vtkXMLTreeReader>       XMLReader;vtkSmartPointer<vtkGraphLayoutView>     GraphView;vtkSmartPointer<vtkQtTreeView>          TreeView;vtkSmartPointer<vtkQtTableView>         TableView;vtkSmartPointer<vtkQtTreeView>          ColumnView;// Designer formUi_EasyView *ui;
};#endif // EasyView_H

2.2 EasyView.cpp

#include "ui_EasyView.h"
#include "EasyView.h"// VTK includes
#include <vtkAnnotationLink.h>
#include <vtkDataObjectToTable.h>
#include <vtkDataRepresentation.h>
#include "vtkGenericOpenGLRenderWindow.h"
#include <vtkGraphLayoutView.h>
#include <vtkQtTableView.h>
#include <vtkQtTreeView.h>
#include <vtkRenderer.h>
#include <vtkSelection.h>
#include <vtkSelectionNode.h>
#include <vtkTable.h>
#include <vtkTableToGraph.h>
#include <vtkTreeLayoutStrategy.h>
#include <vtkViewTheme.h>
#include <vtkViewUpdater.h>
#include <vtkXMLTreeReader.h>// Qt includes
#include <QDir>
#include <QFileDialog>
#include <QTreeView>#include "vtkSmartPointer.h"
#define VTK_CREATE(type, name) \vtkSmartPointer<type> name = vtkSmartPointer<type>::New()// Constructor
EasyView::EasyView()
{this->ui = new Ui_EasyView;this->ui->setupUi(this);vtkNew<vtkGenericOpenGLRenderWindow> renderWindow;this->ui->vtkGraphViewWidget->SetRenderWindow(renderWindow);this->XMLReader    = vtkSmartPointer<vtkXMLTreeReader>::New();this->GraphView    = vtkSmartPointer<vtkGraphLayoutView>::New();this->TreeView     = vtkSmartPointer<vtkQtTreeView>::New();this->TableView    = vtkSmartPointer<vtkQtTableView>::New();this->ColumnView   = vtkSmartPointer<vtkQtTreeView>::New();this->ColumnView->SetUseColumnView(1);// Tell the table view to sort selections that it receives (but does// not initiate) to the topthis->TableView->SetSortSelectionToTop(true);// Set widgets for the tree and table viewsthis->ui->treeFrame->layout()->addWidget(this->TreeView->GetWidget());this->ui->tableFrame->layout()->addWidget(this->TableView->GetWidget());this->ui->columnFrame->layout()->addWidget(this->ColumnView->GetWidget());// Graph View needs to get my render windowthis->GraphView->SetInteractor(this->ui->vtkGraphViewWidget->GetInteractor());this->GraphView->SetRenderWindow(this->ui->vtkGraphViewWidget->GetRenderWindow());// Set up the theme on the graph view :)vtkViewTheme* theme = vtkViewTheme::CreateNeonTheme();this->GraphView->ApplyViewTheme(theme);theme->Delete();// Set up action signals and slotsconnect(this->ui->actionOpenXMLFile, SIGNAL(triggered()), this, SLOT(slotOpenXMLFile()));connect(this->ui->actionExit, SIGNAL(triggered()), this, SLOT(slotExit()));// Apply application stylesheetQString css = "* { font: bold italic 18px \"Calibri\"; color: midnightblue }";css += "QTreeView { font: bold italic 16px \"Calibri\"; color: midnightblue }";//qApp->setStyleSheet(css); // Seems to cause a bug on some systems// But at least it's here as an examplethis->GraphView->Render();
};// Set up the annotation between the vtk and qt views
void EasyView::SetupAnnotationLink()
{// Create a selection link and have all the views use itVTK_CREATE(vtkAnnotationLink,annLink);this->TreeView->GetRepresentation()->SetAnnotationLink(annLink);this->TreeView->GetRepresentation()->SetSelectionType(vtkSelectionNode::PEDIGREEIDS);this->TableView->GetRepresentation()->SetAnnotationLink(annLink);this->TableView->GetRepresentation()->SetSelectionType(vtkSelectionNode::PEDIGREEIDS);this->ColumnView->GetRepresentation()->SetAnnotationLink(annLink);this->ColumnView->GetRepresentation()->SetSelectionType(vtkSelectionNode::PEDIGREEIDS);this->GraphView->GetRepresentation()->SetAnnotationLink(annLink);this->GraphView->GetRepresentation()->SetSelectionType(vtkSelectionNode::PEDIGREEIDS);// Set up the theme on the graph view :)vtkViewTheme* theme = vtkViewTheme::CreateNeonTheme();this->GraphView->ApplyViewTheme(theme);this->GraphView->Update();theme->Delete();VTK_CREATE(vtkViewUpdater,updater);updater->AddView(this->TreeView);updater->AddView(this->TableView);updater->AddView(this->ColumnView);updater->AddView(this->GraphView);updater->AddAnnotationLink(annLink);
}EasyView::~EasyView()
{}// Action to be taken upon graph file open
void EasyView::slotOpenXMLFile()
{// Browse for and open the fileQDir dir;// Open the text data fileQString fileName = QFileDialog::getOpenFileName(this,"Select the text data file",QDir::homePath(),"XML Files (*.xml);;All Files (*.*)");if (fileName.isNull()){cerr << "Could not open file" << endl;return;}// Create XML readerthis->XMLReader->SetFileName( fileName.toLatin1() );this->XMLReader->ReadTagNameOff();this->XMLReader->Update();// Set up some hard coded parameters for the graph viewthis->GraphView->SetVertexLabelArrayName("id");this->GraphView->VertexLabelVisibilityOn();this->GraphView->SetVertexColorArrayName("VertexDegree");this->GraphView->ColorVerticesOn();this->GraphView->SetEdgeColorArrayName("edge id");this->GraphView->ColorEdgesOn();// Create a tree layout strategyVTK_CREATE(vtkTreeLayoutStrategy, treeStrat);treeStrat->RadialOn();treeStrat->SetAngle(360);treeStrat->SetLogSpacingValue(1);this->GraphView->SetLayoutStrategy(treeStrat);// Set the input to the graph viewthis->GraphView->SetRepresentationFromInputConnection(this->XMLReader->GetOutputPort());// Okay now do an explicit reset camera so that// the user doesn't have to move the mouse// in the window to see the resulting graphthis->GraphView->ResetCamera();// Now hand off tree to the tree viewthis->TreeView->SetRepresentationFromInputConnection(this->XMLReader->GetOutputPort());this->ColumnView->SetRepresentationFromInputConnection(this->XMLReader->GetOutputPort());// Extract a table and give to table viewVTK_CREATE(vtkDataObjectToTable, toTable);toTable->SetInputConnection(this->XMLReader->GetOutputPort());toTable->SetFieldType(vtkDataObjectToTable::VERTEX_DATA);this->TableView->SetRepresentationFromInputConnection(toTable->GetOutputPort());this->SetupAnnotationLink();// Hide an unwanted column in the tree view.this->TreeView->HideColumn(2);// Turn on some colors.this->TreeView->SetColorArrayName("vertex id");this->TreeView->ColorByArrayOn();// Update all the viewsthis->TreeView->Update();this->TableView->Update();this->ColumnView->Update();// Force a render on the graph viewthis->GraphView->Render();
}void EasyView::slotExit() {qApp->exit();
}

★ 源码 ★

源码分享一时爽,一直分享一直爽, 链接如下:

自取:https://github.com/DreamLife-Jianwei/Qt-Vtk

在这里插入图片描述


博客签名2021

这篇关于QtVtk-017-EasyView的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/666603

相关文章

[web-017] requirements.txt 从一个项目里提取它所有的依赖包以便为未来做安装使用

一个项目依赖若干个包。在新环境下进行安装,手工确认这些安装包太繁琐。有两种方式可以解决 1. pip3 freeze > requirements.txt 这种方式把pip安装的所有包的版本都导出到requirements.txt文件。方便,但是太多,且有些包并不是必需的。 2. pipreqs工具 pip3 install pipreqs pipreqs /homt/project/r

八爪鱼现金流-017,程序员,要有自己的作品,对接支付或广告

程序员,要有自己的作品。 天天给别人写代码。什么时候把自己的想法、灵感,打造出来呢? 自己写个网站、写个app,挂上广告或者对接支付。 把自己的想法实现了,才是更加有成就感的事情。 最近又开始裁员了,人心惶惶。这个行业md,是不是快没了。 把裁员人员的项目给剩下的人,工作量翻倍。这不是变成核动力驴了。。。。。 我的作品欢迎试用: 八爪鱼现金流【3个哈哈w 点哈哈incom 点哈

Reactor Netty UDP 客户器端-响应式编程-017

🤗 ApiHug × {Postman|Swagger|Api...} = 快↑ 准√ 省↓ GitHub - apihug/apihug.com: All abou the Apihug   apihug.com: 有爱,有温度,有质量,有信任ApiHug - API design Copilot - IntelliJ IDEs Plugin | Marketplace    The N

谷粒商城实战(017 业务-单点登录)

Java项目《谷粒商城》架构师级Java项目实战,对标阿里P6-P7,全网最强 总时长 104:45:00 共408P 此文章包含第231p-第p235的内容 介绍 单点登录(Single Sign-On,SSO)是一种身份验证服务,允许用户使用一组凭据(例如用户名和密码)登录到多个相关但相互独立的软件系统中。在用户进行了一次登录认证后,他们就可以访问其他受信任的系统而无需重新进行身份

蛋白质亚细胞定位预测(生物信息学工具-017)

直奔主题,下面这张表图怎么制作,一般都是毕业论文hh,蛋白质的亚细胞定位如何预测? 01 方法 https://wolfpsort.hgc.jp/ #官网小程序,简单好用,不用R包,python包,linux程序,win软件等等花里胡哨的 粘贴aa序列到网页的大框 这里预测的是植物plant蛋白,也可以预测动物和真菌 点击提交 02 结果 跳出运行结果,选取我们关注的部分

017——DS18B20驱动开发(基于I.MX6uLL)

目录 一、 模块介绍 1.1 简介 1.2 主要特点 1.3 存储器介绍 1.4 时序 1.5 命令 1.5.1 命令大全    1.5.2 命令使用 1.5.3 使用示例 1.6 原理图 二、 驱动程序 三、 应用程序 四、 测试 一、 模块介绍 1.1 简介         DS18B20 温度传感器具有线路简单、体积小的特点,用来测量温度非常简单,

《青少年成长管理2024》017 “成长七要素之二:情感”3/4

《青少年成长管理2024》017 “成长七要素之二:情感”3/4 六、人情(一)什么是人情(二)青少年如何处理好人情世故(三)青少年对待陌生人应当保持怎么情感姿态(四)与人为善 七、情绪(一)什么是情绪(二)青少年如何做好情绪管理(三)老师和家长如何正确对待青少的情绪波动 八、情商(一)什么是情商(二)青少年如何提高自己的情商 本节分析了成长七要素中的情感要素,将其划分为亲情、

Linux C++ 017-运算符重载

Linux C++ 017-运算符重载 本节关键字:Linux、C++、运算符重载、匿名函数 相关库函数: 运算符重载的概念 对已有的运算符重新进行定义,赋予其另外一种功能,以适应不同的数据类型* 运算符重载可以发生函数重载* 对于内置的数据类型的表达式的运算符是不可能改变的* 不要滥用运算符重载 运算符重载的作用 (1) 加号运算符(operator+):实现两个自定义数据类型相

Python-VBA编程500例-017(入门级)

数组剔除元素后的乘积(The Product Resulting From An Array With Elements Excluded)在多个领域具有实际应用价值。常见的应用场景有: 1、金融数据分析:在金融领域,数组通常用来存储股票价格、交易量或其他相关金融指标。当分析人员需要剔除某个异常数据点或某个时间段的数据以进行趋势分析或计算回报率时,他们可以利用数组剔除元素后的乘积。例如,如果一个

html5cssjs代码 017样式示例

html5&css&js代码 017样式示例 一、代码二、解释 这段HTML代码定义了一个网页的基本结构,包括头部、主体和尾部。在头部中,设置了网页标题、字符编码和样式。主体部分包含一个标题和一个表格,表格内分为两个单元格,左侧为菜单,右侧为网页内容。尾部显示了版权信息。通过使用CSS样式,对网页的字体颜色、背景颜色、对齐方式和边距等进行了定制。 一、代码 <!DOCTY