Revision: 20714
          http://sourceforge.net/p/jmol/code/20714
Author:   hansonr
Date:     2015-08-22 04:16:47 +0000 (Sat, 22 Aug 2015)
Log Message:
-----------
Jmol.___JmolVersion="14.3.16_2015.08.21"

new feature: load var x   same as load "@x"
 -- similar to write var x
 
bug fix: creating and running and saving binary hash from PNGJ fails
  -- example:
  
      var x = load("test.png",true)
      load "@x"
      write test2.png as PNGJ
      
bug fix: hover callback is not supposed to be stopped with HOVER OFF
bug fix: atom.sx and atom.sy and atom.sz report incorrectly when antialiasing 
is on
bug fix: write VAR x "test.png" creates a ZIP file instead of a PNGJ file when 
x is from load("test.png",true)

Modified Paths:
--------------
    trunk/Jmol/src/org/jmol/script/ScriptCompiler.java
    trunk/Jmol/src/org/jmol/script/ScriptEval.java
    trunk/Jmol/src/org/jmol/viewer/Jmol.properties

Modified: trunk/Jmol/src/org/jmol/script/ScriptCompiler.java
===================================================================
--- trunk/Jmol/src/org/jmol/script/ScriptCompiler.java  2015-08-22 02:09:08 UTC 
(rev 20713)
+++ trunk/Jmol/src/org/jmol/script/ScriptCompiler.java  2015-08-22 04:16:47 UTC 
(rev 20714)
@@ -1092,6 +1092,7 @@
             String strFormat = script.substring(ichToken, ichToken + cchToken);
             T token = T.getTokenFromName(strFormat.toLowerCase());
             switch (token == null ? T.nada : token.tok) {
+            case T.var:
             case T.menu:
             case T.orientation:
             case T.append:

Modified: trunk/Jmol/src/org/jmol/script/ScriptEval.java
===================================================================
--- trunk/Jmol/src/org/jmol/script/ScriptEval.java      2015-08-22 02:09:08 UTC 
(rev 20713)
+++ trunk/Jmol/src/org/jmol/script/ScriptEval.java      2015-08-22 04:16:47 UTC 
(rev 20714)
@@ -4127,6 +4127,7 @@
     boolean isConcat = false;
     boolean doOrient = false;
     boolean appendNew = vwr.getBoolean(T.appendnew);
+    String filename = null;
     BS bsModels;
     int i = (tokAt(0) == T.data ? 0 : 1);
     String filter = null;
@@ -4185,6 +4186,16 @@
       // load HISTORY
       // load NBO
       switch (tok) {
+      case T.var:
+        String var = paramAsStr(++i);
+        filename = "@" + var;
+        Object o = getVarParameter(var, false);
+        if (o instanceof Map<?, ?>) {
+          checkLength(3);
+          loadPNGJVar(filename, o, htParams);
+          return;
+        }
+        break;
       case T.nbo:
       case T.history:
       case T.menu:
@@ -4339,7 +4350,7 @@
       default:
         modelName = "fileset";
       }
-      if (filenames == null && getToken(i).tok != T.string)
+      if (filename == null && filenames == null && getToken(i).tok != T.string)
         error(ERROR_filenameExpected);
     }
     // long timeBegin = System.currentTimeMillis();
@@ -4360,7 +4371,6 @@
       }
     }
 
-    String filename = null;
     String appendedData = null;
     String appendedKey = null;
 
@@ -4368,8 +4378,8 @@
       // end-of-command options:
       // LOAD SMILES "xxxx" --> load "$xxxx"
 
-      if (i == 0 || filenames == null
-          && (filename = paramAsStr(filePt)).length() == 0)
+      if (filename == null && (i == 0 || filenames == null
+          && (filename = paramAsStr(filePt)).length() == 0))
         filename = getFullPathName();
       if (filename == null && filenames == null) {
         cmdZap(false);
@@ -4401,7 +4411,7 @@
 
       // LOAD "" --> prevous file      
 
-      if ((filename = paramAsStr(filePt)).length() == 0
+      if (filename == null && (filename = paramAsStr(filePt)).length() == 0
           && (filename = getFullPathName()) == null) {
         // no previously loaded file
         cmdZap(false);
@@ -4500,21 +4510,13 @@
       if (isInline) {
         htParams.put("fileData", filename);
       } else if (filename.startsWith("@") && filename.length() > 1) {
-        isVariable = true;
         Object o = getVarParameter(filename.substring(1), false);
         if (o instanceof Map<?, ?>) {
-          SV[] av = new SV[] {SV.newV(T.hash, o)};
-          getCmdExt().dispatch(T.binary, false, av);
-          htParams.put("imageData", av[0].value);
-          OC out = vwr.getOutputChannel(null, null);
-          htParams.put("outputChannel", out);
-          vwr.createZip("", "BINARY", htParams);
-          modelName = "cache://VAR_" + filename;
-          vwr.cacheFileByName("cache://VAR_*",false);
-          vwr.cachePut(modelName, out.toByteArray());
-          cmdScript(0, modelName, null);
+          checkLength(i + 1);
+          loadPNGJVar(filename, o, htParams);
           return;
         }
+        isVariable = true;
         o = "" + o;
         loadScript = new SB().append("{\n    var ")
             .append(filename.substring(1)).append(" = ")
@@ -4665,6 +4667,19 @@
 
   }
 
+  private void loadPNGJVar(String varName, Object o, Map<String, Object> 
htParams) throws ScriptException {
+    SV[] av = new SV[] {SV.newV(T.hash, o)};
+    getCmdExt().dispatch(T.binary, false, av);
+    htParams.put("imageData", av[0].value);
+    OC out = vwr.getOutputChannel(null, null);
+    htParams.put("outputChannel", out);
+    vwr.createZip("", "BINARY", htParams);
+    String modelName = "cache://VAR_" + varName;
+    vwr.cacheFileByName("cache://VAR_*",false);
+    vwr.cachePut(modelName, out.toByteArray());
+    cmdScript(0, modelName, null);
+  }
+
   private String getLoadFilesList(int i, SB loadScript, SB sOptions,
                                 Map<String, Object> htParams, Lst<String> 
fNames) throws ScriptException {
     // list of file names 

Modified: trunk/Jmol/src/org/jmol/viewer/Jmol.properties
===================================================================
--- trunk/Jmol/src/org/jmol/viewer/Jmol.properties      2015-08-22 02:09:08 UTC 
(rev 20713)
+++ trunk/Jmol/src/org/jmol/viewer/Jmol.properties      2015-08-22 04:16:47 UTC 
(rev 20714)
@@ -58,6 +58,9 @@
 
 Jmol.___JmolVersion="14.3.16_2015.08.21"
 
+new feature: load var x   same as load "@x"
+ -- similar to write var x
+ 
 bug fix: creating and running and saving binary hash from PNGJ fails
   -- example:
   

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
_______________________________________________
Jmol-commits mailing list
Jmol-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jmol-commits

Reply via email to