123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202 |
- #include <string>
- #include "Ego.h"
- #include "EgoInterface.h"
- #include "ImageProvider.h"
- #include "appmodel.h"
- #include <QGuiApplication>
- #include <QQmlApplicationEngine>
- #include <QtCore/QDir>
-
- #include <QtQml/QQmlEngine>
- #include <QtQuick>
- #include <QtWidgets/QApplication>
- #include <dbghelp.h>
- #include <tchar.h>
- #pragma comment(lib, "dbghelp.lib")
- #define USER_DATA_BUFFER_SIZE (4096)
- long __stdcall exceptionHander(_EXCEPTION_POINTERS* excp);
- int main(int argc, char *argv[]) {
- //SetUnhandledExceptionFilter(exceptionHander);
-
- // qputenv("QSG_RHI_BACKEND", "opengl");
- QApplication app(argc, argv);
-
- // QCoreApplication::setAttribute(Qt::AA_UseSoftwareOpenGL);
- QQuickView viewer;
- std::array<IRender *, RenderPosition::ALL> ar;
- IEgoNotify *_notify;
- IEgoControl *_control;
- for (int i = 0; i < RenderPosition::ALL; i++) {
- ar[i] = new ShowImage(nullptr,static_cast< RenderPosition>(i));
- }
- _notify = new CEgoNotify();
- _control = GetEgoController(_notify);
- _control->Start(ar);
-
-
- QQmlEngine *engine = viewer.engine();
- // Front Cam
- ShowImage *FrontImage = static_cast<ShowImage *>(ar[0]);
- //FrontImage->campos = RenderPosition::FRONT;
- engine->rootContext()->setContextProperty("FrontImage", FrontImage);
- engine->addImageProvider(QLatin1String("FrontImage"),
- FrontImage->m_pImgProvider);
- // Back Cam
- ShowImage *BackImage = static_cast<ShowImage *>(ar[1]);
- // BackImage->campos = RenderPosition::BACK;
- engine->rootContext()->setContextProperty("BackImage", BackImage);
- engine->addImageProvider(QLatin1String("BackImage"),
- BackImage->m_pImgProvider);
- // Left Cam
- ShowImage *LeftImage = static_cast<ShowImage *>(ar[2]);
- //LeftImage->campos = RenderPosition::LEFT;
- engine->rootContext()->setContextProperty("LeftImage", LeftImage);
- engine->addImageProvider(QLatin1String("LeftImage"),
- LeftImage->m_pImgProvider);
- // Right Cam
- ShowImage *RightImage = static_cast<ShowImage *>(ar[3]);
- //RightImage->campos = RenderPosition::RIGHT;
- engine->rootContext()->setContextProperty("RightImage", RightImage);
- engine->addImageProvider(QLatin1String("RightImage"),
- RightImage->m_pImgProvider);
- ShowImage* LeftAnchor = static_cast<ShowImage*>(ar[4]);
- //LeftAnchor->campos = RenderPosition::LANCHOR;
- engine->rootContext()->setContextProperty("LeftAnchor", LeftAnchor);
- engine->addImageProvider(QLatin1String("LeftAnchor"),
- LeftAnchor->m_pImgProvider);
- ShowImage* RightAnchor = static_cast<ShowImage*>(ar[5]);
- //RightAnchor->campos = RenderPosition::RANCHOR;
- engine->rootContext()->setContextProperty("RightAnchor", RightAnchor);
- engine->addImageProvider(QLatin1String("RightAnchor"),
- RightAnchor->m_pImgProvider);
- QCoreApplication::setAttribute(Qt::AA_UseSoftwareOpenGL);
- #ifdef Q_OS_WIN
- QString extraImportPath(QStringLiteral("%1/../../../../%2"));
- #else
- QString extraImportPath(QStringLiteral("%1/../../../%2"));
- #endif
- viewer.engine()->addImportPath(extraImportPath.arg(
- QGuiApplication::applicationDirPath(), QString::fromLatin1("qml")));
- QObject::connect(viewer.engine(), &QQmlEngine::quit, &viewer,
- &QWindow::close);
- viewer.setTitle(QStringLiteral("Hyper vision remote control System"));
- viewer.setSource(QUrl("qrc:///main.qml"));
- viewer.setResizeMode(QQuickView::SizeRootObjectToView);
- QObject *item = viewer.rootObject();
- auto object = item->findChild<QObject*>("tst");
- if (object==nullptr)
- {
- qDebug() << "ColorSetting failed\n";
- }
- AppModel* appModel = new AppModel(_notify, _control,object);
- viewer.rootContext()->setContextProperty("appModel", appModel);
- QObject::connect(item, SIGNAL(qmlSignalMaxWindow()), &viewer, SLOT(show()));
- QObject::connect(item, SIGNAL(qmlSignalQuit()), appModel, SLOT(OnClose()));
- viewer.setFlags(Qt::FramelessWindowHint | Qt::Window);
- viewer.showMinimized();
- return app.exec();
- }
- /*
- long exceptionHander(_EXCEPTION_POINTERS* excp)
- {
- TCHAR m_szDumpPath[_MAX_PATH];
- TCHAR m_szAppPath[_MAX_PATH];
- TCHAR m_szAppBaseName[_MAX_PATH];
- time_t m_lTime;
- time(&m_lTime);
- LONG retval = EXCEPTION_CONTINUE_SEARCH;
- HMODULE hDll = NULL;
- //TCHAR szDbgHelpPath[_MAX_PATH];
- if (GetModuleFileName(NULL, m_szAppPath, _MAX_PATH))
- {
- TCHAR* pSlash = _tcsrchr(m_szAppPath, '\\');
- if (pSlash)
- {
- _tcsncpy_s(m_szAppBaseName, _MAX_PATH, pSlash + 1, _MAX_PATH);
- *(pSlash + 1) = 0;
- // SetDumpFileName
- wsprintf(m_szDumpPath, _T("%s%s.%ld.dmp"), m_szAppPath, m_szAppBaseName, m_lTime);
- }
- }
- TCHAR szScratch[USER_DATA_BUFFER_SIZE];
- // ask the user if they want to save a dump file
- wsprintf(szScratch, _T("There was an unexpected error:\n\n%s\nWould you like to save a diagnostic file?\n\nFilename: %s"), "", m_szDumpPath);
- if (::MessageBox(NULL, szScratch, NULL, MB_YESNO) != IDYES)
- return EXCEPTION_EXECUTE_HANDLER;
- //创建转储文件
- HANDLE hFile = CreateFile(m_szDumpPath, GENERIC_WRITE, FILE_SHARE_WRITE, NULL,
- CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL);
- LPCTSTR szResult = NULL;
- if (hFile != INVALID_HANDLE_VALUE)
- {
- MINIDUMP_EXCEPTION_INFORMATION exptInfo;
- exptInfo.ThreadId = ::GetCurrentThreadId();
- exptInfo.ExceptionPointers = excp;
- exptInfo.ClientPointers = NULL;
- //将dump信息写入到文件中
- BOOL bOK = MiniDumpWriteDump(GetCurrentProcess(),
- GetCurrentProcessId(),
- hFile, MiniDumpNormal,
- &exptInfo, NULL, NULL);
- if (bOK)
- {
- szResult = NULL;
- retval = EXCEPTION_EXECUTE_HANDLER;
- }
- else
- {
- wsprintf(szScratch, _T("Failed to save dump file to '%s' (error %d)"), m_szDumpPath, GetLastError());
- szResult = szScratch;
- }
- ::CloseHandle(hFile);
- }
- else
- {
- wsprintf(szScratch, _T("Failed to create dump file '%s' (error %d)"), m_szDumpPath, GetLastError());
- szResult = szScratch;
- }
- if (szResult)
- ::MessageBox(NULL, szResult, NULL, MB_OK);
- TerminateProcess(GetCurrentProcess(), 0);
- return EXCEPTION_CONTINUE_SEARCH;
- }
- */
|