Example #1
0
HelloVrui::HelloVrui(int& argc,char**& argv)
	:Vrui::Application(argc,argv),
	 showSurface(true),surfaceTransparent(false),
	 surfaceMaterial(GLMaterial::Color(1.0f,1.0f,1.0f,0.333f),GLMaterial::Color(0.333f,0.333f,0.333f),10.0f),
	 showGrid(true),
	 mainMenu(0),
         drawGLCube(false)
	{
        if(argc > 1)
          {
          if(std::string(argv[1]) == "--gl")
            {
            this->drawGLCube = true;
            }
          }
	/* Create the user interface: */
	mainMenu=createMainMenu();
	Vrui::setMainMenu(mainMenu);

	/* Initialize Vrui navigation transformation: */
	centerDisplayCallback(0);

        this->renWin =
          vtkSmartPointer<vtkExternalOpenGLRenderWindow>::New();
        this->ren = vtkSmartPointer<vtkExternalOpenGLRenderer>::New();
//        this->cam = vtkSmartPointer<vtkExternalOpenGLCamera>::New();
//        this->ren->SetActiveCamera(this->cam);
	}
Example #2
0
Jello::Jello(int& argc,char**& argv,char**& appDefaults)
	:Vrui::Application(argc,argv,appDefaults),
	 crystal(JelloCrystal::Index(4,4,8)),
	 renderer(crystal),
	 targetFrameRate(50.0),
	 numMiniSteps(1),
	 mainMenu(0),settingsDialog(0)
	{
	/* Target frame rate is only (optional) command line parameter: */
	if(argc>=2)
		targetFrameRate=atof(argv[1]);
	
	/* Determine a good color to draw the domain box: */
	GLColor<GLfloat,3> domainBoxColor;
	for(int i=0;i<3;++i)
		domainBoxColor[i]=1.0f-Vrui::getBackgroundColor()[i];
	renderer.setDomainBoxColor(domainBoxColor);
	
	/* Create the program's user interface: */
	mainMenu=createMainMenu();
	Vrui::setMainMenu(mainMenu);
	settingsDialog=createSettingsDialog();
	
	/* Initialize the navigation transformation: */
	centerDisplayCallback(0);
	
	/* Tell Vrui to run in a continuous frame sequence: */
	Vrui::updateContinuously();
	
	/* Initialize the frame time calculator: */
	lastFrameTime=Vrui::getApplicationTime();
	}
Example #3
0
KinectViewer::KinectViewer(int& argc,char**& argv,char**& appDefaults)
	:Vrui::Application(argc,argv,appDefaults),
	 cameraDevice(Vrui::findInputDevice("Camera")),
	 mainMenu(0)
	{
	/* Enable background USB event handling: */
	usbContext.startEventHandling();
	
	/* Connect to given Kinect camera device on the host: */
	#if PLAYBACK
	streamers.push_back(new KinectStreamer("/work/okreylos/3DVideo/Kinect/DepthFrames.dat","/work/okreylos/3DVideo/Kinect/ColorFrames.dat"));
	#else
	
	/* Read the index of the Kinect camera to which to connect: */
	int cameraIndex=0;
	if(argc>=2)
		cameraIndex=atoi(argv[1]);
	
	/* Add a streamer for the selected camera: */
	streamers.push_back(new KinectStreamer(usbContext,cameraIndex));
	
	/* Save frames from the first Kinect streamer: */
	// streamers[0]->frameSaver=new KinectFrameSaver("/work/okreylos/3DVideo/Kinect/DepthFrames2.dat","/work/okreylos/3DVideo/Kinect/ColorFrames2.dat");
	
	/* Add a streamer for another Kinect camera: */
	// streamers.push_back(new KinectStreamer(usbContext,1));
	#endif
	
	/* Create the main menu: */
	mainMenu=createMainMenu();
	Vrui::setMainMenu(mainMenu);
	
	/* Initialize navigation transformation: */
	viewCameraCallback(0,0);
	}
/** Quits the game and returns to the main menu. This event is prompted when the menu button is clicked. */
void onMainMenuClick(GuiButton* button)
{
	// Create new window and set it as active
	GuiWindow* mainMenu = createMainMenu();
	if (NULL == mainMenu)
		g_guiError = true; // Raise flag if an error occured, main loop will respond accordingly

	setActiveWindow(mainMenu); // Switch to main menu window
}
Example #5
0
Game::Game()
{
	model = new Model();
	view = new View(model);
	controller = new Controller(model, view);

	timePerFrame = sf::seconds(1.0f / frameRate);

	createMainMenu();
}
/*
 * initialize - Initialize the GUI portion of the application.
 *
 * parameter volumeFile - const char*& volumeFile
 */
