From 7582e26bf40e070a223a01d6aa6f048bbf361e34 Mon Sep 17 00:00:00 2001 From: Sebastien Jourdain Date: Wed, 27 Jan 2021 15:19:49 -0700 Subject: [PATCH] fix(Render): Trigger render when algo change --- src/core/Algorithm.js | 54 +++++++++++++++++------------- src/core/GeometryRepresentation.js | 4 ++- 2 files changed, 34 insertions(+), 24 deletions(-) diff --git a/src/core/Algorithm.js b/src/core/Algorithm.js index 40e0ceb..841a553 100644 --- a/src/core/Algorithm.js +++ b/src/core/Algorithm.js @@ -1,7 +1,7 @@ import React, { Component } from 'react'; import PropTypes from 'prop-types'; -import { DownstreamContext } from './View'; +import { RepresentationContext, DownstreamContext } from './View'; import vtk from 'vtk.js/vtk.js'; @@ -21,28 +21,33 @@ export default class Algorithm extends Component { render() { return ( - - {(downstream) => { - if (!this.algo) { - const { vtkClass, state } = this.props; - this.algo = vtk({ vtkClass, ...state }); - } - if (!this.downstream) { - downstream.setInputConnection( - this.algo.getOutputPort(), - this.props.port - ); - this.downstream = downstream; - } - return ( - -
- {this.props.children} -
-
- ); - }} -
+ + {(representation) => ( + + {(downstream) => { + this.representation = representation; + if (!this.algo) { + const { vtkClass, state } = this.props; + this.algo = vtk({ vtkClass, ...state }); + } + if (!this.downstream) { + downstream.setInputConnection( + this.algo.getOutputPort(), + this.props.port + ); + this.downstream = downstream; + } + return ( + +
+ {this.props.children} +
+
+ ); + }} +
+ )} +
); } @@ -68,6 +73,9 @@ export default class Algorithm extends Component { if (state && (!previous || state !== previous.state)) { this.algo.set(state); + if (this.representation) { + this.representation.dataChanged(); + } } } } diff --git a/src/core/GeometryRepresentation.js b/src/core/GeometryRepresentation.js index fc3c953..a160011 100644 --- a/src/core/GeometryRepresentation.js +++ b/src/core/GeometryRepresentation.js @@ -106,7 +106,9 @@ export default class GeometryRepresentation extends Component { } dataChanged() { - console.log('dataChanged'); + if (this.view) { + this.view.renderView(); + } } }