107 lines
3.5 KiB
C
107 lines
3.5 KiB
C
|
|
#ifndef DialogCameraLevel_H
|
||
|
|
#define DialogCameraLevel_H
|
||
|
|
|
||
|
|
#include <QDialog>
|
||
|
|
#include <QWidget>
|
||
|
|
#include <QComboBox>
|
||
|
|
#include <QLineEdit>
|
||
|
|
#include <QMessageBox>
|
||
|
|
#include <QThread>
|
||
|
|
#include <vector>
|
||
|
|
#include <mutex>
|
||
|
|
#include "IVrEyeDevice.h"
|
||
|
|
#include "WorkpiecePresenter.h"
|
||
|
|
#include "VZNL_Types.h"
|
||
|
|
|
||
|
|
|
||
|
|
// #define LEVEL_DEBUG_MODE
|
||
|
|
|
||
|
|
namespace Ui {
|
||
|
|
class DialogCameraLevel;
|
||
|
|
}
|
||
|
|
|
||
|
|
class DialogCameraLevel : public QDialog
|
||
|
|
{
|
||
|
|
Q_OBJECT
|
||
|
|
|
||
|
|
public:
|
||
|
|
explicit DialogCameraLevel(QWidget *parent = nullptr);
|
||
|
|
~DialogCameraLevel();
|
||
|
|
|
||
|
|
// Delete copy constructor and assignment operator due to atomic members
|
||
|
|
DialogCameraLevel(const DialogCameraLevel&) = delete;
|
||
|
|
DialogCameraLevel& operator=(const DialogCameraLevel&) = delete;
|
||
|
|
|
||
|
|
// 设置相机列表和presenter
|
||
|
|
void setCameraList(const std::vector<std::pair<std::string, IVrEyeDevice*>>& cameraList,
|
||
|
|
WorkpiecePresenter* presenter);
|
||
|
|
|
||
|
|
private slots:
|
||
|
|
void on_btn_apply_clicked();
|
||
|
|
void on_btn_cancel_clicked();
|
||
|
|
void on_combo_camera_currentIndexChanged(int index);
|
||
|
|
|
||
|
|
private:
|
||
|
|
Ui::DialogCameraLevel *ui;
|
||
|
|
|
||
|
|
// 相机列表和名称
|
||
|
|
std::vector<std::pair<std::string, IVrEyeDevice*>> m_cameraList;
|
||
|
|
WorkpiecePresenter* m_presenter = nullptr;
|
||
|
|
|
||
|
|
// 扫描数据缓存
|
||
|
|
std::vector<SVzNL3DLaserLine> m_scanDataCache;
|
||
|
|
std::mutex m_scanDataMutex;
|
||
|
|
|
||
|
|
// 状态回调相关
|
||
|
|
std::atomic<bool> m_swingFinished = false; // 摆动完成标志,同时表示扫描完成
|
||
|
|
std::atomic<bool> m_callbackRestored = false;
|
||
|
|
|
||
|
|
// 初始化相机选择框
|
||
|
|
void initializeCameraCombo();
|
||
|
|
|
||
|
|
// 执行相机调平
|
||
|
|
bool performCameraLeveling();
|
||
|
|
|
||
|
|
// 直接使用相机接口进行扫描
|
||
|
|
bool startCameraScan(int cameraIndex);
|
||
|
|
bool stopCameraScan(int cameraIndex);
|
||
|
|
|
||
|
|
// 检测数据回调函数
|
||
|
|
static void StaticDetectionCallback(EVzResultDataType eDataType, SVzLaserLineData* pLaserLinePoint, void* pUserData);
|
||
|
|
void DetectionCallback(EVzResultDataType eDataType, SVzLaserLineData* pLaserLinePoint);
|
||
|
|
|
||
|
|
// 状态回调函数
|
||
|
|
static void StaticStatusCallback(EVzDeviceWorkStatus eStatus, void* pExtData, unsigned int nDataLength, void* pInfoParam);
|
||
|
|
void StatusCallback(EVzDeviceWorkStatus eStatus, void* pExtData, unsigned int nDataLength, void* pInfoParam);
|
||
|
|
|
||
|
|
// 设置和恢复状态回调
|
||
|
|
void setLevelingStatusCallback();
|
||
|
|
void restorePresenterStatusCallback();
|
||
|
|
|
||
|
|
// 处理扫描到的地面数据进行调平计算
|
||
|
|
bool calculatePlaneCalibration(double planeCalib[9], double& planeHeight, double invRMatrix[9]);
|
||
|
|
|
||
|
|
// 清空扫描数据缓存
|
||
|
|
void clearScanDataCache();
|
||
|
|
|
||
|
|
// Debug模式方法
|
||
|
|
QString selectDebugDataFile();
|
||
|
|
bool loadDebugDataAndSimulateScan(const QString& filePath);
|
||
|
|
void simulateScanProcess();
|
||
|
|
|
||
|
|
// 更新调平结果显示
|
||
|
|
void updateLevelingResults(double planeCalib[9], double planeHeight, double invRMatrix[9]);
|
||
|
|
|
||
|
|
// 保存调平结果到配置
|
||
|
|
bool saveLevelingResults(double planeCalib[9], double planeHeight, double invRMatrix[9], int cameraIndex, const QString& cameraName);
|
||
|
|
|
||
|
|
// 加载相机标定数据
|
||
|
|
bool loadCameraCalibrationData(int cameraIndex, const QString& cameraName,
|
||
|
|
double planeCalib[9], double& planeHeight, double invRMatrix[9]);
|
||
|
|
|
||
|
|
// 检查并显示相机标定状态
|
||
|
|
void checkAndDisplayCalibrationStatus(int cameraIndex);
|
||
|
|
};
|
||
|
|
|
||
|
|
#endif // DialogCameraLevel_H
|