2026-06-26 17:55:15 +08:00
|
|
|
|
#ifndef DRONESCREWCTRL_MAINWINDOW_H
|
|
|
|
|
|
#define DRONESCREWCTRL_MAINWINDOW_H
|
|
|
|
|
|
|
|
|
|
|
|
#include <QMainWindow>
|
|
|
|
|
|
#include <QImage>
|
|
|
|
|
|
#include <QLabel>
|
|
|
|
|
|
#include <QGraphicsScene>
|
|
|
|
|
|
#include <QGraphicsPixmapItem>
|
2026-07-03 14:19:06 +08:00
|
|
|
|
#include <QDateTime>
|
2026-06-26 17:55:15 +08:00
|
|
|
|
#include <QSize>
|
|
|
|
|
|
#include <QStringListModel>
|
|
|
|
|
|
#include <QVBoxLayout>
|
|
|
|
|
|
#include "IYDroneScrewCtrlStatus.h"
|
|
|
|
|
|
#include "DeviceStatusWidget.h"
|
|
|
|
|
|
#include "DetectLogHelper.h"
|
|
|
|
|
|
#include "AboutDialog.h"
|
|
|
|
|
|
#include "WDRemoteDataTypes.h"
|
|
|
|
|
|
|
|
|
|
|
|
namespace Ui { class MainWindow; }
|
|
|
|
|
|
|
|
|
|
|
|
class DroneScrewCtrlPresenter;
|
|
|
|
|
|
|
|
|
|
|
|
class MainWindow : public QMainWindow, public IYDroneScrewCtrlStatus
|
|
|
|
|
|
{
|
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
explicit MainWindow(QWidget* parent = nullptr);
|
|
|
|
|
|
~MainWindow() override;
|
|
|
|
|
|
|
|
|
|
|
|
// IYDroneScrewCtrlStatus
|
|
|
|
|
|
void OnRtspFrame(const QImage& frame) override;
|
|
|
|
|
|
void OnDetectionResult(const CtrlDetectionFrame& result) override;
|
|
|
|
|
|
void OnWorkStatusChanged(CtrlWorkStatus status) override;
|
|
|
|
|
|
void OnServerConnectionChanged(bool connected) override;
|
|
|
|
|
|
void OnStatusMessage(const QString& msg) override;
|
|
|
|
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
|
|
// 顶部工具栏:两个按钮的状态机
|
|
|
|
|
|
// btn_start —— 主开关:空闲(start_image) ⟷ 运行(stop_all)
|
|
|
|
|
|
// btn_detect_start —— 开始检测(start_detect),仅实时显示状态下可用
|
|
|
|
|
|
void on_btn_start_clicked(); // 开始实时显示 / 停止(按当前状态切换)
|
|
|
|
|
|
void on_btn_detect_start_clicked(); // 开始检测(从实时显示切到检测)
|
|
|
|
|
|
void on_btn_close_clicked();
|
|
|
|
|
|
void on_btn_hide_clicked();
|
|
|
|
|
|
void on_btn_camera_clicked(); // 连接配置
|
|
|
|
|
|
void on_btn_algo_config_clicked(); // 算法参数
|
2026-07-03 14:19:06 +08:00
|
|
|
|
void on_btn_test_clicked(); // 历史数据
|
2026-06-26 17:55:15 +08:00
|
|
|
|
void onServerInfoReceived(const WDRemoteServerInfo& info); // 服务器参数接收
|
|
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
void resizeEvent(QResizeEvent* event) override;
|
|
|
|
|
|
bool eventFilter(QObject* obj, QEvent* event) override;
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
void initUi();
|
|
|
|
|
|
void renderDisplay();
|
|
|
|
|
|
void appendLog(const QString& msg);
|
|
|
|
|
|
void clampResultList();
|
2026-06-29 13:59:12 +08:00
|
|
|
|
void clearResultList();
|
2026-07-03 14:19:06 +08:00
|
|
|
|
bool refreshServerInfoFromServer();
|
|
|
|
|
|
QString historyRootDir() const;
|
|
|
|
|
|
QString finalResultHistoryKey(const CtrlDetectionFrame& result) const;
|
|
|
|
|
|
QString makeFinalResultHistoryText(const CtrlDetectionFrame& result,
|
|
|
|
|
|
const QDateTime& savedAt) const;
|
|
|
|
|
|
bool saveFinalResultHistory(const CtrlDetectionFrame& result);
|
2026-06-26 17:55:15 +08:00
|
|
|
|
|
|
|
|
|
|
// 顶部按钮状态机
|
|
|
|
|
|
enum class UiState { Idle, Live, Detect };
|
2026-06-29 13:59:12 +08:00
|
|
|
|
enum class ResultDisplayMode { Distance, Precision };
|
2026-06-26 17:55:15 +08:00
|
|
|
|
void applyUiState(UiState s);
|
|
|
|
|
|
UiState m_uiState{UiState::Idle};
|
2026-06-29 13:59:12 +08:00
|
|
|
|
ResultDisplayMode m_resultDisplayMode{ResultDisplayMode::Distance};
|
2026-06-26 17:55:15 +08:00
|
|
|
|
|
|
|
|
|
|
// 页面布局
|
|
|
|
|
|
void adjustLayoutForCameraCount(int cameraCount);
|
|
|
|
|
|
void setupSingleCameraLayout();
|
|
|
|
|
|
void setupMultiCameraLayout();
|
|
|
|
|
|
int getAvailableHeight();
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
Ui::MainWindow* ui{nullptr};
|
|
|
|
|
|
DroneScrewCtrlPresenter* m_pPresenter{nullptr};
|
|
|
|
|
|
|
|
|
|
|
|
// 显示画面(QGraphicsView + Scene + PixmapItem)
|
|
|
|
|
|
QGraphicsScene* m_pScene{nullptr};
|
|
|
|
|
|
QGraphicsPixmapItem* m_pPixmapItem{nullptr};
|
|
|
|
|
|
QImage m_currentImage;
|
|
|
|
|
|
QSize m_lastRenderImageSize;
|
|
|
|
|
|
QSize m_lastRenderViewSize;
|
|
|
|
|
|
|
|
|
|
|
|
// 公用组件
|
|
|
|
|
|
DeviceStatusWidget* m_deviceStatusWidget{nullptr};
|
|
|
|
|
|
DetectLogHelper* m_logHelper{nullptr};
|
|
|
|
|
|
QLabel* m_versionLabel{nullptr};
|
|
|
|
|
|
|
|
|
|
|
|
int m_maxResultItems{200};
|
|
|
|
|
|
WDRemoteServerInfo m_cachedServerInfo; // 从 Server 读取的参数缓存
|
2026-07-03 14:19:06 +08:00
|
|
|
|
QString m_lastStoredFinalResultKey;
|
2026-06-26 17:55:15 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif // DRONESCREWCTRL_MAINWINDOW_H
|