pymmcore-plus / pymmcore-widgets

A set of Qt-based widgets onto the pymmcore-plus model
https://pymmcore-plus.github.io/pymmcore-widgets
Other
12 stars 7 forks source link

use `getFocusDirection` when switching objects #197

Open ianhi opened 2 years ago

ianhi commented 2 years ago

pymmcore-plus/napari-micromanager#119 added some logic to move the Z position on switching an objective https://github.com/pymmcore-plus/pymmcore-widgets/blob/2eed0a766d79a20531f4ecf6e1167cb4e0efd32c/src/pymmcore_widgets/_objective_widget.py#L104-L112

I think that in order to be fully safe that logic needs to check the focus device direction with core.getFocusDirection.

From the docs:

Returns +1 if increasing position brings objective closer to sample, -1 if increasing position moves objective away from sample, or 0 if unknown. (Make sure to check for zero!)

https://micro-manager.org/apidoc/MMCore/latest/class_c_m_m_core.html#ace092b60e0d8138c7c68cf6baebfc8af

If it's 0 then I think we can pop up a dialog asking what to do. For -1 I think the move it query the stage limits and then move to the max position.

(I have no sense of if any devices have -1 for this, but I'd hate to be person who found out that my device does :) )

tlambert03 commented 2 years ago

Yep sounds good. Note that pymmcore-plus/napari-micromanager#119 didn't add that, it's been there the whole time, just refactored there to maintain the existing behavior.

I agree that for a safety mechanism it makes too many assumptions... and as noted in the refactor, it also needs a preference (since moving anything should probably be opt in in some way)