graphs.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:Laborejo 作者: hilbrichtsoftware 项目源码 文件源码
def updateGraphBlockTrack(self, staticRepresentationList):
        """Handles and visualizes block boundaries"""
        #{"type" : "GraphBlock", "id":id(block), "name":block.name, "duration":block.duration, "position":tickCounter}

        self.blockListCache = staticRepresentationList #sorted list
        self.blockdictCache = {} #reset

        for tbh in self.transparentBlockHandles:
            tbh.setParentItem(None)
            tbh.scene().removeWhenIdle(tbh)
        self.transparentBlockHandles = [] #reset

        #removeInstancesFromScene(CCGraphTransparentBlock) #this removes ALL blocks in all tracks from the scene. don't.
        for dictExportItem in staticRepresentationList:
            guiBlock = CCGraphTransparentBlock(parent = self, staticExportItem = dictExportItem, x = 0, y = -28, w = dictExportItem["duration"] / constantsAndConfigs.ticksToPixelRatio, h = 2*28)
            guiBlock.setParentItem(self)
            guiBlock.setPos(dictExportItem["position"] / constantsAndConfigs.ticksToPixelRatio,0)
            self.blockdictCache[dictExportItem["id"]] = guiBlock
            self.transparentBlockHandles.append(guiBlock)

        #Use the last item of the loop above to draw length of the boundary lines.
        maximumPixels = (dictExportItem["duration"] + dictExportItem["position"]) / constantsAndConfigs.ticksToPixelRatio
        upperLine = QtWidgets.QGraphicsLineItem(0,-28,maximumPixels,-28) #x1, y1, x2, y2
        #upperLine.setPen(QtGui.QColor("red"))
        upperLine.setParentItem(self)
        self.other.append(upperLine)
        lowerLine = QtWidgets.QGraphicsLineItem(0,28,maximumPixels,28) #x1, y1, x2, y2
        #lowerLine.setPen(QtGui.QColor("green"))
        lowerLine.setParentItem(self)
        self.other.append(lowerLine)
        upperLine.setOpacity(0.3)
        lowerLine.setOpacity(0.3)
        upperLine.setPos(0,0)
        lowerLine.setPos(0,0)
        #for self.stretchXCoordinates
        self.upperLine = upperLine
        self.lowerLine = lowerLine

        self.setRect(0,-28,maximumPixels,2*28)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号