示例#1
0
    def setupUi(self):

        self.objectTree = QtGui.QTreeWidget()
        self.propertiesPanel = PythonQt.dd.ddPropertiesPanel()

        sidePanel = QtGui.QSplitter(QtCore.Qt.Vertical)
        sidePanel.addWidget(self.objectTree)
        sidePanel.addWidget(self.propertiesPanel)
        sidePanel.setSizes([6, 4])

        om.init(self.objectTree, self.propertiesPanel)

        self.view = PythonQt.dd.ddQVTKWidgetView()
        lcmgl.init(self.view)

        self.view.backgroundRenderer().SetBackground(1,1,1)
        self.view.backgroundRenderer().SetBackground2(1,1,1)

        def setTextProperty(caption):
          prop = caption.GetCaptionTextProperty()
          prop.ShadowOff()
          prop.BoldOn()
          prop.ItalicOff()
          prop.SetColor(0,0,0)

        axesActor = self.view.orientationMarkerWidget().GetOrientationMarker()
        setTextProperty(axesActor.GetXAxisCaptionActor2D())
        setTextProperty(axesActor.GetYAxisCaptionActor2D())
        setTextProperty(axesActor.GetZAxisCaptionActor2D())

        w = QtGui.QWidget()
        l = QtGui.QHBoxLayout(w)
        self.slider = QtGui.QSlider(QtCore.Qt.Horizontal)
        self.clearButton = QtGui.QPushButton('clear')
        self.zeroButton = QtGui.QPushButton('zero')

        l.addWidget(self.clearButton)
        l.addWidget(self.zeroButton)
        l.addWidget(self.slider)

        self.slider.connect(self.slider, 'valueChanged(int)', self.onSlider)
        self.slider.connect(self.zeroButton, 'clicked()', self.onZeroButtonClicked)
        self.slider.connect(self.clearButton, 'clicked()', self.onClearButtonClicked)

        ww = QtGui.QWidget()
        ll = QtGui.QVBoxLayout(ww)
        ll.addWidget(self.view)
        #ll.addWidget(w)
        ll.setMargin(0)

        splitter = QtGui.QSplitter()
        splitter.addWidget(sidePanel)
        splitter.addWidget(ww)
        splitter.setSizes([0, 1])

        splitter.show()
        splitter.resize(800, 600)
        self.widget = splitter
        self.widget.setWindowTitle('Drake Viewer')
示例#2
0
    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)
示例#3
0
def main():

    objectTree = QtGui.QTreeWidget()
    propertiesPanel = PythonQt.dd.ddPropertiesPanel()

    om.init(objectTree, propertiesPanel)
    p = om.ObjectModelItem("test parent item")
    p.addProperty("foo", 1)
    p.addProperty("Visible", True)
    om.addToObjectModel(p)
    c = om.ObjectModelItem("test child item")
    om.addToObjectModel(c, p)

    assert om.findObjectByName("test parent item") == p
    assert om.findObjectByName("test child item") == c
    assert p.children()[0] == c
    assert c.children() == []

    objectTree.show()
    propertiesPanel.show()

    objectTree2 = QtGui.QTreeWidget()
    propertiesPanel2 = PythonQt.dd.ddPropertiesPanel()

    tree = om.ObjectModelTree()
    tree.init(objectTree2, propertiesPanel2)

    p2 = om.ObjectModelItem("test parent item 2")
    p2.addProperty("foo2", 1)
    p2.addProperty("Visible", True)
    tree.addToObjectModel(p2)
    c2 = om.ObjectModelItem("test child item 2")
    tree.addToObjectModel(c2, p2)

    assert tree.findObjectByName("test parent item 2") == p2
    assert tree.findObjectByName("test child item 2") == c2
    assert p2.children()[0] == c2
    assert c2.children() == []

    objectTree2.show()
    propertiesPanel2.show()

    startApplication(enableQuitTimer=True)
