From 2ba9c9493bbed4f30fc9cc13a5d1904ca900589c Mon Sep 17 00:00:00 2001 From: Richard Bowman Date: Wed, 25 Mar 2020 05:24:10 +0000 Subject: [PATCH 1/2] Added a pane for camera/stage calibration --- .../controlComponents/paneSettings.vue | 7 ++ .../settingsComponents/cameraSettings.vue | 2 +- .../cameraStageMappingSettings.vue | 111 ++++++++++++++++++ 3 files changed, 119 insertions(+), 1 deletion(-) create mode 100644 src/components/controlComponents/settingsComponents/cameraStageMappingSettings.vue diff --git a/src/components/controlComponents/paneSettings.vue b/src/components/controlComponents/paneSettings.vue index ca8fd408..24e1a1a0 100644 --- a/src/components/controlComponents/paneSettings.vue +++ b/src/components/controlComponents/paneSettings.vue @@ -13,6 +13,11 @@
+
  • + Camera/stage mapping settings +
    +
  • +
  • Microscope settings
    @@ -25,6 +30,7 @@ import streamSettings from "./settingsComponents/streamSettings.vue"; import microscopeSettings from "./settingsComponents/microscopeSettings.vue"; import cameraSettings from "./settingsComponents/cameraSettings.vue"; +import cameraStageMappingSettings from "./settingsComponents/cameraStageMappingSettings.vue"; import appSettings from "./settingsComponents/appSettings.vue"; // Export main app @@ -34,6 +40,7 @@ export default { components: { streamSettings, cameraSettings, + cameraStageMappingSettings, microscopeSettings, appSettings } diff --git a/src/components/controlComponents/settingsComponents/cameraSettings.vue b/src/components/controlComponents/settingsComponents/cameraSettings.vue index caf62c7a..80bd4a45 100644 --- a/src/components/controlComponents/settingsComponents/cameraSettings.vue +++ b/src/components/controlComponents/settingsComponents/cameraSettings.vue @@ -103,7 +103,7 @@ export default { data: function() { return { settings: null, - recalibrationLinks: null, + recalibrationLinks: {}, isCalibrating: false }; }, diff --git a/src/components/controlComponents/settingsComponents/cameraStageMappingSettings.vue b/src/components/controlComponents/settingsComponents/cameraStageMappingSettings.vue new file mode 100644 index 00000000..84ee70eb --- /dev/null +++ b/src/components/controlComponents/settingsComponents/cameraStageMappingSettings.vue @@ -0,0 +1,111 @@ + + + + + From 0e88ad130b2b7c19daf13f0babddce150089ef1d Mon Sep 17 00:00:00 2001 From: Richard Bowman Date: Wed, 25 Mar 2020 05:50:42 +0000 Subject: [PATCH 2/2] Use new click-to-move API route This modifies the client to use the new move_in_image_coordinates API route provided by the camera_stage_mapping plugin. NB I've not yet deleted vestigial code relating to the "FoV" property. --- .../controlComponents/paneNavigate.vue | 55 ++++++++++++++++++- .../viewComponents/streamDisplay.vue | 9 +-- 2 files changed, 57 insertions(+), 7 deletions(-) diff --git a/src/components/controlComponents/paneNavigate.vue b/src/components/controlComponents/paneNavigate.vue index 6e304952..6e8eff12 100644 --- a/src/components/controlComponents/paneNavigate.vue +++ b/src/components/controlComponents/paneNavigate.vue @@ -185,7 +185,8 @@ export default { isAutofocusing: 0, moveLock: false, fastAutofocusUri: null, - normalAutofocusUri: null + normalAutofocusUri: null, + moveInImageCoordinatesUri: null }; }, @@ -215,10 +216,15 @@ export default { this.$root.$on("globalMoveEvent", (x, y, z, absolute) => { this.moveRequest(x, y, z, absolute); }); + // A global signal listener to perform a move action + this.$root.$on("globalMoveInImageCoordinatesEvent", (x, y, absolute) => { + this.moveInImageCoordinatesRequest(x, y, absolute); + }); // Update the current position in text boxes this.updatePosition(); // Look for autofocus plugin this.updateAutofocusUri(); + this.updateMoveInImageCoordinatesUri(); }, beforeDestroy() { @@ -328,6 +334,35 @@ export default { } }, + moveInImageCoordinatesRequest: function(x, y) { + console.log(`Sending move request in image coordinates: ${x}, ${y}`); + // If not movement-locked + if (!this.moveLock) { + // Lock move requests + this.moveLock = true; + + if (!this.moveInImageCoordinatesUri){ + this.modalError("Moving in image coordinates is not supported - you will need to upgrade your microscope's software."); + } + + // Send move request + axios + .post(this.moveInImageCoordinatesUri, { + x: y, // NB the coordinates are numpy/PIL style, meaning X and Y are swapped. + y: x, + }) + .then(() => { + this.updatePosition(); // Update the position in text boxes + }) + .catch(error => { + this.modalError(error); // Let mixin handle error + }) + .then(() => { + this.moveLock = false; // Release the move lock + }); + } + }, + zeroRequest: function() { // Send move request axios @@ -369,6 +404,24 @@ export default { .catch(error => { this.modalError(error); // Let mixin handle error }); + }, + + updateMoveInImageCoordinatesUri: function() { + axios + .get(this.pluginsUri) // Get a list of plugins + .then(response => { + var plugins = response.data; + var foundExtension = plugins.find( + e => e.title === "org.openflexure.camera_stage_mapping" + ); + if (foundExtension) { + // Get plugin action link + this.moveInImageCoordinatesUri = foundExtension.links.move_in_image_coordinates.href; + } + }) + .catch(error => { + this.modalError(error); // Let mixin handle error + }); } } }; diff --git a/src/components/viewComponents/streamDisplay.vue b/src/components/viewComponents/streamDisplay.vue index bb914843..4bfd82d1 100644 --- a/src/components/viewComponents/streamDisplay.vue +++ b/src/components/viewComponents/streamDisplay.vue @@ -115,16 +115,13 @@ export default { let xRelative = (0.5 * event.target.offsetWidth - xCoordinate) / - event.target.offsetWidth; + event.target.offsetWidth * event.target.naturalWidth; let yRelative = (0.5 * event.target.offsetHeight - yCoordinate) / - event.target.offsetHeight; - - let xSteps = xRelative * this.fov[0]; - let ySteps = yRelative * this.fov[1]; + event.target.offsetHeight * event.target.naturalHeight; // Emit a signal to move, acted on by panelNavigate.vue - this.$root.$emit("globalMoveEvent", xSteps, ySteps, 0, false); + this.$root.$emit("globalMoveInImageCoordinatesEvent", -xRelative, -yRelative); }, flashStream: function() {