From: <ha...@us...> - 2011-05-10 22:33:43
|
Revision: 15452 http://jmol.svn.sourceforge.net/jmol/?rev=15452&view=rev Author: hansonr Date: 2011-05-10 22:33:35 +0000 (Tue, 10 May 2011) Log Message: ----------- version=12.0.43_dev # bug fix: CTRL-SHIFT-Z not working for "redo" # bug fix: select within(chain, atomno=xxx) will not select all desired atoms # if the chain is spread out over multiple regions of the file (1gzx) # bug fix: set dragselected may not turn off transient selection halos # bug fix: undo (CTRL-Z) and redo (CTRL-Y) not implemented for dragSelected Modified Paths: -------------- branches/v12_0/Jmol/src/org/jmol/viewer/ActionManager.java branches/v12_0/Jmol/src/org/jmol/viewer/Jmol.properties branches/v12_0/Jmol/src/org/jmol/viewer/MouseManager14.java branches/v12_0/Jmol/src/org/jmol/viewer/Viewer.java branches/v12_0/Jmol/src/org/jmol/viewer/binding/Binding.java Modified: branches/v12_0/Jmol/src/org/jmol/viewer/ActionManager.java =================================================================== --- branches/v12_0/Jmol/src/org/jmol/viewer/ActionManager.java 2011-05-10 20:19:51 UTC (rev 15451) +++ branches/v12_0/Jmol/src/org/jmol/viewer/ActionManager.java 2011-05-10 22:33:35 UTC (rev 15452) @@ -577,6 +577,7 @@ viewer.setPickingMode(null, PICKING_IDENTIFY); viewer.setPickingStyle(null, rootPickingStyle); eval = null; + isAltKeyReleased = true; } synchronized public void startHoverWatcher(boolean isStart) { @@ -849,7 +850,7 @@ // H C + -, etc. // also check valence and add/remove H atoms as necessary? if (measurementPending.getCount() == 2) { - viewer.undoAction(true, -1, 0); + viewer.undoAction(-1, Viewer.ACTION_SAVE, true); viewer.script("assign connect " + measurementPending.getMeasurementScript(" ", false)); } else if (pickAtomAssignType.equals("Xx")) { @@ -861,14 +862,14 @@ + pickAtomAssignType + "\""; if (isPickAtomAssignCharge) { s += ";{atomindex=" + dragAtomIndex + "}.label='%C'; "; - viewer.undoAction(true, dragAtomIndex, - AtomCollection.TAINT_FORMALCHARGE); + viewer.undoAction(dragAtomIndex, + AtomCollection.TAINT_FORMALCHARGE, true); } else { - viewer.undoAction(true, -1, 0); + viewer.undoAction(-1, Viewer.ACTION_SAVE, true); } viewer.script(s); } else if (!isPickAtomAssignCharge) { - viewer.undoAction(true, -1, 0); + viewer.undoAction(-1, Viewer.ACTION_SAVE, true); Atom a = viewer.getModelSet().atoms[dragAtomIndex]; if (a.getElementNumber() == 1) { viewer.script("assign atom ({" + dragAtomIndex + "}) \"X\""); @@ -1024,7 +1025,7 @@ case PICKING_DRAG_MOLECULE: case PICKING_DRAG_MINIMIZE_MOLECULE: if (dragGesture.getPointCount() == 1) - viewer.undoAction(true, dragAtomIndex, AtomCollection.TAINT_COORD); + viewer.undoAction(dragAtomIndex, AtomCollection.TAINT_COORD, true); checkMotion(Viewer.CURSOR_MOVE); if (isBound(action, ACTION_rotateBranch)) { BitSet bs = viewer.getAtomBits(Token.molecule, BitSetUtil.setBit(dragAtomIndex)); @@ -1096,7 +1097,7 @@ if (dragGesture.getPointCount() == 1) { int iatom = viewer.getSelectionSet(false).nextSetBit(0); if (iatom >= 0) - viewer.undoAction(true, iatom, AtomCollection.TAINT_COORD); + viewer.undoAction(iatom, AtomCollection.TAINT_COORD, true); } checkMotion(Viewer.CURSOR_MOVE); if (isBound(action, ACTION_dragSelected)) @@ -1305,7 +1306,7 @@ || bondPickingMode == PICKING_ASSIGN_BOND ? ACTION_assignNew : ACTION_deleteBond)) { if (bondPickingMode == PICKING_ASSIGN_BOND) - viewer.undoAction(true, -1, 0); + viewer.undoAction(-1, Viewer.ACTION_SAVE, true); switch (bondPickingMode) { case PICKING_ASSIGN_BOND: viewer.script("assign bond [{" + nearestPoint.index + "}] \"" @@ -1824,7 +1825,7 @@ bs.clear(imax); } } - viewer.undoAction(true, atomIndex, AtomCollection.TAINT_COORD); + viewer.undoAction(atomIndex, AtomCollection.TAINT_COORD, true); viewer.invertSelected(null, null, atomIndex, bs); viewer.setStatusAtomPicked(atomIndex, "inverted: " + Escape.escape(bs)); } Modified: branches/v12_0/Jmol/src/org/jmol/viewer/Jmol.properties =================================================================== --- branches/v12_0/Jmol/src/org/jmol/viewer/Jmol.properties 2011-05-10 20:19:51 UTC (rev 15451) +++ branches/v12_0/Jmol/src/org/jmol/viewer/Jmol.properties 2011-05-10 22:33:35 UTC (rev 15452) @@ -4,6 +4,7 @@ version=12.0.43_dev +# bug fix: CTRL-SHIFT-Z not working for "redo" # bug fix: select within(chain, atomno=xxx) will not select all desired atoms # if the chain is spread out over multiple regions of the file (1gzx) # bug fix: set dragselected may not turn off transient selection halos Modified: branches/v12_0/Jmol/src/org/jmol/viewer/MouseManager14.java =================================================================== --- branches/v12_0/Jmol/src/org/jmol/viewer/MouseManager14.java 2011-05-10 20:19:51 UTC (rev 15451) +++ branches/v12_0/Jmol/src/org/jmol/viewer/MouseManager14.java 2011-05-10 22:33:35 UTC (rev 15452) @@ -197,14 +197,18 @@ case 'z': // undo switch (modifiers) { case Binding.CTRL: - viewer.undoAction(false, 0, 1); + viewer.undoAction(0, Viewer.ACTION_UNDO, true); + break; + case Binding.CTRL_SHIFT: + viewer.undoAction(0, Viewer.ACTION_REDO, true); + break; } break; case 25: case 'y': // redo switch (modifiers) { case Binding.CTRL: - viewer.undoAction(false, 0, -1); + viewer.undoAction(0, Viewer.ACTION_REDO, true); } break; } Modified: branches/v12_0/Jmol/src/org/jmol/viewer/Viewer.java =================================================================== --- branches/v12_0/Jmol/src/org/jmol/viewer/Viewer.java 2011-05-10 20:19:51 UTC (rev 15451) +++ branches/v12_0/Jmol/src/org/jmol/viewer/Viewer.java 2011-05-10 22:33:35 UTC (rev 15452) @@ -2491,7 +2491,6 @@ } actionStates.clear(); actionStatesRedo.clear(); - lastUndoRedo = 0; } System.gc(); } else { @@ -4060,9 +4059,9 @@ private boolean checkUndo(String str) { if (str.equalsIgnoreCase("redo")) - undoAction(false, 0, -1); + undoAction(0, ACTION_REDO, true); else if (str.equalsIgnoreCase("undo")) - undoAction(false, 0, 1); + undoAction(0, ACTION_UNDO, true); else return false; return true; @@ -7719,7 +7718,7 @@ Bond b = modelSet.getBonds()[rotateBondIndex]; atom1 = b.getAtom1(); atom2 = b.getAtom2(); - undoAction(true, atom1.index, AtomCollection.TAINT_COORD); + undoAction(atom1.index, AtomCollection.TAINT_COORD, true); Point3f pt = new Point3f(x, y, (atom1.screenZ + atom2.screenZ) / 2); transformManager.unTransformPoint(pt, pt); if (atom2.getCovalentBondCount() == 1 @@ -9057,68 +9056,100 @@ private final static int MAX_ACTION_UNDO = 100; private final List actionStates = new ArrayList(); private final List actionStatesRedo = new ArrayList(); - private int lastUndoRedo = 0; + final static int ACTION_SAVE = -1; + final static int ACTION_UNDO = -2; + final static int ACTION_REDO = -3; + private boolean undoWorking = false; - void undoAction(boolean isSave, int taintedAtom, int type) { - int modelIndex = (taintedAtom >= 0 ? modelSet.atoms[taintedAtom].modelIndex + void undoAction(int taintedAtom, int type, boolean clearRedo) { + int modelIndex = (taintedAtom >= 0 ? modelSet.atoms[taintedAtom].modelIndex : modelSet.getModelCount() - 1); - if (!isSave) { + //System.out.print("undoAction " + type + " " + taintedAtom + " modelkit?" + // + modelSet.getModels()[modelIndex].isModelkit()); + //System.out.println(" " + type + " size=" + actionStates.size() + " " + // + +actionStatesRedo.size()); + switch (type) { + case ACTION_REDO: + case ACTION_UNDO: + // from MouseManager + // CTRL-Z: type = 1 UNDO + // CTRL-Y: type = -1 REDO stopMinimization(); - String s; - if (lastUndoRedo != 0 && lastUndoRedo != type) { - try { - if (type == -1) { - actionStates.add(0, actionStatesRedo.remove(0)); - } else { - actionStatesRedo.add(0, actionStates.remove(0)); - } - } catch (Exception e) { - System.out.println("oops"); // ignore - } + String s = ""; + List list1; + List list2; + switch (type) { + default: + case ACTION_UNDO: + list1 = actionStates; + list2 = actionStatesRedo; + break; + case ACTION_REDO: + list1 = actionStatesRedo; + list2 = actionStates; + if (actionStatesRedo.size() == 1) + return; + break; } - lastUndoRedo = type; - if (type == -1) { - if (actionStatesRedo.size() == 0) - return; - s = (String) actionStatesRedo.remove(0); - actionStates.add(0, s); - } else if (actionStates.size() == 0) { + if (list1.size() == 0 || undoWorking) return; + undoWorking = true; + list2.add(0, list1.remove(0)); + s = (String) actionStatesRedo.get(0); + if (type == ACTION_UNDO && list2.size() == 1) { + // must save current state, coord, etc. + // but this destroys actionStatesRedo + int[] pt = new int[] {1}; + type = Parser.parseInt(s, pt); + taintedAtom = Parser.parseInt(s, pt); + undoAction(taintedAtom, type, false); + } + //System.out.println("redo type = " + type + " size=" + actionStates.size() + // + " " + +actionStatesRedo.size()); + if (modelSet.getModels()[modelIndex].isModelkit() + || s.indexOf("zap ") < 0) { + if (Logger.debugging) + log(s); + evalStringQuiet(s); } else { - s = (String) actionStates.remove(0); - actionStatesRedo.add(0, s); + // if it's not modelkit mode and we are trying to do a zap, then ignore + // and clear all action states. + actionStates.clear(); } - if (!modelSet.getModels()[modelIndex].isModelkit() && s.indexOf("zap ") >= 0) { - actionStates.clear(); + break; + default: + if (undoWorking && clearRedo) return; + undoWorking = true; + BitSet bs; + StringBuffer sb = new StringBuffer(); + sb.append("#" + type + " "+ taintedAtom + " " + (new Date()) + "\n"); + if (taintedAtom >= 0) { + bs = getModelUndeletedAtomsBitSet(modelIndex); + modelSet.taint(bs, (byte) type); + sb.append(modelSet.getAtomicPropertyState(-1, null)); + } else { + bs = getModelUndeletedAtomsBitSet(modelIndex); + sb.append("zap "); + sb.append(Escape.escape(bs)).append(";"); + DataManager.getInlineData(sb, modelSet.getModelExtract(bs, false, true, false, false), true, null); + sb.append("set refreshing false;").append( + actionManager.getPickingState()).append( + transformManager.getMoveToText(0, false)).append( + "set refreshing true;"); + } - if (Logger.debugging) - log(s); - evalStringQuiet(s); - return; + if (clearRedo) { + actionStates.add(0, sb.toString()); + actionStatesRedo.clear(); + } else { + actionStatesRedo.add(1, sb.toString()); + } + if (actionStates.size() == MAX_ACTION_UNDO) { + actionStates.remove(MAX_ACTION_UNDO - 1); + } } - lastUndoRedo = 0; - actionStatesRedo.clear(); - BitSet bs; - StringBuffer sb = new StringBuffer(); - if (taintedAtom >= 0) { - bs = getModelUndeletedAtomsBitSet(modelIndex); - modelSet.taint(bs, (byte) type); - sb.append(modelSet.getAtomicPropertyState(-1, null)); - } else { - bs = getModelUndeletedAtomsBitSet(modelIndex); - sb.append("zap "); - sb.append(Escape.escape(bs)).append(";"); - DataManager.getInlineData(sb, modelSet.getModelExtract(bs, false, true, false, false), true, null); - sb.append("set refreshing false;") - .append(actionManager.getPickingState()).append( - transformManager.getMoveToText(0, false)).append( - "set refreshing true;"); - - } - actionStates.add(0, sb.toString()); - if (actionStates.size() == MAX_ACTION_UNDO) - actionStates.remove(MAX_ACTION_UNDO - 1); + undoWorking = !clearRedo; } public void assignBond(int bondIndex, char type) { Modified: branches/v12_0/Jmol/src/org/jmol/viewer/binding/Binding.java =================================================================== --- branches/v12_0/Jmol/src/org/jmol/viewer/binding/Binding.java 2011-05-10 20:19:51 UTC (rev 15451) +++ branches/v12_0/Jmol/src/org/jmol/viewer/binding/Binding.java 2011-05-10 22:33:35 UTC (rev 15452) @@ -19,6 +19,7 @@ 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 CTRL_SHIFT = CTRL | SHIFT; public final static int CTRL_ALT = CTRL | ALT; public final static int LEFT_MIDDLE_RIGHT = LEFT | MIDDLE | RIGHT; public final static int MAC_COMMAND = LEFT | RIGHT; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |