#include "mainwindow.h"
#include "ui_mainwindow.h"
//创建菜单栏,工具栏,状态栏应当包含的头文件
#include <QMenuBar>
#include <QMenu>
#include <QToolBar>
#include <QStatusBar>
#include <QAbstractAnimation>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
m_publicIconMap[TREE_ITEM_ICON_DataItem] = QIcon(QStringLiteral("Icons/folder.png"));
model = new QStandardItemModel(ui->treeView);
model->setHorizontalHeaderLabels(QStringList()<<QStringLiteral("--cloud--DB-Tree--"));
ui->treeView->setHeaderHidden(true);
ui->treeView->setModel(model);
ui->treeView->setSelectionMode(QAbstractItemView::ExtendedSelection);//设置多选
/**************************************初始化******************************************/
//初始化PCL显示控件
viewer.reset(new pcl::visualization::PCLVisualizer("viewer", false));
vtkNew<vtkGenericOpenGLRenderWindow> window;
window->AddRenderer(viewer->getRendererCollection()->GetFirstRenderer());
ui->openGLWidget->setRenderWindow(window.Get());
ui->openGLWidget->update();
/**************************************创建菜单******************************************/
QMenuBar *menu_bar = new QMenuBar(this); //创建一个菜单栏
this->setMenuBar(menu_bar); //设置为MainWindow的菜单栏
menu_bar->setStyleSheet("font-size : 18px");
QMenu *file_menu = new QMenu("文件",menu_bar);
QMenu *visualization_menu=new QMenu("显示",menu_bar);
QMenu *filter_menu=new QMenu("滤波",menu_bar);
//**************************************菜单中创建动作******************************************//
//文件下拉框
QAction *open_action = new QAction("读取");
QAction *save_action = new QAction("保存");
QAction *quit_action = new QAction("退出");
file_menu->addAction(open_action);//添加动作到文件菜单,QAction就会自动变成子菜单
file_menu->addAction(save_action);
file_menu->addSeparator(); //添加菜单分隔符
file_menu->addAction(quit_action);
//***********************************菜单添加至菜单栏***************************************//
menu_bar->addMenu(file_menu);//把菜单添加到菜单栏
//***********************************connect设置*******************************************//
//------------------------------------------------------------------
//文件
connect(open_action,SIGNAL(triggered()),this,SLOT(Open_clicked()));//读取文件
connect(save_action,SIGNAL(triggered()),this,SLOT(Save_clicked()));//保存文件
connect(quit_action,SIGNAL(triggered()),this,SLOT(close()));
//------------------------------------------------------------------
//filter
//------------------------------------------------------------------
//visualization
}
MainWindow::~MainWindow()
{
delete ui;
}
//-------------------------------------function----------------------------------------------------//
//读取有逗号的xyzi
pcl::PointCloud<pcl::PointXYZ>::Ptr get_pointcloud_from_txt(const std::string& file_path)
{
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZ>);
std::ifstream file(file_path.c_str());//c_str():生成一个const char*指针,指向以空字符终止的数组。
while (file)
{
std::string s;
if (!getline(file, s)) break;
std::istringstream ss(s);
std::vector <std::string> record;
std::vector <float> point;
pcl::PointXYZ p;
while (ss)
{
std::string s;
if (!getline(ss, s, ',')) break;
point.push_back(atof(s.c_str()));
}
p.x = point[0];
p.y = point[1];
p.z = point[2];
// p.intensity = point[3];
cloud->push_back(p);
}
file.close();
return cloud;
}
//-------------------------------------file-----------------------------------------------------
//读取点云
void MainWindow::Open_clicked()
{
QString fileName = QFileDialog::getOpenFileName(this, tr("open file"),
"", tr("pcb files(*.pcd *.ply *.xyz) ;;All files (*.*)"));
if(fileName.isEmpty())
{
return;
}
if(fileName.endsWith("ply"))
{
qDebug()<<fileName;
if (pcl::io::loadPLYFile<pcl::PointXYZ>(fileName.toStdString(), cloud) == -1) //* load the file
{
qDebug()<<"Couldn't read file \n";
return ;
}
}
else if (fileName.endsWith("pcd"))
{
qDebug()<<fileName;
if (pcl::io::loadPCDFile<pcl::PointXYZ>(fileName.toStdString(), cloud) == -1) //* load the file
{
qDebug()<<"Couldn't read pcd file \n";
return ;
}
}
else if (fileName.endsWith("xyz"))
{
QFuture<pcl::PointCloud<pcl::PointXYZ>::Ptr> future =
QtConcurrent::run(get_pointcloud_from_txt,std::string(fileName.toStdString()));
while(!future.isFinished())
{
QApplication::processEvents(QEventLoop::AllEvents, 100);
}
auto cloud_out=future.result();
cloud=*cloud_out;
}
else {
QMessageBox::warning(this, "Warning","点云读取格式错误!");
}
//-----------------------------------------------------
cloud_vec.push_back(cloud.makeShared());
cloud_index.push_back(1);
itemFolder = new QStandardItem(m_publicIconMap[QStringLiteral("treeItem_folder")],QStringLiteral("cloud%1").arg(cloud_vec.size()-1));
itemFolder->setCheckable(true);
itemFolder->setCheckState(Qt::Checked);//获取选中状态
model->appendRow(itemFolder);
// item = new QStandardItem(m_publicIconMap[QStringLiteral("treeItem_dataItem")],QStringLiteral("%1").arg(cloud_vec.size()-1));
// item->setCheckable(true);
// item->setCheckState(Qt::Checked);//获取选中状态
// itemFolder->appendRow(item);
//-----------------------------------------------------------
int size = static_cast<int>(cloud.size());
QString PointSize = QString("%1").arg(size);
ui->textBrowser_2->clear();
ui->textBrowser_2->insertPlainText("点云数量: "+PointSize);
ui->textBrowser_2->setFont(QFont( "Arial" , 9 ,QFont::Normal ));
//-----------------------------------------------------------------
//移除窗口点云
//点云设置
viewer.reset(new pcl::visualization::PCLVisualizer("viewer", false));
vtkNew<vtkGenericOpenGLRenderWindow> window;
window->AddRenderer(viewer->getRendererCollection()->GetFirstRenderer());
ui->openGLWidget->setRenderWindow(window.Get());
viewer->addPointCloud<pcl::PointXYZ>(cloud.makeShared(),std::to_string(cloud_vec.size()-1));
//设置点云大小
viewer->setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_POINT_SIZE, point_size, std::to_string(cloud_vec.size()-1));
viewer->resetCamera();
ui->openGLWidget->update();
}
void MainWindow::Save_clicked()
{
QString filename = QFileDialog::getSaveFileName(this, tr ("Open point cloud"), "", tr ("Point cloud data (*.pcd *.ply)"));
if(cloud.empty())
{
return;
}
else
{
if (filename.isEmpty ())
return;
int return_status;
if (filename.endsWith (".pcd", Qt::CaseInsensitive))
return_status = pcl::io::savePCDFileBinary (filename.toStdString (), *cloud.makeShared());
else if (filename.endsWith (".ply", Qt::CaseInsensitive))
return_status = pcl::io::savePLYFileBinary (filename.toStdString (), *cloud.makeShared());
没有合适的资源?快使用搜索试试~ 我知道了~
《QT+PCL》专栏 pcl1.13版本demo案例,下载一个就好,不要都下载,瞎花钱 对应qt6
共7097个文件
idx:7019个
qm:22个
dll:20个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
5星 · 超过95%的资源 14 下载量 18 浏览量
2023-06-29
13:43:52
上传
评论 2
收藏 41.45MB ZIP 举报
温馨提示
《QT+PCL》专栏 pcl1.13版本demo案例,下载一个就好,不要都下载,瞎花钱 对应qt6,
资源推荐
资源详情
资源评论
收起资源包目录
《QT+PCL》专栏 pcl1.13版本demo案例,下载一个就好,不要都下载,瞎花钱
对应qt6 (7097个子文件)
pcl_test.pro.user.5f9b8dd 18KB
pcl_test.pro.user.4.8-pre1 23KB
mainwindow.cpp 10KB
qrc_rsc.cpp 9KB
moc_mainwindow.cpp 4KB
main.cpp 357B
pcl_function.cpp 124B
Makefile.Debug 640KB
opengl32sw.dll 19.95MB
Qt5Gui.dll 6.76MB
Qt5Core.dll 5.72MB
Qt5Widgets.dll 5.26MB
D3Dcompiler_47.dll 3.98MB
libGLESv2.dll 3.21MB
qwindows.dll 1.42MB
qwebp.dll 495KB
qjpeg.dll 409KB
qtiff.dll 379KB
Qt5Svg.dll 322KB
qwindowsvistastyle.dll 140KB
qicns.dll 44KB
qsvgicon.dll 40KB
qgif.dll 37KB
qico.dll 36KB
qtga.dll 30KB
qwbmp.dll 28KB
qsvg.dll 27KB
libEGL.dll 23KB
pcl_test.exe 182KB
ui_mainwindow.h 5KB
mainwindow.h 3KB
pcl_function.h 731B
moc_predefs.h 270B
tech.ico 1KB
tech.ico 1KB
qopenglext.h.BCC2974B655E895C.idx 563KB
winnt.h.3F36B4D748C06CFE.idx 450KB
error_codes.hpp.C7164A5065A9D77F.idx 410KB
error_codes.hpp.06559C888B6CE1AF.idx 410KB
error_codes.hpp.9BA926D1E7533F7B.idx 410KB
wingdi.h.DB9D17A09223ED35.idx 329KB
GeneralBlockPanelKernel.h.5DC2AEEAB2530702.idx 234KB
GeneralBlockPanelKernel.h.E72C53CE1704FA6C.idx 233KB
point_types.hpp.2220ABBE84845C90.idx 198KB
point_types.hpp.31AC6061FE1FDFCF.idx 194KB
CoreEvaluators.h.81BA061069BFB236.idx 194KB
implementation.hpp.D943AFBEF87DD0B9.idx 193KB
point_types.hpp.BBDADF740051F87A.idx 191KB
CoreEvaluators.h.D08848A1E71E15D0.idx 189KB
function_template.hpp.01BE7AE9C37B98AE.idx 186KB
has_binary_operator.hpp.2E909B767631F425.idx 181KB
winerror.h.4DA7EA8F8AD523FC.idx 181KB
function_template.hpp.EECCC33E80220615.idx 160KB
function_template.hpp.A38835C3DC1935CF.idx 160KB
eigen.hpp.7688588434D71EB8.idx 151KB
emmintrin.h.69755A2E4667BC52.idx 149KB
emmintrin.h.3B09679DE2597FB0.idx 149KB
qnamespace.h.FF06AE78BDEE48A5.idx 147KB
qnamespace.h.CF41432CB62662A2.idx 146KB
qmetatype.h.7893870BFDD1F7A9.idx 136KB
qstring.h.DC63E695B8303FD1.idx 134KB
bind.hpp.2BFDD8CF95B8CC5C.idx 132KB
bind.hpp.CE8F8B044EEBC358.idx 130KB
SelfadjointMatrixMatrix.h.5BD48AECBC08C83E.idx 128KB
SelfadjointMatrixMatrix.h.E3AA90DB2AA5A2FE.idx 128KB
point_struct_traits.h.89692697847CFD5F.idx 123KB
point_struct_traits.h.2EF5A092C0D86FF4.idx 123KB
qmetatype.h.555D30A683BDD567.idx 123KB
vtkGenericDataArray.txx.C539B05C9062ADFE.idx 122KB
avxintrin.h.A949A5AC114DCCBA.idx 120KB
point_struct_traits.h.AF8CF84CF2601C77.idx 119KB
qhash.h.8BFE4CF1438708D8.idx 113KB
complex.24E63029838E94A9.idx 111KB
ProductEvaluators.h.AAEF142C3812C866.idx 103KB
PlainObjectBase.h.7E05AFE778E60ACC.idx 99KB
PlainObjectBase.h.756821EBCDF43824.idx 99KB
qvector.h.DBF985B2AE0A545C.idx 98KB
ProductEvaluators.h.F9ED5F00CAA61953.idx 98KB
pcl_visualizer.hpp.6EBA92A4FE9C334F.idx 97KB
bind.hpp.749463031A9F25EE.idx 92KB
bind.hpp.1B661172612C4EC4.idx 92KB
BDCSVD.h.BB5D99DBBDDB41C3.idx 92KB
BDCSVD.h.AE2D03E824B14E42.idx 91KB
qstring.h.567872AFBFEAA616.idx 91KB
GeneralMatrixVector.h.1E82F118C7617D00.idx 90KB
future.hpp.142DC07A0AE9D449.idx 89KB
win32_api.hpp.189D33D7AAF5F035.idx 87KB
GeneralMatrixVector.h.8FC1936F4C26BCEE.idx 87KB
vtkGenericDataArray.txx.C8F569EDB2A8CC26.idx 87KB
qlocale.h.1DDB73BD1DB7ACEC.idx 86KB
qmap.h.33950EE1CAEC44D2.idx 85KB
register_point_struct.h.9EED9CA002EB416F.idx 84KB
xmmintrin.h.45F96C6955EA2A84.idx 84KB
xmmintrin.h.364A73AC0B6B44A1.idx 84KB
CoreEvaluators.h.078AC36267D302BD.idx 84KB
CoreEvaluators.h.6F333AA430DA0B91.idx 84KB
qlocale.h.23AEC99DB28D94FD.idx 82KB
qlist.h.AD66F2FC492EEBDA.idx 82KB
filesystem.7D563E57103A0400.idx 81KB
pcd_io.hpp.B035D4D1004CAB9B.idx 78KB
共 7097 条
- 1
- 2
- 3
- 4
- 5
- 6
- 71
小修勾
- 粉丝: 4328
- 资源: 22
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
前往页