void Domhan_Samhlaigh::initialize(void) {
	scene = new Scene(numberOfHorizontalPatches, numberOfVerticalPatches, minimumLevel, texturePrefix, heightMapPrefix);

	/* Create the user interface: */
	mainMenu=createMainMenu();
	Vrui::setMainMenu(mainMenu);

	/* Center display */
	centerDisplayCallback(0);
} // end initialize()
void  CoaBusinessObject::initialize()
{
   BEGIN;
   if (m_isInitialized == true) return;

   initWorkspace();
   createMainMenu();

   m_isInitialized = true;
   emit isInitialized();
}
Example #8
0
void lmcMainWindow::init(User* pLocalUser, QList<Group>* pGroupList, bool connected) {
	setWindowIcon(QIcon(IDR_APPICON));
    setWindowFlags(windowFlags() & Qt::FramelessWindowHint);
    setWindowFlags(windowFlags() & ~Qt::WindowMaximizeButtonHint);
    setMinimumSize(270, 260);
    setMaximumSize(300, 760);

	this->pLocalUser = pLocalUser;

	createMainMenu();
	createToolBar();
	createStatusMenu();
	createAvatarMenu();

	createTrayMenu();
	createTrayIcon();
	connectionStateChanged(connected);

	createGroupMenu();
	createUserMenu();

	ui.lblDividerTop->setBackgroundRole(QPalette::Highlight);
	ui.lblDividerTop->setAutoFillBackground(true);

	ui.tvUserList->setIconSize(QSize(16, 16));
    ui.tvUserList->header()->setSectionsMovable(false);
	ui.tvUserList->header()->setStretchLastSection(false);
    ui.tvUserList->header()->setSectionResizeMode(0, QHeaderView::Stretch);
	btnStatus->setIconSize(QSize(20, 20));
	int index = Helper::statusIndexFromCode(pLocalUser->status);
	//	if status is not recognized, default to available
	index = qMax(index, 0);
	btnStatus->setIcon(QIcon(QPixmap(statusPic[index], "PNG")));
	statusGroup->actions()[index]->setChecked(true);
    QFont font = ui.lblUserName->font();
	int fontSize = ui.lblUserName->fontInfo().pixelSize();
	fontSize += (fontSize * 0.1);
	font.setPixelSize(fontSize);
    font.setBold(true);
    ui.lblUserName->setFont(font);
	ui.lblStatus->setText(statusGroup->checkedAction()->text());
	nAvatar = pLocalUser->avatar;
	ui.txtNote->setText(pLocalUser->note);

	pSoundPlayer = new lmcSoundPlayer();
	pSettings = new lmcSettings();
	restoreGeometry(pSettings->value(IDS_WINDOWMAIN).toByteArray());
	//	get saved settings
	settingsChanged(true);
	setUIText();

	initGroups(pGroupList);
}
Example #9
0
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); 
}
Example #10
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();
}
Example #11
0
MainWindow::MainWindow()
  : m_ui(new Ui::MainWindow),
    m_logWindow(NULL),
    m_openWithManagerDialog(NULL),
    m_queueManagerDialog(NULL),
    m_minimizeAction(NULL),
    m_maximizeAction(NULL),
    m_restoreAction(NULL),
    m_trayIcon(NULL),
    m_trayIconMenu(NULL),
    m_statusTotalJobs(new QLabel(this)),
    m_statusHiddenJobs(new QLabel(this)),
    m_server(new Server (this))
{
  m_ui->setupUi(this);

  QIcon icon(":/icons/molequeue.png");
  setWindowIcon(icon);

  createActions();
  createActionFactories();
  createShortcuts();
  createMainMenu();
  createTrayIcon();
  createJobTable();
  createStatusBar();

  readSettings();

  connect(m_server, SIGNAL(connectionError(MoleQueue::ConnectionListener::Error,QString)),
          this, SLOT(handleServerConnectionError(MoleQueue::ConnectionListener::Error, QString)));

  connect(Logger::getInstance(), SIGNAL(firstNewErrorOccurred()),
          this, SLOT(errorOccurred()));
  connect(Logger::getInstance(), SIGNAL(newErrorCountReset()),
          this, SLOT(errorCleared()));
  connect(m_ui->errorNotificationLabel, SIGNAL(linkActivated(QString)),
          this, SLOT(handleErrorNotificationLabelAction(QString)));
  connect(m_server->jobManager(), SIGNAL(jobStateChanged(MoleQueue::Job,
                                                         MoleQueue::JobState,
                                                         MoleQueue::JobState)),
          this, SLOT(notifyJobStateChange(MoleQueue::Job,
                                          MoleQueue::JobState,
                                          MoleQueue::JobState)));

  m_server->start();

  m_ui->errorNotificationLabel->hide();
  m_trayIcon->show();
}
Example #12
0
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);
	}
Example #14
0
TextEditorWindow::TextEditorWindow(QWidget *parent, Qt::WindowFlags flags)
        : QMainWindow(parent, flags)
{
    textEdit = new QTextEdit;
    QTextDocument *htmlDoc = textEdit->document();
    htmlDoc->setHtml("<h1>Edit title!</h1> <p>Normal paragraph</p> <ul><li>Some</li>  <li>Fancy</li> <li>Listing</li>  </ul> " );
    textEdit->setLineWrapMode(QTextEdit::NoWrap);
    textEdit->setDocument(htmlDoc);
    setCentralWidget(textEdit);
    setWindowTitle(tr("Your own Basic Text editor"));
    statusBar()->showMessage(tr("Status Bar"));

    createActions();
    createMainMenu();
}
Example #15
0
// Method to create the main title
void Window::createTitle()
{
    // Creates the group box
    titleGroupBox = new QGroupBox();

    // Creates the Horizontal Box Layout for the group box
    QHBoxLayout *layout = new QHBoxLayout;

    // Creates the main title of the program label
    QLabel *mainTitle = new QLabel(tr("Scout Talker"));

    // Center aligns the label
    mainTitle->setAlignment(Qt::AlignCenter);

    QFont font;
    font.setFamily(font.defaultFamily()); // Sets the font as the default one
    font.setPointSize(20); // Sets font size
    font.setBold(true); // Sets font as bold

    // Changes the label font
    mainTitle->setFont(font);

    // Creates the main menu
    createMainMenu();

    // Set alignment of the layout
    layout->setAlignment(Qt::AlignCenter);

    // Add an empty space with the size of 50
    layout->insertSpacing(0, 50);

    // Add title widget to the layout
    layout->addWidget(mainTitle);

    // Add space between widgets
    layout->addSpacing(25);

    // Add button to the layout
    layout->addWidget(mainMenuButton);

    // Add an empty space with the size of 50
    layout->addSpacing(50);

    // Sets the group box layout
    titleGroupBox->setLayout(layout);
    // Command to remove border of Group Box
    titleGroupBox->setStyleSheet("QGroupBox {border: 0px solid gray;}");
}
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);
	}
	MainMenuControlLE::MainMenuControlLE(MyGUI::Widget* _parent) :
		wraps::BaseLayout("MainMenuControl.layout", _parent),
		mBar(nullptr),
		mPopupMenuWidgets(nullptr)
	{
		assignWidget(mBar, "Menu");

		createMainMenu();

		SettingsManager::getInstance().eventSettingsChanged.connect(this, &MainMenuControlLE::notifySettingsChanged);
		EditorWidgets::getInstance().eventChangeWidgets += MyGUI::newDelegate(this, &MainMenuControlLE::notifyChangeWidgets);

		CommandManager::getInstance().getEvent("Command_OnChangeScale")->connect(this, &MainMenuControlLE::CommandOnChangeScale);

		updateMenuScale(100);
	}
