refactor(cloudview): 重构项目结构与代码格式,优化构建配置
1. 调整.gitignore规则,新增资源文件忽略项 2. 重构子项目依赖配置,统一项目构建路径 3. 修复CloudView头文件和pro文件的包含路径 4. 格式化代码缩进与注释风格,调整类成员布局 5. 为CloudView新增--help/-h和--version/-v命令行参数 6. 重构点云渲染模块,新增GLES2 shader渲染支持与悬浮控件
This commit is contained in:
commit
44180b7f85
6
.gitignore
vendored
6
.gitignore
vendored
@ -15,8 +15,10 @@
|
|||||||
Makefile*
|
Makefile*
|
||||||
moc_*.cpp
|
moc_*.cpp
|
||||||
moc_*.h
|
moc_*.h
|
||||||
qrc_*.cpp
|
qrc_*.cpp
|
||||||
ui_*.h
|
*_resource.rc
|
||||||
|
*_resource.res
|
||||||
|
ui_*.h
|
||||||
*.autosave
|
*.autosave
|
||||||
|
|
||||||
# 构建目录
|
# 构建目录
|
||||||
|
|||||||
@ -4,10 +4,17 @@
|
|||||||
QT += core
|
QT += core
|
||||||
|
|
||||||
# 鎸囧畾椤圭洰妯℃澘涓洪潤鎬佸簱
|
# 鎸囧畾椤圭洰妯℃澘涓洪潤鎬佸簱
|
||||||
TEMPLATE = lib
|
TEMPLATE = lib
|
||||||
CONFIG += staticlib
|
CONFIG += staticlib
|
||||||
|
|
||||||
win32-msvc {
|
win32:CONFIG(debug, debug|release) {
|
||||||
|
DESTDIR = $$PWD/debug
|
||||||
|
}
|
||||||
|
win32:CONFIG(release, debug|release) {
|
||||||
|
DESTDIR = $$PWD/release
|
||||||
|
}
|
||||||
|
|
||||||
|
win32-msvc {
|
||||||
QMAKE_CXXFLAGS += /utf-8
|
QMAKE_CXXFLAGS += /utf-8
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -15,9 +15,9 @@ TEMPLATE = app
|
|||||||
|
|
||||||
# 椤圭洰鐩綍
|
# 椤圭洰鐩綍
|
||||||
INCLUDEPATH += $$PWD/Inc
|
INCLUDEPATH += $$PWD/Inc
|
||||||
|
INCLUDEPATH += $$PWD/../../Device/SDK/VzNLSDK/Inc
|
||||||
INCLUDEPATH += $$PWD/../CloudView3D/Inc
|
INCLUDEPATH += $$PWD/../CloudView3D/Inc
|
||||||
INCLUDEPATH += $$PWD/../CloudUtils/Inc
|
INCLUDEPATH += $$PWD/../CloudUtils/Inc
|
||||||
INCLUDEPATH += $$PWD/../../Device/SDK/VzNLSDK/Inc
|
|
||||||
INCLUDEPATH += $$PWD/../VrUtils/Inc
|
INCLUDEPATH += $$PWD/../VrUtils/Inc
|
||||||
INCLUDEPATH += $$PWD/../VrCommon/Inc
|
INCLUDEPATH += $$PWD/../VrCommon/Inc
|
||||||
|
|
||||||
@ -35,23 +35,28 @@ SOURCES += \
|
|||||||
|
|
||||||
# 璧勬簮鏂囦欢
|
# 璧勬簮鏂囦欢
|
||||||
RESOURCES += resource/resource.qrc
|
RESOURCES += resource/resource.qrc
|
||||||
RESOURCES += $$PWD/../../AppUtils/UICommon/common_resources.qrc
|
COMMON_RESOURCES = $$PWD/../../AppUtils/UICommon/common_resources.qrc
|
||||||
|
exists($$COMMON_RESOURCES) {
|
||||||
|
RESOURCES += $$COMMON_RESOURCES
|
||||||
|
} else {
|
||||||
|
message("CloudView: optional common_resources.qrc not found; using text view buttons")
|
||||||
|
}
|
||||||
|
|
||||||
# Windows 搴旂敤鍥炬爣
|
# Windows 搴旂敤鍥炬爣
|
||||||
RC_ICONS = resource/logo.ico
|
RC_ICONS = resource/logo.ico
|
||||||
|
|
||||||
# Windows骞冲彴搴撻摼鎺?
|
# Windows骞冲彴搴撻摼鎺?
|
||||||
win32:CONFIG(release, debug|release): {
|
win32:CONFIG(release, debug|release): {
|
||||||
LIBS += -L../CloudView3D/release -lCloudView3D
|
LIBS += -L$$PWD/../CloudView3D/release -lCloudView3D
|
||||||
LIBS += -L../CloudUtils/release -lCloudUtils
|
LIBS += -L$$PWD/../CloudUtils/release -lCloudUtils
|
||||||
LIBS += -L../VrUtils/release -lVrUtils
|
LIBS += -L$$PWD/../VrUtils/release -lVrUtils
|
||||||
LIBS += -L../VrCommon/release -lVrCommon
|
LIBS += -L$$PWD/../VrCommon/release -lVrCommon
|
||||||
}
|
}
|
||||||
else:win32:CONFIG(debug, debug|release): {
|
else:win32:CONFIG(debug, debug|release): {
|
||||||
LIBS += -L../CloudView3D/debug -lCloudView3D
|
LIBS += -L$$PWD/../CloudView3D/debug -lCloudView3D
|
||||||
LIBS += -L../CloudUtils/debug -lCloudUtils
|
LIBS += -L$$PWD/../CloudUtils/debug -lCloudUtils
|
||||||
LIBS += -L../VrUtils/debug -lVrUtils
|
LIBS += -L$$PWD/../VrUtils/debug -lVrUtils
|
||||||
LIBS += -L../VrCommon/debug -lVrCommon
|
LIBS += -L$$PWD/../VrCommon/debug -lVrCommon
|
||||||
}
|
}
|
||||||
|
|
||||||
# Windows绯荤粺搴?
|
# Windows绯荤粺搴?
|
||||||
|
|||||||
@ -17,17 +17,17 @@
|
|||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
#include <QRadioButton>
|
#include <QRadioButton>
|
||||||
#include <QCheckBox>
|
#include <QCheckBox>
|
||||||
#include <QComboBox>
|
#include <QComboBox>
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include "CloudView3D.h"
|
#include "CloudView3D.h"
|
||||||
#include "PointCloudConverter.h"
|
#include "PointCloudConverter.h"
|
||||||
|
|
||||||
class QTextEdit;
|
class QTextEdit;
|
||||||
class QTableWidget;
|
class QTableWidget;
|
||||||
class QCloseEvent;
|
class QCloseEvent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief 点云查看器主窗口
|
* @brief 点云查看器主窗口
|
||||||
@ -37,55 +37,55 @@ class CloudViewMainWindow : public QMainWindow
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
struct StartupFiles
|
struct StartupFiles
|
||||||
{
|
{
|
||||||
QStringList displayFiles;
|
QStringList displayFiles;
|
||||||
QStringList bboxFiles;
|
QStringList bboxFiles;
|
||||||
QStringList circleFiles;
|
QStringList circleFiles;
|
||||||
QStringList rectangleFiles;
|
QStringList rectangleFiles;
|
||||||
QStringList surfaceFiles;
|
QStringList surfaceFiles;
|
||||||
QStringList triangleFiles;
|
QStringList triangleFiles;
|
||||||
bool sequential = false;
|
bool sequential = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
explicit CloudViewMainWindow(QWidget* parent = nullptr);
|
|
||||||
~CloudViewMainWindow() override;
|
|
||||||
|
|
||||||
bool loadStartupFiles(const StartupFiles& files);
|
|
||||||
bool loadDisplayFile(const QString& fileName);
|
|
||||||
bool loadCircleShapeFile(const QString& fileName);
|
|
||||||
bool loadRectangleShapeFile(const QString& fileName);
|
|
||||||
bool loadSurfaceShapeFile(const QString& fileName);
|
|
||||||
bool loadTriangleShapeFile(const QString& fileName);
|
|
||||||
void fitViewToContent();
|
|
||||||
|
|
||||||
protected:
|
explicit CloudViewMainWindow(QWidget* parent = nullptr);
|
||||||
bool eventFilter(QObject* obj, QEvent* event) override;
|
~CloudViewMainWindow() override;
|
||||||
void closeEvent(QCloseEvent* event) override;
|
|
||||||
|
bool loadStartupFiles(const StartupFiles& files);
|
||||||
private:
|
bool loadDisplayFile(const QString& fileName);
|
||||||
enum class StartupFileType
|
bool loadCircleShapeFile(const QString& fileName);
|
||||||
{
|
bool loadRectangleShapeFile(const QString& fileName);
|
||||||
Display,
|
bool loadSurfaceShapeFile(const QString& fileName);
|
||||||
BBox,
|
bool loadTriangleShapeFile(const QString& fileName);
|
||||||
Circle,
|
void fitViewToContent();
|
||||||
Rectangle,
|
|
||||||
Surface,
|
protected:
|
||||||
Triangle
|
bool eventFilter(QObject* obj, QEvent* event) override;
|
||||||
};
|
void closeEvent(QCloseEvent* event) override;
|
||||||
|
|
||||||
struct StartupItem
|
private:
|
||||||
{
|
enum class StartupFileType
|
||||||
StartupFileType type;
|
{
|
||||||
QString fileName;
|
Display,
|
||||||
};
|
BBox,
|
||||||
|
Circle,
|
||||||
void buildStartupSequence(const StartupFiles& files);
|
Rectangle,
|
||||||
bool loadStartupItem(const StartupItem& item);
|
Surface,
|
||||||
bool loadCurrentStartupSequenceItem();
|
Triangle
|
||||||
|
};
|
||||||
private slots:
|
|
||||||
|
struct StartupItem
|
||||||
|
{
|
||||||
|
StartupFileType type;
|
||||||
|
QString fileName;
|
||||||
|
};
|
||||||
|
|
||||||
|
void buildStartupSequence(const StartupFiles& files);
|
||||||
|
bool loadStartupItem(const StartupItem& item);
|
||||||
|
bool loadCurrentStartupSequenceItem();
|
||||||
|
|
||||||
|
private slots:
|
||||||
/**
|
/**
|
||||||
* @brief 打开文件
|
* @brief 打开文件
|
||||||
*/
|
*/
|
||||||
@ -146,11 +146,6 @@ private slots:
|
|||||||
*/
|
*/
|
||||||
void onPoint2CoordChanged();
|
void onPoint2CoordChanged();
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief 处理视角旋转角度改变事件
|
|
||||||
*/
|
|
||||||
void onViewAnglesChanged(float rotX, float rotY, float rotZ);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief 通过输入线号选择线
|
* @brief 通过输入线号选择线
|
||||||
*/
|
*/
|
||||||
@ -211,11 +206,11 @@ private slots:
|
|||||||
void onSavePointCloud(); // 保存 txt 点云
|
void onSavePointCloud(); // 保存 txt 点云
|
||||||
void onSavePlyPcdCloud(); // 保存 ply/pcd 点云
|
void onSavePlyPcdCloud(); // 保存 ply/pcd 点云
|
||||||
void onBatchConvertTxtToPly(); // 批量转换 txt -> ply
|
void onBatchConvertTxtToPly(); // 批量转换 txt -> ply
|
||||||
void onConvertEulerMatrix();
|
void onConvertEulerMatrix();
|
||||||
void onShowCircleShape();
|
void onShowCircleShape();
|
||||||
void onShowRectangleShape();
|
void onShowRectangleShape();
|
||||||
void onShowSurfaceShape();
|
void onShowSurfaceShape();
|
||||||
void onShowTriangleShape();
|
void onShowTriangleShape();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief 姿态补偿计算
|
* @brief 姿态补偿计算
|
||||||
@ -243,11 +238,6 @@ private:
|
|||||||
*/
|
*/
|
||||||
QGroupBox* createFileGroup();
|
QGroupBox* createFileGroup();
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief 创建视图方向工具栏(纵向排列,位于3D视图左侧)
|
|
||||||
*/
|
|
||||||
QWidget* createViewToolbar();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief 创建选点测距组
|
* @brief 创建选点测距组
|
||||||
*/
|
*/
|
||||||
@ -276,14 +266,14 @@ private:
|
|||||||
/**
|
/**
|
||||||
* @brief 更新选点信息显示
|
* @brief 更新选点信息显示
|
||||||
*/
|
*/
|
||||||
void updateSelectedPointsDisplay();
|
void updateSelectedPointsDisplay();
|
||||||
void clearMeasureResultDisplay();
|
void clearMeasureResultDisplay();
|
||||||
void updateMeasureResultDisplay(const SelectedPointInfo& p1,
|
void updateMeasureResultDisplay(const SelectedPointInfo& p1,
|
||||||
const SelectedPointInfo& p2,
|
const SelectedPointInfo& p2,
|
||||||
float distance,
|
float distance,
|
||||||
const QString& statusPrefix = QString());
|
const QString& statusPrefix = QString());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief 从原始数据获取线上点(包含0,0,0)
|
* @brief 从原始数据获取线上点(包含0,0,0)
|
||||||
*/
|
*/
|
||||||
QVector<QVector3D> getOriginalLinePoints(const SelectedLineInfo& lineInfo);
|
QVector<QVector3D> getOriginalLinePoints(const SelectedLineInfo& lineInfo);
|
||||||
@ -310,12 +300,12 @@ private:
|
|||||||
* @return 是否成功加载到包围盒数据
|
* @return 是否成功加载到包围盒数据
|
||||||
*/
|
*/
|
||||||
bool loadBoundingBoxFile(const QString& fileName);
|
bool loadBoundingBoxFile(const QString& fileName);
|
||||||
void applyTransformToAllClouds(const QMatrix4x4& matrix);
|
void applyTransformToAllClouds(const QMatrix4x4& matrix);
|
||||||
void addGeneratedCloud(const PointCloudXYZ& cloud, const QString& name);
|
void addGeneratedCloud(const PointCloudXYZ& cloud, const QString& name);
|
||||||
void showBasicShape(const QString& shapeName,
|
void showBasicShape(const QString& shapeName,
|
||||||
const QVector<LineSegment>& segments,
|
const QVector<LineSegment>& segments,
|
||||||
const QVector<BasicShapePoint>& points = QVector<BasicShapePoint>());
|
const QVector<BasicShapePoint>& points = QVector<BasicShapePoint>());
|
||||||
void showBasicSurface(const QString& shapeName, const QVector<SurfaceQuad>& surfaces, const QVector<LineSegment>& outlines);
|
void showBasicSurface(const QString& shapeName, const QVector<SurfaceQuad>& surfaces, const QVector<LineSegment>& outlines);
|
||||||
|
|
||||||
// 点云显示控件
|
// 点云显示控件
|
||||||
PointCloudGLWidget* m_glWidget;
|
PointCloudGLWidget* m_glWidget;
|
||||||
@ -328,18 +318,13 @@ private:
|
|||||||
QPushButton* m_btnOpenBBox;
|
QPushButton* m_btnOpenBBox;
|
||||||
QPushButton* m_btnClearAll;
|
QPushButton* m_btnClearAll;
|
||||||
|
|
||||||
// 视图角度输入控件
|
|
||||||
QLineEdit* m_editRotX;
|
|
||||||
QLineEdit* m_editRotY;
|
|
||||||
QLineEdit* m_editRotZ;
|
|
||||||
|
|
||||||
// 选点测距控件
|
// 选点测距控件
|
||||||
QCheckBox* m_cbMeasureDistance;
|
QCheckBox* m_cbMeasureDistance;
|
||||||
QPushButton* m_btnClearPoints;
|
QPushButton* m_btnClearPoints;
|
||||||
QLabel* m_lblPoint1;
|
QLabel* m_lblPoint1;
|
||||||
QLabel* m_lblPoint2;
|
QLabel* m_lblPoint2;
|
||||||
QLabel* m_lblDistance;
|
QLabel* m_lblDistance;
|
||||||
QLabel* m_lblDeltaXYZ;
|
QLabel* m_lblDeltaXYZ;
|
||||||
|
|
||||||
// 点1坐标编辑控件
|
// 点1坐标编辑控件
|
||||||
QLineEdit* m_editPoint1X;
|
QLineEdit* m_editPoint1X;
|
||||||
@ -407,14 +392,10 @@ private:
|
|||||||
QTableWidget* m_linePointsTable;
|
QTableWidget* m_linePointsTable;
|
||||||
QVector<QVector3D> m_currentLinePoints; // 当前线的原始点坐标
|
QVector<QVector3D> m_currentLinePoints; // 当前线的原始点坐标
|
||||||
|
|
||||||
// 悬浮缩放按钮
|
// 启动参数序列显示
|
||||||
QToolButton* m_btnZoomIn;
|
QVector<StartupItem> m_startupSequence;
|
||||||
QToolButton* m_btnZoomOut;
|
int m_startupSequenceIndex;
|
||||||
|
bool m_startupSequentialMode;
|
||||||
// 启动参数序列显示
|
};
|
||||||
QVector<StartupItem> m_startupSequence;
|
|
||||||
int m_startupSequenceIndex;
|
|
||||||
bool m_startupSequentialMode;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // CLOUD_VIEW_MAIN_WINDOW_H
|
#endif // CLOUD_VIEW_MAIN_WINDOW_H
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -65,6 +65,14 @@ int main(int argc, char* argv[])
|
|||||||
parser.addOption(triangleOption);
|
parser.addOption(triangleOption);
|
||||||
parser.addOption(sequenceOption);
|
parser.addOption(sequenceOption);
|
||||||
parser.addPositionalArgument("files", "Point cloud or segment files to load.");
|
parser.addPositionalArgument("files", "Point cloud or segment files to load.");
|
||||||
|
if (app.arguments().contains(QStringLiteral("--help")) ||
|
||||||
|
app.arguments().contains(QStringLiteral("-h"))) {
|
||||||
|
parser.showHelp(0);
|
||||||
|
}
|
||||||
|
if (app.arguments().contains(QStringLiteral("--version")) ||
|
||||||
|
app.arguments().contains(QStringLiteral("-v"))) {
|
||||||
|
parser.showVersion();
|
||||||
|
}
|
||||||
parser.process(app);
|
parser.process(app);
|
||||||
|
|
||||||
CloudViewMainWindow::StartupFiles startupFiles;
|
CloudViewMainWindow::StartupFiles startupFiles;
|
||||||
|
|||||||
@ -4,6 +4,13 @@ CONFIG += c++17 staticlib
|
|||||||
TEMPLATE = lib
|
TEMPLATE = lib
|
||||||
TARGET = CloudView3D
|
TARGET = CloudView3D
|
||||||
|
|
||||||
|
win32:CONFIG(debug, debug|release) {
|
||||||
|
DESTDIR = $$PWD/debug
|
||||||
|
}
|
||||||
|
win32:CONFIG(release, debug|release) {
|
||||||
|
DESTDIR = $$PWD/release
|
||||||
|
}
|
||||||
|
|
||||||
win32-msvc {
|
win32-msvc {
|
||||||
QMAKE_CXXFLAGS += /utf-8
|
QMAKE_CXXFLAGS += /utf-8
|
||||||
QMAKE_CXXFLAGS += /bigobj
|
QMAKE_CXXFLAGS += /bigobj
|
||||||
|
|||||||
@ -4,6 +4,7 @@
|
|||||||
#include <QOpenGLWidget>
|
#include <QOpenGLWidget>
|
||||||
#include <QOpenGLFunctions>
|
#include <QOpenGLFunctions>
|
||||||
#include <QOpenGLBuffer>
|
#include <QOpenGLBuffer>
|
||||||
|
#include <QOpenGLShaderProgram>
|
||||||
#include <QMatrix4x4>
|
#include <QMatrix4x4>
|
||||||
#include <QVector3D>
|
#include <QVector3D>
|
||||||
#include <QQuaternion>
|
#include <QQuaternion>
|
||||||
@ -11,8 +12,13 @@
|
|||||||
#include <QWheelEvent>
|
#include <QWheelEvent>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "CloudView3DTypes.h"
|
#include "CloudView3DTypes.h"
|
||||||
#include "VZNL_Types.h"
|
#include "VZNL_Types.h"
|
||||||
|
|
||||||
|
class QToolButton;
|
||||||
|
class QPushButton;
|
||||||
|
class QPinchGesture;
|
||||||
|
class QResizeEvent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief 点云显示颜色枚举
|
* @brief 点云显示颜色枚举
|
||||||
@ -84,58 +90,58 @@ struct SelectedLineInfo
|
|||||||
/**
|
/**
|
||||||
* @brief 线段数据
|
* @brief 线段数据
|
||||||
*/
|
*/
|
||||||
struct LineSegment
|
struct LineSegment
|
||||||
{
|
{
|
||||||
float x1, y1, z1; // 起点
|
float x1, y1, z1; // 起点
|
||||||
float x2, y2, z2; // 终点
|
float x2, y2, z2; // 终点
|
||||||
float r, g, b; // 颜色 (0-1)
|
float r, g, b; // 颜色 (0-1)
|
||||||
float lineWidth; // 线宽,0 表示使用默认值(来自 RGBA 中 A > 1 的值)
|
float lineWidth; // 线宽,0 表示使用默认值(来自 RGBA 中 A > 1 的值)
|
||||||
|
|
||||||
LineSegment() : x1(0), y1(0), z1(0), x2(0), y2(0), z2(0), r(1), g(1), b(1), lineWidth(0) {}
|
LineSegment() : x1(0), y1(0), z1(0), x2(0), y2(0), z2(0), r(1), g(1), b(1), lineWidth(0) {}
|
||||||
LineSegment(float _x1, float _y1, float _z1, float _x2, float _y2, float _z2, float _r = 1.0f, float _g = 1.0f, float _b = 1.0f, float _lw = 0)
|
LineSegment(float _x1, float _y1, float _z1, float _x2, float _y2, float _z2, float _r = 1.0f, float _g = 1.0f, float _b = 1.0f, float _lw = 0)
|
||||||
: x1(_x1), y1(_y1), z1(_z1), x2(_x2), y2(_y2), z2(_z2), r(_r), g(_g), b(_b), lineWidth(_lw) {}
|
: x1(_x1), y1(_y1), z1(_z1), x2(_x2), y2(_y2), z2(_z2), r(_r), g(_g), b(_b), lineWidth(_lw) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief 面片数据
|
* @brief 面片数据
|
||||||
*/
|
*/
|
||||||
struct SurfaceQuad
|
struct SurfaceQuad
|
||||||
{
|
{
|
||||||
QVector3D p1, p2, p3, p4;
|
QVector3D p1, p2, p3, p4;
|
||||||
float r, g, b, a;
|
float r, g, b, a;
|
||||||
|
|
||||||
SurfaceQuad() : p1(), p2(), p3(), p4(), r(0.0f), g(0.8f), b(1.0f), a(0.5f) {}
|
SurfaceQuad() : p1(), p2(), p3(), p4(), r(0.0f), g(0.8f), b(1.0f), a(0.5f) {}
|
||||||
SurfaceQuad(const QVector3D& _p1,
|
SurfaceQuad(const QVector3D& _p1,
|
||||||
const QVector3D& _p2,
|
const QVector3D& _p2,
|
||||||
const QVector3D& _p3,
|
const QVector3D& _p3,
|
||||||
const QVector3D& _p4,
|
const QVector3D& _p4,
|
||||||
float _r = 0.0f,
|
float _r = 0.0f,
|
||||||
float _g = 0.8f,
|
float _g = 0.8f,
|
||||||
float _b = 1.0f,
|
float _b = 1.0f,
|
||||||
float _a = 0.5f)
|
float _a = 0.5f)
|
||||||
: p1(_p1), p2(_p2), p3(_p3), p4(_p4), r(_r), g(_g), b(_b), a(_a) {}
|
: p1(_p1), p2(_p2), p3(_p3), p4(_p4), r(_r), g(_g), b(_b), a(_a) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct BasicShapePoint
|
struct BasicShapePoint
|
||||||
{
|
{
|
||||||
float x, y, z;
|
float x, y, z;
|
||||||
float r, g, b;
|
float r, g, b;
|
||||||
float pointSize;
|
float pointSize;
|
||||||
|
|
||||||
BasicShapePoint() : x(0), y(0), z(0), r(1), g(1), b(1), pointSize(8.0f) {}
|
BasicShapePoint() : x(0), y(0), z(0), r(1), g(1), b(1), pointSize(8.0f) {}
|
||||||
BasicShapePoint(float _x,
|
BasicShapePoint(float _x,
|
||||||
float _y,
|
float _y,
|
||||||
float _z,
|
float _z,
|
||||||
float _r = 1.0f,
|
float _r = 1.0f,
|
||||||
float _g = 1.0f,
|
float _g = 1.0f,
|
||||||
float _b = 1.0f,
|
float _b = 1.0f,
|
||||||
float _size = 8.0f)
|
float _size = 8.0f)
|
||||||
: x(_x), y(_y), z(_z), r(_r), g(_g), b(_b), pointSize(_size) {}
|
: x(_x), y(_y), z(_z), r(_r), g(_g), b(_b), pointSize(_size) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief 姿态点数据
|
* @brief 姿态点数据
|
||||||
*
|
*
|
||||||
* 坐标系约定(右手坐标系):
|
* 坐标系约定(右手坐标系):
|
||||||
* - X轴:红色,指向右
|
* - X轴:红色,指向右
|
||||||
* - Y轴:绿色,指向上
|
* - Y轴:绿色,指向上
|
||||||
@ -170,12 +176,13 @@ public:
|
|||||||
|
|
||||||
void addPointCloud(const PointCloudXYZ& cloud, const QString& name = "");
|
void addPointCloud(const PointCloudXYZ& cloud, const QString& name = "");
|
||||||
void addPointCloud(const PointCloudXYZRGB& cloud, const QString& name = "");
|
void addPointCloud(const PointCloudXYZRGB& cloud, const QString& name = "");
|
||||||
|
void appendPointCloud(const PointCloudXYZRGB& cloud, const QString& name = "");
|
||||||
void clearPointClouds();
|
void clearPointClouds();
|
||||||
void setPointCloudColor(PointCloudColor color);
|
void setPointCloudColor(PointCloudColor color);
|
||||||
void setPointSize(float size);
|
void setPointSize(float size);
|
||||||
void resetView();
|
void resetView();
|
||||||
void fitToContent();
|
void fitToContent();
|
||||||
void zoomIn();
|
void zoomIn();
|
||||||
void zoomOut();
|
void zoomOut();
|
||||||
/**
|
/**
|
||||||
* @brief 设置视角旋转角度(不改变缩放和平移)
|
* @brief 设置视角旋转角度(不改变缩放和平移)
|
||||||
@ -307,26 +314,26 @@ public:
|
|||||||
*/
|
*/
|
||||||
void clearLineSegments();
|
void clearLineSegments();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief 设置基础图形线段
|
* @brief 设置基础图形线段
|
||||||
*/
|
*/
|
||||||
void setBasicShapeSegments(const QVector<LineSegment>& segments);
|
void setBasicShapeSegments(const QVector<LineSegment>& segments);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief 追加基础图形线段
|
* @brief 追加基础图形线段
|
||||||
*/
|
*/
|
||||||
void appendBasicShapeSegments(const QVector<LineSegment>& segments);
|
void appendBasicShapeSegments(const QVector<LineSegment>& segments);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief 追加基础图形面片
|
* @brief 追加基础图形面片
|
||||||
*/
|
*/
|
||||||
void appendBasicShapeSurfaces(const QVector<SurfaceQuad>& surfaces);
|
void appendBasicShapeSurfaces(const QVector<SurfaceQuad>& surfaces);
|
||||||
void appendBasicShapePoints(const QVector<BasicShapePoint>& points);
|
void appendBasicShapePoints(const QVector<BasicShapePoint>& points);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief 清除基础图形线段
|
* @brief 清除基础图形线段
|
||||||
*/
|
*/
|
||||||
void clearBasicShapeSegments();
|
void clearBasicShapeSegments();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief 添加姿态点
|
* @brief 添加姿态点
|
||||||
@ -338,20 +345,21 @@ public:
|
|||||||
*/
|
*/
|
||||||
void clearPosePoints();
|
void clearPosePoints();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void pointSelected(const SelectedPointInfo& point);
|
void pointSelected(const SelectedPointInfo& point);
|
||||||
void twoPointsSelected(const SelectedPointInfo& p1, const SelectedPointInfo& p2, float distance);
|
void twoPointsSelected(const SelectedPointInfo& p1, const SelectedPointInfo& p2, float distance);
|
||||||
void measurementFinished(const SelectedPointInfo& p1,
|
void measurementFinished(const SelectedPointInfo& p1,
|
||||||
const SelectedPointInfo& p2,
|
const SelectedPointInfo& p2,
|
||||||
float distance,
|
float distance,
|
||||||
float dx,
|
float dx,
|
||||||
float dy,
|
float dy,
|
||||||
float dz);
|
float dz);
|
||||||
void lineSelected(const SelectedLineInfo& line);
|
void lineSelected(const SelectedLineInfo& line);
|
||||||
void viewAnglesChanged(float rotX, float rotY, float rotZ);
|
void viewAnglesChanged(float rotX, float rotY, float rotZ);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void initializeGL() override;
|
bool event(QEvent* event) override;
|
||||||
|
void initializeGL() override;
|
||||||
void resizeGL(int w, int h) override;
|
void resizeGL(int w, int h) override;
|
||||||
void paintGL() override;
|
void paintGL() override;
|
||||||
void mousePressEvent(QMouseEvent* event) override;
|
void mousePressEvent(QMouseEvent* event) override;
|
||||||
@ -360,6 +368,7 @@ protected:
|
|||||||
void wheelEvent(QWheelEvent* event) override;
|
void wheelEvent(QWheelEvent* event) override;
|
||||||
void mouseDoubleClickEvent(QMouseEvent* event) override;
|
void mouseDoubleClickEvent(QMouseEvent* event) override;
|
||||||
void keyPressEvent(QKeyEvent* event) override;
|
void keyPressEvent(QKeyEvent* event) override;
|
||||||
|
void resizeEvent(QResizeEvent* event) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct PointCloudData
|
struct PointCloudData
|
||||||
@ -455,31 +464,68 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
void computeBoundingBox();
|
void computeBoundingBox();
|
||||||
void setCurrentColor(PointCloudColor color);
|
void updateProjection(const QMatrix4x4& modelView);
|
||||||
void setColorByIndex(int colorIndex); // 根据索引设置颜色
|
float fittedCameraDistance(float padding = 1.05f) const;
|
||||||
|
float minimumCameraDistance() const;
|
||||||
|
QVector3D colorForIndex(int colorIndex) const;
|
||||||
SelectedPointInfo pickPoint(int screenX, int screenY);
|
SelectedPointInfo pickPoint(int screenX, int screenY);
|
||||||
void drawSelectedPoints();
|
void drawSelectedPoints();
|
||||||
void drawMeasurementLine();
|
void drawMeasurementLine();
|
||||||
void drawAxis();
|
void drawAxis();
|
||||||
void drawSelectedLine(); // 绘制选中的线
|
void drawSelectedLine(); // 绘制选中的线
|
||||||
void drawLineSegments(); // 绘制线段
|
void drawLineSegments(); // 绘制线段
|
||||||
void drawBasicShapeSurfaces(); // 绘制基础图形面片
|
void drawBasicShapeSurfaces(); // 绘制基础图形面片
|
||||||
void drawBasicShapeSegments(); // 绘制基础图形
|
void drawBasicShapeSegments(); // 绘制基础图形
|
||||||
void drawBasicShapePoints();
|
void drawBasicShapePoints();
|
||||||
void drawLineSegmentList(const QVector<LineSegment>& segments);
|
void drawLineSegmentList(const QVector<LineSegment>& segments);
|
||||||
void drawPosePoints(); // 绘制姿态点
|
void drawPosePoints(); // 绘制姿态点
|
||||||
void drawAxisLabels(); // 绘制坐标轴 XYZ 标注
|
void drawAxisLabels(); // 绘制坐标轴 XYZ 标注
|
||||||
void uploadToVBO(PointCloudData& data); // 上传数据到 VBO
|
void uploadToVBO(PointCloudData& data); // 上传数据到 VBO
|
||||||
void releaseVBO(PointCloudData& data); // 释放 VBO 资源
|
void releaseVBO(PointCloudData& data); // 释放 VBO 资源
|
||||||
|
|
||||||
|
// GLES2 shader 渲染
|
||||||
|
bool ensureShader();
|
||||||
|
void drawCloud(PointCloudData& data, float pointSize);
|
||||||
|
void drawPrimitives(const QMatrix4x4& mvp,
|
||||||
|
const float* positions,
|
||||||
|
int vertexCount,
|
||||||
|
GLenum mode,
|
||||||
|
const float* colors,
|
||||||
|
const QVector3D& uniformColor,
|
||||||
|
float pointSize,
|
||||||
|
float alpha,
|
||||||
|
bool depthTest);
|
||||||
|
void resetRenderState();
|
||||||
|
|
||||||
|
// 覆盖控件:左侧竖向视图按钮 / 左下角旋转角度 / 右侧缩放
|
||||||
|
void createOverlayControls();
|
||||||
|
void repositionOverlayControls();
|
||||||
|
void showViewAngleDialog();
|
||||||
|
void updateViewAngleDisplay();
|
||||||
|
bool handlePinchGesture(QPinchGesture* gesture);
|
||||||
|
|
||||||
std::vector<PointCloudData> m_pointClouds;
|
std::vector<PointCloudData> m_pointClouds;
|
||||||
|
|
||||||
QMatrix4x4 m_projection;
|
QMatrix4x4 m_projection;
|
||||||
QMatrix4x4 m_view;
|
QMatrix4x4 m_view;
|
||||||
QMatrix4x4 m_model;
|
QMatrix4x4 m_model;
|
||||||
|
QMatrix4x4 m_mvp; // 当前帧的模型视图投影矩阵(点云主渲染用)
|
||||||
|
|
||||||
float m_distance;
|
// GLES2 shader 渲染资源
|
||||||
float m_rotationX;
|
QOpenGLShaderProgram* m_shader;
|
||||||
|
QOpenGLBuffer m_dynamicVbo; // 动态叠加图元(选中点/线/轴/姿态等)的临时 VBO
|
||||||
|
bool m_shaderReady;
|
||||||
|
GLint m_mvpLocation;
|
||||||
|
GLint m_positionLocation;
|
||||||
|
GLint m_colorLocation;
|
||||||
|
GLint m_pointSizeLocation;
|
||||||
|
GLint m_alphaLocation;
|
||||||
|
GLint m_useVertexColorLocation;
|
||||||
|
GLint m_uniformColorLocation;
|
||||||
|
|
||||||
|
float m_distance;
|
||||||
|
float m_pinchStartDistance;
|
||||||
|
float m_rotationX;
|
||||||
float m_rotationY;
|
float m_rotationY;
|
||||||
float m_rotationZ;
|
float m_rotationZ;
|
||||||
QQuaternion m_rotation; // 使用四元数存储旋转状态
|
QQuaternion m_rotation; // 使用四元数存储旋转状态
|
||||||
@ -510,12 +556,19 @@ private:
|
|||||||
int m_colorIndex; // 颜色轮换索引
|
int m_colorIndex; // 颜色轮换索引
|
||||||
static const int COLOR_COUNT = 7; // 可用颜色数量
|
static const int COLOR_COUNT = 7; // 可用颜色数量
|
||||||
|
|
||||||
// 线段和姿态点数据
|
// 线段和姿态点数据
|
||||||
QVector<LineSegment> m_lineSegments;
|
QVector<LineSegment> m_lineSegments;
|
||||||
QVector<LineSegment> m_basicShapeSegments;
|
QVector<LineSegment> m_basicShapeSegments;
|
||||||
QVector<SurfaceQuad> m_basicShapeSurfaces;
|
QVector<SurfaceQuad> m_basicShapeSurfaces;
|
||||||
QVector<BasicShapePoint> m_basicShapePoints;
|
QVector<BasicShapePoint> m_basicShapePoints;
|
||||||
QVector<PosePoint> m_posePoints;
|
QVector<PosePoint> m_posePoints;
|
||||||
};
|
|
||||||
|
// 覆盖控件
|
||||||
|
QWidget* m_viewToolbar; // 左侧竖向视图按钮容器
|
||||||
|
QVector<QToolButton*> m_viewButtons;
|
||||||
|
QPushButton* m_viewAngleButton; // 左下角旋转角度显示按钮
|
||||||
|
QToolButton* m_zoomInButton;
|
||||||
|
QToolButton* m_zoomOutButton;
|
||||||
|
};
|
||||||
|
|
||||||
#endif // POINT_CLOUD_GL_WIDGET_H
|
#endif // POINT_CLOUD_GL_WIDGET_H
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
15
Utils.pro
15
Utils.pro
@ -11,18 +11,9 @@ CloudView.file = CloudView/CloudView.pro
|
|||||||
# 添加子项目
|
# 添加子项目
|
||||||
SUBDIRS += \
|
SUBDIRS += \
|
||||||
VrCommon \
|
VrCommon \
|
||||||
VrUtils
|
VrUtils \
|
||||||
|
CloudView3D \
|
||||||
!equals(TARGET_APP, "ParkingSpaceGuideView") {
|
CloudView
|
||||||
SUBDIRS += \
|
|
||||||
CloudUtils \
|
|
||||||
DataUtils
|
|
||||||
}
|
|
||||||
|
|
||||||
win32-msvc:!equals(TARGET_APP, "ParkingSpaceGuideView") {
|
|
||||||
SUBDIRS += \
|
|
||||||
CloudView3D \
|
|
||||||
CloudView
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# 设置依赖关系
|
# 设置依赖关系
|
||||||
|
|||||||
@ -1,10 +1,17 @@
|
|||||||
#CONFIG -= qt
|
#CONFIG -= qt
|
||||||
|
|
||||||
TEMPLATE = lib
|
TEMPLATE = lib
|
||||||
CONFIG += staticlib
|
CONFIG += staticlib
|
||||||
CONFIG += c++17
|
CONFIG += c++17
|
||||||
|
|
||||||
# You can make your code fail to compile if it uses deprecated APIs.
|
win32:CONFIG(debug, debug|release) {
|
||||||
|
DESTDIR = $$PWD/debug
|
||||||
|
}
|
||||||
|
win32:CONFIG(release, debug|release) {
|
||||||
|
DESTDIR = $$PWD/release
|
||||||
|
}
|
||||||
|
|
||||||
|
# You can make your code fail to compile if it uses deprecated APIs.
|
||||||
# In order to do so, uncomment the following line.
|
# In order to do so, uncomment the following line.
|
||||||
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
|
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
|
||||||
|
|
||||||
|
|||||||
@ -6,9 +6,16 @@ DEFINES += TINYXML2_EXPORT
|
|||||||
DEFINES += HAVE_SNPRINTF
|
DEFINES += HAVE_SNPRINTF
|
||||||
DEFINES += LOG4CPP_HAVE_SSTREAM=1
|
DEFINES += LOG4CPP_HAVE_SSTREAM=1
|
||||||
DEFINES += VR_UTILS_EXPORTS
|
DEFINES += VR_UTILS_EXPORTS
|
||||||
CONFIG += c++11
|
CONFIG += c++11
|
||||||
|
|
||||||
# Unix平台特定配置
|
win32:CONFIG(debug, debug|release) {
|
||||||
|
DESTDIR = $$PWD/debug
|
||||||
|
}
|
||||||
|
win32:CONFIG(release, debug|release) {
|
||||||
|
DESTDIR = $$PWD/release
|
||||||
|
}
|
||||||
|
|
||||||
|
# Unix平台特定配置
|
||||||
unix:!macx {
|
unix:!macx {
|
||||||
DEFINES += LOG4CPP_HAVE_UNISTD_H
|
DEFINES += LOG4CPP_HAVE_UNISTD_H
|
||||||
# 确保所有符号导出(对于静态库)
|
# 确保所有符号导出(对于静态库)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user