Example #1
0
    def launchViewer(self):

        playButtonFps = 1.0/self.options['Sim']['dt']

        print "playButtonFPS", playButtonFps
        self.playTimer = TimerCallback(targetFps=playButtonFps)
        self.playTimer.callback = self.playTimerCallback

        panel = QtGui.QWidget()
        l = QtGui.QHBoxLayout(panel)

        playButton = QtGui.QPushButton('Play/Pause')
        playButton.connect('clicked()', self.onPlayButton)

        l.addWidget(playButton)

        w = QtGui.QWidget()
        l = QtGui.QVBoxLayout(w)
        l.addWidget(self.view)
        l.addWidget(panel)
        w.showMaximized()


        self.carFrame.connectFrameModified(self.updateDrawIntersection)
        self.updateDrawIntersection(self.carFrame)

        applogic.resetCamera(viewDirection=[0.2,0,-1])
        self.view.showMaximized()
        self.view.raise_()

        self.app.start()
    def _makeTerrainWizard(self):
        terrainWizard = QtGui.QWidget()

        self.cinderBlockButton = QtGui.QToolButton()
        self.cinderBlock2Button = QtGui.QToolButton()
        self.cinderBlockButton.setIcon(QtGui.QIcon(':/images/cinderblock.png'))
        self.cinderBlock2Button.setIcon(QtGui.QIcon(':/images/cinderblock_double.png'))
        self.cinderBlockButton.setIconSize(QtCore.QSize(60,60))
        self.cinderBlock2Button.setIconSize(QtCore.QSize(60,60))

        self.cinderBlockButton.connect('clicked()', functools.partial(self.onTerrainCinderblockSelected, self.cinderBlockButton))
        self.cinderBlock2Button.connect('clicked()', functools.partial(self.onTerrainCinderblockSelected, self.cinderBlock2Button))

        buttons = QtGui.QWidget()
        l = QtGui.QHBoxLayout(buttons)
        l.setMargin(0)
        l.addStretch()
        l.addWidget(self.cinderBlockButton)
        l.addWidget(self.cinderBlock2Button)
        l.addStretch()

        l = QtGui.QVBoxLayout(terrainWizard)
        l.addWidget(buttons)
        l.addWidget(_makeButton('double wide', functools.partial(startInteractiveLineDraw, [0.1905*2, 0.149225])))


        l.addStretch()
        return terrainWizard
Example #3
0
    def __init__(self):
        self.widget = QtGui.QGroupBox('Drill Planner')

        self.deltaSpinBoxes = [QtGui.QSpinBox() for i in xrange(3)]
        for spin in self.deltaSpinBoxes:
            spin.setMinimum(-100)
            spin.setMaximum(100)
            spin.setSingleStep(1)

        l = QtGui.QVBoxLayout(self.widget)
        l.addWidget(_makeButton('refit drill', self.refitDrill))
        l.addWidget(_makeButton('button preset posture',
                                self.gotoButtonPreset))
        l.addWidget(_makeButton('button pre-pose plan',
                                self.buttonPrePosePlan))
        l.addWidget(_makeButton('request nominal plan', self.nominalPlan))
        l.addWidget(
            _makeButton('request arm prepose plan', self.armPreposePlan))
        l.addWidget(_makeButton('request walking goal', self.walkingGoal))
        l.addWidget(
            _makeButton('request nominal fixed plan', self.nominalFixedPlan))
        l.addWidget(_makeButton('request pre-drill plan', self.preDrillPlan))
        l.addWidget(_makeButton('request drill-in plan', self.drillInPlan))
        l.addWidget(QtGui.QLabel(''))
        l.addWidget(_makeButton('next drill plan', self.nextDrillPlan))

        hw = QtGui.QWidget()
        hl = QtGui.QHBoxLayout(hw)
        hl.addWidget(_makeButton('set drill depth', self.setDrillDepth))
        self.drillDepthSpin = QtGui.QSpinBox()
        self.drillDepthSpin.setMinimum(-100)
        self.drillDepthSpin.setMaximum(100)
        self.drillDepthSpin.setSingleStep(1)
        hl.addWidget(self.drillDepthSpin)
        hl.addWidget(QtGui.QLabel('cm'))
        l.addWidget(hw)

        hw = QtGui.QWidget()
        hl = QtGui.QHBoxLayout(hw)
        self.drillDeltaCombo = QtGui.QComboBox()
        self.drillDeltaCombo.addItem('button')
        self.drillDeltaCombo.addItem('wall')
        self.drillDeltaButton = _makeButton('drill delta', self.drillDelta)
        hl.addWidget(self.drillDeltaButton)
        hl.addWidget(self.drillDeltaCombo)
        for spin in self.deltaSpinBoxes:
            hl.addWidget(spin)
        hl.addWidget(QtGui.QLabel('cm'))
        hl.addWidget(_makeButton('clear', self.clearDrillDelta))
        l.addWidget(QtGui.QLabel(''))
        l.addWidget(QtGui.QLabel(''))
        l.addWidget(hw)
        self.keyPressNav = KeyboardNavigation()
        self.keyPressNav.callbacks.append(self.onKeyPress)
        l.addWidget(self.keyPressNav.widget)
Example #4
0
    def _makeValveWizard(self):
        wizard = QtGui.QWidget()
        l = QtGui.QVBoxLayout(wizard)

        hw = QtGui.QWidget()
        hl = QtGui.QHBoxLayout(hw)
        hl.setMargin(0)
        self.valveMethodCombo = QtGui.QComboBox()
        self.valveMethodCombo.addItem('auto wall')
        self.valveMethodCombo.addItem('manual')
        hl.addWidget(QtGui.QLabel('method:'))
        hl.addWidget(self.valveMethodCombo)
        l.addWidget(hw)

        l.addWidget(_makeButton('segment large valve', self.segmentLargeValve))
        l.addWidget(_makeButton('segment small valve', self.segmentSmallValve))
        l.addWidget(_makeButton('segment bar', self.segmentLeverValve))

        hw = QtGui.QFrame()
        hl = QtGui.QHBoxLayout(hw)
        hl.setMargin(0)
        hl.addWidget(
            _makeButton('segment value radius:',
                        self.segmentValveCustomRadius))
        self.valveRadiusSpin = QtGui.QSpinBox()
        self.valveRadiusSpin.setMinimum(0)
        self.valveRadiusSpin.setMaximum(99)
        self.valveRadiusSpin.setSingleStep(1)
        hl.addWidget(self.valveRadiusSpin)
        hl.addWidget(QtGui.QLabel('cm'))
        l.addWidget(hw)

        l.addWidget(QtGui.QLabel(''))
        l.addWidget(_makeButton('refit wall', startRefitWall))

        hw = QtGui.QFrame()
        hl = QtGui.QHBoxLayout(hw)
        hl.setMargin(0)
        hl.addWidget(
            _makeButton('request valve circle plan',
                        self.requestValveCirclePlan))
        self.circlePlanAngle = QtGui.QSpinBox()
        self.circlePlanAngle.setMinimum(-360)
        self.circlePlanAngle.setMaximum(360)
        self.circlePlanAngle.setSingleStep(5)
        hl.addWidget(self.circlePlanAngle)
        hl.addWidget(QtGui.QLabel('degrees'))
        l.addWidget(hw)

        l.addStretch()
        return wizard
Example #5
0
    def _makeValveWizard(self):
        wizard = QtGui.QWidget()
        l = QtGui.QVBoxLayout(wizard)

        hw = QtGui.QWidget()
        hl = QtGui.QHBoxLayout(hw)
        hl.setMargin(0)
        self.valveMethodCombo = QtGui.QComboBox()
        self.valveMethodCombo.addItem("auto wall")
        self.valveMethodCombo.addItem("manual")
        hl.addWidget(QtGui.QLabel("method:"))
        hl.addWidget(self.valveMethodCombo)
        l.addWidget(hw)

        l.addWidget(_makeButton("segment large valve", self.segmentLargeValve))
        l.addWidget(_makeButton("segment small valve", self.segmentSmallValve))
        l.addWidget(_makeButton("segment bar", self.segmentLeverValve))

        hw = QtGui.QFrame()
        hl = QtGui.QHBoxLayout(hw)
        hl.setMargin(0)
        hl.addWidget(
            _makeButton("segment value radius:",
                        self.segmentValveCustomRadius))
        self.valveRadiusSpin = QtGui.QSpinBox()
        self.valveRadiusSpin.setMinimum(0)
        self.valveRadiusSpin.setMaximum(99)
        self.valveRadiusSpin.setSingleStep(1)
        hl.addWidget(self.valveRadiusSpin)
        hl.addWidget(QtGui.QLabel("cm"))
        l.addWidget(hw)

        l.addWidget(QtGui.QLabel(""))
        l.addWidget(_makeButton("refit wall", startRefitWall))

        hw = QtGui.QFrame()
        hl = QtGui.QHBoxLayout(hw)
        hl.setMargin(0)
        self.circlePlanAngle = QtGui.QSpinBox()
        self.circlePlanAngle.setMinimum(-360)
        self.circlePlanAngle.setMaximum(360)
        self.circlePlanAngle.setSingleStep(5)
        hl.addWidget(self.circlePlanAngle)
        hl.addWidget(QtGui.QLabel("degrees"))
        l.addWidget(hw)

        l.addStretch()
        return wizard
