Skip to content

Commit 67fabd6

Browse files
committed
Added .visual.interactivityFocus method
1 parent cb04546 commit 67fabd6

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
All notable changes to this project will be documented in this file, following the suggestions of [Keep a CHANGELOG](http://keepachangelog.com/). This project adheres to [Semantic Versioning](http://semver.org/) for its most widely used - and defacto - public interfaces.
33

44
## [Unreleased]
5+
- `.visual.interactivityFocus` method
56

67
## [v3.3.2] - 2024-11-25
78
- Fixed Domain Annotations crashing when no domains available

index.html

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,14 @@ <h4>Focus</h4>
109109
Focus on Chain A:14-18
110110
</button>
111111

112+
<h4>Interactivity focus</h4>
113+
<button onclick="viewerInstance.visual.interactivityFocus({ data: [{ struct_asym_id: 'A', start_residue_number: 14, end_residue_number: 18 }] });">
114+
Int. focus on Chain A:14-18
115+
</button>
116+
<button onclick="viewerInstance.visual.interactivityFocus({ data: [] });">
117+
Int. unfocus
118+
</button>
119+
112120
<h4>Highlight</h4>
113121
<button onclick="viewerInstance.visual.highlight({ data: [{ struct_asym_id: 'A', start_residue_number: 14, end_residue_number: 18 }], color: '#ffff00' })">
114122
Highlight Chain A:14-18
@@ -139,6 +147,7 @@ <h4>Selection</h4>
139147
<button onclick="viewerInstance.visual.select({ data: [
140148
{ struct_asym_id: 'B', start_residue_number: 1, end_residue_number: 6, color: '#ffff00', sideChain: true },
141149
{ struct_asym_id: 'B', start_residue_number: 15, end_residue_number: 20, color: '#88ff00', representation: 'spacefill', representationColor: '#ff00ff' }]})">
150+
Select Chain B:1-6, B:15-20, with representations
142151
</button>
143152
<br>
144153
<button onclick="viewerInstance.visual.select({ data: [{ uniprot_accession: 'P02070', start_uniprot_residue_number: 122, end_uniprot_residue_number: 142, color: '#ff00ff' }], nonSelectedColor: '#ffffff' })">

src/app/viewer.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -694,6 +694,18 @@ export class PDBeMolstarPlugin {
694694
this.plugin.managers.camera.focusLoci(loci);
695695
},
696696

697+
/** Apply interactive focus behavior on the part of the structure defined by `data` (i.e. emulate user clicking on a substructure).
698+
* This includes behaviors like "show non-covalent interactions" or "show streamed volume data"
699+
* but not camera adjustment (call `.visual.focus` for that).
700+
* If `data` contains more items, focus on the union of those.
701+
* If `structureId` or `structureNumber` is provided, use the specified structure (numbered from 1!);
702+
* otherwise use the last added structure. */
703+
interactivityFocus: async (params: { data: QueryParam[], structureId?: string, structureNumber?: number }) => {
704+
const structureNumberOrId = params.structureId ?? params.structureNumber;
705+
const loci = this.getLociForParams(params.data, structureNumberOrId);
706+
this.plugin.managers.structure.focus.setFromLoci(loci);
707+
},
708+
697709
/** Trigger highlight on the part of the structure defined by `data`
698710
* (this will look the same as when the user hovers over a part of the structure).
699711
* If `focus`, also zoom on the highlighted part.

0 commit comments

Comments
 (0)