-
Alexander Rose authoredAlexander Rose authored
context.ts 6.50 KiB
/**
* Copyright (c) 2018 mol* contributors, licensed under MIT, See LICENSE file for more info.
*
* @author David Sehnal <david.sehnal@gmail.com>
*/
import { Canvas3D } from 'mol-canvas3d/canvas3d';
import { EmptyLoci, Loci } from 'mol-model/loci';
import { Representation } from 'mol-repr/representation';
import { StructureRepresentationRegistry } from 'mol-repr/structure/registry';
import { State, Transform, Transformer } from 'mol-state';
import { Task } from 'mol-task';
import { ColorTheme } from 'mol-theme/color';
import { SizeTheme } from 'mol-theme/size';
import { ThemeRegistryContext } from 'mol-theme/theme';
import { LogEntry } from 'mol-util/log-entry';
import { RxEventHelper } from 'mol-util/rx-event-helper';
import { merge } from 'rxjs';
import { BuiltInPluginBehaviors } from './behavior';
import { PluginCommand, PluginCommands } from './command';
import { PluginSpec } from './spec';
import { PluginState } from './state';
import { TaskManager } from './util/task-manager';
import { Color } from 'mol-util/color';
import { LociLabelEntry, LociLabelManager } from './util/loci-label-manager';
import { ajaxGet } from 'mol-util/data-source';
import { CustomPropertyRegistry } from './util/custom-prop-registry';
export class PluginContext {
private disposed = false;
private ev = RxEventHelper.create();
private tasks = new TaskManager();
readonly state = new PluginState(this);
readonly commands = new PluginCommand.Manager();
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),
},
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)
},
cameraSnapshots: this.state.cameraSnapshots.events,
snapshots: this.state.snapshots.events,
},
log: this.ev<LogEntry>(),
task: this.tasks.events,
labels: {
highlight: this.ev<{ entries: ReadonlyArray<LociLabelEntry> }>()
},
canvad3d: {
settingsUpdated: this.ev()
}
};
readonly behaviors = {
canvas: {
highlightLoci: this.ev.behavior<{ loci: Loci, repr?: Representation.Any }>({ loci: EmptyLoci }),
selectLoci: this.ev.behavior<{ loci: Loci, repr?: Representation.Any }>({ loci: EmptyLoci }),
},
command: this.commands.behaviour
};
readonly canvas3d: Canvas3D;