Esempio n. 1
0
 def addROI(self,roi = None):
     if self.roiwidget is None:
         self.roiwidget = ROIPlotWidget(roi_target = self.p1,
                                        view = self.view,
                                        parent = self)
         roiTab = QDockWidget("roi cam {0}".format(self.iCam), self)
         roiTab.setWidget(self.roiwidget)
         roiTab.setAllowedAreas(Qt.LeftDockWidgetArea |
                                Qt.RightDockWidgetArea |
                                Qt.BottomDockWidgetArea |
                                Qt.TopDockWidgetArea)
         roiTab.setFeatures(QDockWidget.DockWidgetMovable |
                            QDockWidget.DockWidgetFloatable |
                            QDockWidget.DockWidgetClosable)
         self.parent.addDockWidget(Qt.BottomDockWidgetArea
                                   ,roiTab)
         roiTab.setFloating(True)
         roiTab.resize(600,150)
         
         def closetab(ev):
             # This probably does not clean up memory...
             if not self.roiwidget is None:
                 [self.p1.removeItem(r)
                  for r in self.roiwidget.items()]
                 del self.roiwidget
                 self.roiwidget = None
             ev.accept()
         roiTab.closeEvent = closetab
     self.roiwidget.add_roi(roi)
Esempio n. 2
0
 def histogramWin(self):
     if self.hist is None:
         histTab = QDockWidget("histogram cam {0}".format(self.iCam), self)
         widget = QWidget()
         layout = QGridLayout()
         widget.setLayout(layout)
         win = pg.GraphicsLayoutWidget()
         p1 = win.addPlot()
         p1.getViewBox().invertY(True)
         p1.hideAxis('left')
         p1.hideAxis('bottom')
         
         self.hist = pg.HistogramLUTItem()
         self.hist.axis.setPen('k')
         p1.addItem(self.hist)
         self.hist.setImageItem(self.view)
         layout.addWidget(win,0,0)
         histTab.setWidget(widget)
         histTab.setAllowedAreas(Qt.LeftDockWidgetArea |
                                 Qt.RightDockWidgetArea |
                                 Qt.BottomDockWidgetArea |
                                 Qt.TopDockWidgetArea)
         histTab.setFeatures(QDockWidget.DockWidgetMovable |
                             QDockWidget.DockWidgetFloatable |
                             QDockWidget.DockWidgetClosable)
         self.parent.addDockWidget(Qt.BottomDockWidgetArea
                                   ,histTab)
         histTab.setFloating(True)
     
         histTab.resize(200,200)
     try:
         histstate = self.hist.saveState()
     except Exception as err:
         display('[ERROR] - could not save histogram state. "pip install pyqtgraph --upgrade" might solve it.')
         print(err)
     def closefun(ev):
         try:
             self.hist.restoreState(histstate)
         except Exception as err:
             print(err)
             pass
         self.hist = None
         ev.accept()
     histTab.closeEvent = closefun