示例#4
0
def main():

    objectTree = QtGui.QTreeWidget()
    propertiesPanel = PythonQt.dd.ddPropertiesPanel()

    om.init(objectTree, propertiesPanel)
    p = om.ObjectModelItem('test parent item')
    p.addProperty('foo', 1)
    p.addProperty('Visible', True)
    om.addToObjectModel(p)
    c = om.ObjectModelItem('test child item')
    om.addToObjectModel(c, p)

    assert om.findObjectByName('test parent item') == p
    assert om.findObjectByName('test child item') == c
    assert p.children()[0] == c
    assert c.children() == []

    objectTree.show()
    propertiesPanel.show()

    objectTree2 = QtGui.QTreeWidget()
    propertiesPanel2 = PythonQt.dd.ddPropertiesPanel()

    tree = om.ObjectModelTree()
    tree.init(objectTree2, propertiesPanel2)

    p2 = om.ObjectModelItem('test parent item 2')
    p2.addProperty('foo2', 1)
    p2.addProperty('Visible', True)
    tree.addToObjectModel(p2)
    c2 = om.ObjectModelItem('test child item 2')
    tree.addToObjectModel(c2, p2)

    assert tree.findObjectByName('test parent item 2') == p2
    assert tree.findObjectByName('test child item 2') == c2
    assert p2.children()[0] == c2
    assert c2.children() == []

    objectTree2.show()
    propertiesPanel2.show()

    startApplication(enableQuitTimer=True)
示例#5
0
from ddapp.tasks import taskmanagerwidget
from ddapp.tasks.descriptions import loadTaskDescriptions
import drc as lcmdrc

from collections import OrderedDict
import functools
import math

import numpy as np
from ddapp.debugVis import DebugData
from ddapp import ioUtils as io

drcargs.requireStrict()
drcargs.args()
app.startup(globals())
om.init(app.getMainWindow().objectTree(), app.getMainWindow().propertiesPanel())
actionhandlers.init()

quit = app.quit
exit = quit
view = app.getDRCView()
camera = view.camera()
tree = app.getMainWindow().objectTree()
orbit = cameracontrol.OrbitController(view)
showPolyData = segmentation.showPolyData
updatePolyData = segmentation.updatePolyData


###############################################################################

示例#6
0
 def __init__(self):
     om.init()
     self.objectModelWidget = None
示例#7
0
 def __init__(self):
     om.init()
     self.objectModelWidget = None
示例#8
0
    def setupUi(self):

        self.objectTree = QtGui.QTreeWidget()
        self.propertiesPanel = PythonQt.dd.ddPropertiesPanel()

        sidePanel = QtGui.QSplitter(QtCore.Qt.Vertical)
        sidePanel.addWidget(self.objectTree)
        sidePanel.addWidget(self.propertiesPanel)
        sidePanel.setSizes([6, 4])

        om.init(self.objectTree, self.propertiesPanel)

        self.view = PythonQt.dd.ddQVTKWidgetView()
        lcmgl.init(self.view)

        self.view.backgroundRenderer().SetBackground(1, 1, 1)
        self.view.backgroundRenderer().SetBackground2(1, 1, 1)

        def setTextProperty(caption):
            prop = caption.GetCaptionTextProperty()
            prop.ShadowOff()
            prop.BoldOn()
            prop.ItalicOff()
            prop.SetColor(0, 0, 0)

        axesActor = self.view.orientationMarkerWidget().GetOrientationMarker()
        setTextProperty(axesActor.GetXAxisCaptionActor2D())
        setTextProperty(axesActor.GetYAxisCaptionActor2D())
        setTextProperty(axesActor.GetZAxisCaptionActor2D())

        w = QtGui.QWidget()
        l = QtGui.QHBoxLayout(w)
        self.slider = QtGui.QSlider(QtCore.Qt.Horizontal)
        self.clearButton = QtGui.QPushButton('clear')
        self.zeroButton = QtGui.QPushButton('zero')

        l.addWidget(self.clearButton)
        l.addWidget(self.zeroButton)
        l.addWidget(self.slider)

        self.slider.connect(self.slider, 'valueChanged(int)', self.onSlider)
        self.slider.connect(self.zeroButton, 'clicked()',
                            self.onZeroButtonClicked)
        self.slider.connect(self.clearButton, 'clicked()',
                            self.onClearButtonClicked)

        ww = QtGui.QWidget()
        ll = QtGui.QVBoxLayout(ww)
        ll.addWidget(self.view)
        #ll.addWidget(w)
        ll.setMargin(0)

        splitter = QtGui.QSplitter()
        splitter.addWidget(sidePanel)
        splitter.addWidget(ww)
        splitter.setSizes([0, 1])

        splitter.show()
        splitter.resize(800, 600)
        self.widget = splitter
        self.widget.setWindowTitle('Drake Viewer')
