def plot(self, qp, curve, yaxis): w = self.width() h = self.height() qp.setPen(curve.pen) qp.setBrush(curve.brush) if curve.is_path: if curve._path.elementCount() == 0: curve._path.moveTo(toPixelCords(w, h, 0, self.xaxis, 0, yaxis)) for x, y in zip(curve.xdata, curve.ydata): curve._path.lineTo(toPixelCords(w, h, x, self.xaxis, y, yaxis)) qp.drawPath(curve._path) else: poly = QPolygon() for x, y in zip(curve.xdata, curve.ydata): poly << toPixelCords(w, h, x, self.xaxis, y, yaxis) qp.drawPolyline(poly)
def updateHandles(self): for i, filter in enumerate(self.parent().chain._filters): if filter._enabled is True: fc = filter._fc * fs * 0.5 if filter._type not in (FilterType.Peak, FilterType.LShelving, FilterType.HShelving): y = 0 else: y = filter._g self.handles[i] = toPixelCords(self.width(), self.height(), fc, self.xaxis, y, self.raxis) self.parent().nodes[i].ctrls[2].setText(str(int(fc))) self.parent().nodes[i].ctrls[3].setText("{:.1f}".format(filter._g)) else: self.handles[i] = None
def drawTicks(self, qp, axis): tick_pen = QPen(QColor(200, 200, 200)) qp.setPen(tick_pen) grid_major_pen = QPen(QColor(255, 255, 255, 80)) grid_major_pen.setStyle(Qt.DashLine) grid_minor_pen = QPen(QColor(255, 255, 255, 40)) grid_minor_pen.setStyle(Qt.DashLine) majors = [] minors = [] ticklen = 10 w = self.width() h = self.height() xaxis = self.xaxis bgap = self.height() - self.rect.height() if axis.type == 'bottom': majors = [100, 1000, 10000] for i in range(1,5): minors.extend([j * 10 ** i for j in range(2,10)]) qp.drawLine(self.rect.bottomLeft(), self.rect.bottomRight()) for tick in majors: qp.setPen(tick_pen) qp.drawLine(toPixelCords(w, h, tick, xaxis), h - bgap, toPixelCords(w, h, tick, xaxis), h - bgap - ticklen) qp.drawText(toPixelCords(w, h, tick, xaxis) - bgap, h, str(tick)) qp.setPen(grid_major_pen) qp.drawLine(toPixelCords(w, h, tick, xaxis), h - bgap - ticklen, toPixelCords(w, h, tick, xaxis), 0) for tick in minors: qp.setPen(tick_pen) qp.drawLine(toPixelCords(w, h, tick, xaxis), h - bgap, toPixelCords(w, h, tick, xaxis), h - bgap - ticklen * 0.5) qp.setPen(grid_minor_pen) qp.drawLine(toPixelCords(w, h, tick, xaxis), h - bgap - ticklen * 0.5, toPixelCords(w, h, tick, xaxis), 0) elif axis.type == 'left': i = 1 while -i * 10 > axis.min: majors.append(-i * 10) i = i + 1 qp.drawLine(0, 0, 0, self.height() - bgap) qp.drawText(ticklen, 15, '[dB]') for tick in majors: qp.setPen(tick_pen) yp = toPixelCords(w, h, 0, xaxis, tick, self.laxis).y() qp.drawLine(0, yp, ticklen * 0.5, yp) qp.drawText(ticklen, yp + 4, str(tick)) qp.setPen(grid_major_pen) qp.drawLine(ticklen * 0.5, yp, self.width(), yp) elif axis.type == 'right': n = 11 majors = np.linspace(axis.min, axis.max, n) qp.drawLine(self.rect.topRight(), self.rect.bottomRight()) for tick in majors: yp = toPixelCords(w, h, 0, xaxis, tick, axis).y() qp.drawLine(self.width() - ticklen * 0.5, yp, self.width(), yp) qp.drawText(self.width() - ticklen - 10, yp + 4, str(int(tick)))