main.cpp 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. #include "Ego.h"
  2. #include "EgoInterface.h"
  3. #include "ImageProvider.h"
  4. #include "appmodel.h"
  5. #include <QGuiApplication>
  6. #include <QQmlApplicationEngine>
  7. #include <QtCore/QDir>
  8. #include <QtGui/QGuiApplication>
  9. #include <QtQml/QQmlEngine>
  10. #include <QtQuick>
  11. int main(int argc, char *argv[]) {
  12. qputenv("QSG_RHI_BACKEND", "opengl");
  13. QGuiApplication app(argc, argv);
  14. QCoreApplication::setAttribute(Qt::AA_UseSoftwareOpenGL);
  15. QQuickView viewer;
  16. std::array<IRender *, RenderPosition::ALL> ar;
  17. IEgoNotify *_notify;
  18. IEgoControl *_control;
  19. for (int i = 0; i < RenderPosition::ALL; i++) {
  20. ar[i] = new ShowImage();
  21. }
  22. _notify = new CEgoNotify();
  23. _control = GetEgoController(_notify);
  24. _control->Start(ar);
  25. AppModel *appModel = new AppModel(_notify, _control);
  26. viewer.rootContext()->setContextProperty("appModel", appModel);
  27. QQmlEngine *engine = viewer.engine();
  28. // Front Cam
  29. ShowImage *FrontImage = static_cast<ShowImage *>(ar[0]);
  30. FrontImage->campos = RenderPosition::FRONT;
  31. engine->rootContext()->setContextProperty("FrontImage", FrontImage);
  32. engine->addImageProvider(QLatin1String("FrontImage"),
  33. FrontImage->m_pImgProvider);
  34. // Back Cam
  35. ShowImage *BackImage = static_cast<ShowImage *>(ar[1]);
  36. BackImage->campos = RenderPosition::BACK;
  37. engine->rootContext()->setContextProperty("BackImage", BackImage);
  38. engine->addImageProvider(QLatin1String("BackImage"),
  39. BackImage->m_pImgProvider);
  40. // Left Cam
  41. ShowImage *LeftImage = static_cast<ShowImage *>(ar[2]);
  42. LeftImage->campos = RenderPosition::LEFT;
  43. engine->rootContext()->setContextProperty("LeftImage", LeftImage);
  44. engine->addImageProvider(QLatin1String("LeftImage"),
  45. LeftImage->m_pImgProvider);
  46. // Right Cam
  47. ShowImage *RightImage = static_cast<ShowImage *>(ar[3]);
  48. RightImage->campos = RenderPosition::RIGHT;
  49. engine->rootContext()->setContextProperty("RightImage", RightImage);
  50. engine->addImageProvider(QLatin1String("RightImage"),
  51. RightImage->m_pImgProvider);
  52. // Panel Cam
  53. ShowImage *PanelImage = static_cast<ShowImage *>(ar[4]);
  54. PanelImage->campos = RenderPosition::DASHBOARD;
  55. engine->rootContext()->setContextProperty("PanelImage", PanelImage);
  56. engine->addImageProvider(QLatin1String("PanelImage"),
  57. PanelImage->m_pImgProvider);
  58. // // ForwardLeft Cam
  59. // ShowImage *ForwardLeftImage = static_cast<ShowImage *>(ar[4]);
  60. // ForwardLeftImage->campos = CAM_POS::FORWARD_LEFT;
  61. // engine->rootContext()->setContextProperty("ForwardLeftImage",
  62. // ForwardLeftImage);
  63. // engine->addImageProvider(QLatin1String("ForwardLeftImage"),
  64. // ForwardLeftImage->m_pImgProvider);
  65. // // ForwardRight Cam
  66. // ShowImage *ForwardRightImage = static_cast<ShowImage *>(ar[5]);
  67. // ForwardRightImage->campos = CAM_POS::FORWARD_RIGHT;
  68. // engine->rootContext()->setContextProperty("ForwardRightImage",
  69. // ForwardRightImage);
  70. // engine->addImageProvider(QLatin1String("ForwardRightImage"),
  71. // ForwardRightImage->m_pImgProvider);
  72. #ifdef Q_OS_WIN
  73. QString extraImportPath(QStringLiteral("%1/../../../../%2"));
  74. #else
  75. QString extraImportPath(QStringLiteral("%1/../../../%2"));
  76. #endif
  77. viewer.engine()->addImportPath(extraImportPath.arg(
  78. QGuiApplication::applicationDirPath(), QString::fromLatin1("qml")));
  79. QObject::connect(viewer.engine(), &QQmlEngine::quit, &viewer,
  80. &QWindow::close);
  81. viewer.setTitle(QStringLiteral("Hyper vision remote control System"));
  82. viewer.setSource(QUrl("qrc:///main.qml"));
  83. viewer.setResizeMode(QQuickView::SizeRootObjectToView);
  84. QObject *item = viewer.rootObject();
  85. QObject::connect(item, SIGNAL(qmlSignalMaxWindow()), &viewer, SLOT(show()));
  86. QObject::connect(item, SIGNAL(qmlSignalQuit()), &viewer, SLOT(close()));
  87. viewer.setFlags(Qt::FramelessWindowHint | Qt::Window);
  88. viewer.showMinimized();
  89. return app.exec();
  90. }