示例#1
0
void RayMenuTool::buttonCallback(int,InputDevice::ButtonCallbackData* cbData)
	{
	if(cbData->newButtonState) // Button has just been pressed
		{
		/* Check if the GUI interactor refuses the event: */
		GUIInteractor::updateRay();
		if(!(factory->interactWithWidgets&&GUIInteractor::buttonDown(false)))
			{
			/* Try activating this tool: */
			if(GUIInteractor::canActivate()&&activate())
				{
				/***************************************************************
				Pop up the tool's menu at the appropriate position and
				orientation:
				***************************************************************/
				
				if(isUseEyeRay()||interactionDevice->isRayDevice())
					{
					/* Pop up the menu at the ray's intersection with the UI plane: */
					popupPrimaryWidget(menu->getPopup(),calcRayPoint(GUIInteractor::getRay()),false);
					}
				else
					{
					/* Pop up the menu: */
					popupPrimaryWidget(menu->getPopup(),GUIInteractor::getRay()(factory->initialMenuOffset),false);
					}
				
				/* Grab the pointer: */
				getWidgetManager()->grabPointer(menu->getPopup());
				
				/* Force the event on the GUI interactor: */
				GUIInteractor::buttonDown(true);
				}
			}
		}
	else // Button has just been released
		{
		/* Check if the GUI interactor is active: */
		if(GUIInteractor::isActive())
			{
			/* Deliver the event: */
			GUIInteractor::buttonUp();
			
			/* Check if the tool's menu is popped up: */
			if(MenuTool::isActive())
				{
				/* Release the pointer: */
				getWidgetManager()->releasePointer(menu->getPopup());
				
				/* Pop down the menu: */
				getWidgetManager()->popdownWidget(menu->getPopup());
				
				/* Deactivate the tool: */
				deactivate();
				}
			}
		}
	}
MouseDialogNavigationTool::MouseDialogNavigationTool(const ToolFactory* factory,const ToolInputAssignment& inputAssignment)
	:NavigationTool(factory,inputAssignment),
	 GUIInteractor(false,Scalar(0),getButtonDevice(0)),
	 mouseAdapter(0),
	 navigationDialogPopup(0),
	 currentPos(Point::origin),
	 navigationMode(ROTATING),
	 spinning(false),
	 showScreenCenter(false)
	{
	/* Find the mouse input device adapter controlling the input device: */
	InputDevice* rootDevice=getInputGraphManager()->getRootDevice(getButtonDevice(0));
	mouseAdapter=dynamic_cast<InputDeviceAdapterMouse*>(getInputDeviceManager()->findInputDeviceAdapter(rootDevice));
	
	/* Create the tool's GUI: */
	navigationDialogPopup=new GLMotif::PopupWindow("NavigationDialogPopup",getWidgetManager(),"Mouse Navigation Dialog");
	
	GLMotif::RowColumn* navigationDialog=new GLMotif::RowColumn("NavigationDialog",navigationDialogPopup,false);
	
	GLMotif::RadioBox* navigationModes=new GLMotif::RadioBox("NavigationModes",navigationDialog,false);
	navigationModes->setOrientation(GLMotif::RowColumn::VERTICAL);
	navigationModes->setPacking(GLMotif::RowColumn::PACK_GRID);
	navigationModes->setSelectionMode(GLMotif::RadioBox::ALWAYS_ONE);
	
	navigationModes->addToggle("Rotate");
	navigationModes->addToggle("Pan");
	navigationModes->addToggle("Dolly");
	navigationModes->addToggle("Scale");
	
	switch(navigationMode)
		{
		case ROTATING:
			navigationModes->setSelectedToggle(0);
			break;
		
		case PANNING:
			navigationModes->setSelectedToggle(1);
			break;
		
		case DOLLYING:
			navigationModes->setSelectedToggle(2);
			break;
		
		case SCALING:
			navigationModes->setSelectedToggle(3);
			break;
		}
	navigationModes->getValueChangedCallbacks().add(this,&MouseDialogNavigationTool::navigationModesValueChangedCallback);
	navigationModes->manageChild();
	
	GLMotif::ToggleButton* showScreenCenterToggle=new GLMotif::ToggleButton("ShowScreenCenterToggle",navigationDialog,"Show Screen Center");
	showScreenCenterToggle->setToggle(showScreenCenter);
	showScreenCenterToggle->getValueChangedCallbacks().add(this,&MouseDialogNavigationTool::showScreenCenterToggleValueChangedCallback);
	
	navigationDialog->manageChild();
	
	/* Pop up the navigation dialog: */
	popupPrimaryWidget(navigationDialogPopup);
	}
