def catch(exprs: Sequence[str]) -> bool: """Detection function for solution polygons.""" points, _ = self.solution_polygon( exprs[0], exprs[1:-1], exprs[-1], self.vpoints ) if len(points) < 3: points = convex_hull( [(x + self.sr, y + self.sr) for x, y in points] + [(x - self.sr, y - self.sr) for x, y in points], as_qpoint=True ) else: points = [QPointF(x, y) for x, y in points] polygon = QPolygonF(points) if rect: return polygon.intersects( QPolygonF(self.selector.to_rect(self.zoom))) else: return polygon.containsPoint( QPointF(self.selector.x, -self.selector.y) * self.zoom, Qt.WindingFill )
def catch(exprs: Sequence[str]) -> bool: """Detection function for solution polygons.""" points, _ = self.solution_polygon(exprs[0], exprs[1:-1], exprs[-1], self.vpoints) polygon = QPolygonF(points) if rect: return polygon.intersects( QPolygonF(self.selector.to_rect(self.zoom))) else: return polygon.containsPoint( QPointF(self.selector.x, self.selector.y), Qt.WindingFill)
def catch(link: VLink) -> bool: """Detection function for links. + Is polygon: Using Qt polygon geometry. + If just a line: Create a range for mouse detection. """ points = self.__points_pos(link) if len(points) > 2: polygon = QPolygonF(convex_hull(points, as_qpoint=True)) else: polygon = QPolygonF(convex_hull( [(x + self.sr, y + self.sr) for x, y in points] + [(x - self.sr, y - self.sr) for x, y in points], as_qpoint=True )) if rect: return polygon.intersects(QPolygonF(self.selector.to_rect(self.zoom))) else: return polygon.containsPoint( QPointF(self.selector.x, -self.selector.y) * self.zoom, Qt.WindingFill )