11import React from "react" ;
22import { isEqual , findIndex , map , reduce } from "lodash" ;
33import { v4 as uuidv4 } from "uuid" ;
4-
5- import type {
6- ISimulariumFile ,
7- UIDisplayData ,
8- SelectionStateInfo ,
9- SelectionEntry ,
10- } from "../../type-declarations" ;
11- import { nullAgent , TrajectoryType } from "../../src/constants" ;
12- import SimulariumViewer , {
13- SimulariumController ,
14- RenderStyle ,
15- loadSimulariumFile ,
16- FrontEndError ,
17- ErrorLevel ,
18- NetConnectionParams ,
19- TrajectoryFileInfo ,
20- } from "../../src/index" ;
4+ import { InputParams } from "tweakpane" ;
215
226/**
237 * NOTE: if you are debugging an import/build issue
@@ -32,7 +16,23 @@ import SimulariumViewer, {
3216// FrontEndError,
3317// ErrorLevel,
3418// } from "../es";
35- import "../../style/style.css" ;
19+ import SimulariumViewer , {
20+ SimulariumController ,
21+ RenderStyle ,
22+ loadSimulariumFile ,
23+ FrontEndError ,
24+ ErrorLevel ,
25+ NetConnectionParams ,
26+ TrajectoryFileInfo ,
27+ } from "../../src/index" ;
28+ import { nullAgent , TrajectoryType } from "../../src/constants" ;
29+
30+ import type {
31+ ISimulariumFile ,
32+ UIDisplayData ,
33+ SelectionStateInfo ,
34+ SelectionEntry ,
35+ } from "../../type-declarations" ;
3636import { AgentData } from "../../type-declarations/simularium/types" ;
3737import PointSimulator from "./simulators/PointSimulator" ;
3838import BindingSimulator from "./simulators/BindingSimulator2D" ;
@@ -41,18 +41,25 @@ import PdbSimulator from "./simulators/PdbSimulator";
4141import SinglePdbSimulator from "./simulators/SinglePdbSimulator" ;
4242import CurveSimulator from "./simulators/CurveSimulator" ;
4343import SingleCurveSimulator from "./simulators/SingleCurveSimulator" ;
44- import ColorPicker from "./ColorPicker" ;
45- import RecordMovieComponent from "./RecordMovieComponent" ;
44+ import MetaballSimulator from "./simulators/MetaballSimulator" ;
45+
46+ import ColorPicker from "./Components/ColorPicker" ;
47+ import RecordMovieComponent from "./Components/RecordMovieComponent" ;
48+ import ConversionForm from "./Components/ConversionForm" ;
49+ import AgentMetadata from "./Components/AgentMetadata" ;
50+
51+ import { agentColors } from "./constants" ;
52+ import { BaseType , CustomType } from "./types" ;
4653import {
4754 SMOLDYN_TEMPLATE ,
4855 UI_BASE_TYPES ,
4956 UI_CUSTOM_TYPES ,
5057 UI_TEMPLATE_DOWNLOAD_URL_ROOT ,
5158 UI_TEMPLATE_URL_ROOT ,
5259} from "./api-settings" ;
53- import ConversionForm from "./ConversionForm" ;
54- import MetaballSimulator from "./simulators/MetaballSimulator ";
55- import AgentMetadata from "./AgentMetadata " ;
60+
61+ import "../../style/style.css ";
62+ import "./style.css " ;
5663
5764let playbackFile = "TEST_LIVEMODE_API" ;
5865let queryStringFile = "" ;
@@ -62,26 +69,6 @@ if (urlParams.has("file")) {
6269 playbackFile = queryStringFile ;
6370}
6471
65- const agentColors = [
66- "#fee34d" ,
67- "#f7b232" ,
68- "#bf5736" ,
69- "#94a7fc" ,
70- "#ce8ec9" ,
71- "#58606c" ,
72- "#0ba345" ,
73- "#9267cb" ,
74- "#81dbe6" ,
75- "#bd7800" ,
76- "#bbbb99" ,
77- "#5b79f0" ,
78- "#89a500" ,
79- "#da8692" ,
80- "#418463" ,
81- "#9f516c" ,
82- "#00aabf" ,
83- ] ;
84-
8572interface ViewerState {
8673 renderStyle : RenderStyle ;
8774 particleTypeNames : string [ ] ;
@@ -113,34 +100,6 @@ interface ViewerState {
113100 followObjectData : AgentData ;
114101}
115102
116- interface BaseType {
117- isBaseType : true ;
118- id : string ;
119- data : string ;
120- match : string ;
121- }
122-
123- export interface CustomParameters {
124- name : string ;
125- data_type : string ;
126- description : string ;
127- required : boolean ;
128- help : string ;
129- options ?: string [ ] ;
130- }
131-
132- interface CustomType {
133- [ key : string ] : {
134- "python::module" : string ;
135- "python::object" : string ;
136- parameters : CustomParameters ;
137- } ;
138- }
139-
140- interface InputParams {
141- localBackendServer : boolean ;
142- }
143-
144103const simulariumController = new SimulariumController ( { } ) ;
145104
146105let currentFrame = 0 ;
@@ -386,16 +345,21 @@ class Viewer extends React.Component<InputParams, ViewerState> {
386345 public convertFile ( obj : Record < string , any > , fileType : TrajectoryType ) {
387346 const fileName = uuidv4 ( ) + ".simularium" ;
388347 simulariumController
389- . convertTrajectory ( this . netConnectionSettings , obj , fileType , fileName )
348+ . convertTrajectory (
349+ this . netConnectionSettings ,
350+ obj ,
351+ fileType ,
352+ fileName
353+ )
390354 . then ( ( ) => {
391355 this . clearPendingFile ( ) ;
392356 } )
393357 . then ( ( ) => {
394358 simulariumController . changeFile (
395- { netConnectionSettings : this . netConnectionSettings , } ,
359+ { netConnectionSettings : this . netConnectionSettings } ,
396360 fileName ,
397- true ,
398- )
361+ true
362+ ) ;
399363 } )
400364 . catch ( ( err ) => {
401365 console . error ( err ) ;
@@ -410,7 +374,7 @@ class Viewer extends React.Component<InputParams, ViewerState> {
410374 const simulariumFile = fileName . includes ( ".simularium" )
411375 ? trajectoryFile
412376 : null ;
413- this . setState ( { initialPlay : true } )
377+ this . setState ( { initialPlay : true } ) ;
414378 return simulariumController
415379 . handleFileChange ( simulariumFile , fileName , geoAssets )
416380 . catch ( console . log ) ;
@@ -507,13 +471,18 @@ class Viewer extends React.Component<InputParams, ViewerState> {
507471 [ ]
508472 ) ;
509473 const uniqueTags : string [ ] = [ ...new Set ( allTags ) ] ;
510- if ( isEqual ( uiDisplayData , this . state . selectionStateInfo . appliedColors ) ) {
474+ if (
475+ isEqual ( uiDisplayData , this . state . selectionStateInfo . appliedColors )
476+ ) {
511477 return ;
512478 }
513479 this . setState ( {
514480 particleTypeNames : uiDisplayData . map ( ( a ) => a . name ) ,
515481 particleTypeTags : uniqueTags ,
516- selectionStateInfo : { ...initialState . selectionStateInfo , appliedColors : uiDisplayData } ,
482+ selectionStateInfo : {
483+ ...initialState . selectionStateInfo ,
484+ appliedColors : uiDisplayData ,
485+ } ,
517486 } ) ;
518487 }
519488
@@ -978,24 +947,16 @@ class Viewer extends React.Component<InputParams, ViewerState> {
978947 updateAgentColorArray = { this . updateAgentColorArray }
979948 setColorSelectionInfo = { this . setColorSelectionInfo }
980949 />
981- < button
982- onClick = { ( ) =>
983- this . setRecordingEnabled ( ! this . state . isRecordingEnabled )
984- }
985- >
986- { this . state . isRecordingEnabled ? "Disable" : "Enable" } { " " }
987- Recording
988- </ button >
989- { this . state . isRecordingEnabled && (
990- < RecordMovieComponent
991- startRecordingHandler = {
992- simulariumController . startRecording
993- }
994- stopRecordingHandler = {
995- simulariumController . stopRecording
996- }
997- />
998- ) }
950+ < RecordMovieComponent
951+ startRecordingHandler = { simulariumController . startRecording }
952+ stopRecordingHandler = { simulariumController . stopRecording }
953+ setRecordingEnabled = { ( ) => {
954+ this . setRecordingEnabled (
955+ ! this . state . isRecordingEnabled
956+ ) ;
957+ } }
958+ isRecordingEnabled = { this . state . isRecordingEnabled }
959+ />
999960 < AgentMetadata agentData = { this . state . followObjectData } />
1000961 < div className = "viewer-container" >
1001962 < SimulariumViewer
0 commit comments