当前位置:网站首页>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


在这里插入图片描述
边栏推荐
- 输入3个整数,从大到小输出出来
- Tengwenze, a hot-blooded boy, was invited to serve as the image ambassador of the global finals of the sixth season perfect children's model
- recvmsg & sendmsg
- Three factors affecting personal growth
- Disruptor(一)Sequence
- 物联网亿万级通信一站式解决方案EMQ
- 关于VS scanf出现‘scanf‘: This function or variable may be unsafe. Consider usi问题的解决方法
- Wechat circle of friends test point
- 阳光男孩陈颢天 受邀担任第六季完美童模全球总决赛代言人
- 求n乘阶之和
猜你喜欢

Show spirit chenzitong was invited to be the chief experience officer of the global finals of the sixth season perfect children's model

轻轻松松理解指针

CYCA少儿形体礼仪 乐清市培训成果考核圆满落幕

Xiaomi tablet 5 Pro unlock bootloader

秀场精灵陈梓桐 受邀担任第六季完美童模全球总决赛首席体验官

一分钟了解同步、异步、阻塞和非阻塞的区别

Make a row of the dataframe a column name

Sweet cool girl jinshuyi was invited to be the spokesperson for the global finals of the sixth season perfect children's model

通俗易懂C语言关键字static

vscode调试时提示更新到最新调试版本
随机推荐
17.11 std::atomic续谈、std::async深入谈
如何为政企移动办公加上一道“安全锁”?
Xiaomi tablet 5 Pro unlock bootloader
LeetCode 31 ~ 40
PTA class a simulated third bomb: 1140-1143
如何高效的完成每日的任务?
A solution to cross domain problems
Wechat circle of friends test point
Perfdog
字节序问题
On the difference between strlen and sizeof
轻轻松松理解指针
LeetCode 31 ~ 40
Easy to understand C language keyword static
shell学习记录(一)
Pre ++, post ++ and pre -- and post -- (+a, a++ and --a, a--)
Abnova CSV monoclonal antibody solution
Visual studio 2013 redistributable is installed, but MySQL installation fails
初识Opengl
Mot - clé C facile à comprendre statique