private measurePointerMessageHandler()

in pathology/viewer/src/components/image-viewer-side-nav/image-viewer-side-nav.component.ts [1356:1403]


  private measurePointerMessageHandler() {
    const olMap = this.olMap;
    if (!olMap) return;

    this.createHelpTooltip();
    olMap.on('pointermove', (evt) => {
      if (evt.dragging) {
        return;
      }
      const cursorMessageAllowListActions = [
        ViewerMenuAction.MEASURE,
        ViewerMenuAction.DRAW_POLYGON,
      ];
      if (cursorMessageAllowListActions.includes(this.selectedViewerAction)) {
        let helpMsg = 'Click to start drawing';

        if (this.measureDrawing) {
          const geom = this.measureDrawing.getGeometry();
          const continuePolygonMsg = 'Click to continue drawing the polygon';
          const continueLineMsg = 'Click to stop drawing the line';
          if (geom instanceof Polygon) {
            helpMsg = continuePolygonMsg;
          } else if (geom instanceof LineString) {
            helpMsg = continueLineMsg;
          }
        }
        if (!this.helpTooltipElement) return;

        if (this.selectedViewerAction === ViewerMenuAction.MEASURE) {
          helpMsg = helpMsg.replace('drawing', 'measuring');
        }

        this.windowService.safelySetInnerHtml(this.helpTooltipElement, helpMsg);

        this.helpTooltipOverlay?.setPosition(evt.coordinate);
        this.helpTooltipElement?.classList.remove('hidden');
        return;
      } else {
        if (this.helpTooltipOverlay && olMap) {
          this.resetHelpTooltipOverlay();
        }
      }
      this.helpTooltipElement?.classList.remove('hidden');
    });
    olMap.getViewport().addEventListener('mouseout', () => {
      this.helpTooltipElement?.classList.add('hidden');
    });
  }