David Sehnal 6 年 前
コミット
0a0612baed

+ 2 - 0
src/mol-plugin/behavior/static/representation.ts

@@ -18,6 +18,8 @@ export function SyncRepresentationToCanvas(ctx: PluginContext) {
         ctx.canvas3d.add(e.obj.data);
         ctx.canvas3d.requestDraw(true);
 
+        console.log(e.obj.data);
+
         // TODO: update visiblity
     });
     events.object.updated.subscribe(e => {

+ 4 - 0
src/mol-state/reducer.ts

@@ -0,0 +1,4 @@
+// TODO: state reducers
+// The idea is to have "reduced"/computed objects from a state
+// basicaly something like this Reduce(selection: StateSelection) => Value
+// the reducer would be automatically called each time a state update is finished and any object of the selection is updated.

+ 12 - 2
src/mol-util/param-definition.ts

@@ -90,7 +90,17 @@ export namespace ParamDefinition {
         return { type: 'interval', label, description, defaultValue }
     }
 
-    export type Any = /* GenericValue<any> | */ Select<any> | MultiSelect<any> | Boolean | Range | Text | Color | Numeric | Interval
+    export interface Obj<P extends Params> extends Base<{ [K in keyof P]: P[K]['defaultValue']}> {
+        type: 'obj',
+        pivot?: keyof P,
+        params: P
+    }
+    export function Obj<P extends Params>(label: string, description: string, params: P, pivot?: keyof P): Obj<P> {
+        return { type: 'obj', label, description, defaultValue: getDefaultValues(params), params, pivot };
+    }
+
+    export type Any = Select<any> | MultiSelect<any> | Boolean | Range | Text | Color | Numeric | Interval | Obj<any>
+
     export type Params = { [k: string]: Any }
     export type DefaultValues<T extends Params> = { [k in keyof T]: T[k]['defaultValue'] }
 
@@ -117,7 +127,7 @@ export namespace ParamDefinition {
         definition?(a: A, globalCtx: Ctx): { [K in keyof P]?: Any },
         /** Check the parameters and return a list of errors if the are not valid. */
         validate?(params: P, a: A, globalCtx: unknown): ParamErrors | undefined,
-        /** Optional custom parameter equality. Use deep structural equal by default. */
+        /** Optional custom parameter equality. Use shallow structural equal by default. */
         areEqual?(oldParams: P, newParams: P): boolean
     }
 }