def draw(self, painter, xMap, yMap, rect): margin = 5 pieRect = QRect() pieRect.setX(rect.x() + margin) pieRect.setY(rect.y() + margin) pieRect.setHeight(int(yMap.transform(80.0))) pieRect.setWidth(pieRect.height()) angle = 3 * 5760 / 4 for key in ["User", "System", "Idle"]: curve = self.plot().cpuPlotCurve(key) if curve.dataSize(): value = int(5760 * curve.sample(0).y() / 100.0) painter.save() painter.setBrush(QBrush(curve.pen().color(), Qt.SolidPattern)) painter.drawPie(pieRect, int(-angle), int(-value)) painter.restore() angle += value
def paintEvent(self, e): cr = self.contentsRect() painter = QPainter(self) painter.setClipRegion(e.region()) # if self.__data.isDown: # qDrawWinButton( # painter, 0, 0, self.width(), self.height(), self.palette(), True # ) painter.save() if self.__data.isDown: shiftSize = buttonShift(self) painter.translate(shiftSize.width(), shiftSize.height()) painter.setClipRect(cr) self.drawContents(painter) if not self.__data.icon.isNull(): iconRect = QRect(cr) iconRect.setX(iconRect.x() + self.margin()) if self.__data.itemMode != QwtLegendData.ReadOnly: iconRect.setX(iconRect.x() + BUTTONFRAME) iconRect.setSize(self.__data.icon.size()) iconRect.moveCenter(QPoint(iconRect.center().x(), cr.center().y())) painter.drawPixmap(iconRect, self.__data.icon) painter.restore()