File size: 5,553 Bytes
233f6d4 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 | Clazz.declarePackage ("J.render");
Clazz.load (["J.api.JmolRepaintManager", "JU.BS"], "J.render.RepaintManager", ["java.lang.NullPointerException", "J.api.Interface", "JU.Logger", "JV.JC", "$.Viewer"], function () {
c$ = Clazz.decorateAsClass (function () {
this.vwr = null;
this.shapeManager = null;
this.renderers = null;
this.bsTranslucent = null;
this.holdRepaint = 0;
this.repaintPending = false;
Clazz.instantialize (this, arguments);
}, J.render, "RepaintManager", null, J.api.JmolRepaintManager);
Clazz.prepareFields (c$, function () {
this.bsTranslucent = JU.BS.newN (37);
});
Clazz.makeConstructor (c$,
function () {
});
Clazz.overrideMethod (c$, "set",
function (vwr, shapeManager) {
this.vwr = vwr;
this.shapeManager = shapeManager;
}, "JV.Viewer,JV.ShapeManager");
Clazz.overrideMethod (c$, "isRepaintPending",
function () {
return this.repaintPending;
});
Clazz.overrideMethod (c$, "pushHoldRepaint",
function (why) {
++this.holdRepaint;
}, "~S");
Clazz.overrideMethod (c$, "popHoldRepaint",
function (andRepaint, why) {
--this.holdRepaint;
if (this.holdRepaint <= 0) {
this.holdRepaint = 0;
if (andRepaint) {
this.repaintPending = true;
this.repaintNow (why);
}}}, "~B,~S");
Clazz.overrideMethod (c$, "requestRepaintAndWait",
function (why) {
var jmol = null;
{
jmol = (self.Jmol && Jmol._repaint ? Jmol : null);
}if (jmol != null) {
jmol._repaint (this.vwr.html5Applet, false);
this.repaintDone ();
}{
}}, "~S");
Clazz.overrideMethod (c$, "repaintIfReady",
function (why) {
if (this.repaintPending) return false;
this.repaintPending = true;
if (this.holdRepaint == 0) this.repaintNow (why);
return true;
}, "~S");
Clazz.defineMethod (c$, "repaintNow",
function (why) {
if (!this.vwr.haveDisplay) return;
this.vwr.apiPlatform.repaint (this.vwr.display);
}, "~S");
Clazz.overrideMethod (c$, "repaintDone",
function () {
this.repaintPending = false;
{
}});
Clazz.overrideMethod (c$, "clear",
function (iShape) {
if (this.renderers == null) return;
if (iShape >= 0) this.renderers[iShape] = null;
else for (var i = 0; i < 37; ++i) this.renderers[i] = null;
}, "~N");
Clazz.defineMethod (c$, "getRenderer",
function (shapeID) {
if (this.renderers[shapeID] != null) return this.renderers[shapeID];
var className = JV.JC.getShapeClassName (shapeID, true) + "Renderer";
var renderer;
if ((renderer = J.api.Interface.getInterface (className, this.vwr, "render")) == null) return null;
renderer.setViewerG3dShapeID (this.vwr, shapeID);
return this.renderers[shapeID] = renderer;
}, "~N");
Clazz.overrideMethod (c$, "render",
function (gdata, modelSet, isFirstPass, navMinMax) {
var g3d = gdata;
if (this.renderers == null) this.renderers = new Array (37);
this.getAllRenderers ();
try {
var logTime = this.vwr.getBoolean (603979934);
g3d.renderBackground (null);
if (isFirstPass) {
this.bsTranslucent.clearAll ();
if (navMinMax != null) g3d.renderCrossHairs (navMinMax, this.vwr.getScreenWidth (), this.vwr.getScreenHeight (), this.vwr.tm.getNavigationOffset (), this.vwr.tm.navigationDepthPercent);
var band = this.vwr.getRubberBandSelection ();
if (band != null && g3d.setC (this.vwr.cm.colixRubberband)) g3d.drawRect (band.x, band.y, 0, 0, band.width, band.height);
this.vwr.noFrankEcho = true;
}var msg = null;
for (var i = 0; i < 37 && gdata.currentlyRendering; ++i) {
var shape = this.shapeManager.getShape (i);
if (shape == null) continue;
if (logTime) {
msg = "rendering " + JV.JC.getShapeClassName (i, false);
JU.Logger.startTimer (msg);
}if ((isFirstPass || this.bsTranslucent.get (i)) && this.getRenderer (i).renderShape (g3d, modelSet, shape)) this.bsTranslucent.set (i);
if (logTime) JU.Logger.checkTimer (msg, false);
}
g3d.renderAllStrings (null);
} catch (e) {
if (Clazz.exceptionOf (e, Exception)) {
if (!JV.Viewer.isJS) e.printStackTrace ();
if (this.vwr.async && "Interface".equals (e.getMessage ())) throw new NullPointerException ();
JU.Logger.error ("rendering error? " + e);
} else {
throw e;
}
}
}, "JU.GData,JM.ModelSet,~B,~A");
Clazz.defineMethod (c$, "getAllRenderers",
function () {
var isOK = true;
for (var i = 0; i < 37; ++i) {
if (this.shapeManager.getShape (i) == null || this.getRenderer (i) != null) continue;
isOK = this.repaintPending = !this.vwr.async;
}
if (!isOK) throw new NullPointerException ();
});
Clazz.overrideMethod (c$, "renderExport",
function (gdata, modelSet, params) {
var isOK;
this.shapeManager.finalizeAtoms (null, true);
var exporter3D = this.vwr.initializeExporter (params);
isOK = (exporter3D != null);
if (!isOK) {
JU.Logger.error ("Cannot export " + params.get ("type"));
return null;
}if (this.renderers == null) this.renderers = new Array (37);
this.getAllRenderers ();
var msg = null;
try {
var logTime = this.vwr.getBoolean (603979934);
exporter3D.renderBackground (exporter3D);
for (var i = 0; i < 37; ++i) {
var shape = this.shapeManager.getShape (i);
if (shape == null) continue;
if (logTime) {
msg = "rendering " + JV.JC.getShapeClassName (i, false);
JU.Logger.startTimer (msg);
}this.getRenderer (i).renderShape (exporter3D, modelSet, shape);
if (logTime) JU.Logger.checkTimer (msg, false);
}
exporter3D.renderAllStrings (exporter3D);
msg = exporter3D.finalizeOutput ();
} catch (e) {
if (Clazz.exceptionOf (e, Exception)) {
if (!JV.Viewer.isJS) e.printStackTrace ();
JU.Logger.error ("rendering error? " + e);
} else {
throw e;
}
}
return msg;
}, "JU.GData,JM.ModelSet,java.util.Map");
});
|