def menuToggleSelectCallback(self, cbdata): print 'Application.menuToggleSelectCallback' print ' -- toggle name={0}'.format(cbdata.toggle.getName()) name = cbdata.toggle.getName() if name == 'ShowSurfaceToggle': self.showSurface = cbdata.set elif name == 'ShowGridToggle': self.showGrid = cbdata.set elif name == 'SurfaceTransparentToggle': self.surfaceTransparent = cbdata.set elif name == 'ShowOuterCoreToggle': self.showOuterCore = cbdata.set elif name == 'ShowOuterCoreTransparentToggle': self.outerCoreTransparent = cbdata.set elif name == 'ShowInnerCoreToggle': self.showInnerCore = cbdata.set elif name == 'ShowInnerCoreTransparentToggle': self.innerCoreTransparent = cbdata.set elif name == 'RotateEarthToggle': self.rotateEarth = cbdata.set if self.rotateEarth: self.lastFrameTime = pyvrui.getApplicationTime() print ' -- self.rotateEarth={0}'.format(self.rotateEarth) elif name == 'ShowRenderDialogToggle': if cbdata.set: print ' -- pop up dialog' pyvrui.getWidgetManager().popupPrimaryWidget( self.renderDialog, pyvrui.getWidgetManager().calcWidgetTransformation(self.mainMenu)) else: print ' -- pop down dialog' pyvrui.popdownPrimaryWidget(self.renderDialog)
def createMainMenu(self): widgetManager = pyvrui.getWidgetManager() mainMenuPopup = pyvrui.PopupMenu("MainMenuPopup", widgetManager) mainMenuPopup.setTitle(MainMenuOptions['title']) mainMenu = pyvrui.Menu("MainMenu", mainMenuPopup, False) for (label, callback, type) in MainMenuOptions['items']: if type == 'button': button = pyvrui.Button(label.lower(), mainMenu, label) elif type == 'toggle': button = pyvrui.ToggleButton(label.lower(), mainMenu, label) self.menu_callbacks[button.getName()] = callback button.getSelectCallbacks().add(self.main_menu_callback) mainMenu.manageChild() return mainMenuPopup
def createMainMenu(self): widgetManager = pyvrui.getWidgetManager() ss = widgetManager.getStyleSheet() mainMenuPopup = pyvrui.PopupMenu('MainMenuPopup', widgetManager) mainMenuPopup.setTitle('pyvrui Demo') mainMenu = pyvrui.Menu('MainMenu', mainMenuPopup, False) resetNavigationButton = pyvrui.Button('ResetNavigationButton', mainMenu, 'Reset Navigation') resetNavigationButton.getSelectCallbacks().add(self.resetNavigationCallback) rotateToggleButton = pyvrui.ToggleButton('RotateToggleButton', mainMenu, 'Rotate') rotateToggleButton.setToggle(True) rotateToggleButton.getValueChangedCallbacks().add(self.toggleRotationCallback) mainMenu.manageChild() return mainMenuPopup
def createRenderTogglesMenu(self): renderTogglesMenuPopup = pyvrui.Popup('RenderTogglesMenuPopup', pyvrui.getWidgetManager()) renderTogglesMenu = pyvrui.SubMenu('RenderTogglesMenu', renderTogglesMenuPopup, False) showSurfaceToggle = pyvrui.ToggleButton('ShowSurfaceToggle', renderTogglesMenu, 'Show Surface') showSurfaceToggle.setToggle(self.showSurface) showSurfaceToggle.getValueChangedCallbacks().add(self.menuToggleSelectCallback) surfaceTransparentToggle = pyvrui.ToggleButton('SurfaceTransparentToggle', renderTogglesMenu, 'Surface Transparent') surfaceTransparentToggle.setToggle(self.surfaceTransparent) surfaceTransparentToggle.getValueChangedCallbacks().add(self.menuToggleSelectCallback) showGridToggle = pyvrui.ToggleButton('ShowGridToggle', renderTogglesMenu, 'Show Grid') showGridToggle.setToggle(self.showGrid) showGridToggle.getValueChangedCallbacks().add(self.menuToggleSelectCallback) renderTogglesMenu.manageChild() return renderTogglesMenuPopup
def createMainMenu(self): mainMenuPopup = pyvrui.PopupMenu('MainMenuPopup', pyvrui.getWidgetManager()) mainMenuPopup.setTitle('Interactive Globe') mainMenu = pyvrui.Menu('MainMenu', mainMenuPopup, False) renderTogglesCascade = pyvrui.CascadeButton('RenderTogglesCascade', mainMenu, 'Rendering Modes') renderTogglesCascade.setPopup(self.createRenderTogglesMenu()) rotateEarthToggle = pyvrui.ToggleButton('RotateEarthToggle', mainMenu, 'Rotate Earth') rotateEarthToggle.setToggle(self.rotateEarth) rotateEarthToggle.getValueChangedCallbacks().add(self.menuToggleSelectCallback) centerDisplayButton = pyvrui.Button('CenterDisplayButton', mainMenu, 'Center Display') centerDisplayButton.getSelectCallbacks().add(self.centerDisplayCallback) showRenderDialogToggle = pyvrui.ToggleButton('ShowRenderDialogToggle', mainMenu, 'Show Render Dialag') showRenderDialogToggle.setToggle(False) showRenderDialogToggle.getValueChangedCallbacks().add(self.menuToggleSelectCallback) mainMenu.manageChild() return mainMenuPopup
def createRenderDialog(self): def createCustomToggle(name, parent, label): toggle = pyvrui.ToggleButton(name, parent, label) toggle.setBorderWidth(0.0) toggle.setMarginWidth(0.0) #TODO: toggle.setHAlignment(...) return toggle print 'Application.createRenderDialog' ss = pyvrui.getWidgetManager().getStyleSheet() renderDialogPopup = pyvrui.PopupWindow('RenderDialogPopup', pyvrui.getWidgetManager(), 'Display Settings') renderDialog = pyvrui.RowColumn('RenderDialog', renderDialogPopup, False) renderDialog.setOrientation(pyvrui.RowColumn.VERTICAL) renderDialog.setPacking(pyvrui.RowColumn.PACK_TIGHT) renderDialog.setNumMinorWidgets(2) showSurfaceToggle = createCustomToggle('ShowSurfaceToggle', renderDialog, 'Show Surface') showSurfaceToggle.setToggle(self.showSurface) showSurfaceToggle.getValueChangedCallbacks().add(self.menuToggleSelectCallback) pyvrui.Blind('Blind1', renderDialog) pyvrui.Label('SurfaceTransparencyLabel', renderDialog, 'Surface Transparency') print ' -- ss.fontHeight={0}'.format(ss.fontHeight) surfaceTransparencySlider = pyvrui.Slider('SurfaceTransparencySlider', renderDialog, pyvrui.Slider.HORIZONTAL, 2.0) surfaceTransparencySlider.setValueRange(0.0, 1.0, 0.001) surfaceTransparencySlider.setValue(self.surfaceMaterial[0][3]) surfaceTransparencySlider.getValueChangedCallbacks().add(self.sliderCallback) pyvrui.Label('GridTransparencyLabel', renderDialog, 'Grid Transparency') gridTransparencySlider = pyvrui.Slider('GridTransparencySlider', renderDialog, pyvrui.Slider.HORIZONTAL, 2.0) gridTransparencySlider.setValueRange(0.0, 1.0, 0.001) gridTransparencySlider.setValue(0.1) gridTransparencySlider.getValueChangedCallbacks().add(self.sliderCallback) showOuterCoreToggle = createCustomToggle('ShowOuterCoreToggle', renderDialog, 'Show Outer Core') showOuterCoreToggle.setToggle(self.showOuterCore) showOuterCoreToggle.getValueChangedCallbacks().add(self.menuToggleSelectCallback) pyvrui.Blind('Blind2', renderDialog) pyvrui.Label('OuterCoreTransparencyLabel', renderDialog, 'Outer Core Transparency') outerCoreTransparencySlider = pyvrui.Slider('OuterCoreTransparencySlider', renderDialog, pyvrui.Slider.HORIZONTAL, 2.0) outerCoreTransparencySlider.setValueRange(0.0, 1.0, 0.001) outerCoreTransparencySlider.setValue(self.outerCoreMaterial[0][3]) outerCoreTransparencySlider.getValueChangedCallbacks().add(self.sliderCallback) showInnerCoreToggle = createCustomToggle('ShowInnerCoreToggle', renderDialog, 'Show Inner Core') showInnerCoreToggle.setToggle(self.showInnerCore) showInnerCoreToggle.getValueChangedCallbacks().add(self.menuToggleSelectCallback) pyvrui.Blind('Blind2', renderDialog) pyvrui.Label('InnerCoreTransparencyLabel', renderDialog, 'Inner Core Transparency') innerCoreTransparencySlider = pyvrui.Slider('InnerCoreTransparencySlider', renderDialog, pyvrui.Slider.HORIZONTAL, 2.0) innerCoreTransparencySlider.setValueRange(0.0, 1.0, 0.001) innerCoreTransparencySlider.setValue(self.innerCoreMaterial[0][3]) innerCoreTransparencySlider.getValueChangedCallbacks().add(self.sliderCallback) renderDialog.manageChild() return renderDialogPopup