From: <ha...@us...> - 2009-11-16 05:36:34
|
Revision: 11745 http://jmol.svn.sourceforge.net/jmol/?rev=11745&view=rev Author: hansonr Date: 2009-11-16 05:36:27 +0000 (Mon, 16 Nov 2009) Log Message: ----------- version=11.9.9_dev # new feature: show mouse and show mouse xxxx (still some work to do) # for example, show mouse select # # move selected atoms (requires SET DRAGSELECTED) ALT+SHIFT+LEFT # rotate selected atoms (requires SET DRAGSELECTED) ALT+LEFT # toggle selection (requires SET PICKINGSTYLE EXTENDEDSELECT/RASMOL) SHIFT+LEFT, LEFT+double-click # # or show mouse: # # rotate LEFT # zoom WHEEL # rotate Z ALT+LEFT, SHIFT+RIGHT # rotate Z (horizontal motion of mouse) or zoom (vertical motion of moouse) SHIFT+LEFT, MIDDLE # translate CTRL+ALT+LEFT, CTRL+RIGHT, SHIFT+LEFT+double-click, MIDDLE+double-click # zoom (along right edge of window) LEFT # move selected atoms (requires SET DRAGSELECTED) ALT+SHIFT+LEFT # rotate selected atoms (requires SET DRAGSELECTED) ALT+LEFT # move label (requires SET PICKING LABEL) SHIFT+LEFT # move specific DRAW point (requires SET PICKING DRAW) ALT+LEFT # move whole DRAW object (requires SET PICKING DRAW) SHIFT+LEFT # spin model (swipe and release button and stop motion simultaneously) LEFT # click on two points to spin around axis clockwise (requires SET PICKING SPIN) SHIFT+LEFT # click on two points to spin around axis counterclockwise (requires SET PICKING SPIN) LEFT # adjust slab (front plane; requires SLAB ON) CTRL+SHIFT+LEFT # adjust depth (back plane; requires SLAB ON) CTRL+SHIFT+LEFT+double-click # move slab/depth window (both planes; requires SLAB ON) CTRL+ALT+SHIFT+LEFT # pop up the full context menu CTRL+LEFT, RIGHT # pop up recent context menu (click on Jmol frank) LEFT # translate navigation point (requires SET NAVIGATIONMODE and SET PICKING NAVIGATE) LEFT # pick an atom LEFT # pick a DRAW point (for measurements) LEFT # pick a label to toggle it hidden/displayed (requires SET PICKING LABEL) LEFT # pick an atom to include it in a measurement (after starting a measurement or after SET PICKING DISTANCE/ANGLE/TORSION) LEFT # pick an atom to initiate or conclude a measurement LEFT+double-click # pick an ISOSURFACE point ALT+LEFT # toggle selection (requires SET PICKINGSTYLE EXTENDEDSELECT/RASMOL) SHIFT+LEFT, LEFT+double-click # reset (when clicked off the model) SHIFT+LEFT+double-click, MIDDLE+double-click # Modified Paths: -------------- trunk/Jmol/src/org/jmol/script/ScriptEvaluator.java trunk/Jmol/src/org/jmol/viewer/ActionManager.java trunk/Jmol/src/org/jmol/viewer/Jmol.properties trunk/Jmol/src/org/jmol/viewer/MouseManager14.java trunk/Jmol/src/org/jmol/viewer/Viewer.java trunk/Jmol/src/org/jmol/viewer/binding/Binding.java trunk/Jmol/src/org/jmol/viewer/binding/DragBinding.java trunk/Jmol/src/org/jmol/viewer/binding/JmolBinding.java trunk/Jmol/src/org/jmol/viewer/binding/PfaatBinding.java trunk/Jmol/src/org/jmol/viewer/binding/RasmolBinding.java Modified: trunk/Jmol/src/org/jmol/script/ScriptEvaluator.java =================================================================== --- trunk/Jmol/src/org/jmol/script/ScriptEvaluator.java 2009-11-15 22:52:09 UTC (rev 11744) +++ trunk/Jmol/src/org/jmol/script/ScriptEvaluator.java 2009-11-16 05:36:27 UTC (rev 11745) @@ -4886,7 +4886,13 @@ private void help() throws ScriptException { if (isSyntaxCheck) return; - String what = (statementLength == 1 ? "" : parameterAsString(1)); + String what = optParameterAsString(1); + int pt = 0; + if (what.toLowerCase().startsWith("mouse") + && (pt = what.indexOf(" ")) >= 0 && pt == what.lastIndexOf(" ")) { + showString(viewer.getBindingInfo(what.substring(pt + 1))); + return; + } Token t = Token.getTokenFromName(what); if (t != null && (t.tok & Token.scriptCommand) != 0) what = "?command=" + what; @@ -10957,11 +10963,18 @@ + viewer.getStrandCount(JmolConstants.SHAPE_MESHRIBBON); } else if (str.equalsIgnoreCase("trajectory") || str.equalsIgnoreCase("trajectories")) { - msg = viewer.getTrajectoryInfo(); + if (!isSyntaxCheck) + msg = viewer.getTrajectoryInfo(); + } else if (str.equalsIgnoreCase("mouse")) { + String qualifiers = ((len = statementLength) == 2 + ? null : parameterAsString(2)); + if (!isSyntaxCheck) + msg = viewer.getBindingInfo(qualifiers); } break; case Token.minimize: - msg = viewer.getMinimizationInfo(); + if (!isSyntaxCheck) + msg = viewer.getMinimizationInfo(); break; case Token.axes: switch (viewer.getAxesMode()) { @@ -10979,17 +10992,19 @@ msg = "set bondMode " + (viewer.getBondSelectionModeOr() ? "OR" : "AND"); break; case Token.strands: - msg = "set strandCountForStrands " - + viewer.getStrandCount(JmolConstants.SHAPE_STRANDS) - + "; set strandCountForMeshRibbon " - + viewer.getStrandCount(JmolConstants.SHAPE_MESHRIBBON); + if (!isSyntaxCheck) + msg = "set strandCountForStrands " + + viewer.getStrandCount(JmolConstants.SHAPE_STRANDS) + + "; set strandCountForMeshRibbon " + + viewer.getStrandCount(JmolConstants.SHAPE_MESHRIBBON); break; case Token.hbond: msg = "set hbondsBackbone " + viewer.getHbondsBackbone() + ";set hbondsSolid " + viewer.getHbondsSolid(); break; case Token.spin: - msg = viewer.getSpinState(); + if (!isSyntaxCheck) + msg = viewer.getSpinState(); break; case Token.ssbond: msg = "set ssbondsBackbone " + viewer.getSsbondsBackbone(); @@ -11010,7 +11025,8 @@ case Token.specular: case Token.specpower: case Token.specexponent: - msg = viewer.getSpecularState(); + if (!isSyntaxCheck) + msg = viewer.getSpecularState(); break; case Token.save: if (!isSyntaxCheck) Modified: trunk/Jmol/src/org/jmol/viewer/ActionManager.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/ActionManager.java 2009-11-15 22:52:09 UTC (rev 11744) +++ trunk/Jmol/src/org/jmol/viewer/ActionManager.java 2009-11-16 05:36:27 UTC (rev 11745) @@ -41,52 +41,98 @@ public class ActionManager { - public final static int ACTION_rotateXY = 1; + final static String[] actionNames = new String[] { + //0 + GT._("rotate"), + GT._("zoom"), + GT._("rotate Z"), + GT._("rotate Z (horizontal motion of mouse) or zoom (vertical motion of moouse)"), + GT._("translate"), + //5 + GT._("zoom (along right edge of window)"), + GT._("move selected atoms (requires {0})", "SET DRAGSELECTED"), + GT._("rotate selected atoms (requires {0})", "SET DRAGSELECTED"), + GT._("move label (requires {0})", "SET PICKING LABEL"), + GT._("move specific DRAW point (requires {0})", "SET PICKING DRAW"), + //10 + GT._("move whole DRAW object (requires {0})", "SET PICKING DRAW"), + GT._("spin model (swipe and release button and stop motion simultaneously)"), + GT._("click on two points to spin around axis clockwise (requires SET PICKING SPIN)"), + GT._("click on two points to spin around axis counterclockwise (requires SET PICKING SPIN)"), + GT._("adjust slab (front plane; requires {0})", "SLAB ON"), + //15 + GT._("adjust depth (back plane; requires {0})", "SLAB ON"), + GT._("move slab/depth window (both planes; requires {0})", "SLAB ON"), + GT._("pop up the full context menu"), + GT._("pop up recent context menu (click on Jmol frank)"), + GT._("translate navigation point (requires {0} and {1})", new String[] {"SET NAVIGATIONMODE", "SET PICKING NAVIGATE"}), + //20 + GT._("pick an atom"), + GT._("pick a DRAW point (for measurements)"), + GT._("pick a label to toggle it hidden/displayed (requires {0})", "SET PICKING LABEL"), + GT._("pick an atom to include it in a measurement (after starting a measurement or after {0})", "SET PICKING DISTANCE/ANGLE/TORSION"), + GT._("pick an atom to initiate or conclude a measurement"), + //25 + GT._("pick an ISOSURFACE point"), + GT._("pick a point or atom to navigate to (requires SET NAVIGATIONMODE; undocumented)"), + GT._("select an atom (requires {0})", "SET PICKINGSTYLE EXTENDEDSELECT"), + GT._("select NONE (requires {0})", "SET PICKINGSTYLE EXTENDEDSELECT"), + GT._("toggle selection (requires {0} or {1})", new String[] { + "SET PICKINGSTYLE DRAG/EXTENDEDSELECT/RASMOL"}), + //30 + GT._("click and drag to unselect this group of atoms (requires {0})", "DRAG/EXTENDEDSELECT"), + GT._("click and drag to select selected OR this group of atoms (requires {0})", "SET PICKINGSTYLE DRAG/EXTENDEDSELECT"), + GT._("if all are selected, unselect all, otherwise select if not selected (requires {0})", "SET PICKINGSTYLE DRAG"), + + GT._("reset (when clicked off the model)"), + }; + + public String getBindingInfo(String qualifiers) { + return binding.getBindingInfo(actionNames, qualifiers); + } + + public final static int ACTION_rotateXY = 0; + public final static int ACTION_zoom = 1; public final static int ACTION_rotateZ = 2; - public final static int ACTION_zoom = 3; + public final static int ACTION_rotateZorZoom = 3; public final static int ACTION_translateXY = 4; - public final static int ACTION_rotateMolecule = 5; - public final static int ACTION_slideZoom = 6; + public final static int ACTION_slideZoom = 5; - public final static int ACTION_dragSelected = 101; - public final static int ACTION_dragLabel = 102; - public final static int ACTION_dragDrawPoint = 103; - public final static int ACTION_dragDrawObject = 104; - public final static int ACTION_dragSpin = 105; + public final static int ACTION_dragSelected = 6; + public final static int ACTION_rotateSelected = 7; + public final static int ACTION_dragLabel = 8; + public final static int ACTION_dragDrawPoint = 9; + public final static int ACTION_dragDrawObject = 10; + public final static int ACTION_dragSpin = 11; - public final static int ACTION_spinDrawObjectCW = 201; - public final static int ACTION_spinDrawObjectCCW = 202; + public final static int ACTION_spinDrawObjectCW = 12; + public final static int ACTION_spinDrawObjectCCW = 13; - public final static int ACTION_slab = 301; - public final static int ACTION_depth = 302; - public final static int ACTION_slabDepth = 303; + public final static int ACTION_slab = 14; + public final static int ACTION_depth = 15; + public final static int ACTION_slabDepth = 16; - public final static int ACTION_popupMenu = 401; - public final static int ACTION_clickFrank = 402; + public final static int ACTION_popupMenu = 17; + public final static int ACTION_clickFrank = 18; + public final static int ACTION_navTranslate = 19; - public final static int ACTION_navTranslate = 501; - - public final static int ACTION_pickAtom = 601; - public final static int ACTION_pickPoint = 602; - public final static int ACTION_pickLabel = 603; - public final static int ACTION_pickMeasure = 604; - public final static int ACTION_setMeasure = 605; - public static final int ACTION_pickIsosurface = 606; - public static final int ACTION_pickNavigate = 607; + public final static int ACTION_pickAtom = 20; + public final static int ACTION_pickPoint = 21; + public final static int ACTION_pickLabel = 22; + public final static int ACTION_pickMeasure = 23; + public final static int ACTION_setMeasure = 24; + public static final int ACTION_pickIsosurface = 25; + public static final int ACTION_pickNavigate = 26; - public static final int ACTION_select = 701; - public static final int ACTION_selectNot = 702; - public static final int ACTION_selectToggle = 703; - public static final int ACTION_selectNone = 704; - public static final int ACTION_selectAndNot = 705; - public static final int ACTION_selectOr = 706; + public static final int ACTION_select = 27; + public static final int ACTION_selectNone = 28; + public static final int ACTION_selectToggle = 29; + public static final int ACTION_selectAndNot = 30; + public static final int ACTION_selectOr = 31; + public static final int ACTION_selectToggleOr = 32; - public final static int ACTION_rubberBandSelectToggle = 801; - public final static int ACTION_rubberBandSelectOr = 802; - public final static int ACTION_rubberBandSelectAndNot = 803; + public final static int ACTION_reset = 33; - public final static int ACTION_reset = 9999; - final static float wheelClickFractionUp = 1.15f; final static float wheelClickFractionDown = 1 / wheelClickFractionUp; @@ -177,7 +223,7 @@ } } - private int mouseMovedModifiers = Integer.MAX_VALUE; + private int mouseMovedModifiers = 0; /** * called by MouseManager.keyPressed @@ -188,13 +234,21 @@ return; keyProcessing = true; int i = ke.getKeyCode(); - if (i == KeyEvent.VK_ALT) { + switch(i) { + case KeyEvent.VK_ALT: if (dragSelectedMode && isAltKeyReleased) viewer.moveSelected(Integer.MIN_VALUE, 0, 0, 0, false); isAltKeyReleased = false; - } else if (i == KeyEvent.VK_SHIFT) { - mouseMovedModifiers = Binding.SHIFT; + mouseMovedModifiers &= Binding.ALT; + break; + case KeyEvent.VK_SHIFT: + mouseMovedModifiers &= Binding.SHIFT; + break; + case KeyEvent.VK_CONTROL: + mouseMovedModifiers &= Binding.CTRL; } + int action = Binding.LEFT+Binding.SINGLE_CLICK+mouseMovedModifiers; + checkMotionRotateZoom(action, xCurrent, 0, 0); if (viewer.getNavigationMode()) { int m = ke.getModifiers(); // if (viewer.getBooleanProperty("showKeyStrokes", false)) @@ -216,13 +270,21 @@ public void keyReleased(KeyEvent ke) { int i = ke.getKeyCode(); - if (i == KeyEvent.VK_ALT) { + switch(i) { + case KeyEvent.VK_ALT: if (dragSelectedMode) viewer.moveSelected(Integer.MAX_VALUE, 0, 0, 0, false); isAltKeyReleased = true; - } else if (i == KeyEvent.VK_SHIFT) { - mouseMovedModifiers = 0; + mouseMovedModifiers &= ~Binding.ALT; + break; + case KeyEvent.VK_SHIFT: + mouseMovedModifiers &= ~Binding.SHIFT; + break; + case KeyEvent.VK_CONTROL: + mouseMovedModifiers &= ~Binding.CTRL; } + if (mouseMovedModifiers == 0) + checkMotion(Viewer.CURSOR_DEFAULT); if (!viewer.getNavigationMode()) return; //if (viewer.getBooleanProperty("showKeyStrokes", false)) @@ -278,7 +340,6 @@ void setMouseMode() { drawMode = labelMode = false; dragSelectedMode = viewer.getBooleanProperty("dragSelected"); - rubberbandSelectionMode = (pickingStyle == JmolConstants.PICKINGSTYLE_SELECT_DRAG); measuresEnabled = !dragSelectedMode; if (!dragSelectedMode) switch (pickingMode) { @@ -402,20 +463,16 @@ viewer.setCursor(Viewer.CURSOR_DEFAULT); int action = Binding.getMouseAction(pressedCount, mods); dragGesture.add(action, x, y, time); - boolean isRbAction = (rubberbandSelectionMode && - ( isBound(action, ACTION_rubberBandSelectToggle) - || isBound(action, ACTION_rubberBandSelectOr) - || isBound(action, ACTION_rubberBandSelectAndNot) - )); + boolean isRbAction = isRubberBandSelect(action); if (isRbAction) { BitSet bs = viewer.findAtomsInRectangle(rectRubber); if (BitSetUtil.firstSetBit(bs) >= 0) { String s = Escape.escape(bs); - if (isBound(action, ACTION_rubberBandSelectOr)) + if (isBound(action, ACTION_selectOr)) viewer.script("select selected or " + s); - else if (isBound(action, ACTION_rubberBandSelectAndNot)) + else if (isBound(action, ACTION_selectAndNot)) viewer.script("select selected and not " + s); - else + else // ACTION_selectToggle viewer.script("select selected tog " + s); } viewer.refresh(3, "mouseReleased"); @@ -442,6 +499,14 @@ } } + private boolean isRubberBandSelect(int action) { + return rubberbandSelectionMode && + ( isBound(action, ACTION_selectToggle) + || isBound(action, ACTION_selectOr) + || isBound(action, ACTION_selectAndNot) + ); + } + void mouseDragged(long time, int x, int y, int mods) { setMouseMode(); int deltaX = x - previousDragX; @@ -477,10 +542,11 @@ if (dragSelectedMode && isBound(action, ACTION_dragSelected)) { checkMotion(Viewer.CURSOR_MOVE); - viewer.moveSelected(deltaX, deltaY, x, y, false); + System.out.println(deltaX + " " + deltaY + " " + x + " " + y); + viewer.moveSelected(deltaX, deltaY, x, y, true); return; } - if (viewer.allowRotateSelected() && isBound(action, ACTION_rotateMolecule)) { + if (viewer.allowRotateSelected() && isBound(action, ACTION_rotateSelected)) { checkMotion(Viewer.CURSOR_MOVE); viewer.rotateMolecule(deltaX, deltaY); return; @@ -499,18 +565,12 @@ viewer.moveSelected(deltaX, deltaY, x, y, true); return; } - if (rubberbandSelectionMode && - ( isBound(action, ACTION_rubberBandSelectToggle) - || isBound(action, ACTION_rubberBandSelectOr) - || isBound(action, ACTION_rubberBandSelectAndNot) - )) { + if (isRubberBandSelect(action)) { calcRectRubberBand(); viewer.refresh(3, "mouse-drag selection"); return; } - boolean isZoom = isBound(action, ACTION_zoom); - boolean isRotateZ = isBound(action, ACTION_rotateZ); - if (isZoom && isRotateZ) { + if (isBound(action, ACTION_rotateZorZoom)) { if (Math.abs(deltaY) > 5 * Math.abs(deltaX)) { // if (deltaY < 0 && deltaX > deltaY || deltaY > 0 && deltaX < deltaY) checkMotion(Viewer.CURSOR_ZOOM); @@ -521,11 +581,11 @@ viewer.rotateZBy(-deltaX); } return; - } else if (isZoom) { + } else if (isBound(action, ACTION_zoom)) { checkMotion(Viewer.CURSOR_ZOOM); viewer.zoomBy(deltaY); return; - } else if (isRotateZ) { + } else if (isBound(action, ACTION_rotateZ)) { checkMotion(Viewer.CURSOR_MOVE); viewer.rotateZBy(-deltaX); return; @@ -549,15 +609,18 @@ private boolean checkMotionRotateZoom(int action, int x, int deltaX, int deltaY) { boolean isZoom = isBound(action, ACTION_zoom); boolean isSlideZoom = isBound(action, ACTION_slideZoom); - boolean isRotateXY = isBound(action, ACTION_rotateXY); - if (!isZoom && !isSlideZoom && !isRotateXY) + boolean isRotateXY = isBound(action, ACTION_rotateXY); + boolean isRotateZorZoom = isBound(action, ACTION_rotateZorZoom); + if (!isZoom && !isSlideZoom && !isRotateXY && !isRotateZorZoom) return false; - if (isRotateXY && isSlideZoom) - isSlideZoom = isZoomArea(x) - && (deltaX == 0 || Math.abs(deltaY) > 5 * Math.abs(deltaX)); - checkMotion(isZoom || isSlideZoom ? Viewer.CURSOR_ZOOM - : isRotateXY ? Viewer.CURSOR_MOVE : Viewer.CURSOR_DEFAULT); - return isSlideZoom; + if (isRotateZorZoom) + isZoom = (deltaX == 0 || Math.abs(deltaY) > 5 * Math.abs(deltaX)); + if (isSlideZoom) + isZoom = (isZoomArea(x) + && (deltaX == 0 || Math.abs(deltaY) > 5 * Math.abs(deltaX))); + checkMotion(isZoom ? Viewer.CURSOR_ZOOM + : isRotateXY || isRotateZorZoom ? Viewer.CURSOR_MOVE : Viewer.CURSOR_DEFAULT); + return isZoom; } private boolean isZoomArea(int x) { @@ -759,6 +822,7 @@ } else { pickingStyleSelect = pickingStyle; } + rubberbandSelectionMode = false; switch (pickingStyleSelect) { case JmolConstants.PICKINGSTYLE_SELECT_PFAAT: if (binding.getName() != "Pfaat") @@ -767,6 +831,7 @@ case JmolConstants.PICKINGSTYLE_SELECT_DRAG: if (binding.getName() != "Drag") binding = new DragBinding(); + rubberbandSelectionMode = true; break; case JmolConstants.PICKINGSTYLE_SELECT_RASMOL: if (binding.getName() != "Rasmol") @@ -790,45 +855,14 @@ return drawHover; } - private void pickSelected(String spec, int action) { - switch (pickingMode) { - case JmolConstants.PICKING_IDENT: - case JmolConstants.PICKING_SELECT_ATOM: - applySelectStyle(spec, action); - break; - case JmolConstants.PICKING_SELECT_GROUP: - applySelectStyle("within(group, " + spec +")", action); - break; - case JmolConstants.PICKING_SELECT_CHAIN: - applySelectStyle("within(chain, " + spec +")", action); - break; - case JmolConstants.PICKING_SELECT_MOLECULE: - applySelectStyle("visible and within(molecule, " + spec +")", action); - break; - case JmolConstants.PICKING_SELECT_SITE: - applySelectStyle("visible and within(site, " + spec +")", action); - break; - case JmolConstants.PICKING_SELECT_MODEL: - applySelectStyle("within(model, " + spec +")", action); - break; - case JmolConstants.PICKING_SELECT_ELEMENT: - applySelectStyle("visible and within(element, " + spec +")", action); - break; - case JmolConstants.PICKING_LABEL: - viewer.script("set labeltoggle " + spec); - return; - default: - return; - } - viewer.clearClickCount(); - } - private void atomPicked(int atomIndex, Point3fi ptClicked, int action) { - // atomIndex < 0 is possible here. + // atomIndex < 0 is off structure. if (atomIndex < 0) { - if (isBound(action, ACTION_selectNone)) + resetMeasurement(); + if (isBound(action, ACTION_selectNone)) { viewer.script("select none"); - resetMeasurement(); + return; + } if (pickingMode != JmolConstants.PICKING_SPIN) return; } @@ -906,7 +940,37 @@ viewer.script("set labeltoggle {atomindex="+atomIndex+"}"); return; } - pickSelected("atomindex=" + atomIndex, action); + String spec = "atomindex=" + atomIndex; + switch (pickingMode) { + case JmolConstants.PICKING_LABEL: + viewer.script("set labeltoggle " + spec); + return; + default: + return; + case JmolConstants.PICKING_IDENT: + case JmolConstants.PICKING_SELECT_ATOM: + applySelectStyle(spec, action); + break; + case JmolConstants.PICKING_SELECT_CHAIN: + applySelectStyle("within(chain, " + spec +")", action); + break; + case JmolConstants.PICKING_SELECT_ELEMENT: + applySelectStyle("visible and within(element, " + spec +")", action); + break; + case JmolConstants.PICKING_SELECT_GROUP: + applySelectStyle("within(group, " + spec +")", action); + break; + case JmolConstants.PICKING_SELECT_MODEL: + applySelectStyle("within(model, " + spec +")", action); + break; + case JmolConstants.PICKING_SELECT_MOLECULE: + applySelectStyle("visible and within(molecule, " + spec +")", action); + break; + case JmolConstants.PICKING_SELECT_SITE: + applySelectStyle("visible and within(site, " + spec +")", action); + break; + } + viewer.clearClickCount(); } private int queueAtom(int atomIndex, Point3fi ptClicked) { @@ -918,16 +982,12 @@ } private void applySelectStyle(String item, int action) { - item = "(" + item + ")"; - String select = ""; - if (isBound(action, ACTION_selectAndNot)) { - select = "selected and not "; - } else if (isBound(action, ACTION_selectOr)) { - select = "selected or "; - } else if (isBound(action, ACTION_selectToggle)) { - select = "selected tog "; - } - viewer.script("select " + select + item); + viewer.script("select " + + (isBound(action, ACTION_selectAndNot) ? "selected and not " + : isBound(action, ACTION_selectOr) ? "selected or " + : isBound(action, ACTION_selectToggle) ? + "selected and not (" + item + ") or (not selected) and " + : "") + "(" + item + ")"); } protected class MotionPoint { Modified: trunk/Jmol/src/org/jmol/viewer/Jmol.properties =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Jmol.properties 2009-11-15 22:52:09 UTC (rev 11744) +++ trunk/Jmol/src/org/jmol/viewer/Jmol.properties 2009-11-16 05:36:27 UTC (rev 11745) @@ -3,6 +3,44 @@ version=11.9.9_dev +# new feature: show mouse and show mouse xxxx (still some work to do) +# for example, show mouse select +# +# move selected atoms (requires SET DRAGSELECTED) ALT+SHIFT+LEFT +# rotate selected atoms (requires SET DRAGSELECTED) ALT+LEFT +# toggle selection (requires SET PICKINGSTYLE EXTENDEDSELECT/RASMOL) SHIFT+LEFT, LEFT+double-click +# +# or show mouse: +# +# rotate LEFT +# zoom WHEEL +# rotate Z ALT+LEFT, SHIFT+RIGHT +# rotate Z (horizontal motion of mouse) or zoom (vertical motion of moouse) SHIFT+LEFT, MIDDLE +# translate CTRL+ALT+LEFT, CTRL+RIGHT, SHIFT+LEFT+double-click, MIDDLE+double-click +# zoom (along right edge of window) LEFT +# move selected atoms (requires SET DRAGSELECTED) ALT+SHIFT+LEFT +# rotate selected atoms (requires SET DRAGSELECTED) ALT+LEFT +# move label (requires SET PICKING LABEL) SHIFT+LEFT +# move specific DRAW point (requires SET PICKING DRAW) ALT+LEFT +# move whole DRAW object (requires SET PICKING DRAW) SHIFT+LEFT +# spin model (swipe and release button and stop motion simultaneously) LEFT +# click on two points to spin around axis clockwise (requires SET PICKING SPIN) SHIFT+LEFT +# click on two points to spin around axis counterclockwise (requires SET PICKING SPIN) LEFT +# adjust slab (front plane; requires SLAB ON) CTRL+SHIFT+LEFT +# adjust depth (back plane; requires SLAB ON) CTRL+SHIFT+LEFT+double-click +# move slab/depth window (both planes; requires SLAB ON) CTRL+ALT+SHIFT+LEFT +# pop up the full context menu CTRL+LEFT, RIGHT +# pop up recent context menu (click on Jmol frank) LEFT +# translate navigation point (requires SET NAVIGATIONMODE and SET PICKING NAVIGATE) LEFT +# pick an atom LEFT +# pick a DRAW point (for measurements) LEFT +# pick a label to toggle it hidden/displayed (requires SET PICKING LABEL) LEFT +# pick an atom to include it in a measurement (after starting a measurement or after SET PICKING DISTANCE/ANGLE/TORSION) LEFT +# pick an atom to initiate or conclude a measurement LEFT+double-click +# pick an ISOSURFACE point ALT+LEFT +# toggle selection (requires SET PICKINGSTYLE EXTENDEDSELECT/RASMOL) SHIFT+LEFT, LEFT+double-click +# reset (when clicked off the model) SHIFT+LEFT+double-click, MIDDLE+double-click +# # new feature: zoom gesture: LEFT vertical motion within right 2% of screen # does zoom and shows zoom cursor # new feature: swipe gesture: LEFT motion of at least 10 microsteps stopped Modified: trunk/Jmol/src/org/jmol/viewer/MouseManager14.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/MouseManager14.java 2009-11-15 22:52:09 UTC (rev 11744) +++ trunk/Jmol/src/org/jmol/viewer/MouseManager14.java 2009-11-16 05:36:27 UTC (rev 11745) @@ -23,12 +23,13 @@ */ package org.jmol.viewer; - import java.awt.Component; import java.awt.event.MouseWheelEvent; import java.awt.event.MouseWheelListener; +import org.jmol.viewer.binding.Binding; + class MouseManager14 extends MouseManager11 implements MouseWheelListener { @@ -45,6 +46,7 @@ } public void mouseWheelMoved(MouseWheelEvent e) { - mouseWheel(e.getWhen(), e.getWheelRotation(), e.getModifiers()); + mouseWheel(e.getWhen(), e.getWheelRotation(), + (e.getModifiers() & ~Binding.MIDDLE) | Binding.WHEEL); } } Modified: trunk/Jmol/src/org/jmol/viewer/Viewer.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Viewer.java 2009-11-15 22:52:09 UTC (rev 11744) +++ trunk/Jmol/src/org/jmol/viewer/Viewer.java 2009-11-16 05:36:27 UTC (rev 11745) @@ -6009,6 +6009,10 @@ return global.getAllSettings(prefix); } + public String getBindingInfo(String qualifiers) { + return (actionManager == null ? "" : actionManager.getBindingInfo(qualifiers)); + } + // ////// flags and settings //////// public boolean getDotSurfaceFlag() { Modified: trunk/Jmol/src/org/jmol/viewer/binding/Binding.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/binding/Binding.java 2009-11-15 22:52:09 UTC (rev 11744) +++ trunk/Jmol/src/org/jmol/viewer/binding/Binding.java 2009-11-16 05:36:27 UTC (rev 11745) @@ -1,41 +1,28 @@ package org.jmol.viewer.binding; import java.awt.Event; +import java.util.Arrays; import java.util.Enumeration; import java.util.Hashtable; +import java.util.Vector; abstract public class Binding { + public final static int WHEEL = 32; public final static int LEFT = 16; public final static int MIDDLE = Event.ALT_MASK; // 8 note that MIDDLE public final static int ALT = Event.ALT_MASK; // 8 and ALT are the same public final static int RIGHT = Event.META_MASK; // 4 public final static int CTRL = Event.CTRL_MASK; // 2 public final static int SHIFT = Event.SHIFT_MASK; // 1 - public final static int MIDDLE_RIGHT = MIDDLE | RIGHT; + public final static int CTRL_ALT = CTRL | ALT; public final static int LEFT_MIDDLE_RIGHT = LEFT | MIDDLE | RIGHT; - public final static int CTRL_SHIFT = CTRL | SHIFT; - public final static int CTRL_ALT = CTRL | ALT; - public final static int CTRL_LEFT = CTRL | LEFT; - public final static int CTRL_RIGHT = CTRL | RIGHT; - public final static int CTRL_MIDDLE = CTRL | MIDDLE; - public final static int CTRL_ALT_LEFT = CTRL_ALT | LEFT; - public final static int CTRL_ALT_RIGHT = CTRL_ALT | RIGHT; - public final static int ALT_LEFT = ALT | LEFT; - public final static int ALT_SHIFT_LEFT = ALT | SHIFT | LEFT; - public final static int SHIFT_LEFT = SHIFT | LEFT; - public final static int CTRL_SHIFT_LEFT = CTRL_SHIFT | LEFT; - public final static int CTRL_ALT_SHIFT_LEFT = CTRL_ALT | SHIFT | LEFT; - public final static int SHIFT_MIDDLE = SHIFT | MIDDLE; - public final static int CTRL_SHIFT_MIDDLE = CTRL_SHIFT | MIDDLE; - public final static int SHIFT_RIGHT = SHIFT | RIGHT; - public final static int CTRL_SHIFT_RIGHT = CTRL_SHIFT | RIGHT; - public final static int CTRL_ALT_SHIFT_RIGHT = CTRL_ALT | SHIFT | RIGHT; - public final static int DOUBLE_CLICK = 2; - public final static int SINGLE_CLICK = 1; + public final static int DOUBLE_CLICK = 2 << 8; + public final static int SINGLE_CLICK = 1 << 8; + private final static int BUTTON_MODIFIER_MASK = - CTRL_ALT | SHIFT | LEFT | MIDDLE | RIGHT; + CTRL_ALT | SHIFT | LEFT | MIDDLE | RIGHT | WHEEL; private String name; private Hashtable bindings = new Hashtable(); @@ -50,7 +37,7 @@ public final void bind(int gesture, int action) { //System.out.println("binding " + gesture + "_" + action); - bindings.put(gesture + "_" + action, Boolean.TRUE); + bindings.put(gesture + "_" + action, new int[] {gesture, action}); } public final void unbind(int gesture, int action) { @@ -95,4 +82,83 @@ return gesture >> 8; } + public String getBindingInfo(String[] actionNames, String qualifiers) { + StringBuffer sb = new StringBuffer(); + String qlow = (qualifiers == null || qualifiers.equalsIgnoreCase("all") ? null + : qualifiers.toLowerCase()); + Vector[] names = new Vector[actionNames.length]; + for (int i = 0; i < actionNames.length; i++) + names[i] = (qlow == null + || actionNames[i].toLowerCase().indexOf(qlow) >= 0 ? new Vector() + : null); + Enumeration e = bindings.keys(); + while (e.hasMoreElements()) { + int[] info = (int[]) (bindings.get((String) e.nextElement())); + int i = info[1]; + if (names[i] == null) + continue; + names[i].add(getGestureName(info[0])); + } + for (int i = 0; i < actionNames.length; i++) { + int n; + if (names[i] == null || (n = names[i].size()) == 0) + continue; + Object[] list = names[i].toArray(); + Arrays.sort(list); + sb.append(actionNames[i]).append('\t'); + String sep = ""; + for (int j = 0; j < n; j++) { + sb.append(sep); + sb.append(((String) list[j]).substring(7)); + sep = ", "; + } + sb.append('\n'); + } + return sb.toString(); + } + + private static boolean includes(int gesture, int mod) { + return ((gesture & mod) == mod); + } + private static String getGestureName(int gesture) { + StringBuffer sb = new StringBuffer(); + if (gesture == 0) + return ""; + boolean isMiddle = (includes(gesture, MIDDLE) + && !includes(gesture, LEFT) + && !includes(gesture, RIGHT)); + char[] code = " ".toCharArray(); + if (includes(gesture, CTRL)) { + sb.append("CTRL+"); + code[4] = 'C'; + } + if (!isMiddle && includes(gesture, ALT)) { + sb.append("ALT+"); + code[3] = 'A'; + } + if (includes(gesture, SHIFT)) { + sb.append("SHIFT+"); + code[2] = 'S'; + } + + if (includes(gesture, LEFT)) { + code[1] = 'L'; + sb.append("LEFT"); + } else if (includes(gesture, RIGHT)) { + code[1] = 'R'; + sb.append("RIGHT"); + } else if (isMiddle) { + code[1] = 'W'; + sb.append("MIDDLE"); + } else if (includes(gesture, WHEEL)) { + code[1] = 'W'; + sb.append("WHEEL"); + } + if (includes(gesture, DOUBLE_CLICK)) { + sb.append("+double-click"); + code[0] = '2'; + } + return new String(code) + ":" + sb.toString(); + } + } Modified: trunk/Jmol/src/org/jmol/viewer/binding/DragBinding.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/binding/DragBinding.java 2009-11-15 22:52:09 UTC (rev 11744) +++ trunk/Jmol/src/org/jmol/viewer/binding/DragBinding.java 2009-11-16 05:36:27 UTC (rev 11745) @@ -10,9 +10,9 @@ } private void setSelectBindings() { - bind(getMouseAction(SINGLE_CLICK,SHIFT_LEFT), ActionManager.ACTION_selectToggle); - bind(getMouseAction(SINGLE_CLICK,ALT_LEFT), ActionManager.ACTION_selectOr); - bind(getMouseAction(SINGLE_CLICK,ALT_SHIFT_LEFT), ActionManager.ACTION_selectAndNot); + bind(SINGLE_CLICK+SHIFT+LEFT, ActionManager.ACTION_selectToggle); + bind(SINGLE_CLICK+ALT+LEFT, ActionManager.ACTION_selectOr); + bind(SINGLE_CLICK+ALT+SHIFT+LEFT, ActionManager.ACTION_selectAndNot); } Modified: trunk/Jmol/src/org/jmol/viewer/binding/JmolBinding.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/binding/JmolBinding.java 2009-11-15 22:52:09 UTC (rev 11744) +++ trunk/Jmol/src/org/jmol/viewer/binding/JmolBinding.java 2009-11-16 05:36:27 UTC (rev 11745) @@ -16,73 +16,58 @@ } private void setSelectBindings() { - bind(getMouseAction(DOUBLE_CLICK,LEFT), ActionManager.ACTION_selectToggle); - bind(getMouseAction(SINGLE_CLICK,SHIFT_LEFT), ActionManager.ACTION_selectToggle); } protected void setGeneralBindings() { - bind(getMouseAction(SINGLE_CLICK,SHIFT_LEFT), ActionManager.ACTION_zoom); - bind(getMouseAction(SINGLE_CLICK,MIDDLE), ActionManager.ACTION_zoom); - bind(getMouseAction(SINGLE_CLICK,LEFT), ActionManager.ACTION_slideZoom); + bind(SINGLE_CLICK+SHIFT+LEFT, ActionManager.ACTION_rotateZorZoom); + bind(SINGLE_CLICK+MIDDLE, ActionManager.ACTION_rotateZorZoom); + bind(SINGLE_CLICK+WHEEL, ActionManager.ACTION_zoom); + bind(SINGLE_CLICK+LEFT, ActionManager.ACTION_slideZoom); - bind(getMouseAction(SINGLE_CLICK,LEFT), ActionManager.ACTION_rotateXY); + bind(SINGLE_CLICK+LEFT, ActionManager.ACTION_rotateXY); - bind(getMouseAction(SINGLE_CLICK,LEFT), ActionManager.ACTION_dragSpin); + bind(SINGLE_CLICK+LEFT, ActionManager.ACTION_dragSpin); - bind(getMouseAction(SINGLE_CLICK,SHIFT_LEFT), ActionManager.ACTION_rotateZ); - bind(getMouseAction(SINGLE_CLICK,MIDDLE), ActionManager.ACTION_rotateZ); - bind(getMouseAction(SINGLE_CLICK,SHIFT_RIGHT), ActionManager.ACTION_rotateZ); + bind(SINGLE_CLICK+ALT+LEFT, ActionManager.ACTION_rotateZ); + bind(SINGLE_CLICK+SHIFT+RIGHT, ActionManager.ACTION_rotateZ); - bind(getMouseAction(SINGLE_CLICK,ALT_LEFT), ActionManager.ACTION_rotateMolecule); - bind(getMouseAction(SINGLE_CLICK,CTRL_ALT_RIGHT), ActionManager.ACTION_rotateMolecule); + bind(SINGLE_CLICK+CTRL+ALT+LEFT, ActionManager.ACTION_translateXY); + bind(SINGLE_CLICK+CTRL+RIGHT, ActionManager.ACTION_translateXY); + bind(DOUBLE_CLICK+SHIFT+LEFT, ActionManager.ACTION_translateXY); + bind(DOUBLE_CLICK+MIDDLE, ActionManager.ACTION_translateXY); + + bind(SINGLE_CLICK+ALT+SHIFT+LEFT, ActionManager.ACTION_dragSelected); + bind(SINGLE_CLICK+ALT+LEFT, ActionManager.ACTION_rotateSelected); - bind(getMouseAction(SINGLE_CLICK,CTRL_ALT_LEFT), ActionManager.ACTION_translateXY); - bind(getMouseAction(SINGLE_CLICK,CTRL_RIGHT), ActionManager.ACTION_translateXY); - bind(getMouseAction(DOUBLE_CLICK,SHIFT_LEFT), ActionManager.ACTION_translateXY); - bind(getMouseAction(DOUBLE_CLICK,MIDDLE), ActionManager.ACTION_translateXY); + bind(SINGLE_CLICK+SHIFT+LEFT, ActionManager.ACTION_dragLabel); + + bind(SINGLE_CLICK+ALT+LEFT, ActionManager.ACTION_dragDrawPoint); + bind(SINGLE_CLICK+SHIFT+LEFT, ActionManager.ACTION_dragDrawObject); + bind(SINGLE_CLICK+LEFT, ActionManager.ACTION_spinDrawObjectCCW); + bind(SINGLE_CLICK+SHIFT+LEFT, ActionManager.ACTION_spinDrawObjectCW); + + bind(SINGLE_CLICK+CTRL+LEFT, ActionManager.ACTION_popupMenu); + bind(SINGLE_CLICK+RIGHT, ActionManager.ACTION_popupMenu); + bind(SINGLE_CLICK+LEFT, ActionManager.ACTION_clickFrank); - bind(getMouseAction(SINGLE_CLICK,CTRL_LEFT), ActionManager.ACTION_popupMenu); - bind(getMouseAction(SINGLE_CLICK,RIGHT), ActionManager.ACTION_popupMenu); - bind(getMouseAction(SINGLE_CLICK,LEFT), ActionManager.ACTION_clickFrank); + bind(SINGLE_CLICK+LEFT, ActionManager.ACTION_navTranslate); - bind(getMouseAction(SINGLE_CLICK,LEFT), ActionManager.ACTION_navTranslate); - - bind(getMouseAction(DOUBLE_CLICK,LEFT), ActionManager.ACTION_setMeasure); - - bind(getMouseAction(SINGLE_CLICK,CTRL_SHIFT_LEFT), ActionManager.ACTION_slab); - bind(getMouseAction(DOUBLE_CLICK,CTRL_SHIFT_LEFT), ActionManager.ACTION_depth); - bind(getMouseAction(SINGLE_CLICK,CTRL_ALT_SHIFT_LEFT), ActionManager.ACTION_slabDepth); - - bind(getMouseAction(DOUBLE_CLICK,MIDDLE), ActionManager.ACTION_reset); - bind(getMouseAction(DOUBLE_CLICK,SHIFT_LEFT), ActionManager.ACTION_reset); + bind(SINGLE_CLICK+CTRL+SHIFT+LEFT, ActionManager.ACTION_slab); + bind(DOUBLE_CLICK+CTRL+SHIFT+LEFT, ActionManager.ACTION_depth); + bind(SINGLE_CLICK+CTRL+ALT+SHIFT+LEFT, ActionManager.ACTION_slabDepth); + bind(DOUBLE_CLICK+SHIFT+LEFT, ActionManager.ACTION_reset); + bind(DOUBLE_CLICK+MIDDLE, ActionManager.ACTION_reset); } protected void setPickBindings() { - bind(getMouseAction(SINGLE_CLICK,LEFT), ActionManager.ACTION_pickAtom); - bind(getMouseAction(SINGLE_CLICK,LEFT), ActionManager.ACTION_pickPoint); - bind(getMouseAction(SINGLE_CLICK,LEFT), ActionManager.ACTION_pickLabel); - bind(getMouseAction(SINGLE_CLICK,LEFT), ActionManager.ACTION_pickMeasure); - bind(getMouseAction(SINGLE_CLICK,ALT_LEFT), ActionManager.ACTION_pickIsosurface); - - bind(getMouseAction(SINGLE_CLICK,ALT_LEFT), ActionManager.ACTION_dragSelected); - bind(getMouseAction(SINGLE_CLICK,SHIFT_LEFT), ActionManager.ACTION_dragSelected); - bind(getMouseAction(SINGLE_CLICK,ALT_SHIFT_LEFT), ActionManager.ACTION_dragSelected); - - bind(getMouseAction(SINGLE_CLICK,SHIFT_LEFT), ActionManager.ACTION_dragDrawObject); - - bind(getMouseAction(SINGLE_CLICK,ALT_LEFT), ActionManager.ACTION_dragDrawPoint); - bind(getMouseAction(SINGLE_CLICK,SHIFT_LEFT), ActionManager.ACTION_dragLabel); - - bind(getMouseAction(SINGLE_CLICK,LEFT), ActionManager.ACTION_spinDrawObjectCCW); - bind(getMouseAction(SINGLE_CLICK,SHIFT_LEFT), ActionManager.ACTION_spinDrawObjectCW); - - // these are the same as "drag" - bind(getMouseAction(SINGLE_CLICK,SHIFT_LEFT), ActionManager.ACTION_rubberBandSelectToggle); - bind(getMouseAction(SINGLE_CLICK,ALT_LEFT), ActionManager.ACTION_rubberBandSelectOr); - bind(getMouseAction(SINGLE_CLICK,ALT_SHIFT_LEFT), ActionManager.ACTION_rubberBandSelectAndNot); - + bind(SINGLE_CLICK+LEFT, ActionManager.ACTION_pickAtom); + bind(SINGLE_CLICK+LEFT, ActionManager.ACTION_pickPoint); + bind(SINGLE_CLICK+LEFT, ActionManager.ACTION_pickLabel); + bind(SINGLE_CLICK+LEFT, ActionManager.ACTION_pickMeasure); + bind(DOUBLE_CLICK+LEFT, ActionManager.ACTION_setMeasure); + bind(SINGLE_CLICK+ALT+LEFT, ActionManager.ACTION_pickIsosurface); } } Modified: trunk/Jmol/src/org/jmol/viewer/binding/PfaatBinding.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/binding/PfaatBinding.java 2009-11-15 22:52:09 UTC (rev 11744) +++ trunk/Jmol/src/org/jmol/viewer/binding/PfaatBinding.java 2009-11-16 05:36:27 UTC (rev 11745) @@ -10,10 +10,11 @@ } private void setSelectBindings() { - bind(getMouseAction(SINGLE_CLICK,LEFT), ActionManager.ACTION_selectNone); - bind(getMouseAction(SINGLE_CLICK,SHIFT_LEFT), ActionManager.ACTION_selectToggle); - bind(getMouseAction(SINGLE_CLICK,ALT_SHIFT_LEFT), ActionManager.ACTION_selectAndNot); - bind(getMouseAction(SINGLE_CLICK,ALT_LEFT), ActionManager.ACTION_selectOr); + bind(SINGLE_CLICK+LEFT, ActionManager.ACTION_select); + bind(SINGLE_CLICK+LEFT, ActionManager.ACTION_selectNone); + bind(SINGLE_CLICK+SHIFT+LEFT, ActionManager.ACTION_selectToggle); + bind(SINGLE_CLICK+ALT+SHIFT+LEFT, ActionManager.ACTION_selectAndNot); + bind(SINGLE_CLICK+ALT+LEFT, ActionManager.ACTION_selectOr); } Modified: trunk/Jmol/src/org/jmol/viewer/binding/RasmolBinding.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/binding/RasmolBinding.java 2009-11-15 22:52:09 UTC (rev 11744) +++ trunk/Jmol/src/org/jmol/viewer/binding/RasmolBinding.java 2009-11-16 05:36:27 UTC (rev 11745) @@ -10,7 +10,7 @@ } private void setSelectBindings() { - bind(getMouseAction(SINGLE_CLICK,SHIFT_LEFT), ActionManager.ACTION_selectToggle); + bind(SINGLE_CLICK+SHIFT+LEFT, ActionManager.ACTION_selectToggle); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |