pyclickimage.ImageViewer#
- class pyclickimage.ImageViewer(parent=None, half_shift=True)[source]#
Bases:
QGraphicsViewInteractive image viewer with: - subpixel cursor tracking - crosshair overlay - zoom with mouse wheel - precise click detection (drag-safe) - marker system for annotation
half-shift :
True = (0,0) on the center of the first pixel.
False = (0,0) on the corner of the first pixel.
- add_marker(center: ~typing.Tuple[float, float], color: ~PyQt5.QtGui.QColor = <PyQt5.QtGui.QColor object>, size: int = 8) None[source]#
Add a cross-style marker at a given position.
- Parameters:
center (Tuple[float, float]) – (x, y) coordinates.
color (QtGui.QColor) – Marker color.
size (int) – Half-size of cross arms.
- left_click_signal#
- load_image(path: str) None[source]#
Load an image into the viewer.
- Parameters:
path (str) – Path to image file.
- Raises:
ValueError – If image cannot be loaded.
- mouseMoveEvent(event: QMouseEvent) None[source]#
Update crosshair and coordinate display.
- Parameters:
event (QtGui.QMouseEvent) – Mouse move event.
- mousePressEvent(event: QMouseEvent) None[source]#
Store press position for click validation.
- Parameters:
event (QtGui.QMouseEvent) – Mouse press event.
- mouseReleaseEvent(event: QMouseEvent) None[source]#
Detect valid click and emit coordinates.
- Parameters:
event (QtGui.QMouseEvent) – Mouse release event.
- reset_view() None[source]#
Reset the view to the initial state (no zoom, centered image).
This method: - resets the internal zoom counter - resets Qt transformation matrix - re-applies fitInView on the current image
- right_click_signal#