From: <ha...@us...> - 2009-02-02 16:21:55
|
Revision: 10605 http://jmol.svn.sourceforge.net/jmol/?rev=10605&view=rev Author: hansonr Date: 2009-02-02 16:21:51 +0000 (Mon, 02 Feb 2009) Log Message: ----------- version=11.7.24_dev set picking dragSelected # new feature: set picking dragSelected (preliminary) # # ALT_LEFT highlights atoms and rotates them # ALT_SHIFT_LEFT highlights atoms and translates them Modified Paths: -------------- trunk/Jmol/src/org/jmol/shapespecial/Draw.java trunk/Jmol/src/org/jmol/viewer/Eval.java trunk/Jmol/src/org/jmol/viewer/Jmol.properties trunk/Jmol/src/org/jmol/viewer/JmolConstants.java trunk/Jmol/src/org/jmol/viewer/MouseManager.java trunk/Jmol/src/org/jmol/viewer/Viewer.java Modified: trunk/Jmol/src/org/jmol/shapespecial/Draw.java =================================================================== --- trunk/Jmol/src/org/jmol/shapespecial/Draw.java 2009-02-02 13:27:10 UTC (rev 10604) +++ trunk/Jmol/src/org/jmol/shapespecial/Draw.java 2009-02-02 16:21:51 UTC (rev 10605) @@ -947,18 +947,16 @@ if (pickedMesh == null) return false; boolean moveAll = false; - switch (modifiers & MouseManager.BUTTON_MODIFIER_MASK) { + switch (modifiers) { case MouseManager.SHIFT_LEFT: moveAll = true; //fall through + case MouseManager.ALT_SHIFT_LEFT: case MouseManager.ALT_LEFT: move2D(pickedMesh, pickedMesh.polygonIndexes[pickedModel], pickedVertex, x, y, moveAll); thisMesh = pickedMesh; break; - case MouseManager.ALT_SHIFT_LEFT: - // reserved -- constrained move? - return false; } return true; } Modified: trunk/Jmol/src/org/jmol/viewer/Eval.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Eval.java 2009-02-02 13:27:10 UTC (rev 10604) +++ trunk/Jmol/src/org/jmol/viewer/Eval.java 2009-02-02 16:21:51 UTC (rev 10605) @@ -8776,15 +8776,20 @@ } private void setPicking() throws ScriptException { + // set picking if (statementLength == 2) { setStringProperty("picking", "identify"); return; } + // set picking @{"xxx"} or some large length, ignored if (statementLength > 4 || tokAt(2) == Token.string) { setStringProperty("picking", stringSetting(2, false)); return; } int i = 2; + // set picking select ATOM|CHAIN|GROUP|MOLECULE|MODEL|SITE + // set picking measure ANGLE|DISTANCE|TORSION + // set picking spin fps String type = "SELECT"; switch (getToken(2).tok) { case Token.select: @@ -8802,6 +8807,15 @@ default: checkLength(3); } + + // set picking on + // set picking normal + // set picking identify + // set picking off + // set picking select + // set picking bonds + // set picking dragselected + String str = parameterAsString(i); switch (getToken(i).tok) { case Token.on: @@ -8818,7 +8832,8 @@ str = "bond"; break; } - if (JmolConstants.getPickingMode(str) < 0) + int mode = JmolConstants.getPickingMode(str); + if (mode < 0) error(ERROR_unrecognizedParameter, "SET PICKING " + type, str); setStringProperty("picking", str); } Modified: trunk/Jmol/src/org/jmol/viewer/Jmol.properties =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Jmol.properties 2009-02-02 13:27:10 UTC (rev 10604) +++ trunk/Jmol/src/org/jmol/viewer/Jmol.properties 2009-02-02 16:21:51 UTC (rev 10605) @@ -3,6 +3,11 @@ version=11.7.24_dev +# new feature: set picking dragSelected (preliminary) +# +# ALT_LEFT highlights atoms and rotates them +# ALT_SHIFT_LEFT highlights atoms and translates them + # bug fix: set picking draw can lose focus during drag operation # ----------------------------------------------------------------------------- Modified: trunk/Jmol/src/org/jmol/viewer/JmolConstants.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/JmolConstants.java 2009-02-02 13:27:10 UTC (rev 10604) +++ trunk/Jmol/src/org/jmol/viewer/JmolConstants.java 2009-02-02 16:21:51 UTC (rev 10605) @@ -274,12 +274,14 @@ public final static int PICKING_MEASURE_ANGLE = 17; public final static int PICKING_MEASURE_TORSION = 18; public final static int PICKING_NAVIGATE = 19; + public final static int PICKING_DRAGSELECTED = 20; private final static String[] pickingModeNames = { "off", "identify", "label", "center", "draw", "spin", "coord NOT IMPLEMENTED", "bond NOT IMPLEMENTED", "atom", "group", "chain", "molecule", "site", "element", - "drag", "measure", "distance", "angle", "torsion", "navigate" + "drag", "measure", "distance", "angle", "torsion", "navigate", + "dragselected" }; public final static String getPickingModeName(int pickingMode) { Modified: trunk/Jmol/src/org/jmol/viewer/MouseManager.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/MouseManager.java 2009-02-02 13:27:10 UTC (rev 10604) +++ trunk/Jmol/src/org/jmol/viewer/MouseManager.java 2009-02-02 16:21:51 UTC (rev 10605) @@ -35,25 +35,38 @@ public abstract class MouseManager implements KeyListener { - Viewer viewer; + protected Viewer viewer; - Thread hoverWatcherThread; + protected Thread hoverWatcherThread; - int previousDragX, previousDragY; - int xCurrent = -1000; - int yCurrent = -1000; - long timeCurrent = -1; + private int previousDragX, previousDragY; + protected int xCurrent = -1000; + protected int yCurrent = -1000; + protected long timeCurrent = -1; - boolean drawMode = false; - boolean measuresEnabled = true; - MeasurementPending measurementPending; + private boolean drawMode = false; + private boolean dragSelectedMode = false; + private boolean measuresEnabled = true; + private MeasurementPending measurementPending; - boolean hoverActive = false; + private boolean hoverActive = false; private boolean rubberbandSelectionMode = false; - int xAnchor, yAnchor; - final static Rectangle rectRubber = new Rectangle(); + private int xAnchor, yAnchor; + private final Rectangle rectRubber = new Rectangle(); + private int previousClickX, previousClickY; + private int previousClickModifiers, previousClickCount; + private long previousClickTime; + + private int previousPressedX, previousPressedY; + private int previousPressedModifiers; + private long previousPressedTime; + private int pressedCount; + + protected int mouseMovedX, mouseMovedY; + protected long mouseMovedTime; + abstract boolean handleOldJvm10Event(Event e); MouseManager(Viewer viewer) { @@ -197,17 +210,9 @@ final static int SHIFT_RIGHT = SHIFT | RIGHT; final static int CTRL_SHIFT_RIGHT = CTRL | SHIFT | RIGHT; final static int CTRL_ALT_SHIFT_RIGHT = CTRL | ALT | SHIFT | RIGHT; - public final static int BUTTON_MODIFIER_MASK = CTRL | ALT | SHIFT | LEFT + private final static int BUTTON_MODIFIER_MASK = CTRL | ALT | SHIFT | LEFT | MIDDLE | RIGHT; - int previousPressedX, previousPressedY; - int previousPressedModifiers; - long previousPressedTime; - int pressedCount; - - int mouseMovedX, mouseMovedY; - long mouseMovedTime; - void mouseMoved(long time, int x, int y, int modifiers) { hoverOff(); if (hoverWatcherThread == null) @@ -262,8 +267,8 @@ previousPressedTime = timeCurrent = time; //viewer.setStatusUserAction("mousePressed: " + modifiers); - - switch (modifiers & BUTTON_MODIFIER_MASK) { + modifiers &= BUTTON_MODIFIER_MASK; + switch (modifiers) { /**************************************************************** * mth 2004 03 17 * this isPopupTrigger stuff just doesn't work reliably for me @@ -284,6 +289,8 @@ case ALT_SHIFT_LEFT: if (drawMode) viewer.checkObjectDragged(Integer.MIN_VALUE, 0, x, y, modifiers); + else if (dragSelectedMode && modifiers != SHIFT_LEFT) + viewer.moveSelected(Integer.MIN_VALUE, 0, x, y, false); break; } } @@ -310,27 +317,25 @@ yCurrent = y; viewer.setInMotion(false); viewer.setCursor(Viewer.CURSOR_DEFAULT); - if (rubberbandSelectionMode - && ((modifiers & BUTTON_MODIFIER_MASK) == SHIFT_LEFT)) { + modifiers &= BUTTON_MODIFIER_MASK; + if (rubberbandSelectionMode && modifiers == SHIFT_LEFT) { viewer.selectRectangle(rectRubber, modifiers); viewer.refresh(3, "mouseReleased"); } rubberbandSelectionMode = false; rectRubber.x = Integer.MAX_VALUE; - if (drawMode) - switch (modifiers & BUTTON_MODIFIER_MASK) { - case ALT_LEFT: - case SHIFT_LEFT: - case ALT_SHIFT_LEFT: + switch (modifiers) { + case ALT_LEFT: + case SHIFT_LEFT: + case ALT_SHIFT_LEFT: + if (drawMode) viewer.checkObjectDragged(Integer.MAX_VALUE, 0, x, y, modifiers); - break; - } + else if (dragSelectedMode && modifiers != SHIFT_LEFT) + viewer.moveSelected(Integer.MAX_VALUE, 0, x, y, false); + break; + } } - int previousClickX, previousClickY; - int previousClickModifiers, previousClickCount; - long previousClickTime; - void clearClickCount() { previousClickX = -1; } @@ -354,12 +359,14 @@ previousClickModifiers = modifiers; previousClickCount = clickCount; timeCurrent = previousClickTime = time; + modifiers &= BUTTON_MODIFIER_MASK; if (viewer.haveModelSet()) checkPointOrAtomClicked(x, y, modifiers, clickCount); } void setMouseMode() { drawMode = false; + dragSelectedMode = false; rubberbandSelectionMode = (viewer.getPickingStyle() == JmolConstants.PICKINGSTYLE_SELECT_DRAG); measuresEnabled = true; switch (viewer.getPickingMode()) { @@ -369,6 +376,10 @@ drawMode = true; measuresEnabled = false; break; + case JmolConstants.PICKING_DRAGSELECTED: + dragSelectedMode = true; + measuresEnabled = false; + break; //other cases here? case JmolConstants.PICKING_LABEL: case JmolConstants.PICKING_MEASURE_DISTANCE: @@ -406,7 +417,7 @@ case 1: // mouse single click setMouseMode(); - switch (modifiers & BUTTON_MODIFIER_MASK) { + switch (modifiers) { case LEFT: if (viewer.frankClicked(x, y)) { viewer.popupMenu(-x, y); @@ -436,7 +447,7 @@ case 2: // mouse double click setMouseMode(); - switch (modifiers & BUTTON_MODIFIER_MASK) { + switch (modifiers) { case LEFT: if (measurementPending != null) { addToMeasurement(nearestAtomIndex, nearestPoint, true); @@ -466,10 +477,11 @@ xCurrent = previousDragX = x; yCurrent = previousDragY = y; + modifiers &= BUTTON_MODIFIER_MASK; switch (pressedCount) { case 2: //viewer.setStatusUserAction("mouseDoublePressDrag: " + modifiers); - switch (modifiers & BUTTON_MODIFIER_MASK) { + switch (modifiers) { case SHIFT_LEFT: case ALT_LEFT: case MIDDLE: @@ -483,12 +495,17 @@ } return; case 1: - switch (modifiers & BUTTON_MODIFIER_MASK) { + switch (modifiers) { case LEFT: checkMotion(); viewer.rotateXYBy(deltaX, deltaY); return; case ALT_LEFT: + if (dragSelectedMode) { + checkMotion(); + viewer.moveSelected(deltaX, deltaY, x, y, false); + return; + } if (viewer.allowRotateSelected()) { checkMotion(); viewer.rotateMolecule(deltaX, deltaY); @@ -501,6 +518,10 @@ viewer.checkObjectDragged(previousDragX, previousDragY, x, y, modifiers); return; + } else if (dragSelectedMode && modifiers == ALT_SHIFT_LEFT) { + checkMotion(); + viewer.moveSelected(deltaX, deltaY, x, y, true); + return; } else if (rubberbandSelectionMode) { calcRectRubberBand(); viewer.refresh(3, "mouse-drag selection"); Modified: trunk/Jmol/src/org/jmol/viewer/Viewer.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Viewer.java 2009-02-02 13:27:10 UTC (rev 10604) +++ trunk/Jmol/src/org/jmol/viewer/Viewer.java 2009-02-02 16:21:51 UTC (rev 10605) @@ -6728,6 +6728,33 @@ refreshMeasures(); } + synchronized void moveSelected(int deltaX, int deltaY, int x, int y, boolean isTranslation) { + if (isJmolDataFrame()) + return; + BitSet bsSelected = selectionManager.bsSelection; + if (deltaX == Integer.MIN_VALUE) { + setSelectionHalos(true); + return; + } + if (deltaX == Integer.MAX_VALUE) { + setSelectionHalos(false); + return; + } + if (isTranslation) { + Point3f ptCenter = getAtomSetCenter(bsSelected); + Point3i pti = transformPoint(ptCenter); + Point3f pt = new Point3f(pti.x + deltaX, pti.y + deltaY, pti.z); + unTransformPoint(pt, pt); + pt.sub(ptCenter); + modelSet.setAtomCoordRelative(pt, bsSelected); + } else { + transformManager.setRotateMolecule(true); + transformManager.rotateXYBy(deltaX, deltaY, bsSelected); + transformManager.setRotateMolecule(false); + } + refreshMeasures(); + } + void rotateAtoms(Matrix3f mNew, Matrix3f matrixRotate, boolean fullMolecule, Point3f center, boolean isInternal, BitSet bsAtoms) { modelSet.rotateAtoms(mNew, matrixRotate, bsAtoms, fullMolecule, center, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |