index.tsx 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. import { DebugUtil } from "../TmFv3DApp/tmdet-extension/debug-utils";
  2. import { fetchDescriptor, registerRegionDescriptorData } from "../TmFv3DApp/UniTmpHelper";
  3. import { updateSiteColors } from "../TmFv3DApp/tmdet-extension/tmdet-color-theme";
  4. import * as React from "react";
  5. import { TmViewer } from "./tmdet-viewer/TmViewer";
  6. import { ViewerProps } from "@rcsb/rcsb-molstar/build/src/viewer";
  7. import { TMDETMembraneOrientation } from "../TmFv3DApp/tmdet-extension/behavior";
  8. import { PluginSpec } from "molstar/lib/mol-plugin/spec";
  9. import { PluginLayoutControlsDisplay } from "molstar/lib/mol-plugin/layout";
  10. import { PluginConfig } from "molstar/lib/mol-plugin/config";
  11. import { ObjectKeys } from "molstar/lib/commonjs/mol-util/type-helpers";
  12. import { PluginContext } from "molstar/lib/mol-plugin/context";
  13. // customElements.define(TmFv1DElement.TagName, TmFv1DElement);
  14. const Extensions = {
  15. 'tmdet-membrane-orientation': PluginSpec.Behavior(TMDETMembraneOrientation)
  16. };
  17. const viewerParams: Partial<ViewerProps> = {
  18. layoutIsExpanded: true,
  19. layoutShowControls: true,
  20. layoutControlsDisplay: 'reactive' as PluginLayoutControlsDisplay,
  21. layoutShowSequence: true,
  22. layoutShowLog: true,
  23. viewportShowExpand: PluginConfig.Viewport.ShowExpand.defaultValue,
  24. viewportShowSelectionMode: PluginConfig.Viewport.ShowSelectionMode.defaultValue,
  25. volumeStreamingServer: PluginConfig.VolumeStreaming.DefaultServer.defaultValue,
  26. };
  27. function createTmdetViewer(elementId: string, configParams: any,
  28. callBack: (ctx:PluginContext) => {},
  29. deferred: boolean = true,
  30. viewerProps: Partial<ViewerProps> = viewerParams) {
  31. if (deferred) {
  32. document.addEventListener("DOMContentLoaded", (event) => {
  33. (async function(event) {
  34. updateSiteColors(configParams.side1);
  35. DebugUtil.enableLog();
  36. const viewer = new TmViewer(elementId, {
  37. ...viewerProps,
  38. layoutShowControls:false,
  39. layoutShowSequence: true,
  40. showWelcomeToast: false,
  41. canvas3d: {
  42. multiSample: {
  43. mode: 'off'
  44. }
  45. }
  46. });
  47. callBack(viewer.plugin);
  48. })();
  49. });
  50. }
  51. }
  52. export {
  53. createTmdetViewer,
  54. DebugUtil
  55. };