in pathology/viewer/src/components/image-viewer-side-nav/image-viewer-side-nav.component.ts [1405:1453]
private openSelectedAnnotationOverlay(
feature: ol.Feature, openOnSingleClick = true) {
const olMap = this.olMap;
if (!olMap || !this.selectedAnnotationOverlay) return;
this.selectedFeature = feature;
let coordinates: Coordinate[] = [];
if (feature.getGeometry()?.getType() === 'Polygon') {
const polygonFeature = feature as Feature<Polygon>;
const featureCoordinates =
(polygonFeature.getGeometry()?.getCoordinates() ?? []);
coordinates = featureCoordinates[0];
const isROI = getFeatureAnnotationKey(feature).names.includes('ROI');
const isMeasure =
getFeatureAnnotationKey(feature).names.includes('MEASURE');
if (isROI || isMeasure) {
coordinates = polygonFeature.getGeometry()?.getCoordinates()[0] ?? [];
}
}
if (feature.getGeometry()?.getType() === 'Point') {
const pointFeature = feature as Feature<Point>;
const pointCoordinate = pointFeature.getGeometry()?.getCoordinates();
coordinates = pointCoordinate ? [pointCoordinate] : [];
}
const coordinate = getRightMostCoordinate(coordinates);
if (!coordinate?.length) return;
this.selectedAnnotationOverlay.setPosition(coordinate);
if (!openOnSingleClick) {
const positionChangeListener =
this.selectedAnnotationOverlay?.on('change:position', (position) => {
const targetOverlay = position.target as ol.Overlay;
const targetOverlayPosition: Coordinate|undefined =
targetOverlay?.getPosition();
if (this.selectedAnnotationOverlay && !targetOverlayPosition &&
olMap) {
olMap.removeOverlay(this.selectedAnnotationOverlay);
this.selectedFeature = undefined;
}
if (positionChangeListener) {
unByKey(positionChangeListener);
}
});
}
}