GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — PlotPy/plotpy/items/shape/point.py at master · PlotPyStack/PlotPy Expand file tree/ Copy pathpoint.pyMore file actions 92 lines (70 loc) · 2.4 KB / Copy pathpoint.pyFile metadata and controls92 lines (70 loc) · 2.4 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 # -*- coding: utf-8 -*- from __future__ import annotations from typing import TYPE_CHECKING from guidata.utils.misc import assert_interfaces_valid from qtpy import QtCore as QC from qtpy import QtGui as QG from plotpy.items.shape.polygon import PolygonShape if TYPE_CHECKING: from plotpy.styles.shape import ShapeParam class PointShape(PolygonShape): """Point shape Args: x: X coordinate y: Y coordinate shapeparam: Shape parameters """ CLOSED = False _icon_name = "point_shape.svg" def __init__( self, x: float = 0.0, y: float = 0.0, shapeparam: ShapeParam = None ) -> None: super().__init__(shapeparam=shapeparam) self.set_pos(x, y) def set_pos(self, x: float, y: float) -> None: """Set the point coordinates to (x, y) Args: x: X coordinate y: Y coordinate """ self.set_points([(x, y)]) def get_pos(self) -> tuple[float, float]: """Return the point coordinates Returns: Point coordinates """ return tuple(self.points[0]) def move_point_to( self, handle: int, pos: tuple[float, float], ctrl: bool = False ) -> None: """Move a handle as returned by hit_test to the new position Args: handle: Handle pos: Position ctrl: True if <Ctrl> button is being pressed, False otherwise """ nx, ny = pos self.points[0] = (nx, ny) def __reduce__(self) -> tuple: """Reduce object to picklable state""" state = (self.shapeparam, self.points, self.z()) return (self.__class__, (), state) def __setstate__(self, state: tuple) -> None: """Set object state from pickled state""" self.shapeparam, self.points, z = state self.setZ(z) self.shapeparam.update_item(self) def boundingRect(self) -> QC.QRectF: """Return the bounding rectangle of the shape Returns: Bounding rectangle of the shape """ poly = QG.QPolygonF() if self.ADDITIONNAL_POINTS: shape_points = self.points[: -self.ADDITIONNAL_POINTS] else: shape_points = self.points for i in range(shape_points.shape[0]): poly.append(QC.QPointF(shape_points[i, 0], shape_points[i, 1])) return poly.boundingRect() assert_interfaces_valid(PointShape) |
| You are visitor 01402520 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |