239 lines
7.0 KiB
C++
239 lines
7.0 KiB
C++
#ifndef MAINWINDOW_H
|
||
#define MAINWINDOW_H
|
||
|
||
#include <QMainWindow>
|
||
#include <QTimer>
|
||
#include <QDateTime>
|
||
#include <memory>
|
||
#include <pcl/point_cloud.h>
|
||
#include <pcl/point_types.h>
|
||
|
||
class ConfigManager;
|
||
class NetworkManager;
|
||
class DeviceScanner;
|
||
class GVSPParser;
|
||
class PointCloudProcessor;
|
||
class PointCloudWidget;
|
||
struct DeviceInfo;
|
||
class QListWidget;
|
||
class QListWidgetItem;
|
||
class QPushButton;
|
||
class QSlider;
|
||
class QSpinBox;
|
||
class QLabel;
|
||
class QImage;
|
||
|
||
class MainWindow : public QMainWindow
|
||
{
|
||
Q_OBJECT
|
||
|
||
public:
|
||
explicit MainWindow(QWidget *parent = nullptr);
|
||
~MainWindow();
|
||
|
||
private slots:
|
||
// 相机控制槽函数
|
||
void onStartClicked();
|
||
void onStopClicked();
|
||
void onExposureChanged(int value);
|
||
void onCaptureClicked();
|
||
void onBrowseSavePathClicked();
|
||
|
||
// 网络配置槽函数
|
||
void onConnectClicked();
|
||
void onIpAddressChanged(const QString &ip);
|
||
void onControlPortChanged(int port);
|
||
void onDataPortChanged(int port);
|
||
void onNetworkConnected();
|
||
void onNetworkDisconnected();
|
||
void onDataReceived(const QByteArray &data);
|
||
|
||
// GVSP数据处理槽函数
|
||
void onImageReceived(const QImage &image, uint32_t blockId);
|
||
void onLeftImageReceived(const QByteArray &jpegData, uint32_t blockId);
|
||
void onRightImageReceived(const QByteArray &jpegData, uint32_t blockId);
|
||
void onRgbImageReceived(const QByteArray &jpegData, uint32_t blockId);
|
||
void onDepthDataReceived(const QByteArray &depthData, uint32_t blockId);
|
||
void onPointCloudDataReceived(const QByteArray &cloudData, uint32_t blockId);
|
||
void onPointCloudReady(pcl::PointCloud<pcl::PointXYZ>::Ptr cloud, uint32_t blockId);
|
||
|
||
// 设备扫描槽函数
|
||
void onRefreshClicked();
|
||
void onDeviceFound(const DeviceInfo &device);
|
||
void onScanProgress(int current, int total);
|
||
void onScanFinished(int devicesFound);
|
||
void onDeviceSelected(QListWidgetItem *item);
|
||
|
||
// 定时器更新
|
||
void updateUI();
|
||
|
||
// 日志槽函数
|
||
void onClearLogClicked();
|
||
void onSaveLogClicked();
|
||
|
||
protected:
|
||
// 重写事件处理函数以监听系统主题变化
|
||
void changeEvent(QEvent *event) override;
|
||
|
||
private:
|
||
void setupUI();
|
||
void setupConnections();
|
||
void loadSettings();
|
||
void saveSettings();
|
||
|
||
// 拍照辅助函数
|
||
bool saveDepthImage(const QString &dir, const QString &baseName, const QString &format);
|
||
bool savePointCloud(const QString &dir, const QString &baseName, const QString &format);
|
||
void performBackgroundSave(const QString &saveDir, const QString &baseName,
|
||
const QString &depthFormat, const QString &pointCloudFormat,
|
||
const QImage &image, pcl::PointCloud<pcl::PointXYZ>::Ptr cloud,
|
||
const QByteArray &leftIRData, const QByteArray &rightIRData,
|
||
const QByteArray &rgbData);
|
||
|
||
// 日志辅助函数
|
||
void addLog(const QString &message, const QString &level = "INFO");
|
||
void updateStatistics();
|
||
|
||
private:
|
||
// 核心管理器
|
||
std::unique_ptr<ConfigManager> m_configManager;
|
||
std::unique_ptr<NetworkManager> m_networkManager;
|
||
std::unique_ptr<DeviceScanner> m_deviceScanner;
|
||
std::unique_ptr<PointCloudProcessor> m_pointCloudProcessor;
|
||
|
||
// UI更新定时器
|
||
QTimer *m_updateTimer;
|
||
|
||
// 状态变量
|
||
bool m_isConnected;
|
||
|
||
// 当前帧数据(用于拍照)
|
||
QImage m_currentImage;
|
||
pcl::PointCloud<pcl::PointXYZ>::Ptr m_currentPointCloud;
|
||
uint32_t m_currentFrameId;
|
||
|
||
// 三个相机的原始JPEG数据(用于保存完整分辨率图像)
|
||
QByteArray m_currentLeftIRData;
|
||
QByteArray m_currentRightIRData;
|
||
QByteArray m_currentRgbData;
|
||
|
||
// UI控件指针
|
||
class QWidget *m_centralWidget;
|
||
class QSplitter *m_mainSplitter;
|
||
class QWidget *m_controlPanel;
|
||
class QLabel *m_imageDisplay; // 兼容旧代码
|
||
PointCloudWidget *m_pointCloudWidget;
|
||
|
||
// 三个图像显示控件
|
||
QLabel *m_leftImageDisplay;
|
||
QLabel *m_rightImageDisplay;
|
||
QLabel *m_rgbImageDisplay;
|
||
|
||
// 按钮控件
|
||
QPushButton *m_refreshBtn;
|
||
QPushButton *m_connectBtn;
|
||
QPushButton *m_startBtn;
|
||
QPushButton *m_stopBtn;
|
||
QPushButton *m_captureBtn;
|
||
|
||
// 数据传输开关按钮
|
||
QPushButton *m_leftIRToggle;
|
||
QPushButton *m_rightIRToggle;
|
||
QPushButton *m_rgbToggle;
|
||
QPushButton *m_pointCloudColorToggle; // 点云颜色开关
|
||
QPushButton *m_pointCloudDenoiseToggle; // Point cloud denoise toggle
|
||
|
||
// 单目/双目模式切换按钮
|
||
QPushButton *m_monocularBtn;
|
||
QPushButton *m_binocularBtn;
|
||
|
||
// 输入控件
|
||
QSlider *m_exposureSlider;
|
||
QSpinBox *m_exposureSpinBox;
|
||
QSpinBox *m_ctrlPortSpinBox;
|
||
QSpinBox *m_dataPortSpinBox;
|
||
|
||
// 拍照参数控件
|
||
class QLineEdit *m_savePathEdit;
|
||
QPushButton *m_browseSavePathBtn;
|
||
class QComboBox *m_depthFormatCombo;
|
||
class QComboBox *m_pointCloudFormatCombo;
|
||
QSlider *m_denoiseSupportSlider;
|
||
QSpinBox *m_denoiseSupportSpinBox;
|
||
QSlider *m_denoiseTailSlider;
|
||
QSpinBox *m_denoiseTailSpinBox;
|
||
QSlider *m_denoiseBandSlider;
|
||
QSpinBox *m_denoiseBandSpinBox;
|
||
|
||
// 显示控件
|
||
QLabel *m_statusLabel;
|
||
QListWidget *m_deviceList;
|
||
|
||
// 统计信息控件
|
||
QLabel *m_depthFpsLabel;
|
||
QLabel *m_pointCloudFpsLabel;
|
||
QLabel *m_resolutionLabel;
|
||
QLabel *m_queueLabel;
|
||
|
||
// 三个相机的FPS标签
|
||
QLabel *m_leftFpsLabel;
|
||
QLabel *m_rightFpsLabel;
|
||
QLabel *m_rgbFpsLabel;
|
||
|
||
// 日志显示控件
|
||
class QTextEdit *m_logDisplay;
|
||
QPushButton *m_clearLogBtn;
|
||
QPushButton *m_saveLogBtn;
|
||
|
||
// 统计数据 - 深度图
|
||
QDateTime m_lastDepthFrameTime;
|
||
int m_depthFrameCount;
|
||
int m_totalDepthFrameCount;
|
||
double m_currentDepthFps;
|
||
|
||
// 统计数据 - 点云
|
||
QDateTime m_lastPointCloudFrameTime;
|
||
int m_pointCloudFrameCount;
|
||
int m_totalPointCloudFrameCount;
|
||
double m_currentPointCloudFps;
|
||
|
||
// 统计数据 - 左红外
|
||
QDateTime m_lastLeftFrameTime;
|
||
int m_leftFrameCount;
|
||
int m_totalLeftFrameCount;
|
||
double m_currentLeftFps;
|
||
|
||
// 统计数据 - 右红外
|
||
QDateTime m_lastRightFrameTime;
|
||
int m_rightFrameCount;
|
||
int m_totalRightFrameCount;
|
||
double m_currentRightFps;
|
||
|
||
// 统计数据 - RGB
|
||
QDateTime m_lastRgbFrameTime;
|
||
int m_rgbFrameCount;
|
||
int m_totalRgbFrameCount;
|
||
double m_currentRgbFps;
|
||
|
||
// 解码处理标志(防止线程积压导致闪烁)
|
||
QAtomicInt m_rgbProcessing;
|
||
QAtomicInt m_leftIRProcessing;
|
||
QAtomicInt m_rightIRProcessing;
|
||
QAtomicInt m_pointCloudProcessing;
|
||
QAtomicInt m_pointCloudDropCounter;
|
||
bool m_leftIrDisplayRangeInited;
|
||
float m_leftIrDisplayMin;
|
||
float m_leftIrDisplayMax;
|
||
bool m_rightIrDisplayRangeInited;
|
||
float m_rightIrDisplayMin;
|
||
float m_rightIrDisplayMax;
|
||
int m_rgbSkipCounter; // RGB帧跳过计数器
|
||
|
||
// 相机启用状态标志(防止关闭后闪烁)
|
||
QAtomicInt m_leftIREnabled;
|
||
QAtomicInt m_rightIREnabled;
|
||
QAtomicInt m_rgbEnabled;
|
||
};
|
||
|
||
#endif // MAINWINDOW_H
|