Dear vtk-team,
I’ve created a simple widget with a state and two representations:
- a basic representation displaying a ball at the position of the mouse
- a complex representation generating a large polyData
The representations are automatically recomputed whenever requestData
is called by VTK. The problem I’m facing is that both representations are recomputed as soon as something in the WidgetState
has changed. I’d however like to have the first representation update regularly (e.g. every time the mouse moves), while the second one should only be recomputed once in a while. Is there a way to influence when requestData()
is being called on each representation?
I’ve tried to accomplish this by creating two sub-states (one containing the mouse position - being updated regularly - and one containing the data to construct the large polyData). I gave the two sub-states a different name and different labels array. I then used these separate labels in the viewToRepresentationMapping
, which should make each representation only access it’s own substate.
I however noticed that both representations are still updated on every change to one of the substates. Moreover, the input passed along with requestData
is always an array of length 1, containing the complete widgetState (instead of the expected substate).
Is this normal, or am I doing something wrong? Thanks a lot in advance.
This is how I’m trying to assign separate states to representations:
const viewToRepresentations = (viewType) => {
return [
{
builder: lightweightRepresentation,
labels: ['lightweight']
},
{
builder: heavyRepresentation,
labels: ['heavy']
}
]
}
And this is where I define these substates
const generateState = () => {
return vtkStateBuilder
.createBuilder()
.addField({
name: 'customObject',
initialValue: undefined
})
.addStateFromMixin({
labels: ['lightweight'],
mixins: ['origin', 'direction', 'manipulator', 'visible'],
name: 'lightweight',
initialValues: {
origin: [0, 0, 0],
direction: [0, 0, 1],
visible: true
}
})
.addStateFromMixin({
labels: ['heavy'],
mixins: ['origin', 'direction', 'manipulator', 'visible'],
name: 'heavy',
initialValues: {
origin: [0, 0, 0],
direction: [0, 0, 1],
visible: true
}
})
}