@@ -5,6 +5,7 @@ import { MVSData } from 'molstar/lib/extensions/mvs/mvs-data';
5
5
import { MolstarSubtree } from 'molstar/lib/extensions/mvs/tree/molstar/molstar-tree' ;
6
6
import { ColorT } from 'molstar/lib/extensions/mvs/tree/mvs/param-types' ;
7
7
import { ShapeRepresentation3D } from 'molstar/lib/mol-plugin-state/transforms/representation' ;
8
+ import { setSubtreeVisibility } from 'molstar/lib/mol-plugin/behavior/static/state' ;
8
9
import { PDBeMolstarPlugin } from '../..' ;
9
10
import { QueryParam , queryParamsToMvsComponentExpressions } from '../../helpers' ;
10
11
import { ExtensionCustomState } from '../../plugin-custom-state' ;
@@ -27,18 +28,20 @@ export interface Interaction {
27
28
export interface StateObjectHandle {
28
29
/** State transform reference */
29
30
ref : string ,
31
+ /** Set state object visibility on/off */
32
+ setVisibility ( visible : boolean ) : void ,
30
33
/** Remove state object from state hierarchy */
31
34
delete : ( ) => Promise < void > ,
32
35
}
33
36
34
- export function loadInteractions_example ( viewer : PDBeMolstarPlugin ) {
37
+ export function loadInteractions_example ( viewer : PDBeMolstarPlugin ) : Promise < StateObjectHandle > {
35
38
return loadInteractions ( viewer , { interactions : exampleData } ) ;
36
39
}
37
40
38
- export async function loadInteractionsFromApi ( viewer : PDBeMolstarPlugin , params : { pdbId : string , authAsymId : string , authSeqId : number , structureId ?: string } ) {
41
+ export async function loadInteractionsFromApi ( viewer : PDBeMolstarPlugin , params : { pdbId : string , authAsymId : string , authSeqId : number , structureId ?: string } ) : Promise < StateObjectHandle > {
39
42
const data = await getInteractionApiData ( { ...params , pdbeBaseUrl : viewer . initParams . pdbeUrl } ) ;
40
43
const interactions = interactionsFromApiData ( data , params . pdbId ) ;
41
- await loadInteractions ( viewer , { interactions, structureId : params . structureId } ) ;
44
+ return await loadInteractions ( viewer , { interactions, structureId : params . structureId } ) ;
42
45
}
43
46
44
47
/** Show custom atom interactions */
@@ -58,6 +61,7 @@ export async function loadInteractions(viewer: PDBeMolstarPlugin, params: { inte
58
61
59
62
const visual : StateObjectHandle = {
60
63
ref : data . ref ,
64
+ setVisibility : ( visible : boolean ) => setSubtreeVisibility ( viewer . plugin . state . data , data . ref , ! visible /* true means hidden */ ) ,
61
65
delete : ( ) => viewer . plugin . build ( ) . delete ( data . ref ) . commit ( ) ,
62
66
} ;
63
67
const visualsList = getExtensionCustomState ( viewer . plugin ) . visuals ??= [ ] ;
0 commit comments