Example #6
0
    def __init__(self):
        self.forces = ['pelvis']
        self.widget = QtGui.QWidget()
        self.layout = QtGui.QVBoxLayout(self.widget)

        self.rebuild()
        self.layout.addStretch()
    def __init__(self):
        self.panel = QtGui.QWidget()
        self.panel.setWindowTitle('Segmentation Tools')

        self.taskSelection = PythonQt.dd.ddTaskSelection()
        self.taskSelection.connect('taskSelected(int)', self.onTaskSelected)

        l = QtGui.QVBoxLayout(self.panel)
        self.backButton = self._makeBackButton()
        l.addWidget(self.backButton)
        l.addWidget(self.taskSelection)
        self.backButton.hide()

        wizards = {
            'driving': self._makeDrivingWizard,
            'terrain': self._makeTerrainWizard,
            'ladder': self._makeLadderWizard,
            'debris': self._makeDebrisWizard,
            'door': self._makeDoorWizard,
            'drill': self._makeDrillWizard,
            'valve': self._makeValveWizard,
            'firehose': self._makeFirehoseWizard,
        }

        self.wizards = {}
        for name, func in wizards.iteritems():
            widget = func()
            self.wizards[name] = widget
            l.addWidget(widget)
            widget.hide()
Example #8
0
    def __init__(self, minValue=0.0, maxValue=1.0, resolution=1000):
        self._value = 0.0
        self.spinbox = QtGui.QDoubleSpinBox()
        self.spinbox.setSuffix('s')
        self.slider = QtGui.QSlider(QtCore.Qt.Horizontal)
        self.playButton = QtGui.QPushButton('Play')
        self.setValueRange(minValue, maxValue)
        self.setResolution(resolution)
        self.slider.connect('valueChanged(int)', self._onSliderValueChanged)
        self.spinbox.connect('valueChanged(double)',
                             self._onSpinboxValueChanged)
        self.playButton.connect('clicked()', self._onPlayClicked)
        self.widget = QtGui.QWidget()
        layout = QtGui.QHBoxLayout(self.widget)
        layout.addWidget(self.playButton)
        layout.addWidget(self.spinbox)
        layout.addWidget(self.slider)

        self.animationPrevTime = 0.0
        self.animationRate = 1.0
        self.animationRateTarget = 1.0
        self.animationRateAlpha = 1.0
        self.animationTimer = TimerCallback(callback=self._tick, targetFps=60)
        self.useRealTime = True

        self.callbacks = callbacks.CallbackRegistry(self.events._fields)

        self.eventFilter = PythonQt.dd.ddPythonEventFilter()
        self.eventFilter.connect('handleEvent(QObject*, QEvent*)',
                                 self._filterEvent)
        self.eventFilter.addFilteredEventType(QtCore.QEvent.MouseButtonPress)
        self.eventFilter.addFilteredEventType(QtCore.QEvent.MouseMove)
        self.slider.installEventFilter(self.eventFilter)
    def __init__(self):

        self.app = ConsoleApp()
        self.view = self.app.createView()
        self.robotSystem = robotsystem.create(self.view)

        self.config = drcargs.getDirectorConfig()
        jointGroups = self.config['teleopJointGroups']
        self.jointTeleopPanel = JointTeleopPanel(self.robotSystem, jointGroups)
        self.jointCommandPanel = JointCommandPanel(self.robotSystem)

        self.jointCommandPanel.ui.speedSpinBox.setEnabled(False)

        self.jointCommandPanel.ui.mirrorArmsCheck.setChecked(self.jointTeleopPanel.mirrorArms)
        self.jointCommandPanel.ui.mirrorLegsCheck.setChecked(self.jointTeleopPanel.mirrorLegs)
        self.jointCommandPanel.ui.resetButton.connect('clicked()', self.resetJointTeleopSliders)
        self.jointCommandPanel.ui.mirrorArmsCheck.connect('clicked()', self.mirrorJointsChanged)
        self.jointCommandPanel.ui.mirrorLegsCheck.connect('clicked()', self.mirrorJointsChanged)

        self.widget = QtGui.QWidget()

        gl = QtGui.QGridLayout(self.widget)
        gl.addWidget(self.app.showObjectModel(), 0, 0, 4, 1) # row, col, rowspan, colspan
        gl.addWidget(self.view, 0, 1, 1, 1)
        gl.addWidget(self.jointCommandPanel.widget, 1, 1, 1, 1)
        gl.addWidget(self.jointTeleopPanel.widget, 0, 2, -1, 1)
        gl.setRowStretch(0,1)
        gl.setColumnStretch(1,1)

        #self.sub = lcmUtils.addSubscriber('COMMITTED_ROBOT_PLAN', lcmdrc.robot_plan_t, self.onRobotPlan)
        lcmUtils.addSubscriber('STEERING_COMMAND_POSITION_GOAL', lcmdrc.joint_position_goal_t, self.onSingleJointPositionGoal)
        lcmUtils.addSubscriber('THROTTLE_COMMAND_POSITION_GOAL', lcmdrc.joint_position_goal_t, self.onSingleJointPositionGoal)
