CrustaApp:: CrustaApp(int& argc, char**& argv, char**& appDefaults) : Vrui::Application(argc, argv, appDefaults), dataDialog(NULL), paletteEditor(new PaletteEditor), layerSettings(paletteEditor) { crusta = new Crusta(argv[0]); paletteEditor->getColorMapEditor()->getColorMapChangedCallbacks().add(this, &CrustaApp::changeColorMapCallback); paletteEditor->getRangeEditor()->getRangeChangedCallbacks().add(this, &CrustaApp::changeColorMapRangeCallback); for (int i=1; i<argc; ++i) handleArg(argv[i]); crusta->start(); produceMainMenu(); /* Set the navigational coordinate system unit: */ Vrui::getCoordinateManager()->setUnit( Geometry::LinearUnit(Geometry::LinearUnit::METER, 1)); /* Register a geodetic coordinate transformer with Vrui's coordinate manager: */ VruiCoordinateTransform* userTransform; userTransform=new VruiCoordinateTransform; userTransform->setupComponent(crusta); Vrui::getCoordinateManager()->setCoordinateTransform(userTransform); // coordinate manager owns userTransform resetNavigationCallback(NULL); #if CRUSTA_ENABLE_DEBUG DebugTool::init(); #endif //CRUSTA_ENABLE_DEBUG }
CaveApp::CaveApp(int &argc, char** &argv, char** &appDefaults) : Vrui::Application(argc, argv, appDefaults), mainMenu(0) { /* Create the user interface: */ mainMenu=createMainMenu(); /* Install the main menu: */ Vrui::setMainMenu(mainMenu); /* Set the navigation transformation: */ resetNavigationCallback(0); }
FiberApplication::FiberApplication(int& argc,char**& argv,char**& appDefaults) :Vrui::Application(argc,argv,appDefaults), mainMenu(0), propertiesDialog(0), m_showSelectionBox(true), m_fiberFileName(""), m_anatomyFileName(""), m_showVolume(false), mIsoSurface(NULL) { //TODO create tool at launch if possible processCommandLineArguments(argc,argv); if(m_anatomyFileName != "") { mAnatomy.load(m_anatomyFileName); mIsoSurface = new IsoSurface(&mAnatomy,false); mIsoSurface->GenerateSurface(0.2f); } if(m_fiberFileName != "") { mFibers.load(m_fiberFileName); } //Create the user interface: mainMenu=createMainMenu(); //create Popup Window //propertiesDialog = createPropertiesDialog(); //Install the main menu: Vrui::setMainMenu(mainMenu); if(mFibers.getBBMax()[X_AXIS] + mFibers.getBBMax()[Y_AXIS] + mFibers.getBBMax()[Z_AXIS] > mAnatomy.getBBMax()[X_AXIS] + mAnatomy.getBBMax()[Y_AXIS] + mAnatomy.getBBMax()[Z_AXIS]) { m_BBMax = mFibers.getBBMax(); } else { m_BBMax = mAnatomy.getBBMax(); } //Set the navigation transformation: resetNavigationCallback(0); //Tell Vrui to run in a continuous frame sequence: Vrui::updateContinuously(); }
Viewer::Viewer(int &argc, char** argv, char** appDefaults) : Vrui::Application(argc, argv, appDefaults), tools(ToolList()), model(NULL), frameRateDialog(NULL), positionDialog(NULL), parameterDialog(NULL), currentOptionsDialog(NULL), optionsDialogs(DialogArray()), elapsedTime(0.0), stepSizeVersion(0), modelVersion(0), masterout(std::cout), nodeout(std::cout), debugout(std::cerr) { // load ToolBox ToolBox::ToolBoxFactory::instance(); // load dynamics plugins try { model_names=loadPlugins(); } catch (std::runtime_error& e) { std::cerr << "ERROR: " << e.what() << std::endl; } catch (...) { std::cerr << "UNDEFINED ERROR." << std::endl; } // alphabetize the names list std::sort(model_names.begin(), model_names.end()); // initialize the model dynamics (first one alphabetically) //model=Factory[model_names[0]](); // load lorenz std::string name = "Lorenz Attractor"; model = Factory[name](); // create and set the main menu mainMenu=createMainMenu(); Vrui::setMainMenu(mainMenu); // create other dialogs frameRateDialog = new FrameRateDialog(mainMenu); positionDialog = new PositionDialog(mainMenu); // create and assign associated parameter dialog parameterDialog=model->createParameterDialog(mainMenu); // Make sure the correct system is toggled setRadioToggles(dynamicsToggleButtons, name + "toggle"); // center the display resetNavigationCallback(0); }
VruiAppTemplate::VruiAppTemplate(int& argc,char**& argv,char**& appDefaults) :Vrui::Application(argc,argv,appDefaults), renderingMode(2), // Start rendering polygons material(GLMaterial::Color(0.0f,0.5f,1.0f),GLMaterial::Color(1.0f,1.0f,1.0f),25.0f), // Use a bluish specular material mainMenu(0) { /* Create the user interface: */ mainMenu=createMainMenu(); /* Install the main menu: */ Vrui::setMainMenu(mainMenu); /* Initialize the navigation transformation: */ resetNavigationCallback(0); }
ImageViewer::ImageViewer(int& argc,char**& argv,char**& appDefaults) :Vrui::Application(argc,argv,appDefaults), mainMenu(0) { /* Load the image: */ image=Images::readImageFile(argv[1],Vrui::openFile(argv[1])); /* Create the user interface: */ mainMenu=createMainMenu(); /* Install the main menu: */ Vrui::setMainMenu(mainMenu); /* Initialize the navigation transformation: */ resetNavigationCallback(0); }
VruiDemo::VruiDemo(int& argc,char**& argv) :Vrui::Application(argc,argv), mainMenu(0) { /* Initialize the animation parameters: */ for(int i=0;i<3;++i) modelAngles[i]=Vrui::Scalar(0); rotationSpeeds[0]=Vrui::Scalar(9); rotationSpeeds[1]=Vrui::Scalar(-31); rotationSpeeds[2]=Vrui::Scalar(19); /* Create the user interface: */ mainMenu=createMainMenu(); /* Install the main menu: */ Vrui::setMainMenu(mainMenu); /* Set the navigation transformation: */ resetNavigationCallback(0); }
VideoViewer::VideoViewer(int& argc,char**& argv) :Vrui::Application(argc,argv), videoDevice(0),videoExtractor(0), saveVideoFrames(false),saveVideoFrameNameTemplate("Frame%06u.ppm"),saveVideoNextFrameIndex(0), videoFrameVersion(0), videoControlPanel(0),mainMenu(0) { /* Parse the command line: */ const char* videoDeviceName=0; bool requestSize=false; int videoSize[2]; bool requestRate=false; int videoRate; const char* pixelFormat=0; for(int i=1; i<argc; ++i) { if(argv[i][0]=='-') { /* Parse a command line option: */ if(strcasecmp(argv[i]+1,"size")==0||strcasecmp(argv[i]+1,"S")==0) { /* Parse the desired video frame size: */ i+=2; if(i<argc) { for(int j=0; j<2; ++j) videoSize[j]=atoi(argv[i-1+j]); requestSize=true; } else std::cerr<<"Ignoring dangling -size option"<<std::endl; } else if(strcasecmp(argv[i]+1,"rate")==0||strcasecmp(argv[i]+1,"R")==0) { /* Parse the desired video frame rate: */ ++i; if(i<argc) { videoRate=atoi(argv[i]); requestRate=true; } else std::cerr<<"Ignoring dangling -rate option"<<std::endl; } else if(strcasecmp(argv[i]+1,"format")==0||strcasecmp(argv[i]+1,"F")==0) { /* Parse the desired pixel format: */ ++i; if(i<argc) pixelFormat=argv[i]; else std::cerr<<"Ignoring dangling -format option"<<std::endl; } else if(strcasecmp(argv[i]+1,"saveName")==0||strcasecmp(argv[i]+1,"SN")==0) { ++i; if(i<argc) saveVideoFrameNameTemplate=argv[i]; else std::cerr<<"Ignoring dangling -saveName option"<<std::endl; } else std::cerr<<"Ignoring unknown command line option "<<argv[i]<<std::endl; } else if(strcasecmp(argv[i],"list")==0) { /* Print a list of all connected video devices: */ std::vector<Video::VideoDevice::DeviceIdPtr> videoDevices=Video::VideoDevice::getVideoDevices(); std::cout<<"Connected video devices:"<<std::endl; for(std::vector<Video::VideoDevice::DeviceIdPtr>::iterator vdIt=videoDevices.begin(); vdIt!=videoDevices.end(); ++vdIt) std::cout<<(*vdIt)->getName()<<std::endl; /* Exit from the program: */ Vrui::shutdown(); } else if(videoDeviceName==0) { /* Treat the argument as the name of a video device: */ videoDeviceName=argv[i]; } else std::cerr<<"Ignoring extra device name argument "<<argv[i]<<std::endl; } /* Open the video device: */ std::vector<Video::VideoDevice::DeviceIdPtr> videoDevices=Video::VideoDevice::getVideoDevices(); if(videoDeviceName==0&&!videoDevices.empty()) { /* Select the first video device: */ videoDevice=Video::VideoDevice::createVideoDevice(videoDevices.front()); } else { /* Find a video device whose name matches the given name: */ for(std::vector<Video::VideoDevice::DeviceIdPtr>::iterator vdIt=videoDevices.begin(); vdIt!=videoDevices.end(); ++vdIt) if(strcasecmp((*vdIt)->getName().c_str(),videoDeviceName)==0) { /* Open the matching video device and bail out: */ videoDevice=Video::VideoDevice::createVideoDevice(*vdIt); break; } } if(videoDevice==0) Misc::throwStdErr("VideoViewer: Could not find requested video device"); /* Get and modify the video device's current video format: */ videoFormat=videoDevice->getVideoFormat(); if(requestSize) for(int i=0; i<2; ++i) videoFormat.size[i]=(unsigned int)videoSize[i]; if(requestRate) { /* Convert from frame rate in Hz to frame interval as a rational number: */ videoFormat.frameIntervalCounter=1; videoFormat.frameIntervalDenominator=videoRate; } if(pixelFormat!=0) videoFormat.setPixelFormat(pixelFormat); videoDevice->setVideoFormat(videoFormat); /* Print the actual video format after adaptation: */ std::cout<<"Selected video format on video device "<<(videoDeviceName!=0?videoDeviceName:"Default")<<":"<<std::endl; std::cout<<"Frame size "<<videoFormat.size[0]<<"x"<<videoFormat.size[1]<<" at "<<double(videoFormat.frameIntervalDenominator)/double(videoFormat.frameIntervalCounter)<<" Hz"<<std::endl; char videoPixelFormatBuffer[5]; std::cout<<"Pixel format "<<videoFormat.getFourCC(videoPixelFormatBuffer)<<std::endl; /* Create an image extractor to convert from the video device's raw image format to RGB: */ videoExtractor=videoDevice->createImageExtractor(); /* Initialize the incoming video frame triple buffer: */ for(int i=0; i<3; ++i) { Images::RGBImage img(videoFormat.size[0],videoFormat.size[1]); img.clear(Images::RGBImage::Color(128,128,128)); videoFrames.getBuffer(i)=img; } /* Create the video device's control panel: */ videoControlPanel=videoDevice->createControlPanel(Vrui::getWidgetManager()); /* Check if the control panel is a pop-up window; if so, add a close button: */ GLMotif::PopupWindow* vcp=dynamic_cast<GLMotif::PopupWindow*>(videoControlPanel); if(vcp!=0) { /* Add a close button: */ vcp->setCloseButton(true); /* Set it so that the popup window will pop itself down, but not destroy itself, when closed: */ vcp->popDownOnClose(); } /* Create and install the main menu: */ mainMenu=createMainMenu(); Vrui::setMainMenu(mainMenu); /* Create an event tool to start/stop saving video frames: */ addEventTool("Save Video Frames",0,0); /* Initialize the navigation transformation to show the entire video image: */ resetNavigationCallback(0); /* Start capturing video from the video device: */ videoDevice->allocateFrameBuffers(5); videoDevice->startStreaming(Misc::createFunctionCall(this,&VideoViewer::videoFrameCallback)); }