|
@@ -13,23 +13,10 @@ import { UpdateTrajectory } from 'mol-plugin/state/actions/basic';
|
|
|
import { PluginComponent } from './base';
|
|
|
|
|
|
export class Controls extends PluginComponent<{ }, { }> {
|
|
|
- state = { id: '1grm' };
|
|
|
-
|
|
|
- private _snap: any = void 0;
|
|
|
- private getSnapshot = () => {
|
|
|
- this._snap = this.plugin.state.getSnapshot();
|
|
|
- console.log(btoa(JSON.stringify(this._snap)));
|
|
|
- }
|
|
|
- private setSnapshot = () => {
|
|
|
- if (!this._snap) return;
|
|
|
- this.plugin.state.setSnapshot(this._snap);
|
|
|
- }
|
|
|
-
|
|
|
render() {
|
|
|
- return <div>
|
|
|
- <button onClick={this.getSnapshot}>Get Snapshot</button>
|
|
|
- <button onClick={this.setSnapshot}>Set Snapshot</button>
|
|
|
- </div>;
|
|
|
+ return <>
|
|
|
+
|
|
|
+ </>;
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -163,66 +150,4 @@ export class _test_UpdateTransform extends PluginComponent<{ state: State, nodeR
|
|
|
<button onClick={() => this.update()} style={{ width: '100%' }}>Update</button>
|
|
|
</div>
|
|
|
}
|
|
|
-}
|
|
|
-
|
|
|
-export class CameraSnapshots extends PluginComponent<{ }, { }> {
|
|
|
- render() {
|
|
|
- return <div>
|
|
|
- <h3>Camera Snapshots</h3>
|
|
|
- <CameraSnapshotControls />
|
|
|
- <CameraSnapshotList />
|
|
|
- </div>;
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-class CameraSnapshotControls extends PluginComponent<{ }, { name: string, description: string }> {
|
|
|
- componentDidMount() {
|
|
|
- this.subscribe(this.plugin.events.state.cameraSnapshots.changed, () => this.forceUpdate());
|
|
|
- }
|
|
|
-
|
|
|
- state = { name: '', description: '' };
|
|
|
-
|
|
|
- add = () => {
|
|
|
- PluginCommands.Camera.Snapshots.Add.dispatch(this.plugin, this.state);
|
|
|
- this.setState({ name: '', description: '' })
|
|
|
- }
|
|
|
-
|
|
|
- clear = () => {
|
|
|
- PluginCommands.Camera.Snapshots.Clear.dispatch(this.plugin, {});
|
|
|
- }
|
|
|
-
|
|
|
- render() {
|
|
|
- return <div>
|
|
|
- <input type='text' value={this.state.name} placeholder='Name...' style={{ width: '33%', display: 'block', float: 'left' }} onChange={e => this.setState({ name: e.target.value })} />
|
|
|
- <input type='text' value={this.state.description} placeholder='Description...' style={{ width: '67%', display: 'block' }} onChange={e => this.setState({ description: e.target.value })} />
|
|
|
- <button style={{ float: 'right' }} onClick={this.clear}>Clear</button>
|
|
|
- <button onClick={this.add}>Add</button>
|
|
|
- </div>;
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-class CameraSnapshotList extends PluginComponent<{ }, { }> {
|
|
|
- componentDidMount() {
|
|
|
- this.subscribe(this.plugin.events.state.cameraSnapshots.changed, () => this.forceUpdate());
|
|
|
- }
|
|
|
-
|
|
|
- apply(id: string) {
|
|
|
- return () => PluginCommands.Camera.Snapshots.Apply.dispatch(this.plugin, { id });
|
|
|
- }
|
|
|
-
|
|
|
- remove(id: string) {
|
|
|
- return () => {
|
|
|
- PluginCommands.Camera.Snapshots.Remove.dispatch(this.plugin, { id });
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- render() {
|
|
|
- return <ul style={{ listStyle: 'none' }}>
|
|
|
- {this.plugin.state.cameraSnapshots.entries.valueSeq().map(e =><li key={e!.id}>
|
|
|
- <button onClick={this.apply(e!.id)}>Set</button>
|
|
|
- {e!.name} <small>{e!.description}</small>
|
|
|
- <button onClick={this.remove(e!.id)} style={{ float: 'right' }}>X</button>
|
|
|
- </li>)}
|
|
|
- </ul>;
|
|
|
- }
|
|
|
}
|