biojs-vis-pdbviewer
Version:
A BioJS 2.0 component to view protein structures
101 lines (99 loc) • 3.18 kB
JavaScript
Clazz.declarePackage ("J.shapespecial");
Clazz.load (["J.shape.Mesh", "JU.BS", "$.V3", "J.shapespecial.Draw"], "J.shapespecial.DrawMesh", ["JU.AU", "$.P3", "JU.BSUtil"], function () {
c$ = Clazz.decorateAsClass (function () {
this.modelFlags = null;
this.drawType = null;
this.drawTypes = null;
this.ptCenters = null;
this.axis = null;
this.axes = null;
this.drawVertexCount = 0;
this.drawVertexCounts = null;
this.isFixed = false;
this.isVector = false;
this.drawArrowScale = 0;
this.noHead = false;
this.isBarb = false;
this.scale = 1;
this.isScaleSet = false;
this.bsMeshesVisible = null;
Clazz.instantialize (this, arguments);
}, J.shapespecial, "DrawMesh", J.shape.Mesh);
Clazz.prepareFields (c$, function () {
this.drawType = J.shapespecial.Draw.EnumDrawType.NONE;
this.axis = JU.V3.new3 (1, 0, 0);
this.bsMeshesVisible = new JU.BS ();
});
Clazz.makeConstructor (c$,
function (thisID, colix, index) {
Clazz.superConstructor (this, J.shapespecial.DrawMesh, []);
this.mesh1 (thisID, colix, index);
}, "~S,~N,~N");
Clazz.overrideMethod (c$, "clear",
function (meshType) {
this.clearMesh (meshType);
this.scale = 1;
this.isScaleSet = false;
}, "~S");
Clazz.defineMethod (c$, "setCenters",
function () {
if (this.ptCenters == null) this.setCenter (-1);
else for (var i = this.ptCenters.length; --i >= 0; ) this.setCenter (i);
});
Clazz.defineMethod (c$, "setCenter",
function (iModel) {
var center = JU.P3.new3 (0, 0, 0);
var iptlast = -1;
var ipt = 0;
var n = 0;
for (var i = this.pc; --i >= 0; ) {
if (iModel >= 0 && i != iModel || this.pis[i] == null) continue;
iptlast = -1;
for (var iV = (this.drawType === J.shapespecial.Draw.EnumDrawType.POLYGON) ? 3 : this.pis[i].length; --iV >= 0; ) {
ipt = this.pis[i][iV];
if (ipt == iptlast) continue;
iptlast = ipt;
center.add (this.vs[ipt]);
n++;
}
if (n > 0 && (i == iModel || i == 0)) {
center.scale (1.0 / n);
if (this.mat4 != null) this.mat4.rotTrans (center);
break;
}}
if (iModel < 0) {
this.ptCenter.setT (center);
} else {
this.ptCenters[iModel] = center;
}}, "~N");
Clazz.defineMethod (c$, "offset",
function (offset) {
this.rotateTranslate (null, offset, false);
this.setCenters ();
}, "JU.V3");
Clazz.defineMethod (c$, "deleteAtoms",
function (modelIndex) {
if (modelIndex >= this.pc) return;
this.pc--;
this.pis = JU.AU.deleteElements (this.pis, modelIndex, 1);
this.drawTypes = JU.AU.deleteElements (this.drawTypes, modelIndex, 1);
this.drawVertexCounts = JU.AU.deleteElements (this.drawVertexCounts, modelIndex, 1);
this.ptCenters = JU.AU.deleteElements (this.ptCenters, modelIndex, 1);
this.axes = JU.AU.deleteElements (this.axes, modelIndex, 1);
var bs = JU.BSUtil.newAndSetBit (modelIndex);
JU.BSUtil.deleteBits (this.modelFlags, bs);
}, "~N");
Clazz.defineMethod (c$, "isRenderScalable",
function () {
switch (this.drawType) {
case J.shapespecial.Draw.EnumDrawType.ARROW:
return (this.connections != null);
case J.shapespecial.Draw.EnumDrawType.ARC:
case J.shapespecial.Draw.EnumDrawType.CIRCLE:
case J.shapespecial.Draw.EnumDrawType.CIRCULARPLANE:
return true;
default:
return this.haveXyPoints;
}
});
});