Search code examples
gnuplot

gnuplot: How to keep windows terminal in background when calling from C++?


In gnuplot I can output the mouse position after a click with MOUSE_X and MOUSE_Y. I also found equations that should calculate fractional screen coordinates from them (in gnuplot help under gnuplot-defined variables). But that does not work for me, I get values > 1.0 and < 0.0. Maybe it is because I am using splot, drawing a 3D surface? How can I do it in this case? Is there a gnuplot built-in way to get the screen x and y values?

Update with wider picture:
I feed gnuplot from a C++ program using a pipe. The data is a 3D surface for which the C++ program iteratingly calculates various points and plots these along with the surface in intervals of 1s. The purpose is to visualize the algorithm. So all data and calculations come from the C++ program, gnuplot is only for displaying the surface and points.
Now I would like to give an input into the program to control the program flow like stop the program, change some parameters of the surface or of the calculation. Currently I have a console where I can do inputs. For this I need to change the focus to the console and type in the right moment because the next plot action puts the focus back to gnuplot. So it would be more comfortable to do it from the plot. I thought to draw kind of buttons that you can click. When clicked the following user interaction like entering parameter values can be in the console if that is not possible with gnuplot.


Solution

  • Since you are using terminal windows, maybe the following helps to avoid that the focus is on the terminal after plotting. I don't know if wxt or qt terminals have a similar option.

    From help windows:

    Bring to Top when checked raises the graph window to the top after every plot.

    So, try unchecking: Menubar | Options | "Bring to top"

    At least when plotting or updating a plot from the gnuplot console, the focus will not go to the graph window. Maybe it does the same when plotted from C++. I don't know. Please test.

    enter image description here