diff --git a/src/mol-plugin/behavior/dynamic/volume.ts b/src/mol-plugin/behavior/dynamic/volume.ts index 856f239f42ed3b2b2a5d31a0a065bf4ec23f1e4e..b826f37c0a8f7a90bd00785bd5414d6066d561f2 100644 --- a/src/mol-plugin/behavior/dynamic/volume.ts +++ b/src/mol-plugin/behavior/dynamic/volume.ts @@ -16,6 +16,7 @@ import { Color } from 'mol-util/color'; import { LRUCache } from 'mol-util/lru-cache'; import { ParamDefinition as PD } from 'mol-util/param-definition'; import { PluginBehavior } from '../behavior'; +import { Structure } from 'mol-model/structure'; export namespace VolumeStreaming { function channelParam(label: string, color: Color, defaultValue: number) { @@ -112,8 +113,6 @@ export namespace VolumeStreaming { register(ref: string): void { // TODO: register camera movement/loci so that "around selection box works" // alternatively, and maybe a better solution, write a global behavior that modifies this node from the outside - // this.ref = ref; - this.update(this.params); } async update(params: Params): Promise<boolean> { @@ -127,7 +126,7 @@ export namespace VolumeStreaming { break; case 'cell': box = this.params.levels.name === 'x-ray' - ? void 0 // TODO get bounding box of the model (how to solve assemblies) + ? this.structure.boundary.box : void 0; break; } @@ -142,7 +141,7 @@ export namespace VolumeStreaming { // TODO unsubscribe to events } - constructor(public ctx: PluginContext, public params: Params) { + constructor(public ctx: PluginContext, public params: Params, private structure: Structure) { } } diff --git a/src/mol-plugin/state/actions/volume.ts b/src/mol-plugin/state/actions/volume.ts index e5ff3a167df4e03733f9ee10c77ba204951765a3..c8bbc9c892081968e785ebec860dd76516eae3f1 100644 --- a/src/mol-plugin/state/actions/volume.ts +++ b/src/mol-plugin/state/actions/volume.ts @@ -295,7 +295,7 @@ const DownloadDensity = StateAction.build({ export const InitVolumeStreaming = StateAction.build({ display: { name: 'Volume Streaming' }, - from: PluginStateObject.Molecule.Model, + from: PluginStateObject.Molecule.Structure, params: VolumeStreaming.Params })(({ ref, state, params }, ctx: PluginContext) => { // TODO: specify simpler params @@ -306,9 +306,9 @@ export const InitVolumeStreaming = StateAction.build({ const root = state.build().to(ref) .apply(StateTransforms.Volume.VolumeStreamingBehavior, params); - root.apply(StateTransforms.Volume.VolumeStreamingVisual, { channel: '2FO-FC', level: '2fo-fc' }); - root.apply(StateTransforms.Volume.VolumeStreamingVisual, { channel: 'FO-FC', level: 'fo-fc(+ve)' }); - root.apply(StateTransforms.Volume.VolumeStreamingVisual, { channel: 'FO-FC', level: 'fo-fc(-ve)' }); + root.apply(StateTransforms.Volume.VolumeStreamingVisual, { channel: '2FO-FC', level: '2fo-fc' }, { props: { isGhost: true } }); + root.apply(StateTransforms.Volume.VolumeStreamingVisual, { channel: 'FO-FC', level: 'fo-fc(+ve)' }, { props: { isGhost: true } }); + root.apply(StateTransforms.Volume.VolumeStreamingVisual, { channel: 'FO-FC', level: 'fo-fc(-ve)' }, { props: { isGhost: true } }); return state.updateTree(root); }); \ No newline at end of file diff --git a/src/mol-plugin/state/transforms/volume.ts b/src/mol-plugin/state/transforms/volume.ts index a0516c70ef19d9851d08c479df99ba1607bdbe1c..6c682e4a13cc9df01cea36e51391ae1e832e8259 100644 --- a/src/mol-plugin/state/transforms/volume.ts +++ b/src/mol-plugin/state/transforms/volume.ts @@ -104,14 +104,14 @@ type VolumeStreamingBehavior = typeof VolumeStreamingBehavior const VolumeStreamingBehavior = PluginStateTransform.BuiltIn({ name: 'volume-streaming-behavior', display: { name: 'Volume Streaming Behavior', description: 'Create Volume Streaming behavior.' }, - from: SO.Molecule.Model, + from: SO.Molecule.Structure, to: VolumeStreaming.Obj, params: VolumeStreaming.Params })({ - apply: ({ params }, plugin: PluginContext) => Task.create('Volume Streaming', async ctx => { - const behavior = new VolumeStreaming.Behavior(plugin, params); + canAutoUpdate: ({ oldParams, newParams }) => oldParams.serverUrl === newParams.serverUrl && oldParams.id === newParams.id, + apply: ({ a, params }, plugin: PluginContext) => Task.create('Volume Streaming', async ctx => { + const behavior = new VolumeStreaming.Behavior(plugin, params, a.data); // get the initial data now so that the child projections dont get empty volumes. - // TODO: this is a temporary fix await behavior.update(behavior.params); return new VolumeStreaming.Obj(behavior, { label: 'Volume Streaming' }); }), diff --git a/src/mol-plugin/ui/state/update-transform.tsx b/src/mol-plugin/ui/state/update-transform.tsx index 3cfa511fefc218e746d85874e62fbbcb8fa09cde..e6c0bc198bfdb2d7abf330d1aaab0b07a223a13d 100644 --- a/src/mol-plugin/ui/state/update-transform.tsx +++ b/src/mol-plugin/ui/state/update-transform.tsx @@ -53,6 +53,7 @@ class UpdateTransformContol extends TransformContolBase<UpdateTransformContol.Pr this.subscribe(this.plugin.events.state.object.updated, ({ ref, state }) => { if (this.props.transform.ref !== ref || this.props.state !== state) return; if (this.state.params !== this.props.transform.params) { + this._getInfo = memoizeLatest((t: StateTransform) => StateTransformParameters.infoFromTransform(this.plugin, this.props.state, t)); this.setState({ params: this.props.transform.params, isInitial: true }) } });