def __init__(self): om.init() self.view = PythonQt.dd.ddQVTKWidgetView() # init grid self.gridObj = vis.showGrid(self.view, parent='scene') self.gridObj.setProperty('Surface Mode', 'Surface with edges') self.gridObj.setProperty('Color', [0,0,0]) self.gridObj.setProperty('Alpha', 0.1) # init view options self.viewOptions = vis.ViewOptionsItem(self.view) om.addToObjectModel(self.viewOptions, parentObj=om.findObjectByName('scene')) self.viewOptions.setProperty('Background color', [0.3, 0.3, 0.35]) self.viewOptions.setProperty('Background color 2', [0.95,0.95,1]) # setup camera applogic.setCameraTerrainModeEnabled(self.view, True) applogic.resetCamera(viewDirection=[-1, 0, -0.3], view=self.view) # add view behaviors viewBehaviors = viewbehaviors.ViewBehaviors(self.view) applogic._defaultRenderView = self.view self.mainWindow = QtGui.QMainWindow() self.mainWindow.setCentralWidget(self.view) self.mainWindow.resize(768 * (16/9.0), 768) self.mainWindow.setWindowTitle('Drake Visualizer') self.mainWindow.setWindowIcon(QtGui.QIcon(':/images/drake_logo.png')) self.mainWindow.show() self.drakeVisualizer = DrakeVisualizer(self.view) self.lcmglManager = lcmgl.LCMGLManager(self.view) if lcmgl.LCMGL_AVAILABLE else None self.screenGrabberPanel = ScreenGrabberPanel(self.view) self.screenGrabberDock = self.addWidgetToDock(self.screenGrabberPanel.widget, QtCore.Qt.RightDockWidgetArea) self.screenGrabberDock.setVisible(False) self.cameraBookmarksPanel = camerabookmarks.CameraBookmarkWidget(self.view) self.cameraBookmarksDock = self.addWidgetToDock(self.cameraBookmarksPanel.widget, QtCore.Qt.RightDockWidgetArea) self.cameraBookmarksDock.setVisible(False) model = om.getDefaultObjectModel() model.getTreeWidget().setWindowTitle('Scene Browser') model.getPropertiesPanel().setWindowTitle('Properties Panel') model.setActiveObject(self.viewOptions) self.sceneBrowserDock = self.addWidgetToDock(model.getTreeWidget(), QtCore.Qt.LeftDockWidgetArea) self.propertiesDock = self.addWidgetToDock(self.wrapScrollArea(model.getPropertiesPanel()), QtCore.Qt.LeftDockWidgetArea) self.sceneBrowserDock.setVisible(False) self.propertiesDock.setVisible(False) applogic.addShortcut(self.mainWindow, 'Ctrl+Q', self.applicationInstance().quit) applogic.addShortcut(self.mainWindow, 'F1', self._toggleObjectModel) applogic.addShortcut(self.mainWindow, 'F2', self._toggleScreenGrabber) applogic.addShortcut(self.mainWindow, 'F3', self._toggleCameraBookmarks) applogic.addShortcut(self.mainWindow, 'F8', applogic.showPythonConsole)
def createView(self, useGrid=True): view = PythonQt.dd.ddQVTKWidgetView() view.resize(600, 400) applogic.setCameraTerrainModeEnabled(view, True) if useGrid: self.gridObj = vis.showGrid(view, parent='scene') self.viewOptions = vis.ViewOptionsItem(view) om.addToObjectModel(self.viewOptions, parentObj=om.findObjectByName('scene')) applogic.resetCamera(viewDirection=[-1, -1, -0.3], view=view) viewBehaviors = viewbehaviors.ViewBehaviors(view) applogic._defaultRenderView = view applogic.addShortcut(view, 'Ctrl+Q', self.quit) applogic.addShortcut(view, 'F8', self.showPythonConsole) applogic.addShortcut(view, 'F1', self.showObjectModel) view.setWindowIcon(om.Icons.getIcon(om.Icons.Robot)) view.setWindowTitle('View') return view
# for kintinuous, use 'CAMERA_FUSED', 'CAMERA_TSDF' disparityPointCloud = segmentation.DisparityPointCloudItem('stereo point cloud', 'CAMERA', 'CAMERA_LEFT', cameraview.imageManager) disparityPointCloud.addToView(view) om.addToObjectModel(disparityPointCloud, parentObj=om.findObjectByName('sensors')) def createPointerTracker(): return trackers.PointerTracker(robotStateModel, disparityPointCloud) if useGrid: grid = vis.showGrid(view, color=[0,0,0], alpha=0.1) grid.setProperty('Surface Mode', 'Surface with edges') app.setBackgroundColor([0.3, 0.3, 0.35], [0.95,0.95,1]) viewOptions = vis.ViewOptionsItem(view) om.addToObjectModel(viewOptions, parentObj=om.findObjectByName('sensors')) class ViewBackgroundLightHandler(object): def __init__(self, viewOptions, grid): self.viewOptions = viewOptions self.action = app.getToolsMenuActions()['ActionToggleBackgroundLight'] self.action.connect('triggered()', self.toggle) self.properties = { viewOptions : {'Gradient background':True, 'Background color':[0.0, 0.0, 0.0], 'Background color 2':[0.3, 0.3, 0.3]}, grid : {'Surface Mode':'Wireframe', 'Alpha':0.05, 'Color':[1.0, 1.0, 1.0], 'Color By':0} } self.cachedProperties = {} self.storeProperties()