Browse Source

mol-plugin: code cleanup

David Sehnal 5 years ago
parent
commit
f4ed5e301d
39 changed files with 209 additions and 210 deletions
  1. 7 7
      src/apps/basic-wrapper/index.ts
  2. 2 2
      src/apps/basic-wrapper/superposition.ts
  3. 2 2
      src/apps/demos/lighting/index.ts
  4. 1 1
      src/apps/viewer/index.ts
  5. 4 4
      src/examples/proteopedia-wrapper/index.ts
  6. 1 1
      src/mol-plugin-state/actions/structure.ts
  7. 13 13
      src/mol-plugin-state/animation/built-in.ts
  8. 5 5
      src/mol-plugin-state/builder/data.ts
  9. 9 9
      src/mol-plugin-state/builder/structure.ts
  10. 1 1
      src/mol-plugin-state/builder/structure/preset.ts
  11. 3 3
      src/mol-plugin-state/builder/structure/representation.ts
  12. 4 4
      src/mol-plugin-state/formats/trajectory.ts
  13. 2 2
      src/mol-plugin-state/helpers/structure-overpaint.ts
  14. 6 6
      src/mol-plugin-state/manager/structure/component.ts
  15. 6 6
      src/mol-plugin-state/manager/structure/hierarchy.ts
  16. 11 11
      src/mol-plugin-state/manager/structure/measurement.ts
  17. 3 3
      src/mol-plugin-state/manager/structure/selection.ts
  18. 7 7
      src/mol-plugin-ui/controls.tsx
  19. 7 7
      src/mol-plugin-ui/left-panel.tsx
  20. 4 4
      src/mol-plugin-ui/sequence.tsx
  21. 2 9
      src/mol-plugin-ui/state/tree.tsx
  22. 3 3
      src/mol-plugin-ui/state/update-transform.tsx
  23. 5 5
      src/mol-plugin-ui/structure/components.tsx
  24. 1 1
      src/mol-plugin-ui/viewport/help.tsx
  25. 1 1
      src/mol-plugin-ui/viewport/screenshot.tsx
  26. 1 1
      src/mol-plugin-ui/viewport/simple-settings.tsx
  27. 1 1
      src/mol-plugin/behavior/dynamic/custom-props/computed/interactions.ts
  28. 1 1
      src/mol-plugin/behavior/dynamic/custom-props/computed/valence-model.ts
  29. 2 2
      src/mol-plugin/behavior/dynamic/custom-props/rcsb/assembly-symmetry.ts
  30. 4 4
      src/mol-plugin/behavior/dynamic/representation.ts
  31. 3 3
      src/mol-plugin/behavior/dynamic/selection/structure-representation-interaction.ts
  32. 2 2
      src/mol-plugin/behavior/dynamic/volume-streaming/behavior.ts
  33. 3 3
      src/mol-plugin/behavior/static/representation.ts
  34. 4 4
      src/mol-plugin/behavior/static/state.ts
  35. 6 4
      src/mol-plugin/commands.ts
  36. 41 47
      src/mol-plugin/context.ts
  37. 26 16
      src/mol-plugin/state.ts
  38. 4 4
      src/mol-plugin/util/substructure-parent-helper.ts
  39. 1 1
      src/mol-plugin/util/viewport-screenshot.ts

+ 7 - 7
src/apps/basic-wrapper/index.ts