示例#9
0
def main():


    om.init(QtGui.QTreeWidget(), PythonQt.dd.ddPropertiesPanel())

    # create a frame
    t1 = vtk.vtkTransform()
    f1 = vis.FrameItem('frame 1', t1, view=None)
    om.addToObjectModel(f1)

    # test object model lookup
    assert om.findObjectByName('frame 1')
    assert om.findObjectByName('frame 2') is None


    # test reference cleanup
    f1Ref = weakref.ref(f1)
    assert f1Ref() is f1

    om.removeFromObjectModel(f1)
    del f1
    assert f1Ref() is None

    # add frame again
    f1 = vis.FrameItem('frame 1', t1, view=None)
    om.addToObjectModel(f1)

    # create second frame
    t2 = vtk.vtkTransform()
    f2 = vis.FrameItem('frame 2', t2, view=None)
    om.addToObjectModel(f2)

    # test transform reference is input transform
    assert f2.transform is t2

    # test frame sync
    frameSync = vis.FrameSync()

    frameSync.addFrame(f1)
    frameSync.addFrame(f2)

    t1.Translate(10,0,0)
    t1.Modified()

    assert t2.GetPosition() == (10.0, 0.0, 0.0)


    # test frame sync cleanup
    f1Ref = weakref.ref(f1)
    assert f1Ref() is f1


    assert len(frameSync.frames) == 2

    om.removeFromObjectModel(f1)
    del f1
    assert f1Ref() is None

    assert len(frameSync.frames) == 2

    t2.Translate(10,0,0)
    t2.Modified()

    assert t2.GetPosition() == (20.0, 0.0, 0.0)

    assert len(frameSync.frames) == 1


    # add frame again
    f1 = vis.FrameItem('frame 1', t1, view=None)
    om.addToObjectModel(f1)
    frameSync.addFrame(f1)


    t1.Translate(0,5,0)
    t1.Modified()

    assert t1.GetPosition() == (10.0, 5.0, 0.0)
    assert t2.GetPosition() == (20.0, 5.0, 0.0)


    frameSync.removeFrame(f1)


    t1.Translate(0,5,0)
    t1.Modified()

    assert t1.GetPosition() == (10.0, 10.0, 0.0)
    assert t2.GetPosition() == (20.0, 5.0, 0.0)

    # this has to be wrapped in a function, otherwise the exception
    # handling holds a reference to the FrameSync object which breaks
    # the delete test at the end
    def testException(fs):
        try:
            fs.removeFrame('test')
        except KeyError:
            pass
        else:
            assert False

    testException(frameSync)


    # test cleanup
    f1Ref = weakref.ref(f1)
    om.removeFromObjectModel(f1)
    del f1
    assert f1Ref() is None

    t1Ref = weakref.ref(t1)
    del t1
    assert t1Ref() is None


    # add frame again
    t1 = vtk.vtkTransform()
    f1 = vis.FrameItem('frame 1', t1, view=None)
    om.addToObjectModel(f1)

    frameSync.addFrame(f1)

    t1.Translate(0,0,10)
    t1.Modified()
    assert t2.GetPosition() == (20.0, 5.0, 10.0)


    # verify FrameSync object can be deleted
    frameSyncRef = weakref.ref(frameSync)
    del frameSync
    assert frameSyncRef() is None

    # verify frames are no longer synced after FrameSync is deleted
    t1.Translate(0,0,10)
    t1.Modified()
    assert t2.GetPosition() == (20.0, 5.0, 10.0)


    sys.exit(0)