|
@@ -1,5 +1,5 @@
|
|
|
/**
|
|
|
- * Copyright (c) 2018-2019 mol* contributors, licensed under MIT, See LICENSE file for more info.
|
|
|
+ * Copyright (c) 2018-2020 mol* contributors, licensed under MIT, See LICENSE file for more info.
|
|
|
*
|
|
|
* @author David Sehnal <david.sehnal@gmail.com>
|
|
|
* @author Alexander Rose <alexander.rose@weirdbyte.de>
|
|
@@ -26,7 +26,8 @@ export function registerDefault(ctx: PluginContext) {
|
|
|
ToggleExpanded(ctx);
|
|
|
ToggleVisibility(ctx);
|
|
|
Highlight(ctx);
|
|
|
- ClearHighlight(ctx);
|
|
|
+ HighlightMany(ctx);
|
|
|
+ ClearHighlights(ctx);
|
|
|
Snapshots(ctx);
|
|
|
}
|
|
|
|
|
@@ -104,28 +105,36 @@ function setVisibilityVisitor(t: StateTransform, tree: StateTree, ctx: { state:
|
|
|
}
|
|
|
|
|
|
export function Highlight(ctx: PluginContext) {
|
|
|
- PluginCommands.State.Highlight.subscribe(ctx, ({ state, ref }) => {
|
|
|
+ PluginCommands.State.Highlight.subscribe(ctx, stateRef => highlight(ctx, [stateRef]));
|
|
|
+}
|
|
|
+
|
|
|
+export function HighlightMany(ctx: PluginContext) {
|
|
|
+ PluginCommands.State.HighlightMany.subscribe(ctx, stateRefPairs => highlight(ctx, stateRefPairs));
|
|
|
+}
|
|
|
+
|
|
|
+function highlight(ctx: PluginContext, stateRefPairs: { state: State, ref: StateTransform.Ref }[]) {
|
|
|
+ ctx.managers.interactivity.lociHighlights.clearHighlights();
|
|
|
+ for (const { state, ref } of stateRefPairs) {
|
|
|
const cell = state.select(ref)[0];
|
|
|
- if (!cell) return;
|
|
|
+ if (!cell) continue;
|
|
|
if (SO.Molecule.Structure.is(cell.obj)) {
|
|
|
- ctx.managers.interactivity.lociHighlights.highlightOnly({ loci: Structure.Loci(cell.obj.data) }, false);
|
|
|
+ ctx.managers.interactivity.lociHighlights.highlight({ loci: Structure.Loci(cell.obj.data) }, false);
|
|
|
} else if (cell && SO.isRepresentation3D(cell.obj)) {
|
|
|
const { repr } = cell.obj.data
|
|
|
- ctx.managers.interactivity.lociHighlights.highlightOnly({ loci: repr.getLoci(), repr }, false);
|
|
|
+ ctx.managers.interactivity.lociHighlights.highlight({ loci: repr.getLoci(), repr }, false);
|
|
|
} else if (SO.Molecule.Structure.Selections.is(cell.obj)) {
|
|
|
- ctx.managers.interactivity.lociHighlights.clearHighlights();
|
|
|
for (const entry of cell.obj.data) {
|
|
|
ctx.managers.interactivity.lociHighlights.highlight({ loci: entry.loci }, false);
|
|
|
}
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- // TODO: highlight volumes?
|
|
|
- // TODO: select structures of subtree?
|
|
|
- });
|
|
|
+ // TODO: highlight volumes?
|
|
|
+ // TODO: select structures of subtree?
|
|
|
}
|
|
|
|
|
|
-export function ClearHighlight(ctx: PluginContext) {
|
|
|
- PluginCommands.State.ClearHighlight.subscribe(ctx, ({ state, ref }) => {
|
|
|
+export function ClearHighlights(ctx: PluginContext) {
|
|
|
+ PluginCommands.State.ClearHighlights.subscribe(ctx, () => {
|
|
|
ctx.managers.interactivity.lociHighlights.clearHighlights();
|
|
|
});
|
|
|
}
|