Example #18
0
GridEditor::GridEditor(int& argc,char**& argv)
	:Vrui::Application(argc,argv),
	 grid(0),
	 exportSurfaceHelper("ExportedSurface.ply",".ply",Vrui::openDirectory(".")),
	 mainMenu(0)
	{
	if(argc>=2)
		{
		/* Load the grid from a float-valued vol file: */
		Misc::File volFile(argv[1],"rb",Misc::File::BigEndian);
		
		/* Read the file header: */
		EditableGrid::Index numVertices;
		volFile.read<int>(numVertices.getComponents(),3);
		int borderSize=volFile.read<int>();
		for(int i=0;i<3;++i)
			numVertices[i]+=borderSize*2;
		float domainSize[3];
		volFile.read<float>(domainSize,3);
		EditableGrid::Size cellSize;
		for(int i=0;i<3;++i)
			cellSize[i]=domainSize[i]/float(numVertices[i]-borderSize*2-1);
		
		/* Create the grid: */
		grid=new EditableGrid(numVertices,cellSize);
		
		/* Read all grid values: */
		for(EditableGrid::Index i(0);i[0]<grid->getNumVertices(0);i.preInc(grid->getNumVertices()))
			grid->setValue(i,volFile.read<float>());
		grid->invalidateVertices(EditableGrid::Index(0,0,0),grid->getNumVertices());
		}
	else
		{
		/* Create a new grid: */
		grid=new EditableGrid(EditableGrid::Index(256,256,256),EditableGrid::Size(1.0f,1.0f,1.0f));
		}
	
	/* Create the program GUI: */
	mainMenu=createMainMenu();
	Vrui::setMainMenu(mainMenu);
	
	/* Initialize the navigation transformation: */
	centerDisplayCallback(0);
	
	/* Initialize the tool classes: */
	EditTool::initClass(*Vrui::getToolManager());
	}
void VisualizerView::ShowMenu(void)
{
    QString label = tr("Actions");

    MythMenu *menu = new MythMenu(label, this, "menu");

    menu->AddItem(tr("Change Visualizer"), NULL, createVisualizerMenu());
    menu->AddItem(tr("Show Track Info"), SLOT(showTrackInfoPopup()));
    menu->AddItem(tr("Other Options"), NULL, createMainMenu());

    MythScreenStack *popupStack = GetMythMainWindow()->GetStack("popup stack");

    MythDialogBox *menuPopup = new MythDialogBox(menu, popupStack, "actionmenu");

    if (menuPopup->Create())
        popupStack->AddScreen(menuPopup);
    else
        delete menuPopup;
}
Example #20
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);
	}
Example #21
0
void SearchView::ShowMenu(void)
{
    if (GetFocusWidget() == m_tracksList)
    {
        QString label = tr("Search Actions");

        MythMenu *menu = new MythMenu(label, this, "searchviewmenu");

        MythUIButtonListItem *item = m_tracksList->GetItemCurrent();
        if (item)
        {
            MusicMetadata *mdata = qVariantValue<MusicMetadata*> (item->GetData());
            if (mdata)
            {
                if (gPlayer->getPlaylist()->checkTrack(mdata->ID()))
                    menu->AddItem(tr("Remove From Playlist"));
                else
                {
                    menu->AddItem(tr("Add To Playlist"));
                    menu->AddItem(tr("Add To Playlist And Play"));
                }
            }
        }

        if (GetFocusWidget() == m_tracksList || GetFocusWidget() == m_currentPlaylist)
            menu->AddItem(tr("Search List..."));

        menu->AddItem(tr("More Options"), NULL, createMainMenu());

        MythScreenStack *popupStack = GetMythMainWindow()->GetStack("popup stack");

        MythDialogBox *menuPopup = new MythDialogBox(menu, popupStack, "actionmenu");

        if (menuPopup->Create())
            popupStack->AddScreen(menuPopup);
        else
            delete menu;
    }
    else
        MusicCommon::ShowMenu();
}
/**
*Class constructor
**/
MainWindow::MainWindow()
{
    //QApplication::setStyle(QStyleFactory::create("cleanlooks"));

	mdiArea = new QMdiArea;
    setCentralWidget(mdiArea);

    setWindowIcon(QIcon(":/images/icon.png"));
	setWindowTitle(tr("Live helper chat"));

	createActions();
	createTrayIcon();
	createMainMenu();

	// Try icon changing
	connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
            this, SLOT(iconActivated(QSystemTrayIcon::ActivationReason)));

    connect(trayIcon, SIGNAL(messageClicked()), this, SLOT(messageClicked()));


	trayIcon->show();

	this->createStatusBar();

    QFile file(qApp->applicationDirPath() + "/qss/lhc.qss");
    file.open(QFile::ReadOnly);
    QString styleSheet = QLatin1String(file.readAll());
    qApp->setStyleSheet(styleSheet);

    this->chatID = 0;
    this->chatMode = 0;

    audioOutput = new Phonon::AudioOutput(Phonon::NotificationCategory, this);
    mediaObject = new Phonon::MediaObject(this);
    Phonon::createPath(mediaObject, audioOutput);

}
Example #23
0
ClusterJello::ClusterJello(int& argc,char**& argv,char**& appDefaults)
	:Vrui::Application(argc,argv,appDefaults),
	 clusterPipe(Vrui::openPipe()),
	 crystal(0),
	 atomLocks(17),
	 updateTime(0.02),
	 renderer(0),
	 mainMenu(0),settingsDialog(0),
	 nextDraggerID(0)
	{
	/* Target frame rate is only (optional) command line parameter: */
	if(argc>=2)
		updateTime=1.0/atof(argv[1]);
	
	/* Initialize the proxy crystal states: */
	for(int i=0;i<3;++i)
		proxyCrystal.accessSlot(i).setNumAtoms(JelloCrystal::Index(4,4,8));
	
	/* Initialize the crystal renderer: */
	renderer=new JelloRenderer(proxyCrystal.getLockedValue());
	
	/* Determine a good color to draw the domain box: */
	GLColor<GLfloat,3> domainBoxColor;
	for(int i=0;i<3;++i)
		domainBoxColor[i]=1.0f-Vrui::getBackgroundColor()[i];
	renderer->setDomainBoxColor(domainBoxColor);
	
	if(Vrui::isMaster())
		{
		/* Initialize the simulated Jell-O crystal: */
		crystal=new JelloCrystal(JelloCrystal::Index(4,4,8));
		currentSimulationParameters.atomMass=crystal->getAtomMass();
		currentSimulationParameters.attenuation=crystal->getAttenuation();
		currentSimulationParameters.gravity=crystal->getGravity();
		Vrui::write(clusterPipe,currentSimulationParameters.atomMass);
		Vrui::write(clusterPipe,currentSimulationParameters.attenuation);
		Vrui::write(clusterPipe,currentSimulationParameters.gravity);
		Vrui::finishMessage(clusterPipe);
		
		/* Start the simulation thread: */
		simulationThread.start(this,&ClusterJello::simulationThreadMethodMaster);
		}
	else
		{
		/* Receive the initial simulation parameters: */
		currentSimulationParameters.atomMass=clusterPipe->read<Scalar>();
		currentSimulationParameters.attenuation=clusterPipe->read<Scalar>();
		currentSimulationParameters.gravity=clusterPipe->read<Scalar>();
		
		/* Start the simulation thread: */
		simulationThread.start(this,&ClusterJello::simulationThreadMethodSlave);
		}
	
	/* Create the program's user interface: */
	mainMenu=createMainMenu();
	Vrui::setMainMenu(mainMenu);
	settingsDialog=createSettingsDialog();
	
	/* Initialize the navigation transformation: */
	centerDisplayCallback(0);
	}
Example #24
0
/******************************************************************************
* The constructor of the main window class.
******************************************************************************/
MainWindow::MainWindow() : _datasetContainer(this)
{
	setWindowTitle(tr("Ovito (Open Visualization Tool)"));
	setAttribute(Qt::WA_DeleteOnClose);

	// Setup the layout of docking widgets.
	setCorner(Qt::BottomLeftCorner, Qt::LeftDockWidgetArea);
	setCorner(Qt::BottomRightCorner, Qt::RightDockWidgetArea);

	// Disable context menus in toolbars.
	setContextMenuPolicy(Qt::NoContextMenu);

	// Create input manager.
	_viewportInputManager = new ViewportInputManager(this);

	// Create actions.
	_actionManager = new ActionManager(this);

	// Create the main menu
	createMainMenu();

	// Create the main toolbar.
	createMainToolbar();

	ViewportsPanel* viewportsPanel = new ViewportsPanel(this);
	setCentralWidget(viewportsPanel);

	// Create the animation panel below the viewports.
	QWidget* animationPanel = new QWidget();
	QVBoxLayout* animationPanelLayout = new QVBoxLayout();
	animationPanelLayout->setSpacing(0);
	animationPanelLayout->setContentsMargins(0, 1, 0, 0);
	animationPanel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
#if defined(Q_OS_LINUX)
	QHBoxLayout* animationPanelParentLayout = new QHBoxLayout(animationPanel);
	animationPanelParentLayout->setSpacing(0);
	animationPanelParentLayout->setContentsMargins(0, 0, 0, 0);
	animationPanelParentLayout->addLayout(animationPanelLayout, 1);
	QFrame* verticalRule = new QFrame(animationPanel);
	verticalRule->setContentsMargins(0,0,0,0);
	verticalRule->setFrameStyle(QFrame::VLine | QFrame::Sunken);
	verticalRule->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Expanding);
	animationPanelParentLayout->addWidget(verticalRule);
#else
	animationPanel->setLayout(animationPanelLayout);
#endif

	// Create animation time slider
	AnimationTimeSlider* timeSlider = new AnimationTimeSlider(this);
	animationPanelLayout->addWidget(timeSlider);
	AnimationTrackBar* trackBar = new AnimationTrackBar(this, timeSlider);
	animationPanelLayout->addWidget(trackBar);

	// Create status bar.
	_statusBarLayout = new QHBoxLayout();
	_statusBarLayout->setContentsMargins(0,0,0,0);
	_statusBarLayout->setSpacing(0);
	animationPanelLayout->addLayout(_statusBarLayout, 1);

	_statusBar = new QStatusBar(animationPanel);
	_statusBar->setSizeGripEnabled(false);
	_statusBar->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Preferred);
	setStatusBar(_statusBar);
	_statusBarLayout->addWidget(_statusBar, 1);

	_coordinateDisplay = new CoordinateDisplayWidget(datasetContainer(), animationPanel);
	_statusBarLayout->addWidget(_coordinateDisplay);

	// Create the animation control toolbar.
	QToolBar* animationControlBar1 = new QToolBar();
	animationControlBar1->addAction(actionManager()->getAction(ACTION_GOTO_START_OF_ANIMATION));
	animationControlBar1->addSeparator();
	animationControlBar1->addAction(actionManager()->getAction(ACTION_GOTO_PREVIOUS_FRAME));
	animationControlBar1->addAction(actionManager()->getAction(ACTION_TOGGLE_ANIMATION_PLAYBACK));
	animationControlBar1->addAction(actionManager()->getAction(ACTION_GOTO_NEXT_FRAME));
	animationControlBar1->addSeparator();
	animationControlBar1->addAction(actionManager()->getAction(ACTION_GOTO_END_OF_ANIMATION));
	QToolBar* animationControlBar2 = new QToolBar();
#if 1
	animationControlBar2->addAction(actionManager()->getAction(ACTION_AUTO_KEY_MODE_TOGGLE));
#else
	animationControlBar2->addWidget(new AnimationFramesToolButton(datasetContainer()));
