|
From: Jacques B. <jac...@no...> - 2004-12-20 08:51:52
|
Hello Ethan, Thanks for your answer. So if I understand well, several X11 terminals may be displayed but only the last one is really _alive_, ie will react properly to mouse events (pause command triggering, zooming, etc.). With the other X11 terminals, you can only: - resize the window - have the current mouse coordinates displayed (but not with a configurable format) If there were a way to trigger the pause command from a non-active X11 terminal (and then to know its id), it would be possible to activate it (by replotting it). So right now, I can't display several graphs each in an _interactive_ X11 terminal. I use a single X11 terminal to view several graphs one by one, and I switch between them with the keyboard: n=1 nplots=... load dem.n bind Home "n=1; load dem.n" bind End "n=nplots; load dem.n" bind PageDown "n=n+1; if(n>nplots)n=1; load dem.n; else load dem.n" bind PageUp "n=n-1; if(n<1)n=nplots; load dem.n; else load dem.n" pause -1 |
|
From: Hans-Bernhard B. <br...@ph...> - 2004-12-20 13:31:16
|
On Mon, 20 Dec 2004, Jacques Bouchard wrote: > Hello Ethan, > Thanks for your answer. > > So if I understand well, several X11 terminals may be displayed but only > the last one is really _alive_, ie will react properly to mouse events > (pause command triggering, zooming, etc.). With the other X11 terminals, > you can only: > - resize the window > - have the current mouse coordinates displayed (but not with a > configurable format) > > If there were a way to trigger the pause command from a non-active X11 > terminal (and then to know its id), it would be possible to activate it > (by replotting it). Not by replotting. The entire information needed to do that replot is lost after you make some other plot. The bottleneck is not the window state, or its connection to gnuplot, but the fact that the gnuplot core engine itself doesn't have a way of controlling more than one plot at a time. I.e. you can't regenerate any other plot than the most recent one by 'replot' --- you have to re-run the entire script that generates it. -- Hans-Bernhard Broeker (br...@ph...) Even if all the snow were burnt, ashes would remain. |
|
From: Jacques B. <jac...@no...> - 2004-12-20 14:23:34
|
> Not by replotting ... you have to re-run the entire script that generates it. Yes. When I said "replotting", I didn't mean using the command "replot". |
|
From: Ethan M. <merritt@u.washington.edu> - 2004-12-21 02:32:32
|
On Monday 20 December 2004 12:49 am, Jacques Bouchard wrote:
> If there were a way to trigger the pause command from a non-active X11
> terminal (and then to know its id), it would be possible to activate it
> (by replotting it).
It would be possible to pass back keypress events from keys set with
the "bind" command, including a parameter that contains the id of the
window in which the key was pressed. Using that parameter in the
bound command would be a bit tricky, however.
Hmmmm.
Would it be sufficient to reserve a variable for this returned window id
parameter? Then your bind command would look something like this:
bind End 'n = sprintf("%d",MOUSE_WINDOW_ID); set term x11 MOUSE_WINDOW_ID;
load "plot.".n'
There are probably a number of things that will cause this to fail in
the current code, but I think they could all be made to work.
--
Ethan A Merritt
Biomolecular Structure Center
University of Washington 98195-7742
|
|
From: Jacques B. <jac...@no...> - 2004-12-21 18:34:02
|
Ethan Merritt <merritt <at> u.washington.edu> writes: > Would it be sufficient to reserve a variable for this returned window id > parameter? Then your bind command would look something like this: > > bind End 'n = sprintf("%d",MOUSE_WINDOW_ID); set term x11 MOUSE_WINDOW_ID; > load "plot.".n' That would be great. BTW this script, executed as a _batch_, exits (should it?) if you press 'Right': n=1; set term x11 n; plot x**n n=2; set term x11 n; plot x**n bind Right "n=3-n; set term x11 n; plot x**n" pause -1 but this one doesn't: n=1; plot x**n bind Right "n=3-n; plot x**n" pause -1 |
|
From: Ethan M. <merritt@u.washington.edu> - 2004-12-23 05:01:35
|
On Tuesday 21 December 2004 10:33 am, Jacques Bouchard wrote: > Ethan Merritt <merritt <at> u.washington.edu> writes: > > Would it be sufficient to reserve a variable for this returned window > > id parameter? > That would be great. Please try out patchset #1090199 on SourceForge. It defines a new command option: bind all <key> "command string" "bind all" causes this binding to apply to all existing plot windows, active or not. When <key> is pressed in any plot window, the corresponding window ID is returned in MOUSE_KEY_WINDOW and "command string" is executed. So your example case would become bind all PageUp 'set term x11 MOUSE_KEY_WINDOW; \ load "dem.".MOUSE_KEY_WINDOW' Now PageUp should refresh the specific plot assigned to the window you typed it in. Please let me know how it works for your application, and if you have any ideas for improving it. -- Ethan A Merritt Biomolecular Structure Center University of Washington 98195-7742 |
|
From: Jacques B. <jac...@no...> - 2004-12-28 22:13:16
|
Ethan Merritt wrote: > Please try out patchset #1090199 on SourceForge. > It defines a new command option: > bind all <key> "command string" Thank you very much for your _quick_ answer. I consider this patch as a _big_ step forward. > Please let me know how it works for your application, > and if you have any ideas for improving it. It works well. There is just one thing that could be improved. As I said in my last message, in batch mode, each time a binded key is pressed, a "pause -1" is eaten if the binded command contains: set terminal x11 Doesn't that prevent you to reactivate a x11 terminal as many times as you wish with the "bind all" technique? Is it possible to correct that seemingly wrong behavior? A further step forward would be to allow the user to "bind all" mouse events. For example, a left button press is unused for 2D graphs, and would be a very natural way to reactivate a x11 terminal. But of course that is not essential and probably not worth a difficult patch. Thank you again. |
|
From: Ethan M. <merritt@u.washington.edu> - 2005-01-03 20:18:09
|
On Tuesday 28 December 2004 02:10 pm, Jacques Bouchard wrote: > > It works well. There is just one thing that could be improved. As I said > in my last message, in batch mode, each time a binded key is pressed, a > "pause -1" is eaten if the binded command contains: > > set terminal x11 > > Doesn't that prevent you to reactivate a x11 terminal as many times as > you wish with the "bind all" technique? Is it possible to correct that > seemingly wrong behavior? This may be very difficult. But if I understood better what your application needs to do, maybe I could suggest or create a way around the problem. When you say "batch mode" do you mean: gnuplot inputfile.dat or gnuplot < inputfile.dat or gnuplot gnuplot> load "inputfile.dat" or something else I haven't thought of? For me, the 1st and 3d methods work as expected, but the 2nd method does not. If you must use the 2nd method, perhaps you could use a loop-until-ready construct like this? main script: set mouse n=1; set term x11 n; plot x**n n=2; set term x11 n; plot x**n bind all Home "n=MOUSE_KEY_WINDOW; set term x11 n; plot x**n" bind all End "DONE = 1" DONE = 0 print "Hit <End> in any plot window to continue" load "wait_for_End" File wait_for_End would contain two lines: pause -1 if (!DONE) reread Or maybe it would have to be "pause mouse key" or "pause 1" or I don't know exactly what would fit in with your intended use. > A further step forward would be to allow the user to "bind all" mouse > events. For example, a left button press is unused for 2D graphs, and > would be a very natural way to reactivate a x11 terminal. But of course > that is not essential and probably not worth a difficult patch. > > Thank you again. > -- Ethan A Merritt merritt@u.washington.edu Biomolecular Structure Center Mailstop 357742 University of Washington, Seattle, WA 98195 |
|
From: Jacques B. <jac...@no...> - 2005-01-04 22:51:04
|
Ethan Merritt wrote: > When you say "batch mode" do you mean: > gnuplot inputfile.dat > or > gnuplot < inputfile.dat > or > gnuplot > gnuplot> load "inputfile.dat" I mean the 1st method. > For me, the 1st and 3d methods work as expected, but the > 2nd method does not. Hmmm. > If you must use the 2nd method, > perhaps you could use a loop-until-ready construct like this? > > main script: > set mouse > n=1; set term x11 n; plot x**n > n=2; set term x11 n; plot x**n > bind all Home "n=MOUSE_KEY_WINDOW; set term x11 n; plot x**n" > bind all End "DONE = 1" > DONE = 0 > print "Hit <End> in any plot window to continue" > load "wait_for_End" > > File wait_for_End would contain two lines: > pause -1 > if (!DONE) reread That fits exactly my need. Nice thing to write in a gnuplot HOWTO. And how do you do it with the 1st method? |
|
From: Ethan M. <merritt@u.washington.edu> - 2005-01-06 00:46:29
|
On Tuesday 04 January 2005 02:50 pm, Jacques Bouchard wrote: > > > > File wait_for_End would contain two lines: > > pause -1 > > if (!DONE) reread > > That fits exactly my need. I am glad to hear that it works for your application. It is a bit ugly, however, since it burns a lot of CPU cycles in that wait loop (the "pause -1" returns immediately, as you already know, and so the loop is very tight). I hope someone can think of a better way. > Nice thing to write in a gnuplot HOWTO. One thing at a time. I think there is more work to do on this patchset before it is ready for documentation and inclusion in the main source tree. I do not understand the details of what goes wrong with the "pause" command in your example, and without understanding it is hard to develop a fix. -- Ethan A Merritt merritt@u.washington.edu Biomolecular Structure Center Mailstop 357742 University of Washington, Seattle, WA 98195 |
|
From: Jacques B. <jac...@no...> - 2005-01-06 07:37:35
|
Ethan Merritt wrote: > It is a bit ugly, however, since it burns a lot of CPU > cycles in that wait loop (the "pause -1" returns immediately, > as you already know, and so the loop is very tight). > ... I do not understand > the details of what goes wrong with the "pause" command > in your example, and without understanding it is hard to > develop a fix. Yes, the behavior of your "gnuplot<inputfile.dat" example fits exactly my need but its heavy CPU use is not acceptable. So I tried it in the "gnuplot inputfile.dat" way, but then it doesn't work so well: the application has to be terminated with both End and then Return in the launch terminal (only one method should be used). So, as you say that there is no problem with the pause command in that way, I hoped that you would show me how to modify this example so as to use it with "gnuplot inputfile.dat", and get the same behavior without the CPU use. Thanks again for your help. |
|
From: Ethan M. <merritt@u.washington.edu> - 2005-01-07 05:31:59
|
I suddenly realized that I have been thinking of this in the wrong way, and misinterpreting what is happening. Including "set term foo" in a key binding has nothing to do with it. The command "gnuplot < myscriptfile" resets stdin to a piped copy of the file myscriptfile. But now "pause -1" makes no sense, because it says to wait for the next input on stdin, and we know that stdin will keep on feeding characters from myscriptfile until it runs off the end. That's why it returns immediately in your original test case. OK, so we can't use "pause -1". The obvious replacement is "pause mouse key". And this almost works, but not quite. The glitch is that currently "pause mouse key" (a) only works in the active window, and (b) overrides all key bindings Both of these are fixable. So I have uploaded a new version of the patchset that changes gnuplot behaviour as follows: - "bind all <key> foo" causes that key to be terminate a "pause mouse key" even if it is typed in an inactive window - key bindings are evaluated *before* checking for "pause mouse key", so if you terminate the pause by hitting a key with a binding, the binding executes first With this revised version I think you can do everything you wanted. Here are my test files: bindall.dem: set mouse n=1; set term x11 n; plot x**n n=2; set term x11 n; plot x**n bind all Home 'n=MOUSE_KEY_WINDOW; set term x11 n; plot x**n' bind all End 'DONE = 1' bind all s 'show variable' DONE = 0 print "Hit <End> in any plot window to continue" load "wait_for_End" # print "Now I am done" wait_for_End: pause mouse key if (!DONE) print "Saw key in window ",MOUSE_KEY_WINDOW," but not yet done" if (!DONE) reread These scripts work as intended for either gnuplot < bindall.dem or gnuplot gnuplot> load 'bindall.dem' There is still something out of sync if you say gnuplot bindall.dem As before, please let me know if more, or different, functionality is ideally needed for your full application. -- Ethan A Merritt Biomolecular Structure Center University of Washington 98195-7742 |
|
From: Jacques B. <jac...@no...> - 2005-01-07 21:13:49
|
Ethan Merritt <merritt <at> u.washington.edu> writes: > With this revised version I think you can do everything you > wanted. Here are my test files: > ... > As before, please let me know if more, or different, functionality > is ideally needed for your full application. There is just one problem: you can't zoom with the mouse any longer (and that is one of the reasons why I wanted to reactivate my x11 plots). Thanks again for your help. |
|
From: Jacques B. <jac...@no...> - 2005-01-07 22:12:36
|
Ethan Merritt wrote: > Both of these are fixable. So I have uploaded a new version > of the patchset ... > With this revised version I think you can do everything you > wanted ... > As before, please let me know if more, or different, functionality > is ideally needed for your full application. There is still a problem: you can't zoom with the mouse any longer (and that's one of the reasons why I wish to reactivate my x11 terminals). Thanks again for your help. |
|
From: Ethan M. <merritt@u.washington.edu> - 2005-01-07 22:16:27
|
On Friday 07 January 2005 02:12 pm, Jacques Bouchard wrote: > There is still a problem: you can't zoom with the mouse any longer (and > that's one of the reasons why I wish to reactivate my x11 terminals). Are you sure? Zoom works for me, although there is the confusion that whatever range you zoom into then becomes the default for the next replot command, whichever plot window it may belong to. If you tell me the precise sequence of operations that leads to non-functional zoom, I will try to reproduce it. -- Ethan A Merritt merritt@u.washington.edu Biomolecular Structure Center Mailstop 357742 University of Washington, Seattle, WA 98195 |