@@ -93,7 +93,7 @@ class BasicWrapper {
     async load({ url, format = 'cif', assemblyId = '' }: LoadParams) {
         let loadType: 'full' | 'update' = 'full';
 
-        const state = this.plugin.state.dataState;
+        const state = this.plugin.state.data;
 
         if (this.loadedParams.url !== url || this.loadedParams.format !== format) {
             loadType = 'full';
@@ -118,7 +118,7 @@ class BasicWrapper {
             tree.to('asm').update(StateTransforms.Model.StructureFromModel, p => ({ ...p, ...props }));
         }
 
-        await PluginCommands.State.Update(this.plugin, { state: this.plugin.state.dataState, tree });
+        await PluginCommands.State.Update(this.plugin, { state: this.plugin.state.data, tree });
         this.loadedParams = { url, format, assemblyId };
         PluginCommands.Camera.Reset(this.plugin, { });
     }
@@ -150,7 +150,7 @@ class BasicWrapper {
 
     coloring = {
         applyStripes: async () => {
-            const state = this.plugin.state.dataState;
+            const state = this.plugin.state.data;
 
             const visuals = state.selectQ(q => q.ofTransformer(StateTransforms.Representation.StructureRepresentation3D));
             const tree = state.build();
@@ -167,7 +167,7 @@ class BasicWrapper {
     interactivity = {
         highlightOn: () => {
             const seq_id = 7;
-            const data = (this.plugin.state.dataState.select('asm')[0].obj as PluginStateObject.Molecule.Structure).data;
+            const data = (this.plugin.state.data.select('asm')[0].obj as PluginStateObject.Molecule.Structure).data;
             const sel = Script.getStructureSelection(Q => Q.struct.generator.atomGroups({
                 'residue-test': Q.core.rel.eq([Q.struct.atomProperty.macromolecular.label_seq_id(), seq_id]),
                 'group-by': Q.struct.atomProperty.macromolecular.residueKey()
@@ -182,17 +182,17 @@ class BasicWrapper {
 
     tests = {
         staticSuperposition: async () => {
-            const state = this.plugin.state.dataState;
+            const state = this.plugin.state.data;
             const tree = buildStaticSuperposition(this.plugin, StaticSuperpositionTestData);
             await PluginCommands.State.RemoveObject(this.plugin, { state, ref: StateTransform.RootRef });
             await PluginCommands.State.Update(this.plugin, { state, tree });
         },
         dynamicSuperposition: async () => {
-            await PluginCommands.State.RemoveObject(this.plugin, { state: this.plugin.state.dataState, ref: StateTransform.RootRef });
+            await PluginCommands.State.RemoveObject(this.plugin, { state: this.plugin.state.data, ref: StateTransform.RootRef });
             await dynamicSuperpositionTest(this.plugin, ['1tqn', '2hhb', '4hhb'], 'HEM');
         },
         toggleValidationTooltip: async () => {
-            const state = this.plugin.state.behaviorState;
+            const state = this.plugin.state.behaviors;
             const tree = state.build().to(PDBeStructureQualityReport.id).update(PDBeStructureQualityReport, p => ({ ...p, showTooltip: !p.showTooltip }));
             await PluginCommands.State.Update(this.plugin, { state, tree });
         },

+ 2 - 2
src/apps/basic-wrapper/superposition.ts

@@ -32,7 +32,7 @@ export type SuperpositionTestInput = {
 // }
 
 export function buildStaticSuperposition(ctx: PluginContext, src: SuperpositionTestInput) {
-    const b = ctx.state.dataState.build().toRoot();
+    const b = ctx.state.data.build().toRoot();
     for (const s of src) {
         StateHelper.visual(ctx,
             StateHelper.transform(
@@ -63,7 +63,7 @@ export const StaticSuperpositionTestData: SuperpositionTestInput = [
 ];
 
 export async function dynamicSuperpositionTest(ctx: PluginContext, src: string[], comp_id: string) {
-    const state = ctx.state.dataState;
+    const state = ctx.state.data;
 
     const structures = state.build().toRoot();
     for (const s of src) {

+ 2 - 2
src/apps/demos/lighting/index.ts

@@ -145,7 +145,7 @@ class LightingDemo {
     async load({ url, format = 'cif', assemblyId = '' }: LoadParams) {
         let loadType: 'full' | 'update' = 'full';
 
-        const state = this.plugin.state.dataState;
+        const state = this.plugin.state.data;
 
         if (this.loadedParams.url !== url || this.loadedParams.format !== format) {
             loadType = 'full';
@@ -169,7 +169,7 @@ class LightingDemo {
             tree.to('asm').update(StateTransforms.Model.StructureFromModel, p => ({ ...p, ...props }));
         }
 
-        await PluginCommands.State.Update(this.plugin, { state: this.plugin.state.dataState, tree });
+        await PluginCommands.State.Update(this.plugin, { state: this.plugin.state.data, tree });
         this.loadedParams = { url, format, assemblyId };
         PluginCommands.Camera.Reset(this.plugin, { });
     }

+ 1 - 1
src/apps/viewer/index.ts

@@ -80,7 +80,7 @@ async function tryLoadFromUrl(ctx: PluginContext) {
 
         const params = DownloadStructure.createDefaultParams(void 0 as any, ctx);
 
-        return ctx.runTask(ctx.state.dataState.applyAction(DownloadStructure, {
+        return ctx.runTask(ctx.state.data.applyAction(DownloadStructure, {
             source: {
                 name: 'url',
                 params: {

+ 4 - 4
src/examples/proteopedia-wrapper/index.ts

@@ -74,7 +74,7 @@ class MolStarProteopediaWrapper {
     }
 
     get state() {
-        return this.plugin.state.dataState;
+        return this.plugin.state.data;
     }
 
     private download(b: StateBuilder.To<PSO.Root>, url: string) {
@@ -196,14 +196,14 @@ class MolStarProteopediaWrapper {
     }
 
     private applyState(tree: StateBuilder) {
-        return PluginCommands.State.Update(this.plugin, { state: this.plugin.state.dataState, tree });
+        return PluginCommands.State.Update(this.plugin, { state: this.plugin.state.data, tree });
     }
 
     private loadedParams: LoadParams = { url: '', format: 'cif', assemblyId: '' };
     async load({ url, format = 'cif', assemblyId = 'deposited', representationStyle }: LoadParams) {
         let loadType: 'full' | 'update' = 'full';
 
-        const state = this.plugin.state.dataState;
+        const state = this.plugin.state.data;
 
         if (this.loadedParams.url !== url || this.loadedParams.format !== format) {
             loadType = 'full';
@@ -242,7 +242,7 @@ class MolStarProteopediaWrapper {
     async updateStyle(style?: RepresentationStyle, partial?: boolean) {
         const tree = this.visual(style, partial);
         if (!tree) return;
-        await PluginCommands.State.Update(this.plugin, { state: this.plugin.state.dataState, tree });
+        await PluginCommands.State.Update(this.plugin, { state: this.plugin.state.data, tree });
     }
 
     setBackground(color: number) {

+ 1 - 1
src/mol-plugin-state/actions/structure.ts

@@ -376,7 +376,7 @@ export const AddTrajectory = StateAction.build({
     display: { name: 'Add Trajectory', description: 'Add trajectory from existing model/topology and coordinates.' },
     from: PluginStateObject.Root,
     params(a, ctx: PluginContext) {
-        const state = ctx.state.dataState
+        const state = ctx.state.data
         const models = [
             ...state.selectQ(q => q.rootsOfType(PluginStateObject.Molecule.Model)),
             ...state.selectQ(q => q.rootsOfType(PluginStateObject.Molecule.Topology)),

+ 13 - 13
src/mol-plugin-state/animation/built-in.ts

@@ -30,7 +30,7 @@ export const AnimateModelIndex = PluginStateAnimation.create({
             return { kind: 'skip' };
         }
 
-        const state = ctx.plugin.state.dataState;
+        const state = ctx.plugin.state.data;
         const models = state.select(StateSelection.Generators.ofTransformer(StateTransforms.Model.ModelFromTrajectory));
 
         if (models.length === 0) {
@@ -92,7 +92,7 @@ export const AnimateAssemblyUnwind = PluginStateAnimation.create({
     display: { name: 'Unwind Assembly' },
     params: (plugin: PluginContext) => {
         const targets: [string, string][] = [['all', 'All']];
-        const structures = plugin.state.dataState.select(StateSelection.Generators.rootsOfType(PluginStateObject.Molecule.Structure));
+        const structures = plugin.state.data.select(StateSelection.Generators.rootsOfType(PluginStateObject.Molecule.Structure));
 
         for (const s of structures) {
             targets.push([s.transform.ref, s.obj!.data.models[0].label]);
@@ -106,7 +106,7 @@ export const AnimateAssemblyUnwind = PluginStateAnimation.create({
     },
     initialState: () => ({ t: 0 }),
     async setup(params, plugin) {
-        const state = plugin.state.dataState;
+        const state = plugin.state.data;
         const root = !params.target || params.target === 'all' ? StateTransform.RootRef : params.target;
         const reprs = state.select(StateSelection.Generators.ofType(PluginStateObject.Molecule.Structure.Representation3D, root));
 
@@ -123,20 +123,20 @@ export const AnimateAssemblyUnwind = PluginStateAnimation.create({
 
         if (!changed) return;
 
-        return plugin.runTask(state.updateTree(update, { doNotUpdateCurrent: true }));
+        return plugin.updateState(update, { doNotUpdateCurrent: true });
     },
     async teardown(_, plugin) {
-        const state = plugin.state.dataState;
+        const state = plugin.state.data;
         const reprs = state.select(StateSelection.Generators.ofType(PluginStateObject.Molecule.Structure.Representation3DState)
             .withTag('animate-assembly-unwind'));
         if (reprs.length === 0) return;
 
         const update = state.build();
         for (const r of reprs) update.delete(r.transform.ref);
-        return plugin.runTask(state.updateTree(update));
+        return plugin.updateState(update);
     },
     async apply(animState, t, ctx) {
-        const state = ctx.plugin.state.dataState;
+        const state = ctx.plugin.state.data;
         const root = !ctx.params.target || ctx.params.target === 'all' ? StateTransform.RootRef : ctx.params.target;
         const anims = state.select(StateSelection.Generators.ofTransformer(StateTransforms.Representation.UnwindStructureAssemblyRepresentation3D, root));
 
@@ -174,7 +174,7 @@ export const AnimateUnitsExplode = PluginStateAnimation.create({
     }),
     initialState: () => ({ t: 0 }),
     async setup(_, plugin) {
-        const state = plugin.state.dataState;
+        const state = plugin.state.data;
         const reprs = state.select(StateSelection.Generators.ofType(PluginStateObject.Molecule.Structure.Representation3D));
 
         const update = state.build();
@@ -190,20 +190,20 @@ export const AnimateUnitsExplode = PluginStateAnimation.create({
 
         if (!changed) return;
 
-        return plugin.runTask(state.updateTree(update, { doNotUpdateCurrent: true }));
+        return plugin.updateState(update, { doNotUpdateCurrent: true });
     },
     async teardown(_, plugin) {
-        const state = plugin.state.dataState;
+        const state = plugin.state.data;
         const reprs = state.select(StateSelection.Generators.ofType(PluginStateObject.Molecule.Structure.Representation3DState)
             .withTag('animate-units-explode'));
         if (reprs.length === 0) return;
 
         const update = state.build();
         for (const r of reprs) update.delete(r.transform.ref);
-        return plugin.runTask(state.updateTree(update));
+        return plugin.updateState(update);
     },
     async apply(animState, t, ctx) {
-        const state = ctx.plugin.state.dataState;
+        const state = ctx.plugin.state.data;
         const anims = state.select(StateSelection.Generators.ofTransformer(StateTransforms.Representation.ExplodeStructureRepresentation3D));
 
         if (anims.length === 0) {
@@ -251,7 +251,7 @@ export const AnimateStateInterpolation = PluginStateAnimation.create({
 
         const src = _src.data.tree.transforms, tar = _tar.data.tree.transforms;
 
-        const state = ctx.plugin.state.dataState;
+        const state = ctx.plugin.state.data;
         const update = state.build();
 
         for (const s of src) {

+ 5 - 5
src/mol-plugin-state/builder/data.ts

@@ -11,31 +11,31 @@ import { getFileInfo } from '../../mol-util/file-info';
 
 export class DataBuilder {
     private get dataState() {
-        return this.plugin.state.dataState;
+        return this.plugin.state.data;
     }
 
     async rawData(params: StateTransformer.Params<RawData>, options?: Partial<StateTransform.Options>) {
         const data = this.dataState.build().toRoot().apply(RawData, params, options);
-        await this.plugin.runTask(this.dataState.updateTree(data, { revertOnError: true }));
+        await this.plugin.updateState(data, { revertOnError: true });
         return data.selector;
     }
 
     async download(params: StateTransformer.Params<Download>, options?: Partial<StateTransform.Options>) {
         const data = this.dataState.build().toRoot().apply(Download, params, options);
-        await this.plugin.runTask(this.dataState.updateTree(data, { revertOnError: true }));
+        await this.plugin.updateState(data, { revertOnError: true });
         return data.selector;
     }
 
     async downloadBlob(params: StateTransformer.Params<DownloadBlob>, options?: Partial<StateTransform.Options>) {        
         const data = this.dataState.build().toRoot().apply(DownloadBlob, params, options);
-        await this.plugin.runTask(this.dataState.updateTree(data, { revertOnError: true }));
+        await this.plugin.updateState(data, { revertOnError: true });
         return data.selector;
     }
 
     async readFile(params: StateTransformer.Params<ReadFile>, options?: Partial<StateTransform.Options>) {
         const data = this.dataState.build().toRoot().apply(ReadFile, params, options);
         const fileInfo = getFileInfo(params.file);
-        await this.plugin.runTask(this.dataState.updateTree(data, { revertOnError: true }));
+        await this.plugin.updateState(data, { revertOnError: true });
         return { data: data.selector, fileInfo };
     }
 

+ 9 - 9
src/mol-plugin-state/builder/structure.ts

@@ -29,7 +29,7 @@ export enum StructureBuilderTags {
 
 export class StructureBuilder {
     private get dataState() {
-        return this.plugin.state.dataState;
+        return this.plugin.state.data;
     }
 
     private async parseTrajectoryData(data: StateObjectRef<SO.Data.Binary | SO.Data.String>, format: BuiltInTrajectoryFormat | TrajectoryFormatProvider) {
@@ -44,7 +44,7 @@ export class StructureBuilder {
         const trajectory = state.build().to(data)
             .apply(StateTransforms.Data.ParseBlob, params, { state: { isGhost: true } })
             .apply(StateTransforms.Model.TrajectoryFromBlob, void 0, { tags: StructureBuilderTags.Trajectory });        
-        await this.plugin.runTask(this.dataState.updateTree(trajectory, { revertOnError: true }));
+        await this.plugin.updateState(trajectory, { revertOnError: true });
         return trajectory.selector;
     }
 
@@ -101,7 +101,7 @@ export class StructureBuilder {
         const model = state.build().to(trajectory)
             .apply(StateTransforms.Model.ModelFromTrajectory, params || { modelIndex: 0 }, { tags: StructureBuilderTags.Model, state: initialState });
 
-        await this.plugin.runTask(this.dataState.updateTree(model, { revertOnError: true }));
+        await this.plugin.updateState(model, { revertOnError: true });
         return model.selector;
     }
 
@@ -109,7 +109,7 @@ export class StructureBuilder {
         const state = this.dataState;
         const props = state.build().to(model)
             .insert(StateTransforms.Model.CustomModelProperties, params, { tags: StructureBuilderTags.ModelProperties, isDecorator: true });
-        await this.plugin.runTask(this.dataState.updateTree(props, { revertOnError: true }));
+        await this.plugin.updateState(props, { revertOnError: true });
         return props.selector;
     }
 
@@ -118,7 +118,7 @@ export class StructureBuilder {
         const structure = state.build().to(model)
             .apply(StateTransforms.Model.StructureFromModel, { type: params || { name: 'assembly', params: { } } }, { tags: StructureBuilderTags.Structure, state: initialState });        
 
-        await this.plugin.runTask(this.dataState.updateTree(structure, { revertOnError: true }));
+        await this.plugin.updateState(structure, { revertOnError: true });
         return structure.selector;
     }
 
@@ -126,7 +126,7 @@ export class StructureBuilder {
         const state = this.dataState;
         const props = state.build().to(structure)
             .insert(StateTransforms.Model.CustomStructureProperties, params, { tags: StructureBuilderTags.StructureProperties, isDecorator: true });
-        await this.plugin.runTask(this.dataState.updateTree(props, { revertOnError: true }));
+        await this.plugin.updateState(props, { revertOnError: true });
         return props.selector;
     }
 
@@ -145,13 +145,13 @@ export class StructureBuilder {
             tags: tags ? [...tags, StructureBuilderTags.Component, keyTag] : [StructureBuilderTags.Component, keyTag]
         });
 
-        await this.plugin.runTask(this.dataState.updateTree(component));
+        await this.plugin.updateState(component);
 
         const selector = component.selector;
 
         if (!selector.isOk || selector.cell?.obj?.data.elementCount === 0) {
             const del = state.build().delete(selector.ref);
-            await this.plugin.runTask(this.dataState.updateTree(del));
+            await this.plugin.updateState(del);
             return;
         }
 
@@ -205,7 +205,7 @@ export class StructureBuilder {
     
             if (!selector.isOk || selector.cell?.obj?.data.elementCount === 0) {
                 const del = state.build().delete(selector.ref);
-                await this.plugin.runTask(this.dataState.updateTree(del));
+                await this.plugin.updateState(del);
                 return;
             }
     

+ 1 - 1
src/mol-plugin-state/builder/structure/preset.ts

@@ -46,7 +46,7 @@ const auto = StructureRepresentationProvider({
 });
 
 function reprBuilder(plugin: PluginContext, params: CommonStructureRepresentationParams) {
-    const update = plugin.state.dataState.build();
+    const update = plugin.state.data.build();
     const builder = plugin.builders.structure.representation;
     const typeParams = {
         quality: plugin.managers.structure.component.state.options.visualQuality,

+ 3 - 3
src/mol-plugin-state/builder/structure/representation.ts

@@ -23,7 +23,7 @@ export type StructureRepresentationProviderRef = keyof PresetStructureReprentati
 export class StructureRepresentationBuilder {
     private _providers: StructureRepresentationProvider[] = [];
     private providerMap: Map<string, StructureRepresentationProvider> = new Map();
-    private get dataState() { return this.plugin.state.dataState; }
+    private get dataState() { return this.plugin.state.data; }
 
     readonly defaultProvider = PresetStructureReprentations.auto;
 
@@ -80,7 +80,7 @@ export class StructureRepresentationBuilder {
         const provider = this.resolveProvider(providerRef);
         if (!provider) return;
 
-        const state = this.plugin.state.dataState;
+        const state = this.plugin.state.data;
         const cell = StateObjectRef.resolveAndCheck(state, parent);
         if (!cell) {
             if (!isProductionMode) console.warn(`Applying structure repr. provider to bad cell.`);
@@ -107,7 +107,7 @@ export class StructureRepresentationBuilder {
             .to(structure)
             .apply(StructureRepresentation3D, params, { tags: RepresentationProviderTags.Representation });
 
-        await this.plugin.runTask(this.dataState.updateTree(repr));
+        await this.plugin.updateState(repr);
         return  repr.selector;
     }
 

+ 4 - 4
src/mol-plugin-state/formats/trajectory.ts

@@ -31,21 +31,21 @@ export const MmcifProvider: TrajectoryFormatProvider = {
         return false
     },
     parse: async (plugin, data, params) => {
-        const state = plugin.state.dataState;
+        const state = plugin.state.data;
         const trajectory = state.build().to(data)
             .apply(StateTransforms.Data.ParseCif, void 0, { state: { isGhost: true } })
             .apply(StateTransforms.Model.TrajectoryFromMmCif, void 0, { tags: params?.trajectoryTags })
-        await plugin.runTask(state.updateTree(trajectory, { revertOnError: true }));
+        await plugin.updateState(trajectory, { revertOnError: true });
         return { trajectory: trajectory.selector };
     }
 }
 
 function directTrajectory(transformer: StateTransformer<PluginStateObject.Data.String | PluginStateObject.Data.Binary, PluginStateObject.Molecule.Trajectory>): TrajectoryFormatProvider['parse'] {
     return async (plugin, data, params) => {
-        const state = plugin.state.dataState;
+        const state = plugin.state.data;
         const trajectory = state.build().to(data)
             .apply(transformer, void 0, { tags: params?.trajectoryTags })
-        await plugin.runTask(state.updateTree(trajectory, { revertOnError: true }));
+        await plugin.updateState(trajectory, { revertOnError: true });
         return { trajectory: trajectory.selector };
     }
 }

+ 2 - 2
src/mol-plugin-state/helpers/structure-overpaint.ts

@@ -56,7 +56,7 @@ export async function clearStructureOverpaint(plugin: PluginContext, components:
 }
 
 async function eachRepr(plugin: PluginContext, components: StructureComponentRef[], callback: OverpaintEachReprCallback) {
-    const state = plugin.state.dataState;    
+    const state = plugin.state.data;    
     const update = state.build();
     for (const c of components) {
         for (const r of c.representations) {
@@ -65,7 +65,7 @@ async function eachRepr(plugin: PluginContext, components: StructureComponentRef
         }
     }
 
-    await plugin.runTask(state.updateTree(update, { doNotUpdateCurrent: true }));
+    await plugin.updateState(update, { doNotUpdateCurrent: true });
 }
 
 /** filter overpaint layers for given structure */

+ 6 - 6
src/mol-plugin-state/manager/structure/component.ts

@@ -62,7 +62,7 @@ class StructureComponentManager extends PluginComponent<StructureComponentManage
         }
 
         return this.plugin.dataTransaction(async () => {
-            await this.plugin.runTask(this.dataState.updateTree(update));
+            await this.plugin.updateState(update);
             if (interactionChanged) await this.updateInterationProps();
         });
     }
@@ -96,7 +96,7 @@ class StructureComponentManager extends PluginComponent<StructureComponentManage
                     arraySetAdd(old.autoAttach, InteractionsProvider.descriptor.name);
                     old.properties[InteractionsProvider.descriptor.name] = this.state.options.interactions;
                 });
-                await this.plugin.runTask(this.dataState.updateTree(b));
+                await this.plugin.updateState(b);
             } else {
                 const pd = this.plugin.customStructureProperties.getParams(s.cell.obj?.data);
                 const params = PD.getDefaultValues(pd);
@@ -196,7 +196,7 @@ class StructureComponentManager extends PluginComponent<StructureComponentManage
             update.to(repr.cell).update(params);
         }
 
-        return this.plugin.runTask(this.dataState.updateTree(update, { canUndo: 'Update Representation' }));
+        return this.plugin.updateState(update, { canUndo: 'Update Representation' });
     }
 
     updateRepresentationsTheme<C extends ColorTheme.BuiltIn, S extends SizeTheme.BuiltIn>(components: ReadonlyArray<StructureComponentRef>, params: StructureComponentManager.UpdateThemeParams<C, S>): Promise<any> {
@@ -220,7 +220,7 @@ class StructureComponentManager extends PluginComponent<StructureComponentManage
             }
         }
 
-        return this.plugin.runTask(this.dataState.updateTree(update, { canUndo: 'Update Theme' }));
+        return this.plugin.updateState(update, { canUndo: 'Update Theme' });
     }
 
     addRepresentation(components: ReadonlyArray<StructureComponentRef>, type: string) {
@@ -304,7 +304,7 @@ class StructureComponentManager extends PluginComponent<StructureComponentManage
     }
 
     private get dataState() {
-        return this.plugin.state.dataState;
+        return this.plugin.state.data;
     }
 
     private clearComponents(structures: ReadonlyArray<StructureRef>) {
@@ -318,7 +318,7 @@ class StructureComponentManager extends PluginComponent<StructureComponentManage
                 if (s.currentFocus.surroundings) deletes.delete(s.currentFocus.surroundings.cell.transform.ref);
             }
         }
-        return this.plugin.runTask(this.dataState.updateTree(deletes, { canUndo: 'Clear Selections' }));
+        return this.plugin.updateState(deletes, { canUndo: 'Clear Selections' });
     }
 
     constructor(public plugin: PluginContext) {

+ 6 - 6
src/mol-plugin-state/manager/structure/hierarchy.ts

@@ -30,7 +30,7 @@ export class StructureHierarchyManager extends PluginComponent<StructureHierarch
     }
 
     private get dataState() {
-        return this.plugin.state.dataState;
+        return this.plugin.state.data;
     }
 
     private _currentComponentGroups: ReturnType<typeof StructureHierarchyManager['getComponentGroups']> | undefined = void 0;
@@ -81,7 +81,7 @@ export class StructureHierarchyManager extends PluginComponent<StructureHierarch
     }
 
     private sync() {
-        const update = buildStructureHierarchy(this.plugin.state.dataState, this.state.hierarchy);
+        const update = buildStructureHierarchy(this.plugin.state.data, this.state.hierarchy);
         if (update.added.length === 0 && update.updated.length === 0 && update.removed.length === 0) {
             return;
         }
@@ -129,9 +129,9 @@ export class StructureHierarchyManager extends PluginComponent<StructureHierarch
 
     remove(refs: HierarchyRef[], canUndo?: boolean) {
         if (refs.length === 0) return;
-        const deletes = this.plugin.state.dataState.build();
+        const deletes = this.plugin.state.data.build();
         for (const r of refs) deletes.delete(r.cell.transform.ref);
-        return this.plugin.runTask(this.plugin.state.dataState.updateTree(deletes, { canUndo: canUndo ? 'Remove' : false }));
+        return this.plugin.updateState(deletes, { canUndo: canUndo ? 'Remove' : false });
     }
 
     createAllModels(trajectory: TrajectoryRef) {
@@ -159,7 +159,7 @@ export class StructureHierarchyManager extends PluginComponent<StructureHierarch
         for (const m of trajectory.models) {
             builder.delete(m.cell);
         }
-        return this.plugin.runTask(this.dataState.updateTree(builder));
+        return this.plugin.updateState(builder);
     }
 
     constructor(private plugin: PluginContext) {
@@ -168,7 +168,7 @@ export class StructureHierarchyManager extends PluginComponent<StructureHierarch
             current: { trajectories: [], models: [], structures: [] }
         });
 
-        plugin.state.dataState.events.changed.subscribe(e => {
+        plugin.state.data.events.changed.subscribe(e => {
             if (e.inTransaction || plugin.behaviors.state.isAnimating.value) return;
             this.sync();
         });

+ 11 - 11
src/mol-plugin-state/manager/structure/measurement.ts

@@ -47,9 +47,9 @@ class StructureMeasurementManager extends PluginComponent<StructureMeasurementMa
     }
 
     private getGroup() {
-        const state = this.plugin.state.dataState;
+        const state = this.plugin.state.data;
         const groupRef = StateSelection.findTagInSubtree(state.tree, StateTransform.RootRef, MeasurementGroupTag);
-        const builder = this.plugin.state.dataState.build();
+        const builder = this.plugin.state.data.build();
 
         if (groupRef) return builder.to(groupRef);
         return builder.toRoot().group(StateTransforms.Misc.CreateGroup, { label: `Measurements` }, { tags: MeasurementGroupTag });
@@ -58,7 +58,7 @@ class StructureMeasurementManager extends PluginComponent<StructureMeasurementMa
     async setOptions(options: StructureMeasurementOptions) {
         if (this.updateState({ options })) this.stateUpdated();
 
-        const update = this.plugin.state.dataState.build();
+        const update = this.plugin.state.data.build();
         for (const cell of this.state.distances) {
             update.to(cell).update((old: any) => { 
                 old.unitLabel = options.distanceUnitLabel;
@@ -77,7 +77,7 @@ class StructureMeasurementManager extends PluginComponent<StructureMeasurementMa
         
         if (update.editInfo.count === 0) return;
 
-        await PluginCommands.State.Update(this.plugin, { state: this.plugin.state.dataState, tree: update, options: { doNotLogTiming: true } });
+        await PluginCommands.State.Update(this.plugin, { state: this.plugin.state.data, tree: update, options: { doNotLogTiming: true } });
     }
 
     async addDistance(a: StructureElement.Loci, b: StructureElement.Loci) {
@@ -104,7 +104,7 @@ class StructureMeasurementManager extends PluginComponent<StructureMeasurementMa
                 textColor: this.state.options.textColor
             })
 
-        const state = this.plugin.state.dataState;
+        const state = this.plugin.state.data;
         await PluginCommands.State.Update(this.plugin, { state, tree: update, options: { doNotLogTiming: true } });
     }
 
@@ -134,7 +134,7 @@ class StructureMeasurementManager extends PluginComponent<StructureMeasurementMa
                 textColor: this.state.options.textColor
             })
 
-        const state = this.plugin.state.dataState;
+        const state = this.plugin.state.data;
         await PluginCommands.State.Update(this.plugin, { state, tree: update, options: { doNotLogTiming: true } });
     }
 
@@ -167,7 +167,7 @@ class StructureMeasurementManager extends PluginComponent<StructureMeasurementMa
                 textColor: this.state.options.textColor
             })
 
-        const state = this.plugin.state.dataState;
+        const state = this.plugin.state.data;
         await PluginCommands.State.Update(this.plugin, { state, tree: update, options: { doNotLogTiming: true } });
     }
 
@@ -191,7 +191,7 @@ class StructureMeasurementManager extends PluginComponent<StructureMeasurementMa
                 textColor: this.state.options.textColor
             })
 
-        const state = this.plugin.state.dataState;
+        const state = this.plugin.state.data;
         await PluginCommands.State.Update(this.plugin, { state, tree: update, options: { doNotLogTiming: true } });
     }
 
@@ -213,13 +213,13 @@ class StructureMeasurementManager extends PluginComponent<StructureMeasurementMa
             }, { dependsOn })
             .apply(StateTransforms.Representation.StructureSelectionsOrientation3D)
 
-        const state = this.plugin.state.dataState;
+        const state = this.plugin.state.data;
         await PluginCommands.State.Update(this.plugin, { state, tree: update, options: { doNotLogTiming: true } });
     }
 
     private _empty: any[] = [];
     private getTransforms<T extends StateTransformer<A, B, any>, A extends PluginStateObject.Molecule.Structure.Selections, B extends StateObject>(transformer: T) {
-        const state = this.plugin.state.dataState;
+        const state = this.plugin.state.data;
         const groupRef = StateSelection.findTagInSubtree(state.tree, StateTransform.RootRef, MeasurementGroupTag);
         const ret = groupRef ? state.select(StateSelection.Generators.ofTransformer(transformer, groupRef)) : this._empty;
         if (ret.length === 0) return this._empty;
@@ -240,7 +240,7 @@ class StructureMeasurementManager extends PluginComponent<StructureMeasurementMa
     constructor(private plugin: PluginContext) {
         super({ labels: [], distances: [], angles: [], dihedrals: [], orientations: [], options: DefaultStructureMeasurementOptions });
 
-        plugin.state.dataState.events.changed.subscribe(e => {
+        plugin.state.data.events.changed.subscribe(e => {
             if (e.inTransaction || plugin.behaviors.state.isAnimating.value) return;
             this.sync();
         });

+ 3 - 3
src/mol-plugin-state/manager/structure/selection.ts

@@ -420,7 +420,7 @@ export class StructureSelectionManager extends PluginComponent<StructureSelectio
     }
 
     fromSelections(ref: StateObjectRef<PluginStateObject.Molecule.Structure.Selections>) {
-        const cell = StateObjectRef.resolveAndCheck(this.plugin.state.dataState, ref);
+        const cell = StateObjectRef.resolveAndCheck(this.plugin.state.data, ref);
         if (!cell || !cell.obj) return;
 
         if (!PluginStateObject.Molecule.Structure.Selections.is(cell.obj)) {
@@ -437,8 +437,8 @@ export class StructureSelectionManager extends PluginComponent<StructureSelectio
     constructor(private plugin: PluginContext) {
         super({ entries: new Map(), additionsHistory: [], stats: SelectionStats() });
 
-        plugin.state.dataState.events.object.removed.subscribe(e => this.onRemove(e.ref));
-        plugin.state.dataState.events.object.updated.subscribe(e => this.onUpdate(e.ref, e.oldObj, e.obj));
+        plugin.state.data.events.object.removed.subscribe(e => this.onRemove(e.ref));
+        plugin.state.data.events.object.updated.subscribe(e => this.onUpdate(e.ref, e.oldObj, e.obj));
     }
 }
 

+ 7 - 7
src/mol-plugin-ui/controls.tsx

@@ -26,7 +26,7 @@ export class TrajectoryViewportControls extends PluginUIComponent<{}, { show: bo
     state = { show: false, label: '' }
 
     private update = () => {
-        const state = this.plugin.state.dataState;
+        const state = this.plugin.state.data;
 
         const models = state.selectQ(q => q.ofTransformer(StateTransforms.Model.ModelFromTrajectory));
 
@@ -62,22 +62,22 @@ export class TrajectoryViewportControls extends PluginUIComponent<{}, { show: bo
     }
 
     componentDidMount() {
-        this.subscribe(this.plugin.state.dataState.events.changed, this.update);
+        this.subscribe(this.plugin.state.data.events.changed, this.update);
         this.subscribe(this.plugin.behaviors.state.isAnimating, this.update);
     }
 
     reset = () => PluginCommands.State.ApplyAction(this.plugin, {
-        state: this.plugin.state.dataState,
+        state: this.plugin.state.data,
         action: UpdateTrajectory.create({ action: 'reset' })
     });
 
     prev = () => PluginCommands.State.ApplyAction(this.plugin, {
-        state: this.plugin.state.dataState,
+        state: this.plugin.state.data,
         action: UpdateTrajectory.create({ action: 'advance', by: -1 })
     });
 
     next = () => PluginCommands.State.ApplyAction(this.plugin, {
-        state: this.plugin.state.dataState,
+        state: this.plugin.state.data,
         action: UpdateTrajectory.create({ action: 'advance', by: 1 })
     });
 
@@ -210,8 +210,8 @@ export class AnimationViewportControls extends PluginUIComponent<{}, { isEmpty:
             else this.setState({ isPlaying: false });
         });
         this.subscribe(this.plugin.behaviors.state.isUpdating, isUpdating => {
-            if (isUpdating) this.setState({ isUpdating: true, isExpanded: false, isEmpty: this.plugin.state.dataState.tree.transforms.size < 2 });
-            else this.setState({ isUpdating: false, isEmpty: this.plugin.state.dataState.tree.transforms.size < 2 });
+            if (isUpdating) this.setState({ isUpdating: true, isExpanded: false, isEmpty: this.plugin.state.data.tree.transforms.size < 2 });
+            else this.setState({ isUpdating: false, isEmpty: this.plugin.state.data.tree.transforms.size < 2 });
         });
         this.subscribe(this.plugin.behaviors.state.isAnimating, isAnimating => {
             if (isAnimating) this.setState({ isAnimating: true, isExpanded: false });

+ 7 - 7
src/mol-plugin-ui/left-panel.tsx

@@ -30,7 +30,7 @@ export class LeftPanelControls extends PluginUIComponent<{}, { tab: LeftPanelTab
             }
         });
 
-        this.subscribe(this.plugin.state.dataState.events.changed, ({ state }) => {
+        this.subscribe(this.plugin.state.data.events.changed, ({ state }) => {
             if (this.state.tab !== 'data') return;
             if (state.cells.size === 1) this.set('root');
         });
@@ -58,12 +58,12 @@ export class LeftPanelControls extends PluginUIComponent<{}, { tab: LeftPanelTab
         'none': <></>,
         'root': <>
             <SectionHeader icon='home' title='Home' />
-            <StateObjectActions state={this.plugin.state.dataState} nodeRef={StateTransform.RootRef} hideHeader={true} initiallyCollapsed={true} alwaysExpandFirst={true} />
+            <StateObjectActions state={this.plugin.state.data} nodeRef={StateTransform.RootRef} hideHeader={true} initiallyCollapsed={true} alwaysExpandFirst={true} />
             {this.plugin.spec.components?.remoteState !== 'none' && <RemoteStateSnapshots listOnly /> }
         </>,
         'data': <>
             <SectionHeader icon='flow-tree' title={<><RemoveAllButton /> State Tree</>} />
-            <StateTree state={this.plugin.state.dataState} />
+            <StateTree state={this.plugin.state.data} />
         </>,
         'states': <StateSnapshots />,
         'settings': <>
@@ -111,7 +111,7 @@ class DataIcon extends PluginUIComponent<{ set: (tab: LeftPanelTabName) => void
             else this.forceUpdate();
         });
 
-        this.subscribe(this.plugin.state.dataState.events.changed, state => {
+        this.subscribe(this.plugin.state.data.events.changed, state => {
             if (this.tab !== 'data') this.setState({ changed: true });
         });
     }
@@ -144,7 +144,7 @@ class FullSettings extends PluginUIComponent {
                 <ParameterControls params={Canvas3DParams} values={this.plugin.canvas3d.props} onChange={this.setSettings} />
             </>}
             <SectionHeader title='Behavior' />
-            <StateTree state={this.plugin.state.behaviorState} />
+            <StateTree state={this.plugin.state.behaviors} />
         </>
     }
 }
@@ -162,11 +162,11 @@ export class RemoveAllButton extends PluginUIComponent<{ }> {
 
     remove = (e: React.MouseEvent<HTMLElement>) => {
         e.preventDefault();
-        PluginCommands.State.RemoveObject(this.plugin, { state: this.plugin.state.dataState, ref: StateTransform.RootRef });
+        PluginCommands.State.RemoveObject(this.plugin, { state: this.plugin.state.data, ref: StateTransform.RootRef });
     }
 
     render() {
-        const count = this.plugin.state.dataState.tree.children.get(StateTransform.RootRef).size;
+        const count = this.plugin.state.data.tree.children.get(StateTransform.RootRef).size;
         if (count < 2) return null;
         return <IconButton icon='remove' onClick={this.remove} title={'Remove All'} style={{ display: 'inline-block' }} />;
     }

+ 4 - 4
src/mol-plugin-ui/sequence.tsx

@@ -194,7 +194,7 @@ export class SequenceView extends PluginUIComponent<{ }, SequenceViewState> {
     state = { structure: Structure.Empty, structureRef: '', modelEntityId: '', chainGroupId: -1, operatorKey: '' }
 
     componentDidMount() {
-        if (this.plugin.state.dataState.select(StateSelection.Generators.rootsOfType(PSO.Molecule.Structure)).length > 0) this.setState(this.getInitialState())
+        if (this.plugin.state.data.select(StateSelection.Generators.rootsOfType(PSO.Molecule.Structure)).length > 0) this.setState(this.getInitialState())
 
         this.subscribe(this.plugin.events.state.object.updated, ({ ref, obj }) => {
             if (ref === this.state.structureRef && obj && obj.type === PSO.Molecule.Structure.type && obj.data !== this.state.structure) {
@@ -216,7 +216,7 @@ export class SequenceView extends PluginUIComponent<{ }, SequenceViewState> {
     }
 
     private getStructure(ref: string) {
-        const state = this.plugin.state.dataState;
+        const state = this.plugin.state.data;
         const cell = state.select(ref)[0];
         if (!ref || !cell || !cell.obj) return Structure.Empty;
         return (cell.obj as PSO.Molecule.Structure).data;
@@ -227,7 +227,7 @@ export class SequenceView extends PluginUIComponent<{ }, SequenceViewState> {
     }
 
     private getInitialState(): SequenceViewState {
-        const structureRef = getStructureOptions(this.plugin.state.dataState)[0][0]
+        const structureRef = getStructureOptions(this.plugin.state.data)[0][0]
         const structure = this.getStructure(structureRef)
         let modelEntityId = getModelEntityOptions(structure)[0][0]
         let chainGroupId = getChainOptions(structure, modelEntityId)[0][0]
@@ -242,7 +242,7 @@ export class SequenceView extends PluginUIComponent<{ }, SequenceViewState> {
 
     private get params() {
         const { structure, modelEntityId, chainGroupId } = this.state
-        const structureOptions = getStructureOptions(this.plugin.state.dataState)
+        const structureOptions = getStructureOptions(this.plugin.state.data)
         const entityOptions = getModelEntityOptions(structure)
         const chainOptions = getChainOptions(structure, modelEntityId)
         const operatorOptions = getOperatorOptions(structure, modelEntityId, chainGroupId)

+ 2 - 9
src/mol-plugin-ui/state/tree.tsx

@@ -199,23 +199,16 @@ class StateTreeNodeLabel extends PluginUIComponent<
 
     highlight = (e: React.MouseEvent<HTMLElement>) => {
         e.preventDefault();
-        PluginCommands.State.Highlight(this.plugin, { state: this.props.cell.parent, ref: this.ref });
+        PluginCommands.Interactivity.Object.Highlight(this.plugin, { state: this.props.cell.parent, ref: this.ref });
         e.currentTarget.blur();
     }
 
     clearHighlight = (e: React.MouseEvent<HTMLElement>) => {
         e.preventDefault();
-        PluginCommands.State.ClearHighlights(this.plugin);
+        PluginCommands.Interactivity.ClearHighlights(this.plugin);
         e.currentTarget.blur();
     }
 
-    // private toggleUpdaterObs = new Subject();
-    // toggleUpdater = (e: React.MouseEvent<HTMLAnchorElement>) => {
-    //     e.preventDefault();
-    //     e.currentTarget.blur();
-    //     this.toggleUpdaterObs.next();
-    // }
-
     render() {
         const cell = this.props.cell;
         const n = cell.transform;

+ 3 - 3
src/mol-plugin-ui/state/update-transform.tsx

@@ -31,7 +31,7 @@ namespace UpdateTransformControl {
 class UpdateTransformControl extends TransformControlBase<UpdateTransformControl.Props, UpdateTransformControl.ComponentState> {
     applyAction() { 
         if (this.props.customUpdate) return this.props.customUpdate(this.state.params);
-        return this.plugin.updateTransform(this.props.state, this.props.transform.ref, this.state.params);
+        return this.plugin.state.updateTransform(this.props.state, this.props.transform.ref, this.state.params);
     }
     getInfo() { return this._getInfo(this.props.transform); }
     getTransformerId() { return this.props.transform.transformer.id; }
@@ -103,13 +103,13 @@ class UpdateTransformControl extends TransformControlBase<UpdateTransformControl
 class TransformUpdaterControl extends PluginUIComponent<{ nodeRef: string, initiallyCollapsed?: boolean, header?: StateTransformer.Definition['display'] }> {
     componentDidMount() {
         this.subscribe(this.plugin.events.state.object.updated, ({ ref, state }) => {
-            if (this.props.nodeRef !== ref || this.plugin.state.dataState !== state) return;
+            if (this.props.nodeRef !== ref || this.plugin.state.data !== state) return;
             this.forceUpdate();
         });
     }
 
     render() {
-        const state = this.plugin.state.dataState;
+        const state = this.plugin.state.data;
         const ref = this.props.nodeRef;
         const cell = state.cells.get(ref)!;
 

+ 5 - 5
src/mol-plugin-ui/structure/components.tsx

@@ -62,7 +62,7 @@ class ComponentEditorControls extends PurePluginUIComponent<{}, ComponentEditorC
         this.subscribe(this.plugin.behaviors.state.isBusy, v => {
             this.setState({ isBusy: v, action: this.state.action !== 'options' ? void 0 : 'options' })
         });
-        this.subscribe(this.plugin.state.dataState.events.historyUpdated, ({ state }) => {
+        this.subscribe(this.plugin.state.data.events.historyUpdated, ({ state }) => {
             this.setState({ canUndo: state.canUndo });
         });
     }
@@ -104,13 +104,13 @@ class ComponentEditorControls extends PurePluginUIComponent<{}, ComponentEditorC
     }
 
     undo = () => {
-        const task = this.plugin.state.dataState.undo();
+        const task = this.plugin.state.data.undo();
         if (task) this.plugin.runTask(task);
     }
 
     render() {
         const undoTitle = this.state.canUndo
-            ? `Undo ${this.plugin.state.dataState.latestUndoLabel}`
+            ? `Undo ${this.plugin.state.data.latestUndoLabel}`
             : 'Some mistakes of the past can be undone.';
         return <>
             <div className='msp-control-row msp-select-row'>
@@ -316,12 +316,12 @@ class StructureComponentGroup extends PurePluginUIComponent<{ group: StructureCo
 
     highlight = (e: React.MouseEvent<HTMLElement>) => {
         e.preventDefault();
-        PluginCommands.State.Highlight(this.plugin, { state: this.props.group[0].cell.parent, ref: this.props.group.map(c => c.cell.transform.ref) });
+        PluginCommands.Interactivity.Object.Highlight(this.plugin, { state: this.props.group[0].cell.parent, ref: this.props.group.map(c => c.cell.transform.ref) });
     }
 
     clearHighlight = (e: React.MouseEvent<HTMLElement>) => {
         e.preventDefault();
-        PluginCommands.State.ClearHighlights(this.plugin);
+        PluginCommands.Interactivity.ClearHighlights(this.plugin);
     }
 
     focus = () => {

+ 1 - 1
src/mol-plugin-ui/viewport/help.tsx

@@ -95,7 +95,7 @@ export class HelpContent extends PluginUIComponent {
     }
 
     private getTriggerFor(transformer: StateTransformer, name: string) {
-        const state = this.plugin.state.behaviorState
+        const state = this.plugin.state.behaviors
         const selections = state.select(StateSelection.Generators.ofTransformer(transformer))
         const params = selections.length === 1 ? selections[0].params : undefined
         const bindings = params ? params.values.bindings : {}

+ 1 - 1
src/mol-plugin-ui/viewport/screenshot.tsx

@@ -93,7 +93,7 @@ export class DownloadScreenshotControls extends PluginUIComponent<{ close: () =>
             this.updateQueue.next();
         })
 
-        this.subscribe(this.plugin.state.dataState.events.isUpdating, v => {
+        this.subscribe(this.plugin.state.data.events.isUpdating, v => {
             this.setState({ isDisabled: v })
             if (!v) this.updateQueue.next();
         })

+ 1 - 1
src/mol-plugin-ui/viewport/simple-settings.tsx

@@ -108,7 +108,7 @@ const SimpleSettingsMapping = ParamMapping({
         await PluginCommands.Layout.Update(ctx, { state });
 
         if (hideLeft) {
-            PluginCommands.State.SetCurrentObject(ctx, { state: ctx.state.dataState, ref: StateTransform.RootRef });
+            PluginCommands.State.SetCurrentObject(ctx, { state: ctx.state.data, ref: StateTransform.RootRef });
         }
     }
 })

+ 1 - 1
src/mol-plugin/behavior/dynamic/custom-props/computed/interactions.ts

@@ -29,7 +29,7 @@ export const Interactions = PluginBehavior.create<{ autoAttach: boolean, showToo
             const structures: Structure[] = []
             const root = this.ctx.helpers.substructureParent.get(structure)
             if (root) {
-                const state = this.ctx.state.dataState
+                const state = this.ctx.state.data
                 const selections = state.select(StateSelection.Generators.ofType(PluginStateObject.Molecule.Structure, root.transform.ref));
                 for (const s of selections) {
                     if (s.obj) arraySetAdd(structures, s.obj.data)

+ 1 - 1
src/mol-plugin/behavior/dynamic/custom-props/computed/valence-model.ts

@@ -26,7 +26,7 @@ export const ValenceModel = PluginBehavior.create<{ autoAttach: boolean, showToo
             const structures: Structure[] = []
             const root = this.ctx.helpers.substructureParent.get(structure)
             if (root) {
-                const state = this.ctx.state.dataState
+                const state = this.ctx.state.data
                 const selections = state.select(StateSelection.Generators.ofType(PluginStateObject.Molecule.Structure, root.transform.ref));
                 for (const s of selections) {
                     if (s.obj) arraySetAdd(structures, s.obj.data)

+ 2 - 2
src/mol-plugin/behavior/dynamic/custom-props/rcsb/assembly-symmetry.ts

@@ -27,7 +27,7 @@ export const RCSBAssemblySymmetry = PluginBehavior.create<{ autoAttach: boolean
         private provider = AssemblySymmetryProvider
 
         register(): void {
-            this.ctx.state.dataState.actions.add(InitAssemblySymmetry3D)
+            this.ctx.state.data.actions.add(InitAssemblySymmetry3D)
             this.ctx.customStructureProperties.register(this.provider, this.params.autoAttach);
             this.ctx.representation.structure.themes.colorThemeRegistry.add(AssemblySymmetryClusterColorThemeProvider)
         }
@@ -40,7 +40,7 @@ export const RCSBAssemblySymmetry = PluginBehavior.create<{ autoAttach: boolean
         }
 
         unregister() {
-            this.ctx.state.dataState.actions.remove(InitAssemblySymmetry3D)
+            this.ctx.state.data.actions.remove(InitAssemblySymmetry3D)
             this.ctx.customStructureProperties.unregister(this.provider.descriptor.name);
             this.ctx.representation.structure.themes.colorThemeRegistry.remove(AssemblySymmetryClusterColorThemeProvider)
         }

+ 4 - 4
src/mol-plugin/behavior/dynamic/representation.ts

@@ -97,7 +97,7 @@ export const SelectLoci = PluginBehavior.create({
             this.ctx.canvas3d.mark({ loci: interactionLoci.loci }, action)
         }
         private applySelectMark(ref: string, clear?: boolean) {
-            const cell = this.ctx.state.dataState.cells.get(ref)
+            const cell = this.ctx.state.data.cells.get(ref)
             if (cell && SO.isRepresentation3D(cell.obj)) {
                 this.spine.current = cell
                 const so = this.spine.getRootOfType(SO.Molecule.Structure)
@@ -148,9 +148,9 @@ export const SelectLoci = PluginBehavior.create({
 
             // re-apply select-mark to all representation of an updated structure
             this.subscribeObservable(this.ctx.events.state.object.updated, ({ ref }) => {
-                const cell = this.ctx.state.dataState.cells.get(ref)
+                const cell = this.ctx.state.data.cells.get(ref)
                 if (cell && SO.Molecule.Structure.is(cell.obj)) {
-                    const reprs = this.ctx.state.dataState.select(StateSelection.Generators.ofType(SO.Molecule.Structure.Representation3D, ref))
+                    const reprs = this.ctx.state.data.select(StateSelection.Generators.ofType(SO.Molecule.Structure.Representation3D, ref))
                     for (const repr of reprs) this.applySelectMark(repr.transform.ref, true)
                 }
             });
@@ -160,7 +160,7 @@ export const SelectLoci = PluginBehavior.create({
         }
         constructor(ctx: PluginContext, params: SelectLociProps) {
             super(ctx, params)
-            this.spine = new StateTreeSpine.Impl(ctx.state.dataState.cells)
+            this.spine = new StateTreeSpine.Impl(ctx.state.data.cells)
         }
     },
     params: () => SelectLociParams,

+ 3 - 3
src/mol-plugin/behavior/dynamic/selection/structure-representation-interaction.ts

@@ -75,7 +75,7 @@ const TagSet: Set<StructureRepresentationInteractionTags> = new Set([StructureRe
 
 export class StructureRepresentationInteractionBehavior extends PluginBehavior.WithSubscribers<StructureRepresentationInteractionProps> {
     private ensureShape(cell: StateObjectCell<PluginStateObject.Molecule.Structure>) {
-        const state = this.plugin.state.dataState, tree = state.tree;
+        const state = this.plugin.state.data, tree = state.tree;
         const builder = state.build();
         const refs = StateSelection.findUniqueTagsInSubtree(tree, cell.transform.ref, TagSet);
 
@@ -123,7 +123,7 @@ export class StructureRepresentationInteractionBehavior extends PluginBehavior.W
     }
 
     private clear(root: StateTransform.Ref) {
-        const state = this.plugin.state.dataState;
+        const state = this.plugin.state.data;
         const groups = state.select(StateSelection.Generators.byRef(root).subtree().withTag(StructureRepresentationInteractionTags.Group));
         if (groups.length === 0) return;
 
@@ -215,7 +215,7 @@ export class StructureRepresentationInteractionBehavior extends PluginBehavior.W
     async update(params: StructureRepresentationInteractionProps) {
         this.params = params;
 
-        const state = this.plugin.state.dataState;
+        const state = this.plugin.state.data;
         const builder = state.build();
 
         const all = StateSelection.Generators.root.subtree();        

+ 2 - 2
src/mol-plugin/behavior/dynamic/volume-streaming/behavior.ts

@@ -202,7 +202,7 @@ export namespace VolumeStreaming {
         private updateDynamicBox(box: Box3D) {
             if (this.params.entry.params.view.name !== 'selection-box') return;
 
-            const state = this.plugin.state.dataState;
+            const state = this.plugin.state.data;
             const newParams: Params = {
                 ...this.params,
                 entry: {
@@ -226,7 +226,7 @@ export namespace VolumeStreaming {
         }
 
         private getStructureRoot() {
-            return this.plugin.state.dataState.select(StateSelection.Generators.byRef(this.ref).rootOfType([PluginStateObject.Molecule.Structure]))[0];
+            return this.plugin.state.data.select(StateSelection.Generators.byRef(this.ref).rootOfType([PluginStateObject.Molecule.Structure]))[0];
         }
 
         register(ref: string): void {

+ 3 - 3
src/mol-plugin/behavior/static/representation.ts

@@ -16,7 +16,7 @@ export function registerDefault(ctx: PluginContext) {
 }
 
 export function SyncRepresentationToCanvas(ctx: PluginContext) {
-    const events = ctx.state.dataState.events;
+    const events = ctx.state.data.events;
     events.object.created.subscribe(e => {
         if (!SO.isRepresentation3D(e.obj)) return;
         updateVisibility(e.state.cells.get(e.ref)!, e.obj.data.repr);
@@ -51,7 +51,7 @@ export function SyncRepresentationToCanvas(ctx: PluginContext) {
 
 export function SyncStructureRepresentation3DState(ctx: PluginContext) {
     // TODO: figure out how to do transform composition here?
-    const events = ctx.state.dataState.events;
+    const events = ctx.state.data.events;
     events.object.created.subscribe(e => {
         if (!SO.Molecule.Structure.Representation3DState.is(e.obj)) return;
         const data = e.obj.data as SO.Molecule.Structure.Representation3DStateData;
@@ -77,7 +77,7 @@ export function SyncStructureRepresentation3DState(ctx: PluginContext) {
 
 
 export function UpdateRepresentationVisibility(ctx: PluginContext) {
-    ctx.state.dataState.events.cell.stateUpdated.subscribe(e => {
+    ctx.state.data.events.cell.stateUpdated.subscribe(e => {
         const cell = e.state.cells.get(e.ref)!;
         if (!SO.isRepresentation3D(cell.obj)) return;
         updateVisibility(cell, cell.obj.data.repr);

+ 4 - 4
src/mol-plugin/behavior/static/state.ts

@@ -54,7 +54,7 @@ export function SetCurrentObject(ctx: PluginContext) {
 }
 
 export function Update(ctx: PluginContext) {
-    PluginCommands.State.Update.subscribe(ctx, ({ state, tree, options }) => ctx.runTask(state.updateTree(tree, options)));
+    PluginCommands.State.Update.subscribe(ctx, ({ state, tree, options }) => ctx.updateState(tree, options));
 }
 
 export function ApplyAction(ctx: PluginContext) {
@@ -64,7 +64,7 @@ export function ApplyAction(ctx: PluginContext) {
 export function RemoveObject(ctx: PluginContext) {
     function remove(state: State, ref: string) {
         const tree = state.build().delete(ref).getTree();
-        return ctx.runTask(state.updateTree(tree));
+        return ctx.updateState(tree);
     }
 
     PluginCommands.State.RemoveObject.subscribe(ctx, ({ state, ref, removeParentGhosts }) => {
@@ -104,7 +104,7 @@ function setVisibilityVisitor(t: StateTransform, tree: StateTree, ctx: { state:
 }
 
 export function Highlight(ctx: PluginContext) {
-    PluginCommands.State.Highlight.subscribe(ctx, ({ state, ref }) => {
+    PluginCommands.Interactivity.Object.Highlight.subscribe(ctx, ({ state, ref }) => {
         ctx.managers.interactivity.lociHighlights.clearHighlights();
 
         const refs = typeof ref === 'string' ? [ref] : ref;
@@ -129,7 +129,7 @@ export function Highlight(ctx: PluginContext) {
 }
 
 export function ClearHighlights(ctx: PluginContext) {
-    PluginCommands.State.ClearHighlights.subscribe(ctx, () => {
+    PluginCommands.Interactivity.ClearHighlights.subscribe(ctx, () => {
         ctx.managers.interactivity.lociHighlights.clearHighlights();
     });
 }

+ 6 - 4
src/mol-plugin/commands.ts

@@ -25,9 +25,7 @@ export const PluginCommands = {
 
         ToggleExpanded: PluginCommand<{ state: State, ref: StateTransform.Ref }>(),
         ToggleVisibility: PluginCommand<{ state: State, ref: StateTransform.Ref }>(),
-        Highlight: PluginCommand<{ state: State, ref: StateTransform.Ref | StateTransform.Ref[] }>(),
-        ClearHighlights: PluginCommand<{}>(),
-
+        
         Snapshots: {
             Add: PluginCommand<{ name?: string, description?: string, params?: PluginState.GetSnapshotParams }>(),
             Replace: PluginCommand<{ id: string, params?: PluginState.GetSnapshotParams }>(),
@@ -44,10 +42,14 @@ export const PluginCommands = {
         }
     },
     Interactivity: {
+        Object: {
+            Highlight: PluginCommand<{ state: State, ref: StateTransform.Ref | StateTransform.Ref[] }>(),
+        },
         Structure: {
             Highlight: PluginCommand<{ loci: StructureElement.Loci, isOff?: boolean }>(),
             Select: PluginCommand<{ loci: StructureElement.Loci, isOff?: boolean }>()
-        }
+        },
+        ClearHighlights: PluginCommand<{}>(),
     },
     Layout: {
         Update: PluginCommand<{ state: Partial<PluginLayoutStateProps> }>()

+ 41 - 47
src/mol-plugin/context.ts

@@ -5,50 +5,50 @@
  * @author Alexander Rose <alexander.rose@weirdbyte.de>
  */
 
+import { setAutoFreeze } from 'immer';
 import { List } from 'immutable';
+import { merge } from 'rxjs';
 import { Canvas3D } from '../mol-canvas3d/canvas3d';
+import { CustomProperty } from '../mol-model-props/common/custom-property';
+import { Model, Structure } from '../mol-model/structure';
+import { DataFormatRegistry } from '../mol-plugin-state/actions/data-format';
+import { DataBuilder } from '../mol-plugin-state/builder/data';
+import { StructureBuilder } from '../mol-plugin-state/builder/structure';
+import { TrajectoryFormatRegistry } from '../mol-plugin-state/formats/trajectory';
+import { CameraManager } from '../mol-plugin-state/manager/camera';
+import { InteractivityManager } from '../mol-plugin-state/manager/interactivity';
+import { LociLabelEntry, LociLabelManager } from '../mol-plugin-state/manager/loci-label';
+import { StructureComponentManager } from '../mol-plugin-state/manager/structure/component';
+import { StructureHierarchyManager } from '../mol-plugin-state/manager/structure/hierarchy';
+import { StructureMeasurementManager } from '../mol-plugin-state/manager/structure/measurement';
+import { StructureSelectionManager } from '../mol-plugin-state/manager/structure/selection';
+import { StateTransformParameters } from '../mol-plugin-ui/state/common';
 import { StructureRepresentationRegistry } from '../mol-repr/structure/registry';
 import { VolumeRepresentationRegistry } from '../mol-repr/volume/registry';
-import { State, StateTransform, StateTransformer } from '../mol-state';
-import { Task, Progress } from '../mol-task';
+import { State, StateBuilder, StateTree } from '../mol-state';
+import { Progress, Task } from '../mol-task';
 import { ColorTheme } from '../mol-theme/color';
 import { SizeTheme } from '../mol-theme/size';
 import { ThemeRegistryContext } from '../mol-theme/theme';
 import { Color } from '../mol-util/color';
 import { ajaxGet } from '../mol-util/data-source';
+import { isDebugMode, isProductionMode } from '../mol-util/debug';
+import { ModifiersKeys } from '../mol-util/input/input-observer';
 import { LogEntry } from '../mol-util/log-entry';
 import { RxEventHelper } from '../mol-util/rx-event-helper';
-import { merge } from 'rxjs';
 import { BuiltInPluginBehaviors } from './behavior';
 import { PluginBehavior } from './behavior/behavior';
-import { PluginCommands } from './commands';
 import { PluginCommandManager } from './command';
-import { PluginLayout, LeftPanelTabName } from './layout';
+import { PluginCommands } from './commands';
+import { PluginConfigManager } from './config';
+import { LeftPanelTabName, PluginLayout } from './layout';
 import { PluginSpec } from './spec';
 import { PluginState } from './state';
-import { DataFormatRegistry } from '../mol-plugin-state/actions/data-format';
-import { StateTransformParameters } from '../mol-plugin-ui/state/common';
-import { LociLabelEntry, LociLabelManager } from '../mol-plugin-state/manager/loci-label';
-import { TaskManager } from './util/task-manager';
-import { PLUGIN_VERSION, PLUGIN_VERSION_DATE } from './version';
 import { SubstructureParentHelper } from './util/substructure-parent-helper';
-import { ModifiersKeys } from '../mol-util/input/input-observer';
-import { isProductionMode, isDebugMode } from '../mol-util/debug';
-import { Model, Structure } from '../mol-model/structure';
-import { InteractivityManager } from '../mol-plugin-state/manager/interactivity';
+import { TaskManager } from './util/task-manager';
 import { PluginToastManager } from './util/toast';
-import { StructureMeasurementManager } from '../mol-plugin-state/manager/structure/measurement';
 import { ViewportScreenshotHelper } from './util/viewport-screenshot';
-import { CustomProperty } from '../mol-model-props/common/custom-property';
-import { PluginConfigManager } from './config';
-import { DataBuilder } from '../mol-plugin-state/builder/data';
-import { StructureBuilder } from '../mol-plugin-state/builder/structure';
-import { StructureHierarchyManager } from '../mol-plugin-state/manager/structure/hierarchy';
-import { StructureSelectionManager } from '../mol-plugin-state/manager/structure/selection';
-import { TrajectoryFormatRegistry } from '../mol-plugin-state/formats/trajectory';
-import { StructureComponentManager } from '../mol-plugin-state/manager/structure/component';
-import { CameraManager } from '../mol-plugin-state/manager/camera';
-import { setAutoFreeze } from 'immer';
+import { PLUGIN_VERSION, PLUGIN_VERSION_DATE } from './version';
 
 export class PluginContext {
     private disposed = false;
@@ -61,14 +61,14 @@ export class PluginContext {
     readonly events = {
         state: {
             cell: {
-                stateUpdated: merge(this.state.dataState.events.cell.stateUpdated, this.state.behaviorState.events.cell.stateUpdated),
-                created: merge(this.state.dataState.events.cell.created, this.state.behaviorState.events.cell.created),
-                removed: merge(this.state.dataState.events.cell.removed, this.state.behaviorState.events.cell.removed),
+                stateUpdated: merge(this.state.data.events.cell.stateUpdated, this.state.behaviors.events.cell.stateUpdated),
+                created: merge(this.state.data.events.cell.created, this.state.behaviors.events.cell.created),
+                removed: merge(this.state.data.events.cell.removed, this.state.behaviors.events.cell.removed),
             },
             object: {
-                created: merge(this.state.dataState.events.object.created, this.state.behaviorState.events.object.created),
-                removed: merge(this.state.dataState.events.object.removed, this.state.behaviorState.events.object.removed),
-                updated: merge(this.state.dataState.events.object.updated, this.state.behaviorState.events.object.updated)
+                created: merge(this.state.data.events.object.created, this.state.behaviors.events.object.created),
+                removed: merge(this.state.data.events.object.removed, this.state.behaviors.events.object.removed),
+                updated: merge(this.state.data.events.object.updated, this.state.behaviors.events.object.updated)
             },
             cameraSnapshots: this.state.cameraSnapshots.events,
             snapshots: this.state.snapshots.events,
@@ -199,7 +199,11 @@ export class PluginContext {
     }
 
     dataTransaction(f: () => Promise<void> | void, options?: { canUndo?: string | boolean }) {
-        return this.runTask(this.state.dataState.transaction(f, options));
+        return this.runTask(this.state.data.transaction(f, options));
+    }
+
+    updateState(tree: StateTree | StateBuilder, options?: Partial<State.UpdateOptions>) {
+        return this.runTask(this.state.data.updateTree(tree, options));
     }
 
     requestTaskAbort(progress: Progress, reason?: string) {
@@ -217,18 +221,8 @@ export class PluginContext {
         this.disposed = true;
     }
 
-    applyTransform(state: State, a: StateTransform.Ref, transformer: StateTransformer, params: any) {
-        const tree = state.build().to(a).apply(transformer, params);
-        return PluginCommands.State.Update(this, { state, tree });
-    }
-
-    updateTransform(state: State, a: StateTransform.Ref, params: any) {
-        const tree = state.build().to(a).update(params);
-        return PluginCommands.State.Update(this, { state, tree });
-    }
-
     private initBehaviorEvents() {
-        merge(this.state.dataState.events.isUpdating, this.state.behaviorState.events.isUpdating).subscribe(u => {
+        merge(this.state.data.events.isUpdating, this.state.behaviors.events.isUpdating).subscribe(u => {
             this.behaviors.state.isUpdating.next(u);
         });
 
@@ -248,11 +242,11 @@ export class PluginContext {
         BuiltInPluginBehaviors.Camera.registerDefault(this);
         BuiltInPluginBehaviors.Misc.registerDefault(this);
 
-        merge(this.state.dataState.events.log, this.state.behaviorState.events.log).subscribe(e => this.events.log.next(e));
+        merge(this.state.data.events.log, this.state.behaviors.events.log).subscribe(e => this.events.log.next(e));
     }
 
     private async initBehaviors() {
-        const tree = this.state.behaviorState.build();
+        const tree = this.state.behaviors.build();
 
         for (const cat of Object.keys(PluginBehavior.Categories)) {
             tree.toRoot().apply(PluginBehavior.CreateCategory, { label: (PluginBehavior.Categories as any)[cat] }, { ref: cat, state: { isLocked: true } });
@@ -262,12 +256,12 @@ export class PluginContext {
             tree.to(PluginBehavior.getCategoryId(b.transformer)).apply(b.transformer, b.defaultParams, { ref: b.transformer.id });
         }
 
-        await this.runTask(this.state.behaviorState.updateTree(tree, { doNotUpdateCurrent: true, doNotLogTiming: true }));
+        await this.runTask(this.state.behaviors.updateTree(tree, { doNotUpdateCurrent: true, doNotLogTiming: true }));
     }
 
     private initDataActions() {
         for (const a of this.spec.actions) {
-            this.state.dataState.actions.add(a.action);
+            this.state.data.actions.add(a.action);
         }
     }
 

+ 26 - 16
src/mol-plugin/state.ts

@@ -4,7 +4,7 @@
  * @author David Sehnal <david.sehnal@gmail.com>
  */
 
-import { State } from '../mol-state';
+import { State, StateTransform, StateTransformer } from '../mol-state';
 import { PluginStateObject as SO } from '../mol-plugin-state/objects';
 import { Camera } from '../mol-canvas3d/camera';
 import { PluginBehavior } from './behavior';
@@ -22,8 +22,8 @@ export { PluginState }
 class PluginState {
     private ev = RxEventHelper.create();
 
-    readonly dataState: State;
-    readonly behaviorState: State;
+    readonly data: State;
+    readonly behaviors: State;
     readonly animation: PluginAnimationManager;
     readonly cameraSnapshots = new CameraSnapshotManager();
     readonly snapshots: PluginStateSnapshotManager;
@@ -38,8 +38,8 @@ class PluginState {
         if (kind !== current) {
             this.behavior.kind.next(kind);
             this.behavior.currentObject.next(kind === 'data'
-                ? this.dataState.behaviors.currentObject.value
-                : this.behaviorState.behaviors.currentObject.value)
+                ? this.data.behaviors.currentObject.value
+                : this.behaviors.behaviors.currentObject.value)
         }
     }
 
@@ -47,8 +47,8 @@ class PluginState {
         const p = { ...PluginState.DefaultGetSnapshotParams, ...params };
         return {
             id: UUID.create22(),
-            data: p.data ? this.dataState.getSnapshot() : void 0,
-            behaviour: p.behavior ? this.behaviorState.getSnapshot() : void 0,
+            data: p.data ? this.data.getSnapshot() : void 0,
+            behaviour: p.behavior ? this.behaviors.getSnapshot() : void 0,
             animation: p.animation ? this.animation.getSnapshot() : void 0,
             startAnimation: p.startAnimation ? !!p.startAnimation : void 0,
             camera: p.camera ? {
@@ -66,8 +66,8 @@ class PluginState {
     async setSnapshot(snapshot: PluginState.Snapshot) {
         await this.animation.stop();
 
-        if (snapshot.behaviour) await this.plugin.runTask(this.behaviorState.setSnapshot(snapshot.behaviour));
-        if (snapshot.data) await this.plugin.runTask(this.dataState.setSnapshot(snapshot.data));
+        if (snapshot.behaviour) await this.plugin.runTask(this.behaviors.setSnapshot(snapshot.behaviour));
+        if (snapshot.data) await this.plugin.runTask(this.data.setSnapshot(snapshot.data));
         if (snapshot.canvas3d) {
             if (snapshot.canvas3d.props) await PluginCommands.Canvas3D.SetSettings(this.plugin, { settings: snapshot.canvas3d.props });
         }
@@ -91,27 +91,37 @@ class PluginState {
         }
     }
 
+    applyTransform(state: State, a: StateTransform.Ref, transformer: StateTransformer, params: any) {
+        const tree = state.build().to(a).apply(transformer, params);
+        return PluginCommands.State.Update(this.plugin, { state, tree });
+    }
+
+    updateTransform(state: State, a: StateTransform.Ref, params: any) {
+        const tree = state.build().to(a).update(params);
+        return PluginCommands.State.Update(this.plugin, { state, tree });
+    }
+
     dispose() {
         this.ev.dispose();
-        this.dataState.dispose();
-        this.behaviorState.dispose();
+        this.data.dispose();
+        this.behaviors.dispose();
         this.cameraSnapshots.dispose();
         this.animation.dispose();
     }
 
     constructor(private plugin: import('./context').PluginContext) {
         this.snapshots = new PluginStateSnapshotManager(plugin);
-        this.dataState = State.create(new SO.Root({ }), { globalContext: plugin });
-        this.behaviorState = State.create(new PluginBehavior.Root({ }), { globalContext: plugin, rootState: { isLocked: true } });
+        this.data = State.create(new SO.Root({ }), { globalContext: plugin });
+        this.behaviors = State.create(new PluginBehavior.Root({ }), { globalContext: plugin, rootState: { isLocked: true } });
 
-        this.dataState.behaviors.currentObject.subscribe(o => {
+        this.data.behaviors.currentObject.subscribe(o => {
             if (this.behavior.kind.value === 'data') this.behavior.currentObject.next(o);
         });
-        this.behaviorState.behaviors.currentObject.subscribe(o => {
+        this.behaviors.behaviors.currentObject.subscribe(o => {
             if (this.behavior.kind.value === 'behavior') this.behavior.currentObject.next(o);
         });
 
-        this.behavior.currentObject.next(this.dataState.behaviors.currentObject.value);
+        this.behavior.currentObject.next(this.data.behaviors.currentObject.value);
 
         this.animation = new PluginAnimationManager(plugin);
     }

+ 4 - 4
src/mol-plugin/util/substructure-parent-helper.ts

@@ -19,7 +19,7 @@ class SubstructureParentHelper {
     get(s: Structure): StateObjectCell<PluginStateObject.Molecule.Structure> | undefined {
         const r = this.root.get(s);
         if (!r) return;
-        return this.plugin.state.dataState.cells.get(r.ref);
+        return this.plugin.state.data.cells.get(r.ref);
     }
 
     private addMapping(state: State, ref: string, obj: StateObject) {
@@ -63,15 +63,15 @@ class SubstructureParentHelper {
     }
 
     constructor(private plugin: PluginContext) {
-        plugin.state.dataState.events.object.created.subscribe(e => {
+        plugin.state.data.events.object.created.subscribe(e => {
             this.addMapping(e.state, e.ref, e.obj);
         });
 
-        plugin.state.dataState.events.object.removed.subscribe(e => {
+        plugin.state.data.events.object.removed.subscribe(e => {
             this.removeMapping(e.ref);
         });
 
-        plugin.state.dataState.events.object.updated.subscribe(e => {
+        plugin.state.data.events.object.updated.subscribe(e => {
             this.updateMapping(e.state, e.ref, e.oldObj, e.obj);
         });
     }

+ 1 - 1
src/mol-plugin/util/viewport-screenshot.ts

@@ -99,7 +99,7 @@ class ViewportScreenshotHelper {
     }
 
     getFilename() {
-        const models = this.plugin.state.dataState.select(StateSelection.Generators.rootsOfType(PluginStateObject.Molecule.Model)).map(s => s.obj!.data)
+        const models = this.plugin.state.data.select(StateSelection.Generators.rootsOfType(PluginStateObject.Molecule.Model)).map(s => s.obj!.data)
         const uniqueIds = new Set<string>()
         models.forEach(m => uniqueIds.add(m.entryId.toUpperCase()))
         const idString = Array.from(uniqueIds.values()).join('-')