头文件QVTK.h
#pragma once
#include
#include "ui_QVTK.h"
#include
#include
#include
#include
#include
class QVTK : public QWidget
{
Q_OBJECT
public:
QVTK(QWidget *parent = Q_NULLPTR);
~QVTK();
private:
Ui::QVTK ui;
pcl::PointCloud::Ptr cloud;
boost::shared_ptr viewer;
void initialVtkWidget();
private slots:
void onOpen();
};
源文件QVTK.cpp
#include "QVTK.h"
using namespace std;
QVTK::QVTK(QWidget *parent)
: QWidget(parent)
{
ui.setupUi(this);
initialVtkWidget();
}
QVTK::~QVTK()
{
}
void QVTK::initialVtkWidget()
{
cloud.reset(new pcl::PointCloud);
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 QVTK::onOpen()
{
QString fileName = QFileDialog::getOpenFileName(this, "Open PointCloud", ".", "Open PCD files(*.pcd)");
pcl::io::loadPCDFile(fileName.toStdString(), *cloud);
viewer->updatePointCloud(cloud, "cloud");
viewer->resetCamera();
ui.qvtkWidget->update();
}
QT中ui界面
实现:
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)