structures.py 文件源码

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

项目:Laborejo 作者: hilbrichtsoftware 项目源码 文件源码
def createBeams(self, beamList):
        for b in self.beams:
            self.parentScore.removeWhenIdle(b)
        self.beams = []

        for startTick, endTick, beamtype, positionAsStaffline, direction in beamList:
            numberOfBeams = int(log(beamtype, 2)-2)
            assert numberOfBeams == log(beamtype, 2)-2
            for x in range(numberOfBeams):

                if direction > 0: #stem/beam upwards
                    beamNumberOffset = 4*x
                    xOffset = 7
                else:
                    beamNumberOffset = -4*x
                    xOffset = 1


                #non-scalable X-Offsets are not possible via setPos. zoom and stretch go haywire.
                #Instead we use one item for strechting and for the offset position and wrap it in an item group that is used for positioing.
                shifterAnchor = QtWidgets.QGraphicsItemGroup()
                shifterAnchor.setParentItem(self)

                rectangle = QtWidgets.QGraphicsRectItem(0, 0, (endTick-startTick) / constantsAndConfigs.ticksToPixelRatio, constantsAndConfigs.beamHeight) #x, y, w, h
                rectangle.setBrush(QtGui.QColor("black"))

                shifterAnchor.addToGroup(rectangle)
                shifterAnchor.rectangle = rectangle
                rectangle.setPos(xOffset, 0)

                if constantsAndConfigs.noteHeadMode:
                    rectangle.show()
                else:
                    rectangle.hide()

                self.beams.append(shifterAnchor)

                x = startTick/ constantsAndConfigs.ticksToPixelRatio
                y = beamNumberOffset + positionAsStaffline * constantsAndConfigs.stafflineGap / 2  - 1
                shifterAnchor.setPos(x, y)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号