Advertisement
Guest User

Untitled

a guest
Apr 24th, 2014
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.93 KB | None | 0 0
  1. def plotEMGGraphs(self):
  2. x = self.emg_xValues
  3. self.plotsEMG[:] = []
  4.  
  5. self.EMGlayout = QGridLayout()
  6.  
  7. for i in range(self.emg_yValues.__len__()):
  8. plotWidget = pg.PlotWidget()
  9. self.plotsEMG.append(plotWidget)
  10. hideShowButton = QPushButton()
  11. self.hideAndShowButtonPlotsEMG.append(hideShowButton)
  12. self.hidAndShowButtonIsShowed.append(True)
  13. QtCore.QObject.connect(self.hideAndShowButtonPlotsEMG[i], QtCore.SIGNAL("clicked()"), functools.partial(self.showHideGraph, i))
  14.  
  15. for i in range(self.emg_yValues.__len__()):
  16. # -------------- adding graphs --------------#
  17. y = self.emg_yValues[i]
  18. self.plotsEMG[i].setBackground(None)
  19.  
  20. self.plotsEMG[i].setLabel('left', "Tension", units='V')
  21. self.plotsEMG[i].setLabel('bottom', "Time", units='s')
  22. self.plotsEMG[i].setTitle("EMG : " + str(self.emg_column_names[i+1]))
  23. self.plotsEMG[i].setMouseEnabled(False)
  24.  
  25. thePenForEMG = pg.mkPen(color=(72,118,255), width=2)
  26. plot = self.plotsEMG[i].plot(x, y, pen=thePenForEMG)
  27.  
  28. thePenForHandVLines = pg.mkPen(color=(166,166,166), width=2)
  29. hLine = pg.InfiniteLine(angle=0, movable=False, pen=thePenForHandVLines)
  30. self.vLines.append(pg.InfiniteLine(angle=90, movable=False, pen=thePenForHandVLines))
  31. self.vLines[i].setPos(self.plotEMGXRangeVLineValue)
  32. hLine.setPos(0)
  33. self.plotsEMG[i].addItem(self.vLines[i], ignoreBounds=True)
  34. self.plotsEMG[i].addItem(hLine, ignoreBounds=True)
  35. self.plotsEMG[i].setXRange(self.plotEMGXRangeMin, self.plotEMGXRangeMax, update=True)
  36. self.plotsEMG[i].setYRange(0-self.plotEMGYRangeMaxABS, self.plotEMGYRangeMaxABS)
  37. self.EMGlayout.addWidget(self.plotsEMG[i], i, 0)
  38.  
  39. # ---------- adding hide/show button ----------#
  40. self.hideAndShowButtonPlotsEMG[i].setSizePolicy(QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed))
  41. self.hideAndShowButtonPlotsEMG[i].setText("Hide EMG " + str(i+1))
  42. self.EMGlayout.addWidget(self.hideAndShowButtonPlotsEMG[i], i, 1)
  43. #self.verticalLayout_17.addWidget(self.plotsEMG[i])
  44.  
  45.  
  46. previewButton = QPushButton(self.tab_4)
  47. previewButton.setText("Preview")
  48. QtCore.QObject.connect(previewButton, QtCore.SIGNAL("clicked()"), self.previewViewEMG)
  49. self.EMGlayout.addWidget(previewButton)
  50.  
  51. nextButton = QPushButton(self.tab_4)
  52. nextButton.setText("Next")
  53. QtCore.QObject.connect(nextButton, QtCore.SIGNAL("clicked()"), self.nextViewEMG)
  54. self.EMGlayout.addWidget(nextButton)
  55.  
  56.  
  57. wid = QWidget()
  58. wid.setLayout(self.EMGlayout)
  59. scroll = QScrollArea()
  60. scroll.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
  61. scroll.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded)
  62. scroll.setWidgetResizable(False)
  63. scroll.setWidget(wid)
  64. sizePolicy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
  65. scroll.setSizePolicy(sizePolicy)
  66. self.verticalLayout_17.addWidget(scroll)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement