From: Ben Soares Date: Thu, 27 Oct 2022 10:51:01 +0000 (+0100) Subject: JAL-4083 Use jmolViewer.scriptWait instead of jmolViewer.evalStringQuiet whilst highl... X-Git-Tag: Release_2_11_4_0~520^2~7 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=566c88aca74188b6aa0d89ca6cefb5baa4d0baf3;p=jalview.git JAL-4083 Use jmolViewer.scriptWait instead of jmolViewer.evalStringQuiet whilst highlightingt more than one residue --- diff --git a/src/jalview/ext/jmol/JalviewJmolBinding.java b/src/jalview/ext/jmol/JalviewJmolBinding.java index 895db9a..a40da35 100644 --- a/src/jalview/ext/jmol/JalviewJmolBinding.java +++ b/src/jalview/ext/jmol/JalviewJmolBinding.java @@ -83,6 +83,8 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel public Viewer jmolViewer; + private boolean globalUseScriptWait = false; + public JalviewJmolBinding(StructureSelectionManager ssm, PDBEntry[] pdbentry, SequenceI[][] sequenceIs, DataSourceType protocol) @@ -122,8 +124,21 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel private String jmolScript(String script) { + return jmolScript(script, false); + } + + private String jmolScript(String script, boolean useScriptWait) + { Console.debug(">>Jmol>> " + script); - String s = jmolViewer.evalStringQuiet(script); // scriptWait(script); BH + String s; + if (globalUseScriptWait || useScriptWait) + { + s = jmolViewer.scriptWait(script); + } + else + { + s = jmolViewer.evalStringQuiet(script); // scriptWait(script); BH + } Console.debug("< 1; + boolean prevUseScriptWait = setGlobalUseScriptWait(useScriptWait); if (resetLastRes.length() > 0) { jmolScript(resetLastRes.toString()); @@ -262,14 +279,15 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel for (AtomSpec atom : atoms) { highlightAtom(atom.getAtomIndex(), atom.getPdbResNum(), - atom.getChain(), atom.getPdbFile()); + atom.getChain(), atom.getPdbFile(), useScriptWait); } + setGlobalUseScriptWait(prevUseScriptWait); } } // jmol/ssm only public void highlightAtom(int atomIndex, int pdbResNum, String chain, - String pdbfile) + String pdbfile, boolean useScriptWait) { String modelId = getModelIdForFile(pdbfile); if (modelId.isEmpty()) @@ -295,7 +313,7 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel resetLastRes.append(selection).append(";wireframe 0;").append(selection) .append(" and not hetero; spacefill 0;"); - jmolScript(cmd.toString()); + jmolScript(cmd.toString(), useScriptWait); jmolHistory(true); } @@ -1052,4 +1070,11 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel { return "http://wiki.jmol.org"; // BH 2018 } + + private boolean setGlobalUseScriptWait(boolean b) + { + boolean prev = globalUseScriptWait; + globalUseScriptWait = b; + return prev; + } }