|
@@ -369,9 +369,15 @@ const TransparencyStructureRepresentation3DFromScript = PluginStateTransform.Bui
|
|
from: SO.Molecule.Structure.Representation3D,
|
|
from: SO.Molecule.Structure.Representation3D,
|
|
to: SO.Molecule.Structure.Representation3DState,
|
|
to: SO.Molecule.Structure.Representation3DState,
|
|
params: {
|
|
params: {
|
|
- script: PD.Script(Script('(sel.atom.all)', 'mol-script')),
|
|
|
|
- value: PD.Numeric(0.75, { min: 0, max: 1, step: 0.01 }, { label: 'Transparency' }),
|
|
|
|
- variant: PD.Select('single', [['single', 'Single-layer'], ['multi', 'Multi-layer']] as ['single' | 'multi', string][])
|
|
|
|
|
|
+ layers: PD.ObjectList({
|
|
|
|
+ script: PD.Script(Script('(sel.atom.all)', 'mol-script')),
|
|
|
|
+ value: PD.Numeric(0.5, { min: 0, max: 1, step: 0.01 }, { label: 'Transparency' }),
|
|
|
|
+ }, e => `Transparency (${e.value})`, {
|
|
|
|
+ defaultValue: [{
|
|
|
|
+ script: Script('(sel.atom.all)', 'mol-script'),
|
|
|
|
+ value: 0.5,
|
|
|
|
+ }]
|
|
|
|
+ })
|
|
}
|
|
}
|
|
})({
|
|
})({
|
|
canAutoUpdate() {
|
|
canAutoUpdate() {
|
|
@@ -379,25 +385,25 @@ const TransparencyStructureRepresentation3DFromScript = PluginStateTransform.Bui
|
|
},
|
|
},
|
|
apply({ a, params }) {
|
|
apply({ a, params }) {
|
|
const structure = a.data.source.data;
|
|
const structure = a.data.source.data;
|
|
- const transparency = Transparency.ofScript(params.script, params.value, params.variant, structure);
|
|
|
|
|
|
+ const transparency = Transparency.ofScript(params.layers, structure);
|
|
|
|
|
|
return new SO.Molecule.Structure.Representation3DState({
|
|
return new SO.Molecule.Structure.Representation3DState({
|
|
state: { transparency },
|
|
state: { transparency },
|
|
initialState: { transparency: Transparency.Empty },
|
|
initialState: { transparency: Transparency.Empty },
|
|
info: structure,
|
|
info: structure,
|
|
source: a
|
|
source: a
|
|
- }, { label: `Transparency (${transparency.value})` });
|
|
|
|
|
|
+ }, { label: `Transparency (${transparency.layers.length} Layers)` });
|
|
},
|
|
},
|
|
update({ a, b, newParams, oldParams }) {
|
|
update({ a, b, newParams, oldParams }) {
|
|
const structure = b.data.info as Structure;
|
|
const structure = b.data.info as Structure;
|
|
if (a.data.source.data !== structure) return StateTransformer.UpdateResult.Recreate;
|
|
if (a.data.source.data !== structure) return StateTransformer.UpdateResult.Recreate;
|
|
const oldTransparency = b.data.state.transparency!;
|
|
const oldTransparency = b.data.state.transparency!;
|
|
- const newTransparency = Transparency.ofScript(newParams.script, newParams.value, newParams.variant, structure);
|
|
|
|
|
|
+ const newTransparency = Transparency.ofScript(newParams.layers, structure);
|
|
if (Transparency.areEqual(oldTransparency, newTransparency)) return StateTransformer.UpdateResult.Unchanged;
|
|
if (Transparency.areEqual(oldTransparency, newTransparency)) return StateTransformer.UpdateResult.Unchanged;
|
|
|
|
|
|
b.data.state.transparency = newTransparency;
|
|
b.data.state.transparency = newTransparency;
|
|
b.data.source = a;
|
|
b.data.source = a;
|
|
- b.label = `Transparency (${newTransparency.value})`;
|
|
|
|
|
|
+ b.label = `Transparency (${newTransparency.layers.length} Layers)`;
|
|
return StateTransformer.UpdateResult.Updated;
|
|
return StateTransformer.UpdateResult.Updated;
|
|
}
|
|
}
|
|
});
|
|
});
|
|
@@ -409,9 +415,16 @@ const TransparencyStructureRepresentation3DFromBundle = PluginStateTransform.Bui
|
|
from: SO.Molecule.Structure.Representation3D,
|
|
from: SO.Molecule.Structure.Representation3D,
|
|
to: SO.Molecule.Structure.Representation3DState,
|
|
to: SO.Molecule.Structure.Representation3DState,
|
|
params: {
|
|
params: {
|
|
- bundle: PD.Value<StructureElement.Bundle>(StructureElement.Bundle.Empty),
|
|
|
|
- value: PD.Numeric(0.75, { min: 0, max: 1, step: 0.01 }, { label: 'Transparency' }),
|
|
|
|
- variant: PD.Select('single', [['single', 'Single-layer'], ['multi', 'Multi-layer']] as ['single' | 'multi', string][])
|
|
|
|
|
|
+ layers: PD.ObjectList({
|
|
|
|
+ bundle: PD.Value<StructureElement.Bundle>(StructureElement.Bundle.Empty),
|
|
|
|
+ value: PD.Numeric(0.5, { min: 0, max: 1, step: 0.01 }, { label: 'Transparency' }),
|
|
|
|
+ }, e => `Transparency (${e.value})`, {
|
|
|
|
+ defaultValue: [{
|
|
|
|
+ bundle: StructureElement.Bundle.Empty,
|
|
|
|
+ value: 0.5,
|
|
|
|
+ }],
|
|
|
|
+ isHidden: true
|
|
|
|
+ })
|
|
}
|
|
}
|
|
})({
|
|
})({
|
|
canAutoUpdate() {
|
|
canAutoUpdate() {
|
|
@@ -419,25 +432,25 @@ const TransparencyStructureRepresentation3DFromBundle = PluginStateTransform.Bui
|
|
},
|
|
},
|
|
apply({ a, params }) {
|
|
apply({ a, params }) {
|
|
const structure = a.data.source.data;
|
|
const structure = a.data.source.data;
|
|
- const transparency = Transparency.ofBundle(params.bundle, params.value, params.variant, structure);
|
|
|
|
|
|
+ const transparency = Transparency.ofBundle(params.layers, structure);
|
|
|
|
|
|
return new SO.Molecule.Structure.Representation3DState({
|
|
return new SO.Molecule.Structure.Representation3DState({
|
|
state: { transparency },
|
|
state: { transparency },
|
|
initialState: { transparency: Transparency.Empty },
|
|
initialState: { transparency: Transparency.Empty },
|
|
info: structure,
|
|
info: structure,
|
|
source: a
|
|
source: a
|
|
- }, { label: `Transparency (${transparency.value})` });
|
|
|
|
|
|
+ }, { label: `Transparency (${transparency.layers.length} Layers)` });
|
|
},
|
|
},
|
|
update({ a, b, newParams, oldParams }) {
|
|
update({ a, b, newParams, oldParams }) {
|
|
const structure = b.data.info as Structure;
|
|
const structure = b.data.info as Structure;
|
|
if (a.data.source.data !== structure) return StateTransformer.UpdateResult.Recreate;
|
|
if (a.data.source.data !== structure) return StateTransformer.UpdateResult.Recreate;
|
|
const oldTransparency = b.data.state.transparency!;
|
|
const oldTransparency = b.data.state.transparency!;
|
|
- const newTransparency = Transparency.ofBundle(newParams.bundle, newParams.value, newParams.variant, structure);
|
|
|
|
|
|
+ const newTransparency = Transparency.ofBundle(newParams.layers, structure);
|
|
if (Transparency.areEqual(oldTransparency, newTransparency)) return StateTransformer.UpdateResult.Unchanged;
|
|
if (Transparency.areEqual(oldTransparency, newTransparency)) return StateTransformer.UpdateResult.Unchanged;
|
|
|
|
|
|
b.data.state.transparency = newTransparency;
|
|
b.data.state.transparency = newTransparency;
|
|
b.data.source = a;
|
|
b.data.source = a;
|
|
- b.label = `Transparency (${newTransparency.value})`;
|
|
|
|
|
|
+ b.label = `Transparency (${newTransparency.layers.length} Layers)`;
|
|
return StateTransformer.UpdateResult.Updated;
|
|
return StateTransformer.UpdateResult.Updated;
|
|
}
|
|
}
|
|
});
|
|
});
|