Пример #1
0
 def openFrameGroup(self, fgroup):
     '''Slot to know when the application opens a new framegroup'''
     
     frameCount = len(fgroup)
     self.ui.frameSlider.setMaximum(frameCount -1)
     
     # render previews
     f0 = fgroup[0][0].asQPixmap()
     previewW = self.ui.previewLabel.width()
     previewH = self.ui.previewLabel.height()
     previewPmap = QtGui.QPixmap(previewW, previewH)
     previewPmap.fill()
     
     scaledW = f0.width() * previewH / f0.height()
     printCount = int(previewW) / int(scaledW) # int division
     freeSpace = float(previewW - (printCount * scaledW)) / (printCount - 1)
     
     painter = QtGui.QPainter(previewPmap)
     for i in xrange(printCount):
         fid = int(round(float(i * (frameCount-1)) / (printCount-1)))
         x = int(round(i * (freeSpace + scaledW)))
         frame = fgroup[fid][0].asQPixmap().scaled(scaledW, previewH)
         painter.drawPixmap(x,0,frame)
         
     
     painter.end()
     self.ui.previewLabel.setPixmap(previewPmap)
     
     # render the current frame
     self.ui.frameLabel.setPixmap(fgroup.current()[0].asQPixmap())
Пример #2
0
 def asQPixmap(self):
     '''Returns a qpixmap for this frame'''
     if self._rgbdata is not None:
         height, width = self._rgbdata.shape[:2]
         qimg = QtGui.QImage(self._rgbdata, width, height,
                             QtGui.QImage.Format_RGB888)
     else:
         qimg = QtGui.QImage(320, 240, QtGui.QImage.Format_RGB888)
     return QtGui.QPixmap.fromImage(qimg)
Пример #3
0
    def updateWidgetPosition(self):
        '''Resizes widget to content size and repositions within parent'''

        if len(self._messages) > 0:
            self.show()
            pw = self.parent().childrenRect().width()
            ph = self.parent().childrenRect().height()

            # check size of each message
            w = 0
            h = 0
            fm = QtGui.QFontMetrics(self.font())
            msgposs = []
            for group in self._messageorder:
                msg = self._messages[group][1]
                mw = fm.width(msg) + 2
                msgposs.append((mw, h + fm.ascent()))
                w = max(w, mw)
                h += fm.height() + 2
                #TODO: make this scale the font size

            # calculate the left positions
            self._msgposs = []
            for msgpos in msgposs:
                self._msgposs.append(((w - msgpos[0]) / 2, msgpos[1]))

            # resize/position widget
            self.setGeometry((pw - w) / 2, (ph - h) / 2, w, h)

            # refresh the screen
            self.update()
        else:
            self.hide()
Пример #4
0
    def drawWidget(self, qp):
        if None in self._messages:

            # outlined text
            #TODO: make the text colours into settings
            i = 0
            for group in self._messageorder:
                msg = self._messages[group][1]
                msgpos = self._msgposs[i]
                path = QtGui.QPainterPath()
                path.addText(QtCore.QPoint(*msgpos), self.font(), msg)
                qp.setPen(QtGui.QPen(QtCore.Qt.white, 1.5,
                                     QtCore.Qt.SolidLine))
                qp.setBrush(QtCore.Qt.black)
                qp.drawPath(path)
                i += 1
Пример #5
0
def main(argv):

    args = argv[1:]
    args.insert(0, "After Touches")
    app = QtGui.QApplication(args)
    runtime = AfterTouchesApplication()
    rc = app.exec_()
    runtime.cleanup()
    sys.exit(rc)
Пример #6
0
def main(argv):
    
    args = argv[1:]
    args.insert(0, "Delay Analysis")
    app = QtGui.QApplication(args)
    runtime = DelayVideoApplication()
    rc = app.exec_()
    runtime.cleanup()
    sys.exit(rc)
Пример #7
0
 def convertFrame(self):
     try:
         height, width = self.currentFrame.shape[:2]
         #             print "%s, %s" %(width, height)
         img = QtGui.QImage(self.currentFrame, width, height,
                            QtGui.QImage.Format_RGB888)
         img = QtGui.QPixmap.fromImage(img)
         self.previousFrame = self.currentFrame
         return img
     except:
         return None
Пример #8
0
 def convertFrame(self):
     """
     converts frame to format suitable for QtGui
     """
     try:
         height,width=self.currentFrame.shape[:2]
         img=QtGui.QImage(self.currentFrame,
                           width,
                           height,
                           QtGui.QImage.Format_RGB888)
         img=QtGui.QPixmap.fromImage(img)
         self.previousFrame = self.currentFrame
         return img
     except:
         return None
Пример #9
0
    def __init__(self, parent=None, settings=None, *args, **kwargs):
        QtGui.QWidget.__init__(self, parent, *args, **kwargs)
        self._settings = settings

        self._messages = {}
        self._messageorder = []
        self.setFont(QtGui.QFont("Liberation Sans",
                                 72))  #TODO: put font face in config file
        if parent is not None:
            #TODO: make sure it has a resized signal
            parent.resized.connect(self.parentResized)
        self._baseline = 0
        self._clearTimer = QtCore.QTimer(self)
        self._clearTimer.timeout.connect(self.clearTimeout)
        self._clearTimer.start(100)

        self.updateWidgetPosition()
Пример #10
0
 def paintEvent(self, e):
     qp = QtGui.QPainter()
     qp.begin(self)
     qp.Antialiasing = True
     self.drawWidget(qp)
     qp.end()
Пример #11
0
 def asQImage(self):
     '''Returns a qimage version of this frame'''
     height, width = self._rgbdata.shape[:2]
     return QtGui.QImage(self._rgbdata, width, height,
                         QtGui.QImage.Format_RGB888)
Пример #12
0
 def asQImage(self):
     '''Returns a qimage version of this frame'''
     if self._qimage is None:
         self._qimage = QtGui.QImage(self._filename)
     return self._qimage
Пример #13
0
 def asQPixmap(self):
     '''Returns a qpixmap for this frame'''
     if self._qpixmap is None:
         self._qpixmap = QtGui.QPixmap(self._filename)
     return self._qpixmap
Пример #14
0
def main():
    app = QtGui.QApplication(sys.argv)
    ex = Gui()
    ex.show()
    sys.exit(app.exec_())