#endif
	QWidget* animationTimeSpinnerContainer = new QWidget();
	QHBoxLayout* animationTimeSpinnerLayout = new QHBoxLayout(animationTimeSpinnerContainer);
	animationTimeSpinnerLayout->setContentsMargins(0,0,0,0);
	animationTimeSpinnerLayout->setSpacing(0);
	class TimeEditBox : public QLineEdit {
	public:
		virtual QSize sizeHint() const { return minimumSizeHint(); }
	};
	QLineEdit* timeEditBox = new TimeEditBox();
	timeEditBox->setToolTip(tr("Current Animation Time"));
	AnimationTimeSpinner* currentTimeSpinner = new AnimationTimeSpinner(this);
	currentTimeSpinner->setTextBox(timeEditBox);
	animationTimeSpinnerLayout->addWidget(timeEditBox, 1);
	animationTimeSpinnerLayout->addWidget(currentTimeSpinner);
	animationControlBar2->addWidget(animationTimeSpinnerContainer);
	animationControlBar2->addAction(actionManager()->getAction(ACTION_ANIMATION_SETTINGS));
	animationControlBar2->addWidget(new QWidget());

	QWidget* animationControlPanel = new QWidget();
	QVBoxLayout* animationControlPanelLayout = new QVBoxLayout(animationControlPanel);
	animationControlPanelLayout->setSpacing(0);
	animationControlPanelLayout->setContentsMargins(0, 1, 0, 0);
	animationControlPanelLayout->addWidget(animationControlBar1);
	animationControlPanelLayout->addWidget(animationControlBar2);
	animationControlPanelLayout->addStretch(1);
	animationControlPanel->setStyleSheet("QToolBar { padding: 0px; margin: 0px; border: 0px none black; } QToolButton { padding: 0px; margin: 0px }");
	animationControlPanel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred);

	// Create the viewport control toolbar.
	QToolBar* viewportControlBar1 = new QToolBar();
	viewportControlBar1->addAction(actionManager()->getAction(ACTION_VIEWPORT_ZOOM));
	viewportControlBar1->addAction(actionManager()->getAction(ACTION_VIEWPORT_PAN));
	viewportControlBar1->addAction(actionManager()->getAction(ACTION_VIEWPORT_ORBIT));
	viewportControlBar1->addAction(actionManager()->getAction(ACTION_VIEWPORT_PICK_ORBIT_CENTER));
	QToolBar* viewportControlBar2 = new QToolBar();
	viewportControlBar2->addAction(actionManager()->getAction(ACTION_VIEWPORT_ZOOM_SCENE_EXTENTS));
	viewportControlBar2->addAction(actionManager()->getAction(ACTION_VIEWPORT_ZOOM_SELECTION_EXTENTS));
	viewportControlBar2->addAction(actionManager()->getAction(ACTION_VIEWPORT_FOV));
	viewportControlBar2->addAction(actionManager()->getAction(ACTION_VIEWPORT_MAXIMIZE));
	QWidget* viewportControlPanel = new QWidget();
	QVBoxLayout* viewportControlPanelLayout = new QVBoxLayout(viewportControlPanel);
	viewportControlPanelLayout->setSpacing(0);
	viewportControlPanelLayout->setContentsMargins(0, 1, 0, 0);
	viewportControlPanelLayout->addWidget(viewportControlBar1);
	QHBoxLayout* sublayout = new QHBoxLayout();
	sublayout->addStretch(1);
	sublayout->addWidget(viewportControlBar2);
	viewportControlPanelLayout->addLayout(sublayout);
	viewportControlPanelLayout->addStretch(1);
	viewportControlPanel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred);
	viewportControlPanel->setStyleSheet("QToolBar { padding: 0px; margin: 0px; border: 0px none black; } QToolButton { padding: 0px; margin: 0px }");

	// Create the command panel.
	_commandPanel = new CommandPanel(this, this);

	createDockPanel(tr("Animation Panel"), "AnimationPanel", Qt::BottomDockWidgetArea, Qt::BottomDockWidgetArea, animationPanel);
	createDockPanel(tr("Animation Control Panel"), "AnimationControlPanel", Qt::BottomDockWidgetArea, Qt::BottomDockWidgetArea, animationControlPanel);
	createDockPanel(tr("Viewport Control"), "ViewportControlPanel", Qt::BottomDockWidgetArea, Qt::BottomDockWidgetArea, viewportControlPanel);
	createDockPanel(tr("Command Panel"), "CommandPanel", Qt::RightDockWidgetArea, Qt::DockWidgetAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea), _commandPanel);

	// Create the frame buffer window.
	_frameBufferWindow = new FrameBufferWindow(this);
}
Example #25
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));
}
Example #26
0
void PongApp::update( float realframeTime ) {

    static float frameTime = 1/60.0f;

    frameTime = frameTime*.75 + .25*realframeTime;

    if (!currentMenu && !currentGame && !highScores && !credits && allowMainMenuCreation==true) {
        currentMenu = createMainMenu();
    };

    if (credits) {
        if (credits->update( frameTime ) == 0) {
            delete credits;
            credits = 0;
        };
    };

    if (highScores) {
        if (highScores->update( frameTime ) == 0) {
            delete highScores;
            highScores = 0;
        };
    }

    if (background1) {
        if (background1->update( frameTime ) == false) {
            delete background1;
            background1 = 0;
        };
    };
    if (currentMenu)  {
        const char *command = currentMenu->run( frameTime );
        if (command) {
            GameMenu *newMenu = 0;
                // command has been triggered from the menu
            if (strcmp( command, "exit_query") == 0) {
                //newMenu = createExitQuery();
                engine->exit();
            } else if (strcmp( command, "start_game") == 0) {
                restartGame(true);
#ifdef IAP
            } else if (strncmp( command, "buy_mp_game", 11) == 0) {
                if ((strcmp(command, "buy_mp_game") == 0) && (m_multiplayerPurchased == 0 || m_multiplayerPurchased == 4)) {
                    engine->setUpdateAndPauseState(false, true);
                    engine->getMiniIAPClient()->prepare();
                    engine->setUpdateAndPauseState(false, true);
                    m_multiplayerPurchased = 1;
                    newMenu = createWaitingIAPMenu();
                }
                else if (strcmp(command, "buy_mp_game_waiting") == 0) {
                    if (m_multiplayerPurchased == 1) {
                        m_multiplayerPurchased = 2;
                        engine->setUpdateAndPauseState(true, true);
                        if (engine->getMiniIAPClient()->purchaseProduct(EPongIAP::IAP_ITEM_ID)) {
                            engine->setUpdateAndPauseState(true, true);

                            newMenu = createWaitingIAPMenu();
                        }
                        else {
                            engine->setUpdateAndPauseState(false, false);
                        }
                    }
                    else if (m_multiplayerPurchased == 2) {
                        newMenu = createWaitingIAPMenu();
                    }
                }
                else if (strcmp(command,"buy_mp_game_cancel") == 0) {
                    m_multiplayerPurchased = 4;
                    engine->setUpdateAndPauseState(false, false);
                    // case: "buy_mp_game_ok" -> nothing
                    // case: "buy_mp_game_bypass" -> nothing
                }
                //qDebug() << "buy_mp_game..., command" << command << (newMenu == 0? "no new menu":"new menu!");
#endif
            } else if (strcmp( command, "start_mp_game") == 0) {
                restartGame(false);
            } else if (strcmp( command, "show_scores") == 0) {
                if (highScores) delete highScores;
                highScores = new PongHighScores(this);
            } else if (strcmp( command, "buy_now") == 0)  {
                engine->openUrlInBrowser( "http://store.ovi.com" );
            } else if (strcmp( command, "cancel_game") == 0) {
                if (currentGame) {
                    delete currentGame;
                    currentGame = 0;
                }
            } else if (strcmp( command, "show_credits") == 0) {
                if (credits) delete credits;
                credits = new PongCredits(this);
            };

            delete currentMenu;
            if (!newMenu && currentGame && currentGame->getGameState() == PGS_RUNNING) {
                // return to game
                engine->startSensors();
            }
            currentMenu = newMenu;
        };
    }


    if (currentGame && !currentMenu) {
        if (!currentGame->update( frameTime, buttonDown, pointerX, pointerY)) {
            if (currentGame->isSinglePlayer()) {
                allowMainMenuCreation =false;
                int score = currentGame->getScore();
                delete currentGame;
                currentGame = 0;
                if (highScores) delete highScores;
                highScores = new PongHighScores( this, score );
                allowMainMenuCreation = true;
            } else {
                delete currentGame;
                currentGame = 0;
            }
        }
    }

    if (pengine) {
        pengine->setGravity( sensorGravity );
        pengine->run( frameTime );
    };
}
SharedJello::SharedJello(int& argc,char**& argv,char**& appDefaults)
	:Vrui::Application(argc,argv,appDefaults),
	 pipe(0),
	 newParameterVersion(1),parameterVersion(1),
	 lockedIndex(0),mostRecentIndex(1),
	 nextDraggerID(0),
	 mainMenu(0),settingsDialog(0)
	{
	/* Parse the command line: */
	const char* serverHostName=0;
	int serverPortID=-1;
	bool renderDomainBox=true;
	for(int i=0;i<argc;++i)
		{
		if(argv[i][0]=='-')
			{
			if(strcasecmp(argv[i]+1,"host")==0)
				{
				++i;
				if(i<argc)
					serverHostName=argv[i];
				else
					std::cerr<<"SharedJello::SharedJello: Ignored dangling -host option"<<std::endl;
				}
			else if(strcasecmp(argv[i]+1,"port")==0)
				{
				++i;
				if(i<argc)
					serverPortID=atoi(argv[i]);
				else
					std::cerr<<"SharedJello::SharedJello: Ignored dangling -port option"<<std::endl;
				}
			else if(strcasecmp(argv[i]+1,"nobox")==0)
				renderDomainBox=false;
			}
		}
	if(serverHostName==0||serverPortID<0)
		Misc::throwStdErr("SharedJello::SharedJello: No server host name or port ID provided");
	
	/* Connect to the shared Jell-O server: */
	pipe=Cluster::openTCPPipe(Vrui::getClusterMultiplexer(),serverHostName,serverPortID);
	pipe->negotiateEndianness();
	
	/* Initiate the connection: */
	if(readMessage(*pipe)!=CONNECT_REPLY)
		{
		/* Bail out: */
		pipe=0;
		Misc::throwStdErr("SharedJello::SharedJello: Connection refused by shared Jell-O server");
		}
	
	/* Read the Jell-O crystal's domain box: */
	read(domain,*pipe);
	
	/* Read the number of atoms in the Jell-O crystal: */
	Card na[3];
	pipe->read(na,3);
	JelloCrystal::Index numAtoms(na[0],na[1],na[2]);
	
	/* Wait for the first parameter update message to get the initial simulation parameters: */
	if(readMessage(*pipe)!=SERVER_PARAMUPDATE)
		{
		/* Bail out: */
		pipe=0;
		Misc::throwStdErr("SharedJello::SharedJello: Connection refused by shared Jell-O server");
		}
	atomMass=pipe->read<Scalar>();
	attenuation=pipe->read<Scalar>();
	gravity=pipe->read<Scalar>();
	
	/* Wait for the first server update message to get initial atom positions: */
	if(readMessage(*pipe)!=SERVER_UPDATE)
		{
		/* Bail out: */
		pipe=0;
		Misc::throwStdErr("SharedJello::SharedJello: Connection refused by shared Jell-O server");
		}
	
	/* Create triple buffer of Jell-O crystals: */
	for(int i=0;i<3;++i)
		crystals[i]=new JelloCrystal(numAtoms);
	
	/* Read the first crystal state: */
	crystals[mostRecentIndex]->readAtomStates(*pipe);
	
	/* Calculate the domain box color: */
	GLColor<GLfloat,3> domainBoxColor;
	for(int i=0;i<3;++i)
		domainBoxColor[i]=1.0f-Vrui::getBackgroundColor()[i];
	
	/* Create the triple buffer of Jell-O renderers: */
	for(int i=0;i<3;++i)
		{
		renderers[i]=new JelloRenderer(*crystals[i]);
		renderers[i]->setRenderDomainBox(renderDomainBox);
		renderers[i]->setDomainBoxColor(domainBoxColor);
		}
	renderers[mostRecentIndex]->update();
	
	/* Start the server communication thread: */
	communicationThread.start(this,&SharedJello::communicationThreadMethod);
	
	/* Create the program's user interface: */
	mainMenu=createMainMenu();
	Vrui::setMainMenu(mainMenu);
	settingsDialog=createSettingsDialog();
	
	/* Initialize the navigation transformation: */
	centerDisplayCallback(0);
	}
