Hi Bob,

Am 21.01.2012 um 13:28 schrieb Robert Hanson:

> 
> 
> On Fri, Jan 20, 2012 at 1:27 PM, Alexander Rose <alexander.r...@weirdbyte.de> 
> wrote:
> Hi Bob,
> 
> here is what I tried:
> 
> bind "ALT-LEFT" "javascript jmol_center(_X, _Y, _picked);";
> bind "ALT-LEFT" "javascript jmol_center(_X, _Y, _atomPicked);";
> 
> _X and _Y are replaced with the screen coordinates where the click happened, 
> but _picked or _atomPicked are not replaced by anything. And 'jmol_center' is 
> just some javascript function which gets correctly called.
> 
> 
> right because it is not a pick, since you have bound it differently. I think 
> you would use this:
> 
> set picking ident
> unblind "ALT-LEFT"
> bind "ALT-LEFT" "_pickAtom"
> set pickCallback "myPickCallback"
> 
> For my tests, I used this, and it worked fine:
> 
> set pickCallback "jmolscript: set echo top left;echo @_pickinfo"

sure, but I don't see how this helps me to bind "ALT-LEFT" to 'center on atom' 
and "LEFT" to 'select atom'? When you do:

set picking ident
unbind "ALT-LEFT"
bind "ALT-LEFT" "_pickAtom"
unbind "LEFT"
bind "LEFT" "_pickAtom"

set pickCallback "myPickCallback"

The info available to the pickCallback does not include weather the "ALT" key 
was pressed or if the "LEFT" or the "RIGHT" mouse button was used. This way I 
can't distinguish between "ALT-LEFT" and "LEFT" to trigger the desired action 
'center on atom' or 'select atom'.

I created a small patch which does essentially what i want.

set picking SELECT GROUP
unbind "ALT-LEFT"
bind "ALT-LEFT" "_zoomTo"

While looking at the source code I found that there is an undocumented 
"_center" action, which changes the rotation center (I wanted to get the 
behavior of set picking CENTER, thats why I talked about 'center'). However the 
"_center" action gets only evaluated in the context of dragging, not for a 
click.

I would be happy if you could consider the patch for inclusion. I find it a bit 
inflexible as you can't change duration of the zoomTo command. However, the 
other two approaches (adding the pressed modifier key to the picking callback 
or adding the nearest atomindex to the bind callback) are, as far as I can see, 
more complicated.


Best
Alexander


### Eclipse Workspace Patch 1.0
#P Jmol
Index: src/org/jmol/viewer/ActionManager.java
===================================================================
--- src/org/jmol/viewer/ActionManager.java      (revision 16475)
+++ src/org/jmol/viewer/ActionManager.java      (working copy)
@@ -101,7 +101,8 @@
   public final static int ACTION_reset = 44;
   public final static int ACTION_stopMotion = 45;
   public final static int ACTION_multiTouchSimulation = 46;
-  public final static int ACTION_count = 47;
+  public final static int ACTION_zoomTo = 47;
+  public final static int ACTION_count = 48;
 
   private final static String[] actionInfo = new String[ACTION_count];
   private final static String[] actionNames = new String[ACTION_count];
@@ -159,6 +160,7 @@
     newAction(ACTION_reset,                 "_reset",                
GT._("reset (when clicked off the model)"));
     newAction(ACTION_stopMotion,            "_stopMotion",           
GT._("stop motion (requires {0})", "set waitForMoveTo FALSE"));
     newAction(ACTION_multiTouchSimulation,  "_multiTouchSimulation", 
GT._("simulate multi-touch using the mouse)"));
+    newAction(ACTION_zoomTo,                "_zoomTo",               
GT._("zoom to picked atom)"));
   }
 
   public static String getActionName(int i) {
@@ -1376,6 +1378,11 @@
         viewer.script("!reset");
       return false;
     }
+    if (isBound(action, ACTION_zoomTo)) {
+      if (nearestAtomIndex >= 0) {
+        viewer.script("zoomTo (atomindex=" + nearestAtomIndex + ")");
+      }
+    }
     return (nearestAtomIndex >= 0);
   }
 



