def draw(self, painter, xMap, yMap, canvasQRect): if DEBUG: print("%s.draw called" % self._title) nPoints = len(self._x) if not nPoints: return plot = self.plot() #just a line if len(self._x) < 3: xPixel = [0] * nPoints yPixel = [0] * nPoints for i in range(nPoints): xPixel[i] = plot.transform(Qwt5.QwtPlot.xBottom, self._x[i]) yPixel[i] = plot.transform(Qwt5.QwtPlot.yLeft, self._y[i]) line = qt.QLineF(xPixel[0], yPixel[0],\ xPixel[1], yPixel[1]) painter.drawLine(line) return #a generic polygon qPoints = [0] * nPoints for i in range(nPoints): qPoints[i] = qt.QPointF(\ plot.transform(Qwt5.QwtPlot.xBottom, self._x[i]), plot.transform(Qwt5.QwtPlot.yLeft, self._y[i])) polygon = qt.QPolygonF(qPoints) oldBrush = painter.brush() brush = qt.QBrush(oldBrush) brush.setStyle(qt.Qt.CrossPattern) painter.setBrush(brush) painter.drawPolygon(polygon, qt.Qt.OddEvenFill) painter.setBrush(oldBrush)
def updatePrinter(self): if DEBUG: print("UPDATE PRINTER") self.scene.setSceneRect( qt.QRectF(0, 0, self.printer.width(), self.printer.height())) self.page.setPos(qt.QPointF(0.0, 0.0)) self.page.setRect( qt.QRectF(0, 0, self.printer.width(), self.printer.height())) #self.view.scale(1./self._viewScale, 1./self._viewScale) #self.view.fitInView(self.page.rect(), qt.Qt.KeepAspectRatio) #self._viewScale = 1.00 self.__updateTargetLabel()