Example #1
0
    def initView(self, view):
        # Must call the createview function with the robot name so that the view can be associated, but cannot pass
        # keyword arguments to python_qt functions so need to also pass the -1 to add the tab to the end of the list
        # rather than insert it.
        self.view = view or app.getViewManager().createView(
            "Camera View", "VTK View", -1, self.robotName)
        app.getRobotSelector().associateViewWithRobot(self.view,
                                                      self.robotName)
        self.renderers = [self.view.renderer()]
        renWin = self.view.renderWindow()
        renWin.SetNumberOfLayers(3)
        for i in [1, 2]:
            ren = vtk.vtkRenderer()
            ren.SetLayer(2)
            ren.SetActiveCamera(self.view.camera())
            renWin.AddRenderer(ren)
            self.renderers.append(ren)

        def applyCustomBounds():
            self.view.addCustomBounds([-100, 100, -100, 100, -100, 100])

        self.view.connect("computeBoundsRequest(ddQVTKWidgetView*)",
                          applyCustomBounds)

        app.setCameraTerrainModeEnabled(self.view, True)
        self.resetCamera()
Example #2
0
    def initView(self, view):
        # Must call the createview function with the robot name so that the view can be associated, but cannot pass
        # keyword arguments to python_qt functions so need to also pass the -1 to add the tab to the end of the list
        # rather than insert it.
        self.view = view or app.getViewManager().createView(
            self.viewName, "VTK View", -1, self.robotName)
        app.getRobotSelector().associateViewWithRobot(self.view,
                                                      self.robotName)
        self.view.installImageInteractor()
        # self.interactorStyle = self.view.renderWindow().GetInteractor().GetInteractorStyle()
        # self.interactorStyle.AddObserver('SelectionChangedEvent', self.onRubberBandPick)

        self.imageActor = vtk.vtkImageActor()
        self.imageActor.SetInputData(self.getImage())
        self.imageActor.SetVisibility(False)
        self.view.renderer().AddActor(self.imageActor)

        self.view.orientationMarkerWidget().Off()
        self.view.backgroundRenderer().SetBackground(0, 0, 0)
        self.view.backgroundRenderer().SetBackground2(0, 0, 0)

        self.timerCallback = TimerCallback()
        self.timerCallback.targetFps = 60
        self.timerCallback.callback = self.updateView
        self.timerCallback.start()
Example #3
0
def rayDebug(position, ray):
    d = DebugData()
    d.addLine(position, position + ray * 5.0)
    drcView = app.getViewManager().findView("DRC View")
    obj = vis.updatePolyData(
        d.getPolyData(), "camera ray", view=drcView, color=[0, 1, 0]
    )
    obj.actor.GetProperty().SetLineWidth(2)
Example #4
0
def init(poseCollection, costCollection):

    global _spreadsheetView
    _spreadsheetView = app.getViewManager().createView('Spreadsheet View', 'Spreadsheet View')

    updateMethod = functools.partial(updateSpreadsheetPoses, poseCollection)
    poseCollection.connect('itemChanged(const QString&)', updateMethod)
    poseCollection.connect('itemAdded(const QString&)', updateMethod)
    poseCollection.connect('itemRemoved(const QString&)', updateMethod)

    initSpreadsheetColumns(costCollection)
    updateMethod()
Example #5
0
    def showAssociatedComponents(self, robotName):
        # If we have nothing in the dictionary, do nothing, otherwise may crash due to empty dicts.
        # TODO better checking of internal state of viewmanager to remove this check
        if not self.associatedWidgets:
            return
        # Have to update the page index cache before moving any of the components so that the hidden tabs are placed
        # in the correct order when they are shown
        app.getViewManager().updatePageIndexCache()
        # If there is an open dock widget, we must hide it independently of the action that it is attached to.
        # For simplicity, just hide all dock widgets when switching.
        # TODO remember open docks associated with each robot so that UI state is saved
        app.hideDockWidgets()
        # TODO use an object with a hide/show method to store widgets and other components so that the hiding method
        #  is associated with the object rather than being implemented here
        for robot in self.associatedWidgets.keys():
            for widget in self.associatedWidgets[robot]["widgets"]:
                widget.setVisible(robot == robotName)

            for view in self.associatedWidgets[robot]["views"]:
                if robot == robotName:
                    app.getViewManager().showView(view)
                else:
                    app.getViewManager().hideView(view, False)

            for model in self.associatedWidgets[robot]["models"]:
                model.setProperty("Visible", robot == robotName)

            for viewBehavior in self.associatedWidgets[robot]["viewbehaviors"]:
                # Setting the enabled flag to false will cause the event filter not to filter any events, allowing them
                # to pass to the event filter which is enabled, i.e. the one for the currently selected robot
                viewBehavior.robotViewBehaviors.setEnabled(robot == robotName)

            # Disable the submenu in the view menu for other robots. Without this items in the submenus are hidden
            # but the submenu is not greyed out
            app.findMenu(robot).setEnabled(robot == robotName)