示例#3
0
void SketchingTool::loadCurvesCallback(Misc::CallbackData* cbData)
	{
	/* Create a file selection dialog to select a curve file: */
	GLMotif::FileSelectionDialog* loadCurvesDialog=new GLMotif::FileSelectionDialog(getWidgetManager(),"Load Curves...",0,".curves",openPipe());
	loadCurvesDialog->getOKCallbacks().add(this,&SketchingTool::loadCurvesOKCallback);
	loadCurvesDialog->getCancelCallbacks().add(loadCurvesDialog,&GLMotif::FileSelectionDialog::defaultCloseCallback);
	
	/* Show the file selection dialog: */
	popupPrimaryWidget(loadCurvesDialog);
	}
示例#4
0
void ViewerConfiguration::enable(void)
	{
	/* Ignore the first time the vislet is enabled: */
	if(firstEnable)
		{
		firstEnable=false;
		return;
		}
	
	/* Check if the filming control GUI needs to be created: */
	if(dialogWindow==0)
		buildViewerConfigurationControls();
	
	/* Show the viewer configuration dialog: */
	popupPrimaryWidget(dialogWindow);
	
	active=true;
	}
void ViewpointFileNavigationTool::createGui(void)
	{
	const GLMotif::StyleSheet& ss=*getWidgetManager()->getStyleSheet();
	
	/* Create the playback control dialog window: */
	controlDialogPopup=new GLMotif::PopupWindow("ControlDialogPopup",getWidgetManager(),"Playback Control");
	controlDialogPopup->setResizableFlags(true,false);
	
	GLMotif::RowColumn* controlDialog=new GLMotif::RowColumn("ControlDialog",controlDialogPopup,false);
	controlDialog->setOrientation(GLMotif::RowColumn::VERTICAL);
	controlDialog->setPacking(GLMotif::RowColumn::PACK_TIGHT);
	controlDialog->setNumMinorWidgets(2);
	
	new GLMotif::Label("PositionLabel",controlDialog,"Position");
	
	positionSlider=new GLMotif::TextFieldSlider("PositionSlider",controlDialog,8,ss.fontHeight*10.0f);
	positionSlider->getTextField()->setFloatFormat(GLMotif::TextField::FIXED);
	positionSlider->getTextField()->setFieldWidth(7);
	positionSlider->getTextField()->setPrecision(1);
	positionSlider->setValueRange(splines.front().t[0],splines.back().t[1],1.0);
	positionSlider->setValue(parameter);
	positionSlider->getValueChangedCallbacks().add(this,&ViewpointFileNavigationTool::positionSliderCallback);
	
	new GLMotif::Label("SpeedLabel",controlDialog,"Speed");
	
	GLMotif::TextFieldSlider* speedSlider=new GLMotif::TextFieldSlider("SpeedSlider",controlDialog,8,ss.fontHeight*10.0f);
	speedSlider->getTextField()->setFloatFormat(GLMotif::TextField::FIXED);
	speedSlider->getTextField()->setFieldWidth(7);
	speedSlider->getTextField()->setPrecision(2);
	speedSlider->setValueRange(-2.0,2.0,0.01);
	speedSlider->getSlider()->addNotch(-1.0f);
	speedSlider->getSlider()->addNotch(1.0f);
	speedSlider->setValue(speed);
	speedSlider->getValueChangedCallbacks().add(this,&ViewpointFileNavigationTool::speedSliderCallback);
	
	controlDialog->manageChild();
	
	popupPrimaryWidget(controlDialogPopup);
	}
