You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

62 regels
1.5 KiB

  1. #ifndef MAINWINDOW_H
  2. #define MAINWINDOW_H
  3. #include <QMainWindow>
  4. #include "plc.h"
  5. #include "hmi.h"
  6. #include "modbusmanager.h"
  7. #include "registermanager.h"
  8. QT_BEGIN_NAMESPACE
  9. namespace Ui { class MainWindow; }
  10. class QGraphicsScene;
  11. QT_END_NAMESPACE
  12. class MainWindow : public QMainWindow
  13. {
  14. Q_OBJECT
  15. public:
  16. explicit MainWindow(QWidget *parent = nullptr);
  17. ~MainWindow();
  18. void newPage(bool isPlc);
  19. void createComponents();
  20. void clearScene();
  21. void applyProjectToScene(const Project& proj, int pageIndex = 0); // 添加页面索引参数
  22. void extractSceneToProject(Project& proj, int pageIndex = 0); // 添加页面索引参数
  23. int currentPageIndex() const; // 获取当前页面索引
  24. bool eventFilter(QObject *obj, QEvent *event) override;
  25. private slots:
  26. void plcChange();
  27. void hmiChange();
  28. void newProject();
  29. void openProject();
  30. void saveProject();
  31. void connection();
  32. void disconnection();
  33. void updateConnectionStatus(bool connection);
  34. void onListwidgetCurrenttextchanged(const QString &currentText);
  35. void onTabCloseRequested(int index);
  36. void btnInsertClicked();
  37. private:
  38. Ui::MainWindow *ui;
  39. RegisterManager* registerManager;
  40. ModbusManager* modbusManager;
  41. // PLC状态
  42. QList<QGraphicsScene*> plcScenes;
  43. QList<MyGraphicsView*> plcViews;
  44. // HMI状态
  45. QList<QGraphicsScene*> hmiScenes;
  46. QList<MyGraphicsView*> hmiViews;
  47. QString selectedComponentType;
  48. bool currentIsPLC_ = true;
  49. };
  50. #endif // MAINWINDOW_H