feat: v0.1.0更新
This commit is contained in:
68
include/gui/PointCloudGLWidget.h
Normal file
68
include/gui/PointCloudGLWidget.h
Normal file
@@ -0,0 +1,68 @@
|
||||
#ifndef POINTCLOUDGLWIDGET_H
|
||||
#define POINTCLOUDGLWIDGET_H
|
||||
|
||||
#include <QOpenGLWidget>
|
||||
#include <QOpenGLFunctions>
|
||||
#include <QOpenGLShaderProgram>
|
||||
#include <QOpenGLBuffer>
|
||||
#include <QOpenGLVertexArrayObject>
|
||||
#include <QMatrix4x4>
|
||||
#include <QVector3D>
|
||||
#include <QMouseEvent>
|
||||
#include <QWheelEvent>
|
||||
#include <pcl/point_cloud.h>
|
||||
#include <pcl/point_types.h>
|
||||
#include <vector>
|
||||
|
||||
class PointCloudGLWidget : public QOpenGLWidget, protected QOpenGLFunctions
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit PointCloudGLWidget(QWidget *parent = nullptr);
|
||||
~PointCloudGLWidget();
|
||||
|
||||
void updatePointCloud(pcl::PointCloud<pcl::PointXYZ>::Ptr cloud);
|
||||
|
||||
protected:
|
||||
void initializeGL() override;
|
||||
void resizeGL(int w, int h) override;
|
||||
void paintGL() override;
|
||||
|
||||
// 鼠标交互
|
||||
void mousePressEvent(QMouseEvent *event) override;
|
||||
void mouseMoveEvent(QMouseEvent *event) override;
|
||||
void mouseReleaseEvent(QMouseEvent *event) override;
|
||||
void wheelEvent(QWheelEvent *event) override;
|
||||
|
||||
private:
|
||||
void setupShaders();
|
||||
void updateBuffers();
|
||||
|
||||
private:
|
||||
// OpenGL资源
|
||||
QOpenGLShaderProgram *m_program;
|
||||
QOpenGLBuffer *m_vertexBuffer;
|
||||
QOpenGLVertexArrayObject *m_vao;
|
||||
|
||||
// 点云数据
|
||||
std::vector<float> m_vertices;
|
||||
int m_pointCount;
|
||||
|
||||
// 相机参数
|
||||
QMatrix4x4 m_projection;
|
||||
QMatrix4x4 m_view;
|
||||
QMatrix4x4 m_model;
|
||||
|
||||
float m_orthoSize; // 正交投影视野大小(控制缩放)
|
||||
float m_rotationX; // X轴旋转角度
|
||||
float m_rotationY; // Y轴旋转角度
|
||||
QVector3D m_translation; // 平移
|
||||
|
||||
// 鼠标交互状态
|
||||
QPoint m_lastMousePos;
|
||||
bool m_leftButtonPressed;
|
||||
bool m_rightButtonPressed;
|
||||
};
|
||||
|
||||
#endif // POINTCLOUDGLWIDGET_H
|
||||
27
include/gui/PointCloudWidget.h
Normal file
27
include/gui/PointCloudWidget.h
Normal file
@@ -0,0 +1,27 @@
|
||||
#ifndef POINTCLOUDWIDGET_H
|
||||
#define POINTCLOUDWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QLabel>
|
||||
#include <pcl/point_cloud.h>
|
||||
#include <pcl/point_types.h>
|
||||
|
||||
class PointCloudGLWidget;
|
||||
|
||||
class PointCloudWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit PointCloudWidget(QWidget *parent = nullptr);
|
||||
~PointCloudWidget();
|
||||
|
||||
// 更新点云显示
|
||||
void updatePointCloud(pcl::PointCloud<pcl::PointXYZ>::Ptr cloud);
|
||||
|
||||
private:
|
||||
QLabel *m_statusLabel;
|
||||
PointCloudGLWidget *m_glWidget;
|
||||
};
|
||||
|
||||
#endif // POINTCLOUDWIDGET_H
|
||||
Reference in New Issue
Block a user