int main(int argc, char *argv[]) { srand(time(NULL)); return runConsole(argc, argv); //return runGui(argc, argv); }
// Constructor // ConsoleClass::ConsoleClass() { // Map boost::python stdout and stderr through us object main_module = import("__main__"); object main_namespace = main_module.attr("__dict__"); main_namespace["stdioRedirect"] = class_<stdioRedirect>("stdioRedirect", init<>()) .def("write", &stdioRedirect::Write); python_stdout_redirector = stdioRedirect(); boost::python::import("sys").attr("stdout") = &python_stdout_redirector; python_stderr_redirector = stdioRedirect(); boost::python::import("sys").attr("stderr") = &python_stderr_redirector; // Also create a redirector that writes from evaluated console stuff python_evaluator = stdioRedirect(); // START OF TESTING STUFF // Log file, for demonstration, should be moved later logfile.open("log.txt"); registerStdout(&logfile); registerStderr(&logfile); python_evaluator.registerStream(&logfile); // Run the console runConsole(&std::cin); }
void SyntroHAServer::run() { #ifdef WIN32 runConsole(); #else if (m_daemonMode) runDaemon(); else runConsole(); #endif m_insteonDriver->exitThread(); m_client->exitThread(); SyntroUtils::syntroAppExit(); ((QCoreApplication *)parent())->exit(); }
int main(int argc, char* argv[]) { static const int WINDOW_WIDTH = 1280; static const int WINDOW_HEIGHT = 720; if (argc != 2) { std::cerr << "Incorrect usage: Must supply path to Tiled export Lua file." << std::endl; return -1; } try { const te::Initialization init; te::WindowPtr pWindow = te::createWindowOpenGL( "Map Runner", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, WINDOW_WIDTH, WINDOW_HEIGHT, SDL_WINDOW_SHOWN); te::View view({ 0, 0, 16, 9 }); view.setViewport({ 0.f, 0.f, 1.f, 1.f }); auto pShader = std::make_shared<te::Shader>(view, *pWindow); auto pTMX = std::make_shared<te::TMX>(argv[1]); auto pState = std::make_shared<te::LuaGameState>( pTMX, pShader, glm::scale(glm::vec3(1.f/pTMX->tilewidth, 1.f/pTMX->tileheight, 1.f))); te::StateStack stateStack(pState); bool running = true; std::thread prompt([&running, pState] { pState->runConsole(); }); te::executeStack(stateStack, *pWindow, &running); prompt.join(); } catch (const std::exception& ex) { std::cerr << ex.what() << std::endl; return -1; } return 0; }
void SyntroLCamConsole::run() { #ifndef WIN32 if (m_daemonMode) runDaemon(); else #endif runConsole(); stopVideo(); stopAudio(); m_client->exitThread(); SyntroUtils::syntroAppExit(); QCoreApplication::exit(); }
void SyntroCVCamConsole::run() { m_camera = new OpenCVCamera(); connect(this, SIGNAL(newFrame(Mat)), m_client, SLOT(newFrame(Mat)), Qt::DirectConnection); m_running = true; if (m_daemonMode) runDaemon(); else runConsole(); m_running = false; m_client->exitThread(); SyntroUtils::syntroAppExit(); QCoreApplication::exit(); }
void PointCloudLODGenerator::SetSceneData(osgViewer::CompositeViewer* viewer) { setlocale(LC_ALL, "chs"); AfxMessageBox("第一步:选择待生成LOD的点云文件"); CFileDialog dlg(TRUE, "选择待生成LOD的点云文件", NULL, 0, "All(*.*)|*.*|"); if(dlg.DoModal()!=IDOK) { AfxMessageBox("没有选择文件,工作流结束!"); return; } CString strFileName = dlg.GetPathName(); AfxMessageBox("第二步:保存为osg\\ive格式场景文件"); CFileDialog saveDlg(FALSE, "选择保存文件名", NULL, 0, "osg文件(*.osg)|*.osg|ive文件(*.ive)|*.ive|"); if(saveDlg.DoModal()!=IDOK) { AfxMessageBox("没有选择保存文件名, 工作流结束!"); return; } CString strSaveFileName = saveDlg.GetPathName(); #ifndef _DEBUG AFX_MANAGE_STATE(AfxGetStaticModuleState()); #endif AfxMessageBox("第三步,设置参数"); LODParaSetter setter; float sampleRatio=0.001; unsigned int targetNumOnLeaf = 10000; double maxVisibleRange=800; double minVisibleRange=100; if(setter.DoModal()==IDOK) { sampleRatio = setter.m_sampleRatio; targetNumOnLeaf = setter.m_targetNumOnLeaf; maxVisibleRange = setter.maxBoundVisibleRange; minVisibleRange = setter.minBoundVisibleRange; } AfxMessageBox("第三步:读取点云文件并进行转换,请耐心等待..."); setWorkingPath(); CString cmd = "PointsDividor.exe"; CString par; par.Format("\"%s\" \"%s\" %d %f %d %lf", strFileName, strSaveFileName, 16, sampleRatio, targetNumOnLeaf, maxVisibleRange, minVisibleRange); //AfxMessageBox(par); SHELLEXECUTEINFO shellinfo = runConsole(cmd, par); if(shellinfo.hProcess==NULL) { AfxMessageBox("无法打开应用程序:PointsDividor.exe!工作流结束!"); return; } #ifndef _DEBUG //AFX_MANAGE_STATE(AfxGetStaticModuleState()); CWaitDialog* pWaitDlg = new CWaitDialog; pWaitDlg->Create(IDD_DIALOG_WAIT, NULL); pWaitDlg->ShowWindow(SW_SHOW); #endif while (true) { DWORD signal = WaitForSingleObject(shellinfo.hProcess, 10); if ( signal == WAIT_OBJECT_0 || shellinfo.hProcess==NULL ) { break; } MSG msg; GetMessage(&msg, NULL, 0, 0); if (&msg!=NULL) { TranslateMessage(&msg); DispatchMessage(&msg); } #ifndef _DEBUG pWaitDlg->m_progBar.StepIt(); #endif } #ifndef _DEBUG pWaitDlg->DestroyWindow(); delete pWaitDlg; #endif osg::Node* ret = osgDB::readNodeFile(string(strSaveFileName)); sceneRoot = ret; if(ret==0) { AfxMessageBox("无法读取该文件!"); return; } osg::Group* root = viewer->getView(0)->getSceneData()->asGroup(); root->addChild(ret); }