Example #28
0
KinectViewer::KinectViewer(int& argc,char**& argv)
	:Vrui::Application(argc,argv),
	 saveStreamsToggle(0),saveStreamsDirectory(Vrui::openDirectory(".")),saveStreamsFileSelectionDialog(0),
	 soundRecorder(0),soundPlayer(0),
	 mainMenu(0)
	{
	/* Add a streamer for each camera index or frame file name prefix passed on the command line: */
	bool printHelp=argc==1;
	bool highres=false;
	bool compressDepth=false;
	for(int i=1;i<argc;++i)
		{
		if(argv[i][0]=='-')
			{
			if(strcasecmp(argv[i]+1,"h")==0)
				printHelp=true;
			else if(strcasecmp(argv[i]+1,"high")==0)
				highres=true;
			else if(strcasecmp(argv[i]+1,"low")==0)
				highres=false;
			else if(strcasecmp(argv[i]+1,"compress")==0)
				compressDepth=true;
			else if(strcasecmp(argv[i]+1,"nocompress")==0)
				compressDepth=false;
			else if(strcasecmp(argv[i]+1,"c")==0)
				{
				++i;
				
				if(Vrui::getClusterMultiplexer()==0)
					{
					/* Open the camera of the given index: */
					int cameraIndex=atoi(argv[i]);
					Kinect::Camera* camera=new Kinect::Camera(cameraIndex);
					
					/* Set the camera's frame size and compression flag: */
					camera->setFrameSize(Kinect::FrameSource::COLOR,highres?Kinect::Camera::FS_1280_1024:Kinect::Camera::FS_640_480);
					camera->setCompressDepthFrames(compressDepth);
					
					/* Enable background removal if the camera has a default background image: */
					if(camera->loadDefaultBackground())
						camera->setRemoveBackground(true);
					
					/* Add a new streamer for the camera: */
					streamers.push_back(new KinectStreamer(this,camera));
					}
				else if(Vrui::isMaster())
					{
					/* Can't stream from local camera in cluster mode: */
					std::cerr<<"Ignoring -c "<<argv[i]<<" command line argument: Streaming from local Kinect camera(s) is not supported in cluster environments"<<std::endl;
					}
				}
			else if(strcasecmp(argv[i]+1,"c2")==0)
				{
				++i;
				
				if(Vrui::getClusterMultiplexer()==0)
					{
					/* Open the camera of the given index: */
					int cameraIndex=atoi(argv[i]);
					Kinect::CameraV2* camera=new Kinect::CameraV2(cameraIndex);
					
					/* Enable background removal if the camera has a default background image: */
					if(camera->loadDefaultBackground())
						camera->setRemoveBackground(true);
					
					/* Add a new streamer for the camera: */
					streamers.push_back(new KinectStreamer(this,camera));
					}
				else if(Vrui::isMaster())
					{
					/* Can't stream from local camera in cluster mode: */
					std::cerr<<"Ignoring -c2 "<<argv[i]<<" command line argument: Streaming from local Kinect V2 camera(s) is not supported in cluster environments"<<std::endl;
					}
				}
			else if(strcasecmp(argv[i]+1,"rs")==0)
				{
				++i;
				
				#if KINECT_CONFIG_HAVE_LIBREALSENSE
				
				if(Vrui::getClusterMultiplexer()==0)
					{
					/* Open the camera of the given index: */
					int cameraIndex=atoi(argv[i]);
					Kinect::CameraRealSense* camera=new Kinect::CameraRealSense(cameraIndex);
					
					/* Enable background removal if the camera has a default background image: */
					if(camera->loadDefaultBackground())
						camera->setRemoveBackground(true);
					
					/* Add a new streamer for the camera: */
					streamers.push_back(new KinectStreamer(this,camera));
					}
				else if(Vrui::isMaster())
					{
					/* Can't stream from local camera in cluster mode: */
					std::cerr<<"Ignoring -rs "<<argv[i]<<" command line argument: Streaming from local RealSense camera(s) is not supported in cluster environments"<<std::endl;
					}
				
				#else
				
				throw std::runtime_error("KinectViewer: Intel RealSense cameras not supported");
				
				#endif
				}
			else if(strcasecmp(argv[i]+1,"f")==0)
				{
				++i;
				
				/* Open a frame source for the color and depth files of the given name prefix: */
				std::string colorFileName=argv[i];
				colorFileName.append(".color");
				std::string depthFileName=argv[i];
				depthFileName.append(".depth");
				Kinect::FileFrameSource* fileSource=new Kinect::FileFrameSource(Vrui::openFile(colorFileName.c_str()),Vrui::openFile(depthFileName.c_str()));
				
				/* Add a new streamer for the file source: */
				streamers.push_back(new KinectStreamer(this,fileSource));
				}
			else if(strcasecmp(argv[i]+1,"s")==0)
				{
				++i;
				
				/* Open a sound player: */
				try
					{
					soundPlayer=new Sound::SoundPlayer(argv[i]);
					}
				catch(std::runtime_error err)
					{
					std::cerr<<"Could not open sound file "<<argv[i]<<" due to exception "<<err.what()<<std::endl;
					}
				}
			else if(strcasecmp(argv[i]+1,"p")==0)
				{
				i+=2;
				
				/* Open a multiplexed frame source for the given server host name and port number: */
				Kinect::MultiplexedFrameSource* source=Kinect::MultiplexedFrameSource::create(Cluster::openTCPPipe(Vrui::getClusterMultiplexer(),argv[i-1],atoi(argv[i])));
				
				/* Add a new streamer for each component stream in the multiplexer: */
				for(unsigned int i=0;i<source->getNumStreams();++i)
					streamers.push_back(new KinectStreamer(this,source->getStream(i)));
				}
			}
		}
	
	if(printHelp)
		{
		std::cout<<"Usage: KinectViewer [option 1] ... [option n]"<<std::endl;
		std::cout<<"  Options:"<<std::endl;
		std::cout<<"  -h"<<std::endl;
		std::cout<<"     Prints this help message"<<std::endl;
		std::cout<<"  -high"<<std::endl;
		std::cout<<"     Sets color frame size for all subsequent Kinect cameras to 1280x1024 @ 15Hz"<<std::endl;
		std::cout<<"  -low"<<std::endl;
		std::cout<<"     Sets color frame size for all subsequent Kinect cameras to 640x480 @ 30Hz"<<std::endl;
		std::cout<<"  -compress"<<std::endl;
		std::cout<<"     Requests compressed depth frames from all subsequent Kinect cameras"<<std::endl;
		std::cout<<"  -nocompress"<<std::endl;
		std::cout<<"     Requests uncompressed depth frames from all subsequent Kinect cameras"<<std::endl;
		std::cout<<"  -c <camera index>"<<std::endl;
		std::cout<<"     Connects to the local Kinect camera of the given index (0: first Kinect camera on USB bus)"<<std::endl;
		std::cout<<"  -c2 <camera index>"<<std::endl;
		std::cout<<"     Connects to the local Kinect v2 camera of the given index (0: first Kinect v2 camera on USB bus)"<<std::endl;
		std::cout<<"  -rs <camera index>"<<std::endl;
		std::cout<<"     Connects to the local Intel RealSense camera of the given index (0: first Intel RealSense camera on host)"<<std::endl;
		std::cout<<"  -f <stream file base name>"<<std::endl;
		std::cout<<"     Opens a previously recorded pair of color and depth stream files for playback"<<std::endl;
		std::cout<<"  -s <sound file name>"<<std::endl;
		std::cout<<"     Opens a previously recorded sound file for playback"<<std::endl;
		std::cout<<"  -p <host name of 3D video stream server> <port number of 3D video stream server>"<<std::endl;
		std::cout<<"     Connects to a 3D video streaming server identified by host name and port number"<<std::endl;
		}
	
	if(streamers.empty())
		{
		Vrui::shutdown();
		return;
		}
	
	/* Get a common time base for all streamers: */
	timeBase.set();
	
	/* Start playing back a sound file if requested: */
	if(soundPlayer!=0)
		soundPlayer->start();
	
	/* Start streaming on all streamers: */
	for(std::vector<KinectStreamer*>::iterator sIt=streamers.begin();sIt!=streamers.end();++sIt)
		(*sIt)->startStreaming(timeBase);
	
	/* Create the main menu: */
	mainMenu=createMainMenu();
	Vrui::setMainMenu(mainMenu);
	
	/* Initialize the custom tool classes: */
	SphereExtractorTool::initClass();
	}
