QScanPattern#

class QPolargraph.patterns.QScanPattern.QScanPattern(*args, width=0.6, height=0.6, dx=0.0, dy=0.1, step=5, polargraph, **kwargs)[source]#

Bases: QObject

Base class for polargraph scan-trajectory patterns.

Manages the scan geometry and drives the polargraph through a sequence of waypoints. Subclasses override vertices() and trajectory() to define different scan patterns.

The motion controller is always in one of four states (ScanState):

  • IDLE — no motion.

  • MOVING — positioning to the scan start or returning home; data are not collected.

  • SCANNING — actively scanning; dataReady() is emitted at each position poll.

  • PAUSED — motion suspended; the remaining trajectory is saved and the polargraph holds its current position.

Properties#

widthfloat

Horizontal extent of the scan area [m]. Default: 0.6.

heightfloat

Vertical extent of the scan area [m]. Default: 0.6.

dxfloat

Horizontal offset of the scan area center from the polargraph centerline [m]. Default: 0.

dyfloat

Vertical offset of the scan area top edge below the home position [m]. Default: 0.1.

stepfloat

Spacing between scan lines [mm]. Default: 5.

Signals#

dataReady(numpy.ndarray)

Emitted with (x, y, t) — Cartesian position [m] and a time.monotonic() timestamp [s] — at every position poll during motion (MOVING and SCANNING states). t allows post-processing correlation with independently sampled instruments. Connect to belt animation and, gated on scanning(), to instrument data collection. (Callers that only need x, y may ignore data[2].)

stateChanged(ScanState)

Emitted on every state-machine transition. Subsumes the former moveFinished and scanFinished signals.

closeRequested()

Emitted when the state returns to IDLE after interruptAndClose() was called. Connect to the application window’s close() slot to shut down cleanly after all motion stops.

dataReady#
stateChanged#
closeRequested#
property width: float#

Horizontal extent of the scan area [m].

property height: float#

Vertical extent of the scan area [m].

property dx: float#

Horizontal offset of scan center from polargraph centerline [m].

property dy: float#

Vertical offset of scan top edge below home position [m].

property step: float#

Spacing between scan lines [mm].

isOpen()[source]#

Return True — scan patterns are always available.

Return type:

bool

property rect: list#

Bounding rectangle [x1, y1, x2, y2] of the scan area [m].

vertices()[source]#

Vertices of the scan trajectory.

Return type:

ndarray

Returns:

numpy.ndarray(nvertices, 2) array of (x, y) waypoints [m].

trajectory()[source]#

Coordinates along the scan path for display.

Return type:

ndarray

Returns:

numpy.ndarray(2, npts) array of (x, y) coordinates [m].

scanning()[source]#

Return True if the scanner is actively collecting data.

Return type:

bool

moving()[source]#

Return True if the scanner is in motion (MOVING or SCANNING).

Return type:

bool

active()[source]#

Return True if the scanner is in any non-IDLE state.

Return type:

bool

home()[source]#

Move payload to the home position.

Return type:

None

center()[source]#

Move payload to the center of the scan area.

Return type:

None

scan()[source]#

Execute a full scan, then return home.

State transitions during a normal scan:

IDLE MOVING (positioning to start) SCANNING (collecting data) MOVING (returning home) IDLE

The scan may be paused at any point via pause() and resumed via resume(). Calling home(), center(), or abandon() while paused discards the saved trajectory.

Return type:

None

pause()[source]#

Pause motion at the end of the current move.

The polargraph stops at its current target vertex and holds position. Call resume() to continue or abandon() to discard the remaining trajectory.

Return type:

None

resume()[source]#

Resume a paused trajectory.

Re-issues the last target vertex and continues with the remaining waypoints.

Return type:

None

toggle()[source]#

Start, pause, or resume based on current state.

Calling this slot from any thread is safe: it is the preferred way for the GUI to drive the scan state machine. Connects to the Scan/Pause/Resume button.

Return type:

None

abandon()[source]#

Abandon the current trajectory and return to IDLE.

If the scanner is moving, the motors are stopped immediately. If paused, the saved trajectory is discarded. The polargraph remains at its current position; call home() to return to the home position.

Return type:

None

interruptAndClose()[source]#

Abandon motion and emit closeRequested on reaching IDLE.

Used by the application window’s closeEvent to ensure the polargraph stops cleanly before the application exits.

Return type:

None