From: John Stone (johns_at_ks.uiuc.edu)
Date: Thu May 26 2016 - 11:19:50 CDT

This is a version of a script I wrote as an example eons ago.
You need to run the "enabletrace" proc to cause the counter to be drawn,
and then when finished, you should run "disabletrace".

The "drawcounter" proc does the work of actually drawing, so that is the
part you would generally customize. I should note that if you make any
mistakes in your code in "drawcounter" the general behavior in callbacks is
that they will silently fail. If you want to debug a broken callback, you
will want to use a try/catch block or extensive use of "puts" until it works.

Cheers,
  John Stone
  vmd_at_ks.uiuc.edu

On Fri, May 27, 2016 at 12:08:23AM +0800, sunyeping wrote:
> Dear all,
> I am trying to show the simulation time on a MD movie and I find a script
> that probably does this job in the mail list (written by Peter C. Lai):
> ------------------------
> proc enabletrace {} {
> global vmd_frame;
> trace variable vmd_frame([molinfo top]) w drawcounter
> }
> proc disabletrace {} {
> global vmd_frame;
> trace vdelete vmd_frame([molinfo top]) w drawcounter
> }
> proc drawcounter { name element op } {
> global vmd_frame;
> draw delete all
> # puts "callback!"
> draw color white
> set psperframe 4
> set psoffset 0
> set time [format "%d ps" [expr ($vmd_frame([molinfo top]) * $psperframe)
> + $psoffset]]
> draw text {70 40 80 } "$time"
> }
> -------------------------
> But I don't know how to use it. I sourced it in the VMD Console, the time
> was shown; After that I made the movie, and the time wasn't shown yet.
> Could someone help me with this?
> Best regards.

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