Example #10
0
    def showToolbarWidget(self):

        if app.getMainWindow() is None:
            return

        if self.toolbarWidget:
            self.execButton.setEnabled(True)
            return

        w = QtGui.QWidget()
        l = QtGui.QHBoxLayout(w)

        label = QtGui.QLabel('Walk plan:')
        execButton = QtGui.QPushButton('')
        execButton.setIcon(QtGui.QApplication.style().standardIcon(QtGui.QStyle.SP_MediaPlay))
        clearButton = QtGui.QPushButton('')
        clearButton.setIcon(QtGui.QApplication.style().standardIcon(QtGui.QStyle.SP_TrashIcon))
        stopButton = QtGui.QPushButton('')
        stopButton.setIcon(QtGui.QApplication.style().standardIcon(QtGui.QStyle.SP_MediaStop))

        l.addWidget(label)
        l.addWidget(execButton)
        l.addWidget(stopButton)
        l.addWidget(clearButton)
        l.setContentsMargins(0, 0, 0, 0)

        execButton.setShortcut(QtGui.QKeySequence('Ctrl+Return'))
        execButton.connect('clicked()', self.onExecClicked)
        clearButton.connect('clicked()', self.onClearClicked)
        stopButton.connect('clicked()', self.sendStopWalking)

        self.execButton = execButton
        self.stopButton = stopButton
        self.toolbarWidget = app.getMainWindow().toolBar().addWidget(w)
        self.execButton.show()
Example #11
0
    def __init__(self):
        self.panel = QtGui.QWidget()
        self.panel.setWindowTitle("Segmentation Tools")

        self.taskSelection = PythonQt.dd.ddTaskSelection()
        self.taskSelection.connect("taskSelected(int)", self.onTaskSelected)

        l = QtGui.QVBoxLayout(self.panel)
        self.backButton = self._makeBackButton()
        l.addWidget(self.backButton)
        l.addWidget(self.taskSelection)
        self.backButton.hide()

        wizards = {
            "driving": self._makeDrivingWizard,
            "terrain": self._makeTerrainWizard,
            "ladder": self._makeLadderWizard,
            "debris": self._makeDebrisWizard,
            "door": self._makeDoorWizard,
            "drill": self._makeDrillWizard,
            "valve": self._makeValveWizard,
            "firehose": self._makeFirehoseWizard,
        }

        self.wizards = {}
        for name, func in wizards.items():
            widget = func()
            self.wizards[name] = widget
            l.addWidget(widget)
            widget.hide()
Example #12
0
    def __init__(self, logPlayer):

        self.logPlayer = logPlayer

        w = QtGui.QWidget()
        w.windowTitle = 'LCM Log Playback'

        playButton = QtGui.QPushButton('Play')
        stopButton = QtGui.QPushButton('Stop')
        slider = QtGui.QSlider(QtCore.Qt.Horizontal)
        slider.maximum = int(logPlayer.getEndTime() * 100)
        text = QtGui.QLineEdit()
        text.text = '0.0'
        playButton.connect('clicked()', self.onPlay)
        stopButton.connect('clicked()', self.onStop)
        slider.connect('valueChanged(int)', self.onSlider)
        text.connect('returnPressed()', self.onText)

        l = QtGui.QHBoxLayout(w)
        l.addWidget(slider)
        l.addWidget(text)
        l.addWidget(playButton)
        l.addWidget(stopButton)

        self.slider = slider
        self.text = text
        self.widget = w
        self.widget.show()