> 
> 
>  
> 
> This does not work ether:
> 
> bind "ALT-LEFT" "print _X; print _Y; print _picked; print _pickedAtom;";
> 
> it just print _X and _Y.
> 
> Alex
> 
> 
> ----- Ursprüngliche Mail -----
> > Von: "Bob Hanson" <hans...@stolaf.edu>
> > An: jmol-users@lists.sourceforge.net
> > CC: jmol-users@lists.sourceforge.net
> > Gesendet: Freitag, 20. Januar 2012 18:20:38
> > Betreff: Re: [Jmol-users] bind command and picked atoms
> > _picked is a variable. I thought it was defined prior to the callback.
> >
> > Sent from my stupid iphone
> >
> > On Jan 20, 2012, at 10:35 AM, Alexander Rose
> > <alexander.r...@weirdbyte.de> wrote:
> >
> > > Hi all,
> > >
> > > when using Jmol I find myself using either 'set picking CENTER' or
> > > 'set picking SELECT GROUP', so I would like to switch as fast and
> > > easy as possible between the two modes via the mouse. My first idea
> > > was to use the 'bind' command to bind centering to "ALT-LEFT" and
> > > selecting a group to "LEFT". However there is no "_center"
> > > jmol-action for the bind command and the "_select" jmol-action seems
> > > not to work when 'set picking CENTER' is active. The bind command
> > > also allows to pass a jmol "script" instead of a jmol-action, but
> > > inside that passed script the information which atom was picked is
> > > not available so you can't center on it or select its group. There
> > > is also the pick callback, but this does not give you the modifier
> > > key that was pressed when the atom was picked.
> > >
> > > In my opinion the addition of a "_centerOnPickedAtom" jmol-action
> > > for the bind command would be useful. A more flexible solution would
> > > be to add a "_PICKED" variable (containing a selection of the picked
> > > atom; maybe also other pickable elements?!) to the things that gets
> > > replaced in a script passed to 'bind' command. Based on that
> > > variable it is straightforward to implement centering or selecting a
> > > group. What do you think? Would anyone else find this useful, too?
> > >
> > >
> > > Best
> > > Alexander
> > >
> > > ------------------------------------------------------------------------------
> > > Keep Your Developer Skills Current with LearnDevNow!
> > > The most comprehensive online learning library for Microsoft
> > > developers
> > > is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3,
> > > MVC3,
> > > Metro Style Apps, more. Free future releases when you subscribe now!
> > > http://p.sf.net/sfu/learndevnow-d2d
> > > _______________________________________________
> > > Jmol-users mailing list
> > > Jmol-users@lists.sourceforge.net
> > > https://lists.sourceforge.net/lists/listinfo/jmol-users
> >
> > ------------------------------------------------------------------------------
> > Keep Your Developer Skills Current with LearnDevNow!
> > The most comprehensive online learning library for Microsoft
> > developers
> > is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3,
> > MVC3,
> > Metro Style Apps, more. Free future releases when you subscribe now!
> > http://p.sf.net/sfu/learndevnow-d2d
> > _______________________________________________
> > Jmol-users mailing list
> > Jmol-users@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/jmol-users
> 
> ------------------------------------------------------------------------------
> Keep Your Developer Skills Current with LearnDevNow!
> The most comprehensive online learning library for Microsoft developers
> is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
> Metro Style Apps, more. Free future releases when you subscribe now!
> http://p.sf.net/sfu/learndevnow-d2d
> _______________________________________________
> Jmol-users mailing list
> Jmol-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/jmol-users
> 
> 
> 
> -- 
> Robert M. Hanson
> Professor of Chemistry
> St. Olaf College
> 1520 St. Olaf Ave.
> Northfield, MN 55057
> http://www.stolaf.edu/people/hansonr
> phone: 507-786-3107
> 
> 
> If nature does not answer first what we want,
> it is better to take what answer we get. 
> 
> -- Josiah Willard Gibbs, Lecture XXX, Monday, February 5, 1900
> ------------------------------------------------------------------------------
> Try before you buy = See our experts in action!
> The most comprehensive online learning library for Microsoft developers
> is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
> Metro Style Apps, more. Free future releases when you subscribe now!
> http://p.sf.net/sfu/learndevnow-dev2_______________________________________________
> Jmol-users mailing list
> Jmol-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/jmol-users

------------------------------------------------------------------------------
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
_______________________________________________
Jmol-users mailing list
Jmol-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jmol-users

Reply via email to