molstar
Version:
A comprehensive macromolecular library.
68 lines • 3.23 kB
JavaScript
/**
* Copyright (c) 2020 mol* contributors, licensed under MIT, See LICENSE file for more info.
*
* @author Alexander Rose <alexander.rose@weirdbyte.de>
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.CellPackProvidedColorThemeProvider = exports.CellPackProvidedColorTheme = exports.getCellPackProvidedColorThemeParams = exports.CellPackProvidedColorThemeParams = void 0;
var param_definition_1 = require("../../../mol-util/param-definition");
var color_1 = require("../../../mol-util/color");
var structure_1 = require("../../../mol-model/structure");
var property_1 = require("../property");
var DefaultColor = (0, color_1.Color)(0xCCCCCC);
var Description = 'Gives every model in a CellPack the color provied in the packing data.';
exports.CellPackProvidedColorThemeParams = {};
function getCellPackProvidedColorThemeParams(ctx) {
return exports.CellPackProvidedColorThemeParams; // TODO return copy
}
exports.getCellPackProvidedColorThemeParams = getCellPackProvidedColorThemeParams;
function CellPackProvidedColorTheme(ctx, props) {
var color;
var legend;
var info = ctx.structure && property_1.CellPackInfoProvider.get(ctx.structure).value;
if (ctx.structure && (info === null || info === void 0 ? void 0 : info.colors)) {
var models = ctx.structure.root.models;
var modelColor_1 = new Map();
for (var i = 0, il = models.length; i < il; ++i) {
var idx = structure_1.Model.TrajectoryInfo.get(models[i]).index;
modelColor_1.set(structure_1.Model.TrajectoryInfo.get(models[i]).index, info.colors[idx]);
}
color = function (location) {
if (structure_1.StructureElement.Location.is(location)) {
return modelColor_1.get(structure_1.Model.TrajectoryInfo.get(location.unit.model).index);
}
else if (structure_1.Bond.isLocation(location)) {
return modelColor_1.get(structure_1.Model.TrajectoryInfo.get(location.aUnit.model).index);
}
return DefaultColor;
};
}
else {
color = function () { return DefaultColor; };
}
return {
factory: CellPackProvidedColorTheme,
granularity: 'instance',
color: color,
props: props,
description: Description,
legend: legend
};
}
exports.CellPackProvidedColorTheme = CellPackProvidedColorTheme;
exports.CellPackProvidedColorThemeProvider = {
name: 'cellpack-provided',
label: 'CellPack Provided',
category: "Chain Property" /* Chain */,
factory: CellPackProvidedColorTheme,
getParams: getCellPackProvidedColorThemeParams,
defaultValues: param_definition_1.ParamDefinition.getDefaultValues(exports.CellPackProvidedColorThemeParams),
isApplicable: function (ctx) {
var _a;
return (!!ctx.structure && ctx.structure.elementCount > 0 &&
structure_1.Model.TrajectoryInfo.get(ctx.structure.models[0]).size > 1 &&
!!((_a = property_1.CellPackInfoProvider.get(ctx.structure).value) === null || _a === void 0 ? void 0 : _a.colors));
}
};
//# sourceMappingURL=provided.js.map
;