NanotechConstructionKit::NanotechConstructionKit(int& argc,char**& argv,char**& appDefaults)
	:Vrui::Application(argc,argv,appDefaults),
	 grid(0),
	 createType(UnitDragger::NONE),draggingMode(UnitDragger::SINGLE_UNIT),
	 overrideTools(true),
	 influenceSphereRadius(10.0*Vrui::getUiSize()),
	 currentVoid(0),
	 mainMenu(0),statisticsDialog(0)
	{
	/* Parse the command line: */
	int loadFileMode=0;
	const char* loadFileName=0;
	const char* configFileName=NANOTECHCONSTRUCTIONKIT_CFGFILENAME;
	NCK::Scalar domainSize(24);
	for(int i=1;i<argc;++i)
		{
		if(argv[i][0]=='-')
			{
			if(strcasecmp(argv[i]+1,"CAR")==0)
				loadFileMode=1;
			else if(strcasecmp(argv[i]+1,"UNITS")==0)
				loadFileMode=0;
			else if(strcasecmp(argv[i]+1,"CONFIGFILE")==0)
				{
				++i;
				configFileName=argv[i];
				}
			else if(strcasecmp(argv[i]+1,"DOMAINSIZE")==0)
				{
				++i;
				domainSize=NCK::Scalar(atof(argv[i]));
				}
			}
		else
			loadFileName=argv[i];
		}
	
	/* Initialize structural unit classes: */
	Misc::ConfigurationFile nckConfigFile(configFileName);
	nckConfigFile.setCurrentSection("/NanotechConstructionKit");
	NCK::Scalar maxUnitRadius=NCK::UnitManager::initializeUnitTypes(nckConfigFile.getCurrentSection());
	
	/* Load the input file: */
	if(loadFileName!=0)
		{
		if(loadFileMode==0)
			{
			/* Read a unit file: */
			grid=NCK::readUnitFile(maxUnitRadius,loadFileName);
			}
		else
			{
			/* Read a CAR file: */
			grid=NCK::readCarFile(loadFileName);
			}
		}
	else
		{
		/* Create empty space grid: */
		NCK::Box gridBox(NCK::Point(-domainSize,-domainSize,-domainSize),NCK::Point(domainSize,domainSize,domainSize));
		grid=new NCK::SpaceGrid(gridBox,maxUnitRadius,0x7);
		}
	
	/* Set space grid parameters: */
	grid->setAttenuation(Math::pow(nckConfigFile.retrieveValue<double>("./attenuation",0.95),20.0));
	
	/* Set space grid rendering flags: */
	grid->readRenderingFlags(nckConfigFile.getSection("./RenderingFlags"));
	
	/* Calculate grid boundary color based on background color: */
	Vrui::Color gridColor;
	for(int i=0;i<3;++i)
		gridColor[i]=1.0f-Vrui::getBackgroundColor()[i];
	gridColor[3]=1.0f;
	grid->setGridBoundaryColor(gridColor);
	
	/* Create the UI widgets: */
	mainMenu=createMainMenu();
	Vrui::setMainMenu(mainMenu);
	statisticsDialog=createStatisticsDialog();
	
	/* Initialize navigation transformation: */
	centerDisplayCallback(0);
	
	/* Enable continuous update: */
	Vrui::updateContinuously();
	}
