def qwtDrawStar1Symbols(painter, points, numPoints, symbol): size =symbol.size() painter.setPen(symbol.pen()) sqrt1_2 = np.sqrt(.5) if QwtPainter.roundingAlignment(painter): r = QRect(0, 0, size.width(), size.height()) for pos in points: r.moveCenter(pos.toPoint()) d1 = r.width()/2.*(1.-sqrt1_2) QwtPainter.drawLine(painter, round(r.left()+d1), round(r.top()+d1), round(r.right()-d1), round(r.bottom()-d1)) QwtPainter.drawLine(painter, round(r.left()+d1), round(r.bottom()-d1), round(r.right()-d1), round(r.top()+d1)) c = QPoint(r.center()) QwtPainter.drawLine(painter, c.x(), r.top(), c.x(), r.bottom()) QwtPainter.drawLine(painter, r.left(), c.y(), r.right(), c.y()) else: r = QRectF(0, 0, size.width(), size.height()) for pos in points: r.moveCenter(pos.toPoint()) c = QPointF(r.center()) d1 = r.width()/2.*(1.-sqrt1_2) QwtPainter.drawLine(painter, r.left()+d1, r.top()+d1, r.right()-d1, r.bottom()-d1) QwtPainter.drawLine(painter, r.left()+d1, r.bottom()-d1, r.right()-d1, r.top()+d1) QwtPainter.drawLine(painter, c.x(), r.top(), c.x(), r.bottom()) QwtPainter.drawLine(painter, r.left(), c.y(), r.right(), c.y())
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()
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()