Example #13
0
    def updateLayout(self):
        self.storeButtons = []
        self.flyButtons = []

        w = QtGui.QWidget()
        l = QtGui.QGridLayout(w)

        for i in range(self.numberOfBookmarks):
            storeButton = QtGui.QPushButton('set')
            flyButton = QtGui.QPushButton('fly')
            textEdit = QtGui.QLineEdit('camera %d' % i)
            storeButton.connect('clicked()', self.storeMapper, 'map()')
            flyButton.connect('clicked()', self.flyMapper, 'map()')
            self.storeMapper.setMapping(storeButton, storeButton)
            self.flyMapper.setMapping(flyButton, flyButton)
            self.storeButtons.append(storeButton)
            self.flyButtons.append(flyButton)
            l.addWidget(storeButton, i, 0)
            l.addWidget(flyButton, i, 1)
            l.addWidget(textEdit, i, 2)
            flyButton.setEnabled(False)

        self.flySpeedSpinner = QtGui.QDoubleSpinBox()
        self.flySpeedSpinner.setMinimum(0)
        self.flySpeedSpinner.setMaximum(60)
        self.flySpeedSpinner.setDecimals(1)
        self.flySpeedSpinner.setSingleStep(0.5)
        self.flySpeedSpinner.setSuffix(' seconds')
        self.flySpeedSpinner.setValue(1.0)

        l.addWidget(QtGui.QLabel('Fly speed:'), i+1, 0, 2)
        l.addWidget(self.flySpeedSpinner, i+1, 2)

        self.widget.setWidget(w)
Example #14
0
    def __init__ (self, parent):
        super(_StepByStepSolverTab, self).__init__ (parent)
        self.plugin = parent
        box = QtGui.QVBoxLayout(self)

        b = QtGui.QPushButton(self)
        b.text = "Initialize step by step sequence"
        box.addWidget(b)
        b.connect("clicked()", self.prepareSolveStepByStep)

        w = QtGui.QWidget(self)
        hl = QtGui.QHBoxLayout(w)
        self.stepCount = QtGui.QSpinBox(w)
        self.stepCount.setRange(1, 1000)
        self.value = 1
        hl.addWidget(self.stepCount)
        b = QtGui.QPushButton(self)
        b.text = "Execute N step"
        hl.addWidget(b)
        b.connect("clicked()", self.executeOneStep)
        box.addWidget(w)

        b = QtGui.QPushButton(self)
        b.text = "Finalize"
        box.addWidget(b)
        b.connect("clicked()", self.finishSolveStepByStep)
    def setupPlayback(self):

        self.timer = TimerCallback(targetFps=30)
        self.timer.callback = self.tick

        playButtonFps = 1.0 / self.dt
        print "playButtonFPS", playButtonFps
        self.playTimer = TimerCallback(targetFps=playButtonFps)
        self.playTimer.callback = self.playTimerCallback
        self.sliderMovedByPlayTimer = False

        panel = QtGui.QWidget()
        l = QtGui.QHBoxLayout(panel)

        playButton = QtGui.QPushButton('Play/Pause')
        playButton.connect('clicked()', self.onPlayButton)

        slider = QtGui.QSlider(QtCore.Qt.Horizontal)
        slider.connect('valueChanged(int)', self.onSliderChanged)
        self.sliderMax = self.numTimesteps
        slider.setMaximum(self.sliderMax)
        self.slider = slider

        l.addWidget(playButton)
        l.addWidget(slider)

        w = QtGui.QWidget()
        l = QtGui.QVBoxLayout(w)
        l.addWidget(self.view)
        l.addWidget(panel)
        w.showMaximized()

        self.frame.connectFrameModified(self.updateDrawIntersection)
        self.updateDrawIntersection(self.frame)

        applogic.resetCamera(viewDirection=[0.2, 0, -1])
        self.view.showMaximized()
        self.view.raise_()
        panel = screengrabberpanel.ScreenGrabberPanel(self.view)
        panel.widget.show()

        elapsed = time.time() - self.startSimTime
        simRate = self.counter / elapsed
        print "Total run time", elapsed
        print "Ticks (Hz)", simRate
        print "Number of steps taken", self.counter
        self.app.start()
Example #16
0
 def _makeDoorWizard(self):
     wizard = QtGui.QWidget()
     l = QtGui.QVBoxLayout(wizard)
     l.addWidget(_makeButton('segment door handle - left', functools.partial(startDoorHandleSegmentation, 'door_handle_left')))
     l.addWidget(_makeButton('segment door handle - right', functools.partial(startDoorHandleSegmentation, 'door_handle_right')))
     l.addWidget(_makeButton('segment door frame', functools.partial(startDoorHandleSegmentation, 'doorframe')))
     l.addStretch()
     return wizard
Example #17
0
 def __init__(self):
     self.eventFilter = None
     self.widget = QtGui.QWidget()
     l = QtGui.QVBoxLayout(self.widget)
     self.button = _makeButton('enable keyboard navigation', self.clicked)
     self.button.setCheckable(True)
     l.addWidget(self.button)
     self.callbacks = []
