From: John Stone (johns_at_ks.uiuc.edu)
Date: Sun Apr 30 2006 - 09:16:26 CDT

Yes, and for what you have in mind, you may find it easier to hack the code
that implements the silent atom picking. From your previous description,
it sounds to me like you don't even need the absolute mouse position anyway,
and that what you really need is the distance from the nearest atom so you
can start affecting the mouse behavior. For that sort of thing,
hacking the source may indeed be necessary. While one could do the
unprojection etc in Tcl with the various transformation matrices, you'll
have more access to various information in the C/C++ code, and of course
it'd be faster/more responsive.

  John

On Sun, Apr 30, 2006 at 02:03:07AM -0400, Chang Hu wrote:
> Thanks John,
>
> You really helped me out of here. I guess I can draw something to
> replace the mouse cursor from here. However I have one more problem:
>
> From mouse position, could one determine which atom it's close to? I
> guess it needs an unprojection back to the 3D spece where the molecule
> is in.
>
> Chang
>
>
> John Stone wrote:
>
> >Hi,
> > What you want is to use the new 'mouse mode userpoint' and the
> >vmd_mouse_pos callback, like this:
> >
> >proc do_mouse_pos_client { args } {
> > global vmd_mouse_pos
> > puts "mouse position: $vmd_mouse_pos"
> >}
> >
> >trace add variable vmd_mouse_pos write do_mouse_pos_client
> >mouse mode userpoint
> >
> >
> >
> >On Sat, Apr 29, 2006 at 10:05:37PM -0400, Chang Hu wrote:
> >
> >
> >>John,
> >>
> >>I went through the user's guide and succeeded in tracing the
> >>"vmd_pick_mol_silent", resulting in outputing some messae when one
> >>molecule is picked. However, I tried "vmd_pick_client" hoping it will
> >>output the same message whenever the cursor is moved, but with no luck.
> >>In short, I have several problems:
> >>
> >>1. How to obtain the mouse position whenever it's moved?
> >>2. How to determine if the mouse is near some atom?
> >>
> >>I went through the programmer's guide and got something that returns the
> >>mouse's x and y position, but that's in source code, I still don't know
> >>how to get it via the Tcl script.
> >>
> >>Thanks,
> >>Chang
> >>
> >>John Stone wrote:
> >>
> >>
> >>
> >>>Chang,
> >>>That could probably be made to work by disabling the system's mouse
> >>>cursor while your code is active, and querying the mouse position etc
> >>>for yourself. You might be able to prototype this for yourself very
> >>>quickly with VMD 1.8.4 by using the new mouse position callback and
> >>>writing some simple scripts to test the idea on a tiny molecule.
> >>>(no need to recompile the code even)
> >>>You could render the cursor with graphics/draw commands and redraw for
> >>>every mouse position update. If you like I can give you more suggestions
> >>>about this tomorrow when I have a bit more time to talk. For now, you
> >>>might look at the User's Guide section on callbacks, and the Tcl 'trace'
> >>>command. From there you can user the new position callback and the new
> >>>userpoint mouse mode. (see mouse command)
> >>>If you wanted to hack the source code directly rather than prototyping
> >>>in scripting, then you'll need to pick your favorite display device
> >>>subclass
> >>>and disable the mouse cursor and add cursor rendering there,
> >>>followed by edits to Mouse.C for the new behavior, or something like
> >>>that.
> >>>
> >>>John Stone
> >>>vmd_at_ks.uiuc.edu
> >>>
> >>>On Thu, Apr 27, 2006 at 01:36:23PM -0400, Chang Hu wrote:
> >>>
> >>>
> >>>
> >>>
> >>>>Thanks a lot, John,
> >>>>
> >>>>In that case I'd want to render a cursor inside VMD display because in
> >>>>our system the display of a system window and OpenGL rendering are on
> >>>>seperate screens. Is there any way to do that? I'd imagine getting the
> >>>>mouse movement from the OS and rendering a cursor for each frame
> >>>>rendered. I am not sure if I can creat a Displayable object and if it's
> >>>>the easiest way...
> >>>>
> >>>>Chang
> >>>>
> >>>>
> >>>>John Stone wrote:
> >>>>
> >>>>
> >>>>
> >>>>
> >>>>
> >>>>>Hi,
> >>>>>VMD doesn't actually directly manipulate the mouse cursor position,
> >>>>>this is done completely by the host operating system. The farthest VMD
> >>>>>goes in that direction is to set the active mouse cursor style, among
> >>>>>the
> >>>>>choices available on the host operating system. This is the reason
> >>>>>you haven't
> >>>>>found any code of that sort in VMD. All of the important mouse
> >>>>>behavior
> >>>>>code is contained in Mouse.C, with the lowest level mouse I/O calls
> >>>>>found
> >>>>>in each of the DisplayDevice subclasses for OpenGL, Win32 OpenGL, FLTK,
> >>>>>CAVE, and FreeVR. I'm not even sure there's a means of altering the
> >>>>>mouse acceleration by application control in most windowing systems.
> >>>>>There may be a way to do this on some, but I'm sure you'll find that
> >>>>>to be a difficult thing to write portable code for, if it's even
> >>>>>possible.
> >>>>>John Stone
> >>>>>vmd_at_ks.uiuc.edu
> >>>>>
> >>>>>On Thu, Apr 27, 2006 at 12:19:57AM -0400, Chang Hu wrote:
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>>Hi,
> >>>>>>
> >>>>>>I am trying to implement enhanced picking in VMD. To do this, I am
> >>>>>>planning to decrease the mouse speed whenever it's near an atom,
> >>>>>>according to the distance between the mouse cursor and the atom. I
> >>>>>>looked into the Programmer's Guide and had no luck finding related
> >>>>>>source code. (I guess I need the part where the mouse cursor is
> >>>>>>rendered.) Could anybody help me out with this?
> >>>>>>
> >>>>>>Thanks,
> >>>>>>Chang
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>
> >>>
> >>>
> >
> >
> >

-- 
NIH Resource for Macromolecular Modeling and Bioinformatics
Beckman Institute for Advanced Science and Technology
University of Illinois, 405 N. Mathews Ave, Urbana, IL 61801
Email: johns_at_ks.uiuc.edu                 Phone: 217-244-3349
  WWW: http://www.ks.uiuc.edu/~johns/      Fax: 217-244-6078