Example #6
0
def init(poseCollection, costCollection):

    global _spreadsheetView
    _spreadsheetView = app.getViewManager().createView('Spreadsheet View',
                                                       'Spreadsheet View')

    updateMethod = functools.partial(updateSpreadsheetPoses, poseCollection)
    poseCollection.connect('itemChanged(const QString&)', updateMethod)
    poseCollection.connect('itemAdded(const QString&)', updateMethod)
    poseCollection.connect('itemRemoved(const QString&)', updateMethod)

    initSpreadsheetColumns(costCollection)
    updateMethod()
Example #7
0
    def initView(self, view):
        self.view = view or app.getViewManager().createView(self.viewName, 'VTK View')
        self.view.installImageInteractor()
        self.interactorStyle = self.view.renderWindow().GetInteractor().GetInteractorStyle()
        self.interactorStyle.AddObserver('SelectionChangedEvent', self.onRubberBandPick)

        self.imageActor = vtk.vtkImageActor()
        self.imageActor.SetInput(self.getImage())
        self.imageActor.SetVisibility(False)
        self.view.renderer().AddActor(self.imageActor)

        self.timerCallback = TimerCallback()
        self.timerCallback.targetFps = 60
        self.timerCallback.callback = self.updateView
        self.timerCallback.start()
Example #8
0
    def initView(self, view):
        self.view = view or app.getViewManager().createView(
            self.viewName, 'VTK View')
        self.view.installImageInteractor()
        self.interactorStyle = self.view.renderWindow().GetInteractor(
        ).GetInteractorStyle()
        self.interactorStyle.AddObserver('SelectionChangedEvent',
                                         self.onRubberBandPick)

        self.imageActor = vtk.vtkImageActor()
        self.imageActor.SetInput(self.getImage())
        self.imageActor.SetVisibility(False)
        self.view.renderer().AddActor(self.imageActor)

        self.timerCallback = TimerCallback()
        self.timerCallback.targetFps = 60
        self.timerCallback.callback = self.updateView
        self.timerCallback.start()
Example #9
0
    def initView(self, view):
        self.view = view or app.getViewManager().createView(self.viewName, "VTK View")
        self.view.installImageInteractor()
        self.interactorStyle = self.view.renderWindow().GetInteractor().GetInteractorStyle()
        self.interactorStyle.AddObserver("SelectionChangedEvent", self.onRubberBandPick)

        self.imageActor = vtk.vtkImageActor()
        self.imageActor.SetInput(self.getImage())
        self.imageActor.SetVisibility(False)
        self.view.renderer().AddActor(self.imageActor)

        self.view.orientationMarkerWidget().Off()
        self.view.backgroundRenderer().SetBackground(0, 0, 0)
        self.view.backgroundRenderer().SetBackground2(0, 0, 0)

        self.timerCallback = TimerCallback()
        self.timerCallback.targetFps = 60
        self.timerCallback.callback = self.updateView
        self.timerCallback.start()
Example #10
0
    def initView(self, view):

        self.view = view or app.getViewManager().createView('Camera View', 'VTK View')

        self.renderers = [self.view.renderer()]
        renWin = self.view.renderWindow()
        renWin.SetNumberOfLayers(3)
        for i in [1, 2]:
            ren = vtk.vtkRenderer()
            ren.SetLayer(2)
            ren.SetActiveCamera(self.view.camera())
            renWin.AddRenderer(ren)
            self.renderers.append(ren)

        def applyCustomBounds():
            self.view.addCustomBounds([-100, 100, -100, 100, -100, 100])
        self.view.connect('computeBoundsRequest(ddQVTKWidgetView*)', applyCustomBounds)

        app.setCameraTerrainModeEnabled(self.view, True)
        self.resetCamera()
Example #11
0
    def initView(self, view):

        self.view = view or app.getViewManager().createView('Camera View', 'VTK View')

        self.renderers = [self.view.renderer()]
        renWin = self.view.renderWindow()
        renWin.SetNumberOfLayers(3)
        for i in [1, 2]:
            ren = vtk.vtkRenderer()
            ren.SetLayer(2)
            ren.SetActiveCamera(self.view.camera())
            renWin.AddRenderer(ren)
            self.renderers.append(ren)

        def applyCustomBounds():
            self.view.addCustomBounds([-100, 100, -100, 100, -100, 100])
        self.view.connect('computeBoundsRequest(ddQVTKWidgetView*)', applyCustomBounds)

        app.setCameraTerrainModeEnabled(self.view, True)
        self.resetCamera()
Example #12
0
def rayDebug(position, ray):
    d = DebugData()
    d.addLine(position, position + ray * 5.0)
    drcView = app.getViewManager().findView("DRC View")
    obj = vis.updatePolyData(d.getPolyData(), "camera ray", view=drcView, color=[0, 1, 0])
    obj.actor.GetProperty().SetLineWidth(2)