Are there any examples or tutorials on using a vtk.js proxyManager to load multiple views from different input sources?

I’m back. :grinning:

I learned from @Sebastien_Jourdain that I probably don’t need multiple proxyManagers to handle multiple scans.

I’m now wondering if there are any resources (tutorials, code examples) of setting up a proxyManager that takes data in from multiple inputs (e.g. scan files) and then renders them as views?

For example, I can create a proxyManager:

let myProxyManager = state.proxyManager.createProxy('Sources', 'TrivialProducer',);

I can set the input of myProxyManager to a scan:

myProxyManager.setInputData(scanData);

But what about when I want to load a second scan with the proxyManager without unloading the first?

If I do:

myProxyManager.setInputData(scanData2);

I’ll overwrite the first scan rather than adding a second source?

Update
Looking at setInputData in macros.js I see that it takes two parameters, the first being the dataset (e.g. scan) and the second being a port.

It appears that the port is how I would set multiple inputs, but then there is an error message in the code noting “To add more input ports, use addInputData()”…

Update 2
addInputData is also in macros.js:

function addInputData(dataset) {
 if (model.deleted) {
  vtkErrorMacro('instance deleted - cannot call any method');
  return;
 }
 setInputData(dataset, getPortToFill());
}

So addInputData actually calls setInputData…which calls getPortToFill().

Oh, I guess there is a miss conception here. state.proxyManager is your unique ProxyManager. Your variable myProxyManager is NOT a ProxyManager but a (source) proxy that will hold your data (you called createProxy() to get a new instance for that variable). So you should be using the same proxymanager (state.proxymanager) to create more source proxies (1 per data/scan) that you aim to have a representation and view for.
What might be happening is that in your definition, you may have some definitions that links a lot of properties together for you but you probably don’t want them to be linked across your scan.
Am I getting closer to your initial problem? Or am I totally off?

I also have a question about Proxy.

It’s hard to understand exactly what Proxy does when you look at the AnimationProxyManager example.

Even if you press the current Play button, you can’t see it working.

https://volview.netlify.app/

Can you give me a rough example of what is possible based on the app above?

Maybe I’m beginning to understand? :slight_smile:

// Create proxyManager instance, see collapsed section below for myProxyConfig.
myProxyManager = vtkProxyManager.newInstance({ proxyConfiguration: myProxyConfig });

// Create a source proxy to load a scan
myScanProxy1 = myProxyManager.createProxy( 'Sources', 'TrivialProducer');

// Create a source proxy to load a second scan
myScanProxy2 = myProxyManager.createProxy( 'Sources', 'TrivialProducer');

// Create a source proxy to load a third scan
myScanProxy3 = myProxyManager.createProxy( 'Sources', 'TrivialProducer');
myProxyConfig

const myProxyConfig = {
definitions: {
Proxy: {
LookupTable: createProxyDefinition(vtkLookupTableProxy, [], [], {
presetName: ‘Default (Cool to Warm)’,
}),
// Controls the appearance of the volume.
PiecewiseFunction: createProxyDefinition(vtkPiecewiseFunctionProxy),
},
Sources: {
// For stand-alone data objects
TrivialProducer: activateOnCreate(createProxyDefinition(vtkProxySource)),
Contour: proxyFilter.Contour,
},
Representations: {
Slice: createProxyDefinition(
vtkSliceRepresentationProxy,
proxyUI.Slice,
proxyLinks.Slice,
),
SliceX: createProxyDefinition(
vtkSliceRepresentationProxy,
proxyUI.Slice,
[{ link: ‘SliceX’, property: ‘slice’, updateOnBind: true }].concat(
proxyLinks.Slice,
),
),
SliceY: createProxyDefinition(
vtkSliceRepresentationProxy,
proxyUI.Slice,
[{ link: ‘SliceY’, property: ‘slice’, updateOnBind: true }].concat(
proxyLinks.Slice,
),
),
SliceZ: createProxyDefinition(
vtkSliceRepresentationProxy,
proxyUI.Slice,
[{ link: ‘SliceZ’, property: ‘slice’, updateOnBind: true }].concat(
proxyLinks.Slice,
),
),
Volume: createProxyDefinition(
vtkVolumeRepresentationProxy,
proxyUI.Volume,
proxyLinks.Volume,
),
},
Views: {
View3D: createDefaultView(vtkView, proxyUI.View3D),
View2D: createDefaultView(vtk2DView, proxyUI.View2D),
View2D_X: createDefaultView(vtk2DView, proxyUI.View2D, { axis: 0 }),
View2D_Y: createDefaultView(vtk2DView, proxyUI.View2D, { axis: 1 }),
View2D_Z: createDefaultView(vtk2DView, proxyUI.View2D, { axis: 2 }),
ScreenshotView2D_x: createDefaultView(vtk2DView, proxyUI.View2D, { axis: 0 }),
ScreenshotView2D_y: createDefaultView(vtk2DView, proxyUI.View2D, { axis: 1 }),
ScreenshotView2D_z: createDefaultView(vtk2DView, proxyUI.View2D, { axis: 2 }),
},
},
representations: {
View3D: proxyViewRepresentationMapping.View3D,
View2D: proxyViewRepresentationMapping.View2D,
View2D_X: {
…proxyViewRepresentationMapping.View2D,
vtkImageData: { name: ‘SliceX’ },
},
View2D_Y: {
…proxyViewRepresentationMapping.View2D,
vtkImageData: { name: ‘SliceY’ },
},
View2D_Z: {
…proxyViewRepresentationMapping.View2D,
vtkImageData: { name: ‘SliceZ’ },
},
ScreenshotView2D_x: {
…proxyViewRepresentationMapping.View2D,
vtkImageData: { name: ‘SliceX’ },
},
ScreenshotView2D_y: {
…proxyViewRepresentationMapping.View2D,
vtkImageData: { name: ‘SliceY’ },
},
ScreenshotView2D_z: {
…proxyViewRepresentationMapping.View2D,
vtkImageData: { name: ‘SliceZ’ },
},
},
filters: {
vtkImageData: [‘Contour’],
},
};

1 Like