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.

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