int MCVMain(int argc, char *argv[]) { int retval = 0; // // Process the command line. // bool nowin = false; char *commandFile = NULL; char *dataFile = NULL; char **argv2 = new char*[5]; argv2[0] = argv[0]; int argc2 = 1; char nowin_str[] = "-nowin"; for (int i = 0; i < argc; i++) { if (strcmp(argv[i], "-G") == 0) { nowin = true; argv2[argc2++] = nowin_str; } else if (strcmp(argv[i], "-f") == 0) { commandFile = argv[i+1]; i++; } else { dataFile = argv[i]; } } // // Do basic initialization. This is only done once to initialize the // viewer library. // VisItViewer::Initialize(&argc2, &argv2); TRY { // // Create the viewer. // VisItViewer viewer; // // Set up VISITHOME so it finds the rest of VisIt. If the environment // variable VISITHOME is set, then assume that we are running a public // installation and use that, otherwise assume we are running in the // repo and set it accordingly. // if (getenv("VISITHOME") == NULL) { QDir d("../../"); std::string visithome(d.absolutePath().toStdString()); viewer.SetVISITHOME(visithome); } else { std::string visithome(getenv("VISITHOME")); std::string visithomebase(visithome, 0, visithome.rfind("/")); viewer.SetVISITHOME(visithomebase); } // // Process the command line arguments first since some may be removed // by QApplication::QApplication. // viewer.ProcessCommandLine(argc2, argv2); // // Create the QApplication. This sets the qApp pointer. // QApplication *mainApp = new QApplication(argc2, argv2, !nowin); if (!nowin) { // // Create our gui app. We have to do it before the call // to Setup() since we're embedding vis windows. // MultiCurveViewer *guiApp = new MultiCurveViewer(&viewer); // // Now that we've created the QApplication, let's call the viewer's // setup routine. // viewer.Setup(); // // Attach the attribute subjects that the observes. // guiApp->AttachSubjects(); // // Show our app's main window // guiApp->show(); guiApp->raise(); } else { // // Now that we've created the QApplication, let's call the viewer's // setup routine. // viewer.Setup(); // // Create our cli app. // MultiCurveProcessor *cliApp = new MultiCurveProcessor(&viewer); // // Tell the cli the name of the command file and data file. // cliApp->ProcessBatchFile(commandFile, dataFile); } // // Execute the viewer. // retval = mainApp->exec(); } CATCH2(VisItException, e) { cerr << "VisIt's viewer encountered the following fatal " "initialization error: " << endl << e.Message().c_str() << endl; retval = -1; }
int ViewerMain(int argc, char *argv[]) { int retval = 0; // // Do basic initialization. This is only done once to initialize the // viewer library. // VisItViewer::Initialize(&argc, &argv); TRY { // // Create the viewer. // VisItViewer viewer; // // Connect back to the client if we're not doing a reverse launch from // the compute engine. // bool reverseLaunch = false; for(int i = 1; i < argc && !reverseLaunch; ++i) reverseLaunch |= (strcmp(argv[i], "-connectengine") == 0); if(!reverseLaunch) viewer.Connect(&argc, &argv); // // Process the command line arguments first since some may be removed // by QApplication::QApplication. // viewer.ProcessCommandLine(argc, argv, false); // // Create the QApplication. This sets the qApp pointer. // char **argv2 = new char *[argc + 5]; int real_argc = 0; for(int i = 0; i < argc; ++i) { if(strcmp(argv[i], "-geometry") == 0) ++i; else argv2[real_argc++] = argv[i]; } argv2[real_argc] = (char*)"-font"; argv2[real_argc+1] = (char*)viewer.State()->GetAppearanceAttributes()->GetFontName().c_str(); argv2[real_argc+2] = (char*)"-name"; argv2[real_argc+3] = (char*)"visit-viewer"; argv2[real_argc+4] = NULL; debug1 << "Viewer using font: " << argv2[real_argc+1] << endl; qInstallMsgHandler(Viewer_LogQtMessages); int argc2 = real_argc + 2; QApplication *mainApp = new QApplication(argc2, argv2, !viewer.GetNowinMode()); // // Now that we've created the QApplication, let's call the viewer's // setup routine. // viewer.Setup(); // // Execute the viewer. // bool keepGoing = true; while (keepGoing) { TRY { retval = mainApp->exec(); keepGoing = false; // Remove the crash recovery file on a successful exit. viewer.RemoveCrashRecoveryFile(); } CATCH(LostConnectionException) { cerr << "The component that launched VisIt's viewer has terminated " "abnormally." << endl; keepGoing = false; retval = -1; } CATCH2(VisItException, ve) { QString msg = QObject::tr("VisIt has encountered the following error: %1.\n" "VisIt will attempt to continue processing, but it may " "behave unreliably. Please save this error message and " "give it to a VisIt developer. In addition, you may want " "to save your session and re-start. Of course, this " "session may still cause VisIt to malfunction."). arg(ve.Message().c_str()); viewer.Error(msg); keepGoing = true; } ENDTRY } }