123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- #pragma once
- #include <QMainWindow>
- #include "ui_WindowRuntime.h"
- #include "Common.h"
- #include "WindowAppUiView.h"
- #include "selectwidget.h"
- /// <summary>
- /// Runtime界面
- /// </summary>
- class WindowAppUiView;
- class WindowRuntime : public QMainWindow
- {
- Q_OBJECT
- public:
- WindowRuntime(QWidget *parent = nullptr);
- ~WindowRuntime();
- // 启动所有的UI界面
- bool publishAllPages(WindowAppUiView* pMainPage, QMap<QString, WindowAppUiView*> allPages);
- // 执行指令
- bool runCmd(const QString& strCmd, const QString& strParam = "");
- // 执行Dll中的Tool Interface
- bool runDllInterface(
- const QString& strPouName,
- const QString& strToolName,
- const QString& strInfName,
- VALUE_TYPE controlType
- );
- // 系统命令 - 切换到指定页面
- bool switchToPage(const QString& strPageName);
- // 添加一个新的索引和控件对应关系
- void registerNewIndex(VARIABLE* pIndex, QWidget* pControl);
- // 为控件添加一个变量
- void registerNewVariable(QWidget* pControl, const QString& strPropertyName, const VARIABLE* pVariable);
- // 释放对应控件关系
- void releaseControl(QWidget* pWidget);
- //=======================================================================
- // 同步相关代码
- // 从复杂控件的触发源头同步(一般都是Pou中的Execute,每轮执行会触发更新一遍Runtime)
- void syncFromComplexSource(const VARIABLE* syncVal);
- // 同步到Table控件中
- void syncToTableControl(QWidget* pControl, int nRowIndex);
- //// 刷新Table控件中的值
- //void updateTableControl(QTableWidget* pTableWidget, const SYNC_VARS& vars, int nRowIndex);
-
- // 同步到CustomPlot控件中
- void syncToCustomPlot(QWidget* pControl, int nSliceIndex);
- // 同步到Pie控件中
- void syncToPieChart(QWidget* pControl, int nSliceIndex);
- //// 刷新Pie控件中的值
- //void updatePieChart(VPieChart* pPieChart, const SYNC_VARS& vars, int nIndex);
- // 同步到Image控件中
- void syncToImageControl(QWidget* pControl);
- // 重置所有数据结构,准备执行新的发布动作
- void reset();
-
- private:
- Ui::WindowRuntime ui;
- protected slots:
- //// 绘制界面背景
- //void paintEvent(QPaintEvent*);
- // 接收来自变量到复杂控件单向同步的Event
- // 备注:复杂控件只需要在Execute的时候一次性向Runtime直接推送数据变动即可,不需要做其他同步操作
- virtual void customEvent(QEvent* event) override;
- protected:
- // 界面初始化
- void initUI();
- // 发布对应的页面
- bool publishPage(WindowAppUiView* pPage, bool bMainPage = false);
- protected:
- // 所有发布页面的Stack
- QStackedWidget* m_pRuntimeViews;
- // 发布的页面名字和对应的View序号
- QMap<QString, int> m_AllViews;
- // 复杂控件的索引变量 和 复杂控件指针之间的对应关系
- // 2021-12-28,为了支持一个索引刷新多个Table,增加了一对多的关系
- QMultiHash<const VARIABLE*, QWidget*> m_IndexToComplexControls;
- // 复杂控件的指针 和 每个数值对象的对应关系
- QHash<QWidget*, RUNTIME_SYNC_VARS> m_ComplexControlToVariables;
- };
|