瀏覽代碼

added base geo params to shape repr transform

Alexander Rose 6 年之前
父節點
當前提交
d7bc5a6dca
共有 1 個文件被更改,包括 12 次插入1 次删除
  1. 12 1
      src/mol-plugin/state/transforms/representation.ts

+ 12 - 1
src/mol-plugin/state/transforms/representation.ts

@@ -28,6 +28,7 @@ import { StructureUnitTransforms } from 'mol-model/structure/structure/util/unit
 import { unwindStructureAssembly, explodeStructure, getStructureOverpaint } from '../animation/helpers';
 import { Color } from 'mol-util/color';
 import { Overpaint } from 'mol-theme/overpaint';
+import { BaseGeometry } from 'mol-geo/geometry/base';
 
 export { StructureRepresentation3D }
 export { StructureRepresentation3DHelpers }
@@ -481,9 +482,12 @@ const ShapeRepresentation3D = PluginStateTransform.BuiltIn({
     from: SO.Shape.Provider,
     to: SO.Shape.Representation3D,
     params: (a, ctx: PluginContext) => {
-        return { }
+        return BaseGeometry.Params
     }
 })({
+    canAutoUpdate() {
+        return true;
+    },
     apply({ a, params }, plugin: PluginContext) {
         return Task.create('Shape Representation', async ctx => {
             const props = { ...PD.getDefaultValues(a.data.geometryUtils.Params), params }
@@ -492,5 +496,12 @@ const ShapeRepresentation3D = PluginStateTransform.BuiltIn({
             await repr.createOrUpdate(props, a.data.data).runInContext(ctx);
             return new SO.Shape.Representation3D({ repr, source: a }, { label: a.data.label });
         });
+    },
+    update({ a, b, oldParams, newParams }, plugin: PluginContext) {
+        return Task.create('Shape Representation', async ctx => {
+            const props = { ...b.data.repr.props, ...newParams }
+            await b.data.repr.createOrUpdate(props, a.data.data).runInContext(ctx);
+            return StateTransformer.UpdateResult.Updated;
+        });
     }
 });