本文整理汇总了Python中PyQt5.QtWidgets.QGraphicsLineItem.setZValue方法的典型用法代码示例。如果您正苦于以下问题:Python QGraphicsLineItem.setZValue方法的具体用法?Python QGraphicsLineItem.setZValue怎么用?Python QGraphicsLineItem.setZValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtWidgets.QGraphicsLineItem
的用法示例。
在下文中一共展示了QGraphicsLineItem.setZValue方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: drawGrid
# 需要导入模块: from PyQt5.QtWidgets import QGraphicsLineItem [as 别名]
# 或者: from PyQt5.QtWidgets.QGraphicsLineItem import setZValue [as 别名]
def drawGrid(self):
black_notes = [2,4,6,9,11]
scale_bar = QGraphicsRectItem(0, 0, self.grid_width, self.note_height, self.piano)
scale_bar.setPos(self.piano_width, 0)
scale_bar.setBrush(QColor(100,100,100))
clearpen = QPen(QColor(0,0,0,0))
for i in range(self.end_octave - self.start_octave, self.start_octave - self.start_octave, -1):
for j in range(self.notes_in_octave, 0, -1):
scale_bar = QGraphicsRectItem(0, 0, self.grid_width, self.note_height, self.piano)
scale_bar.setPos(self.piano_width, self.note_height * j + self.octave_height * (i - 1))
scale_bar.setPen(clearpen)
if j not in black_notes:
scale_bar.setBrush(QColor(120,120,120))
else:
scale_bar.setBrush(QColor(100,100,100))
measure_pen = QPen(QColor(0, 0, 0, 120), 3)
half_measure_pen = QPen(QColor(0, 0, 0, 40), 2)
line_pen = QPen(QColor(0, 0, 0, 40))
for i in range(0, int(self.num_measures) + 1):
measure = QGraphicsLineItem(0, 0, 0, self.piano_height + self.header_height - measure_pen.width(), self.header)
measure.setPos(self.measure_width * i, 0.5 * measure_pen.width())
measure.setPen(measure_pen)
if i < self.num_measures:
number = QGraphicsSimpleTextItem('%d' % (i + 1), self.header)
number.setPos(self.measure_width * i + 5, 2)
number.setBrush(Qt.white)
for j in self.frange(0, self.time_sig[0]*self.grid_div/self.time_sig[1], 1.):
line = QGraphicsLineItem(0, 0, 0, self.piano_height, self.header)
line.setZValue(1.0)
line.setPos(self.measure_width * i + self.value_width * j, self.header_height)
if j == self.time_sig[0]*self.grid_div/self.time_sig[1] / 2.0:
line.setPen(half_measure_pen)
else:
line.setPen(line_pen)
示例2: create_axis
# 需要导入模块: from PyQt5.QtWidgets import QGraphicsLineItem [as 别名]
# 或者: from PyQt5.QtWidgets.QGraphicsLineItem import setZValue [as 别名]
def create_axis(self):
bounding_end = abs(self.dimension_analysis.bounding_rect[3])
bounding_start = abs(self.dimension_analysis.bounding_rect[2])
pen = QPen()
pen.setWidthF(0.5)
# horizontal line
self.graph_zero[0] = self.position[0] + self.margin - self.line_extend
self.graph_zero[1] = self.position[1] + bounding_start * self.height_multiplier + self.margin
self.graph_end[0] = self.graph_zero[0] + self.content_width + self.line_extend
self.graph_end[1] = self.graph_zero[1]
line_item_horizontal = QGraphicsLineItem(self.graph_zero[0], self.graph_zero[1], self.graph_end[0], self.graph_end[1])
line_item_horizontal.setPen(pen)
self.addToGroup(line_item_horizontal)
center = (self.graph_zero[0] + self.line_extend), self.graph_zero[1]
y_top = center[1] - (bounding_start*self.height_multiplier)
y_bottom = center[1]+(bounding_end*self.height_multiplier)
line_item_vertical = QGraphicsLineItem(center[0], y_top, center[0], y_bottom)
line_item_vertical.setPen(pen)
self.addToGroup(line_item_vertical)
pen_thin = QPen()
pen_thin.setWidthF(0.2)
start_graph = center[1] - 10
while start_graph > center[1] - bounding_start * self.height_multiplier:
line_item_horizontal = QGraphicsLineItem(self.graph_zero[0], start_graph, self.graph_end[0], start_graph)
line_item_horizontal.setPen(pen_thin)
line_item_horizontal.setZValue(-0.5)
self.addToGroup(line_item_horizontal)
start_graph -= 10
start_graph = center[1] + 10
while start_graph < center[1] + bounding_end * self.height_multiplier:
line_item_horizontal = QGraphicsLineItem(self.graph_zero[0], start_graph, self.graph_end[0], start_graph)
line_item_horizontal.setPen(pen_thin)
line_item_horizontal.setZValue(-0.5)
self.addToGroup(line_item_horizontal)
start_graph += 10
示例3: createArrow
# 需要导入模块: from PyQt5.QtWidgets import QGraphicsLineItem [as 别名]
# 或者: from PyQt5.QtWidgets.QGraphicsLineItem import setZValue [as 别名]
def createArrow(self):
rad = self._RADIUS
pen = QPen()
pen.setWidth(3)
color = QColor(Qt.blue)
color.setAlphaF(0.25)
pen.setBrush(color)
if self._virtual_helix.isEvenParity():
arrow = QGraphicsLineItem(rad, rad, 2*rad, rad, self)
else:
arrow = QGraphicsLineItem(0, rad, rad, rad, self)
arrow.setTransformOriginPoint(rad, rad)
arrow.setZValue(400)
arrow.setPen(pen)
self.arrow = arrow
self.arrow.hide()
示例4: createArrows
# 需要导入模块: from PyQt5.QtWidgets import QGraphicsLineItem [as 别名]
# 或者: from PyQt5.QtWidgets.QGraphicsLineItem import setZValue [as 别名]
def createArrows(self):
rad = _RADIUS
pen1 = self._pen1
pen2 = self._pen2
pen1.setWidth(3)
pen2.setWidth(3)
pen1.setBrush(Qt.gray)
pen2.setBrush(Qt.lightGray)
if self._virtual_helix.isEvenParity():
arrow1 = QGraphicsLineItem(rad, rad, 2*rad, rad, self)
arrow2 = QGraphicsLineItem(0, rad, rad, rad, self)
else:
arrow1 = QGraphicsLineItem(0, rad, rad, rad, self)
arrow2 = QGraphicsLineItem(rad, rad, 2*rad, rad, self)
arrow1.setTransformOriginPoint(rad, rad)
arrow2.setTransformOriginPoint(rad, rad)
arrow1.setZValue(400)
arrow2.setZValue(400)
arrow1.setPen(pen1)
arrow2.setPen(pen2)
self.arrow1 = arrow1
self.arrow2 = arrow2
self.arrow1.hide()
self.arrow2.hide()
示例5: PianoRoll
# 需要导入模块: from PyQt5.QtWidgets import QGraphicsLineItem [as 别名]
# 或者: from PyQt5.QtWidgets.QGraphicsLineItem import setZValue [as 别名]
#.........这里部分代码省略.........
if not old_info == note.note:
self.midievent.emit(["midievent-remove", old_info[0], old_info[1], old_info[2], old_info[3]])
self.midievent.emit(["midievent-add", note.note[0], note.note[1], note.note[2], note.note[3]])
# -------------------------------------------------------------------------
# Internal Functions
def drawHeader(self):
self.header = QGraphicsRectItem(0, 0, self.grid_width, self.header_height)
#self.header.setZValue(1.0)
self.header.setPos(self.piano_width, 0)
self.addItem(self.header)
def drawPiano(self):
piano_keys_width = self.piano_width - self.padding
labels = ('B','Bb','A','Ab','G','Gb','F','E','Eb','D','Db','C')
black_notes = (2,4,6,9,11)
piano_label = QFont()
piano_label.setPointSize(6)
self.piano = QGraphicsRectItem(0, 0, piano_keys_width, self.piano_height)
self.piano.setPos(0, self.header_height)
self.addItem(self.piano)
key = PianoKeyItem(piano_keys_width, self.note_height, self.piano)
label = QGraphicsSimpleTextItem('C8', key)
label.setPos(18, 1)
label.setFont(piano_label)
key.setBrush(QColor(255, 255, 255))
for i in range(self.end_octave - self.start_octave, self.start_octave - self.start_octave, -1):
for j in range(self.notes_in_octave, 0, -1):
if j in black_notes:
key = PianoKeyItem(piano_keys_width/1.4, self.note_height, self.piano)
key.setBrush(QColor(0, 0, 0))
key.setZValue(1.0)
key.setPos(0, self.note_height * j + self.octave_height * (i - 1))
elif (j - 1) and (j + 1) in black_notes:
key = PianoKeyItem(piano_keys_width, self.note_height * 2, self.piano)
key.setBrush(QColor(255, 255, 255))
key.setPos(0, self.note_height * j + self.octave_height * (i - 1) - self.note_height/2.)
elif (j - 1) in black_notes:
key = PianoKeyItem(piano_keys_width, self.note_height * 3./2, self.piano)
key.setBrush(QColor(255, 255, 255))
key.setPos(0, self.note_height * j + self.octave_height * (i - 1) - self.note_height/2.)
elif (j + 1) in black_notes:
key = PianoKeyItem(piano_keys_width, self.note_height * 3./2, self.piano)
key.setBrush(QColor(255, 255, 255))
key.setPos(0, self.note_height * j + self.octave_height * (i - 1))
if j == 12:
label = QGraphicsSimpleTextItem('{}{}'.format(labels[j - 1], self.end_octave - i), key )
label.setPos(18, 6)
label.setFont(piano_label)
self.piano_keys.append(key)
def drawGrid(self):
black_notes = [2,4,6,9,11]
scale_bar = QGraphicsRectItem(0, 0, self.grid_width, self.note_height, self.piano)
scale_bar.setPos(self.piano_width, 0)
scale_bar.setBrush(QColor(100,100,100))
clearpen = QPen(QColor(0,0,0,0))
for i in range(self.end_octave - self.start_octave, self.start_octave - self.start_octave, -1):
for j in range(self.notes_in_octave, 0, -1):
scale_bar = QGraphicsRectItem(0, 0, self.grid_width, self.note_height, self.piano)
scale_bar.setPos(self.piano_width, self.note_height * j + self.octave_height * (i - 1))
scale_bar.setPen(clearpen)
if j not in black_notes:
scale_bar.setBrush(QColor(120,120,120))
示例6: BaseGraphic
# 需要导入模块: from PyQt5.QtWidgets import QGraphicsLineItem [as 别名]
# 或者: from PyQt5.QtWidgets.QGraphicsLineItem import setZValue [as 别名]
class BaseGraphic(object):
def __init__(self, *args):
super(BaseGraphic, self).__init__()
self.label = args[3]
self.parent = args[0]
self.section_analyzer = self.parent.section_analyzer
self.width = None
self.height = None
self.margin = None
self.position = args[1], args[2]
self.content_width = None
self.content_height = None
self.distance_pointer = None
self.distance_label = None
self.section_num = len(self.section_analyzer.section_list)
self.section_distance = self.section_analyzer.section_distance
self.length_multiplier = 100.0
self.height_multiplier = 100.0
self.line_extend = 20
self.margin = 50
self.material_legend = MaterialLegend(self)
self._inited = False
self.items = []
self.add_title()
def add_title(self):
if self.label:
title = QGraphicsSimpleTextItem(self.label)
title.setPos(self.position[0] + self.margin, self.position[1] + self.line_extend)
self.addToGroup(title)
def addToGroup(self, item):
self.items.append(item)
def create_distance_pointer(self):
self.distance_pointer = QGraphicsLineItem()
pen = QPen()
pen.setWidthF(1.0)
pen.setStyle(Qt.DashDotLine)
color = Color.create_qcolor_from_rgb_tuple_f((1,0,0))
pen.setColor(color)
self.distance_pointer.setPen(pen)
self.distance_pointer.setZValue(1.0)
self.addToGroup(self.distance_pointer)
self.distance_label = QGraphicsSimpleTextItem()
self.distance_label.setZValue(1.0)
self.addToGroup(self.distance_label)
def init_dimension(self):
section_num = len(self.section_analyzer.section_list)
section_distance = self.section_analyzer.section_distance
self.content_width = section_num * section_distance * self.length_multiplier
self.create_distance_pointer()
self._inited = True
def update_graph_size(self):
if self.content_height and self.content_width:
self.width = self.content_width + self.margin * 2
self.height = self.content_height + self.margin * 2
# bounding_rect.setWidth(self.width)
# bounding_rect.setHeight(self.height)
def set_distance_pointer(self, distance):
if self._inited:
x1 = self.position[0] + self.margin + distance * self.length_multiplier
y1 = self.position[1]
x2 = x1
y2 = y1 + self.height
self.distance_pointer.setLine(x1, y1, x2, y2)
self.distance_label.setText("%.2f" % distance)
self.distance_label.setPos(x2,y2)
pass
@staticmethod
def set_rect_fill(*args):
if args[0] == 0: #surface color mode
rect = args[1]
color = args[2]
qcolor = Color.create_qcolor_from_rgb_tuple_f(color)
brush = QBrush(qcolor)
rect.setBrush(brush)
def create_legend(self):
x = self.position[0] + self.width
y = self.position[1]
self.material_legend.create_material_legend(x, y)
for item in self.material_legend.graphic_items:
self.addToGroup(item)