|
@@ -29,6 +29,7 @@ import { VolumeRepresentationRegistry } from 'mol-repr/volume/registry';
|
|
|
import { PLUGIN_VERSION, PLUGIN_VERSION_DATE } from './version';
|
|
|
import { PluginLayout } from './layout';
|
|
|
import { List } from 'immutable';
|
|
|
+import { StateTransformParameters } from './ui/state/common';
|
|
|
|
|
|
export class PluginContext {
|
|
|
private disposed = false;
|
|
@@ -87,6 +88,7 @@ export class PluginContext {
|
|
|
}
|
|
|
|
|
|
readonly customModelProperties = new CustomPropertyRegistry();
|
|
|
+ readonly customParamEditors = new Map<string, StateTransformParameters.Class>();
|
|
|
|
|
|
initViewer(canvas: HTMLCanvasElement, container: HTMLDivElement) {
|
|
|
try {
|
|
@@ -136,6 +138,16 @@ export class PluginContext {
|
|
|
this.disposed = true;
|
|
|
}
|
|
|
|
|
|
+ applyTransform(state: State, a: Transform.Ref, transformer: Transformer, params: any) {
|
|
|
+ const tree = state.tree.build().to(a).apply(transformer, params);
|
|
|
+ return PluginCommands.State.Update.dispatch(this, { state, tree });
|
|
|
+ }
|
|
|
+
|
|
|
+ updateTransform(state: State, a: Transform.Ref, params: any) {
|
|
|
+ const tree = state.build().to(a).update(params);
|
|
|
+ return PluginCommands.State.Update.dispatch(this, { state, tree });
|
|
|
+ }
|
|
|
+
|
|
|
private initBuiltInBehavior() {
|
|
|
BuiltInPluginBehaviors.State.registerDefault(this);
|
|
|
BuiltInPluginBehaviors.Representation.registerDefault(this);
|
|
@@ -145,7 +157,7 @@ export class PluginContext {
|
|
|
merge(this.state.dataState.events.log, this.state.behaviorState.events.log).subscribe(e => this.events.log.next(e));
|
|
|
}
|
|
|
|
|
|
- async initBehaviors() {
|
|
|
+ private async initBehaviors() {
|
|
|
const tree = this.state.behaviorState.tree.build();
|
|
|
|
|
|
for (const b of this.spec.behaviors) {
|
|
@@ -155,20 +167,18 @@ export class PluginContext {
|
|
|
await this.runTask(this.state.behaviorState.updateTree(tree, true));
|
|
|
}
|
|
|
|
|
|
- initDataActions() {
|
|
|
+ private initDataActions() {
|
|
|
for (const a of this.spec.actions) {
|
|
|
this.state.dataState.actions.add(a.action);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- applyTransform(state: State, a: Transform.Ref, transformer: Transformer, params: any) {
|
|
|
- const tree = state.tree.build().to(a).apply(transformer, params);
|
|
|
- return PluginCommands.State.Update.dispatch(this, { state, tree });
|
|
|
- }
|
|
|
+ private initCustomParamEditors() {
|
|
|
+ if (!this.spec.customParamEditors) return;
|
|
|
|
|
|
- updateTransform(state: State, a: Transform.Ref, params: any) {
|
|
|
- const tree = state.build().to(a).update(params);
|
|
|
- return PluginCommands.State.Update.dispatch(this, { state, tree });
|
|
|
+ for (const [t, e] of this.spec.customParamEditors) {
|
|
|
+ this.customParamEditors.set(t.id, e);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
constructor(public spec: PluginSpec) {
|
|
@@ -178,6 +188,7 @@ export class PluginContext {
|
|
|
|
|
|
this.initBehaviors();
|
|
|
this.initDataActions();
|
|
|
+ this.initCustomParamEditors();
|
|
|
|
|
|
this.lociLabels = new LociLabelManager(this);
|
|
|
|