示例#6
0
void MessageLogger::showMessageDialog(int messageLevel,const char* messageString)
	{
	/* Assemble the dialog title: */
	std::string title=messageLevel<Warning?"Note":messageLevel<Error?"Warning":"Error";
	
	/* Check if the messageString starts with a source identifier: */
	const char* colonPtr=0;
	for(const char* mPtr=messageString;*mPtr!='\0'&&!isspace(*mPtr);++mPtr)
		if(*mPtr==':')
			colonPtr=mPtr;
	
	if(colonPtr!=0&&colonPtr[1]!='\0'&&isspace(colonPtr[1]))
		{
		/* Append the messageString source to the title: */
		title.append(" from ");
		title.append(messageString,colonPtr);
		
		/* Cut the source from the messageString: */
		messageString=colonPtr+1;
		}
	
	/* Create a popup window: */
	GLMotif::PopupWindow* messageDialog=new GLMotif::PopupWindow("VruiMessageLoggerMessage",getWidgetManager(),title.c_str());
	messageDialog->setResizableFlags(false,false);
	messageDialog->setHideButton(false);
	
	GLMotif::RowColumn* message=new GLMotif::RowColumn("Message",messageDialog,false);
	message->setOrientation(GLMotif::RowColumn::VERTICAL);
	message->setPacking(GLMotif::RowColumn::PACK_TIGHT);
	
	/* Skip initial whitespace in the message message: */
	const char* linePtr=messageString;
	while(*linePtr!='\0'&&isspace(*linePtr))
		++linePtr;
	
	/* Break the message message into multiple lines: */
	while(*linePtr!='\0')
		{
		/* Find potential line break points: */
		const char* breakPtr=0;
		const char* cPtr=linePtr;
		do
			{
			/* Find the end of the current word: */
			while(!isspace(*cPtr)&&*cPtr!='-'&&*cPtr!='/'&&*cPtr!='\0')
				++cPtr;
			
			/* Skip past dashes and slashes: */
			while(*cPtr=='-'||*cPtr=='/')
				++cPtr;
			
			/* If the line is already too long, and there is a previous break point, break there: */
			if(cPtr-linePtr>=40&&breakPtr!=0)
				break;
			
			/* Mark the break point: */
			breakPtr=cPtr;
			
			/* Skip whitespace: */
			while(isspace(*cPtr)&&*cPtr!='\0')
				++cPtr;
			}
		while(cPtr-linePtr<40&&*breakPtr!='\n'&&*breakPtr!='\0');
		
		/* Add the current line: */
		new GLMotif::Label("messageLine",message,linePtr,breakPtr);
		
		/* Go to the beginning of the next line: */
		linePtr=breakPtr;
		while(isspace(*linePtr)&&*linePtr!='\0')
			++linePtr;
		}
	
	/* Add an acknowledgment button: */
	GLMotif::Margin* buttonMargin=new GLMotif::Margin("ButtonMargin",message,false);
	buttonMargin->setAlignment(GLMotif::Alignment::RIGHT);
	GLMotif::Button* okButton=new GLMotif::Button("OkButton",buttonMargin,messageLevel<Warning?"Gee, thanks":messageLevel<Error?"Alright then":"Darn it!");
	okButton->getSelectCallbacks().add(closeMessageDialog);
	
	buttonMargin->manageChild();
	
	message->manageChild();
	
	/* Show the popup window: */
	popupPrimaryWidget(messageDialog);
	}
