Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hide PlanarFreehandROITool annotations #307

Closed
Edward-Son opened this issue Nov 23, 2022 · 1 comment · Fixed by #318
Closed

Hide PlanarFreehandROITool annotations #307

Edward-Son opened this issue Nov 23, 2022 · 1 comment · Fixed by #318

Comments

@Edward-Son
Copy link
Contributor

Hello!

I am attempting to hide all the annotations of my PlanarFreehandROITool, using visibility.setAnnotationVisibility. Using this method successfully sets the visibility of my annotations to false, however the viewport is not updated and still shows them as visible. I make sure to refresh the volume viewport afterwards. On slack it was mentioned that it may not exist for this tool, or be implemented incorrectly. Let me know if there are any solutions!

Here is my snipped of code to set annotation visibility:

import * as csTools3d from '@cornerstonejs/tools';
import { getEnabledElements, getRenderingEngines } from '@cornerstonejs/core';

const { PlanarFreehandROITool, annotation } = csTools3d;
const { visibility } = annotation;
const viewportId = "viewport-0";

export function refreshViewport() {
  const renderingEngine = getRenderingEngines()[0]
  renderingEngine.renderViewport(viewportId);
}

export function toggleContours() {
  const element = getEnabledElements()[0].viewport.element;
  const annotationUIDs = annotation.state.getAnnotations(element, PlanarFreehandROITool.toolName);

  if (annotationUIDs && annotationUIDs.length) {
    annotationUIDs.forEach(annotation => {
      visibility.setAnnotationVisibility(annotation.annotationUID, !annotation.isVisible);
    });

    refreshViewport();
  }
}
@Edward-Son
Copy link
Contributor Author

Upon investigation, it would seem this is because the filterAnnotationsWithinSlice method of the PlanarFreehandROITool is missing the check for annotation visibility, since it doesn't use the one from utilities.planar.filterAnnotationsWithinSlice

at line 512 of PlanarFreehandROITool there should be something like:

if (!annotation.isVisible) {
      continue;
    }

@swederik could this be added?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant