167 lines
4.9 KiB
C++
167 lines
4.9 KiB
C++
#ifndef MAINWINDOW_H
|
||
#define MAINWINDOW_H
|
||
|
||
#include <QMainWindow>
|
||
#include <QImage>
|
||
#include <QLabel>
|
||
#include <QPixmap>
|
||
#include <QListWidget>
|
||
#include <QListWidgetItem>
|
||
#include <QStandardItem>
|
||
#include <QStringListModel>
|
||
#include <QGraphicsView>
|
||
#include <QMenu>
|
||
#include <QAction>
|
||
#include "CommonDialogCamera.h"
|
||
#include "CommonDialogCameraLevel.h"
|
||
#include "DeviceStatusWidget.h"
|
||
#include "TunnelChannelPresenter.h"
|
||
|
||
QT_BEGIN_NAMESPACE
|
||
namespace Ui { class MainWindow; }
|
||
QT_END_NAMESPACE
|
||
|
||
class MainWindow : public QMainWindow, public IYTunnelChannelStatus
|
||
{
|
||
Q_OBJECT
|
||
|
||
public:
|
||
MainWindow(QWidget *parent = nullptr);
|
||
~MainWindow();
|
||
|
||
void updateStatusLog(const QString& message);
|
||
void clearDetectionLog();
|
||
void Init();
|
||
|
||
// 实现IYTunnelChannelStatus接口
|
||
virtual void OnStatusUpdate(const std::string& statusMessage) override;
|
||
virtual void OnDetectionResult(const TunnelDetectionResult& result) override;
|
||
virtual void OnCamera1StatusChanged(bool isConnected) override;
|
||
virtual void OnCamera2StatusChanged(bool isConnected) override;
|
||
virtual void OnRobotConnectionChanged(bool isConnected) override;
|
||
virtual void OnSerialConnectionChanged(bool isConnected) override;
|
||
virtual void OnCameraCountChanged(int cameraCount) override;
|
||
virtual void OnWorkStatusChanged(WorkStatus status) override;
|
||
|
||
// 海康相机2D图像更新
|
||
virtual void OnHikImageUpdated(const QImage& image) override;
|
||
|
||
protected:
|
||
// 事件过滤器(用于处理补光灯按钮在窗口resize时重新定位)
|
||
bool eventFilter(QObject* watched, QEvent* event) override;
|
||
|
||
signals:
|
||
// 工作状态更新信号
|
||
void workStatusUpdateRequested(WorkStatus status);
|
||
|
||
// 检测结果更新信号
|
||
void detectionResultUpdateRequested(const TunnelDetectionResult& result);
|
||
|
||
// 日志更新信号
|
||
void logUpdateRequested(const QString& message);
|
||
|
||
// 清空日志信号
|
||
void logClearRequested();
|
||
|
||
// 2D图像更新信号
|
||
void hikImageUpdateRequested(const QImage& image);
|
||
|
||
private slots:
|
||
|
||
// 工作状态更新槽函数
|
||
void updateWorkStatusLabel(WorkStatus status);
|
||
|
||
// 检测结果更新槽函数
|
||
void updateDetectionResultDisplay(const TunnelDetectionResult& result);
|
||
|
||
// 日志更新槽函数
|
||
void updateDetectionLog(const QString& message);
|
||
|
||
// 清空日志槽函数
|
||
void clearDetectionLogUI();
|
||
|
||
// 2D图像更新槽函数
|
||
void updateHikImageDisplay(const QImage& image);
|
||
|
||
// 处理相机点击事件
|
||
void onCameraClicked(int cameraIndex);
|
||
|
||
// UI操作相关槽
|
||
void on_btn_start_clicked();
|
||
void on_btn_stop_clicked();
|
||
|
||
void on_btn_camera_clicked();
|
||
|
||
void on_btn_algo_config_clicked();
|
||
|
||
void on_btn_camera_levelling_clicked();
|
||
|
||
void on_btn_hide_clicked();
|
||
|
||
void on_btn_close_clicked();
|
||
|
||
void on_btn_test_clicked();
|
||
|
||
// 右键菜单相关槽函数
|
||
void onSaveDetectionData();
|
||
|
||
// 补光灯控制槽函数
|
||
void onSupplementLightToggle();
|
||
|
||
|
||
private:
|
||
Ui::MainWindow * ui;
|
||
CommonDialogCamera* ui_dialogCamera = nullptr;
|
||
CommonDialogCameraLevel* ui_dialogCameraLevel = nullptr;
|
||
|
||
// 业务逻辑处理类
|
||
TunnelChannelPresenter* m_presenter = nullptr;
|
||
|
||
// 日志模型
|
||
QStringListModel* m_logModel = nullptr;
|
||
|
||
// 设备状态显示widget的引用
|
||
DeviceStatusWidget* m_deviceStatusWidget = nullptr;
|
||
|
||
// 当前选中的按钮(用于互斥控制)
|
||
QPushButton* m_selectedButton = nullptr;
|
||
|
||
// 右键菜单相关
|
||
QMenu* m_contextMenu = nullptr;
|
||
QAction* m_saveDataAction = nullptr;
|
||
|
||
void display3DImage(const QImage& image);
|
||
void display2DImage(const QImage& image);
|
||
|
||
// 添加检测结果到列表
|
||
void addDetectionResult(const TunnelDetectionResult& result);
|
||
|
||
// 设置按钮启用/禁用状态
|
||
void setButtonsEnabled(bool enabled);
|
||
|
||
// 按钮图像切换辅助函数
|
||
void setButtonImage(QPushButton* button, const QString& imagePath);
|
||
void setButtonSelectedState(QPushButton* button, bool selected);
|
||
void restoreAllButtonStates();
|
||
void setOtherButtonsEnabled(QPushButton* exceptButton, bool enabled);
|
||
|
||
// 右键菜单相关函数
|
||
void setupContextMenu();
|
||
void showContextMenu(const QPoint& pos, QGraphicsView* view);
|
||
bool saveDetectionDataToFile(const QString& filePath, int cameraIndex);
|
||
|
||
// 补光灯控制相关
|
||
void setupSupplementLightButton();
|
||
void updateSupplementLightButtonState(bool enabled);
|
||
|
||
private:
|
||
// 日志去重相关
|
||
QString m_lastLogMessage; // 最后一条日志消息(不含时间戳)
|
||
int m_lastLogCount = 0; // 最后一条日志的重复次数
|
||
|
||
// 补光灯按钮
|
||
QPushButton* m_btnSupplementLight = nullptr;
|
||
bool m_bSupplementLightOn = false;
|
||
};
|
||
#endif // MAINWINDOW_H
|