示例#7
0
SketchingTool::SketchingTool(const ToolFactory* factory,const ToolInputAssignment& inputAssignment)
	:UtilityTool(factory,inputAssignment),
	 controlDialogPopup(0),lineWidthValue(0),colorBox(0),
	 newLineWidth(3.0f),newColor(255,0,0),
	 active(false)
	{
	/* Get the style sheet: */
	const GLMotif::StyleSheet* ss=getWidgetManager()->getStyleSheet();
	
	/* Build the tool control dialog: */
	controlDialogPopup=new GLMotif::PopupWindow("SketchingToolControlDialog",getWidgetManager(),"Curve Editor Settings");
	controlDialogPopup->setResizableFlags(false,false);
	
	GLMotif::RowColumn* controlDialog=new GLMotif::RowColumn("ControlDialog",controlDialogPopup,false);
	controlDialog->setNumMinorWidgets(1);

	GLMotif::RowColumn* settingsBox=new GLMotif::RowColumn("SettingsBox",controlDialog,false);
	settingsBox->setNumMinorWidgets(2);
	
	/* Create a slider to set the line width: */
	new GLMotif::Label("LineWidthLabel",settingsBox,"Line Width");
	
	GLMotif::RowColumn* lineWidthBox=new GLMotif::RowColumn("LineWidthBox",settingsBox,false);
	lineWidthBox->setOrientation(GLMotif::RowColumn::HORIZONTAL);
	
	lineWidthValue=new GLMotif::TextField("LineWidthValue",lineWidthBox,4);
	lineWidthValue->setFloatFormat(GLMotif::TextField::FIXED);
	lineWidthValue->setPrecision(1);
	lineWidthValue->setValue(newLineWidth);
	
	GLMotif::Slider* lineWidthSlider=new GLMotif::Slider("LineWidthSlider",lineWidthBox,GLMotif::Slider::HORIZONTAL,ss->fontHeight*10.0f);
	lineWidthSlider->setValueRange(0.5,11.0,0.5);
	lineWidthSlider->setValue(newLineWidth);
	lineWidthSlider->getValueChangedCallbacks().add(this,&SketchingTool::lineWidthSliderCallback);
	
	lineWidthBox->manageChild();
	
	/* Create a radio box to set the line color: */
	new GLMotif::Label("ColorLabel",settingsBox,"Color");
	
	colorBox=new GLMotif::RowColumn("ColorBox",settingsBox,false);
	colorBox->setOrientation(GLMotif::RowColumn::HORIZONTAL);
	colorBox->setPacking(GLMotif::RowColumn::PACK_GRID);
	colorBox->setAlignment(GLMotif::Alignment::LEFT);
	
	/* Add the color buttons: */
	for(int i=0;i<8;++i)
		{
		char colorButtonName[16];
		snprintf(colorButtonName,sizeof(colorButtonName),"ColorButton%d",i);
		GLMotif::NewButton* colorButton=new GLMotif::NewButton(colorButtonName,colorBox,GLMotif::Vector(ss->fontHeight,ss->fontHeight,0.0f));
		colorButton->setBackgroundColor(GLMotif::Color(curveColors[i]));
		colorButton->getSelectCallbacks().add(this,&SketchingTool::colorButtonSelectCallback);
		}
	
	colorBox->manageChild();
	
	settingsBox->manageChild();
	
	GLMotif::RowColumn* buttonBox=new GLMotif::RowColumn("ButtonBox",controlDialog,false);
	buttonBox->setOrientation(GLMotif::RowColumn::HORIZONTAL);
	buttonBox->setPacking(GLMotif::RowColumn::PACK_TIGHT);
	buttonBox->setAlignment(GLMotif::Alignment::RIGHT);
	
	GLMotif::NewButton* saveCurvesButton=new GLMotif::NewButton("SaveCurvesButton",buttonBox,"Save Curves");
	saveCurvesButton->getSelectCallbacks().add(this,&SketchingTool::saveCurvesCallback);
	
	GLMotif::NewButton* loadCurvesButton=new GLMotif::NewButton("LoadCurvesButton",buttonBox,"Load Curves");
	loadCurvesButton->getSelectCallbacks().add(this,&SketchingTool::loadCurvesCallback);
	
	GLMotif::NewButton* deleteAllCurvesButton=new GLMotif::NewButton("DeleteAllCurvesButton",buttonBox,"Delete All Curves");
	deleteAllCurvesButton->getSelectCallbacks().add(this,&SketchingTool::deleteAllCurvesCallback);
	
	buttonBox->manageChild();
	
	controlDialog->manageChild();
	
	/* Pop up the control dialog: */
	popupPrimaryWidget(controlDialogPopup);
	}