92 lines
3.1 KiB
C++
92 lines
3.1 KiB
C++
#ifndef DRONESCREWCTRL_MAINWINDOW_H
|
||
#define DRONESCREWCTRL_MAINWINDOW_H
|
||
|
||
#include <QMainWindow>
|
||
#include <QImage>
|
||
#include <QLabel>
|
||
#include <QGraphicsScene>
|
||
#include <QGraphicsPixmapItem>
|
||
#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(); // 算法参数
|
||
void on_btn_test_clicked(); // 单次检测
|
||
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();
|
||
|
||
// 顶部按钮状态机
|
||
enum class UiState { Idle, Live, Detect };
|
||
void applyUiState(UiState s);
|
||
UiState m_uiState{UiState::Idle};
|
||
|
||
// 页面布局
|
||
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 读取的参数缓存
|
||
};
|
||
|
||
#endif // DRONESCREWCTRL_MAINWINDOW_H
|