本文整理汇总了Python中qgis.PyQt.QtWidgets.QGraphicsLineItem.setPen方法的典型用法代码示例。如果您正苦于以下问题:Python QGraphicsLineItem.setPen方法的具体用法?Python QGraphicsLineItem.setPen怎么用?Python QGraphicsLineItem.setPen使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qgis.PyQt.QtWidgets.QGraphicsLineItem
的用法示例。
在下文中一共展示了QGraphicsLineItem.setPen方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: drawHistogram
# 需要导入模块: from qgis.PyQt.QtWidgets import QGraphicsLineItem [as 别名]
# 或者: from qgis.PyQt.QtWidgets.QGraphicsLineItem import setPen [as 别名]
def drawHistogram(self):
#if self.inputlayer is None:
# return
self.showInfo("Drawing histogram...")
viewprect = QRectF(self.histoGraphicsView.viewport().rect())
self.histoGraphicsView.setSceneRect(viewprect)
self.setupScene.clear()
self.setupScene.update()
histbottom = self.histoGraphicsView.sceneRect().bottom()
histtop = self.histoGraphicsView.sceneRect().top()
left = self.histoGraphicsView.sceneRect().left() + self.histopadding
right = self.histoGraphicsView.sceneRect().right() - self.histopadding
histheight = histbottom - histtop
histwidth = right - left
step = 1.0 * histwidth / self.histobins
maxlength = histheight
padding = 1
ll = QPoint(self.histopadding - 1, histheight - padding)
start = QPointF(self.histoGraphicsView.mapToScene(ll))
# Check if there is only one value
#myrange = (self.minValueSpinBox.value(),self.maxValueSpinBox.value())
if self.histogramAvailable:
maxvalue = 0.0
for i in range(len(self.histo[0])):
if self.histo[0][i] > maxvalue:
maxvalue = self.histo[0][i]
if maxvalue == 0:
return
self.maxBinNumber.setText(str(maxvalue))
# Create the histogram:
#self.showInfo("maxvalue: " + str(maxvalue))
#self.showInfo("maxlength: " + str(maxlength))
#self.showInfo("step: " + str(step))
for i in range(self.histobins):
binnumber = self.histo[0][i]
if binnumber == 0:
continue
height = (1.0 * self.histo[0][i] / maxvalue *
(maxlength - padding))
rectangle = QGraphicsRectItem(start.x() + step * i,
start.y(),
step,
-height)
rectangle.setPen(QPen(QColor(102, 102, 102)))
rectangle.setBrush(QBrush(QColor(240, 240, 240)))
self.setupScene.addItem(rectangle)
#self.showInfo(str(i) + ": " + str(height))
#if self.levelsListView.model().rowCount() > 0:
# Add lines for the levels
minvalue = float(self.histMinValue.text())
maxvalue = float(self.histMaxValue.text())
datarange = maxvalue - minvalue
if datarange == 0:
return
i = 0
while self.levelsListView.model().item(i):
#self.showInfo("Element: " +
# str(self.levelsListView.model().item(i).text()))
#continue
value = float(self.levelsListView.model().item(i).text())
xvalue = start.x() + histwidth * (value - minvalue) / datarange
line = QGraphicsLineItem(xvalue, 0, xvalue, histheight)
if i == 0 or i == (self.levelsListView.model().rowCount() - 1):
line.setPen(QPen(QColor(204, 0, 0)))
else:
line.setPen(QPen(QColor(0, 204, 0)))
self.setupScene.addItem(line)
i = i + 1