当前位置:网站首页>qtvtkvs2015测试代码
qtvtkvs2015测试代码
2022-06-26 00:26:00 【ooolmf】
#pragma once
#include <QtWidgets/QMainWindow>
#include "ui_qt_vtk_video.h"
#include <QFileDialog>
#include <vtkRenderWindow.h>
#include <pcl/io/pcd_io.h>
#include <pcl/point_types.h>
#include <pcl/visualization/pcl_visualizer.h>
#include <vtkAutoInit.h>
VTK_MODULE_INIT(vtkRenderingOpenGL2);
VTK_MODULE_INIT(vtkInteractionStyle);
class qt_vtk_video : public QMainWindow
{
Q_OBJECT
public:
qt_vtk_video(QWidget *parent = Q_NULLPTR);
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud;
boost::shared_ptr<pcl::visualization::PCLVisualizer> viewer;
void initialVtkWidget();
void onOpenFile();
private:
Ui::qt_vtk_videoClass ui;
protected slots:
void openPDB();
};

#include "qt_vtk_video.h"
void qt_vtk_video::initialVtkWidget()
{
cloud.reset(new pcl::PointCloud<pcl::PointXYZ>);
viewer.reset(new pcl::visualization::PCLVisualizer("viewer", false));
viewer->addPointCloud(cloud, "cloud");
ui.qvtkWidget->SetRenderWindow(viewer->getRenderWindow());
viewer->setupInteractor(ui.qvtkWidget->GetInteractor(), ui.qvtkWidget->GetRenderWindow());
ui.qvtkWidget->update();
}
void qt_vtk_video::openPDB()
{
QString fileName = QFileDialog::getOpenFileName(this, "Open PCD PointCloud", ".", "Open PCD files(*.pcd)");
if (!fileName.isEmpty()) {
std::string file_name = fileName.toStdString();
pcl::PCLPointCloud2 cloud2;
Eigen::Vector4f origin;
Eigen::Quaternionf orientation;
int pcd_version;
int data_type;
unsigned int data_idx;
int offset = 0;
pcl::PCDReader rd;
rd.readHeader(file_name, cloud2, origin, orientation, pcd_version, data_type, data_idx);
if (data_type == 0)
{
pcl::io::loadPCDFile(fileName.toStdString(), *cloud);
}
else if (data_type == 2)
{
pcl::PCDReader reader;
reader.read<pcl::PointXYZ>(fileName.toStdString(), *cloud);
}
viewer->addCoordinateSystem(0.5);
viewer->updatePointCloud(cloud, "cloud");
viewer->resetCamera();
ui.qvtkWidget->update();
}
}
qt_vtk_video::qt_vtk_video(QWidget *parent)
: QMainWindow(parent)
{
ui.setupUi(this);
initialVtkWidget();
}
/******************************************************************************** ** Form generated from reading UI file 'qt_vtk_video.ui' ** ** Created by: Qt User Interface Compiler version 5.12.2 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/
#ifndef UI_QT_VTK_VIDEO_H
#define UI_QT_VTK_VIDEO_H
#include <QtCore/QVariant>
#include <QtWidgets/QApplication>
#include <QtWidgets/QMainWindow>
#include <QtWidgets/QMenuBar>
#include <QtWidgets/QPushButton>
#include <QtWidgets/QStatusBar>
#include <QtWidgets/QToolBar>
#include <QtWidgets/QWidget>
#include "QVTKWidget.h"
QT_BEGIN_NAMESPACE
class Ui_qt_vtk_videoClass
{
public:
QWidget *centralWidget;
QVTKWidget *qvtkWidget;
QPushButton *pushButton;
QMenuBar *menuBar;
QToolBar *mainToolBar;
QStatusBar *statusBar;
void setupUi(QMainWindow *qt_vtk_videoClass)
{
if (qt_vtk_videoClass->objectName().isEmpty())
qt_vtk_videoClass->setObjectName(QString::fromUtf8("qt_vtk_videoClass"));
qt_vtk_videoClass->resize(787, 751);
centralWidget = new QWidget(qt_vtk_videoClass);
centralWidget->setObjectName(QString::fromUtf8("centralWidget"));
qvtkWidget = new QVTKWidget(centralWidget);
qvtkWidget->setObjectName(QString::fromUtf8("qvtkWidget"));
qvtkWidget->setGeometry(QRect(90, 60, 631, 591));
pushButton = new QPushButton(centralWidget);
pushButton->setObjectName(QString::fromUtf8("pushButton"));
pushButton->setGeometry(QRect(90, 30, 141, 23));
qt_vtk_videoClass->setCentralWidget(centralWidget);
menuBar = new QMenuBar(qt_vtk_videoClass);
menuBar->setObjectName(QString::fromUtf8("menuBar"));
menuBar->setGeometry(QRect(0, 0, 787, 23));
qt_vtk_videoClass->setMenuBar(menuBar);
mainToolBar = new QToolBar(qt_vtk_videoClass);
mainToolBar->setObjectName(QString::fromUtf8("mainToolBar"));
qt_vtk_videoClass->addToolBar(Qt::TopToolBarArea, mainToolBar);
statusBar = new QStatusBar(qt_vtk_videoClass);
statusBar->setObjectName(QString::fromUtf8("statusBar"));
qt_vtk_videoClass->setStatusBar(statusBar);
retranslateUi(qt_vtk_videoClass);
QObject::connect(pushButton, SIGNAL(clicked()), qt_vtk_videoClass, SLOT(openPDB()));
QMetaObject::connectSlotsByName(qt_vtk_videoClass);
} // setupUi
void retranslateUi(QMainWindow *qt_vtk_videoClass)
{
qt_vtk_videoClass->setWindowTitle(QApplication::translate("qt_vtk_videoClass", "qt_vtk_video", nullptr));
pushButton->setText(QApplication::translate("qt_vtk_videoClass", "\346\211\223\345\274\200pdb\347\202\271\344\272\221\346\226\207\344\273\266", nullptr));
} // retranslateUi
};
namespace Ui {
class qt_vtk_videoClass: public Ui_qt_vtk_videoClass {
};
} // namespace Ui
QT_END_NAMESPACE
#endif // UI_QT_VTK_VIDEO_H


在这里插入图片描述
边栏推荐
- Data analysis - similarities and differences between C-end and b-end data analysis
- What happens from entering a web address in the browser's input box to seeing the contents of the web page?
- Tcp网络通信中各个状态的含义
- Chinese and English instructions of collagen enzyme Worthington
- readv & writev
- 初识Opengl
- Disruptor(一)Sequence
- PTA class a simulation bomb 10: 1119-1123
- Abnova actn4 DNA probe solution
- App test (I)
猜你喜欢

pixel 6 root

About vs scanf, 'scanf' appears: this function or variable may be unsafe Solutions to the problem of consumer usi

关于strlen与sizeof的区别

Make a row of the dataframe a column name

阳光男孩陈颢天 受邀担任第六季完美童模全球总决赛代言人

shell学习记录(一)

Redis7.0的安装步骤

Exploring temporary information for dynamic network embedding

Abnova anti GBA monoclonal antibody solution

V4L2+QT视频优化策略
随机推荐
Make a row of the dataframe a column name
UN make (6) conditional execution of makefile
Chemical properties and application of trypsin
Redis的使用
Disruptor(一)Sequence
PTA class a simulation bomb 10: 1119-1123
The answer skills and examples of practical cases of the second construction company are full of essence
A solution to cross domain problems
Detailed explanation of memory leak check tools
Input 3 integers and output them from large to small
biggan:large scale gan training for high fidelity natural image synthesis
Find the multiplication order of n
Dazhou suggested that we media bloggers do these four things in the early stage
Redis7.0的安装步骤
接口测试用例设计
xargs 的作用详解
PTA class a simulated seventh bomb: 1160-1163
Perfdog
shell学习记录(二)
makefile 中export set ENV 的区别和作用