def paintTickMarks(self, qp): if (self.struct_times_days != None): qp.setPen(self.pen_tick_days) qp.setBrush(self.color_tick_days) qp.setFont(self.font_tick_days) metrics = qp.fontMetrics() for n, time_struct in enumerate(self.struct_times_days): if (n == 0): mstime = self.t0 else: mstime = self.mstimestamps_days[n] if (mstime >= self.t0): x0 = int(round(self.pixel_per_msec * (mstime - self.t0))) + self.lmx y0 = 0 timestr=str(time_struct.tm_mday) + ". " + \ str(time_struct.tm_mon) + ". " + str(time_struct.tm_year) fx = 0 fy = int(round(metrics.height())) qp.drawText(QtCore.QPoint(x0 + fx, y0 + fy), timestr) if (self.struct_times_major != None): qp.setPen(self.pen_tick_major) qp.setBrush(self.color_tick_major) qp.setFont(self.font_tick_major) metrics = qp.fontMetrics() for n, time_struct in enumerate(self.struct_times_major): mstime = self.mstimestamps_major[n] if (mstime >= self.t0): x0 = int(round(self.pixel_per_msec * (mstime - self.t0))) + self.lmx x1 = x0 y0 = self.ytick y1 = y0 + self.matick qp.drawLine(QtCore.QLine(x0, y0, x0, y1)) timestr=str(time_struct.tm_hour) + ":" + \ str(time_struct.tm_min) + ":" + str(time_struct.tm_sec) fx = -int(round(metrics.width(timestr) / 2)) fy = int(round(metrics.height())) qp.drawText(QtCore.QPoint(x0 + fx, y1 + fy), timestr) if (self.struct_times_minor != None): qp.setPen(self.pen_tick_minor) qp.setBrush(self.color_tick_minor) for n, time_struct in enumerate(self.struct_times_minor): mstime = self.mstimestamps_minor[n] if (mstime >= self.t0): x0 = int(round(self.pixel_per_msec * (mstime - self.t0))) + self.lmx x1 = x0 y0 = self.ytick y1 = y0 + self.mitick qp.drawLine(QtCore.QLine(x0, y0, x0, y1))
def paintBackground(self, qp): dt = self.t1 - self.t0 qp.setPen(self.pen_bg) qp.setBrush(self.color_bg) # paint also the margins x0 = 0 x1 = int(round(self.pixel_per_msec * dt)) + self.umx + self.lmx y0 = 0 y1 = self.h + self.umy + self.lmy rect = [ QtCore.QPoint(x0, y0), QtCore.QPoint(x1, y0), QtCore.QPoint(x1, y1), QtCore.QPoint(x0, y1) ] qp.drawPolygon(QtGui.QPolygon(rect))
def paintCanvas(self, qp): qp.setPen(self.pen_canvas) qp.setBrush(self.color_canvas) x0 = 0 x1 = self.width() y0 = 0 y1 = self.height() rect = [ QtCore.QPoint(x0, y0), QtCore.QPoint(x1, y0), QtCore.QPoint(x1, y1), QtCore.QPoint(x0, y1) ] # qp.drawPolygon(QtGui.QPolygon(rect)) qp.drawPolygon(QtGui.QPolygon(rect))
def paintLimits(self, limits, qp, pen, brush): qp.setPen(pen) qp.setBrush(brush) x0 = int(round(self.pixel_per_msec * (limits[0] - self.t0))) + self.lmx x1 = int(round(self.pixel_per_msec * (limits[1] - self.t0))) y0 = self.ytick + self.mitick y1 = self.h + self.lmy + self.umy self.logger.debug("paintLimits: %i, %i, %i, %i", x0, x1, y0, y1) rect = [ QtCore.QPoint(x0, y0), QtCore.QPoint(x1, y0), QtCore.QPoint(x1, y1), QtCore.QPoint(x0, y1) ] qp.drawPolygon(QtGui.QPolygon(rect))
def paintSelection(self, qp): return # selection disabled for the moment.. if (self.mstime == None): return if (self.mstime != None): self.sel0 = self.mstime - 5000 # testing.. self.sel1 = self.mstime + 5000 if (self.sel0 != None and self.sel1 != None): # first, paint the shader qp.setPen(self.pen_sel) qp.setBrush(self.color_sel) x0 = int(round( (self.sel0 - self.t0) * self.pixel_per_msec)) + self.lmx x1 = int(round( (self.sel1 - self.t0) * self.pixel_per_msec)) + self.lmx y0 = 0 + self.ytick + self.mitick y1 = self.h + self.lmy + self.umy rect = [ QtCore.QPoint(x0, y0), QtCore.QPoint(x1, y0), QtCore.QPoint(x1, y1), QtCore.QPoint(x0, y1) ] qp.drawPolygon(QtGui.QPolygon(rect)) # second, paint the triangles # (x0,y0) => (x0+dx,0) => (x0-dx,0) => (x0,y0) triangle = [ QtCore.QPoint(x0, y0), QtCore.QPoint(x0 + self.wtria, 0), QtCore.QPoint(x0 - self.wtria, 0) ] qp.drawPolygon(QtGui.QPolygon(triangle), 2) triangle = [ QtCore.QPoint(x1, y0), QtCore.QPoint(x1 + self.wtria, 0), QtCore.QPoint(x1 - self.wtria, 0) ] qp.drawPolygon(QtGui.QPolygon(triangle), 2)
def vec2point(vec): return QtCore.QPoint(int(vec[0]), int(vec[1]))