From: <ha...@us...> - 2007-05-08 23:47:00
|
Revision: 7643 http://svn.sourceforge.net/jmol/?rev=7643&view=rev Author: hansonr Date: 2007-05-08 16:46:45 -0700 (Tue, 08 May 2007) Log Message: ----------- 11.1.36 adds zoomTo (atom expression) 0 with options zoomTo (atom expression) 0+n zoomTo (atom expression) 0-n zoomTo (atom expression) 0*n zoomTo (atom expression) 0/n also moveTo timeSec {x y z w} (atom expression) [zoom factor] and moveTo timeSec {x y z w} 0 transX transY (atom expression) [zoom factor] where [zoom factor] is x, where x > 0 or [0] [[+ | - | * | /] x] Modified Paths: -------------- trunk/Jmol/src/org/jmol/viewer/Eval.java Modified: trunk/Jmol/src/org/jmol/viewer/Eval.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Eval.java 2007-05-08 21:52:24 UTC (rev 7642) +++ trunk/Jmol/src/org/jmol/viewer/Eval.java 2007-05-08 23:46:45 UTC (rev 7643) @@ -2441,6 +2441,9 @@ void moveto() throws ScriptException { //moveto time //moveto [time] { x y z deg} zoom xTrans yTrans (rotCenter) rotationRadius (navCenter) xNav yNav navDepth + //moveto [time] { x y z deg} 0 xTrans yTrans (rotCenter) [zoom factor] (navCenter) xNav yNav navDepth + //moveto [time] { x y z deg} (rotCenter) [zoom factor] (navCenter) xNav yNav navDepth + //where zoom factor is z [[+|-|*|/] n] including 0 //moveto [time] front|back|left|right|top|bottom if (statementLength == 2 && isFloatParameter(1)) { float f = floatParameter(1); @@ -2458,7 +2461,7 @@ float floatSecondsTotal = (isFloatParameter(i) ? floatParameter(i++) : 2.0f); if (floatSecondsTotal < 0) invalidArgument(); - float zoom = 100; + float zoom = Float.NaN; float xTrans = 0; float yTrans = 0; float degrees = 90; @@ -2512,10 +2515,9 @@ boolean isChange = !viewer.isInPosition(pt, degrees); //zoom xTrans yTrans (center) rotationRadius + float zoom0 = viewer.getZoomPercentFloat(); if (i != statementLength && !isCenterParameter(i)) { zoom = floatParameter(i++); - if (!isChange && Math.abs(zoom - viewer.getZoomPercentFloat()) >= 1) - isChange = true; } if (i != statementLength && !isCenterParameter(i)) { xTrans = floatParameter(i++); @@ -2527,16 +2529,33 @@ } float rotationRadius = 0; if (i != statementLength) { + int ptCenter = i; center = centerParameter(i); - i = iToken + 1; - if (i != statementLength && !isCenterParameter(i)) - rotationRadius = floatParameter(i++); if (!isChange && center.distance(viewer.getRotationCenter()) >= 0.1) isChange = true; - if (!isChange - && Math.abs(rotationRadius - viewer.getRotationRadius()) >= 0.1) - isChange = true; + i = iToken + 1; + float radius = viewer.getRotationRadius(); + if (i != statementLength && !isCenterParameter(i)) { + //alternative (center) zoomFactor + if (zoom == 0 || Float.isNaN(zoom)) { + //alternative (atom expression) zoom + float factor = getZoomFactor(i, ptCenter, radius, zoom0); + i = iToken + 1; + if (Float.isNaN(factor)) + invalidArgument(); + zoom = factor; + } else { + rotationRadius = floatParameter(i++); + if (!isChange + && Math.abs(rotationRadius - viewer.getRotationRadius()) >= 0.1) + isChange = true; + } + } } + if (zoom ==0 || Float.isNaN(zoom)) + zoom = 100; + if (!isChange && Math.abs(zoom - zoom0) >= 1) + isChange = true; // (navCenter) xNav yNav navDepth Point3f navCenter = null; @@ -4483,9 +4502,45 @@ boolean isSameAtom = (center != null && currentCenter.distance(center) < 0.1); + //zoom/zoomTo percent|-factor|+factor|*factor|/factor | 0 - float factor0 = zoom; - float factor = (isFloatParameter(i) ? floatParameter(i++) : Float.NaN); + float factor = getZoomFactor(i, ptCenter, radius, zoom); + + if (Float.isNaN(factor) && isZoomTo) { + // no factor -- check for no center (zoom out) or same center (zoom in) + if (statementLength == 1 || isSameAtom) + factor *= 2; + else if (center == null) + factor /= 2; + else + factor = zoom; + } + float xTrans = 0; + float yTrans = 0; + float max = viewer.getMaxZoomPercent(); + if (factor < 5 || factor > max) + numberOutOfRange(5, max); + if (!viewer.isWindowCentered()) { + // do a smooth zoom only if not windowCentered + if (center != null) { + BitSet bs = expression(ptCenter); + if (!isSyntaxCheck) + viewer.setCenterBitSet(bs, false); + } + center = viewer.getRotationCenter(); + xTrans = viewer.getTranslationXPercent(); + yTrans = viewer.getTranslationYPercent(); + } + if (isSyntaxCheck) + return; + if (isSameAtom && Math.abs(zoom - factor) < 1) + time = 0; + viewer.moveTo(time, center, new Point3f(0, 0, 0), Float.NaN, factor, + xTrans, yTrans, radius, null, Float.NaN, Float.NaN, Float.NaN); + } + + float getZoomFactor(int i, int ptCenter, float radius, float factor0) throws ScriptException { + float factor = (isFloatParameter(i) ? floatParameter(i) : Float.NaN); if (factor == 0) { BitSet bs = null; switch (statement[ptCenter].tok) { @@ -4496,16 +4551,17 @@ if (bs == null) invalidArgument(); float r = viewer.calcRotationRadius(bs); - factor0 = radius / r * 100; - factor = (isFloatParameter(i) ? floatParameter(i++) : Float.NaN); + factor0 = radius / r * 100; + factor = Float.NaN; + i++; } if (factor < 0) { factor += factor0; } else if (Float.isNaN(factor)) { factor = factor0; if (isFloatParameter(i + 1)) { - float value = floatParameter(i + 1); - switch (getToken(i).tok) { + float value = floatParameter(i+1); + switch (getToken(i++).tok) { case Token.slash: factor /= value; break; @@ -4518,38 +4574,14 @@ default: invalidArgument(); } - } else if (isZoomTo) { - // no factor -- check for no center (zoom out) or same center (zoom in) - if (statementLength == 1 || isSameAtom) - factor *= 2; - else if (center == null) - factor /= 2; + } else { + --i; } } - float xTrans = 0; - float yTrans = 0; - float max = viewer.getMaxZoomPercent(); - if (factor < 5 || factor > max) - numberOutOfRange(5, max); - if (!viewer.isWindowCentered()) { - // do a smooth zoom only if not windowCentered - if (center != null) { - BitSet bs = expression(ptCenter); - if (!isSyntaxCheck) - viewer.setCenterBitSet(bs, false); - } - center = viewer.getRotationCenter(); - xTrans = viewer.getTranslationXPercent(); - yTrans = viewer.getTranslationYPercent(); - } - if (isSyntaxCheck) - return; - if (isSameAtom && Math.abs(zoom - factor) < 1) - time = 0; - viewer.moveTo(time, center, new Point3f(0, 0, 0), Float.NaN, factor, - xTrans, yTrans, radius, null, Float.NaN, Float.NaN, Float.NaN); + iToken = i; + return factor; } - + void gotocmd() throws ScriptException { String strTo = null; strTo = parameterAsString(1); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |