pdbe-molstar
Version:
Molstar implementation for PDBe
65 lines (64 loc) • 3.4 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.StateGalleryExtensionFunctions = exports.StateGallery = exports.StateGalleryCustomState = exports.StateGalleryExtensionName = void 0;
const behavior_1 = require("molstar/lib/mol-plugin/behavior");
const mol_util_1 = require("molstar/lib/mol-util");
const param_definition_1 = require("molstar/lib/mol-util/param-definition");
const rxjs_1 = require("rxjs");
const plugin_custom_state_1 = require("../../plugin-custom-state");
const manager_1 = require("./manager");
const ui_1 = require("./ui");
/** Name used when registering extension, custom controls, etc. */
exports.StateGalleryExtensionName = 'pdbe-state-gallery';
exports.StateGalleryCustomState = plugin_custom_state_1.ExtensionCustomState.getter(exports.StateGalleryExtensionName);
/** `StateGallery` extension allows browsing pre-computed 3D states for a PDB entry */
exports.StateGallery = behavior_1.PluginBehavior.create({
name: exports.StateGalleryExtensionName,
category: 'misc',
display: {
name: '3D State Gallery',
description: 'Browse pre-computed 3D states for a PDB entry',
},
ctor: class extends behavior_1.PluginBehavior.Handler {
register() {
(0, exports.StateGalleryCustomState)(this.ctx).requestedImage = new rxjs_1.BehaviorSubject(undefined);
(0, exports.StateGalleryCustomState)(this.ctx).manager = new rxjs_1.BehaviorSubject(undefined);
(0, exports.StateGalleryCustomState)(this.ctx).status = new rxjs_1.BehaviorSubject('ready');
this.toggleStructureControls(this.params.showControls);
this.toggleTitleBox(this.params.showTitleBox);
}
update(p) {
if ((0, mol_util_1.shallowEqual)(p, this.params))
return false;
this.toggleStructureControls(p.showControls);
this.toggleTitleBox(p.showTitleBox);
this.params = p;
return true;
}
unregister() {
this.toggleStructureControls(false);
this.toggleTitleBox(false);
plugin_custom_state_1.ExtensionCustomState.clear(this.ctx, exports.StateGalleryExtensionName);
}
/** Register/unregister custom structure controls */
toggleStructureControls(show) {
plugin_custom_state_1.PluginCustomControls.toggle(this.ctx, 'structure-tools', exports.StateGalleryExtensionName, ui_1.StateGalleryControls, show);
}
/** Register/unregister title box */
toggleTitleBox(show) {
plugin_custom_state_1.PluginCustomControls.toggle(this.ctx, 'viewport-top-center', exports.StateGalleryExtensionName, ui_1.StateGalleryTitleBox, show);
}
},
params: () => ({
showControls: param_definition_1.ParamDefinition.Boolean(true, { description: 'Show "3D State Gallery" section in Structure Tools controls' }),
showTitleBox: param_definition_1.ParamDefinition.Boolean(true, { description: 'Show a box in viewport with state title and arrows to move between states' }),
}),
});
/** Public functions provided by the `StateGallery` extension */
exports.StateGalleryExtensionFunctions = {
StateGalleryManager: manager_1.StateGalleryManager,
StateGalleryCustomState: exports.StateGalleryCustomState,
UI: {
StateGalleryControls: ui_1.StateGalleryControls,
},
};