Skip to content

Commit

Permalink
all annotations saved have (accurate) info saved
Browse files Browse the repository at this point in the history
  • Loading branch information
YukaUU committed Jul 21, 2024
1 parent 25f96ca commit 7b373a4
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 10 deletions.
20 changes: 10 additions & 10 deletions apps/viewer/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,18 +260,18 @@ function initCore() {


// add center position and zoom
if (data.states != undefined) {
// Rounds a number to the specified number of decimal places.
function roundTo(num, decimalPlaces) {
const factor = 10 ** decimalPlaces;
return Math.round(num * factor) / factor;
}
if (data.geometries.features[data.selected].viewerStates != null ||
data.geometries.features[data.selected].viewerStates != undefined) {
const decimalPlaces = 3;
attributes.X = data.states.x,
attributes.Y = data.states.y,
attributes.zoom = roundTo(data.states.zoom, decimalPlaces);
attributes.X = data.geometries.features[data.selected].viewerStates.x,
attributes.Y = data.geometries.features[data.selected].viewerStates.y,
attributes.zoom = roundTo(data.geometries.features[data.selected].viewerStates.z, decimalPlaces);
}
// Rounds a number to the specified number of decimal places.
function roundTo(num, decimalPlaces) {
const factor = 10 ** decimalPlaces;
return Math.round(num * factor) / factor;
}


body = convertHumanAnnotationToPopupBody(attributes);
if (
Expand Down
5 changes: 5 additions & 0 deletions common/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,11 @@ function covertToViewportFeature(width, height, og) {
og.geometry.type;
feature = {
type: 'Feature',
viewerStates: {
x: og.viewerStates.x,
y: og.viewerStates.y,
z: og.viewerStates.z,
},
properties: {
style: {},
area: null,
Expand Down
10 changes: 10 additions & 0 deletions core/extension/openseadragon-canvas-draw-overlay.js
Original file line number Diff line number Diff line change
Expand Up @@ -1023,6 +1023,11 @@
if (this.drawMode == 'point') {
this._current_path_ = {
type: 'Feature',
viewerStates: {
x: StatesHelper.getCurrentStates(true).x,
y: StatesHelper.getCurrentStates(true).y,
z: StatesHelper.getCurrentStates(true).z
},
properties: {
style: {},
},
Expand All @@ -1043,6 +1048,11 @@
properties: {
style: {},
},
viewerStates: {
x: StatesHelper.getCurrentStates(true).x,
y: StatesHelper.getCurrentStates(true).y,
z: StatesHelper.getCurrentStates(true).z,
},
geometry: {
type:
this.drawMode === 'line' || this.drawMode === 'grid' ?
Expand Down

0 comments on commit 7b373a4

Please sign in to comment.