完成主要交互、高性能组件、国际化和A型传感器数据包接收

This commit is contained in:
2026-01-13 16:34:28 +08:00
parent 47e6dc7244
commit 1960e6a5b9
84 changed files with 7752 additions and 332 deletions

View File

@@ -1,10 +1,11 @@
//
// Created by Lenn on 2025/12/16.
//
#ifndef TACTILEIPC3D_GLWIDGET_H
#define TACTILEIPC3D_GLWIDGET_H
#include <qopenglshaderprogram.h>
#include <QOpenGLWidget>
#include <QOpenGLFunctions>
#include <QMutex>
@@ -14,10 +15,18 @@
#include <QVector3D>
#include <QString>
#include <atomic>
#include <qtmetamacros.h>
#include <qvectornd.h>
struct Ray {
QVector3D origin;
QVector3D dir;
};
class GLWidget : public QOpenGLWidget, protected QOpenGLFunctions_3_3_Core {
Q_OBJECT
Q_PROPERTY(float yaw READ yaw WRITE setYaw NOTIFY yawChanged)
// Q_PROPERTY(bool showGrid READ showGrid WRITE setShowGrid NOTIFY showGridChanged)
public:
enum RenderMode {
Realistic = 0,
@@ -48,15 +57,23 @@ public:
float yaw() const { return m_camYawDeg; }
bool showGrid() const { return m_showGrid; }
public slots:
// 值域范围,用于 shader 里把 value 映射到颜色(绿->红)
void setRange(int minV, int maxV);
void setYaw(float yawDeg);
void setRenderModeString(const QString& mode);
void setLabelModeString(const QString& mode);
void setLightMode(bool on);
void setShowBg(bool on);
void setShowGrid(bool on);
signals:
void yawChanged();
void dotClicked(int index, int row, int col, float value);
protected:
void initializeGL() override;
@@ -73,9 +90,12 @@ private:
void initBackgroundGeometry_();
void initPrograms_();
void initDotTexture_();
void initRoomGeometry_();
void updateInstanceBufferIfNeeded_();
void updateMatrices_();
void updateRoom_();
bool projectToScreen_(const QVector3D& world, QPointF* out) const;
int pickDotIndex_(const QPoint& pos, QVector3D* worldOut) const;
private:
// 传感值范围(用于颜色映射)
int m_min = 0;
@@ -86,9 +106,9 @@ private:
int m_cols = 4;
// panel: 一个长方体/板子(当前只画顶面矩形)
float m_panelW = 1.2f;
float m_panelH = 0.08f;
float m_panelD = 0.08f;
float m_panelW = 0.25f;
float m_panelH = 0.35f;
float m_panelD = 0.05f;
// 点阵布局参数
float m_pitch = 0.1f;
@@ -103,6 +123,7 @@ private:
// shader program编译/链接后的可执行 GPU 程序)
QOpenGLShaderProgram* m_bgProg = nullptr;
QOpenGLShaderProgram* m_roomProg = nullptr;
QOpenGLShaderProgram* m_panelProg = nullptr;
QOpenGLShaderProgram* m_dotsProg = nullptr;
@@ -119,11 +140,20 @@ private:
unsigned int m_dotsVao = 0;
unsigned int m_dotsVbo = 0;
unsigned int m_instanceVbo = 0;
unsigned int room_vao = 0;
unsigned int room_vbo = 0;
unsigned int room_ibo = 0;
int room_index_count = 0;
bool m_showGrid = true;
int m_instanceCount = 0;
bool m_dotsGeometryDirty = false;
unsigned int m_bgVao = 0;
unsigned int m_bgVbo = 0;
bool m_lightMode = true;
bool m_showBg = true;
// MVP = Projection * View * Model。
// 这里 panel/dots 顶点基本已经是“世界坐标”,所以我们用 proj*view 即可model 先省略)。
@@ -140,11 +170,12 @@ private:
float m_modelPanel[16]{};
float m_zoom_ = 45.0;
float m_camYawDeg = 45.0f;
float m_camPitchDeg = 35.0f;
float m_camYawDeg = -90.0f;
float m_camPitchDeg = 0.0f;
std::atomic<bool> m_rightDown{false};
QPoint m_lastPos;
};