mainwindow.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. #ifndef MAINWINDOW_H
  2. #define MAINWINDOW_H
  3. #include <QMainWindow>
  4. #include <QLabel>
  5. #include <QGroupBox>
  6. #include <QLineEdit>
  7. #include <QSlider>
  8. #include <QComboBox>
  9. #include <QPushButton>
  10. #include <QTimer>
  11. #include "OpenDrive/OpenDrive.h"
  12. #include "OpenDrive/OpenDriveXmlParser.h"
  13. #include "myview.h"
  14. QT_BEGIN_NAMESPACE
  15. namespace Ui { class MainWindow; }
  16. QT_END_NAMESPACE
  17. namespace iv {
  18. struct simobj
  19. {
  20. double mfx;
  21. double mfy;
  22. double mfz;
  23. double mfhdg;
  24. double mflen;
  25. double mfwidth;
  26. double mfheight;
  27. QGraphicsPathItem * mpobjitem;
  28. int nshowid;
  29. };
  30. }
  31. class MainWindow : public QMainWindow
  32. {
  33. Q_OBJECT
  34. public:
  35. MainWindow(QWidget *parent = nullptr);
  36. ~MainWindow();
  37. private slots:
  38. virtual void paintEvent(QPaintEvent *);
  39. void onClickXY(double x,double y);
  40. void onClickSetCarPos();
  41. void onClickAddPedObj();
  42. void onClickAddCarObj();
  43. void onClickAddCustomObj();
  44. void onClickDelObj();
  45. void onTimerShowSelObj();
  46. void onCurrentIndexChanged(int index);
  47. void on_actionLoad_triggered();
  48. private:
  49. Ui::MainWindow *ui;
  50. QImage *image;
  51. QPainter *painter;
  52. MyView *myview;
  53. QTimer *timer;
  54. QGraphicsScene *scene;
  55. QGraphicsScene * mpscene;
  56. QGraphicsPixmapItem * mppixcar;
  57. QLabel * mpLabel_Status;
  58. QLineEdit * mpLE_SelX, * mpLE_SelY, * mpLE_SelLat, * mpLE_SelLon, *mpLE_SelHeading;
  59. QPushButton * mpPBSetCarPos;
  60. QPushButton * mpPBAddPedObj;
  61. QPushButton * mpPBAddCarObj;
  62. QPushButton * mpPBAddCustomObj;
  63. QPushButton * mpPBDelObj;
  64. QComboBox * mpCBObj;
  65. QTimer * mpTimerShowSelObj;
  66. QTabWidget * mTabMain;
  67. void CreateTab1View(QTabWidget * p);
  68. double mfViewMoveX = 0;
  69. double mfViewMoveY = 0;
  70. double mfvehwidth;
  71. double mfvehlen;
  72. private:
  73. int mnFontHeight;
  74. OpenDrive mxodr;
  75. void UpdateScene();
  76. std::vector<QGraphicsPathItem *> mvectorviewitem;
  77. std::vector<QGraphicsPathItem *> mvectorgeoitem;
  78. double mfClickX,mfClickY;
  79. double mfMoveX,mfMoveY;
  80. std::vector<iv::simobj> mvectorsimobj;
  81. int mnshowidindex = 0;
  82. int mnSelObj = 0;
  83. int mnSelShowCount = 0;
  84. public:
  85. void resizeEvent(QResizeEvent *event);
  86. private:
  87. void CreateCar();
  88. void SetCarPos(double x,double y, double fhdg);
  89. void AddPedObj(double x,double y, double fhdg);
  90. void AddCarObj(double x,double y, double fhdg);
  91. void AddCustomObj(double x,double y, double z,double fhdg,double flen,double fwidth,double fheight);
  92. void AddObjToVector(double x,double y, double z,double fhdg,double flen,double fwidth,double fheight,QGraphicsPathItem * pitem);
  93. void DelObjFromVector(unsigned int index);
  94. void normalhdg(double & fhdg);
  95. };
  96. #endif // MAINWINDOW_H