Example #30
0
VRMeshEditor::VRMeshEditor(int& argc,char**& argv,char**& appDefaults)
    :Vrui::Application(argc,argv,appDefaults),
     mesh(0),
     morphBox(0),
     defaultDraggerType(MESHDRAGGER),
     defaultActionType(Influence::DRAG),
     overrideTools(true),
     renderMode(SHADED),
     meshMaterial(GLMaterial::Color(0.7f,0.7f,0.7f),GLMaterial::Color(1.0f,1.0f,1.0f),50.0f),
     mainMenu(0)
{
    /* Parse the command line: */
    int meshFileType=1;
    const char* meshFileName=0;
    int subdivisionDepth=2;
    for(int i=1; i<argc; ++i)
    {
        if(argv[i][0]=='-')
        {
            if(strcasecmp(argv[i]+1,"GTS")==0)
                meshFileType=2;
            else if(strcasecmp(argv[i]+1,"PLY")==0)
                meshFileType=3;
            else if(strcasecmp(argv[i]+1,"DEPTH")==0)
            {
                subdivisionDepth=atoi(argv[i+1]);
                ++i;
            }
        }
        else
            meshFileName=argv[i];
    }
    if(meshFileName==0)
    {
        meshFileType=4;
        // throw std::runtime_error("VRMeshEditor: No mesh file name supplied");
    }

    /* Load the base mesh: */
    MyMesh::BaseMesh* baseMesh=0;
    switch(meshFileType)
    {
    case 1:
        baseMesh=loadMeshfile<MyMesh::Point>(meshFileName);
        break;

    case 2:
        baseMesh=loadGtsMeshfile<MyMesh::Point>(meshFileName);
        break;

    case 3:
        baseMesh=loadPlyMeshfile<MyMesh::Point>(meshFileName);
        break;

    case 4:
        baseMesh=createTetrahedron<MyMesh::Point>();
        break;
    }

    /* Subdivide the base mesh: */
    for(int i=0; i<subdivisionDepth; ++i)
        subdivideCatmullClark(*baseMesh);
    mesh=new MyMesh(*baseMesh);
    delete baseMesh;

    /* Create the main menu: */
    mainMenu=createMainMenu();
    Vrui::setMainMenu(mainMenu);

    /* Set additional physical-space light sources: */
    Vrui::Point l1=Vrui::getDisplayCenter()+Vrui::Vector(-1.0,-0.1,0.5)*Vrui::getDisplaySize();
    Vrui::Point l2=Vrui::getDisplayCenter()+Vrui::Vector(1.0,-0.1,0.5)*Vrui::getDisplaySize();
    Vrui::getLightsourceManager()->createLightsource(true,GLLight(GLLight::Color(0.5f,0.25f,0.25f),GLLight::Position(l1[0],l1[1],l1[2],1.0f)));
    Vrui::getLightsourceManager()->createLightsource(true,GLLight(GLLight::Color(0.25f,0.25f,0.5f),GLLight::Position(l2[0],l2[1],l2[2],1.0f)));

    /* Initialize navigation transformation: */
    centerDisplayCallback(0);
}