|
1 | | -import React, { useState, useContext } from 'react'; |
| 1 | +import { useContext, useState } from 'react'; |
2 | 2 |
|
3 | 3 | import { |
4 | 4 | Contexts, |
5 | | - View, |
6 | | - VolumeRepresentation, |
7 | | - SliceRepresentation, |
8 | | - VolumeController, |
9 | | - ShareDataSet, |
| 5 | + DataArray, |
10 | 6 | ImageData, |
11 | 7 | PointData, |
12 | | - DataArray, |
| 8 | + RegisterDataSet, |
| 9 | + ShareDataSetRoot, |
| 10 | + SliceRepresentation, |
| 11 | + UseDataSet, |
| 12 | + View, |
| 13 | + VolumeController, |
| 14 | + VolumeRepresentation, |
13 | 15 | } from 'react-vtk-js'; |
14 | 16 |
|
15 | 17 | function generateRandomVolumeField(iMax, jMax, kMax) { |
@@ -70,57 +72,61 @@ function Slider(props) { |
70 | 72 | ); |
71 | 73 | } |
72 | 74 |
|
73 | | -function Example(props) { |
| 75 | +function Example() { |
74 | 76 | const [fieldIdx, setFieldIdx] = useState(0); |
75 | 77 | const colorWindow = fieldIdx ? 10 : 1; |
76 | 78 | const colorLevel = fieldIdx ? 5 : 0.5; |
77 | 79 |
|
78 | 80 | return ( |
79 | | - <div style={{ width: '100%', height: '100%' }}> |
80 | | - <View id='0'> |
81 | | - <Slider |
82 | | - max={FIELDS.length - 1} |
83 | | - value={fieldIdx} |
84 | | - setValue={setFieldIdx} |
85 | | - /> |
86 | | - <VolumeRepresentation> |
87 | | - <VolumeController rescaleColorMap={false} /> |
88 | | - <ShareDataSet> |
89 | | - <ImageData |
90 | | - spacing={[1, 1, 1]} |
91 | | - dimensions={[10, 10, 10]} |
92 | | - origin={[0, 0, 0]} |
93 | | - > |
94 | | - <PointData> |
95 | | - <DataArray |
96 | | - registration='setScalars' |
97 | | - type='Float32Array' |
98 | | - values={FIELDS[fieldIdx]} |
99 | | - /> |
100 | | - </PointData> |
101 | | - </ImageData> |
102 | | - </ShareDataSet> |
103 | | - </VolumeRepresentation> |
104 | | - </View> |
105 | | - <div |
106 | | - style={{ |
107 | | - position: 'absolute', |
108 | | - width: '20%', |
109 | | - height: '20%', |
110 | | - bottom: 0, |
111 | | - right: 0, |
112 | | - }} |
113 | | - > |
114 | | - <View background={[1, 1, 1]} triggerRender={fieldIdx}> |
115 | | - <SliceRepresentation |
116 | | - kSlice={5} |
117 | | - property={{ colorWindow, colorLevel }} |
118 | | - > |
119 | | - <ShareDataSet /> |
120 | | - </SliceRepresentation> |
| 81 | + <ShareDataSetRoot> |
| 82 | + <RegisterDataSet id='image'> |
| 83 | + <ImageData |
| 84 | + spacing={[1, 1, 1]} |
| 85 | + dimensions={[10, 10, 10]} |
| 86 | + origin={[0, 0, 0]} |
| 87 | + > |
| 88 | + <PointData> |
| 89 | + <DataArray |
| 90 | + registration='setScalars' |
| 91 | + type='Float32Array' |
| 92 | + values={FIELDS[fieldIdx]} |
| 93 | + /> |
| 94 | + </PointData> |
| 95 | + </ImageData> |
| 96 | + </RegisterDataSet> |
| 97 | + <div style={{ width: '100%', height: '100%' }}> |
| 98 | + <View id='0'> |
| 99 | + <Slider |
| 100 | + max={FIELDS.length - 1} |
| 101 | + value={fieldIdx} |
| 102 | + setValue={setFieldIdx} |
| 103 | + /> |
| 104 | + <VolumeRepresentation> |
| 105 | + <VolumeController rescaleColorMap={false} /> |
| 106 | + <UseDataSet id='image' /> |
| 107 | + </VolumeRepresentation> |
121 | 108 | </View> |
| 109 | + |
| 110 | + <div |
| 111 | + style={{ |
| 112 | + position: 'absolute', |
| 113 | + width: '20%', |
| 114 | + height: '20%', |
| 115 | + bottom: 0, |
| 116 | + right: 0, |
| 117 | + }} |
| 118 | + > |
| 119 | + <View background={[1, 1, 1]}> |
| 120 | + <SliceRepresentation |
| 121 | + kSlice={5} |
| 122 | + property={{ colorWindow, colorLevel }} |
| 123 | + > |
| 124 | + <UseDataSet id='image' /> |
| 125 | + </SliceRepresentation> |
| 126 | + </View> |
| 127 | + </div> |
122 | 128 | </div> |
123 | | - </div> |
| 129 | + </ShareDataSetRoot> |
124 | 130 | ); |
125 | 131 | } |
126 | 132 |
|
|
0 commit comments