controls.tsx 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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 * as React from 'react';
  7. import { PluginUIComponent } from 'molstar/lib/mol-plugin-ui/base';
  8. import { ViewerState } from '../types';
  9. import { CustomStructureControls } from 'molstar/lib/mol-plugin-ui/controls';
  10. import { ImportControls } from './import';
  11. import { ExportControls } from './export';
  12. import { StructureSourceControls } from 'molstar/lib/mol-plugin-ui/structure/source';
  13. import { StructureMeasurementsControls } from 'molstar/lib/mol-plugin-ui/structure/measurements';
  14. import { StructureSuperpositionControls } from 'molstar/lib/mol-plugin-ui/structure/superposition';
  15. import { StructureComponentControls } from 'molstar/lib/mol-plugin-ui/structure/components';
  16. import { VolumeStreamingControls } from 'molstar/lib/mol-plugin-ui/structure/volume';
  17. import { SessionControls } from './session';
  18. import { StrucmotifSubmitControls } from './strucmotif';
  19. export class StructureTools extends PluginUIComponent {
  20. get customState() {
  21. return ViewerState(this.plugin);
  22. }
  23. componentDidMount() {
  24. this.subscribe(this.customState.collapsed, () => this.forceUpdate());
  25. }
  26. render() {
  27. const collapsed = this.customState.collapsed.value;
  28. return <>
  29. {this.customState.showStructureSourceControls && <StructureSourceControls />}
  30. <StructureMeasurementsControls initiallyCollapsed={collapsed.measurements} />
  31. <StrucmotifSubmitControls initiallyCollapsed={collapsed.strucmotifSubmit} />
  32. {this.customState.showSuperpositionControls && <StructureSuperpositionControls initiallyCollapsed={collapsed.superposition} />}
  33. <StructureComponentControls initiallyCollapsed={collapsed.component} />
  34. <VolumeStreamingControls header='Density' initiallyCollapsed={collapsed.volume} />
  35. <CustomStructureControls initiallyCollapsed={collapsed.custom} />
  36. </>;
  37. }
  38. }
  39. export class ControlsWrapper extends PluginUIComponent {
  40. render() {
  41. return <div className='msp-scrollable-container'>
  42. {ViewerState(this.plugin).showImportControls && <ImportControls />}
  43. {ViewerState(this.plugin).showExportControls && <ExportControls />}
  44. {ViewerState(this.plugin).showSessionControls && <SessionControls />}
  45. <StructureTools />
  46. </div>;
  47. }
  48. }