#include #include "Ego.h" #include "EgoInterface.h" #include "ImageProvider.h" #include "appmodel.h" #include #include #include #include"readthread.h" #include #include #include #include #include #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 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(ar[0]); //FrontImage->campos = RenderPosition::FRONT; engine->rootContext()->setContextProperty("FrontImage", FrontImage); engine->addImageProvider(QLatin1String("FrontImage"), FrontImage->m_pImgProvider); // Back Cam ShowImage *BackImage = static_cast(ar[1]); // BackImage->campos = RenderPosition::BACK; engine->rootContext()->setContextProperty("BackImage", BackImage); engine->addImageProvider(QLatin1String("BackImage"), BackImage->m_pImgProvider); // Left Cam ShowImage *LeftImage = static_cast(ar[2]); //LeftImage->campos = RenderPosition::LEFT; engine->rootContext()->setContextProperty("LeftImage", LeftImage); engine->addImageProvider(QLatin1String("LeftImage"), LeftImage->m_pImgProvider); // Right Cam ShowImage *RightImage = static_cast(ar[3]); //RightImage->campos = RenderPosition::RIGHT; engine->rootContext()->setContextProperty("RightImage", RightImage); engine->addImageProvider(QLatin1String("RightImage"), RightImage->m_pImgProvider); //Panel Cam ShowImage* LeftAnchor = static_cast(ar[4]); //LeftAnchor->campos = RenderPosition::LANCHOR; engine->rootContext()->setContextProperty("LeftAnchor", LeftAnchor); engine->addImageProvider(QLatin1String("LeftAnchor"), LeftAnchor->m_pImgProvider); /* ShowImage* RightAnchor = static_cast(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); //创建了一个名为item的指针,指向QML视图中的根对象 QObject *item = viewer.rootObject(); //在item(QML视图的根对象)中查找名为"tst"的子对象 auto object = item->findChild("tst"); if (object==nullptr) { qDebug() << "ColorSetting failed\n"; } AppModel* appModel = new AppModel(_notify, _control,object); viewer.rootContext()->setContextProperty("appModel", appModel); ReadThread* readThread = new ReadThread(); viewer.rootContext()->setContextProperty("readThread", readThread); //在QML中触发最大化窗口的信号时,显示窗口 QObject::connect(item, SIGNAL(qmlSignalMaxWindow()), &viewer, SLOT(show())); //在QML中触发退出应用程序的信号时,执行相应的关闭操作 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; } */