Skip to content
Snippets Groups Projects
Commit e40fa2e7 authored by David Sehnal's avatar David Sehnal
Browse files

mol-plugin: UI fix, volume behavior

parent ed5f5819
No related branches found
No related tags found
No related merge requests found
...@@ -16,6 +16,7 @@ import { Color } from 'mol-util/color'; ...@@ -16,6 +16,7 @@ import { Color } from 'mol-util/color';
import { LRUCache } from 'mol-util/lru-cache'; import { LRUCache } from 'mol-util/lru-cache';
import { ParamDefinition as PD } from 'mol-util/param-definition'; import { ParamDefinition as PD } from 'mol-util/param-definition';
import { PluginBehavior } from '../behavior'; import { PluginBehavior } from '../behavior';
import { Structure } from 'mol-model/structure';
export namespace VolumeStreaming { export namespace VolumeStreaming {
function channelParam(label: string, color: Color, defaultValue: number) { function channelParam(label: string, color: Color, defaultValue: number) {
...@@ -112,8 +113,6 @@ export namespace VolumeStreaming { ...@@ -112,8 +113,6 @@ export namespace VolumeStreaming {
register(ref: string): void { register(ref: string): void {
// TODO: register camera movement/loci so that "around selection box works" // 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 // 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> { async update(params: Params): Promise<boolean> {
...@@ -127,7 +126,7 @@ export namespace VolumeStreaming { ...@@ -127,7 +126,7 @@ export namespace VolumeStreaming {
break; break;
case 'cell': case 'cell':
box = this.params.levels.name === 'x-ray' 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; : void 0;
break; break;
} }
...@@ -142,7 +141,7 @@ export namespace VolumeStreaming { ...@@ -142,7 +141,7 @@ export namespace VolumeStreaming {
// TODO unsubscribe to events // TODO unsubscribe to events
} }
constructor(public ctx: PluginContext, public params: Params) { constructor(public ctx: PluginContext, public params: Params, private structure: Structure) {
} }
} }
......
...@@ -295,7 +295,7 @@ const DownloadDensity = StateAction.build({ ...@@ -295,7 +295,7 @@ const DownloadDensity = StateAction.build({
export const InitVolumeStreaming = StateAction.build({ export const InitVolumeStreaming = StateAction.build({
display: { name: 'Volume Streaming' }, display: { name: 'Volume Streaming' },
from: PluginStateObject.Molecule.Model, from: PluginStateObject.Molecule.Structure,
params: VolumeStreaming.Params params: VolumeStreaming.Params
})(({ ref, state, params }, ctx: PluginContext) => { })(({ ref, state, params }, ctx: PluginContext) => {
// TODO: specify simpler params // TODO: specify simpler params
...@@ -306,9 +306,9 @@ export const InitVolumeStreaming = StateAction.build({ ...@@ -306,9 +306,9 @@ export const InitVolumeStreaming = StateAction.build({
const root = state.build().to(ref) const root = state.build().to(ref)
.apply(StateTransforms.Volume.VolumeStreamingBehavior, params); .apply(StateTransforms.Volume.VolumeStreamingBehavior, params);
root.apply(StateTransforms.Volume.VolumeStreamingVisual, { channel: '2FO-FC', level: '2fo-fc' }); 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)' }); 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)' }); root.apply(StateTransforms.Volume.VolumeStreamingVisual, { channel: 'FO-FC', level: 'fo-fc(-ve)' }, { props: { isGhost: true } });
return state.updateTree(root); return state.updateTree(root);
}); });
\ No newline at end of file
...@@ -104,14 +104,14 @@ type VolumeStreamingBehavior = typeof VolumeStreamingBehavior ...@@ -104,14 +104,14 @@ type VolumeStreamingBehavior = typeof VolumeStreamingBehavior
const VolumeStreamingBehavior = PluginStateTransform.BuiltIn({ const VolumeStreamingBehavior = PluginStateTransform.BuiltIn({
name: 'volume-streaming-behavior', name: 'volume-streaming-behavior',
display: { name: 'Volume Streaming Behavior', description: 'Create Volume Streaming behavior.' }, display: { name: 'Volume Streaming Behavior', description: 'Create Volume Streaming behavior.' },
from: SO.Molecule.Model, from: SO.Molecule.Structure,
to: VolumeStreaming.Obj, to: VolumeStreaming.Obj,
params: VolumeStreaming.Params params: VolumeStreaming.Params
})({ })({
apply: ({ params }, plugin: PluginContext) => Task.create('Volume Streaming', async ctx => { canAutoUpdate: ({ oldParams, newParams }) => oldParams.serverUrl === newParams.serverUrl && oldParams.id === newParams.id,
const behavior = new VolumeStreaming.Behavior(plugin, params); 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. // 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); await behavior.update(behavior.params);
return new VolumeStreaming.Obj(behavior, { label: 'Volume Streaming' }); return new VolumeStreaming.Obj(behavior, { label: 'Volume Streaming' });
}), }),
......
...@@ -53,6 +53,7 @@ class UpdateTransformContol extends TransformContolBase<UpdateTransformContol.Pr ...@@ -53,6 +53,7 @@ class UpdateTransformContol extends TransformContolBase<UpdateTransformContol.Pr
this.subscribe(this.plugin.events.state.object.updated, ({ ref, state }) => { this.subscribe(this.plugin.events.state.object.updated, ({ ref, state }) => {
if (this.props.transform.ref !== ref || this.props.state !== state) return; if (this.props.transform.ref !== ref || this.props.state !== state) return;
if (this.state.params !== this.props.transform.params) { 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 }) this.setState({ params: this.props.transform.params, isInitial: true })
} }
}); });
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment