def hit_test(self, pos): plot = self.plot() if plot is None: return rect = self.get_text_rect() canvasRect = plot.canvas().contentsRect() xMap = plot.canvasMap(self.xAxis()) yMap = plot.canvasMap(self.yAxis()) x, y = self.get_top_left(xMap, yMap, canvasRect) rct = QRectF(x, y, rect.width(), rect.height()) inside = rct.contains(pos.x(), pos.y()) if inside: return self.click_inside(pos.x() - x, pos.y() - y) else: return 1000.0, None, False, None
def draw(self, painter, xMap, yMap, canvasRect): """ Draw the marker :param QPainter painter: Painter :param qwt.scale_map.QwtScaleMap xMap: x Scale Map :param qwt.scale_map.QwtScaleMap yMap: y Scale Map :param QRectF canvasRect: Contents rectangle of the canvas in painter coordinates """ pos = QPointF(xMap.transform(self.__data.xValue), yMap.transform(self.__data.yValue)) self.drawLines(painter, canvasRect, pos) if self.__data.symbol and self.__data.symbol.style( ) != QwtSymbol.NoSymbol: sz = self.__data.symbol.size() clipRect = QRectF( canvasRect.adjusted(-sz.width(), -sz.height(), sz.width(), sz.height())) if clipRect.contains(pos): self.__data.symbol.drawSymbols(painter, [pos]) self.drawLabel(painter, canvasRect, pos)