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

bringing in other widgets for segmentation / painting #158

Open
shanebenlolo opened this issue Nov 24, 2021 · 0 comments
Open

bringing in other widgets for segmentation / painting #158

shanebenlolo opened this issue Nov 24, 2021 · 0 comments

Comments

@shanebenlolo
Copy link

I am trying to expand upon the functionality shown in this example https://react-vtkjs-viewport.netlify.app/painting to have more functionality and options like in this example https://kitware.github.io/vtk-js/examples/PaintWidget.html

I can import, and instantiate the wdigets like so:

    // brush types
    this.paintWidget = vtkPaintWidget.newInstance();
    this.paintWidget.setRadius(radius);
    this.rectangleWidget = vtkRectangleWidget.newInstance({
      resetAfterPointPlacement: true
    });
   
    widgets = [
      this.paintWidget,
      this.rectangleWidget
    ];

but when I replace paintWidget with rectangleWidget when adding a widget to the widgetManager like this:

    if (prevProps.painting !== this.props.painting) {
      if (this.props.painting) {
        this.viewWidget = this.widgetManager.addWidget(
          this.rectangleWidget,
          ViewTypes.SLICE
        );
        this.subs.paintStart.sub(
          this.viewWidget.onStartInteractionEvent(() => {
            this.paintFilter.startStroke();
            this.paintFilter.addPoint(
              this.rectangleWidget.getWidgetState().getTrueOrigin()
            );
            if (this.props.onPaintStart) {
              this.props.onPaintStart();
            }
          })
        );
        this.subs.paint.sub(
          this.viewWidget.onInteractionEvent(() => {
            if (this.viewWidget.getPainting()) {
              this.paintFilter.addPoint(
                this.rectangleWidget.getWidgetState().getTrueOrigin()
              );
              if (this.props.onPaint) {
                this.props.onPaint();
              }
            }
          })
        );
        this.subs.paintEnd.sub(
          this.viewWidget.onEndInteractionEvent(() => {
            const strokeBufferPromise = this.paintFilter.endStroke();

            if (this.props.onPaintEnd) {
              strokeBufferPromise.then(strokeBuffer => {
                this.props.onPaintEnd(strokeBuffer);
              });
            }
          })
        );

        this.widgetManager.grabFocus(this.rectangleWidget);
        this.widgetManager.enablePicking();

        this.genericRenderWindow.resize();
      } else if (this.viewWidget) {
        this.widgetManager.releaseFocus();
        this.widgetManager.removeWidget(this.rectangleWidget);
        this.widgetManager.disablePicking();

        this.subs.paintStart.unsubscribe();
        this.subs.paint.unsubscribe();
        this.subs.paintEnd.unsubscribe();
        this.viewWidget = null;

        this.genericRenderWindow.resize();
      }
    }

I receive the following error in OHIF: ViewerMain: Cannot read properties of null (reading 'isAttributeUsed'), this is the snippet of code throwing the error in index.js:

      if (program.isAttributeUsed('vertexDC')) {
        if (
          !cellBO
            .getVAO()
            .addAttributeArray(
              program,
              cellBO.getCABO(),
              'vertexDC',
              cellBO.getCABO().getVertexOffset(),
              cellBO.getCABO().getStride(),
              model.context.FLOAT,
              3,
              model.context.FALSE
            )
        ) {
          vtkErrorMacro('Error setting vertexDC in shader VAO.');
        }
      }

Does anyone know what I am doing wrong?

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

No branches or pull requests

1 participant