|
- #ifndef MAINWINDOW_H
- #define MAINWINDOW_H
-
- #include <QMainWindow>
- #include "plc.h"
- #include "hmi.h"
- #include "modbusmanager.h"
- #include "registermanager.h"
-
- QT_BEGIN_NAMESPACE
- namespace Ui { class MainWindow; }
- class QGraphicsScene;
- QT_END_NAMESPACE
-
- class MainWindow : public QMainWindow
- {
- Q_OBJECT
-
- public:
- explicit MainWindow(QWidget *parent = nullptr);
- ~MainWindow();
-
- void newPage(bool isPlc);
- void createComponents();
-
- void clearScene();
- void applyProjectToScene(const Project& proj, int pageIndex = 0); // 添加页面索引参数
- void extractSceneToProject(Project& proj, int pageIndex = 0); // 添加页面索引参数
- int currentPageIndex() const; // 获取当前页面索引
- bool eventFilter(QObject *obj, QEvent *event) override;
-
- private slots:
- void plcChange();
- void hmiChange();
- void newProject();
- void openProject();
- void saveProject();
- void connection();
- void disconnection();
- void updateConnectionStatus(bool connection);
- void onListwidgetCurrenttextchanged(const QString ¤tText);
- void onTabCloseRequested(int index);
- void btnInsertClicked();
-
- private:
- Ui::MainWindow *ui;
- RegisterManager* registerManager;
- ModbusManager* modbusManager;
- // PLC状态
- QList<QGraphicsScene*> plcScenes;
- QList<MyGraphicsView*> plcViews;
- QStringList plcPageTitles;
-
- // HMI状态
- QList<QGraphicsScene*> hmiScenes;
- QList<MyGraphicsView*> hmiViews;
- QStringList hmiPageTitles;
-
- QString selectedComponentType;
- bool currentIsPLC_ = true;
- };
-
- #endif // MAINWINDOW_H
|