diff --git a/src/mol-plugin/behavior/dynamic/representation.ts b/src/mol-plugin/behavior/dynamic/representation.ts index 9f3a48c3ae6a0795b89798f77d1685aca4d19c54..0d7487265c4790520781859bf68762b80c216e93 100644 --- a/src/mol-plugin/behavior/dynamic/representation.ts +++ b/src/mol-plugin/behavior/dynamic/representation.ts @@ -41,7 +41,7 @@ export const HighlightLoci = PluginBehavior.create({ ctor: class extends PluginBehavior.Handler<HighlightLociProps> { private lociMarkProvider = (interactionLoci: Interactivity.Loci, action: MarkerAction) => { if (!this.ctx.canvas3d) return; - this.ctx.canvas3d.mark({ loci: interactionLoci.loci }, action) + this.ctx.canvas3d.mark({ loci: interactionLoci.loci, repr: interactionLoci.passRepresentation ? interactionLoci.repr : void 0 }, action) } register() { this.subscribeObservable(this.ctx.behaviors.interaction.hover, ({ current, buttons, modifiers }) => { @@ -94,7 +94,7 @@ export const SelectLoci = PluginBehavior.create({ private spine: StateTreeSpine.Impl private lociMarkProvider = (interactionLoci: Interactivity.Loci, action: MarkerAction) => { if (!this.ctx.canvas3d) return; - this.ctx.canvas3d.mark({ loci: interactionLoci.loci }, action) + this.ctx.canvas3d.mark({ loci: interactionLoci.loci, repr: interactionLoci.passRepresentation ? interactionLoci.repr : void 0 }, action) } private applySelectMark(ref: string, clear?: boolean) { const cell = this.ctx.state.dataState.cells.get(ref) diff --git a/src/mol-plugin/behavior/static/state.ts b/src/mol-plugin/behavior/static/state.ts index 22898b19add985c3c6201154834e5b84f575cb14..9fb62474a8099d43537a35198bcf0c85295326a6 100644 --- a/src/mol-plugin/behavior/static/state.ts +++ b/src/mol-plugin/behavior/static/state.ts @@ -102,14 +102,14 @@ 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, ({ state, ref, passRepresentation }) => { const cell = state.select(ref)[0]; if (!cell) return; if (SO.Molecule.Structure.is(cell.obj)) { ctx.interactivity.lociHighlights.highlightOnly({ loci: Structure.Loci(cell.obj.data) }, false); } else if (cell && SO.isRepresentation3D(cell.obj)) { const loci = SO.Molecule.Structure.is(cell.obj.data.source) ? Structure.Loci(cell.obj.data.source.data) : EveryLoci - ctx.interactivity.lociHighlights.highlightOnly({ loci, repr: cell.obj.data.repr }, false); + ctx.interactivity.lociHighlights.highlightOnly({ loci, repr: cell.obj.data.repr, passRepresentation }, false); } // TODO: highlight volumes and shapes? diff --git a/src/mol-plugin/command.ts b/src/mol-plugin/command.ts index a861e3ba3f4b70527e3c06f5a7bda3268467bf2b..096bbf789c6f00d38ac2709a1c8a187188317a88 100644 --- a/src/mol-plugin/command.ts +++ b/src/mol-plugin/command.ts @@ -26,7 +26,7 @@ export const PluginCommands = { ToggleExpanded: PluginCommand<{ state: State, ref: StateTransform.Ref }>(), ToggleVisibility: PluginCommand<{ state: State, ref: StateTransform.Ref }>(), - Highlight: PluginCommand<{ state: State, ref: StateTransform.Ref }>(), + Highlight: PluginCommand<{ state: State, ref: StateTransform.Ref, passRepresentation?: boolean }>(), ClearHighlight: PluginCommand<{ state: State, ref: StateTransform.Ref }>(), Snapshots: { diff --git a/src/mol-plugin/ui/state/tree.tsx b/src/mol-plugin/ui/state/tree.tsx index 870a047460e84dc4a4196db64a42c11007ae3175..0c4a0762978571c37d844678d1f04e1f87d49242 100644 --- a/src/mol-plugin/ui/state/tree.tsx +++ b/src/mol-plugin/ui/state/tree.tsx @@ -193,7 +193,7 @@ class StateTreeNodeLabel extends PluginUIComponent< highlight = (e: React.MouseEvent<HTMLElement>) => { e.preventDefault(); - PluginCommands.State.Highlight.dispatch(this.plugin, { state: this.props.cell.parent, ref: this.ref }); + PluginCommands.State.Highlight.dispatch(this.plugin, { state: this.props.cell.parent, ref: this.ref, passRepresentation: true }); e.currentTarget.blur(); } diff --git a/src/mol-plugin/util/interactivity.ts b/src/mol-plugin/util/interactivity.ts index 7c5751471bfb1236561ad02402ed286041c9e992..b51edb7e90dc81f771a500104ec46b51b4443e11 100644 --- a/src/mol-plugin/util/interactivity.ts +++ b/src/mol-plugin/util/interactivity.ts @@ -42,7 +42,7 @@ class Interactivity { } namespace Interactivity { - export interface Loci<T extends ModelLoci = ModelLoci> { loci: T, repr?: Representation.Any } + export interface Loci<T extends ModelLoci = ModelLoci> { loci: T, repr?: Representation.Any, passRepresentation?: boolean /** = false */ } export namespace Loci { export function areEqual(a: Loci, b: Loci) { @@ -82,9 +82,9 @@ namespace Interactivity { } protected normalizedLoci(interactivityLoci: Loci, applyGranularity = true) { - const { loci, repr } = interactivityLoci + const { loci, repr, passRepresentation } = interactivityLoci const granularity = applyGranularity ? this.props.granularity : undefined - return { loci: ModelLoci.normalize(loci, granularity), repr } + return { loci: ModelLoci.normalize(loci, granularity), repr, passRepresentation } } protected mark(current: Loci<ModelLoci>, action: MarkerAction) { @@ -124,7 +124,7 @@ namespace Interactivity { if (StructureElement.Loci.is(normalized.loci)) { const loci = this.sel.tryGetRange(normalized.loci) || normalized.loci; this.mark(this.prev, MarkerAction.RemoveHighlight); - const toHighlight = { loci, repr: normalized.repr }; + const toHighlight = { loci, repr: normalized.repr, passRepresentation: normalized.passRepresentation }; this.mark(toHighlight, MarkerAction.Highlight); this.prev = toHighlight; }