class Plugin (QtGui.QDockWidget): def __init__ (self, mainWindow, flags = None): if flags is None: super(Plugin, self).__init__ ("QCP example plugin", mainWindow) else: super(Plugin, self).__init__ ("QCP example plugin", mainWindow, flags) self.setObjectName("QCP example plugin") self.main = mainWindow self.qcp = QCustomPlot () self.qcp.setInteraction (QCP.iRangeDrag, True) self.qcp.setInteraction (QCP.iRangeZoom, True) self.setWidget (self.qcp) self.graph = self.qcp.addGraph () self.graph.setData ([0,1,2,3], [0.1,0.3,0.2,0]) self.qcp.replot() self.tracer = QCPItemTracer (self.qcp) self.tracer.graph = self.graph self.tracer.graphKey = 0 self.tracer.style = 3 self.text = QCPItemRichText (self.qcp) self.text.text = u"q<sub>0,0</sub>" self.text.position("position").setParentAnchor(self.tracer.anchor("position")) self.text.position("position").setCoords (0, -20) self.graph.setData ([0,1,2,3], [1,0.3,0.2,0])
def __init__ (self, mainWindow, flags = None): if flags is None: super(Plugin, self).__init__ ("QCP example plugin", mainWindow) else: super(Plugin, self).__init__ ("QCP example plugin", mainWindow, flags) self.setObjectName("QCP example plugin") self.main = mainWindow self.qcp = QCustomPlot () self.qcp.setInteraction (QCP.iRangeDrag, True) self.qcp.setInteraction (QCP.iRangeZoom, True) self.setWidget (self.qcp) self.graph = self.qcp.addGraph () self.graph.setData ([0,1,2,3], [0.1,0.3,0.2,0]) self.qcp.replot() self.tracer = QCPItemTracer (self.qcp) self.tracer.graph = self.graph self.tracer.graphKey = 0 self.tracer.style = 3 self.text = QCPItemRichText (self.qcp) self.text.text = u"q<sub>0,0</sub>" self.text.position("position").setParentAnchor(self.tracer.anchor("position")) self.text.position("position").setCoords (0, -20) self.graph.setData ([0,1,2,3], [1,0.3,0.2,0])
def __init__(self, plugin): super(Plot, self).__init__(self) self.plugin = plugin self.qcp = QCustomPlot() layout = QtGui.QVBoxLayout(self) layout.addWidget(self.qcp) self.qcp.setInteraction(1, True) # iRangeDrag self.qcp.setInteraction(2, True) # iRangeZoom self.qcp.setAutoAddPlottableToLegend(True) self.qcp.legend().setVisible(True) self.timer = Qt.QTimer(self) self.timer.setSingleShot(False) self.timer.setInterval(100) self.timer.connect(Qt.SIGNAL("timeout()"), self._step)
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)
def makeRightPane (self, layout): 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) 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) self.xselect = QtGui.QComboBox(self) layout.addWidget (self.xselect) # time index is 0 and is value is -1 self.xselect.addItem ("time", -1)
class Plot(QtGui.QWidget): def __init__(self, plugin): super(Plot, self).__init__(self) self.plugin = plugin self.qcp = QCustomPlot() layout = QtGui.QVBoxLayout(self) layout.addWidget(self.qcp) self.qcp.setInteraction(1, True) # iRangeDrag self.qcp.setInteraction(2, True) # iRangeZoom self.qcp.setAutoAddPlottableToLegend(True) self.qcp.legend().setVisible(True) self.timer = Qt.QTimer(self) self.timer.setSingleShot(False) self.timer.setInterval(100) self.timer.connect(Qt.SIGNAL("timeout()"), self._step) def initCurves(self, signals): self.qcp.clearGraphs() self.signals = signals self.times = [] for i, s in enumerate(signals): graph = self.qcp.addGraph() graph.setName(s[0] + '.' + s[1]) graph.setPen(pens[i]) if len(signals) > 0: self.timer.start() def stopAnimation(self): print "Stop animation" self.timer.stop() def _step(self): # print "step", frame nys = self.plugin._fetchNewSignalValues() if nys is not None and len(nys) == len(self.signals): if len(nys) > 0: l = len(nys[0]) # l = len(nys[0][1]) if l > 0: # ntimes = [ ny[0] for ny in nys # print nys # start = (self.times[-1] if len(self.times) > 0 else 0) + 1 # ntimes = range(start,start+l) # self.times.extend(ntimes) for i, ny in enumerate(nys): nnt = [n[0] for n in ny] nny = [n[1][0] for n in ny] # print ntimes,nny self.qcp.addData(i, nnt, nny) # self.qcp.xAxis_setRange(0, self.times[-1]) self.zoomFitBest() def zoomFitBest(self): self.qcp.rescaleAxes() self.qcp.replot()
class Plugin (QtGui.QDockWidget): 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() # 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) l = QtGui.QVBoxLayout () self.makeRightPane (l) self.rightPane.setLayout (l) self.topWidget.addWidget (self.rightPane) self.data = DataQCP(self) def refreshPlot (self): pid = self.pathPlayer.getCurrentPath() if pid < 0: return dl = self.pathPlayer.lengthBetweenRefresh() idxX = self.xselect.currentIndex x = (self.xselect.itemText(idxX), int(self.xselect.itemData(idxX)) + 1) ys = list () for elt in self.yselectcb: cb = elt[0] if cb.checked: ys.append ((str(cb.text), elt[1]+1)) self.data.selectData(pid, dl, x, ys) self.data.acquireData() def refreshJointList (self): jointNames = self.client.robot.getJointNames () # Left pane saLayout = QtGui.QVBoxLayout () formats = ( "%s (%s)", "%s (%s, %i)") self.yselectcb = list () rank = 0 for n in 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 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 self.xselect.clear() # time index is 0 and is value is -1 self.xselect.addItem ("time", -1) rank = 0 for n in jointNames: size = self.client.robot.getJointConfigSize (n) if size == 1: self.xselect.addItem (formats[0] % (n,"q"), rank) else: for i in range (size): self.xselect.addItem (formats[1] % (n,"q",i), rank + i) rank = rank + size for type in ("v", "a"): for n in jointNames: size = self.client.robot.getJointNumberDof (n) if size == 1: self.xselect.addItem (formats[0] % (n,type), rank) else: for i in range (size): self.xselect.addItem (formats[1] % (n,type,i), rank + i) rank = rank + size def refreshInterface (self): self.refreshJointList() def makeLeftPane (self, layout): layout.addWidget (QtGui.QLabel ("Select Y data")) refresh = QtGui.QPushButton ("Refresh", self) refresh.connect (QtCore.SIGNAL("clicked()"), self.refreshPlot) layout.addWidget (refresh) self.scrollArea = QtGui.QScrollArea (self) layout.addWidget (self.scrollArea) def makeRightPane (self, layout): 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) 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) self.xselect = QtGui.QComboBox(self) layout.addWidget (self.xselect) # time index is 0 and is value is -1 self.xselect.addItem ("time", -1) def _mouseDoubleClick (self, event): try: if self.data.x[1] > 0: return except: return try: # Qt 5 x = event.localPos().x() except: # Qt 4 x = event.posF().x() t = self.qcpWidget.xAxis().pixelToCoord (x) self.pathPlayer.setCurrentTime(t) def _axesSelectionChanged (self, unused_parts): xAxis = self.qcpWidget.xAxis() yAxis = self.qcpWidget.yAxis() x = (xAxis.selectedParts != 0) y = (yAxis.selectedParts != 0) if not x and not y: self.qcpWidget.axisRect().setRangeZoomAxes(xAxis, yAxis) elif x: self.qcpWidget.axisRect().setRangeZoomAxes(xAxis, None) elif y: self.qcpWidget.axisRect().setRangeZoomAxes(None, yAxis) def resetConnection(self): self.client = Client(url= str(self.hppPlugin.getHppIIOPurl())) self.gui = GuiClient() def getJointActions(self, name): if name not in self.jointActions: self.jointActions[name] = (JointAction ("Show/Hide joint &velocity", name, self.velocities, self),) return self.jointActions[name]
class Plot(QtGui.QWidget): def __init__(self, plugin): super(Plot, self).__init__(self) self.plugin = plugin self.qcp = QCustomPlot() layout = QtGui.QVBoxLayout(self) layout.addWidget(self.qcp) self.qcp.setInteraction(1, True) # iRangeDrag self.qcp.setInteraction(2, True) # iRangeZoom self.qcp.setAutoAddPlottableToLegend(True) self.qcp.legend().setVisible(True) self.qcp.connect(Qt.SIGNAL("mouseDoubleClick(QMouseEvent*)"), self.doubleClick) # The timer user refresh the interface self.timer = Qt.QTimer(self) self.timer.setSingleShot(False) self.timer.setInterval(100) self.timer.connect(Qt.SIGNAL("timeout()"), self._step) def doubleClick(self, event): x = self.qcp.xAxis().pixelToCoord(event.posF().x()) y = self.qcp.yAxis().pixelToCoord(event.posF().y()) print("You double-clicked at ({0}, {1})".format(x, y)) def makeCurves(self): self.qcp.clearGraphs() self.legends = ["sin", "cos"] self.times = [] for i, l in enumerate(self.legends): graph = self.qcp.addGraph() graph.setName(l) graph.setPen(pens[i]) def start(self): self.makeCurves() self.timer.start() def stop(self): self.timer.stop() def _step(self): t = (self.times[-1] + 1) if len(self.times) > 0 else 0 from math import sin, cos x = sin(0.1 * t) y = cos(0.1 * t) self.qcp.addData(0, (t, ), (x, )) self.qcp.addData(1, (t, ), (y, )) self.times.append(t) self.zoomFitBest() def zoomFitBest(self): self.qcp.rescaleAxes() self.qcp.replot()
class Plugin (QtGui.QDockWidget): 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() # 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) l = QtGui.QVBoxLayout () self.makeRightPane (l) self.rightPane.setLayout (l) self.topWidget.addWidget (self.rightPane) self.data = DataQCP(self) def refreshPlot (self): pid = self.pathPlayer.getCurrentPath() if pid < 0: return dl = self.pathPlayer.lengthBetweenRefresh() idxX = self.xselect.currentIndex x = (self.xselect.itemText(idxX), int(self.xselect.itemData(idxX)) + 1) ys = list () for elt in self.yselectcb: cb = elt[0] if cb.checked: ys.append ((str(cb.text), elt[1]+1)) self.data.selectData(pid, dl, x, ys) self.data.acquireData() def refreshJointList (self): jointNames = self.client.robot.getJointNames () # Left pane saLayout = QtGui.QVBoxLayout () formats = ( "%s (%s)", "%s (%s, %i)") self.yselectcb = list () rank = 0 for n in 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 xrange (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 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 xrange (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 self.xselect.clear() # time index is 0 and is value is -1 self.xselect.addItem ("time", -1) rank = 0 for n in jointNames: size = self.client.robot.getJointConfigSize (n) if size == 1: self.xselect.addItem (formats[0] % (n,"q"), rank) else: for i in xrange (size): self.xselect.addItem (formats[1] % (n,"q",i), rank + i) rank = rank + size for type in ("v", "a"): for n in jointNames: size = self.client.robot.getJointNumberDof (n) if size == 1: self.xselect.addItem (formats[0] % (n,type), rank) else: for i in xrange (size): self.xselect.addItem (formats[1] % (n,type,i), rank + i) rank = rank + size def refreshInterface (self): self.refreshJointList() def makeLeftPane (self, layout): layout.addWidget (QtGui.QLabel ("Select Y data")) refresh = QtGui.QPushButton ("Refresh", self) refresh.connect (QtCore.SIGNAL("clicked()"), self.refreshPlot) layout.addWidget (refresh) self.scrollArea = QtGui.QScrollArea (self) layout.addWidget (self.scrollArea) def makeRightPane (self, layout): 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) 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) self.xselect = QtGui.QComboBox(self) layout.addWidget (self.xselect) # time index is 0 and is value is -1 self.xselect.addItem ("time", -1) def _mouseDoubleClick (self, event): try: if self.data.x[1] > 0: return except: return try: # Qt 5 x = event.localPos().x() except: # Qt 4 x = event.posF().x() t = self.qcpWidget.xAxis().pixelToCoord (x) self.pathPlayer.setCurrentTime(t) def _axesSelectionChanged (self, unused_parts): xAxis = self.qcpWidget.xAxis() yAxis = self.qcpWidget.yAxis() x = (xAxis.selectedParts != 0) y = (yAxis.selectedParts != 0) if not x and not y: self.qcpWidget.axisRect().setRangeZoomAxes(xAxis, yAxis) elif x: self.qcpWidget.axisRect().setRangeZoomAxes(xAxis, None) elif y: self.qcpWidget.axisRect().setRangeZoomAxes(None, yAxis) def resetConnection(self): self.client = Client(url= str(self.hppPlugin.getHppIIOPurl())) self.gui = GuiClient() def getJointActions(self, name): if not self.jointActions.has_key(name): self.jointActions[name] = (JointAction ("Show/Hide joint &velocity", name, self.velocities, self),) return self.jointActions[name]
class QCPWidget(QtGui.QWidget): """ A plot widget with a combo box to select the X axis. """ 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) def toggleLegend(self, enable): self.qcpWidget.legend().visible = enable self.qcpWidget.replot() def refreshPlot(self): pid = self.plugin.pathPlayer.getCurrentPath() if pid < 0: return dl = self.plugin.pathPlayer.lengthBetweenRefresh() idxX = self.xselect.currentIndex x = (self.xselect.itemText(idxX), int(self.xselect.itemData(idxX)) + 1) ys = list() for elt in self.plugin.yselectcb: cb = elt[0] if cb.checked: ys.append((str(cb.text), elt[1] + 1)) self.data.selectData(pid, dl, x, ys) self.data.acquireData() def removePlot(self): self.hide() try: self.plugin.qcpWidgets.remove(self) except ValueError: print("Did not find QCPWidget in plugin") self.plugin.rightPaneLayout.removeWidget(self) def refreshJointList(self, jointNames, jointCfgSize, jointNbDof): # Right pane self.xselect.clear() # time index is 0 and is value is -1 self.xselect.addItem("time", -1) rank = 0 for n, size in zip(jointNames, jointCfgSize): if size == 1: self.xselect.addItem(formats[0] % (n, "q"), rank) else: for i in range(size): self.xselect.addItem(formats[1] % (n, "q", i), rank + i) rank = rank + size for type in ("v", "a"): for n, size in zip(jointNames, jointNbDof): if size == 1: self.xselect.addItem(formats[0] % (n, type), rank) else: for i in range(size): self.xselect.addItem(formats[1] % (n, type, i), rank + i) rank = rank + size def _mouseDoubleClick(self, event): try: if self.data.x[1] > 0: return except: return try: # Qt 5 x = event.localPos().x() except: # Qt 4 x = event.posF().x() t = self.qcpWidget.xAxis().pixelToCoord(x) self.plugin.pathPlayer.setCurrentTime(t) def _axesSelectionChanged(self, unused_parts): xAxis = self.qcpWidget.xAxis() yAxis = self.qcpWidget.yAxis() x = (xAxis.selectedParts != 0) y = (yAxis.selectedParts != 0) if not x and not y: self.qcpWidget.axisRect().setRangeZoomAxes(xAxis, yAxis) elif x: self.qcpWidget.axisRect().setRangeZoomAxes(xAxis, None) elif y: self.qcpWidget.axisRect().setRangeZoomAxes(None, yAxis)