Package org.jmol.script
Class ScriptEval
java.lang.Object
org.jmol.script.ScriptError
org.jmol.script.ScriptParam
org.jmol.script.ScriptEval
- All Implemented Interfaces:
JmolScriptEvaluator
-
Field Summary
FieldsModifier and TypeFieldDescriptionT[][]
static int
static final String
static final String
boolean
boolean
boolean
boolean
int
int
protected Map<String,
ScriptFunction> int
protected T[]
boolean
Fields inherited from class org.jmol.script.ScriptParam
contextFunctions, contextVariables, coordinatesAreFractional, fractionalPoint, isBondSet, iToken, MODE_P_ALLOW_FRACTIONAL, MODE_P_CONVERT_TO_CARTESIAN, MODE_P_IMPLICIT_FRACTIONAL, MODE_P_INT_ONLY, MODE_P_NULL_ON_ERROR, MODE_P3, MODE_P34, MODE_P4, slen, st, theTok, theToken, thisContext
Fields inherited from class org.jmol.script.ScriptError
chk, error, ERROR_badArgumentCount, ERROR_badRGBColor, ERROR_cannotSet, ERROR_endOfStatementUnexpected, ERROR_expressionExpected, ERROR_expressionOrIntegerExpected, ERROR_fileNotFoundException, ERROR_incompatibleArguments, ERROR_insufficientArguments, ERROR_invalidArgument, ERROR_invalidParameterOrder, ERROR_keywordExpected, ERROR_moCoefficients, ERROR_moIndex, ERROR_moModelError, ERROR_moOccupancy, ERROR_moOnlyOne, ERROR_multipleModelsDisplayedNotOK, ERROR_noData, ERROR_noPartialCharges, ERROR_numberExpected, ERROR_operationCanceled, ERROR_what, ERROR_writeWhat, errorMessage, errorMessageUntranslated, errorType, iCommandError, ignoreError, vwr
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
atomExpression
(T[] code, int pcStart, int pcStop, boolean allowRefresh, boolean allowUnderflow, Object[] ret, boolean andNotDeleted) atomExpressionAt
(int index) checkFileExists
(String prefix, boolean isAsync, String filename, int i, boolean doClear) checkScriptSilent
(String script) a method for just checking a scriptboolean
checkSelect
(Map<String, SV> h, T[] where) Check a map for a WHERE phrasevoid
void
cmdLoad()
void
cmdRotate
(boolean isSpin, boolean isSelected) void
void
cmdUndoRedo
(int tok) protected boolean
compareFloat
(int tokOperator, float a, float b) protected BS
compareFloatData
(int tokWhat, float[] data, int tokOperator, float comparisonFloat) boolean
compileScript
(String filename, String strScript, boolean debugCompiler) boolean
compileScriptFile
(String filename, boolean tQuiet) boolean
compileScriptString
(String script, boolean tQuiet) void
delayScript
(int millis) void
deleteAtomsInVariables
(BS bsDeleted) boolean
dispatchCommands
(boolean isSpt, boolean fromFunc, boolean isTry) boolean
doReport()
encodeRadiusParameter
(int index, boolean isOnly, boolean allowAbsolute) float
evalFunctionFloat
(Object func, Object params, float[] values) boolean
evalParallel
(ScriptContext context, ShapeManager shapeManager) void
evaluateCompiledScript
(Object[] params, boolean isCmdLine_c_or_C_Option, boolean isCmdLine_C_Option, boolean historyDisabled, boolean listCommands, SB outputBuffer, boolean allowThreads) evaluateExpression
(Object expr, boolean asVariable, boolean compileOnly) a general-use method to evaluate a "SET" type expression.expandFloatArray
(float[] a, int min, boolean asBS) Accepts a float array and expands [1 -3] to [1 2 3], for example.boolean
getAssocArray
(int i) protected BS
getAtomBits
(int tokType, Object specInfo) getAtomBitSet
(Object atomExpression) A general method to evaluate a string representing an atom set.getBitsetProperty
(BS bs, Lst<SV> pts, int tok, P3 ptRef, P4 planeRef, Object tokenValue, Object opValue, boolean useAtomMap, int index, boolean asVectorIfAll) getColorRange
(int i) getFullPathName
(boolean withType) protected ScriptFunction
getFunction
(String sf) int
when paused, indicates what statement will be nextprotected P3
getObjectCenter
(String axisID, int index, int modelIndex) void
getPartialCharges
(BS bs) protected P4
getPlaneForObject
(String id, V3 vAB) Quat[]
getQuaternionArray
(Object quaternionOrSVData, int itype) getScriptContext
(String why) protected static int
getSeqCode
(T instruction) int
getSetAxesTypeMad10
(int index) getShapeProperty
(int shapeType, String propertyName) boolean
getShapePropertyData
(int shapeType, String propertyName, Object[] data) float
getTranslucentLevel
(int i) getUserFunctionResult
(String name, Lst<SV> params, SV tokenAtom) void
boolean
isAtomExpression
(int i) boolean
protected boolean
isFunction
(String sf) boolean
isPaused()
boolean
boolean
boolean
loadFileAsync
(String prefix, String filename, int i, boolean doClear) Allows asynchronous file loading from the LOAD or SCRIPT command.void
loadFileResourceAsync
(String fileName) load a static file asynchronouslylookupIdentifierValue
(String identifier) protected boolean
noCopy
(int i, int dir) void
protected boolean
parameterExpressionBoolean
(int pt, int ptMax) parameterExpressionList
(int pt, int ptAtom, boolean isArrayItem) protected boolean
parameterExpressionSelect
(Map<String, SV> h, T[] where) protected String
parameterExpressionString
(int pt, int ptMax) protected SV
parameterExpressionToken
(int pt) void
pauseExecution
(boolean withDelay) void
pushContextDown
(String why) void
refresh
(boolean doDelay) Refresh the display NOWvoid
void
restoreScriptContext
(ScriptContext context, boolean isPopContext, boolean isFlowCommand, boolean statementOnly) void
restrictSelected
(boolean isBond, boolean doInvert) void
resumeEval
(Object sco) From dispatchCommands and JmolThread resumeEval.void
void
runBufferedSafely
(String script, SB outputBuffer) void
void
runScriptBuffer
(String script, SB outputBuffer, boolean isFuncReturn) runs a script immediately and sends selected output to a provided SBstatic SV
runUserAction
(String functionName, Object[] params, Viewer vwr) void
setAllowJSThreads
(boolean b) protected void
setAtomProp
(String prop, Object value, BS bs) void
void
void
setException
(ScriptException sx, String msg, String untranslated) boolean
setMeshDisplayProperty
(int shape, int i, int tok) void
setObjectMad10
(int iShape, String name, int mad10) setObjectPropSafe
(String id, int tokCommand) called by Viewer in setting up a PyMOL scene.setShapeNameParameter
(int i) void
setShapeProperty
(int shapeType, String propertyName, Object propertyValue) void
setShapePropertyBs
(int iShape, String propertyName, Object propertyValue, BS bs) void
setShapeSizeBs
(int shapeType, int size, BS bs) void
setShapeTranslucency
(int shapeType, String prefix, String translucency, float translucentLevel, BS bs) protected boolean
setStatement
(T[] st0, int pt0) provides support for @x and @{....} in statements.int
setStatic
(int tok, int ival) set a static variable, with checking for rangeprotected SV
setVariable
(int pt, int ptMax, String key, boolean isSet) void
showString
(String str) void
showStringPrint
(String s, boolean mustDo) static String
statementAsString
(Viewer vwr, T[] statement, int iTok, boolean doLogMessages) void
void
toString()
boolean
Methods inherited from class org.jmol.script.ScriptParam
atomCenterOrCoordinateParameter, centerParameter, centerParameterForModel, checkHKL, checkLast, checkLength, checkLength23, checkLength34, checkLengthErrorPt, checkToken, floatParameter, floatParameterRange, floatParameterSet, getArgbParam, getArgbParamLast, getArgbParamOrNone, getAtomsStartingAt, getCallbackParameter, getContextVariableAsVariable, getFractionalPoint, getHklPlane, getMadParameter, getParameter, getPoint3f, getPoint4f, getPointArray, getPointOrCenterVector, getPointOrPlane, getPointVector, getQuaternionParameter, getToken, getUnitCellCenter, getVarParameter, hklParameter, intParameter, intParameterRange, isArrayParameter, isCenterParameter, isColorParam, isFloatParameter, isPoint3f, listParameter, listParameter4, modelNumberParameter, objectNameParameter, optParameterAsString, paramAsStr, planeParameter, planeValue, setBooleanProperty, setFloatProperty, setIntProperty, setScriptArguments, setStringProperty, stringParameter, stringParameterSet, tickParamAsStr, tokAt, xypParameter, xyzpParameter
Methods inherited from class org.jmol.script.ScriptError
bad, error, errorStr, errorStr2, evalError, getErrorLineMessage, getErrorMessage, getErrorMessageUntranslated, integerOutOfRange, invArg, invArgStr, numberOutOfRange, setCursorWait, setErrorMessage, warning
-
Field Details
-
sm
-
isJS
public boolean isJS -
historyDisabled
public boolean historyDisabled -
tQuiet
public boolean tQuiet -
compiler
-
outputBuffer
-
scriptFileName
-
functionName
-
isStateScript
public boolean isStateScript -
scriptLevel
public int scriptLevel -
CONTEXT_HOLD_QUEUE
- See Also:
-
CONTEXT_DELAY
- See Also:
-
commandHistoryLevelMax
public static int commandHistoryLevelMax -
aatoken
-
pc
public int pc -
thisCommand
-
fullCommand
-
pcResume
public int pcResume -
debugHigh
public boolean debugHigh -
privateFuncs
-
tempStatement
-
-
Constructor Details
-
ScriptEval
public ScriptEval()
-
-
Method Details
-
getAllowJSThreads
public boolean getAllowJSThreads() -
setAllowJSThreads
public void setAllowJSThreads(boolean b) -
doReport
public boolean doReport() -
isStateScript
public boolean isStateScript() -
setStatic
public int setStatic(int tok, int ival) set a static variable, with checking for range -
getScript
-
setViewer
-
setCompiler
public void setCompiler() -
compileScriptString
-
compileScriptFile
-
evaluateCompiledScript
-
useThreads
public boolean useThreads() -
resumeEval
From dispatchCommands and JmolThread resumeEval. After throwing a ScriptInterruption, all statements following the current one are lost. When a JavaScript timeout returns from a DELAY, MOVE, MOVETO, or other sleep-requiring command, it is the ScriptContext that contains all have to worry about this, because the current thread is just put to sleep, not stopped, but in JavaScript, where we only have one thread, we need to manage this more carefully. We re-enter the halted script here, using a saved script context. The program counter is incremented to skip the initiating statement, and all parent contexts up the line are set with mustResumeEval = true.- Parameters:
sco
-
-
runScript
- Throws:
ScriptException
-
runScriptBuffer
public void runScriptBuffer(String script, SB outputBuffer, boolean isFuncReturn) throws ScriptException runs a script immediately and sends selected output to a provided SB- Parameters:
outputBuffer
-script
-- Throws:
ScriptException
-
checkScriptSilent
a method for just checking a script- Parameters:
script
-- Returns:
- a ScriptContext that indicates errors and provides a tokenized version of the script that has passed all syntax checking, both in the compiler and the evaluator
-
setDebugging
public void setDebugging() -
haltExecution
public void haltExecution() -
pauseExecution
public void pauseExecution(boolean withDelay) -
stepPausedExecution
public void stepPausedExecution() -
resumePausedExecution
public void resumePausedExecution() -
isExecuting
public boolean isExecuting() -
isPaused
public boolean isPaused() -
isStepping
public boolean isStepping() -
isStopped
public boolean isStopped() -
getNextStatement
when paused, indicates what statement will be next- Returns:
- a string indicating the statement
-
evaluateExpression
a general-use method to evaluate a "SET" type expression.- Parameters:
asVariable
-expr
-- Returns:
- an object of one of the following types: Boolean, Integer, Float, String, Point3f, BitSet
-
runBufferedSafely
-
runUserAction
-
checkSelect
Check a map for a WHERE phrase -
getAtomBitSet
A general method to evaluate a string representing an atom set. Excepts one atom expression or one per line as "OR". Excepts "()" as "none".- Parameters:
atomExpression
-- Returns:
- is a bitset indicating the selected atoms
-
compileScript
-
evalFunctionFloat
-
getUserFunctionResult
- Throws:
ScriptException
-
clearDefinedVariableAtomSets
public void clearDefinedVariableAtomSets() -
lookupIdentifierValue
- Throws:
ScriptException
-
deleteAtomsInVariables
-
getThisContext
-
pushContextDown
-
getScriptContext
-
restoreScriptContext
public void restoreScriptContext(ScriptContext context, boolean isPopContext, boolean isFlowCommand, boolean statementOnly) -
setException
-
statementAsString
-
setObjectPropSafe
called by Viewer in setting up a PyMOL scene. -
setAtomProp
-
restrictSelected
public void restrictSelected(boolean isBond, boolean doInvert) -
showString
-
showStringPrint
- Specified by:
showStringPrint
in classScriptError
-
report
-
delayScript
public void delayScript(int millis) -
evalParallel
-
loadFileResourceAsync
load a static file asynchronously- Throws:
ScriptException
-
loadFileAsync
public String loadFileAsync(String prefix, String filename, int i, boolean doClear) throws ScriptException Allows asynchronous file loading from the LOAD or SCRIPT command. Saves the context, initiates a FileLoadThread instance. When the file loading completes, the file data (sans filename) is saved in the FileManager cache under cache://localLoad_xxxxx. Context is resumed at this command in the script, and the file is then retrieved from the cache. Only run from JSmol/HTML5 when vwr.isJS; Incompatibilities: LOAD and SCRIPT commands, load() function only; only one "?" per LOAD command- Parameters:
prefix
-filename
- or null if end of LOAD command and now just clearing out cachei
-doClear
- ensures only one file is in the cache for a given type- Returns:
- cached file name if it exists
- Throws:
ScriptException
-
notifyResumeStatus
public void notifyResumeStatus() -
refresh
Refresh the display NOW- Parameters:
doDelay
-- Throws:
ScriptException
-
stopScriptThreads
public void stopScriptThreads() -
getErrorLineMessage2
-
getLinenumber
-
dispatchCommands
public boolean dispatchCommands(boolean isSpt, boolean fromFunc, boolean isTry) throws ScriptException - Parameters:
isSpt
-fromFunc
-isTry
-- Returns:
- false only when still working through resumeEval
- Throws:
ScriptException
-
cmdLoad
- Throws:
ScriptException
-
checkFileExists
public String checkFileExists(String prefix, boolean isAsync, String filename, int i, boolean doClear) throws ScriptException - Throws:
ScriptException
-
isAtomExpression
public boolean isAtomExpression(int i) -
cmdRotate
- Throws:
ScriptException
-
cmdScript
public void cmdScript(int tok, String filename, String theScript, Lst<SV> params) throws ScriptException - Throws:
ScriptException
-
cmdUndoRedo
- Throws:
ScriptException
-
getPartialCharges
- Throws:
ScriptException
-
encodeRadiusParameter
public RadiusData encodeRadiusParameter(int index, boolean isOnly, boolean allowAbsolute) throws ScriptException - Throws:
ScriptException
-
expandFloatArray
Accepts a float array and expands [1 -3] to [1 2 3], for example.- Parameters:
a
-min
-asBS
-- Returns:
- float[] or BS
- Throws:
ScriptException
-
getColorRange
- Throws:
ScriptException
-
getFullPathName
- Throws:
ScriptException
-
getObjectCenter
-
getPlaneForObject
-
getQuaternionArray
-
getSetAxesTypeMad10
- Throws:
ScriptException
-
getShapeProperty
-
getShapePropertyData
-
getTranslucentLevel
- Throws:
ScriptException
-
setMeshDisplayProperty
- Parameters:
shape
-i
-tok
-- Returns:
- true if successful
- Throws:
ScriptException
-
setObjectMad10
-
setObjectProperty
- Throws:
ScriptException
-
setShapeNameParameter
- Throws:
ScriptException
-
setShapeProperty
-
setShapePropertyBs
-
setShapeSizeBs
-
setShapeTranslucency
-
toString
-
getCurrentModelFileAsString
-
getCmdExt
-
getIsoExt
-
getMathExt
-
getSmilesExt
-
parameterExpressionList
protected Lst<SV> parameterExpressionList(int pt, int ptAtom, boolean isArrayItem) throws ScriptException - Throws:
ScriptException
-
parameterExpressionString
- Throws:
ScriptException
-
parameterExpressionBoolean
- Throws:
ScriptException
-
parameterExpressionToken
- Throws:
ScriptException
-
parameterExpressionSelect
- Throws:
ScriptException
-
atomExpressionAt
- Throws:
ScriptException
-
atomExpression
public BS atomExpression(T[] code, int pcStart, int pcStop, boolean allowRefresh, boolean allowUnderflow, Object[] ret, boolean andNotDeleted) throws ScriptException - Parameters:
code
-pcStart
-pcStop
-allowRefresh
-allowUnderflow
-ret
- -- true return value; may not be a BSandNotDeleted
- IGNORED- Returns:
- atom bitset
- Throws:
ScriptException
-
noCopy
protected boolean noCopy(int i, int dir) -
getAssocArray
- Throws:
ScriptException
-
listBS
-
compareFloatData
- Parameters:
tokWhat
-data
-tokOperator
-comparisonFloat
-- Returns:
- BitSet
-
compareFloat
protected boolean compareFloat(int tokOperator, float a, float b) -
getBitsetProperty
public Object getBitsetProperty(BS bs, Lst<SV> pts, int tok, P3 ptRef, P4 planeRef, Object tokenValue, Object opValue, boolean useAtomMap, int index, boolean asVectorIfAll) throws ScriptException - Throws:
ScriptException
-
getAtomBits
-
getSeqCode
-
setVariable
- Parameters:
pt
- starting point in command token sequenceptMax
- ending point in command token sequenec, possibly -1 for "all"key
- the variable name to save the result in. This must be a standard user variable, either local or globalisSet
- from Set ... or Var .... or just xxx ....- Returns:
- a variable or null
- Throws:
ScriptException
-
setStatement
provides support for @x and @{....} in statements. The compiler passes on these, because they must be integrated with the statement dynamically.- Parameters:
st0
- aaToken[i]pt0
-- Returns:
- a fixed token set -- with possible overrun of unused null tokens
- Throws:
ScriptException
-
isFunction
-
addFunction
-
getFunction
-