Example #18
0
    def __init__(self, model, jointController, view):
        self.model = model
        self.jointController = jointController
        self.view = view

        self.colorNoHighlight = QtGui.QColor(190, 190, 190)
        self.colorHighlight = QtCore.Qt.red

        self.timer = TimerCallback()
        self.timer.callback = self.update
        self.timer.targetFps = 60
        #self.timer.start()

        self.collisionStateIds = []

        self.lastRobotStateMessage = None
        self.lastPlanMessage = None
        self.lastPlanCheckMessage = None

        lcmUtils.addSubscriber('EST_ROBOT_STATE', lcmdrc.robot_state_t, self.onRobotState)
        lcmUtils.addSubscriber('ROBOT_COLLISIONS', lcmdrc.robot_collision_array_t, self.onPlanCheck)
        lcmUtils.addSubscriber('CANDIDATE_MANIP_PLAN', lcmdrc.robot_plan_w_keyframes_t, self.onManipPlan)

        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)
        ww.show()
        ww.resize(800, 600)
        self.widget = ww
Example #19
0
 def _makeFirehoseWizard(self):
     firehoseWizard = QtGui.QWidget()
     segmentButton = QtGui.QToolButton()
     segmentButton.setIcon(QtGui.QIcon(':/images/wye.png'))
     segmentButton.setIconSize(QtCore.QSize(60,60))
     segmentButton.connect('clicked()', self.onSegmentWye)
     l = QtGui.QVBoxLayout(firehoseWizard)
     l.addWidget(segmentButton)
     l.addWidget(_makeButton('segment hose nozzle', startHoseNozzleSegmentation))
     l.addStretch()
     return firehoseWizard
Example #20
0
    def _makeBackButton(self):
        w = QtGui.QPushButton()
        w.setIcon(QtGui.QApplication.style().standardIcon(QtGui.QStyle.SP_ArrowBack))
        w.connect('clicked()', self.onBackButton)

        frame = QtGui.QWidget()
        l = QtGui.QHBoxLayout(frame)
        l.setMargin(0)
        l.addWidget(w)
        l.addStretch()
        return frame
Example #21
0
    def makeForcesWidget(self, force):
        w = QtGui.QWidget()
        h = QtGui.QHBoxLayout(w)
        h.addWidget(QtGui.QLabel(force))
        slider = QtGui.QSlider(QtCore.Qt.Horizontal)
        h.addWidget(slider)

        def onSliderChanged(value):
            print value, force

        slider.connect('valueChanged(int)', onSliderChanged)
        return w
Example #22
0
    def __init__(self, mainWindow, flags=None):
        if flags is None:
            super(Plugin, self).__init__("Path graph plugin", mainWindow)
        else:
            super(Plugin, self).__init__("Path graph plugin", mainWindow,
                                         flags)
        self.setObjectName("Path graph plugin")

        self.main = mainWindow
        self.hppPlugin = self.main.getFromSlot("getHppIIOPurl")
        self.pathPlayer = self.main.getFromSlot("getCurrentPath")
        self.jointgroupcreator = self.main.getFromSlot(
            "requestCreateJointGroup")
        self.comgroupcreator = self.main.getFromSlot("requestCreateComGroup")
        self.velocities = Velocities(self)
        self.jointActions = dict()
        self.jointNames = None

        self.qcpWidgets = list()

        # This avoids having a widget bigger than what it needs. It avoids having
        # a big dock widget and a small osg widget when creating the main osg widget.
        p = Qt.QSizePolicy.Ignored
        self.topWidget = QtGui.QSplitter(Qt.Qt.Horizontal, self)
        self.topWidget.setSizePolicy(Qt.QSizePolicy(p, p))
        self.setWidget(self.topWidget)

        self.leftPane = QtGui.QWidget(self)
        l = QtGui.QVBoxLayout()
        self.makeLeftPane(l)
        self.leftPane.setLayout(l)

        self.topWidget.addWidget(self.leftPane)

        self.rightPane = QtGui.QWidget(self)
        self.rightPaneLayout = QtGui.QVBoxLayout()
        self.rightPane.setLayout(self.rightPaneLayout)
        self.addPlotBelow()
        self.topWidget.addWidget(self.rightPane)
        self.topWidget.setStretchFactor(1, 1)
