Browse Source

Issue #820: callback settings of multiple feature view configs

cycle20 1 year ago
parent
commit
bb41ad4ede
1 changed files with 26 additions and 10 deletions
  1. 26 10
      src/TmFv3DApp/FeatureViewConfig.ts

+ 26 - 10
src/TmFv3DApp/FeatureViewConfig.ts

@@ -1,11 +1,9 @@
 import {
     CustomViewInterface,
-    FeatureBlockInterface,
     FeatureViewInterface
 } from "../RcsbFvSequence/SequenceViews/CustomView/CustomView";
 import {
     RcsbFv,
-    RcsbFvDisplayTypes,
     RcsbFvRowConfigInterface,
     RcsbFvTrackDataElementInterface
 } from "@rcsb/rcsb-saguaro";
@@ -38,13 +36,6 @@ export type TmFvConfigParams = {
 };
 export async function createFeatureViewerConfing(params: TmFvConfigParams) {
 
-    const modelId = `${params.pdbEntry}_model`;
-
-    const fvConfig: FeatureViewInterface<LoadMolstarInterface<unknown,unknown>,LoadMolstarReturnType> =
-        params.fvConfigData.blockConfig[0].featureViewConfig[0];
-
-    setFvConfigCallbacks(fvConfig, modelId, params.labelAsymId);
-
     const customConfig: CustomViewInterface<LoadMolstarInterface<unknown,unknown>,LoadMolstarReturnType> =
         params.fvConfigData;
 
@@ -75,7 +66,18 @@ export async function createFeatureViewerConfing(params: TmFvConfigParams) {
 
     updateSiteColors(params.side1 as any);
 
-    setExternalRowTitleComponent(fvConfig.rowConfig, structureRowClickHandler);
+    // set callbacks and external row title components
+    const modelId = `${params.pdbEntry}_model`;
+    params.fvConfigData.blockConfig.forEach((block: any) => block.featureViewConfig.forEach((featureViewConfig: any, index: number) => {
+        const fvConfig: FeatureViewInterface<LoadMolstarInterface<unknown,unknown>,LoadMolstarReturnType> = featureViewConfig;
+
+        if (index == 0) {
+            setFvConfigCallbacks(fvConfig, modelId, params.labelAsymId);
+        } else {
+            emptyFvConfigCallbacks(fvConfig);
+        }
+        setExternalRowTitleComponent(fvConfig.rowConfig, structureRowClickHandler);
+    }));
 
     return { sequenceConfig: sequenceConfig, molstarConfig: molstarConfig };
 }
@@ -136,6 +138,20 @@ function setFvConfigCallbacks(fvConfig: FeatureViewInterface<LoadMolstarInterfac
 
 }
 
+function emptyFvConfigCallbacks(fvConfig: FeatureViewInterface<LoadMolstarInterface<unknown,unknown>,LoadMolstarReturnType>) {
+    fvConfig.sequenceSelectionChangeCallback = (plugin: StructureViewerPublicInterface<LoadMolstarInterface<unknown,unknown>,LoadMolstarReturnType>, stateManager: RcsbFvStateManager, sequenceRegion: Array<RcsbFvTrackDataElementInterface>) => {
+    };
+    fvConfig.sequenceElementClickCallback = (plugin: StructureViewerPublicInterface<LoadMolstarInterface<unknown,unknown>,LoadMolstarReturnType>, stateManager: RcsbFvStateManager, d: RcsbFvTrackDataElementInterface) => {
+    };
+    fvConfig.sequenceHoverCallback = (plugin: StructureViewerPublicInterface<LoadMolstarInterface<unknown,unknown>,LoadMolstarReturnType>, stateManager: RcsbFvStateManager, elements: Array<RcsbFvTrackDataElementInterface>) => {
+    };
+    fvConfig.structureSelectionCallback = (plugin: StructureViewerPublicInterface<LoadMolstarInterface<unknown,unknown>,LoadMolstarReturnType>, pfv: RcsbFv, stateManager: RcsbFvStateManager) => {
+    };
+    fvConfig.structureHoverCallback = (plugin: StructureViewerPublicInterface<LoadMolstarInterface<unknown,unknown>,LoadMolstarReturnType>, pfv: RcsbFv, stateManager: RcsbFvStateManager) => {
+    };
+
+}
+
 function setExternalRowTitleComponent(rows: RcsbFvRowConfigInterface[], titleClick: (e: React.MouseEvent) => void) {
     rows.forEach(track => {
         if (track.externalRowTitle && (track.externalRowTitle.rowTitleComponent as unknown) == "TmRowTitleComponent") {