Browse Source

mol-plugin: fixed a bug where behaviors were not assigned correct default params

David Sehnal 6 years ago
parent
commit
73a883dfba
3 changed files with 3 additions and 4 deletions
  1. 1 0
      src/mol-plugin/behavior/dynamic/labels.ts
  2. 1 1
      src/mol-plugin/context.ts
  3. 1 3
      src/mol-plugin/index.ts

+ 1 - 0
src/mol-plugin/behavior/dynamic/labels.ts

@@ -74,6 +74,7 @@ function getLabelsText(data: LabelsData, props: PD.Values<Text.Params>, text?: T
 export const SceneLabels = PluginBehavior.create<SceneLabelsProps>({
     name: 'scene-labels',
     display: { name: 'Scene Labels', group: 'Labels' },
+    canAutoUpdate: () => true,
     ctor: class extends PluginBehavior.Handler<SceneLabelsProps> {
         private data: LabelsData = {
             transforms: [Mat4.identity()],

+ 1 - 1
src/mol-plugin/context.ts

@@ -136,7 +136,7 @@ export class PluginContext {
         const tree = this.state.behaviorState.tree.build();
 
         for (const b of this.spec.behaviors) {
-            tree.toRoot().apply(b.transformer, b.defaultParams || { }, { ref: b.transformer.id });
+            tree.toRoot().apply(b.transformer, b.defaultParams, { ref: b.transformer.id });
         }
 
         await this.runTask(this.state.behaviorState.update(tree));

+ 1 - 3
src/mol-plugin/index.ts

@@ -14,8 +14,6 @@ import { PluginSpec } from './spec';
 import { DownloadStructure, CreateComplexRepresentation, OpenStructure } from './state/actions/basic';
 import { StateTransforms } from './state/transforms';
 import { PluginBehaviors } from './behavior';
-import { ParamDefinition as PD } from 'mol-util/param-definition'
-import { SceneLabelsParams } from './behavior/dynamic/labels';
 
 function getParam(name: string, regex: string): string {
     let r = new RegExp(`${name}=(${regex})[&]?`, 'i');
@@ -40,7 +38,7 @@ const DefaultSpec: PluginSpec = {
         PluginSpec.Behavior(PluginBehaviors.Representation.DefaultLociLabelProvider),
         PluginSpec.Behavior(PluginBehaviors.Camera.FocusLociOnSelect, { minRadius: 20, extraRadius: 4 }),
         PluginSpec.Behavior(PluginBehaviors.Animation.StructureAnimation, { rotate: false, rotateValue: 0, explode: false, explodeValue: 0 }),
-        PluginSpec.Behavior(PluginBehaviors.Labels.SceneLabels, { ...PD.getDefaultValues(SceneLabelsParams) }), // TODO how to properly call PluginBehaviors.Labels.SceneLabels.definition.params()
+        PluginSpec.Behavior(PluginBehaviors.Labels.SceneLabels),
         PluginSpec.Behavior(PluginBehaviors.CustomProps.PDBeStructureQualityReport, { autoAttach: true }),
         PluginSpec.Behavior(PluginBehaviors.CustomProps.RCSBAssemblySymmetry, { autoAttach: true }),
     ]