Example #23
0
 def __init__(self, minValue=0.0, maxValue=1.0, resolution=1000):
     self.spinbox = QtGui.QDoubleSpinBox()
     self.spinbox.setSuffix('s')
     self.slider = QtGui.QSlider(QtCore.Qt.Horizontal)
     self.setResolution(resolution)
     self.setValueRange(minValue, maxValue)
     self.slider.connect('valueChanged(int)', self._onSliderValueChanged)
     self.spinbox.connect('valueChanged(double)', self._onSpinboxValueChanged)
     self.widget = QtGui.QWidget()
     layout = QtGui.QHBoxLayout(self.widget)
     layout.addWidget(self.spinbox)
     layout.addWidget(self.slider)
     self.animationTimer = None
     self.callbacks = callbacks.CallbackRegistry(self.events._fields)
Example #24
0
    def __init__(self, handlers):
        # Create widget and layouts
        self._widget = QtGui.QWidget()
        self._image_widgets = map(ImageWidget, handlers)
        self._layout = QtGui.QHBoxLayout(self._widget)
        for image_widget in self._image_widgets:
            self._layout.addWidget(image_widget.get_widget())
        self._layout.setContentsMargins(0, 0, 0, 0)

        default_width = 640
        default_height = 480
        dim = [default_width * len(self._image_widgets), default_height]

        self._widget.resize(*dim)
        self._widget.show()
Example #25
0
    def showObjectModel(self):

        if not self.objectModelWidget:
            w = QtGui.QWidget()
            l = QtGui.QVBoxLayout(w)
            model = om.getDefaultObjectModel()
            l.addWidget(model.getTreeWidget())
            l.addWidget(model.getPropertiesPanel())
            applogic.addShortcut(w, "Ctrl+Q", self.quit)
            self.objectModelWidget = w
            self.objectModelWidget.resize(350, 700)

        self.objectModelWidget.show()
        self.objectModelWidget.raise_()
        self.objectModelWidget.activateWindow()
        return self.objectModelWidget
Example #26
0
    def _makeDebrisWizard(self):
        debrisWizard = QtGui.QWidget()
        lumberSelection = PythonQt.dd.ddLumberSelection()
        lumberSelection.connect('lumberSelected(int)', self.onDebrisLumberSelected)
        l = QtGui.QVBoxLayout(debrisWizard)
        l.addWidget(lumberSelection)
        #l.addWidget(_makeButton('segment cinderblock wall', startSegmentDebrisWall))
        #l.addWidget(_makeButton('segment cinderblock wall manual', startSegmentDebrisWallManual))
        l.addWidget(_makeButton('segment truss', startTrussSegmentation))

        self.lockAffordanceButton = _makeButton('lock affordance to hand', self.onLockAffordanceToHand)
        self.lockAffordanceButton.checkable = True
        l.addWidget(self.lockAffordanceButton)

        l.addStretch()
        return debrisWizard
Example #27
0
    def __init__(self, plugin):
        super(QCPWidget, self).__init__(plugin)
        self.plugin = plugin

        layout = QtGui.QVBoxLayout(self)

        from PythonQt.QCustomPlot import QCustomPlot, QCP
        self.qcpWidget = QCustomPlot()
        self.qcpWidget.autoAddPlottableToLegend = True
        self.qcpWidget.setInteraction(QCP.iRangeDrag, True)  # iRangeDrap
        self.qcpWidget.setInteraction(QCP.iRangeZoom, True)  # iRangeZoom
        self.qcpWidget.setInteraction(QCP.iSelectAxes, True)  # iSelectAxes
        self.qcpWidget.legend().visible = True
        layout.addWidget(self.qcpWidget, 1)
        self.qcpWidget.connect(Qt.SIGNAL("mouseDoubleClick(QMouseEvent*)"),
                               self._mouseDoubleClick)
        self.qcpWidget.xAxis().connect(
            Qt.SIGNAL("selectionChanged(QCPAxis::SelectableParts)"),
            self._axesSelectionChanged)
        self.qcpWidget.yAxis().connect(
            Qt.SIGNAL("selectionChanged(QCPAxis::SelectableParts)"),
            self._axesSelectionChanged)

        buttonbar = QtGui.QWidget()
        bbLayout = QtGui.QHBoxLayout(buttonbar)
        button = QtGui.QPushButton("Replot", buttonbar)
        button.connect(QtCore.SIGNAL("clicked()"), self.refreshPlot)
        bbLayout.addWidget(button)
        button = QtGui.QPushButton("Remove", buttonbar)
        button.connect(QtCore.SIGNAL("clicked()"), self.removePlot)
        bbLayout.addWidget(button)
        button = QtGui.QPushButton("Legend", buttonbar)
        button.checkable = True
        button.checked = True
        button.connect(QtCore.SIGNAL("toggled(bool)"), self.toggleLegend)
        bbLayout.addWidget(button)
        button = QtGui.QPushButton(QtGui.QIcon.fromTheme("zoom-fit-best"), "",
                                   buttonbar)
        button.setToolTip("Zoom fit best")
        button.connect(QtCore.SIGNAL("clicked()"), self.qcpWidget.rescaleAxes)
        bbLayout.addWidget(button)

        self.xselect = QtGui.QComboBox(self)
        bbLayout.addWidget(self.xselect, 1)
        layout.addWidget(buttonbar)

        self.data = DataQCP(plugin, self.qcpWidget)
