def createGraphicItemsFromData(self):
w = self.staticItem["completeDuration"] / constantsAndConfigs.ticksToPixelRatio - constantsAndConfigs.magicPixel*2
if int(self.staticItem["numberOfMeasures"]) == self.staticItem["numberOfMeasures"]: #just an int?
numberOfMeasuresString = str(int(self.staticItem["numberOfMeasures"]))
else:
numberOfMeasuresString = str(self.staticItem["numberOfMeasures"]) #include the decimal dot
rect = QtWidgets.QGraphicsRectItem(constantsAndConfigs.magicPixel,0, w, constantsAndConfigs.stafflineGap) #x,y, w, h
rect.setBrush(QtCore.Qt.black)
rect.setParentItem(self)
self.rect = rect #for stretching
leftBlock = QtWidgets.QGraphicsRectItem(2, -1* constantsAndConfigs.stafflineGap, constantsAndConfigs.magicPixel, 3*constantsAndConfigs.stafflineGap)
leftBlock.setBrush(QtCore.Qt.black)
leftBlock.setParentItem(self)
rightBlock = QtWidgets.QGraphicsRectItem(0, -1* constantsAndConfigs.stafflineGap, constantsAndConfigs.magicPixel, 3*constantsAndConfigs.stafflineGap) #x, y, w, h
rightBlock.setBrush(QtCore.Qt.black)
#rightBlock.setPos(w,0)
rightBlock.setPos(rect.rect().right(),0)
rightBlock.setParentItem(self)
self.rightBlock = rightBlock #for stretching
for i, char in enumerate(numberOfMeasuresString):
if char == ".":
continue #TODO: Maybe warn about that? MMR below 1 are not valid but they are needed for editing purposes. Sometimes you need to go through such a value.
else:
n = GuiTimeSignature.digits[int(char)]
char = QtSvg.QGraphicsSvgItem()
char.setSharedRenderer(GuiTimeSignature.renderer)
char.setElementId(n)
#char.setPos(i*4*constantsAndConfigs.magicPixel + 4* constantsAndConfigs.magicPixel, -3*constantsAndConfigs.stafflineGap)
char.setPos(leftBlock.rect().width(), -3*constantsAndConfigs.stafflineGap)
char.setScale(1.5)
char.setParentItem(self)
self.setPos(0, -3 * constantsAndConfigs.stafflineGap)
评论列表
文章目录