1
1
import React , { Component } from 'react' ;
2
2
import PropTypes from 'prop-types' ;
3
3
4
- import { DownstreamContext } from './View' ;
4
+ import { RepresentationContext , DownstreamContext } from './View' ;
5
5
6
6
import vtk from 'vtk.js/vtk.js' ;
7
7
@@ -21,28 +21,33 @@ export default class Algorithm extends Component {
21
21
22
22
render ( ) {
23
23
return (
24
- < DownstreamContext . Consumer >
25
- { ( downstream ) => {
26
- if ( ! this . algo ) {
27
- const { vtkClass, state } = this . props ;
28
- this . algo = vtk ( { vtkClass, ...state } ) ;
29
- }
30
- if ( ! this . downstream ) {
31
- downstream . setInputConnection (
32
- this . algo . getOutputPort ( ) ,
33
- this . props . port
34
- ) ;
35
- this . downstream = downstream ;
36
- }
37
- return (
38
- < DownstreamContext . Provider value = { this . algo } >
39
- < div key = { this . props . id } id = { this . props . id } >
40
- { this . props . children }
41
- </ div >
42
- </ DownstreamContext . Provider >
43
- ) ;
44
- } }
45
- </ DownstreamContext . Consumer >
24
+ < RepresentationContext . Consumer >
25
+ { ( representation ) => (
26
+ < DownstreamContext . Consumer >
27
+ { ( downstream ) => {
28
+ this . representation = representation ;
29
+ if ( ! this . algo ) {
30
+ const { vtkClass, state } = this . props ;
31
+ this . algo = vtk ( { vtkClass, ...state } ) ;
32
+ }
33
+ if ( ! this . downstream ) {
34
+ downstream . setInputConnection (
35
+ this . algo . getOutputPort ( ) ,
36
+ this . props . port
37
+ ) ;
38
+ this . downstream = downstream ;
39
+ }
40
+ return (
41
+ < DownstreamContext . Provider value = { this . algo } >
42
+ < div key = { this . props . id } id = { this . props . id } >
43
+ { this . props . children }
44
+ </ div >
45
+ </ DownstreamContext . Provider >
46
+ ) ;
47
+ } }
48
+ </ DownstreamContext . Consumer >
49
+ ) }
50
+ </ RepresentationContext . Consumer >
46
51
) ;
47
52
}
48
53
@@ -68,6 +73,9 @@ export default class Algorithm extends Component {
68
73
69
74
if ( state && ( ! previous || state !== previous . state ) ) {
70
75
this . algo . set ( state ) ;
76
+ if ( this . representation ) {
77
+ this . representation . dataChanged ( ) ;
78
+ }
71
79
}
72
80
}
73
81
}
0 commit comments