roadviewitem.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. #ifndef ROADVIEWITEM_H
  2. #define ROADVIEWITEM_H
  3. #include <QGraphicsItem>
  4. #include <vector>
  5. #include "OpenDrive/OpenDrive.h"
  6. #include "xodrfunc.h"
  7. namespace iv {
  8. struct lineviewdata
  9. {
  10. double mE;
  11. double mstartx;
  12. double mstarty;
  13. double mendx;
  14. double mendy;
  15. double mfHdg;
  16. QPointF mPoints[4];
  17. };
  18. }
  19. namespace iv{
  20. struct lanesectionpoint
  21. {
  22. std::vector<iv::LanePoint> mvectorlanepoint;
  23. };
  24. struct lanesectionlinese
  25. {
  26. int mnsec = 0;
  27. std::vector<iv::lanesectionpoint> mvectorlanelinese;
  28. };
  29. }
  30. namespace iv {
  31. struct laneviewdata
  32. {
  33. double mS;
  34. double mLane;
  35. int ntype; //0 driving 1 border 2 none 3 sidewalk
  36. QPointF mPoints[4];
  37. };
  38. }
  39. namespace iv {
  40. struct lanemark
  41. {
  42. int ncolor = 0;//White. 1 yellow
  43. int mnmarktype;
  44. QPointF mPoints[4];
  45. };
  46. }
  47. class roadviewitem : public QGraphicsItem
  48. {
  49. public:
  50. roadviewitem(Road * pRoad);
  51. QRectF boundingRect() const override;
  52. void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
  53. void setratio(float ratio);
  54. void setmark(bool bMark);
  55. Road * GetRoad();
  56. void setlaneshow(bool bShow);
  57. void setlineshow(bool bShow);
  58. void setroadidshow(bool bShow);
  59. private:
  60. double mfwidth = 1.0;
  61. double mfratio = 1.0;
  62. Road * mpRoad;
  63. std::vector<iv::lineviewdata> mvectorline;
  64. std::vector<iv::laneviewdata> mvectorlaneview;
  65. std::vector<iv::lanemark> mvectorlanemark;
  66. std::vector<iv::lanesectionlinese> mvectorlaneline;
  67. void CalcLine();
  68. void CalcLane();
  69. float mfoldcalratio;
  70. bool mbNeedCalc;
  71. float mfxmin,mfymin,mfxmax,mfymax;
  72. inline void CalcPoints(iv::lineviewdata * plinedata);
  73. void CalcMaxMin();
  74. double mtextx;
  75. double mtexty;
  76. bool mbMark = false;
  77. bool mbShowLane = true;
  78. bool mbShowLine = false;
  79. bool mbShowRoadID = true;
  80. public:
  81. static bool IsDrawMark(double s);
  82. };
  83. #endif // ROADVIEWITEM_H