types.ts 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /**
  2. * Copyright (c) 2019-2020 mol* contributors, licensed under MIT, See LICENSE file for more info.
  3. *
  4. * @author Alexander Rose <alexander.rose@weirdbyte.de>
  5. */
  6. import { BehaviorSubject } from 'rxjs';
  7. import { ModelLoader } from './helpers/model';
  8. import { PluginContext } from 'molstar/lib/mol-plugin/context';
  9. import { BuiltInTrajectoryFormat } from 'molstar/lib/mol-plugin-state/formats/trajectory';
  10. export type ModelUrlProvider = (pdbId: string) => {
  11. url: string,
  12. format: BuiltInTrajectoryFormat,
  13. isBinary: boolean
  14. }
  15. interface SharedParams {
  16. /** A supported file format extension string */
  17. format: BuiltInTrajectoryFormat,
  18. /** Set to true is the data is binary, e.g. bcif mmCIF files */
  19. isBinary: boolean
  20. }
  21. export interface LoadParams extends SharedParams {
  22. /** A File object or URL representing a structure file */
  23. fileOrUrl: File | string
  24. }
  25. export interface ParseParams extends SharedParams {
  26. /** string for text data, number[] for binary payload */
  27. data: string | number[]
  28. }
  29. export type CollapsedState = {
  30. selection: boolean
  31. strucmotifSubmit: boolean
  32. measurements: boolean
  33. superposition: boolean
  34. component: boolean
  35. volume: boolean
  36. custom: boolean
  37. mp4export: boolean
  38. }
  39. export interface ViewerState {
  40. showImportControls: boolean
  41. showExportControls: boolean
  42. showSessionControls: boolean
  43. showStructureSourceControls: boolean
  44. showSuperpositionControls: boolean
  45. modelLoader: ModelLoader
  46. collapsed: BehaviorSubject<CollapsedState>
  47. detachedFromSierra: boolean
  48. }
  49. export function ViewerState(plugin: PluginContext) {
  50. return plugin.customState as ViewerState;
  51. }