Example #28
0
    def refreshJointList(self):
        self.jointNames = self.client.robot.getJointNames()
        # Left pane
        saLayout = QtGui.QVBoxLayout()

        self.yselectcb = list()
        rank = 0
        for n in self.jointNames:
            size = self.client.robot.getJointConfigSize(n)
            if size == 1:
                cb = QtGui.QCheckBox(formats[0] % (n, "q"))
                self.yselectcb.append((cb, rank))
                saLayout.addWidget(cb)
            else:
                for i in range(size):
                    cb = QtGui.QCheckBox(formats[1] % (n, "q", i))
                    self.yselectcb.append((cb, rank + i))
                    saLayout.addWidget(cb)
            rank = rank + size
        for type in ("v", "a"):
            saLayout.addSpacing(5)
            for n in self.jointNames:
                size = self.client.robot.getJointNumberDof(n)
                if size == 1:
                    cb = QtGui.QCheckBox(formats[0] % (n, type))
                    self.yselectcb.append((cb, rank))
                    saLayout.addWidget(cb)
                else:
                    for i in range(size):
                        cb = QtGui.QCheckBox(formats[1] % (n, type, i))
                        self.yselectcb.append((cb, rank + i))
                        saLayout.addWidget(cb)
                rank = rank + size

        saContent = QtGui.QWidget(self)
        saContent.setLayout(saLayout)
        self.scrollArea.setWidget(saContent)

        # Right pane
        jointCfgSize = [
            self.client.robot.getJointConfigSize(n) for n in self.jointNames
        ]
        jointNbDof = [
            self.client.robot.getJointNumberDof(n) for n in self.jointNames
        ]
        for w in self.qcpWidgets:
            w.refreshJointList(self.jointNames, jointCfgSize, jointNbDof)
Example #29
0
 def _makeLadderWizard(self):
     wizard = QtGui.QWidget()
     l = QtGui.QVBoxLayout(wizard)
     l.addWidget(
         _makeButton(
             'straighten - left',
             functools.partial(
                 drilltaskpanel.sendControlMessage,
                 drilltaskpanel.drill_control_t.LADDER_STRAIGHTEN_LEFT)))
     l.addWidget(
         _makeButton(
             'straighten - right',
             functools.partial(
                 drilltaskpanel.sendControlMessage,
                 drilltaskpanel.drill_control_t.LADDER_STRAIGHTEN_RIGHT)))
     l.addStretch()
     return wizard
    def buildTabWidget(self, jointGroups):

        self.slidersMap = {}
        self.labelMap = {}

        for group in jointGroups:
            groupName = group['name']
            joints = group['joints']
            labels = group['labels']

            if groupName.lower() == 'base':
                continue

            if len(labels) != len(joints):
                print 'error, joints/labels mismatch for joint group:', name
                continue

            jointGroupWidget = QtGui.QWidget()
            gridLayout = QtGui.QGridLayout(jointGroupWidget)
            gridLayout.setColumnStretch(0, 1)

            for jointName, labelText in zip(joints, labels):
                label = QtGui.QLabel(labelText)
                numericLabel = QtGui.QLabel('0.0')
                slider = QtGui.QSlider(QtCore.Qt.Vertical)
                column = gridLayout.columnCount()
                gridLayout.addWidget(label, 0, column)
                gridLayout.addWidget(slider, 1, column)
                gridLayout.addWidget(numericLabel, 2, column)
                self.slidersMap[jointName] = slider
                self.labelMap[slider] = numericLabel

            gridLayout.setColumnStretch(gridLayout.columnCount(), 1)
            self.widget.addTab(jointGroupWidget, groupName)

        self.widget.usesScrollButtons = False
        self.signalMapper = QtCore.QSignalMapper()

        self.sliderMax = 1000.0
        for jointName, slider in self.slidersMap.iteritems():
            slider.connect('valueChanged(int)', self.signalMapper, 'map()')
            self.signalMapper.setMapping(slider, jointName)
            slider.setMaximum(self.sliderMax)

        self.signalMapper.connect('mapped(const QString&)', self.sliderChanged)