From 566c88aca74188b6aa0d89ca6cefb5baa4d0baf3 Mon Sep 17 00:00:00 2001 From: Ben Soares Date: Thu, 27 Oct 2022 11:51:01 +0100 Subject: [PATCH] JAL-4083 Use jmolViewer.scriptWait instead of jmolViewer.evalStringQuiet whilst highlightingt more than one residue --- src/jalview/ext/jmol/JalviewJmolBinding.java | 33 ++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) 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; + } } -- 1.7.10.2